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

namespace ALDS1_1_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();

            int min = int.MaxValue;
            int max = int.MinValue;

            for (int i = 0 ; i < n ; i++)
            {
                int num = ReadInt();
                max = Math.Max(max, num - min);
                min = Math.Min(min, num);
            }

            Console.WriteLine(max.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 20056
// Date: 2020-06-21

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
	LL n;
	cin >> n;
	string ans;
	while(n) {
		int x = (n-1) % 26 + 1;
		ans += (char)(x + 'a' - 1);
		n -= x;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
	struct data {
		int d[7];
	} dice;
	char command[101];
	int i, j, tmp;

	for(i=1;i<=6;i++)
		scanf("%d", &dice.d[i]);
	scanf("%s", command);

	for(i=0;command[i] != '\0';i++){
		switch(command[i]){
			case 'E' :	tmp = dice.d[3];
						dice.d[3] = dice.d[1];
						dice.d[1] = dice.d[4];
						dice.d[4] = dice.d[6];
						dice.d[6] = tmp;
						break;
			case 'N' :	tmp = dice.d[5];
						dice.d[5] = dice.d[1];
						dice.d[1] = dice.d[2];
						dice.d[2] = dice.d[6];
						dice.d[6] = tmp;
						break;
			case 'S' :	tmp = dice.d[2];
						dice.d[2] = dice.d[1];
						dice.d[1] = dice.d[5];
						dice.d[5] = dice.d[6];
						dice.d[6] = tmp;
						break;
			case 'W' :	tmp = dice.d[4];
						dice.d[4] = dice.d[1];
						dice.d[1] = dice.d[3];
						dice.d[3] = dice.d[6];
						dice.d[6] = tmp;
						break;
		}
//	printf("%d\n", dice.d[1]);
	}

	printf("%d\n", dice.d[1]);

	return 0;
}

Measured memory_bytes: 1188
c = [map(int, raw_input().split()) for i in range(3)]
ok = True
for i in range(2):
    for j in range(2):
        if c[i][j] - c[i+1][j] != c[i][j+1] - c[i+1][j+1]:
            ok = False
        if c[i][j] - c[i][j+1] != c[i+1][j] - c[i+1][j+1]:
            ok = False
print "Yes" if ok else "No"

Measured memory_bytes: 2568
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
dp = [float('inf')] * N
dp[0] = 0
for i in range(N - 1):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[-1])


Measured memory_bytes: 55264
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 500100;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

ll inv( ll x ){
	return power(x, mod-2);
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = inv(fact[b]);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();
	ll n, m; cin >> n >> m;
	ll ans = 0;
	for( ll s = 0; s <= n; ++s ){
		ll diff = comb(n, s) * comb(m, s) % mod * fact[s] % mod * comb(m-s, n-s) % mod * fact[n-s] % mod * comb(m-s, n-s) % mod * fact[n-s] % mod;
		if( s % 2 == 1 ) diff = (mod-diff)%mod;
		ans += diff;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11432
package main

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

var stdin []string

func main() {
    scanner := bufio.NewScanner(os.Stdin)

    var tmp string

    for scanner.Scan() {
        tmp = scanner.Text()

        if tmp == "" {
            break
        } else {
            stdin = append(stdin, scanner.Text())
        }
    }

    nums := strings.Split(stdin[1], " ")
    var nums_like []int

    for j := 0; j < 10; j++ {
        if contains(nums, strconv.Itoa(j)) == false {
            nums_like = append(nums_like, j)
        }
    }

    var N int
    var num string
    arr1 := strings.Split(stdin[0], " ")
    N, _ = strconv.Atoi(arr1[0])
    var cnt int
    var length int

    for i := N; i <= 99999; i++ {
        cnt = 0
        length = len(strconv.Itoa(i))

        for j := 0; j < length; j++ {
            num = string([]rune(strconv.Itoa(i)[j:j+1]))

            if contains(nums, num) == true {
                break
            }

            cnt++

            if cnt == length && i >= N {
                fmt.Println(i)
                return
            }
        }
    }
}

func contains(strs []string, val string) bool {
    for _, v := range strs {
        if val == v {
            return true
        }
    }
    return false
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
void dprintf(const char *format, ...) {
  va_list arg;
  va_start (arg, format);
  vfprintf(stderr, format, arg);
  va_end(arg);
}
#define debug(arg) cerr << #arg << " = " << arg << endl;
#else
#define dprintf(...)
#define debug(x)
#endif
using ll = long long;

const int MOD = 1e9 + 7;

void addSelf(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}

void subSelf(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += MOD;
  }
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> Count(1 + k + 1, 0);
  Count[0] = 1;
  for (int i = 1; i <= n; i++) {
    vector<int> NewCount(1 + k + 1, 0);
    int ai;
    scanf("%d", &ai);
    for (int j = 0; j <= k; j++) {
      addSelf(NewCount[j], Count[j]);
      subSelf(NewCount[min(k + 1, j + ai + 1)], Count[j]);
    }
    for (int j = 1; j <= k; j++) {
      addSelf(NewCount[j], NewCount[j - 1]);
    }
    Count = NewCount;
    /*
    for (int j = 0; j <= k; j++) {
      printf("%10d", Count[j]);
    }
    printf("\n");//*/
  }
  int answer = Count[k];
  printf("%d\n", answer);
  return 0;
}


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

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

  vector<vector<int>> data(N, vector<int>(2));
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      cin >> data[i][j];
    }
  }

  int count = 0;

  for(int i=0;i<N;i++){
    if(data.at(i).at(0) == data.at(i).at(1)){
      count = count+1;
      if(count == 3){
        break;
      }
    }else{
      count = 0;
    }
  }

  if(count == 3){
    cout << "Yes";
  }else{
    cout << "No";
  }

}


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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] p = new int[n];
		Arrays.setAll(p, i -> sc.nextInt());
		
		Arrays.sort(p);
		
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += p[i];
		}
		
		System.out.println(sum);
		
		sc.close();
	}
}




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

