akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

class BookIndex
{
   private SortedDictionary<string, List<int>> bookIndexList = new SortedDictionary<string, List<int>>();

   public void Add(string word, int page)
   {
      if (!bookIndexList.ContainsKey(word))
      {
         bookIndexList.Add(word, new List<int>());
      }

      bookIndexList[word].Add(page);
   }

   public override string ToString()
   {
      var stringbuilder = new StringBuilder();

      foreach (var word in bookIndexList.Keys)
      {
         stringbuilder.AppendLine(word);

         bookIndexList[word].Sort();
         bookIndexList[word].Aggregate(stringbuilder, (sb, page) => sb.AppendFormat("{0} ", page.ToString()));
         stringbuilder.Remove(stringbuilder.Length - 1, 1);
         stringbuilder.AppendLine();
      }

      return stringbuilder.ToString();
   }
}

class MainClass
{
   static void Main(string[] args)
   {
      var bookIndex = new BookIndex();

      while (true)
      {
         string line = Console.ReadLine();
         if (line == null) { break; }

         string[] datas = line.Split(' ');
         string word = datas[0];
         int page = int.Parse(datas[1]);

         bookIndex.Add(word, page);
      }

      Console.Write(bookIndex.ToString());
   }
}


Measured memory_bytes: 11428
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

const int INF = 1 << 29;

struct Edge
{
    int to, rev;
    int capacity;

    Edge(int to_, int capacity_, int rev_)
            : to(to_), capacity(capacity_), rev(rev_){}
};

int DFS(int current, int target, int flow,
        std::vector<std::vector<Edge>>& connection,
        std::vector<bool>& seenTable)
{
    if (current == target)
        return flow;

    seenTable[current] = true;
    for (auto& e : connection[current])
    {
        if (!seenTable[e.to] && 0 < e.capacity)
        {
            auto d = DFS(e.to, target, std::min(flow, e.capacity), connection, seenTable);
            if (0 < d)
            {
                // d だけ e に流す
                e.capacity -= d;

                // d だけ 逆編から流れる
                connection[e.to][e.rev].capacity += d;

                return d;
            }
        }
    }

    return 0;
}

int MaxFlow(int s, int t, std::vector<std::vector<Edge>>& connection)
{
    std::vector<bool> seenTable(connection.size());

    int flow = 0;
    while (true)
    {
        for (auto i=0; i<seenTable.size(); ++i)
            seenTable[i] = false;

        int f = DFS(s, t, INF, connection, seenTable);
        if (f == 0)
            return flow;
        else
            flow += f;
    }
}

int main()
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::vector<char>> tile(H, std::vector<char>(W));
    for (auto i=0; i<H; ++i)
        for (auto j=0; j<W; ++j)
            std::cin >> tile[i][j];

    std::vector<std::vector<Edge>> graph;
    graph.resize(H + W + 2);

    const int S = 0;
    const int T = 1;

    // S と T で id を先約してる分ずらす
    auto ToXNode = [&](int x) { return x + H + 2; };
    auto ToYNode = [&](int y) { return y + 2; };
    auto Connect = [&](int from, int to, int capacity)
            {
                graph[from].push_back(Edge(to, capacity, graph[to].size()));
                graph[to].push_back(Edge(from, 0, graph[from].size() - 1));
            };
    for (auto i=0; i<H; ++i)
    {
        for (auto j=0; j<W; ++j)
        {
            // S からや、 T へ直接飛んだら達成不可能(= cap is INF)
            if (tile[i][j] == 'S')
            {
                Connect(S, ToXNode(j), INF);
                Connect(S, ToYNode(i), INF);
            }
            else if (tile[i][j] == 'T')
            {
                Connect(ToXNode(j), T, INF);
                Connect(ToYNode(i), T, INF);
            }

            if (tile[i][j] != '.')
            {
                Connect(ToXNode(j), ToYNode(i), 1);
                Connect(ToYNode(i), ToXNode(j), 1);
            }
        }
    }

    auto result = MaxFlow(S, T, graph);
    if (INF <= result)
        std::cout << -1 << std::endl;
    else
        std::cout << result << std::endl;
}


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

