akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5 + 5;
int main()
{
	int dp[maxn];
	int h[maxn];
	int n,k;
	while(~scanf("%d %d",&n,&k)){
		for(int i=1;i<=n;i++)
			scanf("%d",&h[i]);
		dp[1] = 0;
	    for(int i=2;i<=n;i++){
	    	dp[i]=1e9;
			for(int j=1;j<=k;j++){
				if(i-j<1) break;
			    dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
				}
	}
	printf("%d\n",dp[n]);
	}
	return 0;
}


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

int main()
{
  int t,d;
  cin>>t>>d;
  int ta,tb,da,db;
  double ans = 999999999999;
  cin>>ta>>tb>>da>>db;
  for(int i=0;i*da<=d;i++)
    for (int j=0; i*da+j*db<=d; j++) {
      if(i+j==0)
	continue;
      double tmp  = (ta * (i*da*0.1) + tb * (j*db*0.1)) /  ((i*da*0.1) + (j*db*0.1));
      // cerr<<tmp<<endl;
      ans=min(ans,fabs(t-tmp));
    }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int k, a, b;
    cin >> k >> a >> b;
    FOR (i, a, b + 1) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    
    return 0;
}



Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {

    int n, x;
    int CARD[4][13] = {0};
    char m;

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf(" %c %d", &m, &x);
        if(m == 'S') CARD[0][x - 1] = 1;
        if(m == 'H') CARD[1][x - 1] = 1;
        if(m == 'C') CARD[2][x - 1] = 1;
        if(m == 'D') CARD[3][x - 1] = 1;
    }

    // printf("\n");

    for(int j = 0; j < 4; j++){
        for(int k = 0; k < 13; k++){
            if(CARD[j][k] == 0){
                if(j == 0) printf("S %d\n", k + 1);
                if(j == 1) printf("H %d\n", k + 1);
                if(j == 2) printf("C %d\n", k + 1);
                if(j == 3) printf("D %d\n", k + 1);
            }
        }
    }



    return 0;
}


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

int main(){
    string s, t; cin >> s >> t;
    
    t.erase(t.size()-1,1);

    if(t == s){
        put("Yes");
    }else{
        put("No");
    }
}

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

using namespace std;

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

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

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

