akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

string s, t;cin>>s>>t;

int ans = 0;
for(int i=0;i<s.size();i++)
{
  if(s[i]!=t[i]) ans+=1;
}

cout<<ans;

return 0;
}

Measured memory_bytes: 3780
package main

import (
	"fmt"
)

func main() {
	for i := 0; i < 3; i++ {
		var x string
		fmt.Scan(&x)
		fmt.Print(x[0:1])
	}
	fmt.Println()
}

func Min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func Max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
  ll N; cin >> N;
  vector<ll> A(N); for(auto& in:A) cin >> in;
sort(A.begin(),A.end());
cout << *A.rbegin() - *A.begin() << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N,l,i=0;
    cin >> N;
    int* num =new int[N-1];
    int* ue=new int[N];
    while (cin >> l){
        num[i] = l;
        i++;
        if (i == N-1)
            break;
    }
    for (int i = 0; i < N; i++)
    {
        ue[i] = 0;
    }
    for(int i=0;i<N-1;i++){
        l=num[i];
        ue[l-1]+=1;
    }
    for(int i=0;i<N;i++){
        cout << ue[i] << "\n";
    }
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool ok = 0;
    for(int i=a;i<=b;i++){
        if(i%k==0) ok=1;
    }
    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N,K;
    string S;
    string S2;
    cin >> N >> K >> S;
    S2 = S[K-1];
    transform(S2.begin(),S2.end(),S2.begin(),::tolower);
    cout << S.substr(0,K-1);
    cout << S2;
    if(K != S.size())
        cout << S.substr(K,S.size()-K);
    return 0;
}

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

int main(){
	float base = 100;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		base *= 1.05;
		base = ceil(base);
	}
	cout << (int)(base*1000) << endl;
}


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

int main() {
  int N;
  string a;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (a == "Y"){
        cout << "Four";
        break;
    } else if (i == N-1){
      cout << "Three";
    }
  }
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9
const int mod = 1e9+7;
int X, Y;
const int MAX = 1510000;
long long fac[MAX], finv[MAX], inv[MAX];
const int MOD = 1000000007;
// テーブルを作る前処理
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;
}

int main(){
  cin >> X >> Y;
  int cnt1=-1, cnt2=-1;
  REP(i, X+1){
    if((X-i) % 2) continue;
    int j = (X-i) /2;
    if(i+2*j == X && 2*i+j == Y){
      cnt1 = i;
      cnt2 = j;
      break;
    }
  }
  if(cnt1 == -1){
    cout << 0 << endl;
    return 0;
  }
  COMinit();
  cout << COM(cnt1+cnt2, cnt1) << endl;
  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;

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

    ll k, a, b;
    cin >> k >> a >> b;
    if (k < a - 1) cout << k + 1;
    else
    {
        k -= a - 1;
        cout << max(k + a, a + k / 2 * (b - a) + k % 2);
    }
}


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

int to_int(string s)
{
  int num = 0;
  int m = 1;
  for(int i = 0; i < s.length(); i++)
  {
    if(s[i] >= '0' && s[i] <= '9')
      m = s[i] - '0';
    else
    {
      switch(s[i])
      {
        case 'm':
          num += m * 1000;
          break;
        case 'c':
          num += m * 100;
          break;
        case 'x':
          num += m * 10;
          break;
        case 'i':
          num += m;
          break;
      }
      m = 1;
    }
  }
  return num;
}

string mcxi = "ixcm";
string to_mcxi(int num)
{
  string s;
  stringstream ss;
  int n;
  for(int i = 3; i >= 0; i--)
  {
    n = num / (int)pow(10, i);
    num %= (int)pow(10, i);
    if(n == 1)
      ss << mcxi[i];
    else if(n > 1)
      ss << n << mcxi[i];
  }
  ss >> s;
  return s;
}

int main()
{
  int n;
  string a, b;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> a >> b;
    cout << to_mcxi(to_int(a) + to_int(b)) << endl;
  }
}

