akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=51;
const ll mod=1e9+7;
const ll inf=1e9+500;

ll sek[maxn];
int main(){
	ll k;
	cin>>k;
	ll kk=k;
	if(kk%50!=0){
		kk+=50;
	}
	kk=(kk/50)*50;

	for(ll i=0;i<50;i++){
		sek[i]=49+kk/50;
	}
	while(kk>k){
		ll maxx=0;
		ll kimax=0;
		for(ll i=0;i<50;i++){
			if(sek[i]>maxx){
				maxx=sek[i];
				kimax=i;
			}
		}
		sek[kimax]-=51;
		for(ll i=0;i<50;i++){
			sek[i]++;
		}			
		kk--;
	}
	cout<<50<<endl;
	for(ll i=0;i<50;i++){
		cout<<sek[i]<<' ';
	}


}


Measured memory_bytes: 256
import copy
import sys
import math

def main():
	n,k = map(int,input().split())
	d = list(map(str,input().split()))
	while True:
		s = str(n)
		flag  = True
		for i in s:
			if(i in d):
				flag = False
		if flag:
			print(n)
			sys.exit()
		else:
			n += 1


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()


Measured memory_bytes: 40940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  int cnt = 0;
  bool f = false;
  for(int i = 0; i < n; i++){
    int a,b; cin >> a >> b;
    if(a == b) cnt++;
    else cnt = 0;
    if(cnt == 3) f = true;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int n; cin >> n;
	int a[100100];
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	ll sum2 = 0;
	for (int i = 0; i < n; i+=2) {
		sum2 += a[i];
	}
	int key = 2 * sum2 - sum;
	int x[100100];
	x[0] = key;
	for (int i = 1; i < n ; ++i) {
		x[i] = 2 * a[i - 1] - x[i - 1];
	}
	for (int i = 0; i < n; ++i) {
		cout << x[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 2048
for(i=require("fs").readFileSync("/dev/stdin","utf8").split(/\s/),j=0;a=i[j];j+=8)console.log(Math.abs((i[j+2]-a)*(i[j+6]-i[j+4])+(i[j+3]-i[j+1])*(i[j+7]-i[j+5]))<1e-10?'YES':'NO')

Measured memory_bytes: 7912
# ABC64C
n = int(input())
a = list(map(int,input().split()))
b = set()
d = 0
for i in a:
    c = i // 400
    if c < 8:
        b.add(c)
    else:
        d += 1
print(max(len(b),1),len(b)+d)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  // string s;
  // cin >> s;
  // if (s[2] == s[3] && s[4] == s[5]) {
  //   cout << "Yes";
  // } else {
  //   cout << "No";
  // }

  // int x;
  // cin >> x;
  // int tot = 0;
  // tot += 1000 * (x / 500);
  // x %= 500;
  // tot += 5 * (x / 5);
  // cout << tot;

  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  int maxd = 0, maxidx = -1;
  for (auto &x : a) {
    cin >> x;
  }
  sort(a.begin(), a.end());
  for (int i = 1; i < n; ++i) {
    if (a[i] - a[i - 1] > maxd) {
      maxd = a[i] - a[i - 1];
      maxidx = i;
    }
  }
  int first = a.back() - a.front();
  first = min(first, k - a[maxidx] + a[maxidx - 1]);
  cout << first;
}


Measured memory_bytes: 1656
X, N = map(int, input().split())
ps = map(int, input().split())

dps = set(ps)

i = X
j = X

while True:
    if i not in dps:
        print(i)
        break
    if j not in dps:
        print(j)
        break
    i -= 1
    j += 1

Measured memory_bytes: 9184
#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>;
const int MAX_N = 110000;

int memo[MAX_N]; // memo[i] が i についての答え
int rec(int n) {
    if (n == 0) return 0; // 終端条件
    if (memo[n] != -1) return memo[n]; // すでに探索済みならリターン
    
    int res = n; // INF の気持ち
    
    // 1, 6, 6^2, ..., を試す (n を超えない範囲で)
    for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);
    
    // 1, 9, 9^2, ..., を試す (n を超えない範囲で)
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);
    
    // メモしながらリターン
    return memo[n] = res;
}