int main() {
  string ans="Yes";
  int n,current_t=0,current_x=0,current_y=0;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0;i<n;i++) cin >> t[i] >> x[i] >> y[i];
  for(int i=0;i<n;i++) {
    int tt=(t[i]-current_t);
    int xx=max((current_x-x[i]),(x[i]-current_x));
    int yy=max((current_y-y[i]),(y[i]-current_y));
    if((tt-xx-yy)%2==0&&tt>=xx+yy){
      current_t=t[i];
      current_x=x[i];
      current_y=y[i];
    } else {
      ans="No";
      break;
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 1408
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let n: i32 = buf.trim().parse().ok().unwrap();
    //println!{"{}", n};

    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let v: Vec<i32> = buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect();

    let mut v1: Vec<i32> = Vec::new();
    let mut v2: Vec<i32> = Vec::new();
    for i in 0..v.len() {
        if i % 2 == 0 {v1.push(v[i]);}
        else {v2.push(v[i]);}
    }
    /*
    for i in 0..v.len() {
        println!{"{}", v[i]};
    }
    println!{"------------"};
    for i in 0..v1.len() {
        println!{"{}", v1[i]};
    }
    println!{"------------"};

    for i in 0..v2.len() {
        println!{"{}", v2[i]};
    }
    println!{"------------"};

    */
    let mut cnt1: Vec<(i32, i32)> = Vec::new();
    let mut cnt2: Vec<(i32, i32)> = Vec::new();
    for i in 0..100000+1 {
        cnt1.push((0, i));
        cnt2.push((0, i));
    }
    //println!{"{}", cnt1[100].0};
    //println!{"{}", cnt[100]};
    for i in  0..v1.len() {
        let idx1:usize = v1[i] as usize;
        let idx2:usize = v2[i] as usize;
        cnt1[idx1].0 += 1;
        cnt2[idx2].0 += 1;
    }
    //println!{"{}", cnt1[3].0};
    cnt1.sort();
    //cnt1.sort_by_key(|&(a,b)| a);
    cnt1.reverse();
    //println!{"{} {}", cnt1[0].0, cnt1[0].1};
    //cnt2.sort_by_key(|&(a,b)| a);
    cnt2.sort();
    cnt2.reverse();
    //println!{"{} {}", cnt2[0].0, cnt2[0].1};
    let ans;
    if cnt1[0].1 != cnt2[0].1 {
        ans = n - cnt1[0].0 - cnt2[0].0;
    }
    else {
        ans = std::cmp::min(n - cnt1[0].0 - cnt2[1].0, n - cnt1[1].0 - cnt2[0].0);
    }
    println!{"{}", ans};
}


Measured memory_bytes: 10492
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

map<char, int> cnt;
bool ok = true;

int main(void) {
  string s;
  cin >> s;
  REP(i, (int)s.size())
    cnt[s[i]]++;

  if (cnt['S'] + cnt['N'] > 0 && (cnt['S'] == 0 || cnt['N'] == 0))
    ok = false;
  if (cnt['W'] + cnt['E'] > 0 && (cnt['W'] == 0 || cnt['E'] == 0))
    ok = false;

  printf(ok ? "Yes\n" : "No\n");
  
  return 0;
}


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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        k: usize,
        s: chars
    }
    if s.len() <= k {
        println!("{}", s.iter().collect::<String>());
    } else {
        println!("{}...", s.iter().take(k).collect::<String>());
    }
}


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

