akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  Competitive
//
//  Created by Ashutosh Tiwari on 16/05/20.
//  Copyright © 2020 Ashutosh Tiwari. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <climits>
#include <functional>
#include <unordered_map>
#include <tuple>
#include <iterator>
#include <unordered_set>
#include <chrono>
#include <zconf.h>

using namespace std;

int solve(vector<int>& frog, int N) {
    vector<int> dp(frog.size(), INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < frog.size(); i ++) {
        for (int j = i + 1; j <= i + N; j ++) {
            if (j < frog.size())
                dp[j] = min(dp[j], dp[i] + abs(frog[i] - frog[j]));
        }
    }
//    for (int i = 0; i < frog.size(); i ++) {
//        cout << i << " << " << dp[i]  << " << " << frog[i] << endl;
//    }
    return dp[frog.size() - 1];
}
int main()
{
    ios_base::sync_with_stdio(false);
//    cout << get_current_dir() << endl;
//        freopen("../in.txt", "r", stdin);

//    vector<int> v = {10, 15, 20};

    int T, N;
    cin >> T >> N;

    vector<int> frog(T);
    for (int i = 0; i < T; i ++) cin >> frog[i];
    cout << solve(frog, N) << endl;

    return 0;
}

Measured memory_bytes: 1024
H, W, K =map(int, input().split())

arr= [list(input()) for _ in range(H)]
ans=0

for paint_h in range(2**H):
	for paint_w in range(2**W):
		cnt=0
		for i in range(H):
			for j in range(W):
				if (paint_h>>i)&1==0 and (paint_w>>j)&1==0:
					if arr[i][j]=="#":
						cnt+=1

		if cnt==K:
			ans+=1
print(ans) 

Measured memory_bytes: 9112
import java.util.*;
import java.math.*;
public class Main {
	static int x;
	static int ans;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		Room[] room = new Room[n];
		int[] visited = new int[n];
		int[] ans = new int[n];
		for(int i = 0; i < n; i++) {
			room[i] = new Room(i, 1000000000);
		}
		for(int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			room[a].list.add(b);
			room[b].list.add(a);
		}
		room[0].size = 0;
		PriorityQueue<Room> queue = new PriorityQueue<>();
		queue.add(room[0]);
		int cnt = 0;
		while(queue.size() > 0) {
			Room cur = queue.poll();
			if(visited[cur.index] == 1) continue;
			cnt += 1;
			visited[cur.index] = 1;
			ans[cur.index] = cur.brought;
			for(int x : cur.list) {
				if(visited[x] == 0) {
					if(room[cur.index].size + 1 < room[x].size) {
						room[x].size = room[cur.index].size + 1;
						room[x].brought = cur.index;
					}
					queue.add(room[x]);
				}
			}
		}
		if(cnt != n) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
			for(int i = 1; i < n; i++) {
				System.out.println(ans[i] + 1);
			}
		}
	}
}
class Room implements Comparable<Room> {
	int index;
	int brought;
	Integer size;
	List<Integer> list = new ArrayList<>();
	public Room(int index, int size) {
		this.index = index;
		this.size = size;
	}
	@Override
	public int compareTo(Room obj) {
		return this.size.compareTo(obj.size);
	}
}

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

