akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string S[60];
int vx[] = { 1,1,0,-1,-1,-1,0,1 };
int vy[] = { 0,1,1,1,0,-1,-1,-1 };
int main()
{
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++)cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int ans = 0;
			if (S[i][j] == '#') {
				cout << '#';
				continue;
			}
			for (int k = 0; k < 8; k++) {
				if (j + vx[k] >= 0 && j + vx[k] < W && i + vy[k] >= 0 && i + vy[k] < H) {
					if (S[i + vy[k]][j + vx[k]] == '#') ans++;
				}
			}
			cout << ans;
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
	bool operator<(const Edge& e)const{return weight<e.weight;}
	bool operator>(const Edge& e)const{return weight>e.weight;}
};
typedef vector<vector<Edge> > Graph;

struct UnionFind{
	vi data;
	UnionFind(int size):data(size,-1){}
	int Find(int n){
		return data[n]<0?n:(data[n]=Find(data[n]));
	}
	void Unite(int a,int b){
		int ra=Find(a),rb=Find(b);
		if(ra!=rb){
			if(-data[ra]<-data[rb])
				swap(ra,rb);
			data[ra]+=data[rb];
			data[rb]=ra;
		}
	}
	int Size(int n){
		return -data[Find(n)];
	}
};

int Kruskal(const Graph& g,vector<Edge>& forest)
{
	forest.clear();
	
	vector<Edge> es;
	rep(i,g.size()) rep(j,g[i].size())
		es.push_back(g[i][j]);
	sort(all(es));
	
	UnionFind uf(g.size());
	int res=0;
	rep(i,es.size())
		if(uf.Find(es[i].src)!=uf.Find(es[i].dst)){
			uf.Unite(es[i].src,es[i].dst);
			res+=es[i].weight;
			forest.push_back(es[i]);
		}
	return res;
}

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		Graph g(n);
		rep(i,m){
			int s,d,w; scanf("%d%d%d",&s,&d,&w);
			g[s].push_back(Edge(s,d,w));
			g[d].push_back(Edge(d,s,w));
		}
		
		vector<Edge> forest;
		int res=Kruskal(g,forest);
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 0
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=5*1e5+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;

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

////////////////////////////////////////////////////////////////////////////////////////////
void init(){
	
}
int A[SIZE];
LL solve(){
	cin >> N;
	int ans=0;
	REP(i,N){
		cin >> A[i];
		if(i && A[i]==A[i-1]){
			ans++;
			A[i]=-1;
		}
	}
	cout << ans << endl;
	return 0;
}
signed main(){
	solve();
	return 0;
}

Measured memory_bytes: 12928
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

struct UnionFind
{
    std::vector<std::size_t> _par;
    std::vector<std::size_t> _size;
    std::vector<std::size_t> _rank;

    UnionFind(std::size_t N)
        : _par(N)
        , _size(N, 1)
        , _rank(N, 0)
    {
        for (std::size_t i = 0; i < N; i++)
        {
            _par[i] = i;
        }
    }

    std::size_t Root(std::size_t x)
    {
        if (_par[x] == x)
        {
            return x;
        }
        return _par[x] = Root(_par[x]);
    }

    void Unite(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        if (rx != ry)
        {
            if (_rank[rx] < _rank[ry])
            {
                _par[rx] = ry;
                _size[ry] += _size[rx];
            }
            else
            {
                _par[ry] = rx;
                _size[rx] += _size[ry];
                if (_rank[rx] == _rank[ry])
                {
                    _rank[ry]++;
                }
            }
        }
    }

    size_t Size(std::size_t x) { return _size[Root(x)]; }

