akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

using namespace std;

int main() {
	int N;
	cin >> N;
	vvi edge(N);
	int a, b;
	REP(i, N-1) {
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	vi d(N);
	d[0] = 1;
	queue<int> Q;
	Q.push(0);
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		int size = edge[p].size();
		REP(i, size) {
			int n = edge[p][i];
			if (d[n] == 0) {
				d[n] = d[p] + 1;
				Q.push(n);
			}
		}
	}
	vi e(N);
	e[N - 1] = 1;
	Q.push(N - 1);
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		int size = edge[p].size();
		REP(i, size) {
			int n = edge[p][i];
			if (e[n] == 0) {
				e[n] = e[p] + 1;
				Q.push(n);
			}
		}
	}

	int fennec = 0, snuke = 0;
	REP(i, N) {
		if (e[i] >= d[i]) {
			fennec++;
		}
		else {
			snuke++;
		}
	}

	if (fennec > snuke) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}

	return 0;
}


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



int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }
    if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }
    if(s=="Rainy"){
        cout << "Sunny" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=(n+k-3)/(k-1);
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int a_sum = 0;
  int b_sum = 0;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    vec.at(i) = a;
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for (int i = 0; i < N; i++) {
    if ((i % 2) == 0) {
      a_sum += vec.at(i);
    }
    else if ((i % 2) != 0) {
      b_sum += vec.at(i);
    }
  }
  
  cout << a_sum - b_sum << endl;
}
    

Measured memory_bytes: 256
import java.util.Scanner;

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

		long a = x / 11;
		long b = x % 11;
		long ans = 0;
		if (b == 0) {
			ans = a * 2;
		} else if (b <= 6) {
			ans = a * 2 + 1;
		} else {
			ans = a * 2 + 2;
		}
		System.out.println(ans);
	}
}


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

int main()
{
	string s;
	cin >> s;
	int p = s.length();
	char T[200000];
	s.copy(T, p);
	for (int i = 0; i < p; i++)
	{
		if (T[i] == '?')
		{
			T[i] = 'D';
		}
	}

	for (int i = 0; i < p; i++)
	{
		cout << T[i];
	}

	return 0;
}

Measured memory_bytes: 3952
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    an = list(map(int, input().split()))
    an = sorted(an)
    assert len(an) == n
    bn = [an[0]]
    for i in range(1, n):
        bn.append(bn[-1] + an[i])

    cuts = []
    for i in range(n - 1):
        if bn[i] * 2 < an[i + 1]:
            cuts.append(i + 1)

    maxj = max(cuts + [0])
    assert 0 <= maxj < n
    print(n - maxj)

main()


Measured memory_bytes: 15148
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a;
  cin >> a;
  co(a%100%10 + a%100/10 + a/100);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s;cin>>s;
	int k=s.size()-(s[0]==s.back() ? 1 : 0);
	if(k%2) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

n = int(input())
a = [int(i) for i in input().split()]

#print(a)
a = np.sort(a)
ai = a[n-1]
aj = a[0]
center = ai / 2
diff = ai
i=0
for m in a:
    if diff > abs(m - center) :
        aj = m
        diff = abs(aj - center)
    else:
        break

print(ai,aj)


Measured memory_bytes: 23344
#include<iostream>

using namespace std;