int main()
{
	int n;
	cin>>n;
	vector<string> D(10);
	D[0]="";
	D[1]=".,!? ";
	D[2]="abc";
	D[3]="def";
	D[4]="ghi";
	D[5]="jkl";
	D[6]="mno";
	D[7]="pqrs";
	D[8]="tuv";
	D[9]="wxyz";

	for(int i=0;i<n;i++){
		string s;
		cin>>s;

		int pos=0;
		int now=-1;
		int count=0;
		while(pos<s.size()){
			if(s[pos]=='0'){
				if(now<0){pos++;continue;}
				count%=D[now].size();
				cout<<D[now][count];
				count=0;
				pos++;
				now=-1;
			}
			else{
				if(now<0){
					now=s[pos]-'0';
					count=0;
					
				}
				else count++;
				pos++;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/



int main() {

	ll n, k;
	cin >> n >> k;
	ll red = n - k;
	ll inside = k - 1;

	Combination comb(2050);


	for (int i = 1; i <= k; i++)
	{
		cout << comb.C(k - 1, i - 1)*comb.C(n - k + 1, i) % MOD << endl;

	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  string s;
  cin >> s;
  if(s[s.size()-1]=='s')cout << s+"es" << endl;
  else cout << s+'s' << endl;
}


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

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


int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> ans(n + 1);
	for(int i = 1; i <= n; i++)cin >> a[i];

	for(int i = n; i >= 1; i--) {
		int cnt = 0;
		for(int j = i; j <= n; j += i)cnt += ans[j];
		if(a[i] != cnt % 2)ans[i]++;
	}
	cout << count(ans.begin(), ans.end(), 1) << endl;
	for(int i = 1; i <= n; i++) {
		if(ans[i])cout << i << endl;
	}
}

Measured memory_bytes: 2432
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
const ll P = 1e9+7;
int N, M, A[Nmax];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++) cin >> A[i];

	vector<ll> dp(N+1);
	dp[0] = 1;

	for(int i=0; i<N; i++){
		auto lb = lower_bound(A, A+M, i+1);
		if(lb != A+M && *lb == i+1){
			dp[i+1] = 0;
		} else {
			dp[i+1] = (dp[i] + (i==0?0:dp[i-1])) % P;
		}
		//cout << i+1 << " " << dp[i+1] << endl;
	}

	cout << dp[N] << endl;

	return 0;
}


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

int N,a[2*100000+10],M=0,num[2*100000+10];
vector<int> ans;

signed main(){
  cin >> N;
  for(int i=1;i<=N;i++) cin >> a[i];
  int i;
  for(i=N;i>=N/2+1;i--){
    if(a[i]==0);
    else{
      M++;
      ans.push_back(i);
      num[i]++;
    }
  }
  for(i=N/2;i>=1;i--){
    int j=2;
    int sum=0;
    while(i*j<=N){
      sum+=num[i*j];
      j++;
    }
    if(sum%2==a[i]);
    else{
      M++;
      ans.push_back(i);
      num[i]++;
    }
  }
  cout << M << endl;
  if(M==0) return 0;
  for(int k=0;k<ans.size()-1;k++) cout << ans[k] << " ";
  cout << ans[ans.size()-1] << endl;
  return 0;
}


Measured memory_bytes: 4852
def print_board(A,n):
	for i in range(n):
		s = ""
		for j in range(n):
			st = str(A[i][j])
			if len(st) == 1:
				s += "   "
			elif len(st) == 2:
				s += "  "
			elif len(st) == 3:
				s += " "

			s += str(st)
		print(s)


def check_leftdown(A,h,w,n):
	if h + 1 > n - 1:
		#下に抜けるならば,左に-1してその列に値が入っていない箇所を探す
		w -= 1

		for x in range(n):
			if A[x][w] == 0:
				h = x
				break

	else:
		#左に抜けるならば
		if w - 1 < 0:
			w = n
			h += 1
		else:
			h += 1
			w -= 1

	return h,w

def check_rightdown(A,h,w,n):
	if h + 1 > n - 1:

		#下にも右にも抜ける場合
		if w + 1 > n - 1:
			None
		else:
			#下に抜けるならば,右に＋1してその列に値が入っていない箇所を探す
			w += 1

		for x in range(n):
			if A[x][w] == 0:
				h = x
				break

	else:
		if w + 1 > n - 1:
		#右に抜けるならば
			w = 0
			h += 1
		else:
			#通常パターン
			h += 1
			w += 1
			if A[h][w] != 0:
				#値が既に埋まっている
				#左下をチェック
				h,w = check_leftdown(A,h,w,n)

	return h,w

if __name__ == '__main__':

	while True:
		try:
			n = int(input())

			if n == 0:
				break

			A = [[0 for i in range(n)] for j in range(n)]

			cnt = n * n
			for x in range(cnt):
				if x == 0:
					mid = n // 2
					h = mid + 1
					w = mid
					A[h][w] = x + 1
				else:
					h,w = check_rightdown(A,h,w,n)
					A[h][w] = x+1

			print_board(A,n)

		except EOFError:
			break




Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    int n;cin>>n;
    cout<<n*n*n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;  
  cin>>n;
  int sum=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    int w; cin>>w;
    vec[i]=w;
    sum+=w;
  }
  vector<int>vecsum(n);
  int sum1=0,sum2=0;
    for(int i=0;i<n;i++){
      sum1+=vec[i];
      sum2=sum-sum1;
      vecsum[i]=abs(sum2-sum1);
      
    }
  sort(vecsum.begin(),vecsum.end());
  	cout<<vecsum[0]<<endl;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
from numba import njit
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=readline().strip()
    ans=s.count("R")*s.count("G")*s.count("B")
    s=np.array([0 if s[i]=="R" else 1 if s[i]=="G" else 2 for i in range(n)],dtype=np.int64)

    print(f(n,ans,s))

@njit(cache=True)
def f(n,ans,s):
    for i in range(n):
        for j in range(i+1,n):
            k=2*j-i
            if k>=n: break
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans-=1
    return ans

if __name__=="__main__":
    main()

Measured memory_bytes: 110176
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    while(true){
	real n = readln().chomp().to!real;
	if(n==-1) break;
	real m;
	m = n/2.0;
	while(abs(pow(m,3)-n) >= n*(1e-5)){
	    m = m - (pow(m,3) - n)/(3*m*m);
	}
	writef("%.6f\n",m);
    }

}

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

