akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_by_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll x = a + b;
	ll z = n/x;
	n -= (z * x);
	if(n < a)
	cout<<(z*a + n)<<"\n";
	else cout<<(z+1)*a<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    string S;
    cin >> S;

    vector<string> answers;

    for (int i = 0; i <= 4; ++i) {
        string iter = "";
        for (int j = 0; j < 4 - i; ++j) {
            iter += "0";
        }

        for (int j = 0; j < i; ++j) {
            iter += "1";
        }

        do {
            string akiba = "AKIHABARA";
            int pivot = -1;
            for (int j = 0; j < akiba.size(); ++j) {
                if (akiba[j] == 'A') {
                    pivot++;
                    if (iter[pivot] == '1') {
                        akiba.erase(akiba.begin() + j);
                        j--;
                    }
                }
            }

            answers.push_back(akiba);
        } while (next_permutation(iter.begin(), iter.end()));
    }

    for (int i = 0; i < answers.size(); ++i) {
        if (S == answers[i]) {
            cout << "YES" << endl;
            return 0;
        }
    }

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

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

using namespace std;

int check(int a, int b) {
    int cnt = 0;
    while(a < b) {
        a *= 2;
        cnt++;
    }
    return cnt;
}

long double prob(int a) {
    long double cnt = 1.00;
    for(int i = 0; i < a; i++) {
        cnt *= 0.5;
    }
    return cnt;
} 

int main() {
    int n, k;
    cin >> n >>k;
    long double ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += prob(check(i, k)) / n;
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)

s1 = as.shift
s2 = as.inject(:+)
min = (s1 - s2).abs

while as.length > 1 do
    s1 += as[0]
    s2 -= as[0]
    min = (s1 - s2).abs if min > (s1 - s2).abs
    as.shift
end

p min

Measured memory_bytes: 15236
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define all(c) c.begin(), c.end()
int main(){
    int n; cin >> n;
    while (n--){
        string s; cin >> s;
        sort(all(s));
        int n = stoi(s);
        reverse(all(s));
        int m = stoi(s);
        cout << m - n << endl;
    }
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

//#define LOG(...) printf(__VA_ARGS__)
#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct edge{
    int to, cost, limit;
};

struct P{
    int v;
    double cost;
    int ptown,speed;

    bool operator >(const P &p)const{
        return cost>p.cost;
    }
};

#define MAX_TOWN 31
#define MAX_V 31
#define INF INT64_MAX
double d[MAX_TOWN][MAX_TOWN][MAX_V];//town, from, v

int main() {
    int town, road, s, g;
    while(cin >> town >> road, town|road){
        cin >> s >> g;

        fill_n((double*)d, MAX_TOWN*MAX_TOWN*MAX_V, INF);

        vector<vector<edge> > G(town+1);
        REP(i, road){
            int from,to,cost,limit;
            cin >> from >> to >> cost >> limit;
            G[from].push_back((edge){to, cost, limit});
            G[to].push_back((edge){from, cost, limit});
        }

        d[s][0][1]=0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.push((P){s,0,-1,1});

        double ans = INF;

        while(!que.empty()){
            P p=que.top();que.pop();
            int v=p.v;
            int sp=p.speed;
//            LOG("town %d speed %d cost %f\n",v,sp,p.cost);

            if(v==g&&sp==1){
                ans = d[g][p.ptown][1];
                break;
            }

            if(d[v][p.ptown][sp]<p.cost)continue;
            REP(i, G[v].size()){
                edge e=G[v][i];
                if(p.ptown==e.to)continue;

                for(int i=-1;i<=1;i++){
                    if(i!=0&&p.cost==0){
                        continue;
                    }
                    int nexts=sp+i;
                    if(nexts<=0||30<nexts)continue;
                    if(nexts>e.limit)continue;
                    double time=p.cost+(double)e.cost/(double)nexts;
                    if(d[e.to][v][nexts]>time){
                        d[e.to][v][nexts]=time;
                        que.push((P){e.to,time,v,nexts});
                    }
                }
            }
        }

        if(ans==INF)
            printf("unreachable\n");
        else
            printf("%0.5f\n",ans);
    }
}

