akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

int main() {

    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> s(H, vector<char>(W));
    rep(i, H) rep(j, W) { cin >> s[i][j]; }
    vector<vector<int>> res(H, vector<int>(W, 0));
    int now = 0;
    int cnt = 0;
    vector<int> flag(H, 0);
    for(int i = 0; i < H; i++) {
        cnt = 0;
        now++;
        if(i > 0 && flag[i - 1] == 0)
            now--;
        for(int j = 0; j < W; j++) {
            if(s[i][j] == '#') {
                cnt++;
                flag[i] = 1;
                if(cnt > 1)
                    now++;
            }
            res[i][j] = now;
        }
    }

    // パクる
    rep(i, H) {
        if(flag[i] == 0) {
            int ok = 0;
            for(int j = i + 1; j < H; j++) {
                if(flag[j] == 1) {
                    rep(k, W) { res[i][k] = res[j][k]; }
                    ok = 1;
                    break;
                }
            }
            if(!ok) {
                for(int j = i - 1; j >= 0; j--) {
                    if(flag[j] == 1) {
                        rep(k, W) { res[i][k] = res[j][k]; }
                        break;
                    }
                }
            }
        }
    }

    rep(i, H) {
        rep(j, W) { cout << res[i][j] << " "; }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int len=scanner.nextInt();
		String s=scanner.next();
		int max=0;
		int sum=0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i)=='I') {
				sum++;
			}else {
				sum--;
			}
			if (max<sum) {
				max=sum;
			}
		}
		System.out.print(max);
	}
}

Measured memory_bytes: 21588
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

N = int(input())
print(N*(N-1)//2)

Measured memory_bytes: 64988
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define ll long long
int main()
{
    char a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<'>';
    }
    else if(a<b)
    {
        cout<<'<';
    }
    else
    {
        cout<<'=';
    }
    return 0;
}


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

using namespace std;

const int mod = 998244353;

