akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

template<typename T> 
vector<T> getFactor(T n) {
    vector<T> ret;

    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }

    sort(ret.begin(), ret.end());

    return ret;
}

int main(void)
{
    int n;
    cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i += 2) {
        auto f = getFactor(i);
        if(f.size() == 8) {
            ans++;
        }
    }
    cout << ans << endl;
     
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}
 
const int INF = 1e18, MAXN = 2e5 + 10, MOD = 1e9 + 7;
 
void solve() {
	int n;
	cin >> n;

	map<int, int> cnt;
	for (int i = 2; i <= n; ++i) {
		int d = 2, num = i;
		while (d * d <= num) {
			if (num % d == 0) {
				cnt[d]++; num /= d;
			}
			else {
				d++;
			}
		}

		if (num != 1) {
			cnt[num]++;
		}
	}

	vi dt;
	for (auto it : cnt) {
		int amount = it.y;
		if (amount + 1 >= 3) {
			dt.pb(amount + 1);
		}
	}

	sort(all(dt));

	if (len(dt) <= 1) {
		cout << 0 << endl;
		return;
	}

	int ans = 0;
	if (dt.back() >= 75) {
		ans++;
	}

	for (int i = 0; i < len(dt); ++i) {
		if (dt[i] >= 5) {
			int k = len(dt) - i;
			ans += ((k * (k - 1) / 2) * (len(dt) - 2));
			break;
		}
	}

	for (int i = 0; i < len(dt); ++i) {
		if (dt[i] >= 15) {
			int k = len(dt) - i;
			// ans += k * (n - 1);
			for (int j = 0; j < len(dt); ++j) {
				if (dt[j] >= 5) {
					int k2 = len(dt) - j;
					ans += k * (k2 - 1);
					break;
				}
			}
			break;
		}
	}

	for (int i = 0; i < len(dt); ++i) {
		if (dt[i] >= 25) {
			int k = len(dt) - i;
			ans += k * (len(dt) - 1);
			break;
		}
	}

	cout << ans << endl;
}


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

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

std::vector<int> A;
std::vector<std::vector<bool>> P;
std::vector<std::vector<int>>  Q;
/*
    P[i][j] = 先頭 i 枚を使った時に合計 j にできるか
    Q[i][j] = 後半 i 枚を使った時に合計 j にできるか
    ====> Qについて累積和をとれば区間に属するかがO(1)で判定可能
*/


int main(void){
    int n, k; scanf("%d%d", &n, &k);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    P.resize(n+1, std::vector<bool>(k, false));
    Q.resize(n+1, std::vector<int>(k+1, 0));
    P[0][0] = true;
    REP(i, n){
        REP(j, k) if(P[i][j]){
            P[i+1][j] = true;
            if(j + A[i] < k) P[i+1][j+A[i]] = true;
        }
    }
    Q[0][0] = 1;
    REP(i, n){
        REP(j, k) if(Q[i][j]){
            Q[i+1][j] = 1;
            if(j + A[n-i-1] < k) Q[i+1][j+A[n-i-1]] = 1;
        }
    }
    for(int i=0;i<=n;++i) REP(j,k) Q[i][j+1] += Q[i][j];
    int res = 0;
    REP(i, n){
        bool need = false;
        REP(j, k) if(P[i][j]){
            int u = k - j - 1;
            int vu = Q[n-i-1][u];
            int l = k - A[i] - j - 1;
            int vl = l < 0 ? 0 : Q[n-i-1][l];
            if(vu != vl){
                need = true; break;
            }
        }
        if(not need) res++;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 101504
N,C,K=map(int,input().split())
Tn=sorted([int(input()) for _ in range(N)])

b_cnt=0
p_cnt=0
time=Tn[0]+K
for t in Tn:

    # print(time, p_cnt)
    if (time < t) or (p_cnt >= C) :
        # バス出発
        b_cnt+=1
        p_cnt=0
        time=t+K
        # print("ride", b_cnt)
    p_cnt+=1
else:
    b_cnt+=1

print(b_cnt)


Measured memory_bytes: 8280
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z') cout << 'a' << endl;
	else cout << "A" << endl;
}

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



int main() {
  int n,k;

  int total = 0;

  cin >> n >> k;

  vector<int> p(n);

  rep(i,n){
    cin >> p.at(i);
  }

  sort(p.begin(),p.end());

  rep(i,k){
    total+=p.at(i);

  }

  cout << total;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n,k;
    cin>>n>>k;
    ll h[n+1];
    FOR(i,1,n)
    {
        cin>>h[i];
    }
    vector<ll> dp(n+1,INT64_MAX);
    dp[0]=0;
    dp[1]=0;
    if(n==1)
    return cout<<0,0;
    dp[2]=abs(h[1]-h[2]);
    if(n==2)
    return cout<<dp[2],0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n];
  }  
  return 0;
}

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