Measured memory_bytes: 1960
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        HashMap<String, Integer> wordCnt = new HashMap<String, Integer>();
        String longWord = "";
        String freqWord = "";
        wordCnt.put(freqWord, 0);
        
        while (scanner.hasNext()) {
            String input = scanner.nextLine();
            String[] strList = input.split(" ");
            
            for (int i = 0; i < strList.length; i++) {
                String tmpWord = strList[i];
                if (wordCnt.get(tmpWord) == null) {
                    wordCnt.put(tmpWord, 1);
                } else {
                    wordCnt.put(tmpWord, wordCnt.get(tmpWord)+1);
                }
                if (tmpWord.length() > longWord.length()) {
                    longWord = new String(tmpWord);
                }
                if (wordCnt.get(tmpWord) > wordCnt.get(freqWord)) {
                    freqWord = new String(tmpWord);
                }
            }
        }
        System.out.println(freqWord + " " + longWord);
    }
}

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

int main(){
    int x,y;
    cin >> x >> y;
    if(x%y==0) cout << -1 << endl;
    else{
        for(int i=1;;i++){
            if((x*i)%y==0) continue;
            else{
                cout << x*i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
int main() {
    for (int i = 0; i < 3; ++i) {
        string s;
        cin >> s;
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string a, b;
	cin >> a ;
	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) { b = "Bad"; }
	else { b = "Good"; }
	cout << b << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        ll a;
        cin >> a;
        a--;
        A[a] = i;
    }

    std::set<ll> s;
    s.insert(-1);
    s.insert(N);
    ll ans = 0;
    REP(i, N) {
        ll index = A[i];
        auto it = s.lower_bound(index);
        ll t = *it - index;
        it--;
        t *= index - *it;
        ans += (i + 1) * t;
        s.insert(index);
    }
    cout << ans << endl;
    return 0;
}

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

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

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

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

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

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

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

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

void solve(void)
{
  string str; cin >> str;
  set<char> s{str.begin(), str.end()};
  auto a = (s.find('N') != s.end()) == (s.find('S') != s.end());
  auto b = (s.find('W') != s.end()) == (s.find('E') != s.end());
  auto ans = a && b;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        long[] x = new long[N];
        for (int i = 0; i < N; i++) x[i] = sc.nextLong();

        long ans = Long.MAX_VALUE;
        for(int i = 0; i+K-1 < N; i++){
            long xl = x[i];
            long xr = x[i+K-1];

            if(xl < 0 && xr <= 0){
                ans = Math.min(ans, -xl);
            } else if (xl >= 0 && xr > 0){
                ans = Math.min(ans, xr);
            } else {  // xl <= 0, 0 <= xr
                ans = Math.min(ans, Math.min(-xl, xr) + xr - xl);
            }
        }

        out.println(ans);
    }
}


Measured memory_bytes: 49868
import math

A, B = map(int, input().split())

if math.ceil(A / 0.08) < math.ceil(B / 0.1):
  start_plice = math.ceil(A / 0.08)
  
  while True:
    if math.floor(start_plice * 0.08) > A:
      print(-1)
      break

    if math.floor(start_plice * 0.1) >= B:
      print(start_plice)
      break

    start_plice += 1
    
else:
  start_plice = math.ceil(B / 0.1)
  
  while True:
    if math.floor(start_plice * 0.1) > B:
      print(-1)
      break

    if math.floor(start_plice * 0.08) >= A:
      print(start_plice)
      break

    start_plice += 1

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	
	ll K, N;
	cin >> K >> N;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll m = K - A[N] + A[1];
	
	repn(i, N - 1) {
		m = max(m, A[i + 1] - A[i]);
	}

	cout << K - m;

	system("PAUSE");
}


Measured memory_bytes: 2040
n = int(input())
S = [input() for i in range(n)]

d = {}
for s in S:
    c = s[0]
    if c not in 'MARCH': continue
    if c in d:
        d[c]+=1
    else:
        d[c] = 1

if len(d) <= 2:
    print(0)
    exit()

d_list = list(d.values());
n = len(d_list)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            ans += d_list[i] * d_list[j] * d_list[k]

print(ans)


Measured memory_bytes: 9752
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let s = sc.next_vec_char();
    let mut ans = s[0] == 'A';
    let mut c = 0;
    for i in 1..s.len() {
        if i > 1 && i < s.len() - 1 {
            ans &= s[i].is_lowercase() || s[i] == 'C';
            if s[i] == 'C' {
                c += 1;
            }
        } else {
            ans &= s[i].is_lowercase();
        }
    }
    if ans && c == 1 {
        println!("AC");
    } else {
        println!("WA");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

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

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

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

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		vector<int> v(n);
		for(int& t : v) cin >> t;
		vector<int> appear(10000, 0);
		for(int i=0;i<v.size();i++){
			int cur = 0;
			for(int j=0;j<4&&i+j<v.size();j++){
				cur = 10*cur+v[i+j];
				appear[cur] = 1;
			}
		}
		for(int i=0;i<10000;i++){
			if(appear[i] == 0){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3144
N = int(input())
A = [int(i) for i in input().split()]

tmax = A[0]
humidai = 0
humidai_sum = 0

for a in A :
  if tmax > a:
    humidai = tmax - a
    humidai_sum += humidai
  else :
    tmax = a
    
print(humidai_sum)

Measured memory_bytes: 32140
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.sort()
a.append(10 ** 9 + 7)

memo = [None] * (N + 1)
memo[0] = 1

idx = 0
for pos in range(1, N + 1):
    if a[idx] == pos:
        memo[pos] = 0
        idx += 1
        continue
    else:
        if pos > a[idx]:
            idx += 1
        #
        if pos == 1:
            memo[1] = (memo[0]) % (10 ** 9 + 7)
        else:
            memo[pos] = (memo[pos - 2] + memo[pos - 1]) % (10 ** 9 + 7)

# print("#", memo)
print(memo[-1])

Measured memory_bytes: 7844
#include<cstdio>
#include<algorithm>
using namespace std;

int n, v[100], w[100], W, dp[10001];

int main() {
  scanf("%d%d", &n, &W);
  for (int i = 0; i < n; i++) scanf("%d%d", &v[i], &w[i]);
  for (int i = 0; i < n; i++) {
    for (int j = W; j >= w[i]; j--) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
  }
  printf("%d\n", dp[W]);
}




Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,a,b;
  cin>>n;
  cout<<50<<endl;
  a=n/50;
  b=n%50;
  for(int i=0;i<b;i++){
    cout<<50+a-i<<" ";
  }
  for(int i=b;i<50;i++){
    cout<<max(0LL,49+a-i)<<" ";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, k;
    cin >> n >> k;
    vi dp(n + 1, 1e9);
    dp[1] = 0;
    vi hs(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> hs[i + 1];
    }

    for (int i = 2; i <= n; i++) {
        i64 nin = 1e18;
        for (int j = 1; j <= k; j++) {
            if (i - j >= 1) {
                nin = min(nin, dp[i - j] + abs(hs[i] - hs[i - j]));
            }
        }
        dp[i] = nin;
    }

    cout << dp.back() << endl;
}

Measured memory_bytes: 1792
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def cum_2d(field:list):
    row = len(field)
    col = len(field[0])
    
    # 横方向に累積和
    for r in range(row):
        for c in range(col-1):
            field[r][c+1] += field[r][c]
    
    # 縦方向に累積和
    for c in range(col):
        for r in range(row-1):
            field[r+1][c] += field[r][c]
            
    return field

def compress(xy_row: list, x_compressor, y_compressor):
    xy_comped = []
    for xi, yi in xy_row:
        xy_comped.append((x_compressor[xi], y_compressor[yi]))
        
    return xy_comped

def decompress(comped: list, x_decomp, y_decomp):
    xy_decomped = []
    for xi, yi in comped:
        xy_decomped.append((x_decomp[xi], y_decomp[yi]))
        
    return xy_decomped

n,k = li()
xy_row = [tuple(li()) for _ in range(n)]

x_row = [x for x, _ in sorted(xy_row, key=lambda x:x[0])]
y_row = [y for _, y in sorted(xy_row, key=lambda y:y[1])]

x_compressor = {xi: i+1 for i, xi in enumerate(x_row)}
y_compressor = {yi: i+1 for i, yi in enumerate(y_row)}
x_decomp = {i+1: xi for i, xi in enumerate(x_row)}
y_decomp = {i+1: yi for i, yi in enumerate(y_row)}

xy_comped = compress(xy_row, x_compressor, y_compressor)


grid = [[0]*(len(xy_comped)+1) for _ in range(len(xy_comped)+1)]
for xi, yi in xy_comped:
    grid[xi][yi] += 1
    
grid = cum_2d(grid)

ans = float('inf')

for xleft in range(1,n+1):
    for xright in range(xleft, n+1):
        for ylow in range(1,n+1):
            for yhigh in range(ylow, n+1):
                if grid[xright][yhigh] - grid[xright][ylow-1] - grid[xleft-1][yhigh] + grid[xleft-1][ylow-1] < k:
                    continue
                
                xnw = x_decomp[xleft]
                xne = x_decomp[xright]
                
                yne = y_decomp[yhigh]
                yse = y_decomp[ylow]

                ans = min(ans, (xne-xnw)*(yne-yse))
                
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  bool flag = true;
  rep(i, n){
    if (i % 2 == 0 && s[i] == 'L' ||
        i % 2 == 1 && s[i] == 'R') flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

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

count = [0]*(M+1)
for i in range(N):
    for j in range(KA[i][0]):
        count[KA[i][j+1]] += 1
ans=0
for i in range(1,M+1):
    if count[i] == N:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int mood(int a, int b){
    if (a % b == 0) return b;
    else return a % b;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n/2){
        if (s[i] != s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def main():
    N, Y = map(int, input().split())

    for i in range(0, N+1):
        for j in range(0, (N+1)-i):
            if(10000*i+5000*j+1000*(N-i-j) == Y):
                print("{0} {1} {2}".format(i,j,N-i-j))
                sys.exit()

    print("-1 -1 -1")

main()

Measured memory_bytes: 3060
n=int(input())
P=list(map(int,input().split()))
ans=0
for i in range(n-2):
    if P[i]<P[i+1] and P[i+1]<P[i+2]:
        ans+=1
    elif P[i]>P[i+1] and P[i+1]>P[i+2]:
        ans+=1
print(ans)

Measured memory_bytes: 38352
def next_num(num):
	if num == 0:
		return 3
	elif num % 10 == 3:
		return num + 2
	elif num % 10 == 5:
		return num + 2
	elif num % 10 == 7:
		return next_num(num//10) * 10 + 3

def is_357(num):
	flg = [False for i in range(3)]
	num = str(num)
	for c in num:
		if c == '3':
			flg[0] = True
		elif c == '5':
			flg[1] = True
		elif c == '7':
			flg[2] = True
		else:
			return False
	return all(flg)



N = int(input())

num = 357
counter = 0

while num <= N:
	if is_357(num):
		counter += 1
	
	digit = num % 10
	
	if digit == 3 or digit == 5:
		num += 2
	else:
		num = next_num(num)


print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
ll gcd(ll a, ll b) {
    if (b == 0)return a;
    else return gcd(b, a % b);
}
ll lcm(ll a, ll  b) {
    return a*b/gcd(a, b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int,int> v;
    for (int i = 0; i < n; ++i) {
        int in;
        cin >> in;
        v[in]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int in;
        cin >> in;
        v[in]--;
        //cout << v[in] << in << endl;
    }
    for (auto i = v.begin(); i != v.end(); ++i) {
        if (i->second < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    bool answer = false;

    int a, b;
    int i = 0;

    a = y;
    b = a;

    while (i <= x){
        a = y - i * 2;
        b = a - (x - i) * 4;

        if (b == 0){
            answer = true;
            break;
        } 

        i++;
    }

    if( answer == true ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  string day[7];
  day[2]="sat";
  day[3]="sun";
  day[4]="mon";
  day[5]="tue";
  day[6]="wed";
  day[0]="thu";
  day[1]="fri";
  cin >> n ;
  cout << day[n%7] << endl;
  return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int ball[200005];
vector<int> v1;
int main(){
	int n,t;
	int i,j,k;
	int a,b,c;
	cin>>n>>t;
	for(i=0;i<n;i++){
		cin>>a;
		ball[a-1]++;
	}
	for(i=0;i<n;i++){
		if(ball[i]==0)continue;
		v1.push_back(ball[i]);
	}
	sort(v1.begin(),v1.end());
	if(v1.size()<=t){
		cout<<0<<endl;
		return 0;
	}
	for(a=0,i=0;i<(v1.size()-t);i++){
		a+=v1[i];
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int a,b;
bool check(int n){
int sum=0;
while(n){
    sum+=n%10;
    n/=10;
}
if(sum>=a&&sum<=b)return true;
return false;
}
int main(){
int n;
cin>>n>>a>>b;
long long sum=0;
for(int i=1;i<=n;i++){
    if(check(i))sum+=i;
}
cout<<sum;
    return 0 ;
}


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

int main(){
  int n;
  cin >>n;
  map<string,int>a;
  string s;
  for(int i=0;i<n;i++){
    cin >>s;
    a[s]=1;
  }
  int ans=0;
  for(auto x:a){
    ans++;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 19092
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}

		// 計算
		String result = "No";
        HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
			if(hm.get(a[i]) == null){
			    hm.put(a[i], 1);
			}else{
			    int v = hm.get(a[i]);
			    hm.put(a[i], v + 1);
			}
		}
		if(hm.keySet().size() == 1 && hm.keySet().contains(0)){
		    result = "Yes";
		}else if(hm.keySet().size() == 2){
		    if(hm.get(0) != null && hm.get(0) == n/3){
		        result = "Yes";
		    }else{
		        result = "No";
		    } 
		}else if(hm.keySet().size() == 3){
		    result = "Yes";
		    int v = 0;
		    for(int i : hm.keySet()){
		        if(v == 0) v = hm.get(i);
	            if(v != hm.get(i)) result = "No";
		    }
	        ArrayList<Integer> list = new ArrayList<Integer>(hm.keySet());
	        if((list.get(0).intValue() ^ list.get(1).intValue()) != list.get(2).intValue()) result = "No";
		}
		
		// 出力
		System.out.println(result);
	}
	
}


Measured memory_bytes: 50748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && b >= c)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


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

// fundamental
using ll = long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,s,n) for (ll i = (s); i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(x) ((ll)1e##x)
#define MAXC(c,x) (c = max(c, x))
#define MINC(c,x) (c = min(c, x))
const ll mod = TEN(9) + 7;

// vector
using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> typename enable_if<N==1, vector<T>>::type { return vector<T>(size); }
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> vector<decltype(mdv<T, N - 1>())> { return vector<decltype(mdv<T, N - 1>())>(size); }
template<class T, size_t N, class A, class... B> auto mdv(A size, B... rest) -> typename enable_if<N!=1, vector<decltype(mdv<T, N - 1>(rest...))>>::type { return vector<decltype(mdv<T, N - 1>(rest...))>(size, mdv<T, N - 1>(rest...)); }
template<class T, class... A> auto mdv(A... size) -> decltype(mdv<T, sizeof...(size), A...>(size...)) { return mdv<T, sizeof...(size), A...>(size...); }
// template<size_t N, class A, class... B> auto mdvl(A size, B... rest) -> decltype(mdv<N, ll, A, B...>(size, rest...)) { return mdv<N, ll, A, B...>(size, rest...); }

// template<class T, class A> auto mdv(A size) -> vector<T> { return vector<T>(size); }
// template<class T, class A, class... B> auto mdv(A size, B... rest) -> vector<decltype(mdv<T>(rest...))> { return vector<decltype(mdv<T>(rest...))>(size, mdv<T>(rest...)); }

// io
template<class T> istream& operator >>(istream& is, vector<T>& vec){ for(T& x: vec) is >> x; return is; }
template<class T, class U> istream& operator >>(istream& is, pair<T, U>& p){ is >> p.first >> p.second; return is; }
template<class T> void input(T& t) { cin >> t; assert(cin); } template<class T, class... Ts> void input(T& t, Ts&... ts) { cin >> t; input(ts...); }
template<class T> void print(T&& t) { cout << t; } template<class T, class... Ts> void print(T&& t, Ts&&... ts) { cout << t; print(ts...); }
template<class T> void println(T&& t) { cout << t << endl; } template<class T, class... Ts> void println(T&& t, Ts&&... ts) { cout << t; println(ts...); }
template<class T> string join(const vector<T>& v, const string & sep) { stringstream ss; REP(i, v.size()) ss << (i != 0 ? sep : "") << v[i]; return ss.str(); }

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(50);
    string s; cin >> s;
    ll cnt = 0, ans = 0;
    bool b = false;
    ll i = 0;
    while(i < s.size()) {
        if (s[i] == 'A') {
            cnt++;
            i += 1;
        } else if (i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
            ans += cnt;
            i += 2;
        } else {
            cnt = 0;
            i += 1;
        }
    }
    cout << ans << endl;
}


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

#define llint long long int

using namespace std;

int main(){
    int A, B;

    cin >> A >> B;

    if((A + B) % 2 == 0){
        cout << (A + B) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[11],t[11];
	int i,flg,len;
	scanf("%s %s",s,t);
	len=strlen(s);
	flg=0;
	for(i=0;i<len;i++){
		if(s[i]!=t[i]){
			flg=1;
			break;
		}
	}
	if(flg==0)  printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

int main()
{
    int r, D, x; cin >> r >> D >> x;
    int arr[20];
    arr[0] = x;
    for(int i = 1; i < 11; ++i) {
        arr[i] = r * arr[i-1] - D;
    }
    for(int i = 1; i < 11; ++i) {
        cout << arr[i] << "\n";
    }
    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    if(n % 2){
        cout << "No" << endl;
        return 0;
    }
    n /= 2;
    rep(i, n){
        if(s[i] != s[i+n]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//    ŦĦ€Ř€'Ş ŇØŦĦƗŇǤ ĦØŁĐƗ'Ň Μ€ βΔĆҜ ΔŁŴΔ¥Ş ΔŇĐ ₣ØŘ€V€Ř 😈🤩😇😈💪🤜👊🤛🤟😉🤩:

#include<bits/stdc++.h>

#define mod 1000003
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define B(a) a.begin()
#define E(a) a.end()
#define For(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M_P make_pair
#define P_B push_back

using namespace std;

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

    string s;cin>>s;
    vi a;
    int cnt=0;

    For(i,0,s.length())
    {
        if(s[i]=='S')
            continue;

        while(s[i]=='R')
        {
            i++;
            cnt++;
        }

        a.P_B(cnt);
        cnt=0;

    }

    sort(rall(a));

    if(a.empty())
        cout<<"0";

    else
    cout<<a[0];



    return 0;
}


Measured memory_bytes: 3652
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    H,W = LMIIS()
    N = II()
    A = LMIIS()
    ai = 0
    for i in range(H):
        
        line = deque()

        # from left to right
        if i % 2 == 0:
            j = 0
            while j < W:
                while j < W and A[ai] > 0:
                    # line += str(ai+1)
                    line.append(ai+1)
                    A[ai] -= 1
                    j += 1
                if A[ai] == 0 and ai < N-1:
                    ai += 1

            print(*line)
        # from right to left
        else:

            j = W-1
            while 0 <= j:
                while 0 <= j and A[ai] > 0:
                    # line += str(ai+1)
                    line.appendleft(ai+1)
                    A[ai] -= 1
                    j -= 1
                if A[ai] == 0 and ai < N-1:
                    ai += 1
            # print(line[::-1])
            print(*line)




    

if __name__ == '__main__':
    main()

Measured memory_bytes: 68332
#! python3
# coding:utf-8

n = int(input())

s = [input() for _ in range(n)]
# print(s)

c0=0
c1=0
c2=0
c3=0
for i in s:
    if i == "AC":
        c0+=1
    elif i == "WA":
        c1+=1
    elif i == "TLE":
        c2+=1
    else:
        c3+=1

print("AC x",c0)
print("WA x",c1)
print("TLE x",c2)
print("RE x",c3)


Measured memory_bytes: 16336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int xy[10][10];

void set(int x, int y)
{
    if(x>=0 && y>=0 && x<=9 && y<=9)
        xy[x][y]++;
}

int main(void)
{
    int size, x, y, white, deep;
    while(~scanf("%d,%d,%d", &x, &y, &size))
    {
        if(size >= 1)
        {
            set(x,y);
            set(x,y-1);
            set(x,y+1);
            set(x-1,y);
            set(x+1,y);
        }
        if(size >= 2)
        {
            set(x+1,y+1);
            set(x+1,y-1);
            set(x-1,y+1);
            set(x-1,y-1);
        }
        if(size == 3)
        {
            set(x+2,y);
            set(x-2,y);
            set(x,y+2);
            set(x,y-2);
        }
    }
    
    white = 0;
    deep = 0;
    rep(i,10)
    {
        rep(j,10)
        {
            if(xy[i][j] == 0)
                white++;
            if(deep < xy[i][j])
                deep = xy[i][j];
        }
    }
    
    cout << white << endl << deep << endl;

    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#define pb push_back
     
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


void solve(ll casen)
{
    ll res = 0;
    
    cout << "Case #" << casen << ": " << res << endl;
}

int main()
{
    // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp

    // !!! Here, unordered map was too slow!!!
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    
   ll k;
   string s;
   cin >> k >> s;

   if (s.length() <= k)
   {
        cout << s << endl;
   }
   else
   {
        cout << s.substr(0,k) + "..." << endl;
   }

    return 0;
}

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


int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n)
    cin >> v[i];
  sort(v.begin(), v.end());
  double ans = (v[0] + v[1]) / 2.;
  for (int i=2; i<n; i++)
    ans = (ans + v[i]) / 2.;
  printf("%.6lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
cnt = 0
endA = 0
startB = 0
both = 0
for i in range(N):
	s = input()
	flgA = s[-1] == "A"
	flgB = s[0] == "B"
	if flgA and flgB:
		both += 1
	elif flgA:
		endA += 1
	elif flgB:
		startB += 1
	cnt += s.count("AB")

if both > 0:
	if both > 1:
		cnt += both - 1
	if endA > 0:
		cnt += 1
		endA -= 1
	if startB > 0:
		cnt += 1
		startB -= 1
cnt += min(endA, startB)
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n,m;
	std::cin >> n>>m;
	vvector(a,int,n,m,0);
	std::vector<int> v(m);
	rep(i,n)rep(j,m)std::cin >> a[i][j];
	rep(i,m)std::cin >> v[i];
	rep(i,n){
		int ans=0;
		rep(j,m)ans+=a[i][j]*v[j];
		std::cout << ans << std::endl;
	}
}


Measured memory_bytes: 3212
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    string s;
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    if (s.size() < 26) {
        char e[26]; fill(e, e+26, 0);
        for (char ch : s) e[ch - 'a'] = 1;

        for (int i = 0; i < 26; ++i) {
            if (e[i] == 0) {
                s.push_back('a'+i);
                break;
            }
        }
        cout << s << endl;
    } else {
        bool ok = false;
        for (int i = 25; i >= 0; --i) {
            char nc = 127;
            for (int j = i+1; j < 26; ++j) {
                if (s[i] < s[j]) {
                    nc = min(nc, s[j]);
                }
            }

            if (nc < 127) {
                ok = true;
                s.resize(i+1);
                s[i] = nc;
                break;
            }
        }

        if (ok) {
            cout << s << endl;
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#pragma GCC optimize ("O3")
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 5e5+9;
const double pi=3.14159265358979323846264;
const int inf = 2e9;
const ll mod = 998244353;

int main()
{
    ios::sync_with_stdio(false);
    int n1,m1,n2,m2,k;
    cin>>n1>>m1>>n2>>m2>>k;
    int p=n1*60+m1,q=n2*60+m2;
    cout<<q-k-p;
    return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <algorithm>

const int MAXN = 200005;

struct BIT {
    long long a[MAXN];
    int n;

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

    void update(int pos, long long d) {
        for (int i = pos; i <= n; i += lowbit(i)) a[i] = std::max(a[i], d);
    }

    long long query(int pos) {
        long long res = 0;
        for (int i = pos; i; i -= lowbit(i)) res = std::max(res, a[i]);
        return res;
    }
} bit;

int a[MAXN], h[MAXN];

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    bit.n = n;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long f = bit.query(h[i]) + a[i];
        ans = std::max(ans, f);
        bit.update(h[i], f);
    }

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

Measured memory_bytes: 3328
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
	ll n; cin >> n;
	string s; cin >> s;
	ll r = 0;
	for(auto x: s) if(x == 'R') r++;
	ll ans = r, w = 0;
	debug(r);
	for(int i = 0; i < n; i++) {
		if(s[i] == 'R') r--;
		else w++;
		if(s[i] == 'R') {
			if(w > r) break;
			else ans = min(ans, r);
			debug(ans);
		}
	}
	cout << ans << endl;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


Measured memory_bytes: 3732