akhauriyash/Code-Regression huggingface dataset:
/*

            ░   ▒▓█  𝕿𝖆𝖑𝖐 𝖎𝖘 𝖈𝖍𝖊𝖆𝖕. 𝕾𝖍𝖔𝖜 𝖒𝖊 𝖙𝖍𝖊 𝖈𝖔𝖉𝖊 █▓▒░
   */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define pr_vec(v) for(ll _=0;_<v.size();_++) cout << v[_] << " " ;
const int N = 1e6 + 7;



void solve()
{
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2+m*(m-1)/2);

}





int main()
{



// #ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;


    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        // cout << endl;
    }


}

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

int main() {

  typedef std::multiset<int> MySet;
  MySet heightSet;

  for(int i = 0; i < 10; ++i)
  {
    int val;
    cin >> val;
    // set ???????´?????????\????????¨??????????????????????????????
    heightSet.insert(val);
  }

  // ??§??????????????¢???????????????????????? reverse_iterator ?????????
  MySet::reverse_iterator rit = heightSet.rbegin();
  for(int i = 0; i < 3; ++i)
  {
    cout << *rit << endl;
    ++rit;
  }
  return 0;
}

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

ll modPow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll Fact(ll n,ll p) {
  if (n < 2) {
    return 1;
  }
  ll res = 1;
  for (ll i = n; i >= 1; i--) {
    res *= i;
    res %= p;
  }
  return res;
}

ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll aa = modinv(Fact(a,Mod),Mod);
  ll ba = modinv(Fact(b,Mod),Mod);
  ll as = 1;
  ll bs = 1;
  for (ll i = n-a+1; i <= n; i++) {
    as *= i;
    as %= Mod;
  }
  for (ll i = n-b+1; i <= n; i++) {
    bs *= i;
    bs %= Mod;
  }
  ll s = ((aa * as) % Mod) + ((ba * bs) % Mod);
  ll ans = (modPow(2,n,Mod) - 1 - s) % Mod;
  if (ans < 0) {
    ans += Mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int K;
  string S;
  cin >> K >> S;

  if (K >= S.size()) cout << S << endl;
  else{
    rep(i,K){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3596
W, H, N = map(int, input().split())
xy = [[0 for i in range(W)] for j in range(H)]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(x):
            for k in range(H):
                xy[k][j] = 1
    if a == 2:
        for j in range(x, W):
            for k in range(H):
                xy[k][j] = 1
    if a == 3:
        for j in range(y):
            for k in range(W):
                xy[j][k] = 1
    if a == 4:
        for j in range(y, H):
            for k in range(W):
                xy[j][k] = 1
cnt = 0
for i in range(H):
    for j in range(W):
        if xy[i][j] == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	string s;
	cin >> s;

	int cur = 0;
	int w;
	cin >> w;

	while (cur < len(s)) {
		cout << s[cur];
		cur += w;
	}
	end_routine;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
    
class Node:
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1
        self.depth = -1
        self.c = []
        
T = [Node() for _ in range(100_000)]
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

for i,a in enumerate(A):
    idx, k = a[:2]
    for j in range(k):
        c = a[2+j]
        T[idx].c.append(c)
        if j==0:
            T[idx].left = c
        else:
            T[left].right = c
        left = c
        T[c].parent = idx

for idx in range(n):
    if T[idx].parent == -1:
        root = idx
   
def set_depth(u,d):
    T[u].depth = d
    for c in T[u].c:
        set_depth(c,d+1)
        
set_depth(root, 0)
    
for idx in range(n):
    print('node {}: parent = {}, depth = {}, {}, {}'.format(idx, T[idx].parent, T[idx].depth, ('root' if T[idx].parent==-1 else 'leaf' if T[idx].left==-1 else 'internal node'), T[idx].c))


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

int main(void) {
	int N, D, X; cin >> N >> D >> X;
	int A[N + 1]; int sum = N + X;
	int i, j;
	for (i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (i = 1; i <= N; i++) {
		for (j = 1; j*A[i] + 1 <= D; j++) {
			if (j*A[i] <= D) {
				sum += 1;
			}
		}
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i,l,a,b,c,d,a1,b1;
	cin>>l>>a>>b>>c>>d;
	if(a%c==0)a1=a/c;
	else if(a%c!=0)a1=a/c+1;
	if(b%d==0)b1=b/d;
	else if(b%d!=0)b1=b/d+1;
	if(a1>=b1)cout<<l-a1<<endl;
	else if(a1<b1)cout<<l-b1<<endl;
	return 0;
}

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

int getNDigits(int x) {
    int cnt = 0;
    while (x/10) {
        cnt++;
        x /= 10;
    }
    return cnt;
}

int main() {
    int a, b; cin >> a >> b;
    int nDigits = getNDigits(b);
    int tmp = a*pow(10, nDigits+1)+b;
    for (int i = 1; i < tmp; i++) {
        if (tmp/i == i && tmp%i == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<vector<int>> v(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> v.at(i).at(j);
    }
  }
  vector<vector<bool>> t(h, vector<bool>(w, false));
  for (int i = 0; i < n; i++) {
    if (v.at(i).at(2) == 2) {
      for (int j = v.at(i).at(0); j < w; j++) {
        for (int k = 0; k < h; k++) {
          t.at(k).at(j) = true;
        }
      }
    }
    if (v.at(i).at(2) == 1) {
      for (int j = v.at(i).at(0) - 1; j >= 0; j--) {
        for (int k = 0; k < h; k++) {
          t.at(k).at(j) = true;
        }
      }
    }
    if (v.at(i).at(2) == 4) {
      for (int j = v.at(i).at(1); j < h; j++) {
        for (int k = 0; k < w; k++) {
          t.at(j).at(k) = true;
        }
      }
    }
    if (v.at(i).at(2) == 3) {
      for (int j = v.at(i).at(1) - 1; j >= 0; j--) {
        for (int k = 0; k < w; k++) {
          t.at(j).at(k) = true;
        }
      }
    }
  }
  int c = w * h;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (t.at(i).at(j)) c--;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    long long x;
    cin>>x;
    long long y = x/11;
    long long z = x%11;
    if(6 < x&& x<=11)
    {
        cout << 2 << endl;
    }
    else if(x<=6)
    {
        cout << 1<< endl;
    }
    else if(z==0)
    {
        cout << y*2<< endl;
    }
    else if(z<=6)
    {
        cout << y*2+1<< endl;
    }
    else
    {
        cout << y*2+2<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 101

int Ad[M][M];
int a[M][M];
int main(){

  int n,i,j,u,k;
  scanf("%d",&n);
  for(i=1;i<=M;i++){
    for(j=1;j<=M;j++){
      a[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    if(k!=0){for(j=1;j<=k;j++){
      scanf("%d",&Ad[u][j]);
      a[u][Ad[u][j]]=1;
      }
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j==n)printf("%d\n",a[i][j]);
      else printf("%d ",a[i][j]);
    }
  }

  return 0;
}

Measured memory_bytes: 676
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

		PriorityQueue <Long> A = new PriorityQueue <Long>();
		PriorityQueue <Long> B = new PriorityQueue <Long>();
		PriorityQueue <Long> C = new PriorityQueue <Long>();
		PriorityQueue <Long> D = new PriorityQueue <Long>();
		PriorityQueue <Long> E = new PriorityQueue <Long>();
		PriorityQueue <Long> F = new PriorityQueue <Long>();
		PriorityQueue <Long> G = new PriorityQueue <Long>();
		PriorityQueue <Long> H = new PriorityQueue <Long>();
		
		
		long b=0;
		long t=0;
		long p=0;
		for (int i=0; i<N; i++){
			b=sc.nextLong();
			t=sc.nextLong();
			p=sc.nextLong();
			
			A.add(b+t+p);
			B.add(b+t-p);
			C.add(b-t-p);
			D.add(-b-t-p);
			E.add(b-t+p);
			F.add(-b-t+p);
			G.add(-b+t+p);
			H.add(-b+t-p);
		}
	
		
		for (int i=0; i<N-M; i++){
			A.poll();
			B.poll();
			C.poll();
			D.poll();
			E.poll();
			F.poll();
			G.poll();
			H.poll();
		}
		
		long ans=0;
		long temp=0;
		
		for (int i=0; i<M; i++){
			temp+=A.poll();
		}
		long temp2=0;
		for (int i=0; i<M; i++){
			temp2+=B.poll();
		}
		ans = Math.max(temp,temp2);
		temp=0;
		for (int i=0; i<M; i++){
			temp+=C.poll();
		}
		ans = Math.max(temp,ans);
		
		temp=0;
		for (int i=0; i<M; i++){
			temp+=D.poll();
		}
		ans = Math.max(temp,ans);
		
		temp=0;
		for (int i=0; i<M; i++){
			temp+=E.poll();
		}
		ans = Math.max(temp,ans);
		
		temp=0;
		for (int i=0; i<M; i++){
			temp+=F.poll();
		}
		ans = Math.max(temp,ans);
		
		temp=0;
		for (int i=0; i<M; i++){
			temp+=G.poll();
		}
		ans = Math.max(temp,ans);
		
		temp=0;
		for (int i=0; i<M; i++){
			temp+=H.poll();
		}
		ans = Math.max(temp,ans);
		
		
		System.out.println(ans);
		sc.close();

	}

}


Measured memory_bytes: 27504
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;	cin >> n >> m;
  priority_queue<long long, vector<long long>, less<long long>> a;
  for(long long i=0;i<n;i++){
    long long x;	cin >> x;
    a.push(x);
  }
  
  for(long long i=0;i<m;i++){
    long long x=a.top();
    a.pop();
    a.push(x/2);
  }
  long long ans=0;
  while(!a.empty()){
    ans+=a.top();
    a.pop();
  }
  cout << ans;
}

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

namespace ARC093_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = new List<int>();
            A.Add(0);
            A.AddRange(Console.ReadLine().Split().Select(int.Parse).ToList());
            A.Add(0);

            N = N + 1;

            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += Math.Abs(A[i] - A[i + 1]);
            }

            for (int i = 1; i < N; i++)
            {
                var result = sum + Math.Abs(A[i - 1] - A[i + 1]) - Math.Abs(A[i - 1] - A[i]) - Math.Abs(A[i] - A[i + 1]);
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 25308
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 2000


int main(){
	int a[N];
	vector<int>v;
	vector<int>b;
	vector<int>d;
	int n, k, q;
	int x, y;
	int ans;
	bool c;
	ans = 1000000000;
	scanf("%d %d %d", &n, &k, &q);
	f(i, n){
		scanf("%d", &a[i]);
		v.push_back(a[i]);
	}
	sort(v.begin(), v.end());
	f(ii, n){
		if (ii == 0)c = true;
		else if (v[ii] != v[ii - 1])c = true;
		else c = false;
		if (c){
			b.clear();
			x = 0;
			y = 0;
			f(i, n){
				if (a[i] >= v[ii])x++;
				else {
					sort(d.begin(), d.end());
					f(j, x - k + 1)b.push_back(d[j]);
					x = 0;
					d.clear();
				}
				if (x == k){
					for (int j = (i - k + 1); j < (i + 1); j++)d.push_back(a[j]);
				}
				else if (x > k){
					d.push_back(a[i]);
				}
			}
			sort(d.begin(), d.end());
			f(j, x - k + 1)b.push_back(d[j]);
			d.clear();
			sort(b.begin(), b.end());
			if (b.size() < q)break;
			else{
				ans = min(ans, b[q - 1] - b[0]);
			}
		}
	}

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

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> T(N), A(N);
  for (auto& i : T) cin >> i;
  for (auto& i : A) cin >> i;

  bool flag = false;
  for (int i = 0; i < N; i++)
    if (T[i] == A[i] && T[N-1] == T[i]) flag = true;

  if (!flag) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> v, c;
  int count = 1;
  for (int i = 1; i < N; i++) {
    if (min(A[i],T[i]) == min(A[i-1], T[i-1])) {
      count++;
    } else {
      if (A[i-1] == T[i-1]) count = max(1, count-1);
      v.push_back(count-1);
      c.push_back(min(A[i-1],T[i-1]));
      count = 1;
    }

    if (i == N-1) {
      if (A[i] == T[i]) count = max(1, count-1);
      c.push_back(min(A[i],T[i]));
      v.push_back(count-1);
    }
  }

  long long int ans = 1;

  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i]; j++) {
      ans = (ans * c[i]) % (long long int)(1e9+7);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int N;
V<string> ans;

void gen(string& s) {
    if (s.size() == N) {
        ans.pb(s);
        return;
    }
    int mx = s.size() ? *max_element(ALL(s)) : 'a' - 1;
    for (char i = 'a'; i <= mx + 1; ++i) {
        s.pb(i);
        gen(s);
        s.pop_back();
    }
}

int main() {
    cin >> N;
    string s;
    gen(s);
    sort(ALL(ans));
    for (auto t : ans) {
        cout << t << '\n';
    }

    return 0;
}

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

void solve() {
    int n;
    cin >> n;
    long long ans;
    cin >> ans;
    n--;
    while(n--) {
        long long x;
        cin >> x;
        ans = ans / __gcd(x, ans) * x;
    }
    cout << ans;

}


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


Measured memory_bytes: 3640
void main(){
	int[] n = _scanln();
	foreach(i; 0..n[0]+1 ){
		if(n[1] == 2*i + 4*(n[0]-i)){
			writeln("Yes");
			return;
		}
	}
	writeln("No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2688
#include<iostream>

using namespace std;

int main(){
	int n; cin >> n;
	for(int i=0;i<n;i++){
		int S, Y, m; cin >> S >> Y >> m;
		int M = S;
		for(int j=0;j<m;j++){
			int s = S, y = Y;
			int kind, t; double r;
			cin >> kind >> r >> t;
			if(kind == 0){
				int risi = 0;
				for(int k=0;k<y;k++){
					risi += s * r;
					s -= t;
				}
				M = max(M, risi+s);
			} else {
				for(int k=0;k<y;k++){
					s += s * r;
					s -= t;
				}
				M = max(M, s);
			}
		}
		cout << M << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin >> x;
    cout << (x / 500ll) * 1000ll + ((x % 500ll) / 5ll) * 5ll << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;

const int
	dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
	dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
	dx4[4] = { 0,1,0,-1 },
	dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }




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

	ivec l(3);
	lint ctr[4] = {};
	while (cin >> l[0] >> l[1] >> l[2]) {
		vsort(l);
		if (l[0] + l[1] <= l[2]) {
			cout << ctr[0] << sp << ctr[1] << sp << ctr[2] << sp << ctr[3] << el;
			gc();
			return 0;
		}
		if (l[0] * l[0] + l[1] * l[1] == l[2] * l[2])++ctr[1];
		else if (l[0] * l[0] + l[1] * l[1] > l[2] * l[2])++ctr[2];
		else ++ctr[3];
		++ctr[0];
	}
	gc();
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'
	
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
int main(){
	fast_io; cout_precision;
	int k,a,b;	cin >> k >> a >> b;
	int ans = b/k - a/k;
	if(ans >0 || (a%k==0) || (b%k==0))	cout <<"OK"<<endl;
	else	cout <<"NG"<<endl;

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=-1,c=1;
  int now=1;
  for(int i=0;i<n;i++){
    now = a[now-1];
    if(now==2){
      ans = c;
      break;
    }
    c++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class BCommonRaccoonVsMonster {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int H, N;
	    in >> H >> N;
	    int sum = 0;
	    REP(i, N) {
	        int a; in >> a;
	        sum += a;
	    }
	    out << (sum >= H ? "Yes" : "No") << '\n';
	}
};


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

	BCommonRaccoonVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	ll h; scanf("%lld", &h);
	ll ans = 0, n = 1;
	while (h > 1) {
		ans += n;
		h /= 2;
		n *= 2;
	}
	ans += n;
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
//Rock, Paper, Scissors
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String input;
		int count = 0;
		String[] data = new String[5];
		String judge;

		while (!(input = in.readLine()).equals("0")) {

			data[count] = input;
			count++;

			if (count == 5) {

				judge = Judge(data);

				for (int i = 0; i < data.length; i++) {

					if (judge.equals("drow")) {
						System.out.println("3");
					} else if (judge.equals(data[i])) {
						System.out.println("1");
					} else {
						System.out.println("2");
					}

				}

				count = 0;
			}

		}
	}

	private static String Judge(String[] data) {

		boolean rock = false;
		boolean paper = false;
		boolean scissors = false;

		for (int i = 0; i < data.length; i++) {
			if (data[i].equals("1")) {
				rock = true;
			} else if (data[i].equals("2")) {
				scissors = true;
			} else if (data[i].equals("3")) {
				paper = true;
			}
		}

		if (rock && !paper && scissors) {
			return "1";
		} else if (!rock && paper && scissors) {
			return "2";
		} else if (rock && paper && !scissors) {
			return "3";
		}

		return "drow";
	}

}

Measured memory_bytes: 16944
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int n, count;
	cin >> n;

	vector<string> a(n);

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

	for (int i = 0; i < n; i++) {
		if (a[i] == "Y") {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define Rep(i,a,b) for(register int i=a;i>=b;--i)
inline int read()
{
    bool f=0;int x=0;char ch;
    do{ch=getchar();f|=(ch=='-');}while(!isdigit(ch));
    do{x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}while(isdigit(ch));
    return f?-x:x;
}
inline void write(int x)
{
    if(x<0)x=-x,putchar('-');
    if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writesp(int x)
{
	write(x);putchar(' ');
}
inline void writeln(int x)
{
	write(x);puts("");
}
int main()
{
	int n;cin>>n;
	int a=n/1000+!!(n%1000);
	cout<<a*1000-n<<endl;
	return 0;
}


Measured memory_bytes: 3636
// B - Counting Roads
#include <bits/stdc++.h>
using namespace std;
#define ITE(x) decltype(x)::iterator

int main(){
	int N,M; cin>>N>>M;
	map<int,int> AB;
	for(int i=0; i<M; ++i){
		int a,b; cin>>a>>b;
		AB[a]++; AB[b]++;
	}

	for(int i=1; i<=N; ++i){
		ITE(AB) it = AB.find(i);
		cout<< (it!=AB.end()? AB[i]: 0) <<endl;
	}
}

Measured memory_bytes: 256
//min selection sort 
//change to min from the first index
#include<iostream>
using namespace std;

int main() {
    int n,a[100];
    int c = 0;
    int minj; //temporary min number store
    int tmp;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> a[i];
    for ( int i = 0; i < n; i++ ) {
        minj = i;
        for ( int j = i; j < n; j++ ) {
            if ( a[j] < a[minj] ) {
                minj = j;
            }
        }
        if ( i != minj ) {
          tmp = a[i];
          a[i] = a[minj];
          a[minj] = tmp;
          c++;
        }
    }
    for ( int i = 0; i < n; i++ ) {
        cout << a[i];
        if (i != n - 1) cout << " ";
    }
    cout << endl;
    cout << c << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const ll NMAX = 200002;

ll N, K;
ll A[NMAX] = { 0, };
ll B[NMAX] = { 0, };

void output(ll n[NMAX]) {
	for (ll i = 1; i <= N; i++) {
		if (i == 1)
			cout << n[i];
		else
			cout << " " << n[i];
	}
	cout << endl;

}

void outputN() {
	for (ll i = 1; i <= N; i++) {
		if (i == 1)
			cout << N;
		else
			cout << " " << N;
	}
	cout << endl;
}

void update(ll old[NMAX], ll new_one[NMAX]) {
	ll i, j;
	for (i = 0; i <= N; i++) {
		new_one[i] = 0;
	}

	for (i = 1; i <= N; i++) {
		ll jstart, jend;
		jstart = max((ll)1, i - old[i]);
		jend = min(N, i + old[i])+1;

		new_one[jstart]++;
		new_one[jend]--;
	}
	// output(new_one);
	for (i = 1; i <= N; i++) {
		new_one[i] += new_one[i - 1];
	}


}



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

	for (ll i = 1; i <= N; i++) {
		cin >> A[i];
	}
	
	int stp;

	//if (K >= N) {
	//	outputN();
	//	exit(0);
	//}

	for (stp = 0; stp < K; stp++) {
		if (stp % 2 == 0) {
			update(A, B);
			if (B[1] == N and B[N] == N) {
				outputN();
				exit(0);
			}
			// output(B);
		}
		else {
			update(B, A);
			if (A[1] == N and A[N] == N) {
				outputN();
				exit(0);
			}
			// output(A);
		}
	}
	if (stp % 2 == 0) {
		output(A);
	}
	else {
		output(B);
	}

}

Measured memory_bytes: 6260
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

int k;
vector<vector<int>> G;

struct mint {
private:
    ll x;
public:
    mint(ll x = 0) :x(x%MOD) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend ostream& operator<<(ostream& os, const mint& n) {
        return os << n.x;
    }
};

// comb (前計算O(NlogMOD) クエリO(1))
vector<mint> FACT, IFACT;

//pow
template<typename T, typename U>
T pow(T k, U n) {
    T x = 1;
    while (n > 0) {
        if (n & 1) {
            x *= k;
        }
        k *= k;
        n >>= 1;
    }
    return x;
}

//template<typename T>
mint perm(int n, int r) {
    if (n < 0 || r < 0 || r > n)return 0;
    //if (r > n / 2) r = n - r;
    return FACT[n] * IFACT[n - r];
}

mint dfs(int n, int par = -1) {
    mint res = 1;
    if (par == -1) {
        res *= perm(k, G[n].size() + 1);
    }
    else {
        res = perm(k - 2,G[n].size()-1);
    }
    for (int v : G[n]) {
        if (v == par) continue;
        res *= dfs(v, n);
    }
    return res;
}

int main() {
    int n;
    cin >> n >> k;
    G = vector<vector<int>>(n);
    int MAX_N = k;
    FACT.resize(MAX_N + 1);
    IFACT.resize(MAX_N + 1);
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i;
        IFACT[i] = pow(FACT[i], MOD - 2);
    }
    REP(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << dfs(0) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int k = in.nextInt(), s = in.nextInt();

			long ans = 0;
			
			for (int i = 0; i <= k; i++) {
				for (int j = 0; j <= k; j++) {
					int z = s - (i + j);
					if (0 <= z && z <= k) {
						ans++;
					}
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23380
#include <iostream>
#include <cmath>

using namespace std;

int W[100];
int sum[100];

int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  
  sum[0] = W[0];
  for(int i=1;i<N;i++){
    sum[i] = sum[i-1] + W[i];
  }

  int m = 10001;
  for(int i=0;i<N-1;i++){
    m = min(abs(sum[N-1] - 2*sum[i]),m);
  }
  cout << m << endl;
  return 0;
}

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

typedef long long ll;
using namespace std;

int pot (ll q, ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q*= qw;
	return q;
}

ll n,a,f[200002];

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

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

for (int i = 1; i<n+1; i++)
	cout << f[i] << "\n";
	



return 0;
}



Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	int ans=0;
	cin>>n;
	if(n==1)
	{
		cout<<"0"<<endl;
		return 0;
	}
	long long q=n;
	for(long long i=2;i*i<=q;i++)
	{
		int sum=0;
		while(n%i==0)
		{
			n/=i;
			sum++;			
		}
		int now=0;
		while(sum>0)
		{
			now++;
			sum-=now;
		}
		if(sum<0)
			now--;
		ans+=now;
	}
	if(n!=1)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  map<pair<int,int>,int> mp;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int tail = i%10, top = -1;
    int tmp = i;
    while (tmp) {
      top = tmp;
      tmp /= 10;
    }
    mp[{top,tail}]++;
  }
  rep(i,10) rep(j,10) ans += mp[{i,j}]*mp[{j,i}];
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[1000010], cnt;
void insertionsort(int g) {
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j;
		for (j = i - g; j >= 0 && a[j] > v;) {
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = v;
	}
}
void shellsort() {
	deque<int> d;
	d.push_back(1);
	while (d.front() * 3 + 1 < n) {
		d.push_front(d.front() * 3 + 1);
	}
	cout << d.size() << endl << d[0];
	REP(i, d.size() - 1)cout << " " << d[i];
	cout << endl;
	for (int i : d)insertionsort(i);
	cout << cnt << endl;
	rep(i, n)cout << a[i] << endl;
}
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	shellsort();
	return 0;
}


Measured memory_bytes: 10904
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto nmq = readln.split.to!(long[]);
    long N = nmq[0];
    long M = nmq[1];
    long Q = nmq[2];
    long[] L = new long[](M);
    long[] R = new long[](M);
    long[] Qp = new long[](Q);
    long[] Qq = new long[](Q);

    foreach (i; 0 .. M)
    {
        auto lr = readln.split.to!(long[]);
        L[i] = lr[0];
        R[i] = lr[1];
    }
    foreach (i; 0 .. Q)
    {
        auto pq = readln.split.to!(long[]);
        Qp[i] = pq[0];
        Qq[i] = pq[1];
    }

    long[][] table = new long[][](N + 1, N + 1);
    foreach (t; zip(L, R))
        table[t[0]][t[1]]++;

    foreach (i; 1 .. N + 1)
        foreach (j; 1 .. N + 1)
        {
            table[i][j] += table[i][j - 1];
            table[i][j - 1] += table[i - 1][j - 1];
        }

    foreach (i; 1 .. N + 1)
        table[i][N] += table[i - 1][N];

    // table.writeln;

    foreach (query; zip(Qp, Qq))
    {
        long result = table[query[1]][query[1]];
        result -= table[query[1]][query[0] - 1];
        result -= table[query[0] - 1][query[1]];
        result += table[query[0] - 1][query[0] - 1];
        result.writeln;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];
  rep(i,n) a[i]--;

  int ans = 0;
  rep(i,n) {
    ans += b[a[i]];
  }

  rep(i,n-1) {
    if (a[i]+1 == a[i+1]) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = input()
a = [int(x) for x in n]
if a[0]+a[1]+a[2]+a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'=7')

Measured memory_bytes: 3192
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;

    int ans = INF;
    int tmp = 0;
    rep(i, SZ(s)){
        if(s[i] - '0' == i % 2){
            tmp++;
        }
    }
    ans = min(ans, tmp);
    tmp = 0;
    rep(i, SZ(s)){
        if(s[i] - '0' == (i + 1) % 2){
            tmp++;
        }
    }
    ans = min(ans, tmp);

    cout << ans << endl;

    return 0;
}


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

int sumdigits(int n){
  int d=0;
  
while(n>=1){
 
 d=d+n%10;
  n=n/10;
  
}
return d;
}

int main(){
  
  int N,A,B;
  int sum;
  
  int ans=0;
  cin>>N>>A>>B;
  
  for(int i=1;i<=N;i++){
  sum=sumdigits(i);
   if(A<=sum&&sum<=B){
    ans=ans+i;
    }  
  
  } 
   
    
  cout<<ans<<endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    int H,W;
    cin >> H >> W;

    vector<string> S(H);
    REP (i,H) {
        cin >> S[i];
    }

    vector<int> dh{-1, 1, 0, 0};
    vector<int> dw{ 0, 0,-1, 1};

    REP (h,H) {
        REP (w,W) {
            int chk = 0;
            if (S[h][w] == '#') {
                REP (i,4) {
                    const int nh = h + dh[i];
                    const int nw = w + dw[i];

                    if ((nh < 0) || (H <= nh) || (nw < 0) || (W <= nw)) {
                       continue;
                    }

                    if (S[nh][nw] == '#') {
                       chk++;
                    }

                }
                if (chk == 0) {
                    cout << "No" << endl;
                    return 0;
                } 
            }
        }
    }
 
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
int a[15],b,c,k;
int main()
{
	scanf("%d",&k);
	for(int kk=1;kk<=k;kk++)
	{
		int f=0;
		for(int i=1;i<=10;i++)
			scanf("%d",&a[i]);
		for(int i=1;i<=10;i++)
		{
			if(a[i]<c&&a[i]<b)
			{printf("NO\n");f=1;break;}
			if(b>c)
			{
				if(b<a[i])b=a[i];
				else c=a[i];
			}
			else
			{
				if(c<a[i])c=a[i];
				else b=a[i];
			}
		}
		if(!f)printf("YES\n");
		b=c=0;
	}
}
//2 4 6 8 10 1 3 5 7 9

Measured memory_bytes: 2600
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    ll N, A;
    cin >> N >> A;

    ll x[N + 1];
    ll max_x = 0;
    for (ll i = 1; i <= N; i++)
    {
        cin >> x[i];
        if (x[i] >= max_x)
            max_x = x[i];
    }
    if (A >= max_x)
        max_x = A;

    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(N * max_x + 1, 0)));
    dp[0][0][0] = 1;

    for (ll j = 1; j <= N; j++)
    {
        for (ll k = 0; k <= N; k++)
        {
            for (ll s = 0; s <= N * max_x; s++)
            {
                dp[j][k][s] += dp[j - 1][k][s];
                if (s >= x[j] && k >= 1)
                {
                    dp[j][k][s] += dp[j - 1][k - 1][s - x[j]];
                }
            }
        }
    }

    ll ans = 0;

    for (ll i = 1; i <= N; i++)
    {
        ans += dp[N][i][i * A];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 55196
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int A[100000];
int main() {
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) cin >> A[i];
	LL L = 2, R = 2;
	for (int i = K - 1; i >= 0; i--) {
		LL l = (L + A[i] - 1) / A[i] * A[i];
		LL r = R / A[i] * A[i] + A[i] - 1;
		if (R < l) {
			cout << -1 << endl;
			return 0;
		}
		L = l;
		R = r;
	}
	cout << L << " " << R << endl;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  vector<bool> N(10, false);
  int n;
  for (int i{}; i < 4; ++i) {
    scanf("%d", &n);
    N[n] = true;
  }

  printf(N[1] && N[9] && N[7] && N[4] ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll ans = 0 ;
    for(ll i =1; i <= N; i+=2 ){
        ll cnt = 0;
        for(ll j = 1; j <= i ;j++){
            if(i % j == 0) cnt ++;
            
        }
        if(cnt == 8) ans ++;
    }
    
    cout << ans << endl;
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*

const val P = 998244353L

fun solveBruteForce(s: String): Int {
  val q = ArrayDeque<String>()
  q.offerLast(s)
  val set = mutableSetOf<String>()
  set.add(s)
  while (q.isNotEmpty()) {
    val state = q.pollFirst()
    for (i in 0 until (state.length - 1)) {
      if (state[i] != state[i + 1]) {
        val c1 = state[i]
        val c2 = state[i + 1]
        ('a'..'c').forEach {
          if (c1 != it && c2 != it) {
            val nextBuilder = StringBuilder(state)
            nextBuilder[i] = it
            nextBuilder[i + 1] = it
            val next = nextBuilder.toString()
            if (!set.contains(next)) {
              q.offerLast(next)
              set.add(next)
            }
          }
        }
      }
    }
  }
  return set.size
}

fun cToI(c: Char) = c - 'a'

class LongArray3D(val size1: Int, val size2: Int, val size3: Int) {
  private val innerArray = LongArray(size1 * size2 * size3)

  operator fun get(i1: Int, i2: Int, i3: Int): Long = innerArray[i3 + size3 * (i2 + size2 * i1)]

  operator fun set(i1: Int, i2: Int, i3: Int, v: Long) {
    innerArray[i3 + size3 * (i2 + size2 * i1)] = v
  }
}

fun main(args: Array<String>) {
  val s = readLine()!!

  if (s.all { it == s[0] }) {
    println(1)
    return
  }

  if (s.length <= 3) {
    println(solveBruteForce(s))
    return
  }

  val n = s.length
  // [element index][mod][last]
  val dp1 = LongArray3D(n, 3, 3)
  val dp2 = LongArray3D(n, 3, 3)
  for (x in 0..2) {
    dp1[0, x, x] = 1L
    dp2[0, x, x] = 1L
  }
  for (k in 0 until n - 1) {
    for (m in 0..2) {
      for (x in 0..2) {
        for (y in 0..2) {
          dp1[k + 1, (m + y) % 3, y] += dp1[k, m, x]
          dp1[k + 1, (m + y) % 3, y] %= P
          if (x != y) {
            dp2[k + 1, (m + y) % 3, y] += dp2[k, m, x]
            dp2[k + 1, (m + y) % 3, y] %= P
          }
        }
      }
    }
  }
  val sMod = s.map(::cToI).sum() % 3
  val t1 = (0..2).map { dp1[n - 1, sMod, it] }.sum() % P
  val t2 = (0..2).map { dp2[n - 1, sMod, it] }.sum() % P
  val sCount = !(0 until n - 1).any { s[it] == s[it + 1] }
  val ans = (t1 + P - t2 + if (sCount) 1 else 0) % P
  println(ans)
}


Measured memory_bytes: 67960