Measured memory_bytes: 1268
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const length = Number(inputs[0]);
  const str = inputs[1];
  const checkList = ['R', 'G', 'B'];
  let rejectCount = 0;
  let sum = 0;

  if (str.includes('R') && str.includes('G') && str.includes('B')) {
    sum += (str.split('R').length - 1) * (str.split('G').length - 1) * (str.split('B').length - 1);
  } else {
    console.log(sum);
    return;
  }

  for (let i = 0; i < length; i++) {
    for (let j = 1; j < length; j++) {
      if (i + j >= length || i + j * 2 >= length) {
        break;
      }

      if (str[i] !== str[i + j] && str[i] !== str[i + j * 2] && str[i + j] !== str[i + j * 2]) {
        rejectCount++;
      }
    }
  }

  sum -= rejectCount;

  console.log(sum);
}


Measured memory_bytes: 33196
import java.util.*;
 
 
public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
 
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
int a=Integer.parseInt(line);
line = sc.nextLine();
int b=Integer.parseInt(line);
line = sc.nextLine();
int h=Integer.parseInt(line);
        System.out.println((a+b)*h/2);
    }
}

Measured memory_bytes: 21716
using System;
class abc123a{
  static void Main(){
    var p=new int[5];
    for(int i=0;i<5;i++){
      p[i]=int.Parse(Console.ReadLine());
    }
    var k=int.Parse(Console.ReadLine());
    for(int i=0;i<5;i++){
      for(int j=i+1;j<5;j++){
        var l=p[j]-p[i];
        if(l>k){
          Console.WriteLine(":(");
          return;
        }
      }
    }
    Console.WriteLine("Yay!");
    return;
  }
}


Measured memory_bytes: 13140
def judge_1(arr, p, k):
    index = 0
    n = len(arr)
    for i in range(k):
        weight_sum = 0
        while weight_sum + arr[index] <= p:
            weight_sum += arr[index]
            index += 1
            if index >= n:
                return True
    return index >= n


if __name__ == '__main__':
    n, k = map(int, input().split())
    weight = []
    l, r = 0, 0
    for _ in range(n):
        tmp = int(input())
        weight.append(tmp)
        r += tmp
        l = max(l, tmp)
    ans = r
    while l <= r:
        mid = (l + r) // 2
        if judge_1(weight, mid, k):
            ans = mid
            r = mid - 1
        else:
            l = mid + 1
    print(ans)


Measured memory_bytes: 9556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int N = Integer.valueOf(st.nextToken());
            int M = Integer.valueOf(st.nextToken());
            st = new StringTokenizer(br.readLine());
            int len = Integer.MAX_VALUE;
            int[] data = new int[N];
            for (int i = 0; i < N; i++) {
                int point = Integer.valueOf(st.nextToken());
                data[i] = point;
            }
            for (int i = 0; i < N - M + 1; i++) {
                if (data[i] < 0) {
                    if (data[i + M - 1] < 0) {
                        len = Math.min(len, Math.abs(data[i]));
                    } else if (data[i + M - 1] == 0) {
                        len = Math.min(len, Math.abs(data[i]));
                    } else {
                        len = Math.min(len, Math.abs(data[i]) * 2
                                + data[i + M - 1]);
                        len = Math.min(len, Math.abs(data[i]) + data[i + M - 1]
                                * 2);
                    }
                } else if (data[i] == 0) {
                    len = Math.min(len, data[i + M - 1]);
                } else {
                    len = Math.min(len, data[i + M - 1]);
                }
            }
            System.out.println(len);

        } catch (IOException e) {
        }
    }

}


Measured memory_bytes: 39616
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using II = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VII = vector<II>;

class SuffixArray {
public:
  int N;
  string S;
  VI rank; // rank[i]: iから始まるsuffixの辞書順での順位
  VI sorted; // sorted[i]: suffixが辞書順i番目となる開始位置のindex
  SuffixArray(string s) {
    S = s;
    N = S.size();
    sorted = VI(N); rank = VI(N);
    REP (i, N) {
      sorted[i] = i;
      rank[i] = S[i];
    }

    int k;
    function<bool(int, int)> compare_sa = [this, &k](int i, int j) {
      if (rank[i] != rank[j]) { return rank[i] < rank[j]; }
      int ri = i + k < N ? rank[i + k] : -1;
      int rj = j + k < N ? rank[j + k] : -1;
      return ri < rj;
    };

    for (k = 1; k < N; k *= 2) {
      sort(sorted.begin(), sorted.end(), compare_sa);
      VI tmp(N, 0);
      REPI (i, 1, N) {
        tmp[sorted[i]] = tmp[sorted[i - 1]] + compare_sa(sorted[i - 1], sorted[i]);
      }
      rank = tmp;
    }
  }