int main()
{
	int n;
	while(cin >> n)
	{
		if(n > 36)
		{
			cout << 0 << endl;
			continue;
		}

		int max = (n < 9) ? n : 9;

		int found = 0;
		for(int a = 0; a <= max; a++)
			for(int b = 0; b <= max; b++)
				for(int c = 0; c <= max; c++)
					for(int d = 0; d <= max; d++)
						if(a + b + c + d == n)
							found++;

		cout << found << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
    };
    let mut ans = 100;
    for i in 0..26 {
        let c = (i as u8 + 'a' as u8) as char;
        let (l, r) = {
            let mut max_l = 0;
            let mut l = 0;
            for &s_i in s.iter() {
                if s_i == c {
                    max_l = std::cmp::max(max_l, l);
                    l = 0;
                } else {
                    l += 1;
                }
            }
            (max_l, l)
        };
        let v = r + std::cmp::max(0, l - r);
        ans = std::cmp::min(ans, v);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
 
//#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
 
 
#define boost ios::sync_with_stdio(false); cin.tie(nullptr);
#define MOD 1000000007
#define sd(x) scanf("%d", &(x))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ones(x) __builtin_popcount(x)
#define sz(x) int (x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f1(i,a,b) for(int i=a; i<=b; i++)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
 
 
using ll = unsigned long long ;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;  
typedef double ld;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
 
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
 
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
 
void solve(){
	long long N, M; cin >> N >> M;
 
	cout << abs((N-2)*(M-2)) << endl;
}
 
signed main(){
	int T =1 ; 
	//sd(T);
	while(T--){
		solve();
	}
 
#ifdef np
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

d = defaultdict(list)
for s, c in SC:
    d[s].append(c)


if any(len(set(v)) > 1 for v in d.values()):
    print(-1)
elif d[1] == [0] and N > 1:
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    ans = [0] * N
    ans[0] = 1
    for i in range(N):
        if d[i + 1]:
            ans[i] = d[i + 1].pop()
            
    print("".join(list(map(str, ans))))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    while(1){
        int m;
        cin >> n >> m;
        if(n==0){
            break;
        }
        int tot=0;
        m /= n;
        REP(i,n){
            int a;
            cin >> a;
            tot += min(m,a);
        }
        print(tot);
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
const int M=1E5;
long a[2*M+5];
int main(){
	long n,sum=0,j=1;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];	
	for(int i=0;i<n;i++){
		if(a[i]==j) {
			j++;
			continue;	
		}
		else sum++;
	}
	if(sum==n) cout << "-1" << endl;
	else cout << sum << endl;
	return  0;
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  ll K; cin>>K;
  ll N=S.size();
  
  vector<ll> vec(N);
  rep(i,N) vec[i]=('z'-S[i]+1)%26;
  
  //vector<int> checked(N,0);
  rep(i,N) if(K>=vec[i]) {K-=vec[i]; S[i]='a';}
  K%=26;
  S[N-1]+=K;
  cout<<S<<'\n';
  
  return 0;
}

Measured memory_bytes: 4240
<?php
list($a,$b,$c) = explode(" ",trim(fgets(STDIN)));
$count = trim(fgets(STDIN));
for ($i = 0; $i < $count; $i++) {
     $ha = trim(fgets(STDIN));
     switch($ha) {
         case $ha == "nobiro":
             $a += $b;
             break;
        case $ha == "tidime":
             $a += $c;
             break;
        case $ha == "karero":
             $a = 0;
             break;
     }
     if($a < 0) {
         $a = 0;
     }
}
if($a >= 0) {
echo intval($a) .PHP_EOL;    
} else {
    echo 0 . PHP_EOL;
}




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

int a[15][15];
int c[15];
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++) cin >> a[i][j];
   }
   
   int ans = 1001001001;
    for (int bit=0; bit<(1<<n); bit++){
      int cost = 0;
      int sk[15] = {0};
      bool hantei = true;
        for (int i = 0; i < n; i++){
            if (bit&(1ull<<i)){
              cost += c[i];
              for(int j = 0; j < m; j++) sk[j] += a[i][j];
          }
        }
        for(int j = 0; j < m; j++){
          if(sk[j]>=x) continue;
          else hantei = false;
        }
        if(hantei) ans = min(ans, cost);
    }
   if(ans != 1001001001)cout << ans << endl;
   else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3576
package main

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

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	a := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		a[i] = eGetInt(scanner)
	}
	rev := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		rev[a[i]] = i
	}
	for i := 1; i < n+1; i++ {
		fmt.Println(rev[i])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 4224
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final String num = in.nextLine();
        int bitCount = 0;
        for (int i = 0; i < n; i++) {
            bitCount += num.charAt(i) == '1' ? 1 : 0;
        }
        if (bitCount == 1) {
            for (int i = 0; i < n; i++) {
                if (num.charAt(i) == '1') {
                    System.out.println(0);
                } else {
                    if (i == n - 1 || num.charAt(n - 1) == '1') {
                        System.out.println(2);
                    } else {
                        System.out.println(1);
                    }
                }
            }
            return;
        }
        final long[] plusOne = new long[n];
        final long[] minusOne = new long[n];
        long tempPlusOne = 0;
        long tempMinusOne = 0;
        long runningPlus = 1;
        long runningMinus = 1;
        for (int i = n - 1; i >= 0; i--) {
            plusOne[i] = runningPlus;
            minusOne[i] = runningMinus;
            if (num.charAt(i) == '1') {
                tempPlusOne += runningPlus;
                tempMinusOne += runningMinus;
            }
            runningPlus = (runningPlus * 2) % (bitCount + 1);
            runningMinus = (runningMinus * 2) % (bitCount - 1);
        }
        for (int i = 0; i < n; i++) {
            if (num.charAt(i) == '0') {
                System.out.println(f((tempPlusOne + plusOne[i]) % (bitCount + 1)));
            } else {
                System.out.println(f((tempMinusOne - minusOne[i]) % (bitCount - 1)));
            }
        }
    }

    private static int f(long n) {
        int res = 1;
        while (n > 0) {
            n %= Long.bitCount(n);
            res++;
        }
        return res;
    }
}


