akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused_imports)]

// Input
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)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        op: String,
        B: i64,
    }
    let ans:i64;
    if op=="+"{
        ans = A+B;
    }else{
        ans = A-B;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;

    int min;
    if(a <= b){
        min = a;
    }else{
        min = b;
    }

    std::vector<int> buf{0};
    for(int i = 1; i <= min; ++i){
        if(0 == a%i){
            if(0 == b%i){
                buf.push_back(i);
            }
        }
    }

    std::cout << buf.at(buf.size() - c) << std::endl;

    return 0;
}


Measured memory_bytes: 888
class Test
  @@h = Hash.new{|index,key| index[key] = []}
  def dataIntoHash(data)
    n,m = data.split
   	m2 = m.to_i
    @@h[n] << m2
  end
  
  def hashSort
      @@h.each{|key, value| value.sort!}
      @@h = @@h.sort
  end
  
  def dataOut
    @@h.each{|key, value| 
    puts key + "\n"
    puts value.join(" ")
    }
  end
end


tes = Test.new
while data = gets
  tes.dataIntoHash(data)
end
tes.hashSort
tes.dataOut

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

public class Main {

    public static void main(String[] args) throws IOException {

        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int num = 0;
        for (int i = 1; i <= n; i++) {
            num = (10 * num + 7) % n;
            if (num == 0) {
                System.out.println(i);
                return;
            }
        }
        System.out.println("-1");
        bw.flush();
    }
//==============================================//
//==============================================//

    static void sort(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a) {
            l.add(i);
        }
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) {
            a[i] = l.get(i);

        }
    }

    static class FastScanner {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 32916
A,B,C,X,Y = map(int, input().split())
if A+B < 2*C:
  ans = A*X+B*Y
else:
  XY = min(X,Y)
  ans = min(A*(X-XY) + B*(Y-XY) + 2*C*XY, 2*C*max(X,Y))
print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> ap;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        ap.emplace_back(a, i);
    }

    sort(begin(ap), end(ap));
    for (auto& e : ap) cout << e.second << " ";
}


Measured memory_bytes: 1780
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: u64 = read();
    let n: usize = read();
    let a: u64 = (0..n).map(|_| read()).fold(0, |a, b: u64| a + b);
    if a < h {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
N = int(input())
H = list(map(int, input().split()))

ans = 0
f_ans = 0

for i in range(N-1):
    if(H[i+1] <= H[i]):
        # print('True')
        ans += 1
    else:
        # print('False')
        if(ans >= f_ans):
            f_ans = ans
        ans = 0
    # print(i, H[i], ans)
if(ans >= f_ans):
    f_ans = ans
    ans = 0
print(f_ans)
    

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
vector<int> g[111111];

ll dfs(int v){
	if(g[v].size()==0)return 0;
	if(g[v].size()==1)return dfs(g[v][0])+1;
	vector<ll> res;
	rep(i,g[v].size()){
		res.pb(dfs(g[v][i]));
	}
	sort(all(res));
	ll ans=0;
	rep(i,res.size()){
		maxch(ans,(ll)(res[i]+res.size()-i));
	}
	return ans;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n-1){
		int a;
		cin>>a;
		a--;
		g[a].pb(i+1);
	}
	cout<<dfs(0)<<endl;
	return 0;
}


Measured memory_bytes: 15360
import java.util.*;

// ARC 78-C
// http://arc078.contest.atcoder.jp/tasks/arc078_a

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		long[] sum = new long[N + 1];
		
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			sum[i + 1] = sum[i] +  n;
		}
		
		long answer = Long.MAX_VALUE;
		for (int i = 1; i < N; i++) {
			long remain = sum[N] - sum[i];
			answer = Math.min(answer, Math.abs(remain - sum[i]));
		}
		System.out.println(answer);
	}
	
}


Measured memory_bytes: 66948
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
P=[]
Z=[]
N=[]
for i in range(n):
  if a[i]>0:
    P.append(a[i])
  elif a[i]==0:
    Z.append(a[i])
  else:
    N.append(-a[i])
P.sort()
P3=[1]
for i in range(len(P)):
  P3.append(P3[-1]*P[i]%mod)
P.reverse()
P2=[1]
for i in range(len(P)):
  P2.append(P2[-1]*P[i]%mod)
N.sort()
N3=[1]
for i in range(len(N)):
  N3.append(N3[-1]*N[i]%mod)
N.reverse()
N2=[1]
for i in range(len(N)):
  N2.append(N2[-1]*N[i]%mod)

if n==k:
  ans=1
  for i in range(n):
    ans*=a[i]
    ans%=mod
  print(ans%mod)
  exit()

if k==1:
  print(max(a)%mod)
  exit()

if len(P)+len(N)<k:
  print(0)
  exit()