int main() {
    int N; cin >> N;
    
    // テーブルを -1 で初期化
    for (int i = 0; i < MAX_N; ++i) memo[i] = -1;
    cout << rec(N) << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
    string s; cin >> s;

    int cnt=0, lr=0, rl=0;
    for(int i=0; i<n-1; ++i){
        if(s.substr(i,2)=="LR") ++lr;
        else if(s.substr(i,2)=="RL") ++rl;
        else ++cnt;
    }
    
    int ans=(cnt+2*min({k,lr,rl}));
    if(k-min(lr,rl)>0 && abs(lr-rl)>0) ++ans;
    cout << ans << endl;
}

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

namespace AOJ.Volume0
{
    class Program0001
    {
        static void Main(string[] args)
        {
            int[] height = new int[10];

            for (int i = 0; i < 10; i++)
            {
                height[i] = int.Parse(Console.ReadLine());
            }

            int[] orderedHeight = height.OrderByDescending(x => x).ToArray();

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("{0}", orderedHeight[i]);
            }
        }
    }
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int &x : x) cin >> x;
    int ans = 1000000;
    for (int i = 1; i <= 200; i++){
        int temp = 0;
        for (int j = 0; j < n; j++){
            temp += (x[j] - i) * (x[j] - i);
        }
        if (temp < ans) ans = temp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

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

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// gcd, lcm
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}


int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> soinsuBunkai;
    ll sosu = 2;
    while (M > 1) {
        ll count = 0;
        while (M % sosu == 0) {
            count++;
            M /= sosu;
        }
        soinsuBunkai.push_back(count);
        sosu++;
    }
    COMinit();
    ll ans = 1;
    for (ll i : soinsuBunkai) {
        ans *= COM(N + i - 1, N - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 525908
p = 0
chA = ord("A")

while True:
    try:
        s, t = map(lambda x: ord(x) - chA, raw_input().split(","))
    except EOFError as e:
        break
    if s == p:
        p = t
    elif t == p:
        p = s

print("%s" % (chr(p + chA), ))

Measured memory_bytes: 4224
from collections import deque
# import os
# import io
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys
input = sys.stdin.readline


def main():
    n, q = map(int, input().split())
    node = [[]for _ in range(n)]
    looked = [1] * n
    for i in range(n - 1):
        a, b = map(int, input().split())
        node[b - 1].append(a - 1)
        node[a - 1].append(b - 1)
    counter = [0] * n
    for i in range(q):
        p, x = map(int, input().split())
        counter[p - 1] += x
    queue = deque([0])
    looked[0] = 0
    while queue:
        now = queue.pop()
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)

main()


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

using ll = long long;
using namespace std;

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i] ;

    int Di = 0;
    int cnt = 1;
    for (int i = 1; i <= N; i++){
        Di = Di + L[i-1];
        if (Di <= X) cnt++;
        else break;
    }
    cout << cnt << endl;

    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int cnt=0;
    do
    {
        n/=k;
        cnt++;
    }while(n);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int imos[100010];
signed main() {
    int N, M; cin >> N >> M;
    for(int i=0; i<M; i++) {
        int l, r; cin >> l >> r;
        l--;
        imos[l]++; imos[r]--;
    }
    for(int i=0; i<=N; i++) imos[i+1] += imos[i];
    int ans = 0;
    for(int i=0; i<N; i++) ans += (imos[i] == M);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.math.BigInteger;

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

        long a = stdIn.nextLong();
        long b = stdIn.nextLong();

        long l1, r1, l2, r2;
        if(a % 2 == 0){
            l1 = 25 * a / 2;
        }else{
            l1 = 25 * a / 2 + 1;
        }
        if((a + 1) % 2 == 0){
            r1 = 25 * (a + 1) / 2 - 1;
        }else{
            r1 = 25 * (a + 1) / 2;
        }
        l2 = 10 * b;
        r2 = 10 * (b + 1) - 1;

        if(r1 < l2 || r2 < l1){
            System.out.println(-1);
        }else{
            System.out.println((l1 < l2) ? l2 : l1);
        }
    }
}

Measured memory_bytes: 23636
n, a, b = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]

cost = 0
for i in range(1, n):
    walk = (x[i] - x[i-1]) * a 
    if walk > b:
        cost += b
    else:
        cost += walk
