akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  cout << "ABC" << n << endl;
  
}


Measured memory_bytes: 256
N=int(input())
S=input()

from collections import Counter
we=Counter(list(S))
enum=we["E"]
wnum=0
ans=enum
for s in S:
  if s=="W":
    wnum+=1
  elif s=="E":
    enum-=1
  ans=min(ans, enum+wnum)
print(ans)    

Measured memory_bytes: 11728
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	vector<vector<int>> adj(n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		cin >> u >> v, -- u, -- v;
		adj[u].push_back(v), adj[v].push_back(u);
	}
	vector<int> active, res(n);
	vector<array<int, 2>> log(n);
	function<void(int, int)> dfs = [&](int u, int p){
		int pos = lower_bound(active.begin(), active.end(), a[u]) - active.begin();
		if(pos == int(active.size())){
			log[u] = {pos, -1};
			active.push_back(a[u]);
		}
		else{
			log[u] = {pos, active[pos]};
			active[pos] = a[u];
		}
		res[u] = int(active.size());
		for(auto v: adj[u]){
			if(v != p){
				dfs(v, u);
				if(log[v][1] == -1){
					active.pop_back();
				}
				else{
					active[log[v][0]] = log[v][1];
				}
			}
		}
	};
	dfs(0, 0);
	for(auto x: res){
		cout << x << "\n";
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 1e5+23;

vector<int> a[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int l, v, i = 0; i < n; ++i) {
    scanf("%d%d", &l, &v);
    a[l].emplace_back(v);
  }
  int ans = 0;
  map<int, int> s;
  for (int i = 1; i <= m; ++i) {
    if (s.size() == 0 && a[i].size() == 0) continue;
    for (int e: a[i]) {
      ++s[e];
    }
    const int x = s.rbegin()->first;
    ans += x;
    if (--s[x] == 0) s.erase(x);
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 9080
#include <iostream>

using namespace std;

typedef long long ll;


int main() {
    ll n;
    cin >> n;
    ll a[5];

    ll minv = (ll) 1e16;

    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
        minv = min(minv, a[i]);
    }

    cout << 4 + (n + minv - 1) / minv << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long i,n,sum=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3&&i%5)
			sum+=i;
	}
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mw(vector<pair<lli,lli>>v,lli N,lli W)
{
    lli max_val = N*1000;
    lli inf = 1e9+1;
    lli dp[N+1][max_val+1];
    for(lli w=0;w<=max_val;w++)
    {
        dp[1][w] = inf;
    }
    dp[1][0] = 0;
    dp[1][v[1].second] = v[1].first;
    for(lli i=2;i<=N;i++)
    {
        for(lli w = 0;w<=max_val;w++)
        {
            dp[i][w] = dp[i-1][w];
            if(v[i].second>w)
            continue;
            dp[i][w] = min(dp[i][w],v[i].first+dp[i-1][(w-v[i].second)]);
        }
    }
    lli max = 0;
        for(lli w = 0;w<=max_val;w++)
        {
            if(dp[N][w]<=W)
            max = w;
        }
    return max;
}
int main() 
{
    lli n,w;
    cin>>n>>w;
    vector<pair<lli,lli>>v(n+1);
    for(lli i=1;i<=n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    cout<<mw(v,n,w)<<"\n";
    //cout<<v[1].first<<" "<<v[1].second<<"\n";
}

Measured memory_bytes: 81628
#include <iostream>
#include <set>

using namespace std;

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

    set<int> temp;
    for (int i = 0; i < N; ++i) {
        int d;
        cin >> d;
        temp.insert(d);
    }

    cout << temp.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll mod = 1e9+7;

ll n;
//vector<vector<vector<ll>>> dp;
ll dp[1000005][2][2];

int main()
{
    fastio
    cin >> n;
//    dp.assign(n+1,vector<vector<ll>>(2,vector<ll>(2,-1)));
//    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 1;
    for(int i=1;i<=n;i++) {
        dp[i][1][0] = (9LL*dp[i-1][1][0]%mod + dp[i-1][0][0]) % mod;
        dp[i][0][1] = (9LL*dp[i-1][0][1]%mod + dp[i-1][0][0]) % mod;
        dp[i][0][0] = 8LL*dp[i-1][0][0]%mod;
        dp[i][1][1] = (((10LL*dp[i-1][1][1]%mod + dp[i-1][1][0]))%mod + dp[i-1][0][1]) % mod;
    }
    cout << dp[n][1][1];
}


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

#define int long long

#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int n,a,b;

signed main(){
    cin>>n>>a>>b;
    
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(n==1&&a!=b){
        cout<<0<<endl;
        return 0;
    }
    
    int l=a*(n-2);
    int r=b*(n-2);
    int ans=r-l+1;
    cout<<ans<<endl;
    
    
    
    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int s=0;
  for (int i=0; i<N; i++) {
    if (i%2==0) s+=vec.at(i);
    else s-=vec.at(i);
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  5 15:21:54 2019

@author: Owner
"""

S = input()

A = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]

flg = [True, True, True]

def dfs(n, flg, goal):
    if goal == True:
        return True
    
    if n == 3:
        ops = ["+", "+", "+"]
        tot = A[0]
        for i in range(len(flg)):
            if flg[i]:
                tot += A[i+1]
            else:
                tot -= A[i+1]
                ops[i] = "-" 
        #print("Layer: "+str(n)+", Flags: "+str(flg)+", Total: "+str(tot))
                
        if tot == 7:
            print(str(A[0])+ops[0]+str(A[1])+ops[1]+str(A[2])+ops[2]+str(A[3])+"=7")
            return True
        else:
            return False
    #print("Layer: "+str(n)+", Flags: ", flg)
    flg1 = flg.copy()
    flg1[n] = True
    flg2 = flg.copy()
    flg2[n] = False
    
    goal = dfs(n+1, flg1, goal) or dfs(n+1, flg2, goal)
    
    return goal
    
dfs(0, flg, False)

Measured memory_bytes: 3064
use std::io::{stdin, Stdin, BufRead};

fn main() {
    let stdin = stdin();
    let a_num = read(&stdin);
    let b_num = read(&stdin);
    let c_num = read(&stdin);
    let x_num = read(&stdin);
    assert_eq!(x_num % 50, 0);

    let mut pairs: Vec<(i32, i32, i32)> = Vec::new();
    
    for a in 0..a_num + 1 {
        if a * 500 > x_num {
            continue;
        }

        for b in 0..b_num + 1 {
            if a * 500 + b * 100 > x_num {
                break;
            }

            for c in 0..c_num + 1 {
                let cur_sum = a * 500 + b * 100 + c * 50;
                if cur_sum > x_num {
                    break;
                } else if cur_sum == x_num {
                    pairs.push((a, b, c));
                }
            }
        }
    }

    println!("{}", pairs.len());
}

fn read(stdin: &Stdin) -> i32 {
    let mut buf = String::new();
    stdin.lock().read_line(&mut buf).unwrap();
    buf.pop();
    buf.parse().unwrap()
}


Measured memory_bytes: 4352
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const double EPS = 1e-12;
typedef complex<double> P;

long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}

int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<pair<int,int>>se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		if(se.find({i,j})!=se.end())continue;
		vector<int>x={i,j};
		for(int k=j+1;k<N;k++)if(abs(imag(conj(v[j]-v[k])*(v[i]-v[k])))<1e-12)x.push_back(k);
		for(int a=0;a<x.size();a++)for(int b=a+1;b<x.size();b++){
			r=(r-pow_binary_mod(2,b+~a,M))%M;
			se.emplace(x[a],x[b]);
		}
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

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

int main() {
	string s;
	cin >> s;
	int n = (int)s.size();
	vector<int> div;
	div.push_back(-1);
	for(int i=0;i<n-1;i++) {
		if(s[i] != s[i+1]) {
			div.push_back(i);
		}
	}
	div.push_back(n-1);
	vector<int> ans(n, 0);
	for(int i=0;i<div.size();i++) {
		if(i%2==1) {
			int left = div[i] - div[i-1];
			int right = div[i+1] - div[i];

			ans[div[i]] += (left+1)/2;
			ans[div[i]+1] += left/2;

			ans[div[i]+1] += (right+1)/2;
			ans[div[i]] += right/2;
		}
	}
	for(int i=0;i<n;i++) cout << ans[i] << ((i==n-1)?"\n":" ");
}

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

int main(){

  int len, cnt[2];
  string str;

  while(getline(cin, str)){
    len = str.length();
    if(len == 1) break;
    fill(cnt, cnt+2, 0);

    for(int i=1; i<len; i++){
      if(str[i] == 'A') cnt[0]++;
      else cnt[1]++;
    }
    if(cnt[0] < cnt[1]) cnt[1]++;
    else cnt[0]++;
 
    cout << cnt[0] << " " << cnt[1] << endl;

  }

  return 0;

}

Measured memory_bytes: 1172
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

bool solve() {
  int n, a, b;
  if (scanf("%d%d%d", &n, &a, &b) != 3) { return false; }
  printf("%s\n", (a + b) % 2 == 1 ? "Borys" : "Alice");
  return true;
}

int main() {
  while (solve());
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
using namespace std;

#define f(i,a) for(int i=0;i<a;i++)
#define absc(x) abs(ir[i]-row[x])<2&&abs(ic[i]-col[x])<2

char str[17][17];
int dx[]={-1,-1,-1,0,0,0,1,1,1},dy[]={-1,0,1,-1,0,1,-1,0,1};
int u[17][17],v[17][17],ir[17],ic[17];
int row[300],col[300];
int id,sz,a,b;
long long p[17];

struct st{
    long long v;
    int i;
    st(){i=0,v=0;}
};
bool operator<(const st& a,const st& b){
    return a.v!=b.v?a.v<b.v:a.i<b.i;
}
map<st,int>dp;
int solve(int a,st b){
    if(dp.count(b))return dp[b];
    f(i,id){
        int cnt=0;
        for(int j=a;j<sz;j++)
            if(absc(j))cnt++;
        if(cnt<b.v%p[i+1]/p[i])
            return dp[b]=1e9;
    }
    if(a==sz)return dp[b]=0;
    int ret=1e9;
    b.i++;
    bool ne=true;
    f(i,id)if(absc(a)&&b.v%p[i+1]/p[i]==0)ne=false;
    if(ne){
        f(i,id)if(absc(a))b.v-=p[i];
        ret=min(ret,solve(a+1,b)+1);
        f(i,id)if(absc(a))b.v+=p[i];
    }
    ret=min(ret,solve(a+1,b));
    b.i--;
    return dp[b]=ret;
}
int main(){
    p[0]=1;
    for(int i=1;i<17;i++)p[i]=p[i-1]*10;
    while(cin>>a>>b,a){
        id=sz=0;
        dp.clear();
        st w;
        f(i,a)
            cin>>str[i];
        f(i,a)f(j,b)
            v[i][j]=u[i][j]=0;
        f(i,a)f(j,b)
            if('0'<=str[i][j]&&str[i][j]<='9'){
                ir[id]=i;
                ic[id]=j;
                w.v+=p[id++]*(str[i][j]-'0');
                v[i][j]=str[i][j]-'0';
                f(k,9)
                    if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&str[i+dx[k]][j+dy[k]]!='.')
                        u[i+dx[k]][j+dy[k]]++;
            }
        f(i,a)f(j,b)if(u[i][j])
            row[sz]=i,col[sz++]=j;
        cout<<solve(0,w)<<endl;
    }
}

Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull h;
  cin >> h;

  ull result = 0;
  ull layer = 0;
  while (h != 1) {
    result += (pow(2, layer));
    layer++;
    h = h / 2;
  }

  result += (pow(2, layer));

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#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;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

int main()
{
    int n, k;
    ci >> n >> k;

    co << n - k + 1 << en;
  
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
a = np.array([list(map(int, input().split())) for _ in range(n)])
ab = a*b

ans = 0
for i in ab:
    if sum(i) + c > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 27116
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

class UnionFind {
    public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1){
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_){
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x){
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // Union(Unite, Merge)
    bool merge(ll x, ll y){
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y){ // 連結判定
        return root(x) == root(y);
    }
    ll size(ll x){ // 素集合のサイズ
        return siz[root(x)];
    }
};

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

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

    vector<vector<int>> dir(N);
    vector<vector<int>> block(N);

    UnionFind uf(N);
    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.merge(a,b);
        dir[a].pb(b);
        dir[b].pb(a);
    }
    rep(i,K){
        int c, d;
        cin >> c >> d;
        c--, d--;
        block[c].pb(d);
        block[d].pb(c);
    } 
    rep(i,N){
        int num = i;
        ll ans = uf.size(num)-1-dir[num].size();
        for(int v : block[num]){
            if(uf.issame(num,v)) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 13432
h,w = map(int,input().split())
r = 0
for i in range(h):
    s = input()
    a = 0
    for j in range(w):
        if s[j] == "#":
            if j < r:
                print("Impossible")
                exit()
            else:
                a = j
        else:
            continue
    r = a

print("Possible")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
//A : 190   : 152
//B : 183.3 : 
//C : 170   :
int main(){
    int n;
    while(cin >> n){
        if( !n ) break;
        int ans = 1001001001, temp;

        for(int a=0;a<=n;a+=200){
            for(int b=0;b<=n;b+=300){
                for(int c=0;c<=n;c+=500){
                    if(a+b+c == n){
                        int na = a/200, nb = b/300, nc = c/500;
                        int nna = na/5, nnb = nb/4, nnc = nc/3;
                        int as = nna*380*5*80/100 + (na%5)*380;
                        int bs = nnb*550*4*85/100 + (nb%4)*550;
                        int cs = nnc*850*3*88/100 + (nc%3)*850;
                        temp = as + bs + cs; 
                        ans = min(ans,temp);
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3044
#include<stdio.h>
int main()
{
   long long int n,x,a,b;
    scanf("%lld %lld",&a,&b);
    n=a*b;
    x=2*a+2*b-4;
    if(n>x)
    printf("%lld",n-x);
    else
    printf("%lld",x-n);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int a[200], n, count = 0;
	bool b = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 != 0) {
			b = false;
			break;
		}
	}
	while (b) {
		for (int i = 0; i < n; i++) {
			a[i] /= 2;
			if (a[i] % 2 != 0) {
				b = false;
			}
		}
		count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  
   val s = StdIn.readLine()
   println(
   if(s(0) == s(1) && s(1) == s(2)) "Yes"
   else if(s(1) == s(2) && s(2) == s(3)) "Yes"
   else "No"
   )
}

Measured memory_bytes: 27184
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int n,k;
llint p[15];

void solve(){
	cin >> n >> k;
	llint h[n];
	for(int i=0;i<n;i++)cin >> h[i];
	sort(h,h+n);
	llint x=h[k-1]-h[0];
	for(int i=0;i<n-k+1;i++){
		if(x>h[k+i-1]-h[i])x=h[k+i-1]-h[i];
	}
	cout << x << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n,0);
    int a1=0,a2=0,a4=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1){
            a1++;
        }else if(a[i]%4==0){
            a4++;
        }else{
            a2++;
        }
    }
    if(a2>0){
        if(a4<a1) {
            cout << "No";
        }else{
            cout<<"Yes";
        }
    }else{
        if(a4+1<a1) {
            cout << "No";
        }else{
            cout<<"Yes";
        }
    }
    return 0;
}

Measured memory_bytes: 640
def solve(ls, n):
	dp = [-1] * n
	dp[0] = 0
	if n == 1:
		return 0
	dp[1] = abs(ls[1] - ls[0])
	for i in range(2, n):
		dp[i] = min((dp[i - 1] + abs((ls[i - 1]) - ls[i]), (dp[i - 2] + abs((ls[i - 2]) - ls[i]))))
	return dp[n - 1]


n = int(input())
ls = list(map(int, input().split()))
print(solve(ls, n))


Measured memory_bytes: 13980
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}\
int n;
const int Maxn=1e5+5;
ll a[Maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll res=0,left=0;
	for(int i=1;i<=n;i++){
		res+=(a[i]+left)/2;
		left=(a[i]+left)%2;
		if(!a[i])left=0;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter

MOD = 998244353

n = int(input())
d = list(map(int,input().split()))

d_count = Counter(d)

ans = 1
pre_count = 1

if d[0] > 0: ans = 0

for i,(dist,count) in enumerate(sorted(d_count.items())):
    if i != dist or (i==0 and count > 1):
        ans = 0
        break
    
    ans *= pow(pre_count,count,MOD)
    ans %= MOD
    
    pre_count = count
    
print(ans)

Measured memory_bytes: 21468
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

double ans = 0;
int N, K;

void solve(){
    // rep(i, N+1) cout << Cnt[i] << endl;

    for(int i = 1; i <= N; ++i){
        ll tmp = N;
        int cur = i;
        while(cur < K){
            tmp *= 2;
            cur *= 2;
        }
        // cout << tmp << endl;
        ans += 1/(double)tmp;
    }

    cout << setprecision(15) <<  ans << endl;
}

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

    solve();
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<i32> = read_as_vec();

    let (a, b, c) = (line[0], line[1], line[2]);

    if (a - b) > c{
     println!("0");   
    }else{
     println!("{}", c-(a-b));   
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
 
 
 
//s.reserve(32768); //updated !
//s.max_load_factor(0.25);



int main(){
    


    int n,k;
    cin>>n>>k;

    vector<ll>v(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }

    for(int i=k+1;i<=n;i++){
        if(v[i]>v[i-k])cout<<"Yes"<<"\n";
        else cout<<"No"<<"\n";
    }
}
 
    
 
 
 
    
 
 
 
    
    
    
 
 
 
 
    
 
 
    
 
    
 
 
 
 
 
 
    
    
 
    
 
    
 
 
 
 
    
 


Measured memory_bytes: 4788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

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

    int p[n+1];  // M_iはp[i]行p[i+1]列
    rep(i, n-1) {
        int ri, ci;
        cin >> ri >> ci;
        p[i] = ri; 
    }
    int rn, cn;
    cin >> rn >> cn;
    p[n-1] = rn, p[n] = cn;

    int dp[n][n];  // dp[i][j] : M_i・M_(i+1)・・・M_jの計算回数の最小値(i, jは0-index)
    rep(i, n) {
        rep(j, n) {
            if(i == j) {
                dp[i][j] = 0;
            }
            else {
                dp[i][j] = INF;
            }
        }
    }

    rep(j, n) {
        for(int i = n-1; i >= 0; i--) {
            if(j < i) {
                continue;
            }
            for(int k = i; k < j; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i]*p[k+1]*p[j+1]);
            }
        }
    }

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


Measured memory_bytes: 3128
s = input()
z = ''
ans = 0
for i in range(len(s)):
    if s[i] in 'ACGT':
        ans = max(ans, 1)
        for j in range(i+1, len(s)):
            if s[j] in 'ACGT':
                ans = max(ans, j-i+1)
            else:
                break
    else:
        continue
print(ans)

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

int main () {

  int x , y ;

  while(1) {

    cin >> x >> y;

    if (x == 0 && y ==0) break;

    if (x < y) {

      cout << x << " " << y << "\n";
    
    } else {

      cout << y << " " << x << "\n";

    }

  }

  return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, w);
    Cusum(int, w, sw);
    int ans = 100000;
    For(i, n){
        ans = min(ans, abs(sw[i] - (sw[n]-sw[i])));
    }
    Cout(ans);
}


Measured memory_bytes: 256
import collections


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    counter = collections.Counter(A)
    ans = 0

    for i in counter.values():
        ans += i * (i - 1) // 2

    for a in A:
        count = counter[a]
        print(ans - (count * (count - 1) // 2) +
              ((count - 1) * (count - 2) // 2))


resolve()

Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+10];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0;
	sort(a+1,a+n+1);
	for(int i=n;i>=n-k+1;i--){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    int ans=0;
    for(auto it:mp){
        ans+=it.second*(it.second-1)/2;
    }
    rep(i,n){
        cout<<ans-mp[a[i]]+1<<endl;
    }
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vector<int> M [m];
  int P[m];
  bool N[n];
  fill(N, N+n,false);
  REP(i, m){
    int k; cin >> k;
    REP(j, k){
      int t; cin >> t;
      M[i].push_back(t);
    }
  }
  REP(i, m) cin >> P[i];
    
  int sum = 0;
  REP(i, 1 << n) {
    int t = 0;
    REP(j, m) {
      int count = 0;
      REP(k, M[j].size()){
        if(i&(1<<(M[j][k])-1)){
          count++;
        }
      }
      if (count % 2 == P[j]){
        t++;
      }
    }
    if (t == m){
      sum++;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
(let ((q (read))
    (h (read))
    (s (read))
    (dd (read))
    (n (read)))
    (format t "~D~%"(+ (* (floor (/ n 2)) (min (* q 8) (* h 4) (* 2 s) dd))
                        (if (oddp n) (min (* q 4) (* h 2) s) 0))))

Measured memory_bytes: 24220
from collections import defaultdict

INF = float("inf")


N, *A = map(int, open(0).read().split())

I = defaultdict(lambda: -INF)
O = defaultdict(lambda: -INF)
O[(0, 0)] = 0

for i, a in enumerate(A, 1):
    j = (i - 1) // 2
    for n in [j, j + 1]:
        I[(i, n)] = a + O[(i - 1, n - 1)]
        O[(i, n)] = max(O[(i - 1, n)], I[(i - 1, n)])

print(max(I[(N, N // 2)], O[(N, N // 2)]))

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

bool multi_check(vector<int> v, int m){
  for(int i=0; i<m; i++){
    if(v[i]==v[m]) return true;
  }
  return false;
}

int main(){
  string str;
  cin >> str;
  int ans=753;
  for(int i=0; i+2<str.size(); i++){
    string num=str.substr(i, 3);
    int m=stoi(num);
    int temp=abs(753-m);
    ans=min(ans,temp);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if n == 1:
  if m == 1:
    print(1)
  elif m == 2:
    print(0)
  else:
    print(m-2)
elif n == 2:
  print(0)
else:
  if m == 1:
    print(n-2)
  elif m == 2:
    print(0)
  else:
    print((n-2)*(m-2))

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

int N;
int a[110];

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

    sort(a, a + N);

    int dif = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2) dif -= a[N - 1 - i];
        else dif += a[N - 1 - i];
    }

    cout << dif << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string S;

int main(void){
	//IO("test.in", "test.out");
	cin >> S;
	for(int i = 0; i < S.length(); i += 2) printf("%c", S[i]);
	printf("\n");
}

Measured memory_bytes: 512
k,x=map(int, input().split())
min_ans=x-k+1
max_ans=x+k-1
ans_list=list(range(min_ans,max_ans+1))
for i in range(len(ans_list)):
  ans_list[i]=str(ans_list[i])
ans=" ".join(ans_list)
print(ans)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	
  	int c1, c2, c3, c4, c5, c6;
  	cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
	
	int cash = c1 * 1 + c2 * 5 + c3 * 10 + c4 *50 + c5 *100 + c6 * 500;
	
	if( cash >= 1000)
	cout << "1\n";
	
	else
	cout << "0\n";
  
  return 0;

}


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

maxa = 0
ai = 0
for i in range(N):
    if A[i] > maxa:
        ai = i
        maxa = A[i]
maxa //= 2

res = 0
mind = 10**18
for i in range(N):
    if i==ai: continue
    d = abs(A[i]-maxa)
    if d < mind:
        mind = d
        res = i

print(maxa, A[res]//2)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i,kotae=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=2;i<n;i++){
    if((a[i]-a[i-1])*(a[i-1]-a[i-2])>0){
      kotae++;
    }
  }
  cout<<kotae;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N; cin >> N;
	set<int> A;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		A.insert(tmp);
	}
	cout << (A.size() == N ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
namespace io{
	const int SIZE=(1<<21)+1;char ibuf[SIZE],*iS,*iT,obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1,c,qu[55];int f,qr;
	#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}inline void putc(char x){*oS++=x;if(oS==oT)flush();}
	template<class I>inline void gi(I&x){for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;}
	template<class I>inline void print(I x){if(!x)putc('0');if(x<0)putc('-'),x=-x;while(x)qu[++qr]=x%10+'0',x/=10;while(qr)putc(qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}

const int maxn=100000+7;
int n,k,ans;

int main(){
	#ifdef LOCAL
		freopen("C.in","r",stdin);freopen("C.out","w",stdout);
	#endif
	io::gi(n);io::gi(k);
	ans=(n-1)/(k-1)+((n-1)%(k-1)==0?0:1);
	io::print(ans);io::putc(10);
}

Measured memory_bytes: 2304
a, b = map(int,input().split())

mat = []
vec = []
ans = []

for i in range(a):
    mat.append(list(map(int,input().split())))

for j in range(b):
    vec.append(int(input()))
        
for i in range(a):
    tmp = 0
    for j in range(b):
        tmp += mat[i][j] * vec[j]
    ans.append(tmp)

for i in ans:
    print(i)


Measured memory_bytes: 6020
#include<stdio.h>

int main(void)
{
    int X;

    scanf("%d",&X);

    if(400<=X && X<=599) {
        printf("8\n");
    } else if(600<=X && X<=799) {
        printf("7\n");
    } else if(800<=X && X<=999) {
        printf("6\n");
    } else if(1000<=X && X<=1199) {
        printf("5\n");
    } else if(1200<=X && X<=1399) {
        printf("4\n");
    } else if(1400<=X && X<=1599) {
        printf("3\n");
    } else if(1600<=X && X<=1799) {
        printf("2\n");
    } else if(1800<=X && X<=1999) {
        printf("1\n");
    } else {

    }

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N, A[200010]; 
	int sum = 0; 
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		sum ^= A[i]; 
	}
	for(int i = 0; i < N; i++){
		cout << (A[i] ^ sum) << " "; 
	}
	cout << "\n"; 
}

Measured memory_bytes: 4392
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) = {
    val n = readLine.split(" ")(0).toInt
    val c = readLine.split(" ").map(_.toInt)
    val minVal = (0 to n+1).toArray

    for( i <- 2 to n+1 ) {
      for( j <- c ) {
        if(j<=i && minVal(i-j) + 1 < minVal(i)) {
          minVal(i) = minVal(i-j)+1
        }
      }
    }
    println(minVal(n))
  }
}

Measured memory_bytes: 60684
#include <stdio.h>

int main(void){
	char S[3];
	int i;		
	scanf("%c%c%c",&S[0],&S[1],&S[2]);

	
	if((S[0] == S[1] && S[0] != S[2]) || (S[0] == S[2] && S[0] != S[1]) || (S[1] == S[2] && S[1] != S[0])){
		puts("Yes");
	}else{
		puts("No");
	}
	
	
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



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

	VLL v((1 << 13), INFL);

	v[0] = 0;

	REP(i, m) {
		int a, b;
		cin >> a >> b;
		VI c(b);
		REP(j, b) {
			cin >> c[j];
		}
		sort(ALL(c));
		int d = 0;
		for (int x : c) {
			d += (1 << x);
		}
		


		REP(k, (1 << 13)) {
			v[d | k] = min(v[k] + a, v[d | k]);
		}
		
	}


	if (v[(1 << n+1)-2] == INFL)cout << -1 << endl;
	else cout << v[(1 << n+1)-2] << endl;

}




Measured memory_bytes: 256
from collections import defaultdict
import math
from decimal import Decimal

def main():
    N = int(input())
    t, a = map(int, input().split())
    for _ in range(N - 1):
        T, A = map(int, input().split())
        p = Decimal(max(math.ceil(t / T), math.ceil(a / A)))
        t, a = T * p, A * p
    print(t + a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5460
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	int a[] = {1,3,5,7,9,11,15,17,19,21,23,25};
	cin >>n;
	cin.ignore();
	while(n--){
		string word;
		getline(cin,word);
		for(int i=0; i<12; i++){
			for(int j=0; j<26; j++){
				string affine = word;
				for(int k=0; k<(int)word.size(); k++){
					if(affine[k]>='a' && affine[k]<='z'){affine[k] = (a[i]*(affine[k]-'a')+j)%26+'a';}
				}
				if(affine.find("this")+1 || affine.find("that")+1){
					cout<<affine<<endl;
					goto label;
				}
			}
		}
		label:;
	}
	return 0;
}

Measured memory_bytes: 0
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
// #define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	string s;
	cin >> s;
	map<char, int> mp;
	rep(i, 0, s.length())
	mp[s[i]]++;
	ll fl = 0;
	for (auto i : mp)
		if (i.ss % 2 != 0)
			fl = 1;
	if (fl == 1)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll a;
    cin >> a;

    cout << a+a*a+a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>

using namespace std;


string N;
int K;

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

	auto A = vector<int>(K+1,0);
	int B;

	A[0] = 1;
	A[1] = N[0] - '0' - 1;
	B = 1;

	for (unsigned i = 1; i < N.size(); i++) {
		auto Ad = vector<int>(K + 1, 0);
		int n = N[i] - '0';

		Ad[0] = 1;
		for (int j = 1; j <= K; j++) {
			Ad[j] += A[j - 1] * 9;
			Ad[j] += A[j];
		}

		if (n > 0) {
			if (B < K + 1) {
				Ad[B] += 1;
			}
			if (B < K) {
				Ad[B + 1] += n - 1;
			}
			B++;
		}
		A = Ad;
	}

	ans = A[K];
	if (B == K) { ans++; }


	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int N;
set<int> A;

int main() {
    cin >> N;
    REP (i, N) {
        int a;
        cin >> a;
        A.insert(a);
    }
    if (N == A.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 9600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {

	answer(input(), input(), input(), input())

}

func answer(in ...string) {
	A, _ := strconv.ParseInt(in[0], 10, 64)
	B, _ := strconv.ParseInt(in[1], 10, 64)
	C, _ := strconv.ParseInt(in[2], 10, 64)
	X, _ := strconv.ParseInt(in[3], 10, 64)

	cnt := 0

	for a := int64(0); a <= A; a++ {
		for b := int64(0); b <= B; b++ {
			for c := int64(0); c <= C; c++ {
				if ((500 * a) + (100 * b) + (50 * c)) == X {
					cnt++
				}
			}
		}
	}

	fmt.Println(cnt)

}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	string s,ans;
	cin >> s;
	int size = s.size();
	for (int i = 0; i < size; i++) {
		if (i % 2 == 0)ans += s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 512