  // Tが存在する場合はSにおける先頭index, 存在しない場合は-1を返す
  int find(string T) {
    int l = 0, r = N;
    while (r - l > 1) {
      cout << l << endl;
      int mid = (l + r) / 2;
      if (S.compare(sorted[mid], T.size(), T) < 0) {
        l = mid;
      } else {
        r = mid;
      }
    }
    if (S.compare(sorted[l], T.length(), T) != 0) { return -1; }
    return sorted[l];
  }
};

signed main() {
  int K;
  string S;
  cin >> K >> S;
  int N = S.size();
  int part = N / (K + 1);
  int rest = N % (K + 1);
  SuffixArray sf(S);
  if (rest == 0) {
    int ans = 0;
    REP (i, K + 1) {
      if (sf.rank[ans] < sf.rank[part * i]) {
        ans = part * i;
      }
    }
    cout << S.substr(ans, part) << endl;
    return 0;
  }
  int l = -1, r = N - 1;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    int next = 0;
    int adi = 0;
    REP (i, K + 1) {
      if (sf.rank[next] <= sf.rank[sf.sorted[mid]]) {
        next += part + 1;
        adi++;
      } else {
        next += part;
      }
    }
    if (adi >= rest) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << S.substr(sf.sorted[r], part + 1) << endl;
}

Measured memory_bytes: 2928
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    (\[a,b] -> a*b : (a+b)*2 : []) <$> readDigits
    >>= putStrLn . unwords . map show

Measured memory_bytes: 3604
N=int(input())
def divisor(n):
	divs=[]
	for i in range(1,int(n**0.5)+1):
		if n%i==0:
			divs.append(i)
			if i!=n//i:
				divs.append(n//i)
	divs.sort()
	return divs
d=divisor(N)
s=0
for i in range(1,len(d)):
	if d[i-1]+1!=d[i] and d[i]-1>d[-(i+1)]:
		s=s+d[i]-1
print(s)

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

using namespace std;


int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int w = 0, e = 0;
  for (int i = 1; i <= 999; i++) {
    e += i;
    if (w > 0) {
      if (b - a == e - w && w - a == e - b && w - a > 0) {
        printf("%d\n", w - a);
        return 0;
      }
    }
    w = e;
  }
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu ((int)1e9+7)
#define set0(a) memset(a,0,sizeof(a))

//sieve generation begin
vi PRIME;
void sieve(int n)
{
	bool a[n+1];
	memset(a,0,sizeof(a));
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<=n;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=n;j+=i)
			a[j]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		PRIME.pb(i);
	}
}
//sieve generation end
ll gcd(ll a,ll b)
{
	while(b%a)
	{
		ll c=b;
		b=a;
		a=c%a;
	}
	return a;
}
ll bigpow(ll x,ll y)
{
	if(y==0)
	return 1;
	else if(y&1)
	{
		return (x*bigpow((x*x)%chotu,(y-1)/2))%chotu;
	}
	else 
	return bigpow((x*x)%chotu,y/2);
}
//fastscanning
void fast_longint(ll &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register ll c; 
  
    number = 0; 
    c = getchar(); 
    if (c=='-') 
    { 
        
        negative = true; 
  
        c = getchar(); 
    } 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
    if (negative) 
        number *= -1; 
}
void fast_int(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
    c = getchar(); 
    if (c=='-') 
    { 
        
        negative = true; 
  
        c = getchar(); 
    } 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
    if (negative) 
        number *= -1; 
}
void solve()
{
int n;
cin>>n;
set<string>s;
while(n--)
{
string st;
cin>>st;
s.insert(st);
}
cout<<s.size();
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<'\n';
}

}