int main()
{
	int N;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int a, b, c;

		cin >> a >> b >> c;
		if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b) cout << "YES\n";
		else cout << "NO\n";
	}
}


Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b >> u;
    if(u==s) a--;
    if(u==t) b--;
    cout << a << " " << b <<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, A, B;
  cin >> a >> b;
 
  A = a % 2;
  B = b % 2;
  if (A == 0 || B == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static final long MOD = 1_000_000_007L;
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		sc.close();
		long ans = 0L;
		for(long i = K; i <= N + 1; i++) {
			ans += i*(2*N+1-i)/2 - (i-1)*i/2 + 1;
			ans %= MOD;
			// System.out.println(i + "#" + (i*(2*N+1-i)/2 - (i-1)*i/2 + 1));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27084
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, d[200000], t[200000];
    cin >> n;
    for (int i=0; i<n; i++) cin >> d[i];
    cin >> m;
    for (int i=0; i<m; i++) cin >> t[i];

    sort(d, d+n); sort(t, t+m);

    int j = 0;
    bool memo[200000] = {};
    for (int i=0; i<m; i++) {
        for (j; d[j] <= t[i]; j++) {
            if (d[j] == t[i]) {
                memo[i] = true;
                j++;
                break;
            }
        }
    }

    bool f = true;
    for (int i=0; i<m; i++) {
        if (!memo[i]) f = false;
    }

    cout << (f ? "YES" : "NO") << endl;

    return 0;
}


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

int N;
int A[110];

int main(){
  cin >> N;
  int min,max;
  for(int i = 0; i < N; i++) cin >> A[i];
  min = A[0];
  max = A[0];
  for(int i = 1; i < N; i++){
    if(min > A[i]) min = A[i];
    if(max < A[i]) max = A[i];
  }
  
  cout << max - min << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var W = sc.nextInt();
        var H = sc.nextInt();
        var N = sc.nextInt();
        var x = new int[N];
        var y = new int[N];
        var a = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }

        var wmin = 0;
        var wmax = W;
        var hmin = 0;
        var hmax = H;
        for (int i = 0; i < N; i++) {
            if (a[i] == 1) {
                wmin = Max(wmin, x[i]);
            } else if (a[i] == 2) {
                wmax = Min(wmax, x[i]);
            } else if (a[i] == 3) {
                hmin = Max(hmin, y[i]);
            } else {
                hmax = Min(hmax, y[i]);
            }
        }
        if (wmin >= wmax || hmin >= hmax) {
            WriteLine(0);
            return;
        }
        WriteLine(Abs(wmax-wmin) * Abs(hmax-hmin));
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N - K) {
        if (A[i] < A[i + K]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());



            string[] str = Console.ReadLine().Split(' ');
            int k = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            str = Console.ReadLine().Split(' ');
            int[] a = new int[m];

            for(int i = 0; i < m; i++) { a[i] = int.Parse(str[i]); }

            int max = k - a[m - 1] + a[0];
            for(int i = 0; i < m-1; i++)
            {
                int temp = a[i + 1] - a[i];
                if (max < temp) max = temp;
            }

            Console.WriteLine(k-max);





            //ここまで
        }



    }

}


Measured memory_bytes: 34652
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    // debug
    // for (int i = 0; i < N; i++)
    // {
    //     cout << S[i] << endl;
    // }
    sort(S.begin(), S.end());
    //  debug
    // for (int i = 0; i < N; i++)
    // {
    //     cout << S[i] << endl;
    // }
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
    return (0);
}

Measured memory_bytes: 9544
l1 = gets.split.map(&:to_i)
l2 = gets.split.map(&:to_i)
l3 = gets.split.map(&:to_i)

f1 = false
f2 = false
(-100..100).each do |i|
  lb1 = l1.map{|v| v-i}
  (-100..100).each do |j|
    lb2 = l2.map{|v| v-j}
    lb3 = l3.map{|v| v-j}
    f1 = true if lb2 == lb1
    f2 = true if lb3 == lb1
  end
end

if f1 && f2
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n, m, c := nextInt(), nextInt(), nextInt()
	b := nextInts(m)

	ans := 0
	for i := 0; i < n; i++ {
		a := nextInts(m)
		sum := 0
		for i := range b {
			sum += a[i] * b[i]
		}
		if sum+c > 0 {
			ans++
		}
	}
	puts(ans)

	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  //ifstream cin("in.txt");
  map<string, int> mp;
  int q;
  cin >> q;
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      string name;
      int val;
      cin >> name >> val;
      mp[name] = val;
    } else if (op == 1) {
      string name;
      cin >> name;
      cout << mp[name] << endl;
    } else if (op == 2) {
      string name;
      cin >> name;
      mp.erase(name);
    }
  }

  return 0;
}