print(cost)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define MOD (ll)(1e9 + 7)
#define MAX (ll)(2e5 + 4)
#define INF (ll)(1e9)
using namespace std;
using ll =  long long;
using ld = long double;

int la = 0, ra = MOD;

bool ch (pair<int, int> p1, pair<int, int> p2) {
	if (max (p1.second - la + 1, 0) != max (p2.second - la + 1, 0)) {
		return max (p1.second - la + 1, 0) < max (p2.second - la + 1, 0);
	}
	return max (ra - p1.first + 1, 0) > max (ra - p2.first + 1, 0);
}

int main () {
	int n;
	cin >> n;
	vector<pair<int, int>> vp;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		la = max (l, la);
		ra = min (r, ra);
		vp.push_back (make_pair (l, r));
		ans = max (ans, r - l + 1);
	}
	ans += max (ra - la + 1, 0);
	sort (vp.begin (), vp.end (), ch);
	int ar[n] = {}, br[n] = {}, l = 1, r = INF;
	for (int i = 0; i < n; i++) {
		l = max (vp[i].first, l), r = min (vp[i].second, r);
		ar[i] = r - l + 1;
		if (ar[i] <= 0) {
			ar[i] = 0;
			break;
		}
	}
	l = 1, r = INF;
	for (int i = n - 1; i >= 0; i--) {
		l = max (vp[i].first, l), r = min (vp[i].second, r);
		br[i] = r - l + 1;
		if (br[i] <= 0) {
			br[i] = 0;
			break;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		ans = max (ans, ar[i] + br[i + 1]);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1908
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

// テゥツ鳴湘・ツケツエテ・ツ按、テ・ツョツ?
bool leapYear(ll y) {
  return y%400==0 || y%4==0&&y%100;
}

// fairfield テ」ツ?ョテ・ツ?ャテ・ツシツ?
ll fairfield(ll y, ll m, ll d) {
  if (m<3) {y--; m+=12;}
  return 365*y + y/4 - y/100 + y/400 + 306*(m+1)/10 + d - 428;
}

struct Date {
  ll dnum;
  ll y,m,d;
  Date(int y, int m, int d) : y(y),m(m),d(d) {
    dnum = fairfield(y,m,d);
  }
  Date(ll dnum) : dnum(dnum) {
    for (y=1; ; ++y) {
      int t=365;
      if (leapYear(y))t++;
      if (t>=dnum) break;
      dnum-=t;
    }
    for (m=1; ; ++m) {
      int t=31;
      if (m==4||m==6||m==9||m==11) t--;
      if (m==2) {
        if (leapYear(y)) t-=2;
        else t-=3;
      }
      if (t>=dnum) break;
      dnum-=t;
    }
    d = dnum;
  }
  int weekday() {               // 0 : テヲツ猟・テヲツ崢?
    return dnum % 7 + 0;        
  }
};

int main() {
  ll base = Date(2012,12,21).dnum;
  string s;
  while(cin >> s, s!="#") {
    if (count(ALL(s),'.') == 2) {
      ll y, m, d;
      sscanf(s.c_str(),"%lld.%lld.%lld",&y,&m,&d);
      ll dnum = Date(y,m,d).dnum - base;
      ll A = dnum/20/18/20/20%13;
      ll B = dnum/20/18/20%20;
      ll C = dnum/20/18%20;
      ll D = dnum/20%18;
      ll E = dnum%20;
      printf("%lld.%lld.%lld.%lld.%lld\n",A,B,C,D,E);
    } else {
      ll A,B,C,D,E;
      sscanf(s.c_str(),"%lld.%lld.%lld.%lld.%lld",&A,&B,&C,&D,&E);
      ll dnum = A*20*18*20*20 + B*20*18*20 + C*20*18 + D*20 + E;
      Date t(dnum+base);
      printf("%lld.%lld.%lld\n",t.y,t.m,t.d);
    }
  }
}

Measured memory_bytes: 1244
N, M = map(int, input().split())
stores = []
for i in range(N):
    stores.append(list(map(int, input().split())))

stores.sort(key=lambda store: store[0])

remaining_demand = M
payment = 0
for price, stock in stores:
    if stock >= remaining_demand:
        payment += price * remaining_demand
        break
    else:
        payment += price * stock
        remaining_demand -= stock

print("{}".format(payment))


Measured memory_bytes: 28976
require 'prime'
N = gets.to_i

divs = {}

(2..N).each do |i|
    Prime.prime_division(i).each do |pr, n|
        divs[pr] ||= 0
        divs[pr] += n
    end
end

MOD = 10**9 + 7

prod = 1

divs.each do |pr, n|
    prod *= (n + 1)
    prod %= MOD
end

puts prod

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

int main(void){
   int a, b;
   cin >> a;
   cin >> b;
   
   if (a<b){
       cout <<"a < b";
   }
   else if (a>b){
       cout <<"a > b";
   }
   else if (a==b){
       cout <<"a == b";
   }
   cout << endl;
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{   
    i_os;
    int mod = 1e9 + 7;
    ll s;
    cin>>s;
    ll n = s/3;
    if(n == 0){
        cout<<0<<endl;
        return 0;
    }
    vector<vector<ll>> dp;
    dp.resize(s+1,vector<ll>(n,0));

    REP(i,0,s+1){
        REP(j,0,n){
            dp[i][j] = 0;
        }
    }
    REP(i,3,s+1){
        dp[i][0] = 1;
    }
    ll ans = dp[s][0];
    REP(j,1,s+1){
        dp[j][0] += dp[j-1][0];
        dp[j][0] %= mod;
    }

    REP(i,1,n){
        REP(j,3,s+1){
            dp[j][i] += dp[j-3][i-1];
            dp[j][i] %= mod;
        }
        ans += dp[s][i];
        ans %= mod;
        REP(j,1,s+1){
            dp[j][i] += dp[j-1][i];
            dp[j][i] %= mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}   
    

Measured memory_bytes: 13648
A,B,C,K = map(int,input().split())
ans = 0

if K<A:
  ans+=K
  print(ans)
  exit()
else:
  ans+=A
  K-=A
  
if K<B:
  print(ans)
  exit()
else:
  K-=B
  
if K<C:
  ans+=K*(-1)
  print(ans)
else:
  ans+=C*(-1)
  print(ans)

Measured memory_bytes: 9216
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;

typedef long long ll;
typedef long double ld;
 
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;

#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n;
	cin >> n; 
	vector<int> A;
	int S = 0;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		A.pb(x);
		S ^= x;
	}
	vector<int> ans;
	for(int i = 0; i < n; i++){
		cout << (S ^ A[i]) << " ";
	}
}

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

int gcd(int c, int d){
  int r,l;
  int a = c;
  int b = d;
  if (a<b) swap(a,b);
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  int temp;
  rep(i,n){ 
    cin >> temp;
    a.push_back(temp);
  }
  vector<int> left(n,0), right(n,0);
  left[0] = a[0];
  right[n-1] = a[n-1];
  for(int i=1; i<n; i++){
    left[i] = (gcd(left[i-1],a[i]));
  }
  for(int i=n-2; i>=0; i--){
    right[i] = gcd(right[i+1],a[i]);
  }

  vector<int> ans(n,0);
  ans[0] = right[1];
  ans[n-1] = left[n-2];
  for(int i=1; i<n-1; i++){
    ans[i] = gcd(left[i-1],right[i+1]);
  }

  cout << *max_element(ans.begin(),ans.end()) << endl;
  
  return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  Graph G(n, vi(2));
  rep(i,n) rep(j,2) cin >> G[i][j];

  sort(all(G));

  unordered_map<int, int> order;
  set<int> s;
  rep(i,n) s.insert(G[i][1]);
  int sz = 0;
  for (auto v : s) {
    order[v] = sz;
    ++sz;
  }

  Graph edge(sz), line(sz);
  int x = -1, y = -1;

  rep(i,n) {
    if (G[i][0] == x) {
      edge[y].push_back(order[G[i][1]]);
      edge[order[G[i][1]]].push_back(y);
    }
    else {
      x = G[i][0];
      y = order[G[i][1]];
    }
    line[order[G[i][1]]].push_back(x);
  }

  vb seen(sz, false);
  ll ans = -n;

  rep(i,sz) {
    if (seen[i]) continue;

    seen[i] = true;
    queue<int> q;
    q.push(i);
    unordered_set<int> Xcounter;
    for (auto p : line[i]) Xcounter.insert(p);
    ll Ycounter = 1;

    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto nv : edge[v]) {
        if (seen[nv]) continue;

        seen[nv] = true;
        q.push(nv);
        for (auto p : line[nv]) Xcounter.insert(p);
        ++Ycounter;
      }
    }

    ans += Xcounter.size() * Ycounter;
  }

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


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

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i = 0; i < n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
    for(int i = 1; i <= n; i++){
        dp[i][0] = a[i - 1] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i - 1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i - 1] + max(dp[i - 1][1], dp[i - 1][0]);
    }
    ll maxim = 0;
    maxim = max(dp[n][0], max(dp[n][1], dp[n][2]));
   
    cout<<maxim;
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

#define ARRAY_INIT 0
#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dm;
	unsigned long aulW_DG[ G_MAX ];
	unsigned long ulW_Dv;
	signed long slW_Dk;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = ( int * ) malloc ( sizeof ( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dm = 1;
	aulW_DG[ 0 ] = 1;
	while( 3 * aulW_DG[ ulW_Dm - 1 ] + 1 < ulW_Dtc_cnt ){
		aulW_DG[ ulW_Dm ] = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
		ulW_Dm++;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm / 2; ulW_Cloop_cnt++ ){
		ulW_Dv = aulW_DG[ ulW_Cloop_cnt ];
		aulW_DG[ ulW_Cloop_cnt ] = aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ];
		aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ] = ulW_Dv;
	}

	printf( "%d\n", ulW_Dm );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == ulW_Dm - 1 ){
			printf( "%d\n", aulW_DG[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", aulW_DG[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = aulW_DG[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dv = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			slW_Dk = ulW_Cloop_sub_cnt - aulW_DG[ ulW_Cloop_cnt ];
			while( ( slW_Dk >= 0 ) && ( aulW_Dtestcase[ slW_Dk ] > ulW_Dv ) ){
				aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ slW_Dk ];
				slW_Dk -= aulW_DG[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = ulW_Dv;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    cout << (*max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())) << endl;
}

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

int main(){

  int n;

  while(cin >> n, n){

    int m,e,j;

    for(int i=0;i<n;i++){

      double ave,lank = 0,me;

      cin >> m >> e >> j;
      
      ave = m + e + j;
      ave /= 3;
      me = m + e;
      me /= 2;

      if(m == 100 || e == 100 || j == 100) lank = 3;

      

      if(lank != 3){
	if(me >= 90) lank = 3;
	else if(ave >= 80) lank = 3;
	else if(ave >= 70) lank = 2;
	else if(ave >= 50 && m >= 80 || e >= 80) lank = 2;
	else lank = 1;
      }

      if(lank == 3) cout << "A" << endl;
      else if(lank == 2) cout << "B" << endl;
      else cout << "C" << endl;

    }
  }
}

Measured memory_bytes: 1156
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		
		List<int> A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
		
		A.Sort(); //昇順にソート
		Modular sum = 0;
		//long comb = CombinationL(n-1,k-1);
		for(int i=0;i<n;i++){
		    //if(i>k)break;
		    //Console.WriteLine("n:"+(n-1)+" k:"+(k-1));
		    Modular comb = Modular.Ncr(n-1-i,k-1);
		    //Max
		    Modular aMax = new Modular(A[n-1-i]) * comb;
		    sum = sum + aMax;
		    //Console.WriteLine("Max:"+A[n-1-i]+" nCr:"+(int)comb+" aMax:"+(int)aMax);
		    
		    //Min
		    Modular aMin = new Modular(A[i]) * comb;
		    //Console.WriteLine("Min:"+A[i]+" nCr:"+(int)comb+" aMin:"+(int)aMin);
		    sum = sum - aMin;
		}
		
		Console.WriteLine((int)sum);

	}
}