Measured memory_bytes: 19248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  io;
  ll n,i,t,a,ans=0;
  vector <ll> v,h;
  cin>>n;
  cin>>a;
  v.pb(a);
  t=a;
  h.pb(0);
  for(i=1;i<n;i++)
  {
    cin>>a;
    v.pb(a);
    if(t<a)
    t=a;

    h.pb(t);
  }
  for(i=1;i<n;i++)
  {
    if(v[i]<h[i])
    ans+=h[i]-v[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6664
n,t = map(int, input().split())
T = list(map(int, input().split()))

elapsed_t = 0
ans = 0

for i in range(1, n):
  elapsed_t = T[i]-T[i-1]
  if elapsed_t < t:
    ans += elapsed_t
  else:
    ans += t
    
print(ans+t)

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

class A
{
	static void Main() => Console.WriteLine(string.Join("\n", new int[int.Parse(Console.ReadLine())].Select(_ => Solve())));

	static long Solve()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long n = h[0], d = h[4], Mx = (1L << 60) / d;
		var ops = new[] { (2, h[1]), (3, h[2]), (5, h[3]) };

		var m = n <= Mx ? n * d : 1L << 60;
		var set = new HashSet<long>();
		var pq = PQ<(long x, long cost)>.Create(v => v.cost);
		pq.Push((n, 0));

		while (pq.Any())
		{
			var (x, cost) = pq.Pop();
			if (x <= Mx) m = Math.Min(m, cost + x * d);
			if (x == 1) return m;
			if (set.Contains(x)) continue;
			set.Add(x);

			foreach (var (p, c) in ops)
			{
				var div = x / p;
				for (int i = 0; i < 2; i++)
				{
					var nx = div + i;
					if (nx > 0) pq.Push((nx, cost + c + Math.Abs(nx * p - x) * d));
				}
			}
		}
		return -1;
	}
}

class PQ<T> : List<T>
{
	public static PQ<T> Create<TKey>(Func<T, TKey> getKey, T[] vs = null, bool desc = false)
	{
		var c = Comparer<TKey>.Default;
		return desc ?
			new PQ<T>(vs, (x, y) => c.Compare(getKey(y), getKey(x))) :
			new PQ<T>(vs, (x, y) => c.Compare(getKey(x), getKey(y)));
	}

	Comparison<T> c;
	public T First => this[0];

	PQ(T[] vs, Comparison<T> _c)
	{
		c = _c;
		if (vs != null) foreach (var v in vs) Push(v);
	}

	void Swap(int i, int j) { var o = this[i]; this[i] = this[j]; this[j] = o; }
	void UpHeap(int i) { for (int j; i > 0 && c(this[j = (i - 1) / 2], this[i]) > 0; Swap(i, i = j)) ; }
	void DownHeap(int i)
	{
		for (int j; (j = 2 * i + 1) < Count;)
		{
			if (j + 1 < Count && c(this[j], this[j + 1]) > 0) j++;
			if (c(this[i], this[j]) > 0) Swap(i, i = j); else break;
		}
	}

	public void Push(T v)
	{
		Add(v);
		UpHeap(Count - 1);
	}
	public T Pop()
	{
		var r = this[0];
		this[0] = this[Count - 1];
		RemoveAt(Count - 1);
		DownHeap(0);
		return r;
	}
}


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

const int N=300005,M=1000000007;
int n,f[N][2][3];
char s[N];
void add0(int i){
	for(int j=0;j<3;j++)for(int k=0;k<2;k++){
		f[i][0][j]=(f[i][0][j]+f[i-1][k][j])%M;
	}
}
void add1(int i){
	for(int j=0;j<3;j++)f[i][1][j]=(f[i][1][j]+f[i-1][0][j])%M;
	if(i&1)
		f[i][1][1]=(f[i][1][1]+f[i-1][1][0])%M;
	else f[i][1][0]=(f[i][1][0]+f[i-1][1][0])%M;
	if(i&1)
		f[i][1][1]=(f[i][1][1]+f[i-1][1][1])%M;
	else f[i][1][2]=(f[i][1][2]+f[i-1][1][1])%M;
	f[i][1][2]=(f[i][1][2]+f[i-1][1][2])%M;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0][1][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]=='0'){
			add0(i);
		}else if(s[i]=='1'){
			add1(i);
		}else{
			add0(i);
			add1(i);
		}
//		for(int j=0;j<2;j++)for(int k=0;k<3;k++)printf("%d ",f[i][j][k]);printf("\n");
	}
	add1(n+1);
	printf("%d\n",f[n+1][1][2]);
	return 0;
}

Measured memory_bytes: 7552
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Bool
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  s <- BS.getLine
  t <- BS.getLine
  print $ minimum $ map (length . (filter id) . BS.zipWith (/=) t) $ take (BS.length s - BS.length t + 1) $ BS.tails s


