akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

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

    ll m = 1;
    ll t = 1;
    while(m <= k){
        m *= 2;
        t++;
    }

    m /= 2;
    t--;

    ll mk = 0;

    for(ll i = t; i > 0; i--){
        if(mk + ((ll)1 << (i-1)) > k){
            continue;
        }
        ll c = 0;
        for(int j = 0; j < n; j++){
            if(a[j]&((ll)1 << (i-1))){
                c++;
            }
        }
        if(c > n/2){

        }else{
            mk += (ll)1 << (i-1);
        }
    }

    ll mt = 0;

    for(ll i = t-1; i > 0; i--){
        ll c = 0;
        for(int j = 0; j < n; j++){
            if(a[j]&((ll)1 << (i-1))){
                c++;
            }
        }
        if(c > n/2){

        }else{
            mt += (ll)1 << (i-1);
        }
    }

    ll ans = 0;
    ll tmp = 0;
    for(int j = 0; j < n; j++){
        ans += a[j]^mk;
        tmp += a[j]^mt;
    }

    cout << max(ans,tmp) << endl;
    
    return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int bj=0;
    if(a==b&&a!=c)
        bj=1;
    else if(a==c&&a!=b)
        bj=1;
    else if(b==c&&b!=a)
        bj=1;
    if(bj==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,ans,a[11];
void dfs(long long k,long long t,long long s)
{
	if (s>=ans)return;
	if (!t)ans=s;
	if ((k==3)||(t<0))return;
	dfs(k+1,t,s);
	dfs(k,t-(1<<k),s+a[k]);
}
int main()
{
	for (int i=0;i<4;i++)scanf("%lld",&a[i]);
	scanf("%lld",&n);
	n*=4;
	ans=a[0]*(n%8);
	dfs(0,n%8,0);
	printf("%lld\n",ans+n/8*min(min(a[0]*8,a[1]*4),min(a[2]*2,a[3])));
}

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

int solve(vector<int>&v,int k)
{
    bool dp[k+1];
    memset(dp,0,sizeof dp);

    for(int i=1;i<=k;i++)
    {
        for(int x:v)
        {
            if(x>i)
                continue;

            if(dp[i-x]==0)
                dp[i]=1;
        }
    }
  return dp[k];

}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];

     if(solve(v,k)==1)
        cout<<"First"<<"\n";

     else
        cout<<"Second"<<"\n";

    return 0;
}


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