int main() {
    string S;
    cin >> S;
 
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: u32,
        a: u32,
        b: u32,
    };
    let s: u32 = (0..=n)
        .filter_map(|c| {
            let s = sum_digit(c);
            if s >= a && s <= b {
                Some(c)
            } else {
                None
            }
        })
        .sum();
    println!("{}", s);
}

fn sum_digit(n: u32) -> u32 {
    n.to_string()
        .chars()
        .map(|c| c.to_digit(10).unwrap())
        .sum::<u32>()
}


Measured memory_bytes: 2088
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  lint res=0;
  for(int i=1;i<=n;i++){
    lint cnt=n/i;
    lint tmp_res=cnt*(2*i+(cnt-1)*i)/2;
    res+=tmp_res;
  }
  cout<<res<<endl;

  return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    string s;
    cin >> n >> s;

    ll ret = 0;
    REP(i, n-2) if(s.substr(i, 3) == "ABC") ret++;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	int N, L;
	cin >> N >> L;
	
	string box[101] = {};
	for(int i = 0; i < N; ++i){
		cin >> box[i];
	}


	string ans = "";

	for(int i = 0; i < N - 1; ++i){
		for(int j = i + 1; j < N; ++j){
			if(box[i] > box[j]){
				string tmp = box[i];
				box[i] = box[j];
				box[j] = tmp;
			}
		}
	}

	for(int i = 0; i < N; ++i){
		ans += box[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n ,total=0 ,x ,y;
  for( int i=0 ; i<4 ; i++ ){
    cin >> n;
    total += n;
  }

  if( total >= 60 ){
    x = total / 60;
    total %= 60;
  }

  y = total;

  cout << x << endl << y << endl;
}

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

int main(void)
{
	int a,b,c;
	int N;


	while(cin >> a >> b >> c, a | b | c){
		cin >> N;

		int abc = a + b + c;
		int in[1000][4];
		int d[1000];

		for(int i = 0; i < 1000; i++)
			d[i] = 2;

		for(int i = 0; i < N; i++){
			for(int j = 0; j < 4; j++)
				cin >> in[i][j];

			if(in[i][3]){
				d[in[i][0]] = d[in[i][1]] = d[in[i][2]] = 1;
			}
		}

		for(int i = 0; i < N; i++){
			for(int j = 0; j < 3; j++){
				if(d[in[i][(j+1)%3]] == 1 && d[in[i][(j+2)%3]] == 1 && !in[i][3])
					d[in[i][j]] = 0;
			}
		}

		for(int i = 1; i <= abc; i++)
			cout << d[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 
int A[50], n;
 
int solve (int i, int m) {
  if (m == 0) return 1;
  if (i >= n) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}
 
int main(){
  int q, M;
  cin >> n;
  REP(i, n) {
    cin >> A[i];
  }
  cin >> q;
  REP(i, q) {
    cin >> M;
    if (solve(0, M)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3100
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  let i, j, X, Y, xlen, ylen, maxlen;
  let c;
  let str = '';
  while ((X = lines.shift()) && (Y = lines.shift())) {
    xlen = X.length;
    ylen = Y.length;
    c = Array.from(Array(xlen + 1), () => []);

    for (i = 1; i <= xlen; i++) {
      for (j = 1; j <= ylen; j++) {
        if (X[i-1] === Y[j-1]) c[i][j] = c[i - 1][j - 1] + 1||1;
        else c[i][j] = Math.max(c[i - 1][j]||0, c[i][j - 1]||0);
      }
    }
    str += `${c[xlen][ylen]}\n`;
  }
  process.stdout.write(str);
})();



Measured memory_bytes: 148684
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int N, K, R, S, P;


void choose_best_hands(vector<char> &hands, string &T, int i, int j, char r, char s, char p) {
  if (j == i) {
    hands[j] = p;
  } else if (hands[j-K] == p) {
    if (j+K < N) {
      if (T[j+K] == r) {
        hands[j] = s; // p以外なら何でも良い
      } else if (T[j+K] == s) {
        hands[j] = s;
      } else {
        hands[j] = r;
      }
    } else {
      hands[j] = s;
    }
  } else {
    hands[j] = p;
  }
}

int main() {
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  vector<char> hands(T.length());
  for (int i = 0; i < K; i++) {
    for (int j = i; j < N; j += K) {
      if (T[j] == 'r') {
        choose_best_hands(hands, T, i, j, 'r', 's', 'p');
      } else if (T[j] == 's') {
        choose_best_hands(hands, T, i, j, 's', 'p', 'r');
      } else {
        choose_best_hands(hands, T, i, j, 'p', 'r', 's');
      }
    }
  }
  int score = 0;
  for (int i = 0; i < hands.size(); i++) {
    if (T[i] == 'r' && hands[i] == 'p') {
      score += P;
    } else if (T[i] == 's' && hands[i] == 'r') {
      score += R;
    } else if (T[i] == 'p' && hands[i] == 's') {
      score += S;
    }
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 512
//<============ Author --> @venom ============>//
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fo(i,n)           for(int i=0;i<n;i++)
#define int               long long
#define pb                emplace_back
#define mp                make_pair
#define ff                first
#define ss                second
#define all(x)            x.begin(), x.end()
#define sortall(x)        sort(all(x))
#define sortrev(x)        sort(all(x), greater<int>())
#define w(x)              int x; cin>>x; while(x--)
#define trunc(x,y)        fixed<<setprecision(y)<<x
#define mk(arr, n, type)  type *arr=new type[n];
#define PI                3.1415926535897932384626
#define mod               1000000007
#define inf               1e9 + 5
#define FIO               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int, int>    pi;
typedef vector<int>       vi;
typedef vector<pi>        vpi;
typedef vector<vi>        vvi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
const int N = 3e5, M = N;
int mpow(int base, int exp);
int gcd(int a, int b) {if (a == 0) return b; return gcd(b % a, a);}
//<----------------------------------------------------------------------------->//
void fastIO()
{
  FIO;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    
  FIO;
  
  int n, W;
  cin >> n >> W;

  int wt[n], val[n];

  fo(i, n)
  {
    cin >> wt[i] >> val[i];
  }

  int dp[n + 1][W + 1] = {0};

  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j <= W; j++)
    {
      if (i == 0 || j == 0)
      {
        dp[i][j] = 0;
      }

      else
      {
        if (wt[i - 1] <= j)
        {
          dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
        }

        else
        {
          dp[i][j] = dp[i - 1][j];
        }
      }
    }
  }

  cout << dp[n][W];

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((int)result * base) % mod;
    base = ((int)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, h[200100], i, ans=0, cost[200100];
    cin >> n;
    for(i=0;i<n;i++){
        cin >> h[i];
    }

    for(i=1;i<n;i++){
        if(i==1) cost[i]=abs(h[i-1]-h[i]);
        else{
            cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));
        }
    }

    cout << cost[n-1] <<endl;
    return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <list>
#include <cmath>

using namespace std;

int main() {
	int n;
	while ((cin >> n),n != 0) {
		list<int> s;
		for (int i = 2; i < sqrt(2 * n) + 1; i++) s.push_back(i);
		for (auto itr = s.begin(); itr != s.end(); itr++) {
			int val = *itr;
			s.remove_if([&](int p){ return p > val && p % val == 0; });
		}
		list<int> dst;
		for (int i = n+1; i <= 2 * n; i++) dst.push_back(i);
		for (auto itr = s.begin(); itr != s.end(); itr++) {
			int val = *itr;
			dst.remove_if([&](int p){ return p > val && p % val == 0; });
		}
		cout << dst.size() << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

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

vector<string> v, v2, v3, v4, v5;

int main()
{
  int h, w;
  ci >> h >> w;

  string s;
  rep(i, h) ci >> s, v.pb(s);

  string all = "";
  rep(i, w) all += '.';

  rep(i, h) if(v[i] != all) v2.pb(v[i]);

  rep(i, w) {
    string hoge = "";
    rep(j, v2.size()) hoge += v2[j][i];
    
    v3.pb(hoge);
  }

  all = "";
  rep(i, v3[0].size()) all += '.';
  rep(i, v3.size()) if(v3[i] != all) v4.pb(v3[i]);

  rep(i, v4[0].size()) {
    string hoge = "";
    rep(j, v4.size()) hoge += v4[j][i];
    
    v5.pb(hoge);
  }
  
  rep(i, v5.size()) co << v5[i] << en;
  
  return 0;
}


Measured memory_bytes: 384
A=[[int(i) for i in input().split()] for q in range(3)]
n=int(input())

tar=[]
for i in range(n):
  ck=int(input())
  for p in range(9):
    if A[p//3][p%3] == ck:
      tar.append(p)
      
def check(a,b,c):
  if a in tar and b in tar and c in tar:
    return 1
  else:
    return 0
  
res=check(0,1,2)+check(3,4,5)+check(6,7,8)+check(0,3,6)+check(1,4,7)+check(2,5,8)+check(0,4,8)+check(2,4,6)
if res == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
EPS = 0.0001
while True:
    try:
        a = list(map(float, input().split()))
        dd = a[0]*a[4]-a[3]*a[1]
        d1 = a[2]*a[4]-a[5]*a[1]
        d2 = a[0]*a[5]-a[3]*a[2]
        print("{0:.3f} {1:.3f}".format(d1/dd+EPS, d2/dd+EPS))
    except EOFError:
        break


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  vector<int> dp(n, INF);
  dp[0] = 0;

  for(int i=0;i<n;++i) {
    for(int j=0;j<k;++j) {
      int next = i+j+1;
      if(next >= n) break;
      dp[next] = min(dp[next], dp[i] + abs(h[next] - h[i]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    char c;
    cin >> c;
    string vowel = "vowel", consonant = "consonant";

    if(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o'){
        p(vowel);
    }else{
        p(consonant);
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, M;
	cin >> N >> M;
	vector<int> memo(M + 1, 0);
	REP(i, N) {
		int K;
		cin >> K;
		REP(j, K) {
			int A;
			cin >> A;
			memo[A]++;
		}
	}
	int res = 0;
	FOR(i, 1, M + 1) res += memo[i] == N ? 1 : 0;
	cout << res << "\n";

	return 0;
}

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

typedef long long ll;

const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main () {
	COMinit ();

	int n, k;
	vector <int> a;
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		int tmp;
		cin >> tmp;
		a.push_back (tmp);
	}

	sort (a.begin (), a.end ());
	ll sum = 0;
	for (int i=0; i<n; i++) {
		ll tmp = 0;
		if (i<=n-k) {
			tmp -= COM (n-i-1,k-1);
			tmp %= MOD;
		}
		if (i>=k-1) {
			tmp += COM (i, k-1);
			tmp %= MOD;
		}
		sum += tmp*a[i];
		sum %= MOD;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 12796
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
  int x=0,y=0,z=0,w=0;
  string a="";
  std::cin >> x>>y>>a;
  rep(i,y){
    Rep(j,x){
      if(i==0||i==y-1){
        if(j==0||j==x-1){
          std::cout << "+";
        }else{
          std::cout << "-";
        }

      }else{
        if(j==0||j==x-1){
          std::cout << "|" ;
        }else if(j==x/2&&i==y/2){
          std::cout << a;
        }else{
          std::cout << ".";
        }
      }
    }
    std::cout <<'\n';
  }

}



Measured memory_bytes: 3164
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

#define INFL (1LL << 62)

typedef long long ll;

using namespace std;

int main() {
    ll n;
    scanf("%lld", &n);
    vector<ll> h(n + 1), dp(n + 1, 0);
    for (int i = 1; i <= n; ++i) scanf("%lld", h.begin() + i);
    h.front() = INFL;
    for (int i = 2; i <= n; ++i) dp.at(i) = min(dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    printf("%lld\n", dp.back());
    return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	q := n / (a + b)
	r := n % (a + b)

	var ans int
	if a < r {
		ans = q*a + a
	} else {
		ans = q*a + r
	}

	fmt.Print(ans)
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<int> x(n), y(n);
    for (int i = 1; i < n; ++i) {
      int j, d;
      cin >> j >> d;
      x[i] = x[j], y[i] = y[j];
      if (d == 0) {
        --x[i];
      } else if (d == 1) {
        --y[i];
      } else if (d == 2) {
        ++x[i];
      } else {
        ++y[i];
      }
    }
    int w = *max_element(begin(x), end(x)) - *min_element(begin(x), end(x)) + 1;
    int h = *max_element(begin(y), end(y)) - *min_element(begin(y), end(y)) + 1;
    cout << w << ' ' << h << '\n';
  }
}



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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	k, n = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	mind = 10**9
	for i in range(n):
		if i == 0:
			mind = min(mind, k - abs(a[i] - a[i+1]), k - abs(a[i] + k - a[-1]))
			continue
		if i == n - 1:
			mind = min(mind, k - abs(k - a[i] + a[0]), k - abs(a[i] - a[i-1]))
			continue
		mind = min(mind, k - abs(a[i] - a[i+1]), k - abs(a[i] - a[i-1]))
	print(mind)


main()

Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long C, vector<long long> x, vector<long long> v){
	vector<ll> d(N+1), r(N+1), md(N+1), mr(N+1);
	repn(i, N) {
		d[i] = d[i-1] + v[i-1] - (x[i]-x[i-1]);
		md[i] = max(md[i-1], d[i]);
	}
	repn(i, N) {
		r[i] = r[i-1] + v[N-i] - ((C-x[N-i+1])-(C-x[N-i+2]));
		// cout << i << ": " << r[i] << " " << C-x[N-i+1] << " " << (C-x[N-i+2]) << endl;
		mr[i] = max(mr[i-1], r[i]);
	}

	ll res = 0;
	repn(i, N) {
		ll now = 0;
		now = d[i]+max(mr[N-i]-x[i], 0LL);
		// cout << i << ": " << d[i] << " " << N-i << ": " << max(mr[N-i]-x[i], 0LL) << endl;
		res = max(res, now);
	}
	repn(i, N) {
		ll now = 0;
		now = r[i]+max(md[N-i]-(C-x[N-i+1]), 0LL);
		// cout << "rev " << i << ": " << r[i] << " " << N-i << ": " << max(md[N-i]-(C-x[N-i]), 0LL) << endl;
		res = max(res, now);
	}
	cout << res << endl;
}

int main(){	
	long long N;
	long long C;
	scanf("%lld",&N);
	vector<long long> x(N+2);
	vector<long long> v(N);
	scanf("%lld",&C);
	x[N+1] = C;
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i+1]);
		scanf("%lld",&v[i]);
	}
	solve(N, C, x, v);
	return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e9;
const int MOD = INF+7;
using P = pair<int,int>;

signed main(){
    int N,M;
    cin >> N >> M;
    vector<int> Ball(N,1),Possible(N,0);
    Possible[0] = true;

    rep(i,M){
        int x,y;
        cin >> x >> y; x--,y--;
        Possible[y] |= Possible[x];
        Ball[x]--;
        Ball[y]++;
        if(Ball[x] == 0) Possible[x] = false;
    }

    int ans = 0;
    rep(i,N) ans += Possible[i];

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long int pow2(long long int a){
    long long int ans = 1;
    for(int i=0; i<a; i++) ans = ans*2;
    return ans;
}

int main(void){
    long long int n, k, i, j, keta, ansx=0, ans=0, po;
    scanf("%lld %lld", &n, &k);
    long long int a[n];
    for(i=0; i<n; i++) scanf("%lld", &a[i]);
    for(i=40; i>=0; i--){
        po = 0;
        for(j=0; j<n; j++){
            if((a[j]%pow2(i+1))/pow2(i)) po++;
        }
        if(po<(double)n/2 && ansx + pow2(i)<=k) ansx += pow2(i);
    }
    for(i=0; i<n; i++) ans += ansx^a[i];
    printf("%lld", ans);
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int a,b,x,y,z;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if (x<y){
		if (y<z){
			printf("%d",z);
		} else {
			printf("%d",y);
		}
		}else if (x<z){
				printf("%d",z);
			} else {
				printf("%d",x);
			}
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception {
		
		List<String> resultList = new ArrayList<String>();

		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        while(N != 0) {
        	List<String> line = checkRevenue(N ,br);
        	if(line.size() == 0) {
        		resultList.add("NA");
        	} else {
        		resultList.addAll(line);
        	}
        	N = Integer.parseInt(br.readLine());
        }
        
        // ???????????????
     	Iterator<String> k = resultList.iterator();
    	while (k.hasNext()) {
    		System.out.println(k.next());
    	}
	}

	private static List<String> checkRevenue(
								int N, 
								BufferedReader br
	) throws Exception {
		List<String> resultRevenue = new ArrayList<String>();
		List<String> idList = new ArrayList<String>();
		Map<String, BigDecimal> revenue = new HashMap<String, BigDecimal>();;
		for(int i = 0; i < N; i++) {
			String[] line_Array = br.readLine().split(" ");
			String id = line_Array[0];
			BigDecimal x = new BigDecimal(line_Array[1]);
			BigDecimal y = new BigDecimal(line_Array[2]);
			revenue = addRevenue(id, x, y, idList, revenue);
		}
		for(int j = 0; j < idList.size(); j++) {
			String id = idList.get(j);
			if((revenue.get(id)).compareTo(BigDecimal.valueOf(1000000)) >= 0) {
				resultRevenue.add(idList.get(j));
			}
		}
		return resultRevenue;
	}
	
	private static Map<String, BigDecimal> addRevenue(
											String id, 
											BigDecimal x, 
											BigDecimal y,
											List<String> idList,
											Map<String, BigDecimal> revenue
	) {
		BigDecimal total = BigDecimal.valueOf(0);
		if(revenue.containsKey(id)) {
			total = revenue.get(id);
			total = total.add(x.multiply(y));
			revenue.put(id, total);
		} else {
			total = x.multiply(y);
			revenue.put(id, total);
			idList.add(id);
		}
		return revenue;
	}
}

Measured memory_bytes: 27332
S=input()
N=len(S)
cnt=0
cnt1=0
cnt2=0
for i in range (N):
    if S[i]==S[N-1-i]:
        cnt+=1

if cnt==N:
    for j in range((N-1)//2):
        if  S[j]==S[(N-1)//2 -1-j]:
            cnt1+=1
    if cnt1==(N-1)//2:
        for k in range((N-1)//2):
            if S[(N+3)//2 -1+k]==S[N-1-k]:
                cnt2+=1
    else:
        print("No")
        exit()
    if cnt2==(N-1)//2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
    
    vector<long long int> hen;
    
    long long int x;
    for (int i = 0; i < 3; i++) {
        cin >> x;
        if (x % 2 == 0) {
            cout << "0" << endl;
            return 0;
        }
        hen.push_back(x);
    }
    
    sort(hen.begin(), hen.end());
    cout << hen.at(0) * hen.at(1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn pcnt(x: i32) -> i32 {
    x.count_ones() as i32
}
fn f(x: i32) -> i32 {
    if x == 0 {
        return 0;
    }
    f(x % pcnt(x)) + 1
}
fn main() {
    let n: usize = read();
    let s: String = read();
    let mut s: Vec<char> = s.chars().collect();
    let mut x: Vec<i32> = vec![0; n];
    for i in 0..n {
        x[i] = s[i] as i32 - '0' as i32;
    }
    let mut pc = 0;
    for i in 0..n {
        pc += x[i];
    }
    let mut ans: Vec<i32> = vec![0; n];
    for b in 0..2 {
        let mut npc = pc;
        if b == 0 {
            npc += 1;
        } else {
            npc -= 1;
        }
        if npc <= 0 {
            continue;
        }
        let mut r0 = 0;
        for i in 0..n {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        let mut k = 1;
        for i in 0..n {
            if x[n - 1 - i] == b {
                let mut r = r0;
                if (b == 0) {
                    r = (r + k) % npc;
                } else {
                    r = (r - k + npc) % npc;
                }
                ans[n - 1 - i] = f(r) + 1;
            }
            k = (k * 2) % npc
        }
    }
    for i in 0..n {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	int a,b,k,i,f=0;
	cin>>k>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹ここにすきなもじをいれてね！╹) */
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/* (๑╹最強╹) */




int main() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll p3 = 1000000000000;
    ll p1 = A*X + B*Y;
    ll p2 = 2*C * max(X,Y);
        if (X<Y)
           p3 = 2*C * X + B * abs(Y-X);
        if (X>Y)
           p3 = 2*C * Y + A * abs(X-Y);
    ll ans = min(p1,min(p2,p3));

cout << ans << endl;

}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, b = LI()
    if a == 1:
        a = 14
    if b == 1:
        b = 14

    if a == b:
        print('Draw')
    elif a > b:
        print('Alice')
    else:
        print('Bob')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10120
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    llt num = 100 * r + 10 * g + b;

    if (num % 4 == 0)
        cout << "YES" << endl;

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


Measured memory_bytes: 888
N = int(input())
dict = {}
nums = list(map(int, input().split()))

for num in nums:
  if num in dict.keys():
    dict[num] += 1
  else:
    dict[num] = 1
ans = 0
for key, value in dict.items():
  if int(key) == value:
    continue
  elif int(key) > value:
    ans += value
  else:
    ans += value - int(key)
print(ans)


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

const int MAX_R = 10, MAX_C = 10000;
int R, C;
int grid[MAX_R+5][MAX_C+5];
int bit[MAX_R+5];

int count() {
    int ret = 0;
    for(int i = 0; i < C; i++) {
        int tmp = 0;
        for(int j = 0; j < R; j++) {
            if((bit[j]&&grid[j][i]) || (!bit[j]&&!grid[j][i])) tmp++;
        }
        ret += max(tmp, R-tmp);
    }
    return ret;
}

int solve() {
    int ans = 0;
    for(int i = 0; i < 1<<R; i++) {
        for(int j = 0; j < R; j++) {
            bit[j] = (i >> j)%2;
        }
        ans = max(ans, count());
    }
    cout << ans << endl;
    return 0;
}

int main() {
    while(true) {
        cin >> R >> C;
        if(!R && !C) break;
        for(int i = 0; i < R; i++) {
            for(int j = 0; j < C; j++) {
                cin >> grid[i][j];
            }
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 1556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  string S;
  cin>>S;
  bool CAN=true;
  
  if(S.at(2)!=S.at(3)) CAN=false;
  if(S.at(4)!=S.at(5)) CAN=false;
  
  if(CAN) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> E(N, 0);
    vector<int> W(N, 0);
    
    for(int i = 1; i < N; i++){
        W[i] = W[i - 1];
        if(S[i - 1] == 'W')W[i]++;
        E[N - 1 - i] = E[N - i];
        if(S[N - i] == 'E')E[N - 1 - i]++;
    }
    
    int ans = N;
    for(int i = 0; i < N; i++){
        int res = E[i] + W[i];
        if(res < ans)ans = res;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
import collections

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
c = collections.Counter(dists)
keys = c.keys()
for K in range(1,N):
    if K in keys:
        print(c[K])
    else:
        print(0)

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

ll GCD(ll a,ll b){
    if(b==0) return a;
    else return GCD(b,b%a);
}

int main() {
    int k;
    cin>>k;
    int s = 0;
    for(int a=1;a<=k;a++) {
        for(int b=1;b<=k;b++) {
            for(int c=1;c<=k;c++) {
                s += gcd(c,gcd(a,b));
            }
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, m;
  cin >> n >> m;
  if (n==1 && m==1) cout << 1 << endl;
  else if (n==1) cout << m-2 << endl;
  else if (m==1) cout << n-2 << endl;
  else cout << (n-2) * (m-2) << endl;
  return 0;
}


Measured memory_bytes: 256