Measured memory_bytes: 62828
def main(n: int, k: int, h: list):
    h.sort()

    print(min([h[i + k - 1] - h[i] for i in range(n - k + 1)]))


if __name__ == "__main__":
    n, k = map(int, input().split())
    h = [int(input()) for _ in range(n)]

    main(n, k, h)


Measured memory_bytes: 11292
#include<stdio.h>
int main()
{
	int h, w, k;
	scanf("%d %d %d", &h, &w, &k);
	int i, j;
	char s[302][302];
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	int ans[302][302];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			ans[i][j] = 0;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (s[i][j] == '#')
			{
				ans[i][j] = k;
				k--;
			}
		}
	}
	for (i = 0; i < h; i++)
		for (j = 0; j < w - 1; j++)
			if (ans[i][j + 1] == 0)
				ans[i][j + 1] = ans[i][j];
	for (i = 0; i < h; i++)
		for (j = w - 1; j > 0; j--)
			if (ans[i][j - 1] == 0)
				ans[i][j - 1] = ans[i][j];
	for (j = 0; j < w; j++)
		for (i = 0; i < h - 1; i++)
			if (ans[i + 1][j] == 0)
				ans[i + 1][j] = ans[i][j];
	for (j = 0; j < w; j++)
		for (i = h - 1; i > 0; i--)
			if (ans[i - 1][j] == 0)
				ans[i - 1][j] = ans[i][j];
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w - 1; j++)
			printf("%d ", ans[i][j]);
		printf("%d\n", ans[i][w - 1]);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len-1); msk++) {
        ll num = S[0] - '0';

        for (int i = 0; i < len-1; i++) {
            if (msk & 1 << i) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        ans+=num;
    }

    cout << ans << "\n";

    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    bool ans=true;;
    string s;
    cin>>s;
    map<char,int> mp;
    REP(i,0,s.size()) mp[s[i]]=1;
    if(mp['N']^mp['S']) ans=false;
    if(mp['E']^mp['W']) ans=false;
    YesNo(ans);
    return 0;
}


Measured memory_bytes: 256
from sys import exit

n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 65516
#include <bits/stdc++.h>
#define INF 1000000000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<18;
	ll dp[1<<19];
	segtree(){
		memset(dp,0,sizeof(dp));
		for(int i=0;i<N*2;i++){
			dp[i]=-INF;
		}
	}
	void update(int k,ll v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=max(dp[k*2+1],dp[k*2+2]);
		}
	}

	ll query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return -INF;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		ll vl=query(a,b,k*2+1,l,mid);
		ll vr=query(a,b,k*2+2,mid,r);
		return max(vl,vr);
	}
};

segtree seg;
int n;
ll c;
ll x[100005];
ll v[100005];