    bool Same(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        return rx == ry;
    }
};

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

    UnionFind uf(n + 1);
    vector<pair<int, int>> friends;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        uf.Unite(a, b);
        friends.emplace_back(a, b);
    }
    vector<int> result(n + 1);
    for (int i = 1; i <= n; i++)
    {
        result[i] = uf.Size(i) - 1;
    }

    for (int i = 0; i < k; i++)
    {
        int c, d;
        cin >> c >> d;
        if (uf.Same(c, d))
        {
            result[c]--;
            result[d]--;
        }
    }
    for (auto f : friends)
    {
        result[f.first]--;
        result[f.second]--;
    }

    for (int i = 1; i <= n; i++)
    {
        if (i > 1)
        {
            cout << " ";
        }
        cout << result[i];
    }
    cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll a;
	cin >> a;
	cout << (a + a*a + a*a*a) << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int k, n;
   cin >> k >> n;
   vector<int> a;
   int y;
   cin >> y;
   a.push_back(y);
   int max = y;
   int flag = 0;
   for (int i = 1; i < n; i++)
   {
      int x;
      cin >> x;
      a.push_back(x);
      if (x - a[i - 1] > max)
      {
         max = x - a[i-1];
         flag = i;
      }
   }
   if(k - a[n-1] + a[0] > max) {
      max = k-a[n-1]+a[0];
      flag = n-1;
   }
   cout << k-max << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  
  int64_t ans1 = 0;
  int64_t ans2 = 0;
  if(k%2 == 0){
    ans2 = n/(k/2);
  }
  
  ans1 = n/k;
  
  ans2 = ans2 - ans1;
  if(ans2 <= 0){
    ans2 = 0;
  }
  ans1 = ans1*ans1*ans1;
  ans2 = ans2*ans2*ans2;
  
  int64_t ans = ans1+ans2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b<=9)cout<<a+b<<endl;
    else cout<<"error"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  if (n % 7 == 0) {
    n = (n / 7) * 9;
  } else {
    n *= 9;
  }
  ll now = 10;
  int i = 1;
  ll ans = -1;
  for (; i < 1000001; i++) {
    if (now % n == 1) {
      ans = i;
      break;
    } else {
      now = (now % n) * 10;
    }
  }
  cout << ans << endl;
}

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

int a,b,c;

bool cek(int x, int y, int z){
	return (x%2==0) && (y%2==0) && (z%2==0);
}

int main(){
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<=1000;i++){
		if(!cek(a,b,c)){
			printf("%d\n",i);
			return 0;
		}
		int ta = (b/2)+(c/2);
		int tb = (a/2)+(c/2);
		int tc = (a/2)+(b/2);
		a = ta;
		b = tb;
		c = tc;
	}
	printf("-1\n");
	return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

const int inf = 1'000'000'007;

int calc(int x) {
  return x == 0 ? 0 : calc(x % __builtin_popcount(x)) + 1;
}