int main(int argc, char **argv) {
	ll n;
	string s, t;
	cin >> n >> s;
	set<string> used;
	used.insert(s);
	REP(i, n-1) {
		cin >> t;
		if (s[s.length()-1] != t[0] || used.count(t) != 0) {
			cout << "No" << endl;
			return 0;
		}
		s = t;
		used.insert(t);
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>

using namespace std;
int a[202020],n,cnt = 0,k;
int main(){
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n; i++) {
		scanf("%d",&a[i]);
	} 
	for (int i = k+1;i <= n; i++) {
		if (a[i] > a[i-k]) {
			printf("Yes\n");
		}
		else
			printf("No\n");
	}
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans1 = 0;
  REP(i, (n-1)/2) {
    if(i != (n-1)/2-1 || n % 2 == 0) ans1 += abs(a[n-1-i] - a[i]) + abs(a[i] - a[n-2-i]);
    else if(n % 2 == 1) ans1 += abs(a[n-1-i] - a[i]);
  }
  ans1 += abs(a[n-1] - a[(n-1)/2]);
  int ans2 = 0;
  REP(i, (n-1)/2) {
    if(i != (n-1)/2-1 || n%2 == 0) ans2 +=  abs(a[i] - a[n-1-i]) + abs(a[n-1-i] - a[i+1]);
    else if(n%2 == 1) ans2 += abs(a[i] - a[n-1-i]);
  }
  if(n % 2 == 0) ans2 += abs(a[0] - a[n/2]);
  else ans2 += abs(a[0] - a[(n-1)/2]);
  cout << max(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
Su = [[] for i in range(N)]
for j in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  A = [a-1 for a in A]
  for a in A:
    Su[a].append(j)

ans = [L for L in Su if len(L) == 0]
ans = len(ans)
print(ans)

Measured memory_bytes: 9304
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A[] = new long[N + 1];
        long B[] = new long[N];
        for(int i = 0; i < N + 1; i++){
            A[i] = sc.nextLong();
        }
        for(int i = 0; i < N; i++){
            B[i] = sc.nextLong();
        }
        
        long total = 0;
        for(int i = 0; i < N; i++){
            if(A[i] <= B[i]){
                total += A[i];
                B[i] = B[i] - A[i];
            }else{
                total += B[i];
                continue;
            }
            if(A[i + 1] <= B[i]){
                total += A[i + 1];
                A[i + 1] = 0;
            }else{
                total += B[i];
                A[i + 1] = A[i + 1] - B[i];
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 87700
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    vi num;
    rep(i,42858){
        num.pb(7*i+1);
        num.pb(7*i+6);
    }
    vi pri;
    Rep(i,1,num.size()){
        bool f=true;
        for(int j=1;num[j]*num[j]<=num[i];j++){
            if(num[i]%num[j]==0){
                f=false;
                break;
            }
        }
        if(f)pri.pb(num[i]);
    }
    while(true){
        int n;
        cin>>n;
        if(n==1)break;
        cout<<n<<":";
        rep(i,pri.size()){
            if(n%pri[i]==0)cout<<sp<<pri[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 4316
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 200005
#define ll long long
int L,n,a[N],b[N];ll ans,s1[N],s2[N];
int main()
{
	scanf("%d%d",&L,&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)b[i]=L-a[n-i+1];
	for(int i=1;i<=n;i++)s1[i]=s1[i-1]+a[i],s2[i]=s2[i-1]+b[i];
	ans=max(a[n],L-a[1]);
	for(int i=1;i<n;i++)
	{
		int t=min(i,n-i);
		ll t1=(s1[i]-s1[i-t])<<1,t2=(s2[n-i]-s2[n-i-t])<<1;
		ans=max(ans,t1+t2-a[i]);
		if(i>t)ans=max(ans,t1+t2-a[i]+(a[i-t]<<1));
		ans=max(ans,t1+t2-b[n-i]);
		if(i+t<n)ans=max(ans,t1+t2-b[n-i]+b[n-i-t]*2);
	}
	printf("%lld\n",ans);
}


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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll d = c-a-b;
    if(d > 0 && d*d > 4*a*b){
        cout << "Yes" << endl;
    } else {
         cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

void sit(vector<int>&seats, int who) {
	if (who == 1) {
		for (int i = 0; i < seats.size(); ++i) {
			if (!seats[i]) {
				seats[i] = who;
				return;
			}
		}
	}
	else if (who == 2) {
		for (int i = seats.size()-1; i >= 0; --i) {
			if (!seats[i]) {
				bool ok = true;
				for (int k = i+1; k >= i-1; k -= 2) {
					if (k >= 0 && k < seats.size()) {
						if (seats[k] == 1)ok = false;
					}
				}
				if (ok) {
					seats[i] = who;
					return;
				}
			}
		}
		for (int i = 0; i < seats.size(); ++i) {
			if (!seats[i]) {
				seats[i] = who;
				return;
			}
		}
	}
	else if (who == 3) {
		for (int i = 0; i < seats.size(); ++i) {
			if (seats[i]) {
				if (i!=seats.size()-1&&!seats[i+1]) {
					seats[i+1] = who;
					return;
				}
				else if (i != 0 && !seats[i - 1]) {
					seats[i - 1] = who;
					return;
				}
			}
		}
		seats[seats.size() / 2] = who;
		return;
	}
	else {
		vector<int>diss(seats.size(), 1000);
		for (int i = 0; i < seats.size(); ++i) {
			if (seats[i]) {
				diss[i] = 0;
				for (int j = i - 1; j >= 0; --j) {
					diss[j] = min(diss[j], i-j);
				}
				for (int j = i + 1; j < seats.size(); ++j) {
					diss[j] = min(diss[j], j - i);
				}
			}
		}
		int maxdis = -1;
		int ans = -1;
		for (int i = 0; i < seats.size(); ++i) {
			if (maxdis < diss[i]) {
				maxdis = diss[i];
				ans = i;
			}
		}
		seats[ans] = who;
		return;
	}
	assert(false);
}

int main() {
	while (1) {
		vector<int>nums(3);
		vector<int>hs(5);
		for (int i = 0; i < 5; ++i) {
			int h; cin >> h;
			if (!i&&!h)return 0;
			h--; nums[h]++;
			hs[i] = h;
		}
		if (nums[0] == 5 || nums[1] == 5 || nums[2] == 5 || (nums[0] && nums[1] && nums[2])) {
			for (int i = 0; i < 5; ++i) {
				cout << 3 << endl;
			}
		}
		else {
			for (int j = 0; j < 3; ++j) {
				if (nums[j] && nums[(j + 1) % 3]) {
					for (int k = 0; k < 5; ++k) {
						if (hs[k] == j) {
							cout << 1 << endl;
						}
						else {
							cout << 2 << endl;
						}
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2960
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


MOD=(10**9+7)
m,n=get_i
ans=1
while n>0
    ans=ans*m%MOD if (n&1)==1
    m=m*m%MOD
    n>>=1
end
puts ans


Measured memory_bytes: 6884
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A_Painting.exe A_Painting.cpp 
Execute: ./A_Painting
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
using namespace std;

int main() { 	
	/* Input */ 
	int h, w, n;
	cin >> h >> w >> n;
	
	/* Calculations */ 
	int b_min, b_max, result; 
	b_min = (h < w)? h : w;
	b_max = (h > w)? h : w;
	result = 1 + ((n - 1) / b_max); 
	
	/* Output */ 
	cout << result << endl;
	
	return 0; 
} 


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

array<int, 4> the_change(int n) {
    if(n <= 0) return {{0, 0, 0, 0}};

    array<int, 4> ret;
    ret[3] = n / 500, n %= 500;
    ret[2] = n / 100, n %= 100;
    ret[1] = n / 50, n %= 50;
    ret[0] = n / 10;
    return ret;
}

int main() {
    int N;
    bool is_first = true;
    while(cin >> N, N) {
        if(!is_first) {
            cout << endl;
        }
        is_first = false;

        array<int, 4> coin; // 10, 50, 100, 500
        for(int i=0; i<4; ++i) {
            cin >> coin[i];
        }

        int num = 1e9;
        array<int, 4> ret;
        for(int i=0; i<=coin[0]; ++i) { // 20^4
            for(int j=0; j<=coin[1]; ++j) {
                for(int k=0; k<=coin[2]; ++k) {
                    for(int l=0; l<=coin[3]; ++l) {
                        if(N <= i*10 + j*50 + k*100 + l*500) {
                            auto change = the_change(i*10 + j*50 + k*100 + l*500 - N);
                            array<int, 4> pay = {i, j, k, l};
                            int rest = accumulate(coin.begin(), coin.end(), 0);
                            for(int m=0; m<change.size(); ++m) {
                                int tmp = min(change[m], pay[m]);
                                change[m] -= tmp;
                                pay[m] -= tmp;
                                rest += change[m] - pay[m];
                            }
                            if(rest < num) {
                                for(int m=0; m<4; ++m) {
                                    ret[m] = pay[m];
                                }
                                num = rest;
                            }
                        }
                    }
                }
            }
        }
        array<int, 4> tmp2 = {10, 50, 100, 500};
        for(int i=0; i<4; ++i) {
            if(ret[i] != 0) {
                cout << tmp2[i] << " " << ret[i] << endl;
            }
        }
    }
}


Measured memory_bytes: 3064
#include <stdio.h>

int n, G[100][100];

int prim(){
    
    int u, m, d[100], p[100], c[100], i, v, sum = 0;
    
    for(i = 0; i < n; i++){
        d[i] = 10000;
        p[i] = -1;
        c[i] = 0;
    }
    
    d[0] = 0;
    
    while(1){
        m = 10000;
        u = -1;
        for(i = 0; i < n; i++){
            if(m > d[i] && c[i] != 2){
                u = i;
                m = d[i];
            }
        }
        if(u == -1) break;
        c[u] = 2;
        for(v = 0; v < n; v++){
            if(c[v] != 2 && G[u][v] != 10000){
                if(d[v] > G[u][v]){
                    d[v] = G[u][v];
                    p[v] = u;
                    c[v] = 1;
                }
            }
        }
    }
    for(i = 0; i < n; i++){
        if(p[i] != -1){
            sum += G[i][p[i]];
        }
    }
    return sum;
}

int main(){
    
    int i, j, u;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
             scanf("%d", &u);
            if(u == -1) G[i][j] = 10000;
            else G[i][j] = u;
        }
    }

    printf("%d\n", prim());
    
    return 0;
    
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

static class Program
{
    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    static void Main(string[] args)
    {
        int[] args1 = ReadInts();
        int N = args1[0];
        int T = args1[1];
        int[] t = ReadInts();
        int sum = Enumerable.Range(0, N - 1).Sum(i => Math.Min(t[i + 1] - t[i], T)) + T;
        Console.WriteLine(sum);
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int maxn = in.nextInt();
            int maxk = in.nextInt();
            long modulo = in.nextLong();
            long[][] c = new long[maxn + 1][maxn + 1];
            c[0][0] = 1 % modulo;
            for (int i = 1; i <= maxn; ++i) {
                c[i][0] = 1 % modulo;
                for (int j = 1; j <= maxn; ++j) {
                    c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % modulo;
                }
            }
            long[][] res = new long[maxn + 1][maxk + 1];
            Arrays.fill(res[0], 1);
            for (int n = 1; n <= maxn; ++n) {
                for (int k = 1; k <= maxk; ++k) {
                    if (k == 1) {
                        res[n][k] = 1 % modulo;
                    } else {
                        res[n][k] = res[n][k - 1];
                        for (int before = 0; before < n; ++before) {
                            res[n][k] = (res[n][k] + res[before][k - 1] * c[n][before] % modulo * res[n - 1 - before][k]) % modulo;
                        }
                    }
                }
            }
            out.println(res[maxn][maxk]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 26248
package main

import "fmt"

func main() {
    var a,b,c int

    fmt.Scan(&a, &b, &c)

    abc := a*100 + b*10 + c
    if (abc%4 == 0) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }

    
}

Measured memory_bytes: 512
// AOJ Vol-3 0300: Floppy Cube
// 2017.9.30

#include <stdio.h>
#include <string.h>

int ans;

int rot[4][31] = {
	{ 0,1,2,3,4,5,6,22,23,24,12,11,10,18,14,15,16,17,13,19,20,21,7,8,9,25,26,27,28,29,30 },
	{ 0,28,29,30,4,5,6,7,8,9,10,11,12,13,14,16,15,17,18,21,20,19,22,23,24,25,26,27,1,2,3 },
	{ 0,24,2,3,27,5,6,30,8,9,21,11,12,13,14,15,18,17,16,19,20,10,22,23,1,25,26,4,28,29,7 },
	{ 0,1,2,22,4,5,25,7,8,28,10,11,19,15,14,13,16,17,18,12,20,21,3,23,24,6,26,27,9,29,30 }};

int check(char *a)
{
	int i;
	for (i =  2; i <=  9; i++) if (a[i] != a[ 1]) return 0;
	for (i = 11; i <= 12; i++) if (a[i] != a[10]) return 0;
	for (i = 14; i <= 15; i++) if (a[i] != a[13]) return 0;
	for (i = 17; i <= 18; i++) if (a[i] != a[16]) return 0;
	for (i = 20; i <= 21; i++) if (a[i] != a[19]) return 0;
	for (i = 23; i <= 30; i++) if (a[i] != a[22]) return 0;
	return 1;
}

void dfs(char *a, int k)
{
	int i, j;
	char b[31];

	if (check(a)) { if (k < ans) ans = k; return ; }
	if (k > ans) return;
	for (i = 0; i < 4; i++) {
		for (j = 1; j <= 30; j++) b[j] = a[rot[i][j]];
		dfs(b, k+1);
	}
}

int main()
{
	int n, i, t;
	char a[31];

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 1; i <= 30; i++) scanf("%d", &t), a[i] = t;
		if (check(a)) puts("0");
		else {
			ans = 8;
			dfs(a, 0);
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1796
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    num1=str(i)
    num2=0
    for j in range(len(num1)):
        num2+=int(num1[j])
    if num2>=a and num2<=b:
        ans+=i
print(ans)


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC132C()
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (auto& x : d)
		cin >> x;
	sort(d.begin(), d.end());
	int M = N / 2;
	int B = d[M-1];
	int R = d[M];
	int K = R - B;
	cout << K << endl;
}

int main()
{
	ABC132C();
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	while(b!=0)
	{
		int r=a%b;
		a=b;
		b=r;
	}
	return a;
}
int main(void)
{
	long long n,an=0,g;
	cin>>n;
	for(int i=1;i<=n;i++){
	for(int h=1;h<=n;h++){
	for(int j=1;j<=n;j++)
	{
		int g=gcd(i,h);
		an+=gcd(g,j);
	}}
}
	cout<<an;
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
X = list(map(int, input().split()))
#N / 2 or N / 2 + 1番目
center1 = sorted(X)[int(N / 2) - 1]
center2 = sorted(X)[int(N / 2)]
for i in range(N):
    if X[i] > center1:
        print(center1)
    else:
        print(center2)



Measured memory_bytes: 26772
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	unsigned long long sum;
	int n;

	cin >> n;

	sum = 0;
	for( int i = 0;i < n;i++ ){
		unsigned int money;
		cin >> money;
		sum += money;
	}

	cout << ( sum / n ) << endl;
	return 0;
}

Measured memory_bytes: 0
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[4005][4005][2];
int sum[4005][4005][2];
char c[5];
inline int calc_sum(int i,int j,int k,int l)
{
    return sum[i+k][j+k][l]-sum[i][j+k][l]-sum[i+k][j][l]+sum[i][j][l];
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,k;
    scanf("%d%d",&n,&k);
    int t=k*2;
    int i;
    for (i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x%=t;
        y%=t;
        scanf("%s",c);
        if (c[0]=='B')
        {
            a[x][y][0]++;
        }
        else
        {
            a[x][y][1]++;
        }
    }
    int j;
    for (i=0;i<t;i++)
    {
        for (j=0;j<t;j++)
        {
            a[i+t][j][0]=a[i][j][0];
            a[i][j+t][0]=a[i][j][0];
            a[i+t][j+t][0]=a[i][j][0];
            a[i+t][j][1]=a[i][j][1];
            a[i][j+t][1]=a[i][j][1];
            a[i+t][j+t][1]=a[i][j][1];
        }
    }
    t*=2;
    for (i=0;i<t;i++)
    {
        for (j=0;j<t;j++)
        {
            sum[i+1][j+1][0]=sum[i+1][j][0]+sum[i][j+1][0]-sum[i][j][0]+a[i][j][0];
            sum[i+1][j+1][1]=sum[i+1][j][1]+sum[i][j+1][1]-sum[i][j][1]+a[i][j][1];
        }
    }
    int val=0;
    for (i=0;i<k;i++)
    {
        for (j=0;j<k+k;j++)
        {
            //Start from here!
            val=max(val,calc_sum(i,j,k,0)+calc_sum(i+k,j+k,k,0)+calc_sum(i+k,j,k,1)+calc_sum(i,j+k,k,1));
        }
    }
    printf("%d\n",val);
    return 0;
} 


Measured memory_bytes: 250752
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])

    prime = [1]
    for p in res:
        for _ in range(p[1]):
            prime.append(p[0])

    return prime


def resolve():
    a, b = map(int, input().split())
    A = prime_factorization(a)
    B = prime_factorization(b)

    res = set(A) & set(B)
    print(len(res))


if __name__ == '__main__':
    resolve()


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

void fnInput(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

int64_t fnConvInt(const vector<char>& cnrvcNum)
{
  const vector<int> cnvnNum = {0, 3, 5, 7};

  vector<char> vcRevNum(cnrvcNum);
  reverse(begin(vcRevNum), end(vcRevNum));

  int64_t nNum = 0;
  for (int i = 0; i < vcRevNum.size(); i++)
  {
    if (vcRevNum[i] == '0') break;
    nNum += cnvnNum[ vcRevNum[i] - '0' ] * pow(10, i);
  }

  return nNum;
}

int fnDgt753_Check(const vector<char>& rvcNum)
{
  int nDig3 = 0, nDig5 = 0, nDig7 = 0;

  for (int i = 0; i <rvcNum.size(); i++)
    if      (rvcNum[i] == '1') nDig3++;
    else if (rvcNum[i] == '2') nDig5++;
    else if (rvcNum[i] == '3') nDig7++;

  if (nDig3 && nDig5 && nDig7)
    return 1;
  else
    return 0;
}

int fnDgt753_Count(int nMaxNum)
{
  vector<char> vcNum(11, '0');
  int nDgt753Cnt = 0;

  while (true)
  {
    vcNum[vcNum.size() - 1]++;
    for (int i = vcNum.size() - 1; i >= 1; i--)
      if (vcNum[i] > '3')
      {  
        vcNum[i - 1]++;
        vcNum[i] = '1';
      }
      else
        break;

    if (!fnDgt753_Check(vcNum)) continue;
    if (fnConvInt(vcNum) > nMaxNum) break;
    nDgt753Cnt++;
  }

  return nDgt753Cnt;
}

int main()
{
  int nMaxNum;

  fnInput(nMaxNum);
  cout << fnDgt753_Count(nMaxNum) << endl;

  return 0;
}

Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))
#print(n,l)

ans = 0
for i in range(1,n-1):
  if l[i] > l[i-1] and l[i+1] > l[i]:
    ans += 1
  elif l[i] < l[i-1] and l[i+1] < l[i]:
    ans += 1
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d = [0]*(n+1)
for i in range(n):
  if a[i] >= b[i]:
    d[i] += b[i]
  else:
    d[i] += a[i]
    if a[i+1] < b[i] -a[i]:
      d[i+1] = a[i+1]
      a[i+1] = 0
    else:
      d[i+1] = b[i] - a[i]
      a[i+1] -= b[i] -a[i]
      
print(sum(d))

Measured memory_bytes: 18476
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> x(n+2), sorted_x(n+1);
  int sum = 0;
  for(int i = 1; i <= n; i++){
    cin >> x[i];
  }
  x[0] = 0;
  x[n+1] = 0;
  for(int i = 0; i <= n; i++){
    sum += abs(x[i+1] - x[i]);
  }
  for(int i = 1; i <= n; i++){
    cout << sum + abs(x[i+1] - x[i-1]) - (abs(x[i+1] - x[i]) + abs(x[i] - x[i-1])) << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  vector<int> ans(N);
  for(int i = 0; i < 30; i++) {
    int sum = 0;
    for(int j = 0; j < N; j++) {
      sum += data.at(j) % 2;
    }
    sum %= 2;
    for(int k = 0; k < N; k++) {
      if(data.at(k) % 2 != sum) {
        ans.at(k) += pow(2, i);
      }
      data.at(k) /= 2;
    }
  }
  for(int i = 0; i < N; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4864
#include <stdio.h>
#include <string.h>
#define T_MAX 1000001
#define P_MAX 10001
  
int main(){
  char T[T_MAX];
  char P[P_MAX];
  int i, S1, S2;
      
  scanf("%s",T);
  scanf("%s",P);
    
  S1=strlen(T);
  S2=strlen(P);
      
  for(i=0;i<S1;i++){
    if(strncmp(&T[i],P,S2)==0)printf("%d\n",i);
  }
          
  return 0;
      
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int h, w, c, s[8][8], res;

int p(int d) {
	d += c*10000;
	int t[8][8] = {};
	rep(i,h) rep(j,w) t[i][j] = s[i][j];
	rep(k,5) {
		int l = t[0][0], r = d%10;
		d /= 10;
		if (l==r) continue;
		queue<pii> q;
		q.push({0,0});
		while (!q.empty()) {
			int x = q.front().fi, y = q.front().se; q.pop();
			t[x][y] = r;
			rep(i,4) {
				int xx = x + dx[i], yy = y + dy[i];
				if (ool(xx,yy,h,w) || t[xx][yy]!=l) continue;
				q.push({xx,yy});
			}
		}
	}
	queue<pii> q;
	q.push({0,0});
	bool u[8][8] = {};
	while (!q.empty()) {
		int x = q.front().fi, y = q.front().se; q.pop();
		u[x][y] = 1;
		rep(i,4) {
			int xx = x + dx[i], yy = y + dy[i];
			if (ool(xx,yy,h,w) || t[xx][yy]!=c || u[xx][yy]) continue;
			q.push({xx,yy});
		}
	}
	int sum = 0;
	rep(i,h) rep(j,w) sum += u[i][j];
	return sum;
}

void cal(int d, int t) {
	if (t==4) chmax(res,p(d));
	else repst(i,1,6) cal(d*10+i, t+1);
}

signed main() {
	while (1) {
		cin >> h >> w >> c;
		if (h==0) break;
		rep(i,h) rep(j,w) cin >> s[i][j];
		res = 0;
		cal(0,0);
		cout << res << ln;
	}
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 200005

class UnionFind
{
public:
  int par[MAX_N];
  int depth[MAX_N];
  int nGroup[MAX_N];

  UnionFind(int n) {
    init(n);
  }

  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }

  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m; cin >> n >> m;
  UnionFind uf(2*n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, n+b);
    uf.unite(n+a, b);
  }
  bool isBipartite = true;
  int nb = 0;
  rep(i, n) {
    if(uf.root(i) == uf.root(n+i)) isBipartite = false;
    if(uf.root(i) == uf.root(0)) nb++;
  }
  cout << (isBipartite ? nb*(n-nb)-m : n*(n-1)/2-m) << "\n";
  return 0;
}


Measured memory_bytes: 5968
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 101000

typedef long long i64;

int n, m, cnt[2], stk[NR], top, d[NR], cX, cY, len, sum;
vector<int> g[NR];
bool col[NR], vc[NR];
i64 ans;

void paint(int x, int fa) {
	
	d[x] += col[x] ? +1 : -1;
	for (int v : g[x]) if (v != fa) 
		col[v] = col[x] ^ 1, paint(v, x);
}

void del_vec(vector<int> &a, int e) {
	for (auto it = a.begin(); it != a.end(); ++it)
		if (*it == e) {
			a.erase(it);
			return;
		}
}

void find_cycle(int x, int fa) {
	vc[x] = true; stk[++top] = x;
	int del = -1;
	for (int v : g[x]) if (v != fa) {
	//	printf("!%d %d\n", x, v);
		if (!vc[v]) find_cycle(v, x);
		else if (!cX) {
			cX = x, cY = v;
 		//	iter(i, top) printf("%d ", stk[i]);
		//	printf(" (%d %d)\n", x, v);
			for (len = 0; stk[top - len] != v; ++len);
			++len;
			del = v;
		} else del = v;
	}
	if (del != -1) del_vec(g[x], del);
	--top;
}

int dfs(int x, int fa) {
	int sum = d[x];
	for (int v : g[x]) if (v != fa) sum += dfs(v, x);
	ans += abs(sum);
	return sum;
}

i64 solve(int dX, int dY) {
	iter(i, n) d[i] = 0;
	paint(1, 0);
//	printf("!%d %d %d\n", cX, cY, len);
	d[cX] += dX, d[cY] += dY;
	ans = 0;
	sum = dfs(1, 0);
	return sum != 0 ? -1 : ans;
}

i64 F(int x) { return solve(x, -x) + abs(x); }
int abs(int x) { return x > 0 ? x : -x; }
int main() {
	scanf("%d%d", &n, &m);
	if (n % 2 != 0) { puts("-1"); return 0; }

	iter(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y), g[y].push_back(x);
	}

	if (m == n - 1) printf("%d\n", solve(0, 0));
	else {
		find_cycle(1, 0);
		if (len % 2 == 0) {
			if (solve(0, 0) == -1) puts("-1");
			else {
				int l = 0, r = 2 * n;
				for (; l < r - 3; ) {
					int _l = (l * 2 + r) / 3, _r = (l + r * 2) / 3;
					if (F(_l - n) < F(_r - n)) r = _r;
					else l = _l;
				}
				i64 mn = F(l - n);
				for (int i = l + 1; i <= r; ++i) {
					i64 tmp = F(i - n);
					if (tmp < mn) mn = tmp, l = i;
				}
				printf("%lld\n", mn);
			}
		} else {
			i64 tmp = solve(0, 0); int s = sum;
			printf("%lld\n", tmp != -1 ? tmp : (solve(-s / 2, -s / 2) + abs(s)/2));
		}
	}
	return 0;
}


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

int N, A, B, C;
int l[8];

int dfs (int cur, int a, int b, int c) {
  
  if (cur == N) {
    if (min(a, min(b, c)) > 0) {
      return abs(a - A) + abs (b - B) + abs(c - C) - 30;
    } else {
      return 1e9;
    }
  }
  
  int ret0 = dfs (cur + 1, a, b, c);
  int ret1 = dfs (cur + 1, a + l[cur], b, c) + 10;
  int ret2 = dfs (cur + 1, a, b + l[cur], c) + 10;
  int ret3 = dfs (cur + 1, a, b, c + l[cur]) + 10;
  
  return min(ret0, min(ret1, min(ret2, ret3)));
}
 
int main() {

  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  cout << dfs (0, 0, 0, 0) << endl;
  
}

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

int main(){
	int a[5];
	int sum = 0;
	for(int i=0;i<5;i++){
		cin >> a[i];
	}
	int max = 0;
	for(int i=0;i<5;i++){
		sum += ceil((double)a[i]/10)*10;
		int tmp = ceil((double)a[i]/10)*10-a[i];
		if(max<tmp){
			max = tmp;
		}
	}
	cout << sum - max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    if(N % 2 != 0){cout << 0;return 0;}
    N /= 2;
    for(ll i = 5;i <= N;i*=5){
        ans += N / i;
    }
    cout << ans;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    while(t!="END_OF_TEXT"){
        for(int i=0; i<t.size(); ++i){
            if(t[i]>='A'&&t[i]<='Z')t[i]+=32;
        }
        if(s==t)ans++;
        cin>>t;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

long long int a(long long int N) {
	long long int i;
	long long int max = 0;
	for (i = 2; i * i <= N; i++) {
		if (N % i == 0) {
			if (i > max) max = i;
		}
	}
	if (max == 0) {
		return 0;
	}
	else {
		return max;
	}
}


int main() {
	long long int N;
	long long int x, y;
	scanf("%lld", &N);

	x = a(N);
	if (x == 0) {
		printf("%lld", N - 1);
	}
	else {
		y = N / x;
		printf("%lld", x + y - 2);
	}

	return 0;
}

Measured memory_bytes: 128
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, w, i, j;
    cin>>n>>w;
    vector<int> weight(n), value(n);
    long long total = 0;
    for(i=0;i<n;++i)
    {
        cin>>weight[i]>>value[i];
        total += value[i];
    }
    vector<long long> dp(total+1,INT_MAX);
    dp[0] = 0;
    for(i=0;i<n;++i)
    {
        for(j=total-value[i];j>=0;--j)
        {
            dp[j+value[i]] = min(dp[j+value[i]], dp[j]+weight[i]);
        }
    }
    long long ans = 0;
    for(i=0;i<total+1;++i)
    {
        if(dp[i] <= w)
            ans = max(ans,(long long)i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
bool cust(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} 
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
int dive[10000001];
void ans(int n) { 
    memset(dive, 0, n+1); 
    for (int i = 1; i <= n; i++) { 
        for (int j = 1; j * i <= n; j++) 
            dive[i * j]++; 
    } 
    for (int i = 1; i <= n; i++) {
        dive[i]*=i;
        if(i!=1){
        	dive[i]+=dive[i-1];
        }
    }
}
int32_t main(){
	kehsihba();
	ll n;cin>>n;
	ans(n);
	cout<<dive[n];
}

Measured memory_bytes: 81756
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

int h[1000000];
int ANS = 0;
int a, b, c[1002][1002], x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
P d[1000000];
int main() {
	memset(h, -1, sizeof(h));
	for (int i = 0; i < 1002; i++) {
		for (int j = 0; j < 1002; j++) {
			c[i][j] = 1 << 29;
		}
	}
	cin >> a >> b;
	for (int e = 0; e < a; e++) {
		for (int f = 0; f < b; f++) {
			int g; scanf("%d", &g);
			g--;
			c[e + 1][f + 1] = g;
			d[g] = P(e + 1, f + 1);
		}
	}
	for (int i = 0; i < a*b; i++) {
		int dx = d[i].first, dy = d[i].second;
		bool k = false; int sum = 0;
		for (int j = 0; j < 4; j++) {
			if (c[dx + x[j]][dy + y[j]]<i) {
				sum++;
				if (h[c[dx + x[j]][dy + y[j]]] ==-1) {
					k = true;
				}
				else {	
					if (h[i] == -1) {
						h[i] = h[c[dx + x[j]][dy + y[j]]];
					}
					else if (h[i] != h[c[dx + x[j]][dy + y[j]]])k = true;
				}
			}
		}
		if (sum!=0) {
			if (k)h[i] = -1;
			else  {  ANS++; }
		}
		else {
			h[i] = i;
			ANS++;
		}
	}
	cout << a*b-ANS << endl;
}

Measured memory_bytes: 18804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

int INF = 1e9;

int main(){
  int n;
  string s, ans = "";
  cin >> n >> s;
  for(char &c: s){
    if(c+n > 'Z') ans += c + n - 26;
    else ans += c + n;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int k,s;
  cin >> k >> s;
  int ans = 0;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int z = s-(x+y);
      if(z<0||z>k) continue;
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {

  int n;
  cin >> n;
  vector<int> boss(n);
  rep(i,n-1){
    int x;
    cin >> x;
    ++boss[--x];
  }
  rep(i,n){
    cout << boss [i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,l;
  cin>>n>>l;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  
  bool flag = false;
  int index;
  REP(i,n-1){
    if(a[i]+a[i+1]>=l){
      flag = true;
      index = i;
      break;
    }
  }
  if(!flag){
    cout<<"Impossible"<<endl;
    return 0;
  }
  
  cout<<"Possible"<<endl;
  REP(i,index){
    cout<<i+1<<endl;
  }
  for(int i=n-2;i>index;i--){
    cout<<i+1<<endl;
  }
  cout<<index+1<<endl;
  return 0;
}


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

const int N = 105;
int in[N];

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> in[i];

    int res = 1e9;
    for(int avg = -100; avg <= 100; ++avg) {
        int s = 0;
        for(int i = 1; i <= n; ++i) {
            s += (avg - in[i]) * (avg - in[i]);
        }
        res = min(res, s);
    }
    cout << res << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// dp[i][j]i桁目まで見た時に、0でない数値の個数がj個
// dp[i][j]:i桁目まで見ている時の数値の個数、j=0は今の所nと同値、j=1はn未満が確定
ll dp[101][2][4];

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

  dp[0][0][0]=1;
  rep(i, s.size()){
    int c = s[i]-'0';
    rep(j, 10)rep(kk, 4){
      // kは非0の個数を表す、前のkの値をひとまずそのまま使い、もしjが0よりも大きければ非0が増えるのでインクリメントする。そしてk<=3なのでkが3を超えたら無視する。
      int nk=kk;
      if(j>0) nk++;
      if(nk>3)continue;

      if(j<c){
        // 今見ている桁の数値がNの同じ桁よりも小さいなら、その時点でN未満が確定する。なので、N一致とN未満確定の2つの個数を同時に加算する

        dp[i+1][1][nk] += dp[i][0][kk]+dp[i][1][kk];
        // cout<<dp[i][0][kk]<<' '<<dp[i][1][kk]<<endl;
      }else if(j==c){
        // 今見ている桁の数値がNと一致しているなら、前の桁の`今の所Nと一致している数値の個数`をそのまま加算する
        dp[i+1][0][nk] += dp[i][0][kk];
        // N未満が確定済みなら今見ている桁がNと一致していても問題ないのでN未満確定済みはそのまま加算する。
        dp[i+1][1][nk] += dp[i][1][kk];
      }else{
        // Nと一致している状態で、今見ている桁がNよりも大きいと、Nを超過するため、N未満確定の数値の個数のみ加算する
        dp[i+1][1][nk] += dp[i][1][kk];
      }
    }
    // rep(k,4)cout<<dp[i+1][0][k]<<' '<<dp[i+1][1][k]<<endl;
    // cout<<endl;
  }

  ll result = dp[s.size()][0][k] + dp[s.size()][1][k];
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
	char ch[5];
	scanf("%s", ch);
	if((ch[0]=='a' or ch[1]=='a' or ch[2]=='a') and (ch[0]=='b' or ch[1]=='b' or ch[2]=='b') and (ch[0]=='c' or ch[1]=='c' or ch[2]=='c'))
	printf("Yes");
	else
	printf("No");
	
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}

	vector<int> c(30, 0);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int x = a[i][j] - 'a';
			c[x]++;
		}
	}
	sort(c.begin(), c.end(), greater<int>());

	int cnt4 = 0, cnt2 = 0, cnt1 = 0;
	if ((H % 2 == 0) && (W % 2 == 0)) {
		cnt4 = (H / 2) * (W / 2);
	} else if ((H % 2 == 1) && (W % 2 == 1)) {
		cnt4 = (H / 2) * (W / 2);
		cnt2 = (H / 2) + (W / 2);
		cnt1 = 1;
	} else {
		cnt4 = (H / 2) * (W / 2);
		cnt2 = H / 2;
		if (H % 2 == 1) cnt2 = W / 2;
	}

	while (cnt4 > 0) {
		if (c[0] - 4 >= 0) {
			c[0] -= 4;
			cnt4--;
			sort(c.begin(), c.end(), greater<int>());
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	while (cnt2 > 0) {
		if (c[0] - 2 >= 0) {
			c[0] -= 2;
			cnt2--;
			sort(c.begin(), c.end(), greater<int>());
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	while (cnt1 > 0) {
		if (c[0] - 1 >= 0) {
			c[0] -= 1;
			cnt1--;
			sort(c.begin(), c.end(), greater<int>());
		} else {
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 0; i < c.size(); i++) {
		if (c[i] != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256