int main()
{
    string s;
    cin>>s;
    int l=s.length();
    char a=s[l-1];
    if(a=='2' || a=='4' || a=='5' || a=='7' || a=='9')cout<<"hon";
    else if( a=='0' || a=='1' || a=='6' || a=='8')cout<<"pon";
    else cout<<"bon";

    return 0;
}



Measured memory_bytes: 3596
#include <iostream>

int main(void)
{
  int n = 0;
  std::cin >> n;
  
  long long int fact = 1;
  
  for (int i = 1; i <= n; i++) {
    fact *= i;
  }
  
  std::cout << fact << std::endl;
  
  return 0;
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+2;
typedef long long ll;
int a[maxn];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
	}
	ll ans = 0;
	int tot = 0;
	int l=0,r=0;
	
	while(1)
	{

		while(r<n && !(tot&a[r]))
		{
			tot+=a[r++];
			
		}
		//if(r>=n) break;
		ans+=r-l;
		//cout<<l<<" "<<r<<"\n";
		tot^=a[l++];
		if(l>=n) break;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
import numpy as np
H, W = map(int, input().split())

lst = []
for i in range(H):
    lst += [list(input())]

arr = np.array(lst)

lstH = []
for i in range(H):
    if all(arr[i,:] == '.'):
        lstH += [i]

arr = np.delete(arr, lstH, 0)

lstW = []
for j in range(W):
    if all(arr[:,j] == '.'):
        lstW += [j]

arr = np.delete(arr, lstW, 1)

for k in arr:
    for l in k:
        print (l, end = '')
    print ()


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  auto isEvenStr = [&]() {
    int len = s.size();
    if (len & 1) return false;
    bool ok = true;
    rep(i, len/2) {
      if (s[i] != s[i+len/2]) ok = false;
    }
    return ok;
  };
  do
    s.pop_back();
  while (!isEvenStr());
  std::cout << s.size() << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n, d;
	cin >> n >> d;
	cout << (ll)ceil((double)n / (2 * d+1)) << endl;
	return 0;
}


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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var buff = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = buff[0];
            int K = buff[1];

            var sunuke = new int[K][];
            var confection = new int[K];
            var list = new List<int>();
            for(int i = 0; i < K; i++)
            {
                confection[i] = int.Parse(Console.ReadLine());
                sunuke[i] = new int[confection[i]];
                sunuke[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }
            for (int i = 0; i < K; i++)
            {
                for (int j = 0; j < confection[i]; j++)
                {
                    if(!list.Contains(sunuke[i][j]))
                    {
                        list.Add(sunuke[i][j]);
                    }
                }
            }
            Console.WriteLine(N - list.Count);
        }
    }
}


Measured memory_bytes: 28568
n,k=map(int,input().split())
i=list(map(int,input().split()))
l=[0]*(n-k)
for j in range(n-k):
  l[j]=i[j+k]-i[j]
place=0
plus=0
for j in range(n-k):
  plus=plus+l[j]
  if plus>0:
    place=j+1
    plus=0
a=0.0
for j in range(k):
  a+=float(i[j+place]+1)/2
print(a)

Measured memory_bytes: 25604
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

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

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

// 0: not msnum, 1: is msnum and is msprime, 2: is msnum but is not msprime
int num_status[300000+1];