void solve() {
  int n;
  string s;
  cin >> n >> s;
  s = '0' + s;

  int cnt = count_if(s.begin(), s.end(), [](char x) {
    return x == '1';
  });

  vector<vector<int> > pw2(2, vector<int> (n + 1, 0));
  pw2[0][0] = pw2[1][0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (cnt > 1) {
      pw2[0][i] = (cnt <= 1 ? 0 : pw2[0][i - 1] * 2ll % (cnt - 1));
    }
    pw2[1][i] = pw2[1][i - 1] * 2ll % (cnt + 1);
  }

  vector<vector<int> > suff(2, vector<int> (n + 2, 0));
  for (int i = n; i >= 1; --i) {
    if (cnt > 1) {
      suff[0][i] = (suff[0][i + 1] + (s[i] == '1') * pw2[0][n - i]) % (cnt - 1);
    }
    suff[1][i] = (suff[1][i + 1] + (s[i] == '1') * pw2[1][n - i]) % (cnt + 1);
  }

  int cur0 = 0;
  int cur1 = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '0') {
      int val = (cur1 + pw2[1][n - i]) % (cnt + 1);
      val = (val + suff[1][i + 1]) % (cnt + 1);
      cout << calc(val) + 1 << "\n";
    } else {
      if (cnt == 1) {
        cout << "0\n";
      } else {
        int val = cur0 % (cnt - 1);
        val = (val + suff[0][i + 1]) % (cnt - 1);
        cout << calc(val) + 1 << "\n";
      }
      if (cnt > 1) {
        cur0 = (cur0 + pw2[0][n - i]) % (cnt - 1);
      }
      cur1 = (cur1 + pw2[1][n - i]) % (cnt + 1);
    }
  }
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while(t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 7340
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a = 1
b = 1
Pmin = sorted(P)
Qmin = sorted(Q)

for i in range(N-1) :
  Porder = Pmin.index(P[i])
  a += Porder * math.factorial(N - i - 1)
  Pmin.pop(Porder)

for i in range(N-1) :
  Qorder = Qmin.index(Q[i])
  b += Qorder * math.factorial(N - i - 1)
  Qmin.pop(Qorder)

ans = a-b

if a-b >= 0 :
  print(ans)
else :
  print(-1 * ans)

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

int main(){
   long long a,b,k,z=0; cin>>a>>b>>k;
   k=a-k;
   a=max(z,k);
   if(k<0) b=max(z,b+k);
   cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

long long rec(int n, long long x) {
    if (n == 0) return 1;
    long long len = (1LL<<(n+1)) - 3;
    long long num = (1LL<<n) - 1;
    if (x == 1) return 0;
    else if (x <= len + 1) return rec(n-1, x-1);
    else if (x == len + 2) return num + 1;
    else if (x <= (len + 1) * 2) return num + 1 + rec(n-1, x-len-2);
    else return num * 2 + 1;
}

int main() {
    int N; long long X; cin >> N >> X;
    cout << rec(N, X) << endl;
}

Measured memory_bytes: 256
#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, t;
    cin >> a >> b >> t;
    int ans = t / a;
    ans *= b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
k = int(input())
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[k-1])

Measured memory_bytes: 3060
import java.util.*;

public class Main {
 
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String upperCases = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    String lowerCases = "abcdefghijklmnopqrstuvwxyz";
    
    String oneChar = sc.next();
    if (upperCases.indexOf(oneChar) >= 0) {
       System.out.println("A");
    } else {
       System.out.println("a");
    }
  }
}

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

int main(){
    string s;
    cin >> s;

    vector<long> v(s.size()+1, 0);

    //printf("aaa\n");

    for(long i = 0; i < s.size(); i++){
        if(s[i] == '<'){
            v[i+1] = v[i] + 1;
        }
        
    }

    //printf("bbb\n");
    
    for(long long i = s.size()-1; i >= 0; i--){
        if(s[i] == '>'){
           
            v[i] = max(v[i+1] + 1, v[i]);
           
        }
    }

    long long sum = 0;

    for(long long  i = 0; i <= s.size(); i++){
        sum += v[i];
    }

    printf("%lld\n", sum);

    return 0;
    
}

Measured memory_bytes: 4740
import Data.List (unfoldr)

main :: IO ()
main = do
  n <- read <$> getLine
  bs <- map read . words <$> getLine
  let
    bis = zip bs [1 ..]
    bs' = reverse . unfoldr next $ bis
  if length bs' < n then print (-1) else mapM_ print bs'
  
next :: [(Int, Int)] -> Maybe (Int, [(Int, Int)])
next = (uncurry . flip $ fmap . flip (,)) . foldr step (Nothing, [])
  where
    step (bi, i) (Nothing, xs) | bi == i = (Just bi, map (fmap pred) xs)
    step bi (t, xs) = (t, bi : xs)


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

int digits_sum(int n){
    int sum = 0;
    div_t tmp;
    while(n != 0){
         tmp = div(n, 10);
         sum += tmp.rem;
         n = tmp.quot;
    }
    return sum;
}