int main() {
	string s;
	int K;
	cin >> s >> K;
	set <string> st;
	for (int i = 0;i < K;i++) {
		for (int j = 0;j + i < s.size();j++) {
			st.insert(s.substr(j,i+1));
		}
	}
	int count = 0;
	string ans;
	for (auto it = st.begin();it != st.end();it++) {
		count++;
		if (count == K) {
			ans = *it;
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<algorithm>
#define lint long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define PI 3.14159265358979323846264338327950288
using namespace std;

int main(){
  double a;
  cin>>a;
  printf("%f %f\n",PI*pow(a,2),2*PI*a);
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b, c;
  cin >> n;
  int A=0, B=0, C=0;
  for(int i = 0; i < n; i++){
    cin >> a >> b >> c;
    a+=max(B, C);
    b+=max(A, C);
    c+=max(A, B);
    A = a; B = b; C = c;
  }
  cout << max(A, max(B, C)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	long long int a = 0, b = 0, c = 0, d = 0, n = 0, ans = 2, h, count = 0, w, up, down, end = 0, idx, m, kuso=0, k, ni = 0;
	string s;
	vector<long long int> x;
	vector<long long int>::iterator position;
	bool q = false;
	cin >> h;
	count = h;
	while (1) {
		count /= 2;
		kuso++;
		if (count <= 1)break;
	}
	for (int i = 0; i < kuso; i++) {
		ans *= 2;
	}
	if (h == 1)cout << 1 << endl;
	else cout << ans - 1 << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout<<max(a - b, max(a + b, a * b))<<endl;
    return 0;
}

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

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

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

  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;

  if((a1+a2+a3) >= 22) {
    cout << "bust" << endl;
  }

  else {
    cout << "win" << endl;
  }
  return 0;
}


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



int main(void){
    int n;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    for(int i = 0;i < n;i++){
          cin >> t[i];
          sum += t[i];
    }
    int m;
    cin >> m;
    for(int i = 0;i < m;i++){
          int p,x;
          cin >> p >> x;
          p--;
          cout << sum - t[p] + x << endl;
    }
}


Measured memory_bytes: 256
num = gets.to_i
 
loop_count = 100

ans = Array.new(num,0)
1.upto(loop_count) do |x|
  1.upto(loop_count) do |y|
    1.upto(loop_count) do |z|
      result = x**2 + y**2 + z**2 + x*y + y*z + z*x

      ans[result-1] += 1 if result <= num
    end
  end
end
 
ans.each do |a|
  puts a
end

Measured memory_bytes: 14324
x = int(input())

nums = [True]*(10**6)
n = int(10**6**0.5)
for i in range(4, 10**6, 2): nums[i] = False
for i in range(3, n, 2):
  if nums[i]:
    for j in range(i+i, 10**6, i): nums[j] = False
      
while True:
  if nums[x]:
    print(x)
    break
  x += 1

Measured memory_bytes: 71912
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>

using namespace std;

int main(){

    int A, B, C, ans = 0;
    cin >> A >> B >> C;

    ans = C - (A - B);
    if (ans < 0){
        cout << "0" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


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

int main()
{
    long long n,m;
    cin>>n>>m;
    int arr[m],sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
        cout<<-1<<endl;
    else
        cout<<n-sum<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26;

int d;
int c[A],s[D][A];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j];
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]>s[i][best])
                best=j;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3728
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {



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


String S=sc.nextLine();
String T=sc.nextLine();

boolean ans=false;

for(int i=0;i<S.length();++i){
if(S.equals(T)){
ans=true;
break;
}
S=S.substring(S.length()-1,S.length())+S.substring(0,S.length()-1);
}
if(ans){
System.out.println("Yes");
}else{
System.out.println("No");
}

}

}



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

int main()
{
    int N;
    cin >> N;
    vector<int> p;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }

    if (is_sorted(p.begin(), p.end()))
    {
        cout << "YES";
        return 0;
    }

    for (int i = 0; i < p.size() - 1; ++i)
    {
        for (int j = i + 1; j < p.size(); ++j)
        {
            swap(p[i], p[j]);

            if (is_sorted(p.begin(), p.end()))
            {
                cout << "YES";
                return 0;
            }
            swap(p[i], p[j]);
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int n;
  cin >> n;
  
  int maxb = n / 100;
  int r = n % 100;

  int t = r / 5;
  if(r % 5 != 0) t++;
  if(t <= maxb){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }

}


Measured memory_bytes: 256
A,B,C,D = map(int, input().split())

risuto1 = []
risuto2 = []
for i in range(A,B+1):
    risuto1.append(i)
for i in range(C,D+1):
    risuto2.append(i)
kotae = len(set(risuto1) & set(risuto2)) 

if kotae == 0:
    print("0")
else:
    print(list(set(risuto1) & set(risuto2))[-1] - list(set(risuto1) & set(risuto2))[0])


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
    int N, T, c[110], t[110];

    cin >> N >> T;
    for(int i = 0; i < N; i++) cin >> c[i] >> t[i];
    

    int ans = INT_MAX, min;
    bool flag = false;
    for(int i = 0; i < N; i++){
        if(t[i] <= T){
            min = c[i];

            if(min < ans) ans = min;
            flag = true;
        }
        
    }
    if(flag) cout << ans << endl;
    else cout << "TLE" << endl; 

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  ll N; cin>>N;
  int odd = 0;
  FOR(i,0,N){
    ll in;
    cin>>in;
    if(in%2==1) odd++;
  }
  cout << (odd%2==0 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void change(int* x, int* y){
    int t = *x;
    *x = *y;
    *y = t;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b){
        change(&a, &b);
    }
    if(b > c){
        change(&b, &c);
    }
    if(a > b){
        change(&a, &b);
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC059C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] x = new long[N];
            var target = Console.ReadLine().Split(' ');
            for(int i=0;i<N;i++) x[i] = long.Parse(target[i]);
            long count1 = 0;
            long total = 0;
            for(int i=0; i<x.Length;i++){
                long tmp = 0;
                if(i % 2 == 0){ // 奇数個の和が正
                    tmp = (long)Math.Min(0, -total-1-x[i]);
                } else {
                    tmp = (long)Math.Max(0, -total+1-x[i]);
                }
                count1 += (long)Math.Abs(tmp);
                total += x[i]+tmp;
            }
            long count2 = 0;
            total = 0 ;
            for(int i=0; i<x.Length;i++){
                long tmp = 0;
                if(i % 2 == 1){ // 偶数個の和が正
                    tmp = (long)Math.Min(0, -total-1-x[i]);
                } else {
                    tmp = (long)Math.Max(0, -total+1-x[i]);
                }
                count2 += (long)Math.Abs(tmp);
                total += x[i]+tmp;
            }
            if(count1 < count2) Console.WriteLine(count1);
                else Console.WriteLine(count2);
//            Console.WriteLine("{0} {1}", count1,count2);
        }
    }
}


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

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

    std::vector<int64_t> L(86);

    L[0] = 2;
    L[1] = 1;

    if (N >= 2)
    {
        for (auto i = 2; i <= N; i++)
        {
            L[i] = L[i - 1] + L[i - 2];
        }
    }

    std::cout << L[N] << std::endl;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long


const int INF = 1e9 + 5;
int main()
{
	load;
	int n;
	cin >> n;
	vector<vector<int>> v(n, vector<int>(3));
	for (int i =0; i<n;i++){
		for (int j=0; j<3;j++){
			cin >> v[i][j];
		}
	}
	vector<int> dp(3);
	for (int i =0; i<3; i++){
		dp[i] = v[0][i];
	}
	for (int day=1; day<n; day++){
		vector<int> dptemp(3,0);
		for (int i =0; i<3;i++){
			for (int j =0; j<3; j++){
				if (i != j){
					dptemp[i] = max(dptemp[i], v[day][i] + dp[j]);
				}
			}
		}
		dp = dptemp;
	}
	cout << max(dp[0], max(dp[1], dp[2])) << endl ;
}


Measured memory_bytes: 5760
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: isize,
        k: isize,
    }

    let ans = if k == 1 {
        0
    } else {
        (n - (k - 1)) - 1
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int n;
string s;
int cnt = 0;

int main() {
    cin >> n;
    cin >> s;
    
    int i = 0, j = n-1;

    while (i < j){
        while (s[i] == 'R'){
            i++;
        }
        while (s[j] == 'W'){
            j--;
        }

        if (i >= j) break;
        else {
            s[i] = 'R';
            s[j] = 'W';
        }

        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin() (x).end()
#define rall(x) (x).rbegin() (x).rend()
typedef pair<int,int> pii;
typedef long long ll;

int main(){
	string s; cin>>s;
    int c = 0, ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R')
            c++;
        else{
            ans = max(ans,c);
            c = 0;
        }
    }
    ans = max(ans, c);
    cout<<ans;
}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, k;
    cin >>n>>k;
    vector<ll> l(n);
    rep(i,0,n) cin >> l[i];
    
    sort(l.begin(), l.end(), greater<ll>()); 

    ll s(0);
    rep(i,0,k)
        s += l[i];

    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define N_MAX 200002

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll A[100000];
int N;

class ModInt{
    public:
    ll v;
    ModInt(ll _v = 0){
        v = _v;
    }
    ModInt operator+(ll n){
        return ModInt((v+n)%MOD);
    }
    ModInt operator-(ll n){
        return ModInt((v-n+MOD)%MOD);
    }
    ModInt operator*(ll n){
        return ModInt((v*n)%MOD);
    }
    ModInt operator/(ll n){
        return ModInt((ModInt(n).inv()*v).v%MOD);
    }

    void operator+=(ll n){
        v = (v+n)%MOD;
    }
    void operator-=(ll n){
        v = (v-n+MOD)%MOD;
    }
    void operator*=(ll n){
        v = (v*n)%MOD;
    }
    
    
    ModInt operator+(ModInt n){
        return ModInt((v+n.v)%MOD);
    }
    ModInt operator-(ModInt n){
        return ModInt((v-n.v+MOD)%MOD);
    }
    ModInt operator*(ModInt n){
        return ModInt((v*n.v)%MOD);
    }
    ModInt operator/(ModInt n){
        return ModInt((n.inv()*v).v%MOD);
    }

    void operator+=(ModInt n){
        v = (v+n.v)%MOD;
    }
    void operator-=(ModInt n){
        v = (v-n.v+MOD)%MOD;
    }
    void operator*=(ModInt n){
        v = (v*n.v)%MOD;
    }

    void operator=(ModInt n){
        v = n.v;
    }
    void operator=(ll n){
        v = n;
    }

    ModInt inv(){
        if(v == 1) return ModInt(1);
        else return ModInt(MOD-ModInt(MOD%v).inv().v*(MOD/v)%MOD);
    }
};

ostream& operator<<(ostream& os, const ModInt& m){
    os << m.v;
    return os;
}

istream & operator >> (istream &in,  ModInt &m){
    in >> m.v;
    return in;
}

ModInt pow(ModInt a, ll n) {
	ModInt ans = 1;
	ModInt tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		}
		tmp *= tmp;
	}
	return ans;
}