if len(N)==0:
  print(P2[k]%mod)
  exit()

if len(P)+len(N)==k:
  if len(N)%2==0:
    print(P2[-1]*N2[-1]%mod)
    exit()
  else:
    if len(Z)!=0:
      print(0)
    else:
      print(-P2[-1]*N2[-1]%mod)
    exit()

if k%2==0:
  ans=1
  xp=0
  xn=0
  for i in range(k//2):
    if xp+1<len(P):
      xa=P[xp]*P[xp+1]
    else:
      xa=1
    if xn+1<len(N):
      xb=N[xn]*N[xn+1]
    else:
      xb=1
    if xa<=xb:
      xn+=2
      ans*=xb
      ans%=mod
    else:
      xp+=2
      ans*=xa
      ans%=mod
  print(ans%mod)

else:
  ans=1
  xp=0
  xn=0
  ctP=0
  ctN=0
  for i in range(k//2):
    if xp+1<len(P):
      xa=P[xp]*P[xp+1]
    else:
      xa=1
    if xn+1<len(N):
      xb=N[xn]*N[xn+1]
    else:
      xb=1
    if xa<=xb:
      xn+=2
      ans*=xb
      ans%=mod
      ctN+=1
    else:
      xp+=2
      ans*=xa
      ans%=mod
      ctP+=1
  if ctP*2+1<=len(P):
    ans*=P[ctP*2]
    ans%=mod
    print(ans%mod)
  else:
    N.reverse()
    P.reverse()
    ans=1
    xp=0
    xn=0
    ctP=0
    ctN=0
    for i in range(k//2):
      if xp+1<len(P):
        xa=P[xp]*P[xp+1]
      else:
        xa=0
      if xn+1<len(N):
        xb=N[xn]*N[xn+1]
      else:
        xb=0
      if xa<=xb:
        xn+=2
        ans*=xb
        ans%=mod
        ctN+=1
      else:
        xp+=2
        ans*=xa
        ans%=mod
        ctP+=1
    ans*=N[ctN*2]
    ans%=mod
    if len(Z)!=0:
      print(0)
    else:
      print(-ans%mod)

Measured memory_bytes: 132280
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll ans=-1001001001001001001;
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
}

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

int main(){
int n;
cin >> n;
vector<int> v(n);
for(int i=0; i < n; i++){
cin >> v[i];
}
sort(v.begin(),v.end(), greater<int>());
int ans = 0;
v[0] /= 2;
for(int i = 0; i < n; i++){
ans += v[i];
}
cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq
vertices, edges = (int(n) for n in input().split(" "))
conn = defaultdict(set)
weight = defaultdict(dict)
for i in range(edges):
    v1, v2, w = (int(n) for n in input().split(" "))
    conn[v1] |= {v2}
    conn[v2] |= {v1}
    weight[v1][v2] = w
    weight[v2][v1] = w

queue = []
heapq.heapify(queue)
heapq.heappush(queue, [0,0])
went = set()
went_vertices = 0
answer_weight = 0
while went_vertices < vertices:
    here_weight, here_v = heapq.heappop(queue)
    if here_v in went:
        continue
    went |= {here_v}
    for c in conn[here_v]:
        if c not in went:
            heapq.heappush(queue,[weight[here_v][c], c])
    answer_weight += here_weight
    went_vertices += 1
print(answer_weight)

Measured memory_bytes: 47584
#! /usr/bin/ruby -w
# encoding: utf-8
#

def count_path(node, queue, checked, goal, count)
  next_step = []
  queue.each do |current|
    if current == goal
      return count
    else
      node[current].each do |n|
        if checked[n].nil?
          checked[n] = true
          next_step << n
        end
      end
    end
  end
  if next_step.empty?
    return -1
  else
    return count_path(node, next_step, checked, goal, count + 1)
  end
end

if __FILE__ == $0
  n = gets.to_i
  node = {}
  n.times {
    info = gets.split.map(&:to_i)
    node_num, adj = info[0], info[2..-1]
    node[node_num] = adj
  }

  n.times do |t|
    node_num = t + 1
    puts "#{node_num} #{count_path(node, [1], {}, node_num, 0)}"
  end
end


Measured memory_bytes: 7236
#include<iostream>

int main(){
    int a,b,plus,minus,product,max;
    std::cin>>a>>b;
    minus=a-b;
    plus=a+b;
    product=a*b;
    max=minus;
    if(max<product){
        max=product;
    }
    if(max<plus){
        max=plus;
    }
    std::cout<<max<<"\n";
    return(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

vector<char> Op; vector<int> In1, In2, Out;
int last_id = 3;

class V
{
public:
	explicit V(int id = -1) : id_(id) {}

	inline V operator+(const V& b) const {
		Op.push_back('+');
		In1.push_back(id_);
		In2.push_back(b.id_);
		Out.push_back(last_id);
		return V(last_id++);
	}
	inline V operator<(const V& b) const {
		Op.push_back('<');
		In1.push_back(id_);
		In2.push_back(b.id_);
		Out.push_back(last_id);
		return V(last_id++);
	}
	inline V operator>(const V& b) const {
		return b < *this;
	}
	int id_;
};

V pows[60], bpow[30];
V a(0), b(1), zero(2);

V mulpow2(V x, int n) {
	V ret = x;
	for (int i = 0; i < n; ++i) ret = ret + ret;
	return ret;
}

V cond(V x, V y, int rep) {
	// x ? y : 0
	// y < 2 ** rep
	V negx = x < pows[0];
	V ret = zero;
	for (int i = rep - 1; i >= 0; --i) {
		V c = y > (ret + pows[i]);
		c = c > negx;
		ret = ret + mulpow2(c, i);
	}
	return ret + ((y > zero) > negx);
}

typedef unsigned long long ui64;

ui64 emulate(ui64 x, ui64 y) {
	const int maxn = 200000;
	const ui64 maxv = 10000000000000000000ULL;
	vector<ui64> buffer(maxn, 0LL);
	buffer[0] = x;
	buffer[1] = y;
	for (int i = 0; i < Op.size(); ++i) {
		if (!(0 <= In1[i] && In1[i] < maxn)) abort();
		if (!(0 <= In2[i] && In2[i] < maxn)) abort();
		if (!(0 <= Out[i] && Out[i] < maxn)) abort();

		if (Op[i] == '+') {
			buffer[Out[i]] = buffer[In1[i]] + buffer[In2[i]];
			if (buffer[Out[i]] > maxv) abort();
		} else {
			buffer[Out[i]] = (buffer[In1[i]] < buffer[In2[i]]) ? 1 : 0;
		}
	}
	return buffer[2];
}

ui64 tests[6] = {1, 13, 0, 998224353, 123456789, 1000000000 };

int main()
{
	V tmp = (a > zero) + (b > zero);
	pows[0] = tmp > zero;
	for (int i = 1; i < 60; ++i) pows[i] = pows[i - 1] + pows[i - 1];
	bpow[0] = b;
	for (int i = 1; i < 30; ++i) bpow[i] = bpow[i - 1] + bpow[i - 1];
	V ret = zero, added = zero;
	for (int i = 29; i >= 0; --i) {
		V flg = a > (added + pows[i]);
		ret = ret + cond(flg, bpow[i], i + 30);
		added = added + mulpow2(flg, i);
	}
	ret = ret + cond(a > zero, b, 30);
	Op.push_back('+');
	In1.push_back(zero.id_);
	In2.push_back(ret.id_);
	Out.push_back(2);

	printf("%d\n", Op.size());
	for (int i = 0; i < Op.size(); ++i) printf("%c %d %d %d\n", Op[i], In1[i], In2[i], Out[i]);
	
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 6; ++j) {
			ui64 expected = tests[i] * tests[j];
			ui64 ans = emulate(tests[i], tests[j]);
			if (expected != ans)
			printf("%llu %llu %llu %llu\n", tests[i], tests[j], emulate(tests[i], tests[j]), tests[i] * tests[j]);
		}
	}
	return 0;
}


Measured memory_bytes: 4932
import java.util.Scanner;

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

        String word = sc.next();
        int count = 0;

        while(true){
            String text = sc.next();

            if(text.equals("END_OF_TEXT"))break;

            if(word.compareToIgnoreCase(text) == 0){
                count++;
            }
        }

        System.out.printf("%d\n",count);

    }
}


Measured memory_bytes: 26432
def inv_mod(a, p):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

MOD = 998244353
inpl = lambda: list(map(int,input().split()))
N, M, K = inpl()

if M == 1:
    if K == N-1:
        print(1)
    else:
        print(0)
else:
    q = pow(M-1,N-1,MOD) * M % MOD
    S = q
    f = inv_mod(M-1,MOD)
    for k in range(1,K+1):
        q *= f * (N-k) * inv_mod(k,MOD)
        q %= MOD
        S += q
        S %= MOD
    print(S)


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

char img_A[55][55], img_B[55][55];

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> img_A[i][j];
    }
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) cin >> img_B[i][j];
    }
    if (N < M) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i <= N - M; i++) {
        for (int j = 0; j <= N - M; j++) {
            bool is_correct = true;
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (img_A[i + k][j + l] != img_B[k][l]) is_correct = false;
                }
            }
            if (is_correct) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