-- Input

getInt :: IO Int
getInt = readLn
second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine
 
getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

-- 組み合わせ
powerset :: [a] -> [[a]]  
powerset xs = filterM (\x -> [True, False]) xs


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string st;
    cin >> st;

    int w=0,r=0;

    REP(i,n){
        if(st[i]=='W')w++;
        else r++;
    }

    int sum=0;
    REP(i,r){
        if(st[i]=='W')sum++;
    }
    cout << sum << endl;
}


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

typedef pair<int, int> pii;

int K;
priority_queue<pii> pq;
int dist[100010];

int main() {
    scanf("%d", &K);

    for(int i = 0; i < 100010; i++) dist[i] = 1e9;
    for(int i = 1; i < min(K, 10); i++) {
        pq.push({-i, i});
        dist[i] = i;
    }

    while(!pq.empty()) {
        int u = pq.top().second;
        int d = pq.top().first;
        pq.pop();

        if(d > dist[u]) continue;

        for(int i = 0; i < 10; i++) {
            int v = (10 * u + i) % K;
            int w = i;

            if(dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                pq.push({ -dist[v], v });
            }
        }
    }

    printf("%d", dist[0]);
}


Measured memory_bytes: 2804
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,int> pl;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXV=100000;
const int MAXE=200000;
const ll INF=1e18;

struct edge{
    int to;
    ll cost;
};

int v,e,r;
vector<vector<edge> > G(MAXV);
vector<ll> d(MAXV,INF);

void dijkstra(int r){
    priority_queue<pl,vector<pl>,greater<pl> > que;
    d[r]=0;
    que.push(pl(0,r));
    while(!que.empty()){
        pl p=que.top();que.pop();
        ll a=p.first;int v=p.second;
        if(d[v]<a) continue;
        for(int i=0;i<(int)G[v].size();i++){
            edge ed=G[v][i];
            if(d[ed.to]>d[v]+ed.cost){
                d[ed.to]=d[v]+ed.cost;
                que.push(pl(d[ed.to],ed.to));
            }
        }
    }
}

int main(){
    cin>>v>>e>>r;
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        G[s].push_back(edge{t,d});
    }
    dijkstra(r);
    for(int i=0;i<v;i++){
        if(d[i]==INF) cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 19512
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int d[] = { 0, 1, 0, -1 };
int H, W; string s[55];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') cout << '#';
			else {
				int cnt = 0;
				for (int dx = -1; dx <= 1; dx++) {
					for (int dy = -1; dy <= 1; dy++) {
						int tx = i + dx, ty = j + dy;
						if (0 <= tx && tx < H && 0 <= ty && ty < W && s[tx][ty] == '#') cnt++;
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {
    static int[] label = new int[6];
    static int[][] label2;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        boolean ans = true;

        n = sc.nextInt();
        label2 = new int[n][6];
        for (int i = 0; i < 6; i++)
            label[i] = sc.nextInt();
        for (int j = 0; j < n - 1; j++) {
            for (int i = 0; i < 6; i++) 
                label2[j][i] = sc.nextInt();
            if (dice3(j)) {
                ans = false;
                break;
            }
        }
        
        if (ans) {
            System.out.println("Yes");
        }  else {
            System.out.println("No");
        }    
    }

    public static void dice1(char c) {
        int temp;
        switch (c) {
        case 'N':
            temp = label[0];
            label[0] = label[1];
            label[1] = label[5];
            label[5] = label[4];
            label[4] = temp;
            break;
        default :
            temp = label[1];
            label[1] = label[2];
            label[2] = label[4];
            label[4] = label[3];
            label[3] = temp;
            break;
        }
    }

    public static boolean dice3(int k) {
        boolean ans = false;
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 3; j++) {
                if (Arrays.equals(label2[k], label)) {
                    ans = true;
                    break;
                }
                dice1('X');
            }
            if (Arrays.equals(label2[k], label)) {
                ans = true;
                break;
            }
            dice1('N');
            if (i >= 2)
                dice1('N');
            if (i >= 3)
                dice1('N');
        }

        if (ans) {
            return true;
        }  else {
            return false;
        } 
    }
}


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

int N;
string s;

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

    int countR=0;
    int countB=0;

    for (int i=0; i<N; i++){
        if (s[i]=='R') countR++;
        if (s[i]=='B') countB++;
    }

    if(countR>countB) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int N, sol, y;

int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        if (i % 15 == 0) {
            sol -= 200;
        }
        sol += 800;
    }

    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define MAX_V 100005