int main(){
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  vector<vector<long long>> dp(N + 1, vector<long long>(S + 1, 0));
  dp[N][0] = 1;
  for(int R = N - 1; R >= 0; R--){
    dp[R][0] = 1;
    for(int j = 0; j <= S; j++){
      (dp[R][j] += dp[R + 1][j]) %= mod;
      if(j + A[R] <= S) (dp[R][j + A[R]] += dp[R + 1][j]) %= mod;
    }
  }
  
  long long sum = 0;
  for(int L = 0; L < N; L++){
    (sum += dp[L][S]) %= mod;
  }
  
  cout << (sum + mod) % mod << endl;
  
  return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	OUT(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K,C;
	cin >> N >> K >> C;
	string str;
	cin >> str;
	vector<LL> conv(N + 1,false);
	for (LL n = 0; n < N; n++) {
		if (str[n] == 'o')conv[n + 1] = true;
		else conv[n + 1] = false;
	}
	VVLL reg;
	reg.resize(2e5 + 1, VLL());
	VLL DP(N + 1, -1);
	VLL DDP(N + 1, -1);
	DP[0] = 0;
	DDP[0] = 0;
	for (LL n = 1; n <= N; n++) {
		if (conv[n]) {
			DP[n] = DDP[max((LL)0, n - C - 1)]+1;
			reg[DP[n]].push_back(n);
		}
		DDP[n] = max(DP[n], DDP[n - 1]);
	}
	VLL ans;
	if (reg[K + 1].size() > 0) {
		return 0;
	}
	if (reg[K].size() == 1)ans.push_back(reg[K][0]);
	set<LL> check;
	while (K > 1) {
		LL last = reg[K].back();
		LL s = 0, e = reg[K - 1].size();
		while (e - s > 1) {
			LL m = (e + s) / 2;
			if (reg[K - 1][m] <= last - C - 1)s = m;
			else e = m;
		}
		if (s == 0)ans.push_back(reg[K - 1][s]);
		while (reg[K - 1].size() > s + 1) {
			reg[K - 1].pop_back();
		}
		K--;
	}
	for (LL n = ans.size() - 1; n >= 0; n--)cout << ans[n] << "\n";
	return 0;
}


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

public class Main {

    private static void solver(InputReader sc, PrintWriter out) throws Exception {
          int n = sc.nextInt();
          int m = sc.nextInt();
          int arr[] = new int[n];
          boolean good[] = new boolean[n];
          Arrays.fill(good,true);
          for(int i=0;i <n; i++) arr[i] = sc.nextInt();
          for(int i=0; i<m; i++){
              int x = sc.nextInt()-1;
              int y = sc.nextInt()-1;
              if(arr[x] <= arr[y]) {
                  good[x] = false;
              }
              if(arr[y] <= arr[x])
                  good[y] = false;
          }
          int count=0;
          for(boolean xx : good){
              if(xx)
                  count++;
          }
          out.println(count);
    }
    private static int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }
    private static long helper(long x){
        long ans = (x * (x-1))/2;
        return ans;
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    long x;
    long y;
    Pair(long x, long y){
        this.x  =x ;
        this.y =y;
    }
}


Measured memory_bytes: 53416
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll N, M; cin >> N >> M;
    vl as(N, 0), bs(N, 0); REP(i, N) cin >> as[i] >> bs[i];
    map<ll, ll> m;
    REP(i, N){
        m[as[i]] += bs[i];
    }
    ll d = 0, ans = 0;
    FORMAP(it, m){
        if(d + it->ss < M){
            ans += it->ff * it->ss;
            d += it-> ss;
        }
        else{
            ll remain = M -d;
            ans += it->ff * remain;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    vector<ll> A(3);
    FOR(i, 0, 3){
        cin >> A[i];
    }
    sort(ALL(A));

    p2(A[0], A[2]);
    
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E, Q;

struct Edge {
	int from, to;
	Edge(int u, int v) :from(u), to(v) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];

	int pre[NUM], lowlink[NUM], dfs_clock;
	bool _cycle = false, instack[NUM];

	void init(int n) {
		this->n = n;
		edges.clear();
		for (int i = 0; i < n; i++) {
			G[i].clear();
		}
	}

	void AddEdge(int from, int to) {
		edges.push_back(Edge(from, to));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	int dfs(int u, int fa) {
		int lowu = pre[u] = ++dfs_clock;
		for (int i = 0; i < G[u].size(); i++) {
			int v = edges[G[u][i]].to;
			if (!pre[v]) {
				instack[v] = true;
				int lowv = dfs(v, u);
				lowu = min(lowu, lowv);
				if (lowlink[v] <= pre[u])
					_cycle = true;
			}
			else if (pre[v] < pre[u] && v != fa && instack[v])
				lowu = min(lowu, pre[v]);
		}
		lowlink[u] = lowu;
		instack[u] = false;
		return lowu;
	}

	void find_cycle(int n) {
		dfs_clock = 0;
		memset(pre, 0, sizeof(pre));
		for (int i = 0; i < n; i++)
			if (!pre[i]) {
				instack[i] = true;
				dfs(i, -1);
			}
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s, t;
	cin >> V >> E;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d", &s, &t);
		solve.AddEdge(s, t);
	}
	solve.find_cycle(V);
	if (solve._cycle)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int k;
int a[N];

int main()
{

    for(int i = 0; i < 3; i++) cin >> a[i];
    cin >> k;
    sort(a, a + 3);

    while(k--) a[2] *= 2;

    int res = 0;
    for(int i = 0; i < 3; i++) res += a[i];

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

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

using namespace std;


int main(){
    int n,m;
    while(cin>>n>>m && n){
        vector<int> v(n);
        rep(i,0,n)cin>>v[i];
        int ans=0;
        rep(i,0,n-1)rep(j,i+1,n)if(v[i]+v[j]<=m)ans=max(ans,v[i]+v[j]);
        if(ans==0)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int h=sc.nextInt();
			int w=sc.nextInt();
			if(h==0&&w==0){
				break;
			}
			char[][] map=new char[h][w];
			boolean[][] mapFlag=new boolean[h][w];
			for(int i=0;i<h;i++){
				map[i]=sc.next().toCharArray();
			}
			int x=0;
			int y=0;
			boolean flag=true;
			while(map[y][x]!='.'){
				if(mapFlag[y][x]){
					flag=false;
					break;
				}
				mapFlag[y][x]=true;
				if(map[y][x]=='>'){
					x++;
				}
				if(map[y][x]=='v'){
					y++;
				}
				if(map[y][x]=='<'){
					x--;
				}
				if(map[y][x]=='^'){
					y--;
				}
			}
			if(flag){
				System.out.println(x+" "+y);
			}else{
				System.out.println("LOOP");
			}
		}
	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for (auto &&i : D) {
        cin >> i;
    }

    auto check = [&](int x) {
        while (x != 0) {
            int now = x % 10;
            for (auto &&i : D) {
                if (now == i)
                    return false;
            }
            x /= 10;
        }
        return true;
    };

    constexpr int MAX = 1000000;
    for (int i = N; i < MAX; i++) {
        if (check(i)) {
            cout << i << endl;
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 75164
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

n = 7
for i in range(1,10**7):
    if n%k == 0:
        print(i)
        break
    else:
        n = (n%k +0.7) *10
    

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

ll f(map<int , int> & fr){
	ll val = 0;
	
	for(pii e : fr){
		if(e.fi > val && e.se >= 2){
			val = e.fi;
		}
	}
	
	fr[val] = max(fr[val] - 2 , 0);
	
	return max(val , 0ll);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	
	map<int , int> fr;
	for(int e : v){
		++fr[e];
	}
	
	cout << f(fr) * f(fr);

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

class Team{
public:
    int id, solved, penalty;
    vector<int> wrongs;
    
    Team(int _id, int p): id(_id){
        solved = 0;
        penalty = 0;
        wrongs = vector<int>(p);
    }
    
    bool operator < (const Team &r) const{
        return solved==r.solved ? (penalty==r.penalty ? id<r.id : penalty<r.penalty) :solved>r.solved;
    }
};

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int T, P, R;
    while(cin>>T>>P>>R, T|P|R){
        vector<Team> teams;
        for(int i=0; i<T; i++)
            teams.push_back(Team(i, P));
        
        while(R--){
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;
            tid--; pid--;
            auto &team = teams[tid];
            
            if(message == "WRONG"){
                team.wrongs[pid]++;
            }else if(message == "CORRECT"){
                team.solved++;
                team.penalty += team.wrongs[pid] * 1200 + time;
            }
        }
        
        sort(teams.begin(), teams.end());
        for(Team team: teams)
            cout << team.id+1 << " " << team.solved << " " << team.penalty << endl;
    }
    
    return 0;
}

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

int main() {
    int a, b;
    int x = 0;
    int sum = 0;

    cin >> a >> b;

    do{
        x++;
        sum = (a * x) - (x-1); 
        
    }while(sum < b);

    if(a>b){
        x=1;
    }
    if(b==1){
        x=0;
    }

    cout << x <<endl;

    return 0;

}

Measured memory_bytes: 256
n,q=gets.split.map &:to_i
A=n.times.map{[]}
q.times{
a=gets.split.map &:to_i
if a[0]==0
A[a[1]]<<a[2]
elsif a[0]==1
puts A[a[1]]*' '
else
A[a[1]].clear
end
}


Measured memory_bytes: 16100
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int i,j,k,c,H[100], W[100];
	i = 0;
	while (1){
		scanf("%d %d", &H[i], &W[i]);
		if (0 == H[i] && 0 == W[i]) {
			break;
		}
		i++;
	}
	c = i;
	for (k = 0; k < c; k++) {
		for (j = 0; j < H[k]; j++) {
			for ( i = 0; i <W[k] ; i++){
				printf("#");

			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 2596
#include <iostream>

using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int t_a = (c - 1) / b;
  int t_b = (a - 1) / d;
  
  if(t_a > t_b){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;


 class Main
 { 
	public static void main(String args[])
 	{ 

		Scanner sc =new Scanner(System.in);
		long l = sc.nextInt();
		long r = sc.nextInt();
		
		long res = Integer.MAX_VALUE;
		
		if(r - l >= 2019){
			System.out.println(0); 
			return;
		}
		
		for(long i = l; i <= r; i++){
			for(long j = i+1; j <= r; j++){
				res = Math.min(res, i*j%2019);
			}
		}
		
		System.out.println(res);

 	}
 }

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

int main() {
    long long R0, W0, C, R;
    while (true) {
        cin >> R0 >> W0 >> C >> R;
        if (R0 == 0 && W0 == 0 && C == 0 && R == 0) { break; }

        // (R0 + R*k) / W0 >= C
        // k >= (C * W0 - R0) / R
        
        cout << max(0LL, (C * W0 - R0 + R - 1) / R) << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
const fs = require('fs')
const n = parseInt(fs.readFileSync('/dev/stdin', 'utf8').trim())

function primeFactorize(n) {
  const primes = []
  for (let p = 2; p * p <= n; p += 1) {
    if (n % p != 0) continue

    let e = 0
    while (n % p == 0) {
      n /= p
      e += 1
    }
    primes.push({ p, e })
  }

  if (n != 1) primes.push({ p: n, e: 1 })
  return primes
}

let count = 0
const primes = primeFactorize(n)
primes.forEach(prime => {
  let e = prime.e
  for (let i = 1; i <= e; i += 1) {
    e -= i;
    count += 1;
  }
})

console.log(count)


Measured memory_bytes: 33140
n, k = list(map(int, input().split(' ')))
W = [int(input()) for i in range(n)]

# 最大積載量をPとした時, k台のトラックでどの荷物まで積めるのか
def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する
def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

ans = solve()
print(ans)


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n,m;

/*funcs*/
ll exc(ll a){
    ll t=1;
    ll ans=1;
    while(t<=a){
        ans=ans*t;
        ans=ans%1000000007;
        t++;
    }
    return ans;
}

/*main*/
int main(){
    cin>>n>>m;
    ll ans;
    if(n==m){
        ll p;
        p=exc(n);
        ans=(p*p*2)%1000000007;
    }else if(n==m+1){
        ll p;
        p=exc(m);
        ans=(((p*p)%1000000007)*n)%1000000007;
    }else if(n==m-1){
        ll p;
        p=exc(n);
        ans=(((p*p)%1000000007)*m)%1000000007;
    }else{
        ans=0;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#coding:utf-8
import math

#移動回数はa+b-2。これを満たす座標(a,b)について、a,bの最小値
#探索範囲はsqrt(N)まで、a<=b
n = int(input())
ans = n-1

for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0:
        ans = min(ans, n//i + i -2)

print(ans)


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,m,x;
 	cin>>n>>m>>x;
 	ll val[n][m];
 	ll c[n];
 	for(ll i=0;i<n;i++)
 	{
 		cin>>c[i];
 		for(ll j=0;j<m;j++)
 		{
 			cin>>val[i][j];
 		}
 	}
 	ll ans=1e9+7;
 	for(ll i=0;i<(1LL<<n);i++)
 	{
 		ll cost=0;
 		bool vali=true;
 		ll b[m]={0};
 		for(ll j=0;j<n;j++)
 		{
 			if(i&(1LL<<j))
 			{
 				cost+=c[j];
 				for(ll k=0;k<m;k++)
 				{
 					b[k]+=val[j][k];
 				}
 			}
 		}
 		for(ll k=0;k<m;k++)
 		{
 			if(b[k]<x)
 				vali=false;
 		}
 		if(vali)
 		{
 			ans=min(ans,cost);
 		}
 	}
 	if(ans==1e9+7)
 	{
 		cout<<-1<<endl;
 	}
 	else
 	{
 		cout<<ans<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>

int main(void)
{
	char s[10] = "Sunny";
	char c[10] = "Cloudy";
	char r[10] = "Rainy";
	char a[10];

	scanf("%s",&a);

	if (strcmp(s, a) == 0)
		printf("%s", c);
	if (strcmp(c, a) == 0)
		printf("%s", r);
	if (strcmp(r, a) == 0)
		printf("%s", s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int magic[24][3]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,5,6},{4,6,2},{4,2,1},
	{5,1,3},{5,3,6},{5,6,4},{5,4,1},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}
};
int t[3][3],f[3][3];
int id[3][3][3];
set<int> st;
void rec(int cnt){	//T,F,R
	if(cnt==27){
		int tmp=0;
		rep(x,3) rep(y,3) tmp+=magic[id[x][y][0]][2];
		st.insert(tmp);
		return;
	}
	int x=cnt/9,y=cnt%9/3,z=cnt%3;
	rep(i,24){
		if(x==0){
			if(t[2-y][2-z]!=0&&magic[i][0]!=t[2-y][2-z]) continue;
		}
		if(y==0){
			if(f[x][2-z]!=0&&magic[i][1]!=f[x][2-z]) continue;
		}
		if(x>0&&magic[id[x-1][y][z]][0]!=magic[i][0]) continue;
		if(y>0&&magic[id[x][y-1][z]][1]!=magic[i][1]) continue;
		if(z>0&&magic[id[x][y][z-1]][2]!=magic[i][2]) continue;
		id[x][y][z]=i;
		rec(cnt+1);
	}
}
int main(){
	int T;
	cin>>T;
	rep(tt,T){
		rep(i,3) rep(j,3) cin>>t[i][j];
		rep(i,3) rep(j,3) cin>>f[i][j];
		st.clear();
		rec(0);
		if(st.empty()) puts("0");
		else{
			int N=st.size();
			for(int x:st){
				cout<<x<<(N==1?"\n":" ");
				N--;
			}
		}
	}
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> res(N + 1);
    for(int x = 1; x <= 100; x++) {
        for(int y = 1; y <= 100; y++)
            for(int z = 1; z <= 100; z++) {
                if(x * x + y * y + z * z + x * y + y * z + z * x <= N) {
                    res[x * x + y * y + z * z + x * y + y * z + z * x]++;
                }
            }
    }
    for(int i = 1; i <= N; i++) {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

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

    if (t * s >= d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 27016
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
// Air Conditioner
int main()
{
    int X;
    cin >> X;
    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int mid(int a,int b,int c){
  return a+b+c-max(max(a,b),c)-min(min(a,b),c);
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(C - (A - B) >= 0)
    cout << C - (A - B) << endl;
    else 
    cout << 0 << endl;
}

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

const int MAX_V = 1e2;
const int MAX_LOG_V = 20;

// 入力
vector<int> G[MAX_V];           // グラフの隣接リスト表現
int root;                       // 根ノードの番号

int parent[MAX_LOG_V][MAX_V];   // 親ノード(根ノードの親は-1とする)  
int depth[MAX_V];               // 根からの深さ

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    for(int i = 0; i < G[v].size(); i++){
        if(G[v][i] != p) dfs(G[v][i], v, d + 1);
    }
}

// 初期化
void init(int V){
    // parent[0]とdepthを初期化する
    dfs(root, -1, 0);
    // parentを初期化する
    for(int k = 0; k + 1 < MAX_LOG_V; k++){
        for(int v = 0; v < V; v++){
            if( parent[k][v] < 0) parent[k+1][v] = -1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }
}

// uとvのLCAを求める
int lca(int u, int v){
    // uとvの深さが同じになるまで親をたどる
    if(depth[u] > depth[v]) swap(u,v);
    for(int k = 0; k < MAX_LOG_V; k++){
        if((depth[v] - depth[u]) >> k & 1){
            v = parent[k][v];
        }
    }
    if(u == v) return u;
    // 二分探索でLCAを求める
    for(int k = MAX_LOG_V - 1; k >= 0; k--){
        if(parent[k][u] != parent[k][v]){
            u = parent[k][u];
            v = parent[k][v];
        }
    }
    return parent[0][u];
}
vector<int> cnt;

int rec(int v, int p = -1){
    for(auto nv: G[v]){
        if(nv == p) continue;
        cnt[v] += rec(nv, v);
    }
    return cnt[v];
}

int main(){
    int V; cin >> V;
    root = 0;
    rep(i, 0, V - 1){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int M; cin >> M;
    vector<pair<int,int> > P(M);
    rep(i, 0, M){
        cin >> P[i].first >> P[i].second;
        P[i].first--;
        P[i].second--;
    }

    init(V);
    vector<int> lcaidx(M);
    rep(i, 0, M) lcaidx[i] = lca(P[i].first, P[i].second);
    //rep(i, 0, M) cerr << lcaidx[i]<< " " ;
    ll ans = 0;

    rep(i, 0, 1 << M){
        cnt = vector<int>(V, 0);
        rep(j, 0, M) if((i >> j) & 1){
            cnt[P[j].first]++;
            cnt[P[j].second]++;
            cnt[lcaidx[j]] -= 2; 
        }

        rec(0);
        int tmp{};
        rep(j, 0, V) if(cnt[j] > 0) tmp++;
        //rep(j, 0, V) cerr << j << " " << cnt[j] << endl;;
        //cerr << tmp << endl;
        if(__builtin_popcount(i) % 2 == 0) ans += (1LL << (V - 1 - tmp));
        else ans -= (1LL << (V - 1 - tmp));
        //cerr << i << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
# define ulli unsigned long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define MAX 9999999
#define MOD 1000000007
using namespace std;
//ll prime[9999999];
// //Modular Exponentiation
// ll fastExpo(ll x, ll n) {
//   if (n == 0) return 1;
//   if ((n & 1) == 0) return fastExpo((x * x) % MOD, n / 2) % MOD;
//   return ((x % MOD) * fastExpo((x * x) % MOD, (n - 1) / 2)) % MOD;
// }
//   //Euclidean Algorithm
// ll gcd(ll a, ll b) {
//   return (b == 0) ? a : gcd(b, a % b);
// }
//  // Extended Euclidean Algorithm
//   ll exgcd(ll a,ll b,ll &x, ll &y){
//   if(b==0){
//     x=1,y=0;
//     return a;
//   }
//    ll x1,y1;
//     ll d=exgcd(b,a%b,x1,y1);
//    x=y1;
//    y=x1-y1*(a/b);
//    return d;
//  }

// void sieve() {
//   prime[0] = 0;
//   prime[1] = 0;
//   for (int i = 2; i < 9999999; i++) {
//     prime[i] = 1;
//   }
//   for (int i = 2; i * i < 9999999; i++) {
//     if (prime[i] == 1) {
//       for (int j = i * i; j < 9999999; j += i) {
//         prime[j] = 0;
//       }
//     }
//   }
// }
// int fi[10009];
// void fun(){
//   for(int i=0;i<10009;i++)fi[i]=i;
//   for(int i=2;i<10009;i++)
//   {   if(fi[i]==i)
//       {
//         for(int j=i;j vt<10009;j+=i)
//         fi[j]=fi[j]*(i-1)/i;
//       }
//   }
//

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //  cout << fixed;
  // cout.precision(2);

  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; i++)cin >> a[i];
  ll mn = 0, ans = 0;
  for (ll i = 0; i < n; i++)
  {
    if (a[i] >= mn)
      mn = a[i];
    else
      ans += mn - a[i];
  }
  cout << ans << "\n";
  return 0;
}







Measured memory_bytes: 5228
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
char s[200][201];
int d[200][200];
int n;
bool is_bipartite_graph(){
    vector<int> color(n,-1);
    color[0]=0;
    queue<int> qu;
    qu.push(0);
    while(!qu.empty()){
        int i=qu.front();
        qu.pop();
        loop(j,n){
            if(s[i][j]=='1'){
                if(i==j)continue;
                if(color[j]==-1){
                    color[j]=1-color[i];
                    qu.push(j);
                }else if(color[j]==color[i]){
                    return false;
                }
            }
        }
    }
    return true;
}
int main(){
    cin >> n;
    loop(i,n)scanf("%s",s[i]);
    //二部グラフでなければ不可
    //理由：V_1, ..., V_k に分割できるなら、 V_奇数 と V_偶数 が二部グラフになっているから
    if(!is_bipartite_graph()){
        cout << -1 << endl;
        return 0;
    }
    //二部グラフのときはグラフの直径になる
    //理由：V_1,...,V_k 間はパスはあるので、直径以上の長さにはならない
    //また、直径を与えるパスの各頂点を V_1,...,V_k に入れれば、二部グラフなので過不足なく残りを割り振れる
    loop(i,n)loop(j,n)d[i][j]=((s[i][j]=='1')?1:10000);
    loop(i,n)d[i][i]=0;
    loop(k,n)loop(i,n)loop(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int ans=0;
    loop(i,n)loop(j,n)ans=max(ans,d[i][j]);
    cout << 1+ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int a,b,c,d;
  int ans = 0;

  cin >> a >> b >> c >> d;

  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      if (i == j) {
        ans++;
      }
    }
  }

  if (ans > 0) {
    ans -= 1;
  }
  else {
    ans = 0;
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import itertools

n,m,q =map(int,input().split())
a =[0]*q
b =[0]*q
c =[0]*q
d =[0]*q

for i  in range(q):
    a[i],b[i],c[i],d[i]= map(int,input().split())
    
A=list(itertools.combinations_with_replacement([i for i in range(1,m+1)],n))


g=[]
for v in A:
    e=0
    for i in range(q):
        
        if v[b[i]-1]-v[a[i]-1] ==c[i]:
            e += d[i]
            
        
    g += [e]
print(max(g))

Measured memory_bytes: 25220
fun main(args: Array<String>){
	val array = readLine()!!.split(" ")
	val n = array[0].toInt()
	val k = array[1].toInt()
	val s = readLine()!!
	
	if( n < 2 )
		println(0)
	else{
		var happy = if(s[0] == 'R' && s[1] == 'R') 1 else 0
		happy += if(s[n-1] == 'L' && s[n-2] == 'L') 1 else 0
		if( 2 < n )
			for(i in 1..n-2)
				if( s[i] == 'R' && s[i+1] == 'R' || s[i] == 'L' && s[i-1] == 'L' )
					happy++
		
		println(happy + Math.min(n - happy - 1, 2 * k))
	}
}


Measured memory_bytes: 38536
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0 )<< endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;

    if(A>B){
        cout << A + max(A-1,B) << endl;
    }
    else if(B>A){
        cout << B + max(B-1,A) << endl;
    }
    else{
        cout << 2*A  << endl;
    }
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = str(input())

l = [0]*N
count = 0

for i in range (1, N):
	if S[i-1] == 'A' and S[i] == 'C':
		count+=1
		l[i] = count
	else:
		l[i] = count

for i in range(0, Q):
	O, P = map(int, input().split())
	print(l[P-1] - l[O-1])

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

int dp[1010][1010], c[1010], d[1010];

int main()
{
  int n, m;
  cin >> n >> m;

  fill(dp[0], dp[1010], 1000000000);
  for (int i = 0; i < n; i++) cin >> d[i];
  for (int i = 0; i < m; i++) cin >> c[i];

  dp[0][0] = 0;
  for (int i = 0; i <= n; i++){
    for (int j = 0; j <= m; j++){
      dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + c[j] * d[i]);
    }
  }

  cout << dp[n][m] << '\n';
}

Measured memory_bytes: 7080
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n - 1; i++) cin >> c[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b[a[i] - 1];
		if (i < n - 1 && a[i + 1] - a[i] == 1) ans += c[a[i] - 1];
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int q;
  cin >> q;
  while(q--){
    int c,a,n;
    cin >> c >> a >> n;
    int result = 0;
    while(c>0){
      if(n>0 && a>0){
        --c;
        --a;
        --n;
        ++result;
      }else if(a>0 && c>1){
        --c;
        --c;
        --a;
        ++result;
      }else if(c>2){
        --c;
        --c;
        --c;
        ++result;
      }else{
        break;
      }
    }
    cout << result << endl;
  }
  return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    string S;
    cin >> S;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i=0; i<S.size(); i++) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"


int main() {
	string st;
	getline(cin, st);
	int a = -1;
	vector<string>anss;
	while (1) {
		int b = st.size();
		for (int i = a + 1; i < st.size(); ++i) {
			if (st[i] == ',' || st[i] == ' ' || st[i] == '.') {
				b = i;
				break;
			}
		}
		if (b == st.size())break;
		string name = st.substr(a + 1, b - a - 1);
		if (name.size() <= 6 && name.size() >= 3) {
			anss.emplace_back(name);
		}
		a = b;
	}
	for (int i = 0; i < anss.size(); ++i) {
		cout << anss[i];
		if (i == anss.size() - 1)cout << endl;
		else cout << " ";
	}
	return 0;
}

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

#define MOD (1000000007LL)

using namespace std;

int main(void){
    int A[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> A[i][j];
    }

    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++) if(A[j][k] == b) A[j][k] = 0;
        }
    }

    for(int i = 0; i < 3; i++){
        int s = 0;
        for(int j = 0; j < 3; j++){
            s += A[i][j];
        }
        if(s == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int i = 0; i < 3; i++){
        int s = 0;
        for(int j = 0; j < 3; j++){
            s += A[j][i];
        }
        if(s == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    int s = 0;
    for(int j = 0; j < 3; j++){
        s += A[j][j];
    }
    if(s == 0){
        cout << "Yes" << endl;
        return 0;
    }
    s = 0;
    for(int j = 0; j < 3; j++){
        s += A[j][2 - j];
    }
    if(s == 0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import collections
import fractions
import math
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
zero = 0
dic = {}
mod = 10**9+7
for i in range(n):
    a,b = map(int,input().split())
    rt =0
    if a==0 and b==0:
        zero+=1
        continue
    g = math.gcd(a,b)
    a = a//g
    b = b//g
    if b<0:
        a=-a
        b=-b
    if a<0 and b==0:
        a=-a
        b=-b
    if a<=0:
        rt=1
        a,b = b,-a

    if (a,b) not in dic:
        if rt==0:
            dic[(a,b)] = [1,0]
        else:
            dic[(a,b)] = [0,1]
    else:
        if rt==0:
            dic[(a,b)][0] += 1
        else:
            dic[(a,b)][1] += 1

ans = 1
for i,j in dic.values():
    tmp = pow(2,i,mod) - 1
    tmp2 = pow(2,j,mod) - 1
    su = (tmp+tmp2+1)%mod
    ans = (ans*su)%mod

ans = (ans-1+zero)%mod

print(ans)


Measured memory_bytes: 131320
# include <iostream>
# include <vector>
# include <map>
using namespace std;

int main() {
    int n, in;
    vector <int> v;
    cin >> n;
    int copy(n);
    while (n - 1) {
        cin >> in;
        v.push_back(in);
        n -= 1;
    }

    map <int, int> m;
    for (int i = 0; i < v.size(); i++) {
        m[v[i]]++;
    }
    for (int i = 1; i <= copy; i++) {
        if (m.find(i) != m.end()) cout << m[i] << "\n";
        else cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 13552