// (i, b, d) => n
// i桁目より上が決定
// b = K以下確定 ? 1 : 0
// そこまでの各桁の数字の総和が d mod D となる個数n

const i64 MOD = 1e9 + 7;
i64 dp[10001][2][100];

int main() {
    string K;
    int D, N;
    cin >> K >> D;
    reverse(WHOLE(K));
    N = K.size();
    for(int i = 0; i <= N; i++) {
        for(int b = 0; b < 2; b++) {
            for(int d = 0; d < D; d++) {
                dp[i][b][d] = 0;
            }
        }
    }
    dp[N][0][0] = 1;
    for(int i = N - 1; i >= 0; i--) {
        int n = K[i] - '0';
        for(int d = 0; d < D; d++) {
            for(int x = 0; x < n; x++) {
                dp[i][1][d] += dp[i + 1][0][(d - x + 100 * D) % D];
            }
            for(int x = 0; x < 10; x++) {
                dp[i][1][d] += dp[i + 1][1][(d - x + 100 * D) % D];
            }
            dp[i][0][d] += dp[i + 1][0][(d - n + 100 * D) % D];
            dp[i][0][d] %= MOD;
            dp[i][1][d] %= MOD;
        }
    }
    cout << (dp[0][1][0] + dp[0][0][0] - 1 + MOD) % MOD << endl;
}

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