struct edge{
    int to;
    long long cost;
    edge(int i, long long j) {to = i, cost = j; };
};
typedef pair<long long, int> P; // firstは最短距離、secondは頂点の番号

int V;
vector<edge> G[MAX_V];
long long d[MAX_V];
int pv[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, LLONG_MAX);
    fill(pv, pv + V, -1);
    d[s] = 0;
    que.push(P(0,s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first ) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost ) {
                d[e.to] = d[v] + e.cost;
                pv[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vector<int> get_path(int t){
    vector<int> path;
    for(; t != -1; t = pv[t]) path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

int main() {

    cin >> V;
    int a, b, c;

    REP(i, V-1){
        cin >> a >> b >> c;
        a--; b--;
        // cout << "a b c : " << a << " " << b << " " << c << endl;

        G[a].push_back(edge(b, c));
        G[b].push_back(edge(a, c));
    }

    int Q, K; cin >> Q >> K;
    K--;

    dijkstra(K);

    int x, y;
    REP(i, Q){
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 11504
#if defined(LOCAL)
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define MAX(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__y:__x;})
#define MIN(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  stack<l> s;
  vl v(n, numeric_limits<int>::max());
  vb in_queue(n);
  queue<l> q;
  F(j, 1, 10) {
    l t = j % n;
    if (in_queue[t]) continue;
    v[t] = j;
    in_queue[t] = true;
    q.emplace(t);
  }
  while (not q.empty()) {
    l a = q.front(); q.pop();
    in_queue[a] = false;
    F(i, 0, 10) {
      l t = (a * 10 + i) % n;
      if (v[t] <= v[a] + i) continue;
      v[t] = v[a] + i;
      if (in_queue[t]) continue;
      in_queue[t] = true;
      q.emplace(t);
    }
  }
  cout << v[0] << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
void solve(){
	double n,m,x,y,p,q;
	cin>>n;
	//expectancy =1/probabiluty;
	vector<int>A(4);
	for(int i=0;i<n;i++){
		cin>>x;
		A[x]++;
	}
	int a,b,c;
	a=A[1]+A[2]+A[3];
	b=A[2]+A[3];
	c=A[3];
	double dp[a+1][b+1][c+1];
	dp[0][0][0]=0;
	//dp[i][j][k] means probability when i 1-sushi dish, j 2-sushi dish, k 3- sushi dish
	double t=0;
	for(int k=0;k<=c;k++){
		for(int j=0;j<=(b-k);j++){
			for(int i=0;i<=(a-j-k);i++){
				t=j+k+i; //total ways to eat
				if((i+j+k)>0) dp[i][j][k]=n/double(t);
				if(k>0) dp[i][j][k]+=(double(k)/t)*dp[i][j+1][k-1];
				if(j>0) dp[i][j][k]+=(double(j)/t)*dp[i+1][j-1][k];
				if(i>0) dp[i][j][k]+=(double(i)/t)*dp[i-1][j][k];
			}
		}
	}
	cout<<setprecision(15)<<dp[A[1]][A[2]][A[3]]<<"\n";

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

Measured memory_bytes: 111048
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    vector<int> v(5), a(5);
    for(int i = 0; i < 5; i++) {
        cin >> v[i];
        if(v[i]%10 == 0) a[i] = 0;
        else a[i] = 10 - v[i] % 10;
    }
    
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < 5; i++) {
        ans += v[i] + a[i];
    }
    ans -= a.back();

    cout << ans << endl;

    return 0;
}

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;


int main(){
  int n;
  cin >> n;
  int v;
  vector<int> a(100010,0),b(100010,0);
  FOR(i,n){
    cin >> v;
    if(i%2==0){
      a.at(v)++;
    }else{
      b.at(v)++;
    }
  }
  int ans=0;
  auto a1=max_element(a.begin(),a.end());
  auto b1=max_element(b.begin(),b.end());
  int aa=distance(a.begin(),a1);
  int bb=distance(b.begin(),b1);
  if(aa==bb){
    int x=*a1;
    int y=*b1;
    a.at(aa)=0;
    b.at(bb)=0;
    auto a2=max_element(a.begin(),a.end());
    auto b2=max_element(b.begin(),b.end());
    ans=n-x-*b2;
    chmin(ans,n-*a2-y);
  }else{
    ans=n-*a1-*b1;
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i - 1] != s[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
N  = int(input())
As = [int(i) for i in input().split()]

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

devs = make_divisors(As[0])
devs.extend(make_divisors(As[1]))
devs = list(set(devs))
cnt = 1
for dev in sorted(devs)[::-1]:
    a = sum([a%dev==0 for a in As])
    if N - a == 0 or N -a == 1:
        print(dev)
        break

Measured memory_bytes: 14400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
 
typedef long long ll;
ll mod = 1e9+7;



int main()
{
    int n;
    cin>>n;
    if(n>=30)   cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;

     
    int ab;
    cin>>ab;
}

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

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<long long> a(n);
	long long sum = 0;
	
	for(long long &x : a) {
		cin >> x;
		sum += x;
		sum %= mod;
	}
	
	long long ans = 0;
	
	// 1 * 2 + 1 * 3 = 1 (2 + 3)
	
	for(int i = 0; i < n - 1; i++) {
		
		sum -= a[i];
		sum = (sum + mod) % mod;
		
		long long temp = (a[i] * sum) % mod;
		ans = (ans + temp) % mod;
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4780
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int n = in.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
		}
		for (int i = 0; i < n; i++) {
			y[i] = in.nextInt();
		}
		
		double max = 0;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, Math.abs(x[i] - y[i]));
		}
		
		out.println(minkowski(n, x, y, 1));
		out.println(minkowski(n, x, y, 2));
		out.println(minkowski(n, x, y, 3));
		out.println(max);
	}
	static double minkowski(int n, int[] x, int[] y, int p) {
		double sum = 0;
		for (int i = 0; i < n; i++) {
			double temp = Math.abs(x[i] - y[i]);
			sum += Math.pow(temp, p);
		}
		return Math.pow(sum, 1.0 / p);
	}
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
const ll INF = 1e18L + 5;
const ll MOD = 1e9 + 7;
const int nax = 1e5 + 5;


int main(){
	int n, c;
	scanf("%d%d", &n, &c);
	vector<ll> dp(nax + 1, INF); // 0....v
	dp[0] = 0;
	for(int item = 0; item < n; ++item) {
		ll w;
		int v;
		cin >> w >> v;
		for(int upto = nax - v; upto >= 0; --upto) {
			dp[upto + v] = min(dp[upto + v], dp[upto] + w);
		}
	}
	int res = 0;
	for(int i = 0; i <= nax; ++i) {
		if(dp[i] <= c && i > res) {
				res = i;
		}
	}
	printf("%d\n", res);
}



Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    LL tot = 0;
    LL cnt = n / k;
    tot += cnt * cnt * cnt;
    if (k % 2 == 0) {
        if (n%k >= k/2) cnt++;
        tot += cnt * cnt * cnt;
    }
    cout << tot << endl;








/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 256
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            char x1 = input[0];
            char x2 = input[1];
            char x3 = input[2];
            char x4 = input[3];

            int a = x1;
            int b = x2;
            int c = x3;
            int d = x4;

            if (a == b)
                Console.WriteLine("Bad");
            else if(b == c)
                Console.WriteLine("Bad");
            else if(c ==d)
                Console.WriteLine("Bad");
            else
                Console.WriteLine("Good");
        }
    }