int main(void){
    int i, N;
    scanf("%d", &N);
    int min = 100, tmp;
    for(i = 1; i <= N/2; i++){
        tmp = digits_sum(i) + digits_sum(N-i);
        if(tmp < min) min = tmp;
    }
    printf("%d", min);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n;

ll calc(ll num) {
	ll res = 0;
	while (num) {
		num /= 10;
		res++;
	}
	return res;
}

int main() {
	cin >> n;
	ll ans = INF;
	FOR(i, 1, 100000 + 1) {
		if (n%i == 0) {
			ll num = max(calc(i), calc(n / i));
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      if(one.get(0) + one.get(1) + one.get(2) >= 22){
        myout("bust");
      }else{
        myout("win");
      }
	}
	//Method addition frame start

  

	//Method addition frame end
}


Measured memory_bytes: 32840
import java.util.Scanner;

class Main{
  public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();
    StringBuffer sb = new StringBuffer(input);

    String tmp = in.nextLine();
    int cmd_cnt = Integer.parseInt(tmp);

    for(int i=0; i<cmd_cnt; i++){
        input = in.nextLine();
        String [] command_line = input.split(" ", 0);
        String command = command_line[0];
        int start = Integer.parseInt(command_line[1]);
        int end = Integer.parseInt(command_line[2]);

        if(command.equals("print")){
            System.out.println(sb.substring(start, end+1));
        }else if(command.equals("reverse")){
            // debug System.out.println("reverse!!!");
            String rev_str = sb.substring(start, end+1);
            StringBuffer tmp_rev = new StringBuffer(rev_str);
            rev_str = tmp_rev.reverse().toString();
            sb.replace(start, end+1, rev_str);
        }else if(command.equals("replace")){
            String rep_str = command_line[3];
            sb.replace(start, end+1, rep_str);
        }
    }
  }
}

Measured memory_bytes: 28424
import sys
from string import digits

k = int(sys.stdin.readline().rstrip())

def main():
    if k <= 9:
        print(k)
        return
    res = list(digits[1:])
    r = k - 9
    while True:
        nex = []
        for n in res:
            o = ord(n[-1])
            for i in range(-1, 2):
                d = chr(o + i)
                if d < '0' or d > '9': continue
                nex.append(n + d)
                r -= 1
                if not r:
                    print(nex[-1])
                    return
        res = nex.copy()    

if __name__ ==  '__main__':
    main()

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

int main(){
int n,m;
  double total =0;
  int cnt =0;
cin>>n>>m;
  vector<int> vote(120);
  for(int i =0;i<n;i++){
  cin >> vote.at(i);
  }
  for(int i =0;i<n;i++){
    total+=vote[i];
  }
  for(int i =0;i<n;i++){
    if(vote[i]>=total/((double) 4*m))
      cnt++;
  }
  if(cnt>=m){
    cout<<"Yes"<<endl;
  }
   else{
     cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s;
    int q;
    cin >> s >> q;

    bool flipped = false;
    deque<char> bg, ed;

    for (int i=0; i<q; i++) {
        int x;
        cin >> x;
        if (x == 1) flipped = !flipped;
        else {
            char c;
            cin >> x >> c;
            if (flipped == x-1) bg.push_front(c);
            else ed.push_back(c);
        }
    }
    if (flipped) {
        while (!ed.empty()) {
            cout << ed.back();
            ed.pop_back();
        }
        reverse(s.begin(), s.end());
        cout << s;
        while (!bg.empty()) {
            cout << bg.back();
            bg.pop_back();
        }
    } else {
        while (!bg.empty()) {
            cout << bg.front();
            bg.pop_front();
        }
        cout << s;
        while (!ed.empty()) {
            cout << ed.front();
            ed.pop_front();
        }
    }
    cout << "\n";
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  ans += b;
  if(a + b >= c) {
    ans += c;
  } else if(a + b < c) {
    ans += a + b + 1;
  }
  cout << ans << endl;
  return 0;
}

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

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(x) cerr << #x << ": " << x << "\n"

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

long MOD = 1000000007;
long modpow(long a, int p) {
    if (p == 0) {
        return 1;
    } else if (p % 2 == 0) {
        long h = modpow(a, p / 2);
        return h * h % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

long comb(int a, int b) {
    if (b > a - b) {
        return comb(a, a - b);
    }
    long m = 1;
    long d = 1;
    REP(i, b) {
        m *= (a - i);
        d *= (i + 1);
        m %= MOD;
        d %= MOD;
    }
    return m * modpow(d, MOD - 2) % MOD;
}

// main
int main() {
    int N, M;
    cin >> N >> M;
    long ans = 1;
    for (int i = 2; i * i <= M; ++i) {
        if (M % i == 0) {
            int c = 0;
            while (M % i == 0) {
                ++c;
                M /= i;
            }
            ans *= comb(N + c - 1, N - 1);
            ans %= MOD;
        }
    }
    if (M != 1) {
        ans *= comb(N, N - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int count=0;
        String B;
        for(int i=1; i<=(int)Math.sqrt(N); i++){
            if(N%i==0){
                B = String.valueOf(N/i);
                count = B.length();
            }
        }
          System.out.println(count);
        }
    }


Measured memory_bytes: 35692
n, k = map(int, input().split())
lst = [0 for _ in range(n)]

for _ in range(k):
    d = input()
    a = list(map(int,input().split()))
    for i in a:
        lst[i-1] += 1

cnt = 0
for i in range(len(lst)):
    if lst[i] == 0:
        cnt += 1

print(cnt)



Measured memory_bytes: 9112
#include <iostream>
 using namespace std;
 int main()
 {
 int i=0; int num[10];
 for(;i<10;i++)
 cin>>num[i];
 int temp=0,temp1=0,j=0,k=0;
  for(;j<3;j++) {
  for(i=0;i<10;i++)
   { temp1=temp; temp=temp<num[i]?num[i]:temp; if(temp>temp1) k=i; }
    cout<<num[k]<<endl; temp=0; num[k]=0; }
     return 0;
      }

Measured memory_bytes: 1160
import itertools
n = int(input())
a = [input() for _ in range(n)]

#print("out")
suits = ['S', 'H', 'C', 'D']
ranks = range(1, 14)
cards = ["%s %d" % (suit, rank) for suit, rank in itertools.product(suits, ranks)]
answers = [card for card in cards if card not in a]

for out in answers:
    print(out)


Measured memory_bytes: 5648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int N = Integer.parseInt(str);
		System.out.println(800 * N - 200 * (int) Math.floor(N / 15));
	}
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 607;

int n, m, d1, d2;
bool g[MAXN][MAXN];

void init ();
void input ();
void work ();

void del ( int d );



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n >> d1 >> d2;
}

void work ()
{
	// main work

	m = n << 1;

	INIT ( g, true );

	del ( d1 );
	del ( d2 );

	int cc = 0;
	lp ( i, 0, m ) {
		lp ( j, 0, m ) {
			if ( g[i][j] ) {
				if ( cc < n * n ) {
					cout << i << " " << j << endl;
					++cc;
				}
			}
		}
	}
}



void del ( int d )
{
	int t = 0;
	while ( d % 4 == 0 ) d /= 4, ++t;

	if ( d & 1 ) {
		lp ( i, 0, m ) lp ( j, 0, m ) if ( ( i >> t & 1 ) ^ ( j >> t & 1 ) ) g[i][j] = false;
	} else {
		lp ( i, 0, m ) if ( i >> t & 1 ) lp ( j, 0, m ) g[i][j] = false;
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int A, B, C;

	cin >> A >> B >> C;

	int rest = C - (A - B);
	if (rest < 0) {
		rest = 0;
	}

	cout << rest << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int> > sum(N+1,vector<int>(N+1,0));
  for(int i=0;i<M;i++){
    int L,R;cin>>L>>R;
    sum[L][R]++;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      sum[i+1][j+1]+=sum[i+1][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      sum[i+1][j+1]+=sum[i][j+1];
    }
  }
  for (int i=0;i<Q;i++) {
    int L,R;cin>>L>>R;
    cout<<sum[R][R]+sum[L-1][L-1]-sum[L-1][R]-sum[R][L-1]<<endl;
  }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
Node treeSearch(Node, int);

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else 
             x = x->right;
             z->parent = y;
}
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else 
        y->right = z;

}

void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
}
  return 0;
}



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

int main() {
  int p, a, b;

  cin >> p;
  if(p == 1) {
    cout << "Hello World" << endl;
  }
  else {
    cin >> a >> b;
    cout << a + b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list( input() )

if len(S) > 1:
    count = 0

    temp = S[1]

    for i in range(0, len(S)-1):
        if S[i] == S[i+1]:
            count += 1

    print( min(len(S)-1, count + 2*K) )
else:
    print(0)

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

int main(){
  int64_t N;
  cin >> N;
  string s=to_string(N);
  s=string(s.size()-1,'9');
  for(int i=9;i>=0;i--){
    if(stoll((char)(i+'0')+s)<=N){
      cout << s.size()*9+i << endl;
      return 0;
    }
  }
  return 0;
}


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

import math

ans = set([])

targ = N
divider = []
for d in range(1, int(math.sqrt(targ)) + 1):
    if targ % d == 0:
        if d * d < targ:
            divider.append(d)
            divider.append(targ // d)
        else:
            divider.append(d)

for K in divider:
    if K == 1: continue
    N_tmp = N
    while N_tmp % K == 0:
        N_tmp //= K
    #
    if N_tmp % K == 1:
        # print("#", K)
        ans.add(K)
            
targ = N - 1
divider2 = []
for d in range(1, int(math.sqrt(targ)) + 1):
    if targ % d == 0:
        if d * d < targ:
            divider2.append(d)
            divider2.append(targ // d)
        else:
            divider2.append(d)

for K in divider2:
    if K == 1: continue
    # print("#", K)
    ans.add(K)

print(len(ans))

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

void sort(int* num, int n);
void output(int* num, int n);

int cnt = 0;

int main(){
  int n;
  cin >> n;
  int* num;
  num = new int[n];
  for(int i = 0; i < n; i++) cin >> num[i];
  sort(num, n);
  output(num, n);
  delete[] num;
  return 0;
}

void sort(int* num, int n){
  int flag = 1;
  while(flag){
    flag = 0;
    for(int j = n - 1; j > 0; j--){
      if(num[j] < num[j - 1]){
        int temp = num[j];
        num[j] = num[j - 1];
        num[j - 1] = temp;
        flag = 1;
        cnt++;
      }
    }
  }
}

void output(int* num, int n){
  for(int i = 0; i < n; i++){
    if(i == n - 1) cout << num[i];
    else cout << num[i] << " ";
  }
  cout << endl;
  cout << cnt << endl;
}

Measured memory_bytes: 3084
#include<stdio.h>

int binarySearch(int n, int key, int *S){

  int left=0,right=n,mid;

  while(left<right){
    mid=(left + right)/2;
    if(S[mid]==key){
      return mid;
    }
    else if(key<S[mid]){
      right=mid;
    }
    else{
      left=mid+1;
    }
  }
    return 0;
}
    
int main(){

  int i,n,q,key,count=0;
  int S[100001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(n,key,S)){
      count++;
    }
  }

  printf("%d\n",count);

  return 0;
}
 

Measured memory_bytes: 988
N = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

A.sort()
B.sort()
C.sort()

m = [0 for i in range(N)]

j = k = 0
while j < N and k < N:
    if B[j] >= C[k]:
        k += 1
        continue
    m[j] = N - k
    j += 1

for i in range(N-2, -1, -1):
    m[i] += m[i+1]
    
cnt = 0
i = j = 0
while i < N and j < N:
    if A[i] >= B[j]:
        j += 1
        continue
    cnt += m[j]
    i += 1

print cnt


Measured memory_bytes: 18616
import java.util.*;

public class Main {
  public static void main(String args[]) {
    String alphabet = "abcdefghijklmnopqrstuvwxyz";
    Scanner sc = new Scanner(System.in);
    
    String C = sc.next();
    sc.close();
    
    for(int i = 0; i < alphabet.length()-1; i++) {
		if (alphabet.substring(i,i+1).equals(C)) {
          System.out.println(alphabet.substring(i+1,i+2));
		}
	}
  }
}
    

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

using namespace std;

const int inf = 1e9;

const int MAXN = 1e5 + 10;

int dp[MAXN + 10];
int h[MAXN + 10];
int main() {
    #ifdef BLAT
        freopen("input", "r", stdin);
    #endif

    dp[1] = 0;
    dp[0] = inf;

    int n;
    cin >> n;
    int k;
    cin >> k;
    for(int i = 1; i <= n; ++i) {
    	cin >> h[i];
    	dp[i] = (i==1? 0 :inf);
    	for(int j = i-1; j >= i-k && j; --j) {
    		dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    	}	
    }

    cout << dp[n] << '\n';
}  

Measured memory_bytes: 1024
H, W = map(int, input().split())
if H == 1 or W ==1:
    print(1)
elif H % 2 == 0:
    print(H * W // 2)
elif W % 2 == 0:
    print(W * H // 2)
else:
    print((H * W + 1) // 2)

Measured memory_bytes: 2940
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
list = [a, b, c, d, e]
result = []
for i in range(len(list)):
    for j in range(len(list)):
        result.append(list[i]-list[j])
if max(result) >  k:
    print(":(")
else:
    print("Yay!")

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

int main() {
	int a;
	while (cin >> a, a) {
		vector<int>V[100]{};
		bool hannin[100];
		memset(hannin,true, a);
		for (int b = 0; b < a; b++) {
			int c;
			scanf("%d", &c);
			for (int d = 0; d < c; d++) {
				int e;
				scanf("%d", &e);
				e--;
				V[e].push_back(b);
			}
		}
		int x;
		scanf("%d", &x);
		for (int y = 0; y < x; y++) {
			int z;
			scanf("%d", &z);
			z--;
			for (int i = 0,sum=0; i < a; i++) {
				if (sum < V[z].size() && V[z][sum] == i)sum++;
				else hannin[i] = false;
			}
		}
		int s = 0, l = 0;
		for (int k = 0; k < a; k++) {
			if (hannin[k]) { s++; l = k + 1; }
		}
		if (s == 1)cout << l << endl;
		else puts("-1");
	}
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  scan(a);

  ll s = accumulate(all(a), 0LL);
  ll sub = 0LL;
  for (int i = 1; i < n; i += 2) sub += 2 * a[i];

  vector<ll> ans(n);
  ans[0] = s - sub;

  rrep(i, n, 1) { ans[i] = 2 * a[i] - ans[(i + 1) % n]; }

  string s_ans = "";
  rep(i, 0, n) s_ans += to_string(ans[i]) + " ";
  s_ans.pop_back();

  cout << s_ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 4096
#include <stdio.h>
#define MAX 1000000001
 
int w[100001];
 
int main() {
  int n,k,i;
  scanf("%d %d",&n,&k);
  for(i=0; i<n; i++) scanf("%d",&w[i]);
  int l=0,r=MAX;
  int ans=MAX;
  while(l+1<r) {
    int mid=(l+r)/2;
    int sum=0,cnt=0,max=0;
    for(i=0; i<n; i++) {
      if(sum+w[i]>mid) {
    if(cnt<k-1) {
      cnt++;
      sum=0;
    }
      }
      sum+=w[i];
      if(max<sum) max=sum;
    }
    if(ans>max) ans=max;
    if(max<=mid) r=mid;
    else l=mid;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2176
L,R=map(int,input().split())
if L//2019 != R//2019:
    print(0)
elif L%2019==0:
    print(0)
else:
    ans=float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)

Measured memory_bytes: 64248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    bool ans;
    cin>>n;
    if(n%4==0||n%7==0||n%11==0)
        cout<<"Yes"<<endl;
    else
    {
        for(i=0; ;i++)
        {
            n-=11;
            if((n%4==0||n%7==0)&&n>=0)
            {
                ans=true;
                break;
            }
            if(n<0)
            {
                ans=false;
                break;
            }
        }
        if(ans)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3600
A, B = map(int,input().split())
P = [1]
a = set([1,A])
b = set([1,B])
for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
    elif A%k == 0:
        a.add(A//k)
    elif B%k == 0:
        b.add(B//k)

P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U))


Measured memory_bytes: 42204
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int R, G, B, N;

void solve() {

	cin >> R >> G >> B >> N;
	ll cnt = 0;
	for (int i = 0; R * i <=N; i++) {
		for (int j = 0; R * i + G * j <= N; j++) {
			int b = N - R * i - G * j;
			if (b % B == 0) {
				cnt++;
			}
		}
	}
	
	cout << cnt << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const ll inf = 2e18;

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

	int n; cin >> n;
	ll c[n][3];
	rep(i, 0, n) rep(a, 0, 3) cin >> c[i][a];

	ll dp[n + 1][3] = {{0, 0, 0}};
	rep(i, 0, n) {
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + c[i][0];
		dp[i + 1][1] = max(dp[i][2], dp[i][0]) + c[i][1];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i][2];
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

Measured memory_bytes: 4992
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<int> a;
map<int, int> s;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    a.assign(n, 0);
    F0R(i, n) cin >> a[i];
    F0R(i, sz(a)) s[a[i]]++;
    if(sz(s) == 1 && s.find(0) != s.end())
    {
        cout << "Yes";
        return 0;
    }
    if(sz(s) == 2 && sz(a) == 3)
    {
        bool p1 = false;
        for(auto i : s)
        {
            if(i.f == 0 && i.s == 1) p1 = true;  
        }
        if(p1) cout << "Yes";
        else cout << "No";
        return 0;
    }
    if(sz(s) == 2)
    {
        int szxt = (*s.begin()).s;
        auto itx = s.begin(); itx++;
        if((*s.begin()).f == 0 && (*(itx)).s == szxt * 2) cout << "Yes";
        else cout << "No";
        return 0;
    }
    if(sz(s) != 3) 
    {
        cout << "No";
        return 0;
    }
    bool p = true;
    int szx = (*s.begin()).s;
    vector<ll> res;
    for(auto i : s)
    {
        if(i.s != szx) p = false;
        res.pb(i.f);
    }
    if(!p)
    {
        cout << "No";
        return 0;
    }
    if((res[0] ^ res[1]) != res[2]) cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<pii> p(m);
    REP(i,m) {
        cin >> p[i].first >> p[i].second;
        p[i].first--;
    }

    int s = n == 1 ? 0 : pow(10,n-1);
    int e = pow(10,n);
    FOR(i,s,e) {
        string is = to_string(i);
        bool ok = true;
        for(auto x:p) {
            if (is[x.first]- '0' != x.second) {
                ok = false;
                break;
            }
        }
        if (ok) {
            OUT(i)
            return 0;
        }
    }

    OUT(-1)

    return 0;
}

Measured memory_bytes: 256
from numpy import cumsum
from collections import Counter
import math
def count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
wa = list(cumsum(a))
wa.append(0)
c = Counter(wa)
keys = set(wa)
ans = 0
for i in keys:
    num = c[i]
    if num >= 2:
        ans += count(num,2)
    else:
        pass
print(ans)


Measured memory_bytes: 56824