signed main(){
    int N, x;
    cin >> N >> x;
    vi a(N);
    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());
    
    int counter = 0;
    rep(i, N){
        x -= a[i];
        if(x < 0) break;
        counter++;
    }

    if(x > 0) counter--;

    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, m, l;
    cin >> n >> m >> l;
    int a[110][110], b[110][110];
    rep(i, 0, n) rep(j, 0, m) cin >> a[i][j];
    rep(i, 0, m) rep(j, 0, l) cin >> b[i][j];
    int c[110][110] = {};
    rep(i, 0, n){
        rep(j, 0, l){
            rep(k, 0, m){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    rep(i, 0, n){
        rep(j, 0, l){
            cout << c[i][j];
            if(j != l - 1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3316
//
// Created by keane on 19-6-16.
//
#include <bits/stdc++.h>
using namespace std;
int n;
int main(void){
//    freopen("in.txt","r",stdin);
    int x,a;
    scanf("%d%d",&x,&a);
    if(x<a){
        printf("0\n");
    }else{
        printf("10\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 1000000001

int ruizyo(int n,int r) {
	long long nowmul=n;
	long long result=1;
	if(n>=INF)return INF;
	while(r>0) {
		if(r&1)result*=nowmul;
		if(result>=INF)return INF;
		nowmul*=nowmul;
		if(nowmul>INF)nowmul=INF;
		r>>=1;
	}
	return (int)result;
}

int main(void) {
	int n,T;
	char siki[1000]={};
	int i;
	int nowSteps=0;
	int parsing=0;
	scanf("%d%d",&n,&T);
	scanf("%s",siki);
	for(i=2;siki[i-1];i++) {
		if(isdigit(siki[i])) {
			if(parsing<1000000000)parsing=parsing*10+siki[i]-'0';
		} else {
			nowSteps+=ruizyo(n,parsing);
			if(nowSteps>INF)nowSteps=INF;
			parsing=0;
			i+=2;
		}
	}
	if((long long)nowSteps*T<=1000000000) {
		printf("%d\n",nowSteps*T);
	} else {
		puts("TLE");
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long lli;
typedef pair<lli, lli> ip;
typedef pair<ip, ip> q;

lli a[200001], s[200001];
int n;

q f(int l, int r) {
	if (l + 1 == r) return q(ip(a[l], a[r]), ip(a[l], a[r]));
	if (a[l] >= s[r] - s[l]) return q(ip(a[l], s[r] - s[l]), ip(a[l] + a[l + 1], s[r] - s[l + 1]));
	int lo = l, hi = r - 1;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (s[mid] - s[l - 1] < s[r] - s[mid]) lo = mid;
		else hi = mid;
	}
	return q(ip(s[lo] - s[l - 1], s[r] - s[lo]), ip(s[lo + 1] - s[l - 1], s[r] - s[lo + 1]));
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		s[i] = s[i - 1] + a[i];
	}
	lli res = (1LL << 60);
	for (int i = 2; i <= n - 2; i++) {
		q t1 = f(1, i), t2 = f(i + 1, n);
		lli r1[2][2] = {
			{t1.first.first, t1.first.second},
			{t1.second.first, t1.second.second}
		}, r2[2][2] = {
			{t2.first.first, t2.first.second},
			{t2.second.first, t2.second.second}
		};
		for (int u = 0; u < 2; u++) {
			for (int v = 0; v < 2; v++) {
				lli A[4] = { r1[u][0],r1[u][1],r2[v][0],r2[v][1] };
				sort(A, A + 4);
				lli dif = A[3] - A[0];
				if (dif < res) res = dif;
			}
		}
	}
	printf("%lld\n", res);
	return 0;
}

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

int main(){
 char c;
 cin >> c;
  
 if (c != 'a' && c != 'i' && c != 'u' && c != 'e' && c != 'o'){
  cout << "consonant" << endl;
 }
 else{
  cout << "vowel" << endl;
 }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#define itn int
#define reaD read
typedef long long ll;
#define N 100005
using namespace std;

ll n, a[N], l, r, t[N << 1], sum[N]; 

inline int read()
{
	int x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	return x * w;
}

int lowbit(int x) { return x & (-x); }

void add(int x, long long y) { for(int i = x; i <= 200000; i += lowbit(i)) t[i] += y; }

long long query(int x) { long long res = 0; for(int i = x; i; i -= lowbit(i)) res += t[i]; return res; }

bool check(long long mid)
{
	memset(t, 0, sizeof(t));
	long long cnt = 0;
	for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (a[i] >= mid ? 1 : -1);
	for(int i = 0; i <= n; i++)
	{
		cnt += query(sum[i] + 100000);
		add(sum[i] + 100000, 1); 
	}
	return cnt >= 1ll * n * (n + 1) / 4; 
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i++) r = max(r, a[i] = read());
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(check(mid)) l = mid + 1;
		else r = mid - 1; 
	}
	printf("%lld\n", r); 
	return 0;
}

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

def ans(A, B, K):
    pA = [0]
    for a in A:
        pA += [pA[-1] + a]
    pB = [0]
    for b in B:
        pB += [pB[-1] + b]

    # print(pA, pB)

    j = len(B)

    ans = float("-inf")

    for i in range(0, len(pA)):
        # print("considering", i, j)
        while j > 0 and pA[i] + pB[j] > K: j -= 1
        if pA[i] + pB[j] <= K:
            ans = max(ans, i + j)

    return ans

N, M, K = input().split(' ')
K = int(K)

A = input().split(' ')
A = list(map(int, A))

B = input().split(' ')
B = list(map(int, B))

print(ans(A, B, K))

Measured memory_bytes: 129440
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;

int n,m;
int dp[100005] = {0};
int in[100005] = {0};

int ec = 0,hed[100005] = {0},to[100005],nxt[100005];
void add_edge(int f,int t){
	in[t] ++;
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

queue <int> q;
void tpsort(){
	for(int i = 1;i <= n;i ++){
		if(!in[i]) q.push(i);
	}
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int i = hed[u];i;i = nxt[i]){
			int v = to[i];
			dp[v] = max(dp[v],dp[u] + 1);
			in[v] --;
			if(!in[v]) q.push(v);
		}
	}
}

int main(){
	int a,b;
	scanf("%d %d",&n,&m);
	while(m --){
		scanf("%d %d",&a,&b);
		add_edge(a,b);
	}
	tpsort();
	int ans = 0;
	for(int i = 1;i <= n;i ++) ans = max(ans,dp[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2432
import heapq
N = int(input())
li = [ int(it) for it in input().split() ]

X = li[:N]
sX = [0]*(N+1)
sX[0] = sum(X)
heapq.heapify(X) 
for i in range(N):
  pu = li[N+i]
  heapq.heappush(X,pu)
  po = heapq.heappop(X)
  sX[1+i] = sX[i] + pu - po

li = [ -li[3*N-1-i] for i in range(3*N)] 
Y = li[:N]
sY = [0]*(N+1)
sY[0] = sum(Y)
heapq.heapify(Y) 
for i in range(N):
  pu = li[N+i]
  heapq.heappush(Y,pu)
  po = heapq.heappop(Y)
  sY[1+i] = sY[i] + pu - po

  
s = -100000000000000000000000
for i in range(N+1):
  s = max( sX[i] + sY[N-i] ,s )
print  (s)


Measured memory_bytes: 120208
def main():
    h = int(input())
    summ = 0
    bun = 1
    hh = h
    while(True):
        if hh <= 1:
            summ += bun
            break
        else:
            hh  = hh // 2
            summ += bun
            bun *= 2
    print(summ)

if __name__ == "__main__":
    main()


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

int main(){
  string s,t;
  cin>>s>>t;
  string tmp;
  int cou=0;
  int flag=0;
  int l=s.size();
  while(cou!=l){
    s = s[l-1]+s.substr(0, l-1);
    if(t==s){
      flag=1;
      break;
    }
    cou++;
  }
  if(flag==1)cout<<"Yes"<<endl;
  if(flag==0)cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
}


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

bool calcnext(vector<vector<int>> &s, int sindex, int Ac, int Bc, int Cc, vector<int> &choice)
{
	vector<int> sc = s[sindex];
	bool result = false;

	//選択1；sc[0]を1引く
	if (sc[0] == 0 && Ac - 1 >= 0)
	{ //Aを1引く場合；Aが負にならない場合は次へ進む、そうでない場合は打ち切り
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[1] == 1)
		{ //最後でない場合はBに1足して次
			result = calcnext(s, sindex + 1, Ac - 1, Bc + 1, Cc, choice);
		}
		else
		{ //Cに1足して次
			result = calcnext(s, sindex + 1, Ac - 1, Bc, Cc + 1, choice);
		}
	}
	else if (sc[0] == 1 && Bc - 1 >= 0)
	{
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[1] == 0)
		{
			result = calcnext(s, sindex + 1, Ac + 1, Bc - 1, Cc, choice);
		}
		else
		{
			result = calcnext(s, sindex + 1, Ac, Bc - 1, Cc + 1, choice);
		}
	}
	else if(sc[0] == 2 && Cc - 1 >= 0)
	{
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[1] == 0)
		{
			result = calcnext(s, sindex + 1, Ac + 1, Bc, Cc - 1, choice);
		}
		else
		{
			result = calcnext(s, sindex + 1, Ac, Bc + 1, Cc - 1, choice);
		}
	}

	//クリアできる場合が見つかっていれば終了
	if (result)
	{
		choice.emplace_back(sc[1]); //1を足す方の選択を保存して終了
		return true;
	}


	//選択2；sc[1]を1引く
	if (sc[1] == 0 && Ac - 1 >= 0)
	{ //Aを1引く場合；Aが負にならない場合は次へ進む、そうでない場合は打ち切り
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[0] == 1)
		{ //最後でない場合はBに1足して次
			result = calcnext(s, sindex + 1, Ac - 1, Bc + 1, Cc, choice);
		}
		else
		{ //Cに1足して次
			result = calcnext(s, sindex + 1, Ac - 1, Bc, Cc + 1, choice);
		}
	}
	else if (sc[1] == 1 && Bc - 1 >= 0)
	{
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[0] == 0)
		{
			result = calcnext(s, sindex + 1, Ac + 1, Bc - 1, Cc, choice);
		}
		else
		{
			result = calcnext(s, sindex + 1, Ac, Bc - 1, Cc + 1, choice);
		}
	}
	else if (sc[1] == 2 && Cc - 1 >= 0)
	{
		if (sindex + 1 == s.size())
		{ //最後の選択までクリアしたので終了
			result = true;
		}
		else if (sc[0] == 0)
		{
			result = calcnext(s, sindex + 1, Ac + 1, Bc, Cc - 1, choice);
		}
		else
		{
			result = calcnext(s, sindex + 1, Ac, Bc + 1, Cc - 1, choice);
		}
	}

	if (result)
	{
		choice.emplace_back(sc[0]); //1を足す方の選択を保存して終了
		return true;
	}

	//クリアできる場合が見つからなかった
	return false;
}


int main()
{
	int N, A, B, C;
	cin >> N >> A >> B >> C;

	vector<vector<int>> s;
	for (int i = 0; i < N; i++)
	{
		string tmps;
		cin >> tmps;

		vector<int> tmpv(2);
		for (int j = 0; j < 2; j++)
		{
			tmpv[j] = (int)(tmps[j] - 'A');
		}
		s.emplace_back(tmpv);
	}


	//打ち切りありの2分木探索をする
	vector<int> choice;
	if (calcnext(s, 0, A, B, C, choice))
	{
		cout << "Yes" << endl;
		for (int i = N - 1; i >= 0; i--)
		{
			cout << (char)(choice[i] + 'A') << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}



	return 0;
}



Measured memory_bytes: 19644
#include<bits/stdc++.h>
#include<cmath>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 1e6+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())
ll x,a,b;
ll f(ll x){
	return x*x*x*x*x;
}
map<ll,bool> m;map<ll,int> s;
int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  	cin>>x;
  	//rep(x,1,1e9){
  	rep(i,-5000,5000) m[f(i)]=1,s[f(i)]=i;
  	rep(i,-5000,5000){ 
  		if(m[f(i)-x]){
  			cout<<i<<' '<<s[f(i)-x];return 0; 
		  }
	} 
		
//	}
  	return 0;
}



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

int main()
{
	char ch;
	int num,count[26] = {0};
	while(scanf("%c",&ch) != EOF) {
		if(isupper(ch)) ch = tolower(ch);
		num = ch;
		if(num >= 'a' && num <= 'z') count[num - 'a']++;
		}
		
		for(int i = 'a';i <= 'z';i++){
			cout << char(i) << " : " << count[i - 'a'] << endl;
		}
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

bool isPrime(int x)
{
	if (x == 2)
	{
		return true;
	}
	if (x < 2 || x % 2 == 0)
	{
		return false;
	}

	int i = 3;

	while (i <= static_cast<int>(sqrt(x)))
	{
		if (x % i == 0)
		{
			return false;
		}
		i = i + 2;
	}
	return true;
}

int main()
{
	int ans = 0;
	int biggest_number = 0;
	vector<bool> v(100000000);

	int n;
	while (cin >> n)
	{
		if (n > biggest_number)
		{

			biggest_number = n;
		}
		v[n] = true;
	}
	
	for (int i = 0; i < biggest_number + 1; i++)
	{
		if (v[i] == true)
		{
			if (isPrime(i))
			{
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14752
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd

def resolve():
    N=int(input())

    # dp[i]はh[i]までにかかるコストの最小値
    dp = [float('inf') for _ in range(N+1)]
    dp[0] = 1
    dp[1]=1


    for i in range(2,N+1):
        dp[i] = min(dp[i], dp[i - 1] + dp[i-2])
    print(dp[N])



resolve()


Measured memory_bytes: 5612
N = int(input())
S = list(input())
count = S.count("R")*S.count("B")*S.count("G")
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i < N:
            if S[i]!=S[j] and S[2*j-i]!=S[i] and S[2*j-i]!=S[j]:
                count-=1
print(count)
        

Measured memory_bytes: 9084
package main

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

func main() {
	sc := NewScanner()
	N, S, T := sc.NextInt(), sc.Next(), sc.Next()

	P := ""
	for i := 0; i < N; i++ {
		P += string(S[i]) + string(T[i])
	}

	fmt.Println(P)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int N, T;
  scanf("%d %d", &N, &T);

  int max_c = 10000;
  for(int i = 0; i < N; i++) {
    int c, t;
    scanf("%d %d", &c, &t);
    if(t <= T) {
      if(c <= max_c) {
	max_c = c;
      }
    }
  }

  if(max_c > 1000) {
    printf("TLE\n");
  } else {
    printf("%d\n", max_c);
  }

  return 0;
}


Measured memory_bytes: 128
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=1e5+5;
const ll INF=1e18+5;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,k,a[N],dp[105][N],pre[105][N];

int main()
{
  cin>>n>>k;
  for(ll i=0;i<n;i++){cin>>a[i];}
  for(ll i=0;i<=a[0];i++){dp[0][i]=1;pre[0][i]=(i+1);}
  for(ll i=a[0]+1;i<=k;i++){pre[0][i]=pre[0][i-1];}
  for(ll i=1;i<n;i++)
  {
    for(ll j=0;j<=k;j++)
    {
      ll pos=min(j,a[i]);
      ll l=j-pos-1,r=j;
      if(l<0){dp[i][j]=add(dp[i][j],pre[i-1][r],mod);}
      else
      {
        dp[i][j]=add(dp[i][j],pre[i-1][r]-pre[i-1][l],mod);
        if(dp[i][j]<0){dp[i][j]+=mod;}
        dp[i][j]%=mod;
      }
      //dp[i][j]=add(dp[i][j],pre[i-1][r],mod);
      //trace6(i,j,dp[i][j],l,r,pre[i-1][r]);
      /*for(ll h=0;h<=min(j,a[i]);h++)
      {
        //if(i-1<0||j-h<0){continue;}
        dp[i][j]=add(dp[i][j],dp[i-1][j-h],mod);
        trace5(i,j,h,dp[i][j],dp[i-1][j-h]);
      }
      cout<<endl;*/
    }
    for(ll j=0;j<=k;j++){pre[i][j]=dp[i][j]%mod;}
    for(ll j=1;j<=k;j++){pre[i][j]=add(pre[i][j],pre[i][j-1],mod);}
    //for(ll j=a[i]+1;j<=k;j++){pre[i][j]=pre[i][j-1];}
  }
  cout<<dp[n-1][k]%mod<<endl;
}


Measured memory_bytes: 160000
#include <iostream>
     
    int main () {
    int n;
      int ans =0;
      std::cin >> n;
      int arr[10001];
      
      for (int i = 0; i < n;++i){
      std::cin >> arr[i];
      }
      
      for (int i = 0; i < n;++i){
      while(arr[i]%2==0){
      arr[i]/=2;
        ans++;
      }
      }
      std::cout << ans << std::endl;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long count = 0;
    for (int i = 0; i * R <= N; i++) {
        for (int j = 0; i * R + j * G <= N; j++) {
            if ((N - i * R - j * G) % B == 0) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(void){
	int n; cin >> n;
	int d[n]; rep(i, n) cin >> d[i];

	int ans = 0;
	rep(i, n){
		for(int j = i + 1; j < n; j++){
			if(i != j){
				ans += d[i] * d[j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

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

}


Measured memory_bytes: 3088
n, m = map(int, input().split())
requests = []
for i in range(m):
     requests += [list(map(int,input().split()))]

requests = sorted(requests, key=lambda x: x[1])# end <= nextend
start = 0
end = 0
ans = 0
for request in requests:
    nextstart, nextend = request
    if end <= nextstart:
        ans += 1
        start = nextstart
        end = nextend
print(ans)

Measured memory_bytes: 29844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean[] triple = new boolean[n];
		for (int i = 0; i < m; i++) {
			int c = sc.nextInt();
			int d = sc.nextInt();

			for (int j = c; j < d; j++) {
				triple[j] = true;
			}
		}

		int ans = 0;
		for (int i = 0; i < triple.length; i++) {
			if (triple[i]) {
				ans += 2;
			}
		}

		System.out.println(ans + n + 1);
		sc.close();

	}

}

Measured memory_bytes: 22136
#include <stdio.h>
int main(void) {
	int a, b, i, sum;
	
	while (scanf("%d %d", &a, &b)!= EOF) {
		i = 0;
		sum = a + b;
		while (sum != 0) {
			i++;
			sum /= 10;
		}
		printf("%d\n", i);

	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int a;cin>>a;
  print(a+a*a+a*a*a);
  return 0;
}

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

int main(){
  int64_t H; cin >> H;
  int64_t p =1;
  int64_t sum =0;
  while(H>0){
    sum += p;
    p *= 2;
    H /= 2;
  }
  cout << sum << endl;


}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	map<ll, int> m;
	ll sum = 0;
	REP(i, n){
		cin  >> tmp;
		m[tmp] ++;
		sum += tmp;
	}
	int q; cin >> q;
	ll b, c;
	REP(i, q){
		cin >> b >> c;
		sum += (c-b) * m[b];
		cout << sum << endl;
		m[c] += m[b];
		m[b] = 0;
	}
//	cout << ans << endl;
}

Measured memory_bytes: 9468
k = int(input())
a, b = list(map(int,input().split()))
judge = False
# print(k,a,b)
for i in range(a,b+1):
    # print(i%k)
    if i % k == 0:
        judge = True
if judge:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 61780
a,b = map(int,input().split())
k = [2,5,5,4,5,6,3,7,6]

c = list(map(int,input().split()))

c.sort()
cc = [[c[i],k[c[i]-1]] for i in range(b)]
ccc = [[c[i],k[c[i]-1]] for i in range(b)]
dp = [-1 for i in range(a+1)]
dp[0] = 0
cc.sort(key = lambda x:x[1])
for j in range(b):
	for i in range(a+1):
		if i-cc[j][1] >= 0 and dp[i-cc[j][1]] >= 0:
			dp[i] = max(dp[i-cc[j][1]]+1,dp[i])
ccc.reverse()
k = a
co = ''
for i in range(dp[a]):
	for j in range(b):
		if k-ccc[j][1] >= 0 and dp[k-ccc[j][1]] == dp[k] - 1:
			co += str(ccc[j][0])
			k -= ccc[j][1]
			break
print(co)


Measured memory_bytes: 42476
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

   int n, k;
   cin >> n >> k;
   vector<int> a(3);
   rep(i, 0, 3) cin >> a[i];
   string s;
   cin >> s;
   map<char, int> mp;
   mp['r'] = 2;
   mp['s'] = 0;
   mp['p'] = 1;
   int ans = 0;
   rep(i, 0, k) {
      vector<int> x;
      for (int j = i; j < n; j += k) {
         x.push_back(mp[s[j]]);
      }
      vector<int> dp(2);
      int pre = -1;
      for (int nx : x) {
         vector<int> p(2);
         swap(dp, p);
         dp[0] = max(p[0], p[1]);
         if (pre == nx) {
            dp[1] = p[0] + a[nx];
         } else {
            dp[1] = max(p[1], p[0]) + a[nx];
         }
         pre = nx;
      }
      ans += max(dp[0], dp[1]);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1020
# bit全探索で解いてみる
# 0~2**d-1の中に全てのパターンを試せるような情報が含まれる
numbers = list(input())

for i in range(1 << (len(numbers)-1)):
    tmp = numbers[0]
    for j in range(len(numbers)-1):  # j番目のbitが立っているかどうかを見る
        if (i >> j) & 1:
            tmp += "+"
        else:
            tmp += "-"
        tmp += numbers[j+1]
    if eval(tmp) == 7:
        print(tmp+"=7")
        break


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <functional>
#include <cassert>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int X[SIZE];

int main()
{
	int n,A,B;
	scanf("%d %d %d",&n,&A,&B);
	for(int i=0;i<n;i++) scanf("%d",&X[i]);
	ll ret=0;
	for(int i=0;i+1<n;i++)
	{
		ret+=min((ll) (X[i+1]-X[i])*(ll) A,(ll) B);
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 512