void seive(){
  for(int i = 0; i <= 300000; i++) num_status[i] = 0; 
  for(int i = 1; i <= 300000; i += 7) num_status[i] = 1; 
  for(int i = 6; i <= 300000; i += 7) num_status[i] = 1;
  num_status[1] = num_status[6] = 1;
  for(int i = 6; i * i <= 300000; i++){
    if(num_status[i] == 0 || num_status[i] == 2) continue;
    for(int j = i + i; j <= 300000; j += i) num_status[j] = 2;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  seive();
  int num;
  while(cin >> num, num != 1){
    set<int> msprfac;
    for(int i = 6; i <= num; i++){
      if(num_status[i] == 1 && num % i == 0){
        msprfac.insert(i);
      }
    }
    cout << num << ": ";
    int i = 0;
    for(auto n : msprfac){
      if(i++) cout << " ";
      cout << n;
    }
    cout << endl;

  }
  return 0;
}

Measured memory_bytes: 2376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
ll a, b, n;
int main(){
	scanf("%lld%lld%lld", &a, &b, &n);
	printf("%lld\n", a * min(b-1, n) / b);
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 998244353;
const int MAX_N = 100005;
ll D[MAX_N];
ll D2[MAX_N]; //D2[i] 距離iの頂点の数

ll modpow(ll a, ll n)
{
	ll ans = 1;
	rep(i,n)
	{
		ans = (ans * a) % MOD;
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> D[i];
	}

	if (D[0] != 0)
	{
		cout << "0" << endl;
		return 0;
	}

	sort(D,D+N);
	rep(i,N)
	{
		D2[D[i]]++;
	}

	if (D2[0] != 1)
	{
		cout << "0" << endl;
		return 0;
	}

	ll ans = 1;
	for (int i = 1; i < N; ++i)
	{
		if (D2[i] != 0)
		{
			ans = ( ans * (modpow(D2[i-1], D2[i]) % MOD) ) % MOD;
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
from collections import deque
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
Q = deque()
INF = H+W+1
C = [[-1]*W for i in range(H)]
for y in range(H):
  for x in range(W):
    if A[y][x] == "#":
      Q.append((y,x))
      C[y][x] = 0
X = [1,0,-1,0]
Y = [0,-1,0,1]
      
while Q:
  y,x = Q.popleft()
  for i in range(4):
    ny = y + Y[i]
    nx = x + X[i]
    if 0<=ny<H and 0<=nx<W and C[ny][nx]==-1 and A[ny][nx] == ".":
      C[ny][nx] = C[y][x] + 1
      Q.append((ny,nx))
ans = 0
for i in range(H):
  ans = max(ans,max(C[i]))
print(ans)

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

const ll p = 998244353;

ll powmod(ll a, ll b){
    if(b==0) return 1;
    if(b%2==1) return (a*powmod(a,b-1)) % p;
    else{
        ll x = powmod(a,b/2);
        return (x*x) % p;
    }
}

ll combinemod(ll a, ll b){
    ll x=1,y=1;
    for(int i=1;i<=b;i++){
        y = (y*i)%p;
    }
    for(int i=a-b+1;i<=a;i++){
        x = (x*i)%p;
    }

    return (x * powmod(y,p-2)) % p;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    
    vector<ll> dp1(k+1), dp2(k+1);
    dp1.at(0) = m * powmod(m-1,n-1) % p;
    dp2.at(0) = 1;
    rep(i,k){
        dp1.at(i+1) = m*powmod(m-1,n-1-(i+1)) % p;
        dp2.at(i+1) = (dp2.at(i) * (n-i-1) % p * powmod(i+1,p-2)) % p;
    }

    ll tot = 0;
    rep(i,k+1){
        tot += dp1.at(i) * dp2.at(i) % p;
        tot %= p;
    }

    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
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;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
struct edge{int to,cap,rev;};
vector<edge>G[210];
bool used[210];
void add_edge(int from,int to,int cap){
    G[from].pb({to,cap,G[to].size()});
    G[to].pb({from,0,G[from].size()-1});
}
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(edge &e:G[v]){
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        fill(used,used+210,false);
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}
int h,w;
char c[110][110];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>c[i][j];
            if(c[i][j]=='S'){
                add_edge(0,i,INF);
                add_edge(i,0,INF);
                add_edge(0,h+j,INF);
                add_edge(h+j,0,INF);
            }
            if(c[i][j]=='T'){
                add_edge(h+w+1,i,INF);
                add_edge(i,h+w+1,INF);
                add_edge(h+w+1,h+j,INF);
                add_edge(h+j,h+w+1,INF);
            }
            if(c[i][j]=='o'){
                add_edge(i,h+j,1);
                add_edge(h+j,i,1);
            }
        }
    }
    int ans=max_flow(0,h+w+1);
    if(ans>=INF)puts("-1");
    else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>

int main()
{
	int H, W;
	while (1) {
		std::cin >> H >> W;
		if (H <= 0 && W <= 0) {
			break;
		}

		for (int i = 0;i < H;i++) {
			for (int j = 0;j < W;j++) {
				if (i <= 0 || H - 1 <= i || j <= 0 || W - 1 <= j) {
					std::cout << "#";
				}
				else {
					std::cout << ".";
				}

			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  string S;
  ll K;
  cin >> K;
  cin >> S;

  if (S.size() <= K){
    cout << S << endl;
  }else{
    cout << (S.substr(0,K) + "...") << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
Int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
bool linearCongruences(const vector<Int> &a,
                       const vector<Int> &b,
                       const vector<Int> &m,
                       Int &x, Int &M) {
  int n = a.size();
	Int z,y,g,b0,m0;
	x=0;M=1;
	for(int i=0;i<n;i++){
		//if(!a[i])continue;
		b0=b[i]-a[i]*x;
		if(b0%(g=extgcd(a[i]*M,m[i],z,y))!=0)return 0;
		m0=m[i]/g;
		x+=M*(z*(b0/g%m0)%m0);
		M*=m0;
		x=(x%M+M)%M;
		if(M>1000000000){
			for(int j=0;j<n;j++){
				if(x*a[j]%m[j]!=b[j]%m[j])return 0;
			}
			return 1;
		}
	}
	return 1;
}
long long s[110];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	vector<Int>d(b);
	vector<Int>I(b);
	for(int i=0;i<b;i++)I[i]=1;
	for(int i=0;i<b;i++)scanf("%lld",s+i);
	bool dame=false;
	for(int i=0;i<c;i++){
		vector<Int>t(b);
		for(int j=0;j<b;j++){
			scanf("%lld",&t[j]);
			if(t[j]==-1){
				t[j]=0;
				I[j]=0;
				d[j]=1;
			}else{
				I[j]=1;
				d[j]=s[j];
			}
		}
		Int x,mod;
		bool res=linearCongruences(I,t,d,x,mod);
	//	printf("%lld %lld\n",x,mod);
		if(!res){dame=true;break;}
		if(mod>a){
			if(x>a){
				dame=true;break;
			}
			a=x;
		}else{
			x+=((a-x)/mod)*mod;
			a=x;
		}
	}
	if(dame){
		printf("-1\n");
	}else printf("%d\n",a);
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	ll n=read(),ans=0;
	for (ll l=1,r=1;l<=n;l=++r){
		r=n/(n/l);
		ll k=n/l;
		if (n%k==0){
			ll x=n/k-1;
			if (x==0) continue;
			if (n%x==n/x) ans+=x;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3760
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//std::ios::sync_with_stdio(false);

main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	string s;
	int i,c=0; 
	cin>>s;
	rep(i,s.length()){
		if(s[i]=='o'){
			c++;
		}
	}
	c+=15-s.length();
	if(c>=8){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
} 
	

Measured memory_bytes: 256
package main

import (
  "fmt"
  "strings"
)

func main() {

  var s string

  fmt.Scan(&s)

  days := len(s)
  wins := strings.Count(s, "o")
  
  if (wins + (15 - days)) >= 8 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }

}

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

using namespace std;

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

    int N, M;
    cin >> N >> M;

    bool to[200000] = {};
    bool from[200000] = {};
    int f, t;

    for (int i=0; i<M; i++) {
      cin >> f >> t;

      if (f == 1) {
        to[t] = true;
      }
      if (t == N) {
        from[f] = true;
      }
    }

    if (from[1]) {
      cout << "POSSIBLE" << endl;
      return 0;
    }

    for (int i=0; i<N; i++) {
      if (to[i] and from[i]) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 640
K = int(input())
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(n[K-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <string>
using namespace std;
int N,M;
typedef long long ll;
typedef pair<int,int> p;
#define NMAX 1000
vector<p> data;
ll dp[NMAX][NMAX];

ll nap(int jn,int day){
    ll na;
    cout << jn << " " << day <<" "<< dp[jn][day]<< endl;
    if(jn >= N) return 0;
    if(dp[jn][day]>=0) return dp[jn][day];
    if(day <= 1 ){
         na = 0;
    }else if(data[jn].first > day ){
        na = nap(jn+1,day);
    }else{
        na = max(nap(jn+1,day),nap(jn+1,day-1)+data[jn].second);
    }
    return dp[jn][day]=na;
}
bool cmb(p a,p b){
     return a.second >= b.second && a.first >= b.first;
}

int main(){
    cin >> N >> M;
    vector<vector<int>> jobs(M);
    for(int i=0;i<N;i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 > M) continue;
        jobs[M-tmp1].push_back(tmp2);
    }
    ll ans=0;
    priority_queue<int> q;
    for(int i=M-1;i>=0;i--){
        for(int b:jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    // int day = M;

    // // for(int i=0;i<N;i++){
    // //     cout << data[i].first << " " << data[i].second << endl;
    // // }
    // for(int i=0;i<N;i++){
    //     if(day < 1) continue;
    //     else if(data[i].second > day) continue;
    //     else{
    //         ans += data[i].first;
    //         day -= 1;
    //     }
    // }
    cout << ans << endl;
}

Measured memory_bytes: 5632
M=10**9+7;N,K=map(int,input().split())
def c(n,k,m=1,d=1):
 for i in range(k):m*=n-i;d*=i+1
 return m%M*pow(d%M,M-2,M)%M
for i in range(K):print(c(K-1,i)*(N-K>i-1and c(N-K+1,i+1))%M)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
 
//const ll mod =  1000000007;
//const ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main() {
    int ans=0;
    vi a(10,0);
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
            a.at(i)=1;
        }
    }
    rep2(i,1,10){
        if(a.at(i)==1)a.at(i)+=a.at(i-1);
    }
    rep(i,10){
        ans=max(ans,a.at(i));
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int H, W; cin >> H >> W;
  vector<vector<char>> C(H, vector<char>(W));
  for (auto& row : C) {
    for (auto& cell : row) {
      cin >> cell;
    }
  }
  for (const auto& row : C) {
    for (const auto& c : row) {
      cout << c;
    }
    cout << CRLF;
    for (const auto& c : row) {
      cout << c;
    }
    cout << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

int main(void) {
  ll x, y;
  cin >> x >> y;
  int ans = 0;
  while(y >= x) {
    ans++;
    x *= 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
int main() {
	char a[102],b[102];
	scanf("%s",a);
	scanf("%s",b);
	
	if(!strcmp(a,b))
        printf("EQUAL\n");
	else if(strlen(a)==strlen(b)){
	    for(int x=0;x<strlen(a);++x){
	        if(a[x]>b[x]){
	            printf("GREATER\n");
	            break;
	        }	            
            else if(a[x]<b[x]){
                printf("LESS\n");
                break;
            }
	    }
	}
	
	else if(strlen(a)>strlen(b))
	    printf("GREATER\n");
	else
	    printf("LESS\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int D = in.nextInt();
		int[][] table = new int[H*W+1][2];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				int num = in.nextInt();
				table[num][0] = i;
				table[num][1] = j;
			}
		}
		int[] cost = new int[H*W+1];
		for(int i=D+1;i<=2*D;i++) {
			int j = i;
			while(j<=H*W) {
				cost[j] = cost[j-D] + Math.abs(table[j][0]-table[j-D][0]) + Math.abs(table[j][1]-table[j-D][1]);
				j += D;
			}
		}
		int Q = in.nextInt();
		int[] l = new int[Q];
		int[] r = new int[Q];
		for(int i=0;i<Q;i++) {
			l[i] = in.nextInt();
			r[i] = in.nextInt();
		}
		in.close();
		for(int i=0;i<Q;i++) {
			System.out.println(cost[r[i]]-cost[l[i]]);
		}
	}

}


Measured memory_bytes: 101436
# -*- coding: utf-8 -*-

MAX_V = 10**5
INF = 10**10
N, W = list(map(int, input().split()))
# dp[i][v]はi番目までの品物を使った際に合計価値がvを超える最小のコストw
dp = [[INF for _ in range(MAX_V+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    w, v = list(map(int, input().split()))
    for over_v in range(MAX_V+1):
        if over_v - v < 0:
            dp[i][over_v] = dp[i-1][over_v]
            continue
        dp[i][over_v] = min(dp[i-1][over_v-v] + w, dp[i-1][over_v])

ans = 0
for v in range(MAX_V+1):
    if dp[N][v] <= W:
        ans = v
print(ans)


Measured memory_bytes: 173040
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H,W;
    cin >> H >> W;
    vector<vector<char>> now(H,vector<char>(W)),red(H,vector<char>(W,'.')),blue(H,vector<char>(W,'.'));
    rep(i,H)
    rep(j,W)cin >> now[i][j];
    rep(i,H){
        rep(j,W - 2){
            if(i % 2 == 0){
                red[i][j + 1] = '#';
            }
            else{
                blue[i][j + 1] = '#';
            }
        }
    }
    rep(i,H){
        red[i][0] = '#';
        blue[i][W - 1] = '#';
    }
    rep(i,H){
        rep(j,W){
            if(now[i][j] == '#'){
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }
    rep(i,H){
        rep(j,W){
            cout << red[i][j];
        }
        cout << "\n";
    }
    cout << "\n";
    rep(i,H){
        rep(j,W){
            cout << blue[i][j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 4332
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int n,m,i,j;
    scanf("%d %d",&n,&m);
    int A[n][m],b[m],c[100] = {0};
    
    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < m ; j++ ){
            scanf("%d",&A[i][j]);
        }
    }
    for( i = 0 ; i < m ; i++ ){
        scanf("%d",&b[i]);
    }
    
    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < m ; j++ ){
            c[i] += A[i][j] * b[j];
        }
    }
    
    for( i = 0 ; i < n ; i++ ){
        printf("%d\n",c[i]);
    }
    
    return 0;
}

Measured memory_bytes: 636
from heapq import heappush, heappop

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

def solve() :
    h = []
    for i in range(N) :
        if A[i] == B[i] :
            continue
        heappush(h, (-B[i], i))

    ret = 0
    while h :
        _, i = heappop(h)
       
        m, M = B[(i-1)%N], B[(i+1)%N]
        if m > M :
            m, M = M, m
        
        if M >= A[i] :
            x = (B[i] + m - 1) // (m + M)
            B[i] -= x * (m + M)
            ret += x
        else :
            if (B[i] - A[i]) % (m + M) != 0 :
                return -1
            ret += (B[i] - A[i]) // (m + M)
            B[i] = A[i]
        
        if A[i] > B[i] :
            return -1
            
        elif A[i] < B[i] :
            heappush(h, (-B[i], i))
    
    return ret
    
print(solve())

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

int main(){
    using namespace std;
    long N;
    cin >> N;
    array<long, 5> v{};
    for(auto& i : v)cin >> i;
    
    cout << 5 + (N - 1) / *min_element(v.begin(), v.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			if (map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i])+1);
			} else {
				map.put(a[i], 1);
			}
		}
		long ans = 0;
		for (Map.Entry<Integer, Integer> e : map.entrySet()) {
			if (e.getKey() > e.getValue()) {
				ans += e.getValue();
			} else {
			ans += Math.abs(e.getValue()-e.getKey());
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65952
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;
    int ans=0;
    rep(i,100){
        int k=i*i;
        rep(j,10) {
            if (k<=x) ans=max(ans,k);
            k*=i;
        }
    }
    cout << ans << endl;


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for (int i = 0; i < 4; i++) {
		if (i == 0) {
			int difx = tx - sx;
			int dify = ty - sy;
			
			for (int j = 0; j < difx; j++) {
				cout << 'R';
			}
			 
			
			for (int j = 0; j < dify; j++) {
				cout << 'U';
			}
			
		} else if (i == 1) {
			int difx = tx - sx;
			int dify = ty - sy;
		
			for (int j = 0; j < difx; j++) {
				cout << 'L';
			}
			
			
			for (int j = 0; j < dify; j++) {
				cout << 'D';
			}
			
		} else if (i == 2) {
			int difx = tx - sx + 1;
			int dify = ty - sy + 1;
			cout << 'L';
			for (int j = 0; j < dify; j++) {
				cout << 'U';
			}
			for (int j = 0; j < difx; j++) {
				cout << 'R';
			}
			cout << 'D';
		} else {
			int difx = tx - sx + 1;
			int dify = ty - sy + 1;
			cout << 'R';
			for (int j = 0; j < dify; j++) {
				cout << 'D';
			}
			for (int j = 0; j < difx; j++) {
				cout << 'L';
			}
			cout << 'U';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256