int main(void)
{
    long long N;
    cin >> N;

    vector<long long> L(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    long long ans = 0;

    for (long long i = 0; i < N; i++)
    {
        for (long long j = i+1; j < N; j++)
        {
            for (long long k = j+1; k < N; k++)
            {
               if(L[i] > L[j] && L[i] > L[k] && L[j] != L[k])
               {
                   if (L[j] + L[k] > L[i])
                   {
                       ans++;
                   }
               }
               else if(L[j] > L[i] && L[j] > L[k] && L[i] != L[k])
               {
                   if (L[i] + L[k] > L[j])
                   {
                       ans++;
                   }
               }
               else if(L[k] > L[i] && L[k] > L[j] && L[i] != L[j])
               {
                   if (L[i] + L[j] > L[k])
                   {
                       ans++;
                   }
               }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;

int main(){
  int total, number, cost;
  cost=0;
  cin>>total;
  cin>>number;
  vector<int> arr(total);
  for(int i=0; i<total; i++){
    cin>>arr[i];
  }
  sort(arr.begin(), arr.end());
  for(int i=0; i<number; i++){
    cost+=arr[i];
  }
  cout<<cost;
  return 0;
}

Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
    static class Fast
    {
        BufferedReader br;
        StringTokenizer st;
 
        public Fast()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[] ) throws Exception {
        Fast in=new Fast();
        PrintWriter out = new PrintWriter(System.out); 
	    int a=in.nextInt(),b=in.nextInt(),c=in.nextInt();
	    int arr[]={a,b,c};
	    Arrays.sort(arr);
	    if(arr[2]!=arr[0]+arr[1]){
	        out.println("No");
	    }else{
	        out.println("Yes");
	    }
	    
	
	
	
        out.close();
    }
}



Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
int main(void) {
    int len,i,num,j;
    char seg[12][9]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"},dis[9];
    while (scanf("%d",&len)!=EOF&&len!=-1) {
        strcpy(dis,"0000000");
        for (i=0; i<len; i++) {
            scanf("%d",&num);
            for (j=0; j<7; j++) {
                if (dis[j]==seg[num][j]) {
                    printf("0");
                } else {
                    printf("1");
                    dis[j]=seg[num][j];
                }
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define lli long long int
#define MAX 100000000
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    int A[M];
    int answer = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp = 0;
        for (int j = 0; j < M; j++)
        {
            cin >> A[j];
            tmp += A[j] * B[j];
        }
        if (tmp + C > 0)
        {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

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


void solve(long long X){
    long long m = 100, y = 0;
    while(m < X) {
        m = floor(1.01 * m);
        ++y;
    }
    cout << y << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3808
A, B, C = [list(input()) for i in range(3)]


turn = "a"

while True:
    if turn == 'a':
        if len(A) != 0:
            turn = A.pop(0)
        else:
            print('A')
            break
    elif turn == 'b':
        if len(B) != 0:
            turn = B.pop(0)
        else:
            print('B')
            break
    elif turn == 'c':
        if len(C) != 0:
            turn = C.pop(0)
        else:
            print('C')
            break



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[101],t[101];
	int ns[101],nt[101];
	scanf("%s%s",s,t);
	int lens=strlen(s),lent=strlen(t);
	int i,k,temp;
	for(i=0;i <= lens-1;i++)
		{ns[i] = s[i];}
	for(i=0;i <= lent-1;i++)
		{nt[i] = t[i];}
	for(i=0;i <= lens-2;i++)
		{
		for(k=0;k <= lens-2-i;k++)
			{
			if(ns[k] > ns[k+1])
				{
				temp = ns[k];
				ns[k] = ns[k+1];
				ns[k+1] = temp;
				}
			}
		}
	for(i=0;i <= lent-2;i++)
		{
		for(k=0;k <= lent-2-i;k++)
			{
			if(nt[k] < nt[k+1])
				{
				temp = nt[k];
				nt[k] = nt[k+1];
				nt[k+1] = temp;
				}
			}
		}
	ns[lens]=0;
/*	for(i=0;i <= lens-1;i++){printf("%d ",ns[i]);}
	printf("\n");
	for(i=0;i <= lent-1;i++){printf("%d ",nt[i]);}
	printf("\n"); */
	int check=1;
	i=0;
	while(check==1 && i <= lent-1)
		{
		if(ns[i] < nt[i]){break;}
		else if(ns[i] == nt[i])
			{
			if(i == lent-1){check=0;}
			else{i++;}
			}
		else{check=0;}
		}
	if(check==0){printf("No\n");}
	else{printf("Yes\n");}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		final String d = ":";
		int	i = Integer.parseInt(s.next());

		System.out.print  (i/3600);
		i%=3600;
		System.out.print  (d+i/60);
		i%=60;
		System.out.println(d+i);
	}
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    string s;
    cin >> s;
    if(s.at(2)==s.at(3) && s.at(4)==s.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
tap [] _=True
tap (x:xs) n
  |n`mod`2==1&&x`elem`"RUD"||
  n`mod`2==0&&x`elem`"LUD"=True&&tap xs (n+1)
  |otherwise=False

main=do
  n<-getLine
  let ans=tap n 1
  if ans
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 380
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e5+5
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;


pair<int,int>solve(int x,int y,int a,int b){
	if(a <= x && y <= b){
		return make_pair(x,y);
	}else if(x<=a && b<=y){
		return make_pair(a,b);
	}else if(x<=a && a<=y && y<=b){
		return make_pair(a,y);
	}else if(a<=x && x<=b && b<=y){ 
		return make_pair(x,b);
	}	
}

int main(){
	int n,m,a,b,x,y,i;
	scanf("%d%d",&n,&m);
	
	for(i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		if(i == 0){
			x = a;
			y = b;
		}else{
			pair<int,int>p = solve(x,y,a,b);
			x = p.first;
			y = p.second;
		}
	}

	printf("%d\n",(y-x)+1);
	return 0;
}



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

int main(){
  int n;
  cin>>n;
  int a,b;
  //int count=0;
  vector <int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
    sort(v.begin(), v.end());
    a=v[n/2];
    b=v[n/2-1];
  cout<<(a-b)<<endl;
  return 0;
}
  

Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;
int n;
string st;
int b,a;
int main(){
	cin>>n>>st;
	int right=0,left=0;
	for(int i=0;i<st.length();i++){
		if(st[i]=='('){
			left++;
		}
		else if(st[i]==')'){
			right++;
			if(right>left){
				a++;
				left++;
			}
		}
	}
	right=0;left=0;
	for(int i=st.length()-1;i>=0;i--){
		if(st[i]=='('){
			left++;
			if(right<left){
				b++;
				right++;
			}
		}
		else if(st[i]==')'){
			right++;
		}
	}
	for(int i=0;i<a;i++)cout<<"(";
	cout<<st;
	for(int i=0;i<b;i++)cout<<")";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

tmp_A = A*100
if tmp_A%8==0:
  min_A = tmp_A//8
  max_A = (tmp_A+100)//8
else:
  min_A = tmp_A//8+1
  max_A = (tmp_A+100)//8-1

min_B = 10*B
max_B = 10*B+9

min_AB = max(min_A, min_B)
max_AB = min(max_A, max_B)

if min_AB <= max_AB:
  print(min_AB)
else:
  print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int num[26]={};
    while( scanf("%c", &ch) != EOF ){
		if(isupper(ch)){
		    ch = tolower(ch);
		}
	
		if('a'<=ch && ch<='z'){
		    num[ch-'a'] += 1;
		}
	}
    
     ///出力
        for(char ci='a';ci<='z';ci++){
            cout << ci << " " << ":" << " " << num[ci-'a'] << endl;
            
        }
}


Measured memory_bytes: 3232
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //input
            var inputs = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(inputs[0]);
            int B = Convert.ToInt32(inputs[1]);

            double x = Math.Ceiling((B - 1) / (double)(A - 1));

            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

struct Player
{
  std::vector<Player*> schedule;
  int last_match_date = 0;
};

template<typename T>
class VectorSelector
{
  int index_ = 0;
  std::array<std::vector<T>, 2> vectors_;

public:
  std::vector<T>& current() { return vectors_.at(index_); }
  std::vector<T>& next() { return vectors_.at(next_index()); }
  void rotate() { index_ = next_index(); }

private:
  int next_index() const { return (index_ + 1) % 2; }
};

int solve(int n, std::vector<Player>& players)
{
  VectorSelector<Player*> v_selector;

  for (auto& p : players) {
    v_selector.current().push_back(&p);
  }

  int date = 1;
  for (; !v_selector.current().empty(); ++date, v_selector.rotate()) {
    for (auto* p : v_selector.current()) {
      if (p->last_match_date == date) continue;
      if (p->schedule.empty()) continue;
      auto* opposition = p->schedule.back();
      if (opposition->schedule.back() == p
          && opposition->last_match_date < date) {
        p->last_match_date = date;
        p->schedule.pop_back();
        opposition->last_match_date = date;
        opposition->schedule.pop_back();
        v_selector.next().push_back(p);
        v_selector.next().push_back(opposition);
      }
    }
    v_selector.current().clear();
  }

  return std::all_of(
      players.begin(),
      players.end(),
      [](const Player& p) { return p.schedule.empty(); })
      ? date - 2
      : -1;
}

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

  std::vector<Player> players(n);
  for (auto& p : players) {
    for (int i = 0; i < n - 1; ++i) {
      int a;
      std::cin >> a;
      p.schedule.insert(p.schedule.begin(), &players[a - 1]);
    }
  }

  std::cout << solve(n, players) << std::endl;
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <string.h>
char a[2][1010], b[1010][40];
const char* str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(void)
{
    int n, m, q;
    while (scanf("%d%d%d", &n, &m, &q), n) {
        int i, j, k=0;
        memset(a, '0', sizeof(a));
        memset(b, 1, sizeof(b));
        while (q--) {
            char s[60];
            scanf("%s%s", s, a[k]);
            for(i=0;i<n;++i) for(j=0;j<m;++j) {
                if (s[i]=='1')
                    b[j][i]=(b[j][i] && a[k][j]==a[1-k][j])?0:b[j][i];
                else if (a[k][j]!=a[1-k][j])
                    b[j][i]=0;
            }
            k=1-k;
        }
        for(i=0;i<m;++i) {
            int p=0, res;
            for(j=0;j<n;++j) if (b[i][j]==1) { ++p; res=j; }
            putchar(p==1?str[res]:'?');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 640
A, B, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
coupons = []
for _ in range(M):
    x, y, c = map(int, input().split())
    coupons.append((x, y, c))

price_min = min(As) + min(Bs)
coupon_min = min([As[x - 1] + Bs[y - 1] - c for (x, y, c) in coupons])

print(min((price_min, coupon_min)))


Measured memory_bytes: 32916
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a == b) {
    cout << (c == b ? "No\n" : "Yes\n");
  } else if (b == c) {
    cout << (a == b ? "No\n" : "Yes\n");
  } else if (a == c) {
    cout << (a == b ? "No\n" : "Yes\n");
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
    scanf("%d%d",&a,&b);
    if(a*b%2==0)printf("Even\n");
    else printf("Odd\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int cost[502][502]; int n;
bool z[502][502];
int xmove[4] = {0,0,-1,1};
int ymove[4] = {1,-1,0,0};

void dfs(int x, int y){
    assert(x > 0);
    assert(y > 0);
    FOR(i,4){
        if(cost[x+xmove[i]][y+ymove[i]] > cost[x][y]+((int)z[x][y])){
            cost[x+xmove[i]][y+ymove[i]] = cost[x][y]+((int)z[x][y]);
            dfs(x+xmove[i],y+ymove[i]);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; m0(cost);
    F0R(i,1,n) F0R(j,1,n) z[i][j] = 1;
    F0R(i,1,n) F0R(j,1,n) cost[i][j] = min(min(i-1,n-i),min(j-1,n-j));
    int ans = 0;
    FOR(i,n*n){
        int a; cin >> a;
        int x = ((a-1)/n) + 1, y = (a-1)%n + 1;
        ans += cost[x][y];
        z[x][y] = 0;
        dfs(x,y);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20216
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(v[i] - c[i] > 0)
        {
            ans += v[i] - c[i];
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N, K;
ll ans = 0;

int main() {
    cin >> N >> K;
    //for (ll k = K - 1; k <= N; k++) {
    //    ans += -k * k + (N - 1) * k + N + 1;
    //    ans %= ll(1e9) + 7;
    //}
    ll n = N - (K - 1);
    ans += -n * (n + 1) * (2 * n + 1) / 6;
    ll mod = ll(1e9) + 7;
    ans %= mod;
    ans += (N - 2 * K + 1) * n * (n + 1) / 2;
    ans %= mod;
    ans += (n + 1) * (-(K - 1) * (K - 1) + (N - 1) * (K - 1) + N + 1);
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
class LazySegTree{
    private:
        ll n;
        vector<ll> node,lazy;
    public:
        LazySegTree(vector<ll> v){
            ll sz = (ll)v.size();
            n = 1;
            while(n < sz) n *= 2;
            node.resize(2*n-1);
            lazy.resize(2*n-1,0);
            rep(i,sz) node[i+n-1] = v[i];
            for(int i = n-2;i >= 0;i--) node[i] = node[i*2+1]+node[i*2+2];
        }
        void eval(ll k,ll l,ll r){
            if(lazy[k] != 0){
                node[k] += lazy[k];
                if (r-l > 1){
                    lazy[2*k+1] += lazy[k]/2;
                    lazy[2*k+2] += lazy[k]/2;
                }
                lazy[k] = 0;
            }
        }
        void add(ll a,ll b,ll x,ll k=0,ll l=0,ll r=-1){
            if (r < 0) r = n;
            eval(k,l,r);
            if (b <= l || r <= a) return;
            if (a <= l && r <= b){
                lazy[k] += (r-l)*x;
                eval(k,l,r);
            }
            else{
                add(a,b,x,2*k+1,l,(l+r)/2);
                add(a,b,x,2*k+2,(l+r)/2,r);
                node[k] = node[2*k+1]+node[2*k+2];
            }
        }
        ll query(ll a,ll b,ll k = 0,ll l = 0,ll r = -1){
            if (r < 0) r = n;
            eval(k,l,r);
            if (b <= l || r <= a) return 0;
            if (a <= l && r <= b) return node[k];
            ll vl = query(a,b,2*k+1,l,(l+r)/2);
            ll vr = query(a,b,2*k+2,(l+r)/2,r);
            return vl+vr;
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q,s,t,x;
    bool c;
    cin >> n >> q;
    vector<ll> v(n,0);
    LazySegTree p(v);
    rep(i,q){
        cin >> c;
        if (c == 0){
            cin >> s >> t >> x;
            p.add(s-1,t,x);
        }
        else{
            cin >> s >> t;
            PRINT(p.query(s-1,t));
        }
    }
}



Measured memory_bytes: 8696
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()

def Base_10_to_n(X, n):
    if int(X/n):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

s = str(Base_10_to_n(n, k))
print(len(s))

Measured memory_bytes: 63212
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


long long int n;
long long int ans = 0;

void dfs(long long int i, long long int x, long long int y, long long int z) {
	if (i > n) {
		return;
	}

	if (x >= 1 && y >= 1 && z >= 1) {
		//cout << i << " " << x << " " << y << " " << z << endl;
		ans++;
	}

	dfs(10 * i + 3, x+1, y, z);
	dfs(10 * i + 5, x, y+1, z);
	dfs(10 * i + 7, x, y, z+1);


}



int main(void) {
	cin >> n;

	dfs(3, 1, 0, 0);
	dfs(5, 0, 1, 0);
	dfs(7, 0, 0, 1);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int n,p[5050],dp[5050][5050],f[5050],siz[5050],esiz[5050],ans,a[5050],tot;
int find(int x)
{
	if(x!=f[x])return f[x]=find(f[x]);
	return x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]),siz[i]=1,f[i]=i;
	for(int i=1;i<=n;++i)
		if(p[i]!=-1)
		{
			if(find(p[i])!=i)siz[find(p[i])]+=siz[i],esiz[find(p[i])]+=esiz[i],f[i]=find(p[i]);
			++esiz[find(i)];
		}
	ans=n;
	for(int i=1;i<=n;++i)
		if(f[i]==i)
		{
			if(esiz[i]==siz[i])--ans;
			else a[++tot]=siz[i];
		}
	ans=1ll*ans*kpow(n-1,tot)%mod;
	dp[0][0]=1;
	for(int i=1;i<=tot;++i)
		for(int j=0;j<i;++j)
		{
			dp[i][j]=(dp[i][j]+1ll*dp[i-1][j]*(n-1))%mod;
			dp[i][j+1]=(dp[i][j+1]+1ll*dp[i-1][j]*a[i])%mod;
		}
	int sum=0;
	for(int i=1;i<=tot;++i)sum+=a[i]-1;
	if(tot)ans=(ans+1ll*(mod-sum)*kpow(n-1,tot-1))%mod;
	int fac=1;
	for(int i=2;i<=tot;++i)fac=1ll*fac*(i-1)%mod,ans=(ans+1ll*fac*(mod-dp[tot][i]))%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 68732
#include<cstdio>
int main(){
  int a, b; scanf("%d%d", &a, &b);
  int i = 1;
  while(i++){
    int t = i*(i+1)/2;
    int t2 = (i+1) * (i+2) /2;
    if(t-a == t2-b){
      printf("%d\n", t-a);
      return 0;
    }
  }
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok().unwrap();
    let num_collection: Vec<u32> = s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect();
    let first = num_collection[0];
    let second = num_collection[1];
    println!("{} {}", first * second, 2 * first + 2 * second);
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i-= i&-i) {
            x += d[i];
        }
        return x;
    }
    // 下の2個の操作を使う時は上の2個の操作が使えない事に注意
    T getmax(int i){ // get max(d[i]) for i = 0,1,...,i-1,i
        T x = 0;
        for(i++;i;i-=i&-i) {
            x = max(x, d[i]);
        }
        return x;
    }
    void setmax(int i, int v){ // set d[i] = max(d[i], v)
        for(i++;i<=n;i+=i&-i){
            d[i] = max(d[i], v);
        }
    }
};

int a[100005];
vector<int> dp(1e5+5,1e9+7);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,ans = 0;
    cin >> n;
    rep(i,n)cin >> a[i];
    for(int i=n-1;i>=0;i--){
        *upper_bound(ALL(dp),a[i]) = a[i];
    }
    cout << lower_bound(ALL(dp),1e9+7) - dp.begin() << endl;
}

Measured memory_bytes: 1024
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A1 = new Array[Int](N)
  val B1 = new Array[Int](N)
  val C1 = new Array[Int](N)

  for(i <- 0 until N)
    A1(i) = in.next().toInt
  for(i <- 0 until N)
    B1(i) = in.next().toInt
  for(i <- 0 until N)
    C1(i) = in.next().toInt

  val A = 0 +: A1
  val B = 0 +: B1.sorted.reverse
  val C = 0 +: C1.sorted.reverse


  // process //
  def check(n: Int, obje: Int, ar: Array[Int]): Boolean = {
    ar(n) > obje
  }

  // 条件を満たす最大の値を返す
  def binarySearch(min: Int, max: Int, obje: Int, ar: Array[Int]): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(max, obje, ar) match{
          case true  => max
          case false => min
        }
      case _ =>
        (check(mid, obje, ar)) match{
          case true  => binarySearch(mid, max, obje, ar)
          case false => binarySearch(min, mid, obje, ar)
        }
    }
  }

  //
  val dpB = new Array[Long](N+1)
  for(i <- 1 to N) {
    if(B(i) < C(1)) {
      dpB(i) = binarySearch(1, N, B(i), C)
    }
  }

  // imos
  for(i <- 1 to N-1)
    dpB(i+1) += dpB(i)

  var ans = 0L
  for(i <- 1 to N) {
    if(A(i) < B(1)) {
      val bi = binarySearch(1, N, A(i), B)

      ans += dpB(bi)
    }
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 68328
s = input()
t = input()

s = sorted(s)
t = sorted(t)[::-1]

answer = "Yes"
for i in range(len(s)):
  if i == len(t):
    answer = "No"
    break
  s_c = s[i]
  t_c = t[i]
  if s_c < t_c:
    break
  elif s_c == t_c:
    continue
  else:
    answer = "No"
    break

if s == t:
  answer = "No"

print(answer)

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

typedef long long ll;

struct three{
    ll x,y,z;
};

int n,m;
three a[1005];
int pn[3];

ll val(three i){
    return i.x*pn[0]+i.y*pn[1]+i.z*pn[2];
}

bool cmp(three i,three j){
    return val(i)>val(j);
}

ll dfs(int dp){
    ll res=0;
    if(dp==3){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            res+=val(a[i]);
        }
        return res;
    }
    pn[dp]=1;
    res=dfs(dp+1);
    pn[dp]=-1;
    res=max(res,dfs(dp+1));
    return res;
}

int main(){

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

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i].x>>a[i].y>>a[i].z;
    }
    cout<<dfs(0)<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if(2*ab[1] >= ab[0]) Console.WriteLine(0);
            else Console.WriteLine(ab[0] - 2*ab[1]);
        }
    }
}


Measured memory_bytes: 13268
a,b,c,d = map(int, input().split())

if b < 0:
    if c > 0:
        print(b*c)
    else:
        print(a*c)
elif a < 0:
    if d < 0:
        print(a*c)
    elif c < 0:
        print(max(a*c,b*d))
    else:
        print(b*d)
else:
    if d < 0:
        print(a*d)
    else:
        print(b*d)



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

using namespace std;


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

    auto ans = "No";
    for (int i = 0; i < S.size() - 1; ++i) {
        if (S[i] == 'A' && S[i + 1] == 'C') ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[])
{
  int n, m;
  cin >> n >> m;

  vector<pair<int, string>> submissions(m);
  vector<int> ac(n + 1, -1);
  for (int i = 0; i < m; i++) {
    cin >> submissions[i].first;
    cin >> submissions[i].second;
    if (submissions[i].second == "AC" && ac[submissions[i].first] < 0) {
      ac[submissions[i].first] = i;
    }
  }

  int penalty_cnts = 0;
  for (int i = 0; i < submissions.size(); i++) {
    auto &submission = submissions[i];
    if (ac[submission.first] > i && submission.second == "WA") {
      penalty_cnts++;
    }
  }

  int ac_cnt = count_if(ac.begin(), ac.end(), [](int n) { return n >= 0; });
  cout << ac_cnt << " " << penalty_cnts << "\n";
  return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define f first
#define s second
#define cs 137
#define ll long long
#define mp make_pair
#define N 100005
#define ln 1e16
#define oo 111539786
#define Pa pair < int, int >

using namespace std;

int n, m, X, H[N], T[N];
vector < Pa > a[N];
priority_queue < pair < ll, int > > que;
ll D[N];

int main()
{
    //filein("SUGARGLIDER.inp");  fileout("SUGARGLIDER.out");
    int u, v, w;
    cin >> n >> m >> X;
    for(int i=1; i<=n; i++)
        cin >> H[i];
    for(int i=1; i<=m; i++)
    {
        cin >> u >> v >> w;
        a[u].push_back(mp(v, w));
        a[v].push_back(mp(u, w));
    }
    for(int i=1; i<=n; i++)
        D[i] = ln;
    D[1] = 0;
    T[1] = X;
    que.push(mp(0, 1));
    while(que.empty() == 0)
    {
        pair < ll, int > P = que.top(); que.pop();
        int u = P.s;
        if(D[u] != -P.f)    continue;
        for(int i=0; i<a[u].size(); i++)
        {
            int v = a[u][i].f;
            int w = a[u][i].s;
            if(H[u] < w)    continue;
            int time = max(0, w - T[u]) + w;
            int h = max(0, T[u] - w);
            time += max(0, h - H[v]);
            h = min(h, H[v]);
            if(D[u] + time < D[v])
            {
                D[v] = D[u] + time;
                T[v] = h;
                que.push(mp(-D[v], v));
            }
        }
    }
    if(D[n] != ln)  cout << H[n] - T[n] + D[n];
    else    cout << -1;
    cout << endl;
}

Measured memory_bytes: 14656
n,m = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())

a,b = zip(*sorted(zip(a,b)))
ans = 0
cnt_drink = 0
pos = 0
while cnt_drink < m:
    if m - cnt_drink >= b[pos]:
        ans += b[pos]* a[pos]
        cnt_drink += b[pos]
    else: 
        ans += (m - cnt_drink) * a[pos]
        cnt_drink = m
    pos += 1
print(ans)

Measured memory_bytes: 64216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double n; cin >> n;
    double ans = n/1.08;
    if(floor(floor(ans)*1.08)==n) {
        cout << floor(ans) << endl;
    }
    else if(floor((floor(ans)+1.0)*1.08)==n) {
        cout << floor(ans)+1.0 << endl;
    }
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
n = ARGF.gets.to_i
b1 = ARGF.gets.split.map(&:to_i)
b2 = b1.dup
b1.push(b2.last)
b2.unshift(b1.first)
a = n.times.map do |i|
  [b1[i], b2[i]].min
end
# $stderr.puts "#{b1}"
# $stderr.puts "#{b2}"
# $stderr.puts "#{a}"
puts a.inject(&:+)


Measured memory_bytes: 1788
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      #print(a*500+b*100+c*50)
      if a*500+b*100+c*50 == X:
        count+=1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
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 T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

int main() {
    char c; cin >> c;
    cout << (char)(c+1) << endl;
}


Measured memory_bytes: 256
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

def permutations(nums, path, p):
    if len(nums) == 0:
        p.append(path)
        return
    for i in range(len(nums)):
        permutations(nums[:i] + nums[i + 1:], path + [nums[i]], p)

p = []
permutations([i for i in range(n)], [], p)

average = 0
for way in p:
    length = 0
    for i in range(len(way) - 1):
        start = way[i]
        end = way[i + 1]
        length += ((xy[start][0] - xy[end][0]) ** 2 + (xy[start][1] - xy[end][1]) ** 2) ** 0.5
    average += length / len(p)
print(average)

Measured memory_bytes: 61400
import java.util.Scanner;

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

		int[] men=new int[4];

		for(int i=0; i<4; i++) {
			men[i]=sc.nextInt();
		}
		System.out.println(Math.max(men[0]*men[1], men[2]*men[3]));
	}
}

Measured memory_bytes: 21332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int[] A;
        static long[,] dp;
        static readonly int Taro = 0;
        static readonly int Jiro = 1;
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            A = Sarray();

            dp = new long[N + 1, N + 1];//X-Y
            var k = (A.Length + 1) % 2;//偶数なら最後は次郎
            for (var i = 0; i < N; ++i)
                dp[i, i] = k == Taro ? A[i] : -A[i];
            for (var i = 1; i < N; ++i)
            {
                k = (k + 1) % 2;
                for (var s = 0; s < N - i; ++s)
                {
                    var e = s + i;
                    if (k == Taro)
                        dp[s, e] = Max(dp[s + 1, e] + A[s], dp[s, e - 1] + A[e]);
                    else
                        dp[s, e] = Min(dp[s + 1, e] - A[s], dp[s, e - 1] - A[e]);
                }
            }
            WriteLine(dp[0, N - 1]);
        }
    }
}

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

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

    if(H == 1 || W == 1){
        cout << 1 << endl;
    } else {
        if((H % 2) == 1 && (W % 2) == 1){
            cout << (H * W / 2) + 1 << endl;
        } else {
            cout << H * W / 2 << endl; 
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
using namespace std;
int main() {
    int N = 0;
    scanf("%d", &N);
    int increament = 0;
    vector<long>v (N,0);

    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int expr = (x * x + y * y + z * z + x * y + x * z + z * y);
                if (expr != 0 && expr <= N) {
                    v[expr - 1]++;
                }
            }
        }
    }

    for (int i = 0; i < v.size(); i++) {
        string str = to_string(v[i]);
        const char* l = str.c_str();
        printf(l);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3844
#include                <bits/stdc++.h>
#define ff              first
#define ss              second
#define pb(x)           push_back(x)
#define dbg(a)          cout<< #a <<" --> "<<(a)<<endl;
#define read            freopen("tst.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> PP;

int n;
string s;
vector<int> v[12],ar;

bool fn(int p){
    ar = vector<int> (3);
    for(int i = 0; i<3; i++){
        ar[2-i] = p%10;
        p/=10;
    }
    int a = ar[0],b = ar[1],c = ar[2];
    if(v[a].size()==0)  return false;
    if(v[a][0]>=n-2)    return false;
    int tmp = v[a][0];

    for(int i = 1; i<3; i++){
        int x = ar[i];
        int id = upper_bound(v[x].begin(),v[x].end(),tmp) - v[x].begin();
        if(id==v[x].size())    return false;
        tmp = v[x][id];
    }
    return 1;
}

main(){
//read;
cin>>n>>s;

for(int i = 0; i<n; i++)
    v[s[i] - '0'].push_back(i);

int ans = 0;
for(int i = 0; i<1000; i++){
    ans+=fn(i);
}

cout<<ans;

return 0;
}



Measured memory_bytes: 512
using System;

namespace AOJ.Volume2
{
    public class NextTrip
    {
        public static int Main()
        {
            while (true)
            {
                int cost = int.Parse(Console.ReadLine());
                if (cost == 0) { break; }

                int saving = 0;
                int answer = 0;
                for (int i = 1; i <= 12; i++)
                {
                    var input = Console.ReadLine().Split();
                    saving += int.Parse(input[0]) - int.Parse(input[1]);
                    if (saving >= cost)
                    {
                        if (answer == 0) { answer = i; }
                    }
                }
                Console.WriteLine(answer == 0 ? "NA" : answer.ToString());
            }
            return 0;
        }
    }
}

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

typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



int main() {

  bool flag = false;
  REP(i,3){
    char s;
    cin >> s;
    if(s=='7'){
      flag = true;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef string str;
template<class T> using vec = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> using umap = unordered_map<T, S>;
template<class T> using pqueue =  priority_queue<T>;
template<class T> using flist = forward_list<T>;
const int mbs = sizeof(bitset<1>)*8;
template<int N> using bits = bitset<mbs*((N+mbs-1)/mbs)>;

const int MOD = 1000000007; // 10^9 + 7
const double PI = 3.14159265358979323846;
const int N = 1000000; // 10^6

main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	str s,t;
	cin>>s>>t;
	int ans=0;
	REP(i,s.size())
		if(s[i]!=t[i]) ans++;
	cout<<ans;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 200005;
int n,k,h[MX];
long long ans;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n) scanf("%d", h+i);
	sort(h,h+n);
	rep(i,n-k) ans += h[i];
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>;
#define vi vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false);
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always

int main() {
    ios
    
    int n, m; cin >> n >> m;
    int ans = 0;
    rep(i, m) {int a; cin >> a; if (a > m) ans++;}
    cout << ans << endl;
}



Measured memory_bytes: 3224
N = int(input())
H = list(map(int, input().split()))

# dp[i] := 足場iに来るのにかかる最小のコスト
dp = [0 for _ in range(N)]
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    c1 = dp[i - 2] + abs(H[i] - H[i - 2])
    c2 = dp[i - 1] + abs(H[i] - H[i - 1])
    dp[i] = min(c1, c2)
ans = dp[-1]
print(ans)


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

int main(void){
    int a,b,c,count;
    cin>>a>>b>>c;

    count=0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3096