Measured memory_bytes: 27824
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var k = Read().ToInt();
            var l = new List<decimal>();
            for (int i = 1; i <= 9; i++)
            {
                l.Add(i);
            }
            var ans = new List<decimal>();
            ans.AddRange(l);
            foreach (var num in l)
            {
                Add(num, ans);
            }
            ans.Sort();
            WriteRead(ans[k - 1]);
        }

        private static void Add(decimal num, List<decimal> a)
        {
            if (num > 999999999)
            {
                return;
            }
            if (num.ToString().Last().ToInt() + 1 < 10)
            {
                var cNum = (num.ToString() + (num.ToString().Last().ToDecimal() + 1).ToString()).ToDecimal();
                a.Add(cNum);
                Add(cNum, a);
            }
            if (num.ToString().Last().ToInt() - 1 >= 0)
            {
                var cNum2 = (num.ToString() + (num.ToString().Last().ToDecimal() - 1).ToString()).ToDecimal();
                a.Add(cNum2);
                Add(cNum2, a);
            }
            var cNum3 = (num.ToString() + (num.ToString().Last().ToDecimal()).ToString()).ToDecimal();
            a.Add(cNum3);
            Add(cNum3, a);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {   
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 26496
s=gets.chomp.to_s
s1=s.count(s[0])
s2=s.count(s[1])
s3=s.count(s[2])
s4=s.count(s[3])
puts (s1==2)&&(s2==2)&&(s3==2)&&(s4==2) ? :Yes : :No

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll ans=0;
  ll n=s.size()/2;
  rep(i,n-1){
    if(s.substr(0,i+1)==s.substr(i+1,i+1)) ans=(i+1)*2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

if 0 in A:
  iszero = True
for i in range(N):
  if(iszero):
    ans = 0
    break
  ans *= A[i] 
  if ans>10**18:
    ans = -1
    break

print(ans)

Measured memory_bytes: 21432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const int N=75,mod=1e9+7;
int n,k,a[N],use[N],posr[N],posb[N],fac[N],ifac[N],c[N*3][N*3],Ans;
char s[N];
inline int fpow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1) ans=(ll)ans*a%mod;
	return ans;
}
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x; 
}
inline int C(ri n,ri m){
	return m<0||n<m?0:c[n][m];
}
inline void solve(ri cnt){
	ri i,now,res;
	for(i=1;i<=k;++i) use[i]=0;
	for(i=1;i<=cnt;++i) posr[i]=posb[i]=0;
	now=0;
	for(i=1;i<=k&&now<cnt;++i)
		if(s[i]=='r') use[i]=1,posr[++now]=i;
	if(now<cnt) return;
	now=0;
	for(i=1;i<=cnt&&a[i]>=2;++i){
		for(now=max(now,posr[i]+1);now<=k&&s[now]!='b';++now);
		if(now>k) return;
		posb[i]=now;
		use[now]=1;
		++now;
	}
	now=0;
	for(i=1;i<=cnt&&a[i]>=3;++i){
		res=a[i]-2;
		for(now=max(now,posb[i]+1);now<=k&&res;++now)
			if(!use[now])
				use[now]=1,--res;
		if(res) return;
	}
	
	ri j,ans=fac[cnt],c1,c2;
	for(i=1;i<=cnt;i=j+1){
		for(j=i;j+1<=cnt&&a[j+1]==a[i];++j);
		ans=(ll)ans*ifac[j-i+1]%mod;
	}
	c1=n+1;
	c2=0;
	for(i=1;i<=cnt;++i){
		if(a[i]>=2)
			c1+=2;
		c2+=a[i]*2;
	} 
	ans=(ll)ans*C(c1,c2)%mod; 
	add(Ans,ans);
}
inline void dfs(ri i,ri sum){
	if(i>1) solve(i-1);
	for(ri j=a[i-1];j;--j)
		if(sum+j*2-(j>=2?2:0)<=n+1)
			a[i]=j,
			dfs(i+1,sum+j*2-(j>=2?2:0));
}
int main(){
	scanf("%d%d%s",&n,&k,s+1);
	ri i,j,m;
	fac[0]=1;
	for(i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod;
	ifac[n]=fpow(fac[n],mod-2);
	for(i=n;i;--i) ifac[i-1]=(ll)ifac[i]*i%mod;
	m=3*n+1;
	for(i=0;i<=m;++i){
		c[i][0]=1;
		for(j=1;j<=i;++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	a[0]=m;Ans=1;
	dfs(1,0);
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <deque>
using namespace std;

int main() {
	int n ; cin >> n ; cin.ignore();
	while(n--)
	{
		string str; getline(cin,str);
		deque<char> dq; deque<char>::iterator ite;
		char ch; ch=str[0]; dq.push_front(ch);
		ite=dq.begin();
		for(int i=1;i<str.size();i+=3)
		{
			string tmp="";
			tmp+=str[i]; tmp+=str[i+1];
			ch=str[i+2];
			if(tmp=="->")
			{
				ite++;
				if(ite==dq.end()) dq.push_back(ch);
				else if(*ite!=ch) dq.insert(ite,ch);
			}
			else
			{
				if(ite==dq.begin()) dq.push_front(ch),ite--;
				else
				{
					ite--;
					if(*ite!=ch) dq.insert(ite,ch);
				}
			}
		}
		for(ite=dq.begin();ite<dq.end();ite++) cout << *ite ;
		cout << '\n' ; dq.clear();
	}
}

Measured memory_bytes: 1216
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long n;cin>>n;
  //完全に隣り合ったものだと思ってて無理でしょこれになっていた...
  vector<long> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  vector<long> B(n+1);
  B[0] = 0;
  for(int i = 0; n > i; i++){
    B[i+1] = B[i]+A[i]; 
  }
  long i = n-1;
  while(2*B[i]>=A[i])i--;
  cout << n-i << endl;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int lim = M/N;

  for(int i = lim; i > 0; i--){
    if(M%i == 0){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
// atcoder/abc179/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);


  int n;
  while (cin >> n) {
    int x = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; i * j <= n; ++j) {
        if (i * j < n) ++x;
      }
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let a: i64 = sc.get();
    let b: i64 = sc.get();
    let c: i64 = sc.get();
    if a + b > c {
        println!("No");
        return;
    }
    if 4 * a * b < (c - a - b) * (c - a - b) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int W, A, B;
	cin >> W >> A >> B;
	int ans1 = 0;
	int ans2 = 0;
	ans1 = B - A - W;
	ans2 = A - B - W;
	if (ans1 < 0) {
		ans1 = 0;
	}
	if (ans2 < 0) {
		ans2 = 0;
	}
	cout << max(ans1, ans2) << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#1400

def main():
	x,y=MI()
	mod=10**9+7

	a=2*y-x
	b=2*x-y

	if a%3!=0 or b%3!=0 or a<0 or b<0:
		print(0)
		exit(0)

	a//=3
	b//=3

	f=[1]
	for i in range(1,10**6):
		f.append(f[-1]*i%mod)

	ans=f[a+b]*pow(f[a],mod-2,mod)*pow(f[b],mod-2,mod)
	print(ans%mod)


if __name__ == "__main__":
	main()

Measured memory_bytes: 42668
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> s(n+1);
    map<ll,ll> h;
    s[0]=0;
    h[0]++;
    rep(i,n){
        ll a;
        cin >> a;
        s[i+1]=(s[i]+a)%m;
        h[s[i+1]]++;
    }
    ll ans=0;
    for(auto x:h){
        if(x.se>=2){
            ans+=(x.se-1)*x.se/2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
		ans ^= a[i];
	}
	ll cpy = ans;
	rep(i,n) {
		ans = cpy ^ a[i];
		cout << ans << ' ';
	}
	cout << endl;
	return 0;
}


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

int main(){
    int n,sum;
    cin >> n >> sum;
    bool isFound = false;
    for(int x = 0; x <= n; x++){
        for(int y = 0; y <= n-x; y++){
            if(x*10000 + y*5000 + 1000*(n-x-y) == sum){
                cout << x << " " << y << " " << n-x-y << endl;
                isFound=true; break;
            }
        }
        if(isFound) break;
    }
    if(!isFound) cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
H = read_ints()

# https://atcoder.jp/contests/dp/tasks/dp_a
# 全探索ではナンセンス(というより処理が終わらない)
# i+1 or i+2のうち小さい方を選びつづければいいということにすぐに気がつく
# こういったように、今の状態から次の状態が決まるときはDPが使えることがおおい(この問題はgreedy気味にも捉えることができるが。)
# 途中までの状態が決まれば、最善手を選ぶことで次の状態が決定できるのを実装する。
# 今回の場合だったらhまでの最善の状態というのはmin(2つ前までの最善の状態+差, 1つ前までの最善の状態+差)なのでこれでdpテーブルを埋めていくことができる。
# こういった最小化問題はinfで初期化すると良い

import numpy as np
dp = np.full((N), float('inf'))
dp[0] = 0
dp[1] = abs(H[0] - H[1])

# この概念はいわゆる貰うDP
# for i in range(2, N):
#     dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]),
#                 dp[i - 2] + abs(H[i] - H[i - 2]))

# print(dp[-1])
# 配るDPで実装してみる
for i in range(0, N-2):
    dp[i + 1] = min(dp[i] + abs(H[i] - H[i+1]), dp[i+1])
    dp[i + 2] = min(dp[i] + abs(H[i] - H[i + 2]), dp[i + 2])

# これだと最後のdp[N-1]がdp[N-2]から値を受け取れないので最後につじつま合わせ

dp[-1] = min(dp[-2] + abs(H[-2] - H[-1]), dp[-1])

print(int(dp[-1]))


Measured memory_bytes: 17156
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int w, a, b;
	cin >> w >> a >> b;

	int ans;

	if(a<b) ans = b-a-w;
	if(a>b) ans = a-b-w;

	if(ans < 0) ans = 0;

	cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
*A, = map(int,input().split())

if N==1:
    print(1)
    exit()

A.sort()

L = [False]*(10**6+1)
for i,a in enumerate(A):
    if A[i-1] == a:
        L[a] = True
        continue
    if L[a]: continue
    for i in range(2,10**6+1):
        if a*i > 10**6: break
        L[a*i] = True

ans = 0
for a in A:
    if not L[a] : ans += 1
print(ans)

Measured memory_bytes: 130432
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		char[] c = s.toCharArray();
		int a = (int)c[0];
		if(65<=a&&a<=90) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}

	}

}


Measured memory_bytes: 35660
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  string ans, in;
  cin >> in;
  for (auto& c : in) {
    if (c != 'B') {
      ans += c;
    } else {
      if (ans.size())
        ans.pop_back();
    }
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define FILE_IN freopen("input.txt", "r", stdin);
#define FILE_OUT freopen("output.txt", "w", stdout);
#define PI acos(-1)
using namespace std;
void fastio()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);
  cout. tie(0);

}
int main() {
 fastio();
  int f,t,x,y;
    multiset<int>s;
 multiset<int>::iterator it1,it2;
    cin>>t;
    while(t--) {
        cin>>f>>x;
        if(f==0) {
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(f==1)
            cout<<s.count(x)<<endl;

       else if(f==2)
          s.erase(x);

       else{
          cin>>y;

         it1=s.lower_bound(x);
         it2=s.upper_bound(y);
         for(;it1 != it2;it1++)
          cout<<*it1<<endl;
       }

}
    return 0;
}




Measured memory_bytes: 12404
#include <stdio.h>

int main(void)
{
    int     level;
    int     a, b;
    scanf("%d", &level);
    if(level == 1)
        printf("Hello World\n");
    else if(level == 2){
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d\n", a + b);
    }
    return (0);
}

Measured memory_bytes: 128
import collections
N = int(input())
A = list(map(int,input().split()))
S = collections.deque([])
for i in range(1,N):
    S.append(A[i]^A[i-1])
val = A[0]
for i in range(0,len(S),2):
    val = val^S[i]
T = [str(val)]
while len(S)>0:
    T.append(str(int(T[-1])^S.popleft()))
print(' '.join(T))
    


Measured memory_bytes: 113088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    bool flag = true;
    if(s.size()%2 == 0){
        ll i = 0;
        while(i < s.size()){
            if(s[i] != 'h' || s[i+1] != 'i'){
                flag = false;
                break;
            }
            i+=2;
        }
        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
d={}
for i in range(n-1):
    try:
        d[a[i]]+=1
    except:
        d[a[i]]=1
for i in range(n):
    try:
        print(d[i+1])
    except:
        print(0)


Measured memory_bytes: 33536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;
int main() {
    int n; cin>>n;
    vector<int> c(n),s(n),f(n);
    rep(i,0,n-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    
    rep(i,0,n){
        int t=0;
        rep(j,i,n-1){
            if(t<s[j])t=s[j];
            else if(t%f[j])t=t+f[j]-t%f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

def divide_3(a, b):
    diff1, diff2 = INF, INF
    for i in range(-1, 2):
        p1 = (a//3+i) * b
        left_1 = H*W - p1
        p2 = b//2 * (a - (a//3+i))
        p3 = left_1 - p2
        diff_1 = max(p1, p2, p3) - min(p1, p2, p3)
        diff1 = min(diff1, diff_1)

        q1 = (ceil(a/3)+i) * b
        left_2 = H*W - q1
        q2 = b//2 * (a - (ceil(a/3)+i))
        q3 = left_2 - q2
        diff_2 = max(q1, q2, q3) - min(q1, q2, q3)
        diff2 = min(diff2, diff_2)

    return min(diff1, diff2, a, b)

print(min(divide_3(H, W), divide_3(W, H)))



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

map<char, string> en;
map<string, string> de;
string s, t;
string in;
int n;

void encode()
{
  en[' '] = "101";
  en['\''] = "000000";
  en[','] = "000011";
  en['-'] = "10010001";
  en['.'] = "010001";
  en['?'] = "000001";
  en['A'] = "100101";
  en['B'] = "10011010";
  en['C'] = "0101";
  en['D'] = "0001";
  en['E'] = "110";
  en['F'] = "01001";
  en['G'] = "10011011";
  en['H'] = "010000";
  en['I'] = "0111";
  en['J'] = "10011000";
  en['K'] = "0110";
  en['L'] = "00100";
  en['M'] = "10011001";
  en['N'] = "10011110";
  en['O'] = "00101";
  en['P'] = "111";
  en['Q'] = "10011111";
  en['R'] = "1000";
  en['S'] = "00110";
  en['T'] = "00111";
  en['U'] = "10011100";
  en['V'] = "10011101";
  en['W'] = "000010";
  en['X'] = "10010010";
  en['Y'] = "10010011";
  en['Z'] = "10010000";
}

void decode()
{
  de["00000"] = "A";
  de["00001"] = "B";
  de["00010"] = "C";
  de["00011"] = "D";
  de["00100"] = "E";
  de["00101"] = "F";
  de["00110"] = "G";
  de["00111"] = "H";
  de["01000"] = "I";
  de["01001"] = "J";
  de["01010"] = "K";
  de["01011"] = "L";
  de["01100"] = "M";
  de["01101"] = "N";
  de["01110"] = "O";
  de["01111"] = "P";
  de["10000"] = "Q";
  de["10001"] = "R";
  de["10010"] = "S";
  de["10011"] = "T";
  de["10100"] = "U";
  de["10101"] = "V";
  de["10110"] = "W";
  de["10111"] = "X";
  de["11000"] = "Y";
  de["11001"] = "Z";
  de["11010"] = " ";
  de["11011"] = ".";
  de["11100"] = ",";
  de["11101"] = "-";
  de["11110"] = "'";
  de["11111"] = "?";
}

int main()
{
  encode();
  decode();

  while(getline(cin, s)){
    t = "";
    in = "";
    in += s + " ";

    rep(i, in.size()-1) t += en[in[i]];
    n = (5 - t.size() % 5) % 5;
    rep(i, n) t += "0";

    n = t.size() / 5;
    rep(i, n) cout << de[t.substr(5*i, 5)];
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, dp[maxn];
int h[maxn];
main () {
	cin >> n;
	forn(i, 1, n)
		cin >> h[i];
	dp[1] = 0;
	forn(i, 2, n){
		dp[i] = inf * inf;
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i > 2)
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n];

}

Measured memory_bytes: 1792
/*****TEMPLATE*****/
      

#include <algorithm>
#include <array>
#include <bitset>
#include <cctype> 
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cstring>
#include <cstdio>
#include <stdio.h>
//INCLUDES
using namespace std;

#define lld long long int
#define ulld unsigned long long int
#define mod 1000000007
#define pb push_back
#define umap unordered_map
#define mp make_pair
#define fi first
#define se second 
#define rep(n) for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//DEFINES

lld gcd(lld a,lld b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){lld r=a%b; a=b; b=r;} return a;}
lld bs(lld arr[], lld l, lld r, lld x) { if (r >= l) {  lld mid = l + (r - l) / 2;  if (arr[mid] == x)  return mid; if (arr[mid] > x)  return bs(arr, l, mid - 1, x);  return bs(arr, mid + 1, r, x);  }  return -1; }
lld mypower(lld x, lld n){	if (n == 0)	return 1;	if (n & 1) 	return (((x * mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod)%mod);return (((mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod))%mod;}
lld modinv(lld a) { lld g = gcd(a, mod); if (g != 1) return -1;else{  return mypower(a, mod-2)%mod; } } 

//FUNCTIONS
void solve()
{
    lld n;
    cin>>n;
    lld h[n];
    rep(n)cin>>h[i];
    lld ans[n]={};
    ans[0]=0;
    ans[1]=abs(h[1]-h[0]);
    for (int i = 2; i < n; i++) {
        ans[i]=min((abs(h[i]-h[i-1])+ans[i-1]),(abs(h[i]-h[i-2])+ans[i-2]));
    }
    cout<<ans[n-1]<<"\n";
    return;
}
int main() 
{
    fast
    // lld t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}



Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(min(a + b, b + c), c + a) << endl;
}

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

int main() {
  int N;
  int K;  
  int output=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int x,dist_K,output_buff;
    cin>>x;
    dist_K=K-x;
    if(x<dist_K){
    output_buff=x*2;
    }else{
    output_buff=dist_K*2;
      if(output_buff<0){
      output_buff*=-1;
      }
    }
    output+=output_buff;
  }
  cout<< output<<endl;
  // ここにプログラムを追記
  
}



Measured memory_bytes: 256