int main(void){
	scanf("%d%lld",&n,&c);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x[i],&v[i]);
	}
	ll ans=0;
	for(int k=0;k<2;k++){
		ll dist=0;
		ll now=c;
		for(int i=n-1;i>=0;i--){
			dist-=now-x[i];
			dist+=v[i];
			seg.update(i,dist);
			now=x[i];
		}
		ans=max(seg.query(0,n),ans);
		now=0;
		dist=0;
		for(int i=0;i<n;i++){
			dist-=x[i]-now;
			dist+=v[i];
			ans=max(ans,dist);
			ans=max(ans,dist-x[i]+seg.query(i+1,n));
			now=x[i];
		}
		dist=0;
		now=0;
		reverse(x,x+n);
		reverse(v,v+n);
		for(int i=0;i<n;i++){
			x[i]=c-x[i];
		}
	}
	

	printf("%lld\n",max(ans,0LL));
	return 0;
}

Measured memory_bytes: 5888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    ArrayList<String> inputList = new ArrayList<>();

    while (input.ready())
    {
      inputList.add(input.readLine());
    }
    final String ans = sover(inputList);
    System.out.println(ans);

  }

  private static String sover(ArrayList<String> inputList)
  {
    ThreeCupSet cupset = new ThreeCupSet();

    for (String each : inputList)
    {
      String[] cups = each.split(",");
      cupset.replace(cups[0], cups[1]);
    }
    return cupset.inBallCup();

  }

  static class ThreeCupSet
  {
    private boolean[] cupSet = new boolean[3];

    public ThreeCupSet()
    {
      Arrays.fill(this.cupSet, false);
      this.cupSet[0] = true;
    }

    private int getIndex(String str)
    {
      switch (str)
      {
      case "A":
        return 0;
      case "B":
        return 1;
      case "C":
        return 2;
      default:
        return -1;
      }
    }

    private String getCupName(int index)
    {
      switch (index)
      {
      case 0:
        return "A";
      case 1:
        return "B";
      case 2:
        return "C";
      default:
        return "";
      }
    }

    public void replace(String cup1, String cup2)
    {
      final boolean tmp1 = this.cupSet[getIndex(cup1)];
      final boolean tmp2 = this.cupSet[getIndex(cup2)];
      this.cupSet[getIndex(cup2)] = tmp1;
      this.cupSet[getIndex(cup1)] = tmp2;
    }

    public String inBallCup()
    {
      for (int i = 0; i < cupSet.length; i++)
      {
        if (cupSet[i])
        {
          return getCupName(i);
        }
      }
      return "";
    }
  }
}

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

using namespace std;

int a, b, c, d;

int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (a > b) swap(a, b);
	if (c > d) swap(c, d);
	printf("%d\n", a + c);
	return 0;
}

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

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

    }
    cout<<max(cnt,mx)<<endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    set<string>s;
    string st;
    for(ll i=0;i<n;i++)
    {
        cin>>st;
        s.insert(st);
    }
    cout<<s.size();
    

    return 0;
}

Measured memory_bytes: 19196
#include <cstdio>
#include <map>
int Q;
long long q[100001], s[100001];
std::map < long long, long long > M;
int main()
{
	scanf("%lld%d", q, &Q);
	for (int i = 1; i <= Q; i++)
		scanf("%lld", q + i);
	M = { { q[Q], 1 } };
	for (int i = Q - 1; ~i; i--)
	{
		auto it = M.upper_bound(q[i]);
		for (auto j = it; j != M.end(); j++)
		{
			M[q[i]] += j -> first / q[i] * j -> second;
			if (j -> first % q[i])
				M[j -> first % q[i]] += j -> second;
		}
		M.erase(it, M.end());
	}
	for (auto &i : M)
		s[i.first] += i.second;
	for (int i = q[0] - 1; i; i--)
		s[i] += s[i + 1];
	for (int i = 1; i <= q[0]; i++)
		printf("%lld\n", s[i]);
	return 0;
}