ModInt inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=1;fac[1]=1;
    finv[0]=1;finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=(ModInt)MOD-inv[MOD%i]*(MOD/i);
        fac[i]=fac[i-1]*(ll) i;
        finv[i]=finv[i-1]*inv[i];
    }
}

ModInt comb(ll n, ll r){
  if(n < r){
      return ModInt(0);
  }else{
      return fac[n]*finv[r]*finv[n-r];
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    ModInt ans = 0;
    ModInt tmp = 0;
    for(int i = 1; i <= N; i++) tmp += fac[N]*inv[i];
    ans += tmp*A[0];
    for(int i = 1; i < N; i++){
        tmp -= fac[N]*inv[N-i+1];
        tmp += fac[N]*inv[i+1];
        ans += tmp*A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 9108
n = int(input())
h = list(map(int, input().split()))
 
before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

string ans;
int main() {
    int n;

    cin>>n;

    if(n>999){
        printf("ABD");
    }else{
        printf("ABC");
    }


    //out << ans << endl;
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> v;
    for(int i = 0; i < N; i++) v.push_back(0);
    for(int i = 0; i < N - 1; i ++) {
        int t;
        cin >> t;
        v.at(t - 1) += 1;
    }
    for (int n : v) cout << n << "\n";
    return 0;
}

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

int main(){
 int X,Y,Z; cin >> X >> Y >> Z;
 
 int tmp;
 tmp = X; //swap X & Y
 X = Y;
 Y = tmp;
 
 int tmp2;
 tmp2 = Z;
 Z = X;
 X = tmp2;

 cout << X << " " << Y << " " << Z << endl;
} 
 

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = scan!(usize, usize);
    println!("{}", k * (0..n - 1).fold(1, |prod, _| prod * (k - 1)))
}


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

int main(){
  int N, M;
  cin >> N >> M;

  priority_queue<int> A;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    A.push(a);
  }

  for(int i = 0; i < M; i++){
    int a = A.top();
    A.pop();
    A.push(a / 2);
  }

  long long ans = 0;
  for(int i = 0; i < N; i++){
    ans += A.top();
    A.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void){
	int n,z[2002],*a=z,*b=z+1001,m,i,j,k,*t;
	for(;scanf("%d",&n),n;printf("%d\n",m)){
		for(memset(a,*b=m=i=0,4004);i<n;i++){
			scanf(" ");
			for(j=1;j<=n;j++)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);
			t=a;a=b;b=t;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;

int main(){
	
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int ta,tb;
	ta=a/k;
	tb=b/k;
	if(ta==tb&&a%k!=0)cout<<"NG"<<endl;
	else cout<<"OK"<<endl;
	return 0;
}


Measured memory_bytes: 3636
// AOJ Volume 1 Problem 0183 Black-and-White

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char str[4];
    int i, j;
    int board[3][3];
    int sum;
    int result;
    
    while (1){
        // üÍ
        for (i = 0; i < 3; i++){
            scanf("%s", str);
            if (str[0] == '0'){
                return (0);
            }
            for (j = 0; j < 3; j++){
                if (str[j] == 'b'){
                    board[i][j] = -1;
                }
                else if (str[j] == 'w'){
                    board[i][j] = 1;
                }
                else {
                    board[i][j] = 0;
                }
            }
        }
        
        result = 0;
        for (i = 0; i < 3; i++){
            sum = 0;
            for (j = 0; j < 3; j++){
                sum += board[i][j];
            }
            if (abs(result) < abs(sum)){
                result = sum;
            }
            sum = 0;
            for (j = 0; j < 3; j++){
                sum += board[j][i];
            }
            if (abs(result) < abs(sum)){
                result = sum;
            }
        }

        sum = board[0][0] + board[1][1] + board[2][2];
        if (abs(result) < abs(sum)){
            result = sum;
        }

        sum = board[0][2] + board[1][1] + board[2][0];
        if (abs(result) < abs(sum)){
            result = sum;
        }

        if (result == -3){
            printf("b\n");
        }
        else if (result == 3){
            printf("w\n");
        }
        else {
            printf("NA\n");
        }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c;
    scanf("%d",&n);
    int a[n+2];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    c=0;
    for(i=1;i<=n;i++){
        if(i%2==1&&a[i]%2==1)
           c++;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
 	int N,K;
 	cin >> N >> K;
 	vector<pair<int,int>> vec(N);
 	for(int i = 0;i < N;i++) {
 		int A,B;
 		cin >> A >> B;
 		vec.at(i) = make_pair(A,B);
 	}
 	sort(vec.begin(),vec.end());
 	int count = 0;
 	int answer = 0;
 	for(int i = 0;i < N;i++) {
 		if(K - count <= vec[i].second) {
 			answer = vec[i].first;
 			break;
 		}
 		count += vec[i].second;
 	}
 	cout << answer << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int value = sc.nextInt();
			if(value >=1 && value <=100) {
				System.out.println((int)Math.pow(value,3));			
			}
		}
	}
}

Measured memory_bytes: 25936
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	int n,a[105];
	cin >> n ;
	for(int i{0};i < n;i++){
		cin >> a[i];
	}
	int ans = 0;
	sort(a,a+n);
	for(int i{0};i < n;i++){
		for(int j{i+1};j < n;j++){
			if(a[j] == a[i])continue;
			for(int k{j+1};k < n;k++){
				if(a[k] == a[j])continue;
				if(a[i] + a[j] > a[k])ans++;
			}
		}
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

typedef long long ll;

#define rep(a,b,c) for(int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(int a=b,a##end=c;a>=a##end;--a)


char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}

const int N=2e3+10,P=1e9+7;

int n,k;
ll po[N],Inv[N];

ll C(int n,int m){
	if(n<m) return 0;
	if(n<0||m<0) return 0;
	return po[n]*Inv[m]%P*Inv[n-m]%P;
}




int main(){
	n=rd(),k=rd();
	if(n==k){
		puts("1");
		rep(i,1,k-1)puts("0");
		return 0;
	}
	Inv[1]=1;
	po[0]=1;
	rep(i,1,n) po[i]=1ll*po[i-1]*i%P;
	rep(i,2,n) Inv[i]=((-Inv[P%i]*(P/i))%P+P)%P;
	Inv[0]=1;
	rep(i,2,n) Inv[i]=1ll*Inv[i-1]*Inv[i]%P;
	rep(i,1,k){
		if(i-1>n-k) { puts("0") ;continue;}
		//if(i==1) { printf("%d\n",n-k+1);continue; }
		ll ans=C(k-1,i-1)*((C(n-k-1,i-2)+C(n-k-1,i-1)*2+C(n-k-1,i))%P)%P;
		printf("%lld\n",ans);
	}
}








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

int main() {
    vector<int> seq;
    int n, q, tmp, cnt;

    scanf("%d", &n);
    seq.reserve(n);
    for(int i=0; i<n; ++i) {
        scanf("%d", &tmp);
        seq.push_back(tmp);
    }

    sort(seq.begin(), seq.end());

    scanf("%d", &q);
    cnt = 0;
    for(int i; i<q; ++i) {
        scanf("%d", &tmp);
        if(binary_search(seq.begin(), seq.end(), tmp))   ++cnt;
    }

    printf("%d\n", cnt);
}

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

const int MOD = 1e9+7;
long long N,dp[55];
char s1[55],s2[55];

int main(){
    cin >> N;
    scanf("%s%s",s1+1,s2+1);
    dp[0] = 1;
    for(int i = 1;i <= N;++i){
        if(s1[i] != s2[i]){
            if(s1[i-1] != s2[i-1])
                dp[i+1] = dp[i-1] * 3 % MOD;
            else{
                if(i == 1)
                    dp[i+1] = 6;
                else
                    dp[i+1] = 2 * dp[i-1] % MOD;
            }
            i++;
        }
        else{
            if(s1[i-1] != s2[i-1])
                dp[i] = dp[i-1];
            else{
                if(i == 1)
                    dp[i] = 3;
                else
                    dp[i] = 2 * dp[i-1] % MOD;
            }
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=1e5+10;
int n,k,a[N],b[N];
LL ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x, U&... y){read(x), read(y...);}
template<typename I> inline I mx(const I a,const I b){return a>b ? a : b;}
int main()
{
	//freopen("IntegerotS.in","r",stdin);
	read(n,k); 
	for(RG int i=1;i<=n;i++)
	{
		read(a[i],b[i]);
		if((a[i]&k)==a[i]) ans+=b[i];
	}
	for(RG int i=0;i<=30;i++)
	{
		if(((1<<i)&k)==0) continue;
		int tt=(k^(1<<i))|((1<<i)-1); LL re=0;
		for(RG int i=1;i<=n;i++) if((a[i]&tt)==a[i]) re+=b[i];
		ans=mx(ans,re);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,K=rl()
print(1 if N%K!=0 else 0)


Measured memory_bytes: 3060
#include<string>
#include <vector>
#include <stack>
#include <map>
#include<iostream>
#include <algorithm>
#include <limits.h> 
#include <functional>

using namespace std;
int n;
int m;
int a;

int main(){
	while(true){
		cin >>n;
		if(n==0){
			break;
		}
		cin >>m;
		if(m==0){
			break;
		}

		vector<int> codebook;
		vector<int> data;
		for(int i=0;i<m;i++){
			cin >> a;
			codebook.push_back(a);
		}
		for(int i=0;i<n;i++){
			cin >> a;
			data.push_back(a);
		}
		//一個前のハッシュ値による最小誤差でハッシュ。
		
		//map<int,int> hash;
		int hash[256];
		for(int i=0;i<256;i++){
			hash[i]=INT_MAX;
		}
		hash[128]=0;

		int _mi;int _mindex=-1;
		for(int i=0;i<n;i++){
			int d=data[i];//次のデータ		
			int next_hash[256];
			for(int j=0;j<256;j++){
				next_hash[j]=INT_MAX;
			}
			//最小値とdの間のみ保存。
			for(int j=0;j<256;j++)
			{
				for(int k=0;k<m;k++){
					if(hash[j]!=INT_MAX){
						int f=max(min(j+codebook[k],255),0);
						int div=f-d;
						int s=hash[j]+div*div;
						next_hash[f]=min(next_hash[f],s);
					}
				}
			}
			for(int j=0;j<256;j++){
				hash[j]=next_hash[j];
			}
		}
		int mi=INT_MAX;
		for(int i=0;i<256;i++){
			mi=min(hash[i],mi);
		}
		cout << mi <<endl;
	}
}

Measured memory_bytes: 1348
#include <stdio.h>
typedef long l;
// typedef long long ll;

int main(void){
  l i;
  l n;
  l t=-1;
  int tf=1;

  scanf("%ld", &n);
  l h[n];
  for(i=0; i<n; i++){
    scanf("%ld", &h[i]);
    //隣との差が2以上だとだめ
    if(i>=1){
      if(h[i-1]-h[i]>=2){
        tf=0;
        break;
      }
    }
  }

  if(n==1){
    printf("Yes\n");
    return 0;
  }else if(tf==0){
    printf("No\n");
    return 0;
  }else{
    //なし
  }

  for(i=1; i<n; i++){
    if(t>0){
      if(t>h[i]){
        tf=0;
        break;
      }
    }
    if(h[i-1]-1==h[i]){
      t=h[i];
      // printf("i=%ld h[i-1]-1=h[i]=%ld t=%ld\n",i, h[i],t);
      //h[i+1]以降はt以上でないといけない
    }
    //同じかh[i]<h[i+1]
  }

  if(tf==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main (){
while (1){
long n,dset[5000],temp=0,max;
cin>>n;
if (n==0)break;
for (int i=0;i<n;i++){
        cin>>dset[i];
}
max=-100000;
for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
                temp=temp+dset[j];
                if (max<temp){
                        max=temp;
                }
        }
temp=0;
}
cout<<max<<endl;
}
return 0;
}

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

signed main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  
  int A;
  vector<int> tensu(N, 0);
  for( int i = 0; i < Q; i++ ){
    cin >> A;
    tensu.at(A-1)++;
  }
  
  for( int i = 0; i < N; i++ ){
    if( K - Q + tensu.at(i) > 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

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

int main() {
  int N, ans;
  cin >> N;
  
  if(N>=64)ans=64;
  else if(N>=32)ans=32;
  else if(N>=16)ans=16;
  else if(N>=8)ans=8;
  else if(N>=4)ans=4;
  else if(N>=2)ans =2;
  else ans=1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	vector<int> rsl;
	while(true) {
		ll N, M;
		cin >> N >> M;
		if(N == 0 and M == 0) break;

		vector<ll> P;
		rep(i, 0, N) {
			ll p;
			cin >> p;
			P.push_back(p);
		}
		P.push_back(0);

		vector<ll> kk;

		rep(i, 0, N + 1) rep(j, 0, N + 1) kk.push_back(-P[i] + -P[j]);

		vsort(kk);

		vector<ll> tmp;
		rep(i, 0, N + 1) rep(j, 0, N + 1) {
			ll tmp_point = P[i] + P[j] + -*lower_bound(kk.begin(), kk.end(), -(M - P[i] - P[j]));
			if(tmp_point > M) tmp.push_back(0);
			else tmp.push_back(tmp_point);
		}
		vsort(tmp);
		rsl.push_back(tmp[tmp.size() - 1]);
	}
	rep(i, 0, rsl.size()) cout << rsl[i] << endl;


}



Measured memory_bytes: 26536
#include<bits/stdc++.h>
using namespace std;
int min(int a, int b){
    return (a<b?a:b);
}
int main(){
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0;  i < n;  i++)
        cin >> arr[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i = 2;  i < n;  i++){
        dp[i] = INT_MAX;
        int x = k;
        for(int j = i-1;  j >= 0  &&  x > 0;  j--, x--)
            dp[i] = min(dp[i], dp[j]+abs(arr[j]-arr[i]));
    }
    cout << dp[n-1] << endl;
	return 0;
}

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

int main(){

	string S;
	cin >> S;

	int kari = 0;
	int answer = 0;

	for(int i=0;i<S.size();i++) {
		if(S[i] == 'A'||S[i] == 'T'||S[i] == 'G'||S[i] == 'C'){
			kari++;
		}
		else{
			kari = 0;
		}
		answer = max(answer,kari);
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second

using namespace std;
const int MAX=30000;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;

int memo[1024][1024]; // 最低何回の移動でそこにこれるか


int H,W,K;
queue<PII> q;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

bool check(int x, int y){
  return 0 <= x && x < W && 0 <= y && y < H;
}

int main(void){
  string str[1024];

  cin >> H >> W >> K;
  rep(i,H)cin >> str[i];

  rep(i,H)rep(j,W)
    if(str[i][j] == 'S'){
      q.push(MP(j,i));
      q.push(MP(j,i));
      str[i][j] = '.';
      i = H;j=W;
    }

  //1順目に動ける場所
  queue<PII> mv;
  int ss = q.size();
  mv.push(q.front());q.pop();
  rep(i,K){
    int si = mv.size();
    rep(j,si){
      PII pos = mv.front();mv.pop();
      if(memo[pos.Y][pos.X] == 1)continue;
      memo[pos.Y][pos.X] = 1;
      rep(k,4){
        int nx = pos.X + dx[k];
        int ny = pos.Y + dy[k];
        if(!check(nx, ny))continue;
        if(str[ny][nx] == '#') continue;
        mv.push(MP(nx, ny));
        q.push(MP(nx,ny));
      }
    }
  }


  int ans = 1000000000;
  while(!q.empty()){
    PII t = q.front();q.pop();
    int resX = t.X%K;
    int resY = t.Y%K;
    if(resX>0)resX = 1;
    if(resY>0)resY = 1;
    ans = min(ans, t.X/K + resX + 1);
    ans = min(ans, t.Y/K + resY + 1);

    resX = (W-1-t.X)%K;
    resY = (H-1-t.Y)%K;
    if(resX>0)resX = 1;
    if(resY>0)resY = 1;

    ans = min(ans, (W-1-t.X)/K + resX + 1);
    ans = min(ans, (H-1-t.Y)/K + resY + 1);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25268
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	string S, T; cin >> S >> T;
	if (T.substr(0, S.size()) == S) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <functional>
#include <stack>
#include <fstream>
#include <bitset>
#include <iomanip>

using namespace std;

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

const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const long long LONG_INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const double PI = 3.1415926535;

const vector<int> dx = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
const vector<int> dy = { -1, -1, 0, 1, 1, 1, 0, -1, -1 };


int main() {

	long long k;
	cin >> k;

	long long n = 50;
	cout << n << endl;

	vector<long long> ans(n, 0);
	forn(i, n)
		ans[i] = n - i - 1;

	forn(i, k % 50)
		ans[i]++;

	forn(i, n)
		ans[i] += k / 50;

	for (long long i : ans)
		cout << i << ' ';
	cout << endl;
}

Measured memory_bytes: 256