akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
inline int read() {
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f; 
}
#define ll long long
int n;
ll ans;
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll lcm(int a,int b){return 1ll*a/gcd(a,b)*b;}
int main() {
	n=read(); 
	for(int i=1;i<=n;i++) ans+=read()-1;
	printf("%lld\n",ans);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int a;
  cin>>a;
  if(a==0)
    cout<<1<<nl;
  else
    cout<<0<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3648
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [a,b,k] <- r'
    putStrLn $ if k < a
        then show (a-k) ++ " " ++ (show b)
        else show 0 ++ " " ++ (show $ max 0 (b-(k-a)))



Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  sort(all(h));
  int ans=INF;
  int cnt;
  for(int i=k-1;i<n;i++){
    cnt=h[i]-h[i-k+1];
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3760
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
long long a[300005];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=3*n; ++i)
		scanf("%lld",a+i);
	sort(a+1,a+3*n+1);
	long long ans=0;
	for(int i=3*n-1; i>=n+1; i-=2)
		ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
n=int(input())
p=[int(j) for j in input().split()]
q=[int(j) for j in input().split()]
l=list(range(1,n+1)[::-1])
import itertools
ll=[]
for x in itertools.permutations(l):
    ll.append(list(x))
ll.sort()
a=0
b=0
c=0
for i in ll:
    if i==p:
        a=c
    if i==q:
        b=c
    c+=1
print(abs(a-b))


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

int main(void){
    int n,ans,max_seq,seq;
    string s;
    cin>>n>>s;
    ans = 0;
    for(int i=1; i<n; i++){
        max_seq = 0;
        seq = 0;
        for(int j=0; j<n-i; j++){
            if(s[j]==s[j+i]){
                seq += 1;
            }else{
                max_seq = max(max_seq,seq);
                seq = 0;
            }
            if(seq == i){
                break;
            }
        }
        max_seq = max(max_seq,seq);
        ans = max(ans,max_seq);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k=0;
    int g=0;
    scanf("%d",&n);
    for(int i=1;i<10;i++){
        for(int j=i;j<10;j++){
            k=i*j;
            if(k==n){
                break;
            }
        }
        if(k==n){
            g=1;
            break;
        }
    }
    if(g==1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int multiple(int x){
  if(x==0) return 0;
  int y=1;
  for(int i=1; i<=x; i++) y*=i;
  return y;
}

int main(){
  int N;
  int a=1;
  int b=1;
  int P[10], Q[10];
  cin >> N;
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];
  
  for(int i=0; i<N; i++){
    int Pcopy = P[i];
    for(int j=0; j<i; j++){
      if(P[j]<P[i]) Pcopy--;
    }
    a+=(Pcopy-1)*multiple(N-1-i);
  }
    for(int i=0; i<N; i++){
    int Qcopy = Q[i];
    for(int j=0; j<i; j++){
      if(Q[j]<Q[i]) Qcopy--;
    }
    b+=(Qcopy-1)*multiple(N-1-i);
  }
  if(a>=b) cout << a-b << endl;
  else cout << b-a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  char ch;
  int cnt[26] = {}; // 配列の初期化

  while(cin >> ch){ // 文字列入力があるまで実行する
    ch = tolower(ch); // 小文字に変換する
    if (isalpha(ch)){ // アルファベット判別する
      cnt[ch-'a']++; // 配列に値を足す(charのaはASCIIコード表の数値なのでaを起点として指定の場所に値を増やす処理をしている)
    }
  }

  for (int i = 0; i < 26; i++){
    printf("%c : %d\n", i+'a', cnt[i]); // printfによる指定　https://www.k-cube.co.jp/wakaba/server/format.html
  }
  return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  cin >> n;
  VI h(n);
  rep(i,n){
    cin >> h[i];
  }
  VLL dp(n+1,1e12);

  dp[0] = 0;
  rep(i,n){
    if(i+1 < n) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    if(i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double
#define f(variable, start, end) for (int variable = start; variable < end; ++variable)
#define be(a) a.begin(), a.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nor cout << "NO\n"; return
#define yesr cout << "YES\n"; return
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>


using namespace std;


template<typename T, typename E>
vector<T> &operator>>(vector<T> &v, E a) {
    v.push_back(a);
    return v;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}

//vector<pair<T, E>> output
template<typename T, typename E>
ostream &operator<<(ostream &os, vector<pair<T, E>> &vec) {
    for (pair<T, E> i : vec) {
        os << i.first << ' ' << i.second << '\n';
    }
    return os;
}


int32_t main() {
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(10);
    ios_base::sync_with_stdio(false);
#ifdef TIME
    int32_t start = clock();
#endif

    int n;
    cin >> n;
    string cur;
    int ac = 0, wa = 0, tle = 0, re = 0;
    f(i, 0, n) {
        cin >> cur;
        if (cur == "AC") ac++;
        if (cur == "WA") wa++;
        if (cur == "TLE") tle++;
        if (cur == "RE") re++;
    }
    
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';

#ifdef TIME
    cout << "\ntime: " << (clock() - start) / (CLOCKS_PER_SEC * 1.0);
#endif

    return 0;
}

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

int main(){
    int sum = 0, n = 0;
    string s, ans;

    while( getline(cin,s) ){
        ans = "";
        for(int i=0 ; i<s.size() ; i++){
            if(s[i]=='@'){
                for(int j=0 ; j<(s[i+1]-'0') ; j++){
                    ans += s[i+2];
                }
                i += 2;
            }else{
                ans += s[i];
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 0
<?php

    function sum_calc($target) {
        $sum = 0;
        $target_len = strlen($target);
        for ($i = 0; $i < $target_len; $i++) {
            $sum = $sum + substr($target, ($target_len - $i - 1), 1);
        }
        return $sum;
    }

    fscanf(STDIN, "%d", $stdin);
    $min = 100000;
    for ($a = 1; $a <= $stdin / 2; $a++) {
        $b = $stdin - $a;
        $sum_a_b = sum_calc($a) + sum_calc($b);
        if ($sum_a_b < $min) $min = $sum_a_b;
    }
    echo($min);

?>

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

pair <int, int> arr[100005];

ll ans[100005];

int n;

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i].fi);
        arr[i].se = i;
    }

    sort(arr + 1, arr + n + 1);
    reverse(arr + 1, arr + n + 1);

    int mn = n + 1;

    for (int i = 1; i <= n; ++i) {
        ll diff = arr[i].fi - arr[i + 1].fi;

        mn = min(mn, arr[i].se);
        ans[mn] += diff * i;
    }

    for (int i = 1; i <= n; ++i) {
        printf("%lld\n", ans[i]);
    }
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
    int q, num;
    int64_t p;
    cin >> q;
    vector<int> A;
    for (int i=0; i<q; i++){
        cin >> num;
        if (num == 0 || num == 1){
            cin >> p;
        }
        if (num == 0){
            A.push_back(p);
        }else if (num == 1){
            cout << A.at(p) << endl;
        }else{
            A.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;

  int ans = 0;
  for (int i = 1; i <= N; i+= 2){
    int num_of_divisors = 0;
    for (int j = 1; j <= i; j++){
      if (i % j == 0) num_of_divisors ++;
    }
    if (num_of_divisors == 8) ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
from itertools import accumulate


def get_prime_numbers_til(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


N_MAX = 10 ** 5
primes = get_prime_numbers_til(N_MAX)
is_2017_like = list(accumulate([1 if i in primes and (i + 1) // 2 in primes else 0 for i in range(N_MAX + 1)]))
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(is_2017_like[r] - is_2017_like[l - 1])


Measured memory_bytes: 8292
N = int(input())
B = list(map(int, input().split()))

A = [0]*N


A[0] = B[0]

for i in range(1, N-1):
    A[i] = min(B[i-1], B[i])
    
A[-1] = min(B[-1], B[-1])

print(sum(A))

Measured memory_bytes: 3064
#include<iostream>
#define MAX 50000
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	vector<int> a(MAX),pri;
	fill(a.begin(),a.end(),1);
	a[0]=0;
	a[1]=0;
	for(int i=0;i<=MAX;i++)
	if(a[i]){
		for(int j=i*2;j<=MAX;j+=i)
		a[j]=0;
		pri.push_back(i);
	}
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=0;pri[i]<=n/2;i++)
		for(int j=i;pri[j]+pri[i]<=n;j++)
		if(pri[j]+pri[i]==n){
		ans++;
			break;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility> 
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

ll kai[200001];
ll gyaku[200001];

//繰り返し2乗法
ll kuri2(ll n, ll p){
    if(p==0)
			return 1;
		ll res=kuri2(n*n%MOD,p/2);
		if(p&1)
			res=res*n%MOD;
		return res;
}

ll extgcd(ll a,ll b,ll &x, ll &y)
{
	ll d=a;
	if(b!=0)
	{
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;y=0;
	}
	return d;
}

ll inv(ll a)
{
	ll x,y;
	extgcd(a,MOD,x,y);
	return (MOD+x%MOD)%MOD;
}

int main()
{
	int n;
	ll a,b,c;
	ll ans=0;
	cin>>n>>a>>b>>c;
	ll mother=kuri2(a+b,2*n-1)*(100-c);//分母
	mother%=MOD;
	if(mother<0)
		mother+=MOD;
	kai[0]=1;
	gyaku[0]=inv(1);
	for(ll i=1;i<200001;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
		gyaku[i]=inv(kai[i]);
	}
	//cerr<<(kai[10]*gyaku[10])%MOD<<endl;
	//ここまで前計算
	ll child=0;
	//高橋が勝つ
	for(ll i=0;i<n;i++)
	{
		ll kei=i+n;
		ll tmp=kuri2(a,n)*kuri2(b,i);
		tmp%=MOD;
		ll comb=kai[i+n-1]*gyaku[n-1];
		comb%=MOD;
		comb*=gyaku[i];
		comb%=MOD;
		tmp*=comb;
		tmp%=MOD;
		//補正する
		tmp*=kuri2(a+b,n-1-i);
		tmp%=MOD;
		tmp*=100;
		tmp%=MOD;
		tmp*=((ll)n+i);
		tmp%=MOD;
		//cerr<<n<<" "<<i<<" "<<tmp<<endl;
		child+=tmp;
		child%=MOD;
	}
	//アオキが勝つ
	for(ll i=0;i<n;i++)
	{
		ll kei=i+n;
		ll tmp=kuri2(b,n)*kuri2(a,i);
		tmp%=MOD;
		ll comb=kai[i+n-1]*gyaku[n-1];
		comb%=MOD;
		comb*=gyaku[i];
		comb%=MOD;
		tmp*=comb;
		tmp%=MOD;
		tmp*=100;
		tmp%=MOD;
		tmp*=((ll)n+i);
		tmp%=MOD;
		//補正する
		tmp*=kuri2(a+b,n-1-i);
		tmp%=MOD;
		child+=tmp;
		child%=MOD;
	}
	if(child<0)
		child+=MOD;
	//cerr<<mother<<" "<<child<<endl;
	//cerr<<kuri2(mother,MOD-1)%MOD<<endl;
	//motherの逆元はその場で求める
	ans=child*inv(mother);
	ans%=MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		if(a*b >= c*d){
			System.out.println(a*b);
		}
		else {
			System.out.println(c*d);
		}
	}
}


Measured memory_bytes: 23764
m,d = gets.chomp.split(" ").map(&:to_i)

cnt = 0
for i in 4..m do
    for j in 2..9 do 
        if i % j == 0
            d10 = i/j
            if d10 >1 && (d10 * 10 + j) <= d 
                # print i,"=",j,"x",d10,"\n"
                cnt += 1
            end
        end
    end
end

p cnt

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t;
	return 0;
}

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

#define ff first
#define ss second

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

int main()
{
	ios::sync_with_stdio(false);

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll divisible = (b / c) + (b / d) - (b / lcm(c, d));
	divisible -= ((a-1) / c) + ((a-1) / d) - ((a-1) / lcm(c, d));
	ll ans = b - a + 1 - divisible;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int n,a[100002] = {0},p = 0;

int solve(int c) {
    if((a[c] - a[c+1]) * (a[c] - a[c-1]) <= 0)
        return p;
    else {
        return p - min(abs(a[c] - a[c+1]),abs(a[c] - a[c-1])) * 2;
    }
}

int main(void) {
    cin >> n;
    for(int i = 1;i <= n;i++)
        cin >> a[i];
    for(int i = 0;i <= n;i++)
        p += abs(a[i] - a[i+1]);
    for(int i = 1;i <= n;i++)
        cout << solve(i) << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

const int INF = 1<<28;

struct edge_t {
    int from, to, cost;
    edge_t(int from, int to, int cost) : from(from), to(to), cost(cost) {}
    bool operator<(const edge_t &o) const {
        return (cost < o.cost);
    }
    bool operator>(const edge_t &o) const {
        return (cost > o.cost);
    }
};
struct state_t {
    int v;
    int min_cost;
    state_t(int v, int min_cost) : v(v), min_cost(min_cost) {}
    bool operator<(const state_t &o) const {
        return (min_cost < o.min_cost);
    }
    bool operator>(const state_t &o) const {
        return (min_cost > o.min_cost);
    }
};
typedef vector<edge_t> vertex_t;
struct graph_t {
    vector<vertex_t> g;

    graph_t() {}

    graph_t(int vertex_count) {
        g.resize(vertex_count);
    }
    graph_t(vector<vertex_t> g) : g(g) {}

    inline vertex_t& operator[](int index) {
        return g[index];
    }

    inline void push_back(vertex_t v) {
        g.push_back(v);
    }

    int prim() {
        bool used[g.size()];
        int min_span_cost = 0;
        priority_queue< edge_t, vector<edge_t>, greater<edge_t> > q;

        fill(used, used+g.size(), false);

        used[0] = true;
        for (int i = 0; i < g[0].size(); i++) {
            q.push(g[0][i]);
        }

        while (!q.empty()) {
            edge_t e = q.top(); q.pop();
            if (used[e.to]) continue;
            used[e.to] = true;
            min_span_cost += e.cost;
            for (int i = 0; i < g[e.to].size(); i++) {
                q.push(g[e.to][i]);
            }
        }

        return min_span_cost;
    }

    void dijkstra(int s, vector<int> &min_cost) {
        min_cost.resize(g.size());
        priority_queue< state_t, vector<state_t>, greater<state_t> > q;
        
        fill(min_cost.begin(), min_cost.end(), INF);

        min_cost[s] = 0;
        q.push(state_t(s, 0));

        while (!q.empty()) {
            state_t p = q.top(); q.pop();
            int v = p.v;
            if (min_cost[v] < p.min_cost) continue;
            for (int i = 0; i < g[v].size(); i++) {
                edge_t e = g[v][i];
                if (min_cost[e.to] > min_cost[v] + e.cost)  {
                    min_cost[e.to] = min_cost[v] + e.cost;
                    q.push(state_t(e.to, min_cost[e.to]));
                }
            }
        }
    }
};

int main() {
    int n, m;
    while (cin >> n) {
        if (n == 0) break;
        cin >> m;
        graph_t g(n);
        for (int i = 0; i < m; i++) {
            int a, b, cost;
            char d;
            cin >> a >> d >> b >> d >> cost;
            g[a].push_back(edge_t(a, b, cost/100-1));
            g[b].push_back(edge_t(b, a, cost/100-1));
        }
        cout << g.prim() << endl;
    }
    return 0;
}

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

int main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    for(;;){
        C -=B;
        if(C<=0){
            cout << "Yes"<< endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout << "No"<< endl;
            break;
        }
        
    }
        
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

int main(){
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	rep(i, h){
		rep(j, w){
			if (i < b && j < a || i >= b && j >= a) cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin>>n;
    vi h = readVector<int>(n);
    vi a = readVector<int>(n);

    set<pair<int,ll>> zet;
    zet.insert({-1,0});

    FOR(i,n) {
        auto it = zet.lower_bound({h[i], 0});
        ll nb = prev(it)->second + a[i];
        while(it!=zet.end() && nb>it->second)
            it = zet.erase(it);
        zet.insert({h[i], nb});
    }

    cout<<prev(zet.end())->second<<endl;

    return 0;
}



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

ans = [-10]*11
ans[0] = 1
c = 1
for i in range(k - 1):
    for j in range(c):
        if ans[j] == 9 and ans[j + 1] == -10:
            c += 1
            ans[j + 1] = 1
            for l in range(c - 1):
                ans[l] = 0
            break
        elif ans[j] == 9 or (ans[j] > ans[j + 1] and ans[j + 1] != -10):
            continue
        else:
            ans[j] += 1
            for l in range(j - 1,-1,-1):
                ans[l] = max(0,ans[l + 1] - 1)
            break

for i in range(len(ans)-1,-1,-1):
    if ans[i] == -10:continue
    print(ans[i],end="")
print()

Measured memory_bytes: 42736
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int a0 = 0, a2 = 0, a4 = 0;
		for(int i = 0;i < N;i ++) {
			int a = scn.nextInt();
			if(a%4==0) {
				a4++;
			}else if(a % 2 == 0) {
				a2++;
			}else {
				a0++;
			}
		}
		boolean ans = a4 >= a0 || a4 == N/2;
		System.out.println(ans?"Yes":"No");
	}

}


Measured memory_bytes: 49384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

typedef pair<ll,ll> pii;

int k;
ll dis[MAXN];
bool vis[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> k;

    priority_queue<pii, vector<pii>, greater<pii> > pq;

    memset(dis, 0x3f3f3f3f3f3f3f3f,sizeof(dis));
    REP1 (i, 9) {
        if (dis[i%k] > i) {
            dis[i%k] = i;
            pq.emplace(dis[i%k], i%k);
        }
    }

    while (pq.size()) {
        ll cur = pq.top().second;
        pq.pop();
        if (vis[cur]) {
            continue;
        }
        vis[cur] = true;

        REP (i, 10) {
            ll x = (cur*10 + i) % k;
            if (dis[x] > dis[cur] + i) {
                dis[x] = dis[cur] + i;
                pq.emplace(dis[x], x);
            }
        }
    }

    cout << dis[0] << endl;
}


Measured memory_bytes: 7280
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll INF = 1e9 + 10 ;
vector<ll> solve(long long x){
    vector<ll> v(40) ;
    ll cur = 1 ;
    for(ll i = 0; i < 40; i++){
        ll len = (1LL << cur) ;
        ll t = x + 1 ;
        v[i] = t / len * (1LL << i) ;
        ll c = t % len - len / 2 ;
        if ( c >= 0 ) v[i] += c ;
        cur++ ;
    }
    return v ;
}

int main(){
    long long a , b ;
    cin >> a >> b ;
    vector<ll> y = solve(b) ;
    debug() << imie(y) ; 
    if ( a != 0 ){
        a--;
        vector<ll> x = solve(a);
        for(ll i = 0; i < 40; i++){
            y[i] -= x[i] ;
        }
    }
    long long ans = 0 ; 
    for(ll i = 0; i < 40; i++){
        if ( y[i] % 2 != 0 ) ans += (1LL << i) ; 
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N;
	cin >> N;
  int wrong = 0;
  for (int i = 1; i <= N; i++) {
    int p;
    cin >> p;
    if (i!=p) wrong++;
  }
  if (wrong <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,d,i,ringo=1;
  scanf("%d %d",&n,&d);
  
  for(i=0;i<n;i++){
    ringo*=100;
  }
  
  if(d<100){
    printf("%d",ringo*d);
  } else {
    printf("%d",ringo*(d+1));
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    vector<int> RG;
    for (int i = 0; R * i <= 3000; i++) {
        for (int j = 0; G * j <= 3000; j++ ) {
            int temp = (R * i) + (G * j);
            if (temp <= 3000) RG.push_back(temp);
        }
    }
    vector<bool> BN(10000, false);
    for (int i = 0; N - (B * i) >= 0; i++) {
        BN[N - (B * i)] = true;
    }
    int ans = 0;
    for (int i = 0; i < RG.size(); i++) {
        if (BN[RG[i]]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 66528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int x, t;
  cin >> x >> t;

  cout << max(0, x-t) << endl;

  return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll t1,t2,a1,a2,b1,b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;
    ll d1 = t1 * (a1 - b1);
    ll d2 = t2 * (a2 - b2);
    if(d1 < 0){
        d1 = -d1;
        d2 = -d2;
    }
    if(d1 + d2 > 0){
        cout << 0 << endl;
    }else if(d1 + d2 == 0){
        cout << "infinity" << endl;
    }else{
        ll d = -(d1 + d2);
        ll n = d1 / d;
        ll ans = 2*n + 1;
        if(d1 % d == 0) ans--;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, A, B;
	
	cin>>N>>A>>B;
	
	cout<<min(N*A, B)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
#pragma endregion

int main()
{
  init_main();

  ll n, m;
  cin >> n >> m;

  if (n % 2 == 0)
  {
    bool add = false;
    for (int l = 1, r = n, cnt = 0; cnt < m; cnt++, l++, r--)
    {
      if (cnt == (m + 1) / 2 && !add)
      {
        l++;
        add = true;
      }
      cout << l << " " << r << "\n";
    }
  }
  else
  {
    for (int l = 1, r = n, cnt = 0; cnt < m; cnt++, l++, r--)
    {
      cout << l << " " << r << "\n";
    }
  }

  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    map<array<int, 2>, int> count;
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            count[array<int,2>{i, j}] = 0;
        }
    }
    for(int i=1; i<=N; i++){
        auto i0 = i % 10;
        auto i1 = i;
        while(i1>=10) i1 /= 10;
        auto k = array<int, 2>{i1, i0};
        count[k]++;
    }
    int res = 0;
    for(auto m : count){
        auto k = m.first;
        auto k2 = array<int, 2>{k[1], k[0]};
        res += count[k] * count[k2];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,K,cnt[15];
char s[15][1005];
int main()
{
    scanf("%d%d%d",&n,&m,&K);
    for (int i=0;i<n;++i) scanf("%s",s[i]);
    int res=1000000000;
    for (int i=0;i<1<<(n-1);++i) {
        int tmp= __builtin_popcount(i);
        vector<int> vec;
        vec.push_back(0);
        for (int j=0;j<n-1;++j) {
            if (i>>j&1) vec.push_back(0);
            cnt[j+1]=vec.size()-1;
        }
        for (int j=0;j<m;++j) {
            for (int k=0;k<n;++k) {
                if (s[k][j]=='1') ++vec[cnt[k]];
                if (vec[cnt[k]]>K) {
                    ++tmp;
                    fill(vec.begin(),vec.end(),0);
                    for (int l=0;l<n;++l) {
                        if (s[l][j]=='1') ++vec[cnt[l]];
                        if (vec[cnt[l]]>K) tmp=1000000000;
                    }
                    break;
                }
            }
        }
        res=min(res,tmp);
    }
    printf("%d\n",res);
    return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

int main()
{
    string s;
    cin >> s;
    rep(i, s.length())
    {
        if (s[i] == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<iostream>
int main(){
  int n,m,**M,*V,i,j,ans;
  std::cin >> n >> m;
  M = new int* [n];
  for(i=0; i<n; i++) M[i] = new int [m];
  for(i=0; i<n; i++) for(j=0; j<m; j++) std::cin >> M[i][j];
  V = new int [m];
  for(i=0; i<m; i++) std::cin >> V[i];
  for(i=0; i<n; i++){
    ans = 0;
    for(j=0; j<m; j++) ans += M[i][j] * V[j];
    std::cout << ans << "\n";
  }
  for(i=0; i<n; i++) delete[] M[i];
  delete[] M;
  delete[] V;
  return 0;
}

Measured memory_bytes: 3136
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    s=input().replace('?','.')
    t=input()
    import re
    for i in range(len(s)-len(t),-1,-1):
        if re.match(s[i:i+len(t)],t):
            s=s.replace('.','a')
            print(s[:i]+t+s[i+len(t):])
            return
    print("UNRESTORABLE")
resolve()

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int N, K;
    cin >> N >> K;
    set<int> have;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            have.insert(A);
        }
    }
    cout << N - (int) have.size();
}


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

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

    int n;
    cin >> n;
    int residence[4][3][10]{0};
    rep(qi, n) {
        int b, r, f, v;
        cin >> b >> r >> f >> v;

        if (residence[b - 1][r - 1][f - 1] + v < 0) {
            residence[b - 1][r - 1][f - 1] = 0;
        } else if (residence[b - 1][r - 1][f - 1] + v > 9) {
            residence[b - 1][r - 1][f - 1] = 9;
        } else {
            residence[b - 1][r - 1][f - 1] += v;
        }
    }

    rep(i, 4) {
        rep(j, 3) {
            rep(k, 10) cout << " " << residence[i][j][k];
            cout << "\n";
        }
        if (i != 3)
            cout << "####################\n";
    }
    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
using namespace std;
int N,A[10010];
int min(){
    int n,minn=A[0];
    for (n=0;n<N;++n)
    {
        if (minn>A[n])
            minn=A[n];
    }
    return minn;
}
int max(){
    int maxx=A[0];
    for (int n=0;n<N;++n)
    {
        if (maxx<A[n])
            maxx=A[n];
    }
    return maxx;
}
long long sum(){
    long long s=0;
    for(int n=0;n<N;++n)
        s=s+A[n];
    return s;
}
int main(){
    //cout<<"input N:"<<endl;
    cin>>N;
    //cout<<"input A[]:"<<endl;
    for(int i=0;i<N;i++)
    {cin>>A[i];}
    cout<<min()<<' '<<max()<<' '<<sum()<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n;

void preParse(int);
void inParse(int);
void postParse(int);

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=NIL;


   for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

   for(i=0;i<n;i++) if( T[i].p==NIL) root=i;

   printf("Preorder\n");
   preParse(root);
   printf("\n");
   printf("Inorder\n");
   inParse(root);
   printf("\n");
   printf("Postorder\n");
   postParse(root);
   printf("\n");
   
  return 0;
}

void preParse(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
 if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}



Measured memory_bytes: 2048
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    a = input()
    if a == "AC":
        ac +=1
    elif a == "WA":
        wa +=1
    elif a == "TLE":
        tle +=1
    else:
        re +=1

print("AC x %d" % ac)
print("WA x %d" % wa)
print("TLE x %d" % tle)
print("RE x %d" % re)

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

int main() {
	int n; cin >> n;
	int c = 0;
	rep(i, n) {
		string s; cin >> s;
		if (s == "A")c++;
		else c--;
		if (c < 0)break;
	}
	puts(c ? "NO" : "YES");
}

Measured memory_bytes: 3152
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll x,i,N,Q,ng,ok,mid;
  cin>>N>>Q;
  vec v(N),sum(N+1,0),tsum(N+1,0);
  rep(i,N)cin>>v[i];
  rep(i,N){
    tsum[N-i-1]=tsum[N-i]+(~i&1)*v[N-i-1];
    sum[N-i-1]=sum[N-i]+v[N-i-1];
  }
  while(Q--){
    cin>>x;
    if(x>=v[N-2]){
      print(tsum[0]);
      continue;
    }
    ok=N-1;
    ng=upper_bound(all(v),x)-v.begin();
    ng-=ng&&x-v[ng-1]<=v[ng]-x;
    while(ok-ng>1){
      mid=(ok+ng)>>1;
      if(N-mid-1<=mid-(lower_bound(all(v),x*2-v[mid])-v.begin())){
        ok=mid;
      }else{
        ng=mid;
      }
    }
    print(sum[ok]+tsum[0]-tsum[max(0LL,ok*2-N)]);
  }
  // }return 0;
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long

int main()
{
    ll t,n,c,res;
    ci>>n;
    c=n%10;
    if(c==2||c==4||c==5||c==7||c==9) co<< "hon";
    else if(c==0||c==1||c==6||c==8) co<< "pon";
    else co<< "bon";
}





Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main() {
    int A, B, flag = 0;
    cin >> A >> B;
    for(int i = 1; i <= 10000; i++)
    if(i * 8 / 100 == A && i / 10 == B) {
        cout << i << endl;
        return 0;
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
N = n//2
ans = float("INF")
for i in range(1,N+1):
  a,b = list(str(i)), list(str(n-i))
  A,B = sum(list(map(int, a))), sum(list(map(int, b)))
  if ans > A+B: ans = A+B
print(ans)

Measured memory_bytes: 3060