Measured memory_bytes: 12288
#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;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
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; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_d>
 問題文============================================================
 
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N); for(int i = 0; i < N;i++) cin >> w[i] >> v[i];
    vector<ll> dp(W+1,0);
    for(int i = 0; i < N;i++){
        for(ll j = W; j >= 0;j--){
            if(j+w[i] > W) continue;
            dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    res = dp[W];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,m,a,b,ans,dp[1005][1005];
string s[1005];
//<<-----Implement Functions Here---->>//
ll solve(ll i)
{
	if(visit[i]!=-1)return visit[i];
	for(ll j=0;j<adj[i].size();j++)visit[i] = max(visit[i],solve(adj[i][j]));
	visit[i]++;
	return visit[i];
}
ll add(ll a,ll b){return (a+b)%MOD;}

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>m;mset(dp,0);
		for(ll i=0;i<n;i++)cin>>s[i];
	
		for(ll i=1;i<n;i++){if(s[i][0]!='#')dp[i][0] = 1;else break;} 
		for(ll i=1;i<m;i++){if(s[0][i]!='#')dp[0][i] = 1;else break;} 
		for(ll i=1;i<n;i++)
		{
			for(ll j=1;j<m;j++)
				if(s[i][j]!='#')dp[i][j] = add(dp[i-1][j],dp[i][j-1]);
		}
		cout<<dp[n-1][m-1];
		
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
set<string> S;
string p;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>p;
		if(i && p[0]!=s.back()) return _P("No\n");
		if(S.count(p)) return _P("No\n");
		S.insert(p);
		s=p;
	}
	_P("Yes\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
// ABC 161-C
// 2020.4.4 bal4u

#include <stdio.h>

typedef long long ll;

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define ABS(a) ((a)>=0?(a):-(a))

int main()
{
	ll N, K;

	scanf("%lld%lld", &N, &K);
	if (N >= K) N %= K;
	printf("%lld\n", MIN(N, ABS(N-K)));
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


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

  int A, B, T; cin >> A >> B >> T;
  cout << (T/A)*B <<endl;
  return 0;
}

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

int main() {

  double xa, ya, xb, yb, xc, yc, xd, yd;

  while( cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd ) {

    if ( xa == xb ) {
      if ( yc == yd ) {
	cout << "YES" << endl;
      }else {
	cout << "NO" << endl;
      }
    }else if ( xc == xd ) {
      if ( ya == yb ) {
	cout << "YES" << endl;
      }else {
	cout << "NO" << endl;
      }
    }else {
      if ( abs( ( yb - ya ) / ( xb - xa ) * ( yd - yc ) / ( xd - xc ) + 1 ) < 0.000000001 ) {
	cout << "YES" << endl;
      }else {
	cout << "NO" << endl;
      }
    }
  }

  return 0;

}

Measured memory_bytes: 1220
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    a = [None] * N
    b = [None] * N
    c = [None] * N
    for i in range(N):
        a[i], b[i], c[i] = [Node(int(ele)) for ele in input().split()]

    a[0].dp_val = a[0].val
    b[0].dp_val = b[0].val
    c[0].dp_val = c[0].val

    for i in range(N-1):
        j = i + 1
        a[j].dp_val = max(b[i].dp_val, c[i].dp_val) + a[j].val
        b[j].dp_val = max(a[i].dp_val, c[i].dp_val) + b[j].val
        c[j].dp_val = max(a[i].dp_val, b[i].dp_val) + c[j].val

    print(max(a[-1].dp_val, b[-1].dp_val, c[-1].dp_val))


class Node():

    def __init__(self, val):
        self.val = val
        self.dp_val = -1


if __name__ == "__main__":
    main()


Measured memory_bytes: 70748
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
using namespace std;
int main(void){
	long long n,i,j,ans=-10000000000,t;
	cin>>n;
	long long a[n];
	for(i=0;i<n;i++)cin>>a[i];
t=a[0];
	for(i=1;i<n;i++){
	 t=min(t,a[i-1]);
        ans=max(ans,a[i]-t);	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4632
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define all(c) (c).begin(),(c).end()
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
bool operator < (Point p)const{return (p.y!=y)?y<p.y:x<p.x;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  bool on(Point c){return abs(ccw(a,b,c))!=1;}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}

  //射影
  Point project(Point p){
    Point base=b-a;
    Real t=(p-a).dot(base)/base.dot(base);
    return a+base*t;
  }
};


struct Polygon{
  //頂点。反時計回りに順番で与えられていること。
  vector<Point>v;
  
  Polygon(){}
  Polygon(int n){v.resize(n);}

  vector<Point>convexHull(){
    sort(all(v));
    int k=0;
    vector<Point> qs(v.size()*2);
    
    for(int i=0;i<v.size();i++){
      while(k>1 && (qs[k-1]-qs[k-2]).cross(v[i]-qs[k-1])<0)k--;
      qs[k++]=v[i];
    }
    
    for(int i=v.size()-2,t=k;i>=0;i--){
      while(k>t && (qs[k-1]-qs[k-2]).cross(v[i]-qs[k-1])<0)k--;
      qs[k++]=v[i];
    }
    qs.resize(k-1);
    return qs;
  }
};

int main(void){

  int n;
  cin >> n;
  Polygon p(n);

  for(int i=0;i<n;i++)
    cin >> p.v[i].x >> p.v[i].y;
  
  vector<Point>res=p.convexHull();

  cout << res.size() << endl;
  for(int i=0;i<res.size();i++)
    cout << res[i].x << " " << res[i].y << endl;

  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<int>>g(n);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b; --a,--b;
		g.at(a).emplace_back(b);
		g.at(b).emplace_back(a);
	}
	int ans=0;
	for(auto&&i:g){
		for(auto&&j:i){
			int tmp=-1;
			swap(j,tmp);
			vector<bool>usd(n,false); usd.front()=true;
			queue<int>q; q.push(0);
			while(q.size()){
				int cur=q.front(); q.pop();
				for(auto&&k:g.at(cur)){
					if(k==-1||usd.at(k))continue;
					usd.at(k)=true;
					q.push(k);
				}
			}
			if(count(usd.begin(),usd.end(),false)){
				++ans;
			}
			swap(j,tmp);
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
L = []
for a in A:
    L.append([a-1, a, a+1])
from itertools import product
ans = 0
for t in product(*L):
    k = 1
    for n in t:
        k *= n
    if k%2==0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

vector<int> vt[8];

int dfs(vector<int> flag, int now, int N)
{
    flag[now]=1;
    bool all_visted=true;
    for(int i=0; i<N; i++){
        if(flag[i]==0){
            all_visted=false;
        }
    }
    if(all_visted){
        return 1;
    }

    int ret=0;
    for(int i=0; i<vt[now].size(); i++){
        if(flag[vt[now][i]]==1) continue;
        
        flag[vt[now][i]]=true;
        ret+=dfs(flag, vt[now][i], N);
        flag[vt[now][i]]=false;
    }

    return ret;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> flag(N);
    fill(flag.begin(), flag.end(), 0);

    for(int i=0; i<M; i++){
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        tmpa--;
        tmpb--;
        vt[tmpa].push_back(tmpb);
        vt[tmpb].push_back(tmpa);
    }
    
    cout << dfs(flag, 0, N) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();
		int ans = 0;
		int sum = 0;
		for(int r = 0; r * R <= N; r++) {
			for(int g = 0; r * R + g * G <= N; g++) {
				sum = r * R + g * G;
				if((N - sum) % B == 0) ans++;
			}
		}
		System.out.println(ans);
	}
}


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

long long dp[1009][1009][2], dp2[1009], mod = 1000003;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long solve(int N, int K) {
	K = min(K, N);
	for (int i = 0; i < 1009; i++) { for (int j = 0; j < 1009; j++) { dp[i][j][0] = 0; dp[i][j][1] = 0; } }

	dp[0][0][1] = 1;
	dp[1][1][1] = 1; // 最初が A と仮定しているので、A -> B
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (dp[i][j][0] >= 1) {
				if (j < K) { dp[i + 1][j + 1][0] += dp[i][j][0]; if (dp[i + 1][j + 1][0] >= mod) dp[i + 1][j + 1][0] -= mod; }
				dp[i + 1][1][1] += dp[i][j][0]; if (dp[i + 1][1][1] >= mod) dp[i + 1][1][1] -= mod;
			}
			if (dp[i][j][1] >= 1) {
				if (j < K) { dp[i + 1][j + 1][1] += dp[i][j][1]; if (dp[i + 1][j + 1][1] >= mod) dp[i + 1][j + 1][1] -= mod; }
				dp[i + 1][1][0] += dp[i][j][1]; if (dp[i + 1][1][0] >= mod) dp[i + 1][1][0] -= mod;
			}
		}
	}

	long long ans = 0;
	for (int i = 1; i <= K; i++) {
		// i 回連続の場合
		for (int j = 0; j <= K; j++) ans += dp[N - i][j][1];
		for (int j = 0; j <= K - i; j++) ans += dp[N - i][j][0];
		ans %= mod;
	}
	return (ans * 2) % mod;
}

long long val[1009];

long long calc(int N, int K) {
	if (N < K) K = N;
	for (int i = 0; i < 1009; i++) val[i] = 0;
	vector<int>vec; for (int i = 1; i <= N; i++) { if (N%i == 0) vec.push_back(i); }

	for (int i = 0; i < vec.size(); i++) {
		val[i] = solve(vec[i], K);
		if (vec[i] <= K && K < N) val[i] -= 2;
		for (int j = 0; j < i; j++) { if (vec[i] % vec[j] == 0) val[i] -= val[j]; }
		val[i] += 100000000LL * mod; val[i] %= mod;
	}

	long long sum = 0;
	for (int i = 0; i < vec.size(); i++) {
		sum += Div(val[i], vec[i], mod); sum %= mod;
	}
	return sum;
}

int main() {
	while (true) {
		long long N, K;
		cin >> N >> K; if (N + K == 0) break;
		cout << calc(N, K) << endl;
	}
	return 0;
}


Measured memory_bytes: 19024
import numpy as np

def test():
    H,W = map(int,input().split())
    h,w = map(int,input().split())

    data = np.ones((H,W))
    data[:h,:] = 0
    data[:,:w] = 0
    print(int(data.sum()))


if __name__ == "__main__":
    test()


Measured memory_bytes: 12392
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll fastpow(ll a, int p){
	if(p == 0) return 1;
	ll z = fastpow(a,p/2);
	z = z*z%MOD;
	if(p%2) z = a*z%MOD;
	return z;
}

int main(){
	fastio;

	ll ans = 0;
	int n;
	cin>>n;
	ll x[n];
	forn(i,n) cin>>x[i];

	ll part = 1;
	forn(i,n-1){
		ll temp = (part*(x[i+1]-x[i]))%MOD;
		ans = (ans+temp)%MOD;
		part += fastpow(i+2,MOD-2);
		part %= MOD;
	}
	ll fact = 1;
	forsn(i,1,n) fact = fact*i%MOD;
	ans = (ans*fact)%MOD;
	cout<<ans<<ln;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

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(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<bool> b(n + 2);
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        b[a] = true;
    }
    vector<ll> dp(n + 2);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        if(!b[i + 1]) dp[i + 1] += dp[i];
        dp[i + 1] %= MOD;
        if(!b[i + 2]) dp[i + 2] += dp[i];
        dp[i + 2] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 110;
int V, E;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    int T[MAX_N][MAX_N] = {};
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) T[i][j] = 1<<28;
    }
    for(int i = 0; i < MAX_N; i++) T[i][i] = 0;
    for(int i = 0; i < E; i++)
    {
        int s, t; cin >> s >> t;
        T[s][t] = -1;
    }
    for(int k = 0; k < V; k++)
    {
        for(int i = 0; i < V; i++)
        {
            for(int j = 0; j < V; j++)
            {
                T[i][j] = min(T[i][j], T[i][k] + T[k][j]);
            }
        }
    }
    bool res = false;
    for(int i = 0; i < V; i++)
    {
        if(T[i][i] < 0) res = true;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>
#include <stdlib.h>

int main() {
  char a[4],b[4],c[4];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  char p[3];
  printf("%c",a[0]);
  printf("%c",b[1]);
  printf("%c",c[2]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long X,Y,s,c=0;
	while(cin>>X>>Y){
		if(X==0 && Y==0) break;
		if(X<Y) swap(X,Y);
		while(Y!=0){
			s = X % Y;
			X = s;
			swap(X,Y);
			c++;
		}
	cout<<X<<" "<<c<<endl;
	c=0;
	}
}

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

const ull mod = 1e9+7;
struct mint
{
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod){}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x;}
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
};

int main(){
    const ull mod = 1e9+7;
    int n; cin >> n;
    ull a[n]; rep(i, n) cin >> a[i];

    mint sqsum(0);
    rep(i, n){
        mint tmp(a[i]);
        tmp *= a[i];
        sqsum += tmp;
    }

    mint sum(0);
    rep(i, n){
        mint tmp(a[i]);
        sum += tmp;
    }

    mint ans(1);
    ans *= sum;
    ans *= sum;
    ans -= sqsum;
    ans /= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5124