Measured memory_bytes: 13140
#include <stdio.h>

int main(){
  int i, n, k, n_m = 0, n_p = 0;
  int x_m[ 100001 ] = {0};
  int x_p[ 100001 ] = {0};

  scanf( "%d%d", &n, &k );
  for ( i = 0; i < n; i++ ){
    int temp;
    scanf( "%d", &temp );
    if ( temp < 0 ){
      x_m[ n_m ] = temp;
      n_m++;
    }else {
      x_p[ n_p ] = temp;
      n_p++;
    }
  }
  //printf( "%d %d\n", n_m, n_p );
  int dist = -1, k_m = 0, k_p = k - k_m;
  int temp_d;
  //int pattern = 0;
  do{
    
    if ( k_p > n_p || k_m > n_m ){
      k_m++;
      k_p = k - k_m;
      continue;
    }
    //printf( "%d %d\n", k_m, k_p );
    temp_d = 0;
    if ( k_p == 0 ){
      //printf( "%d \n", x_m[ n_m - k_m ] );
      temp_d = ( -1 ) * x_m[ n_m - k_m ];
      //printf( "a:%d %d\n", temp_d, dist );
      if ( dist < 0 || dist > temp_d ) dist = temp_d;
    }else if ( k_m == 0 ){
      //printf( " %d\n", x_p[ k_p - 1 ] );
      temp_d = x_p[ k_p - 1 ];
      //printf( "b:%d %d\n", temp_d, dist );
      if ( dist < 0 || dist > temp_d ) dist = temp_d;
    }else if ( ( -1 ) * x_m[ n_m - k_m ] < x_p[ k_p - 1 ] ){
      //printf( "%d %d\n", x_m[ n_m - k_m ], x_p[ k_p - 1 ] );
      temp_d = -2 * x_m[ n_m - k_m ] + x_p[ k_p - 1 ];
      //printf( "c:%d %d\n", temp_d, dist );
      if ( dist < 0 || dist > temp_d ) dist = temp_d;
    }else if( ( -1 ) * x_m[ n_m - k_m ] >= x_p[ k_p - 1 ] ){
      //printf( "%d %d\n", x_m[ n_m - k_m ], x_p[ k_p - 1 ] );
      temp_d = ( -1 ) * x_m[ n_m - k_m ] + 2 * x_p[ k_p - 1 ];
      //printf( "d:%d %d\n", temp_d, dist );
      if ( dist < 0 || dist > temp_d ) dist = temp_d;
    }
    k_m++;
    k_p = k - k_m;
  }while ( k_m <= k );

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

  return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int H, W, K, cnt = 0;
	scanf("%d %d %d", &H, &W, &K);
	vector<int> cakes[H];
	int ans[H][W];
	char c;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			scanf(" %c", &c);
			if (c == '#') cakes[i].push_back(j);
			ans[i][j] = 0;
		}
	}
	for (int i = 0; i < H; ++i) {
		if (cakes[i].empty()) continue;
		int ptr = 0;
		for (int j: cakes[i]) {
			++cnt;
			for (; ptr <= j; ++ptr) ans[i][ptr] = cnt;
		}
		for (; ptr < W; ++ptr) ans[i][ptr] = cnt;
	}
	for (int i = 1; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (ans[i][j] == 0 && ans[i - 1][j] != 0) ans[i][j] = ans[i - 1][j];
		}
	}
	for (int i = H - 2; i >= 0; --i) {
		for (int j = 0; j < W; ++j) {
			if (ans[i][j] == 0 && ans[i + 1][j] != 0) ans[i][j] = ans[i + 1][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) printf("%d ", ans[i][j]);
		printf("%d\n", ans[i][W - 1]);
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    Pattern p = Pattern.compile("A.*Z");
    Matcher m = p.matcher(s);
    m.find();
    System.out.println(m.group().length());
  }
}

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