class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r)  ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

const ll MAX_A = 1001000;

ll gcd(ll n, ll m) {
    if(n > m) {
        ll l = n;
        n = m;
        m = l;
    }
    if(n == 0) {
        return m;
    }
    while(1) {
        ll l = n;
        n = m % n;
        m = l;
        if(n == 0) {
            break;
        }
    }
    return m;
}

bool isprime(ll n) {
    if(n == 1) {
        return false;
    }
    if(n == 2) {
        return true;
    }
    ll sq = (ll)sqrt(double(n));
    for(ll i = 2; i <= sq; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll N;
    cin >> N;
    vll A(N);
    for(auto &e : A)
        cin >> e;
    // setwise
    ll g = A[0];
    for(i = 1; i < N; i++) {
        g = gcd(g, A[i]);
    }
    if(g > 1) {
        cout << "not coprime" << endl;
        return 0;
    }
    // pairwise
    // D[x]はxを割り切る最小の素数
    vll D(MAX_A, 0);
    for(i = 2; i < D.size(); i++) {
        if(D[i] == 0) {
            ll p = i;
            while(p < D.size()) {
                D[p] = i;
                p += i;
            }
        }
    }
    set<ll> pset;
    for(i = 0; i < N; i++) {
        ll a = A[i];
        if(a == 1)
            continue;
        set<ll> pset_sub;
        while(D[a] != a) {
            auto itr = pset.find(D[a]);
            if(itr != pset.end()) {
                cout << "setwise coprime" << endl;
                return 0;
            }
            pset_sub.insert(D[a]);
            a = a / D[a];
        }
        auto itr = pset.find(a);
        if(itr != pset.end()) {
            cout << "setwise coprime" << endl;
            return 0;
        }
        pset_sub.insert(a);
        for(auto p : pset_sub) {
            pset.insert(p);
        }
    }

    cout << "pairwise coprime" << endl;

    return 0;
}


Measured memory_bytes: 18644
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pll>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1010205047;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 200;

char c;
 
int main(){
//	cout<<fixed<<setprecision(10);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>c;
    if(c>='A'&&c<='Z')cout<<"A\n";
    else cout<<"a\n";
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <=n; i++) {
		for (int j = 0; j <=n-i; j++) {
			if (9000 * i + 4000 * j == y - 1000 * n) {
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1;
	}

	

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

void print(vector<int> A)
{
  for (int i = 0; i < A.size(); i++)
  {
    if (i)
    {
      cout << " ";
    }
    cout << A.at(i);
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  print(A);
  for (int i = 1; i < N; i++)
  {
    int v = A.at(i);
    int j = i - 1;
    while (j >= 0 && A.at(j) > v)
    {
      A.at(j + 1) = A.at(j);
      j--;
    }
    A.at(j + 1) = v;
    print(A);
  }
}


Measured memory_bytes: 3120
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

using pr = pair<int, int>;

int m, n;
int a[2000][2000];
int px[1000010], py[1000010];
int dp[2000][2000];
int p[1000010];

int main()
{
	loop(i, 2, 1000010) p[i] = 1;
	for (int i = 2; i * i <= 1000010; i++){
		for (int j = i * i; j <= 1000010; j += i){
			p[j] = 0;
		}
	}

	while (cin >> m >> n, m){
		memset(a, -1, sizeof(a));
		memset(px, -1, sizeof(px));
		memset(py, -1, sizeof(py));
		fill_n(*dp, 2000 * 2000, -INF);

		vector<int> v;
		for (int i = 0, d = 3;; i++){
			rep(j, i / 2 + 1) v.eb(d);
			d = (d + 1) % 4;
			if (v.size() > m) break;
		}

		int x = 1000, y = 1000;
		rep(i, m){
			a[x][y] = i + 1;
			px[i + 1] = x;
			py[i + 1] = y;
			x += dx[v[i]];
			y += dy[v[i]];
		}
		
		dp[px[n]][py[n]] = p[a[px[n]][py[n]]];
		rep(i, 2000) rep(j, 2000){
			if (pr(i, j) <= pr(px[n], py[n])) continue;
			if (a[i][j] == -1) continue;
			dp[i][j] = p[a[i][j]] + max({
				dp[i - 1][j - 1],
				dp[i - 1][j],
				dp[i - 1][j + 1]
			});
		}
		
		pr res(0, 0);
		rep(i, 2000) rep(j, 2000){
			if (dp[i][j] <= 0) continue;
			if (p[a[i][j]]) chmax(res, pr(dp[i][j], a[i][j]));
		}

		cout << res.fi << " " << res.se << endl;
	}
}

Measured memory_bytes: 50008
#include <stdio.h>

int main(void) {
	int prevsuuretu[12];
	int suuretu[12];
	int bunpu[12];
	int suuzi[12];
	int hyoulength;
	int length;
	int i;
	int kaisuu;
	int j;
	while(1) {
		scanf("%d",&length);
		if(length==0)break;
		for(i=0;i<length;i++) {
			scanf("%d",&suuretu[i]);
			prevsuuretu[i]=suuretu[i];
		}
		kaisuu=0;
		while(1) {
			for(i=0;i<12;i++)bunpu[i]=0;
			hyoulength=0;
			for(i=0;i<length;i++) {
				for(j=0;j<hyoulength;j++) {
					if(suuzi[j]==suuretu[i]) {
						bunpu[j]++;
						break;
					}
				}
				if(j>=hyoulength) {
					suuzi[hyoulength]=suuretu[i];
					bunpu[hyoulength]=1;
					hyoulength++;
				}
			}
			for(i=0;i<length;i++) {
				for(j=0;j<hyoulength;j++) {
					if(suuzi[j]==suuretu[i]) {
						suuretu[i]=bunpu[j];
						break;
					}
				}
			}
			for(i=0;i<length;i++) {
				if(suuretu[i]!=prevsuuretu[i])break;
			}
			if(i>=length)break;
			for(i=0;i<length;i++)prevsuuretu[i]=suuretu[i];
			kaisuu++;
		}
		printf("%d\n",kaisuu);
		for(i=0;i<length;i++) {
			printf(i?" %d":"%d",suuretu[i]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n - 2) {
		int x = max({ a[i],a[i + 1],a[i + 2] });
		int y = min({ a[i],a[i + 1],a[i + 2] });
		if (x != a[i + 1] && y != a[i + 1]) ans++;
	}
	cout << ans;
	return 0; 
}









Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn solve(h: usize, w: usize) -> usize {
    let mut ans;
    if w%3==0 {
        return 0;
    } else {
        ans = (h*(w/3+1)) - h*(w/3);
    }

    for w1 in 1..w {
        let a1 = w1*h;
        let h2 = h/2;
        let a2 = (w-w1) * h2;
        let h3 = h/2 + h%2;
        let a3 = (w-w1) * h3;
        let a_max = max(a1, max(a2, a3));
        let a_min = min(a1, min(a2, a3));
        ans = min(ans, a_max - a_min);
        // debug!(w1, a1, a2, a3, ans);
    }
    ans
}

fn main() {
    input!{
      h: usize,
      w: usize,
    }
    println!("{}", min(solve(h, w), solve(w, h)));
}


Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().A();
	}

	void A() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ma = -1, mi = 101;
		for (int i = 0; i <= Math.min(A, B); ++i) {// A,B両方
			int j = A - i;
			int k = B - i;
			if (i + j + k > N || j < 0 || k < 0)
				continue;
			ma = Math.max(i, ma);
			mi = Math.min(i, mi);
		}
		System.out.println(ma + " " + mi);

	}

	void B() {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (a.charAt(i) == b.charAt(i) && b.charAt(i) == c.charAt(i)) {
				continue;
			} else if (a.charAt(i) == b.charAt(i) || b.charAt(i) == c.charAt(i) || c.charAt(i) == a.charAt(i)) {
				ans += 1;
			} else {
				ans += 2;
			}
		}
		System.out.println(ans);
	}


	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 21076
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    auto c = [&](ll x){
        bool ok = true;
        ll t = x % 10;
        while(x){
            ok &= x % 10 == t;
            x /= 10;
        }
        return ok;
    };
    rep(i,n,1000){
        if(c(i)){
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int d;
    cin>>d;
    if (d==25) {
        cout<<"Christmas"<<endl; 
    } else if (d==24) {
        cout<<"Christmas Eve"<<endl; 
    } else if (d==23) {
        cout<<"Christmas Eve Eve"<<endl;
    } else if (d==22) {
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}


Measured memory_bytes: 256