int main() { 
    string s;
    cin >> s;
    int a = s.find_first_of('A');
    int z = s.find_last_of('Z');
    cout << z - a + 1 << endl;
}

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

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

  int free_cnt = 0;
  const long long mod = 1e9 + 7;
  long long ans = 1;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(free_cnt * 2 + 1 <= tmp){
      free_cnt++;
    }else{
      ans *= (free_cnt + 1);
      ans %= mod;
    }
  }

  for(int j = 1; j <= free_cnt; j++){
    ans *= j;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,k;
    cin >> n >> k;
    
    vector<int> h(n);
    rep(i,n){
        int in;
        cin >> in;
        h.at(i) = in;
    }

    if(k >= n){
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(),h.end(),greater<int>());

    rep(i,k){
        h.at(i) = 0;
    }

    long long int sum = 0;
    rep(i,n){
        sum += h.at(i); 
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
# いきぬきreview　忘れた問題
# gluttony
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
A.sort(reverse=True)


def func(X):
    s = 0
    for i in range(N):
        a, f = A[i], F[i]
        s += max(0, a-X//f)
    return s <= K


R = 10**12
L = -1
while R-L > 1:
    m = (R+L)//2
    if func(m):
        R = m
    else:
        L = m
print(R)

Measured memory_bytes: 113868