akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}
const int MOD = 1e9 + 7;

ll power(int n, int p)
{
    if (p == 0)
        return 1;
    long long res = 1;
    long long add = n;
    while (p > 0)
    {
        if (p & 1)
            res = (res * add) % MOD;
        p >>= 1;
        add = add*add%MOD;
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> num(k+1, 0);

    RFOR(i, k, 1){
        ll kazu = power(k/i, n);
        int j = 2;
        while(i*j<=k){
            kazu = (kazu + MOD - num[i*j]) % MOD;
            j++;
        }
        num[i] = kazu;
    }

    ll ans = 0;
    IFOR(i, 1, k)
        ans = (ans + i * num[i]) % MOD;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;
int main() {
    long long N;
    cin >> N;

    cout << N << ":";

    for (long long i = 2; i * i <= N; ++i) {
        while ((N % i) == 0) {
            cout << " " << i;
            N /= i;
        }
    }
    if (N != 1) {
        cout << " " << N;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n,k;
  string s;
  cin >> n >> s >>k;
  char c=s.at(k-1);
  for(int i=0;i<n;i++){
    if(s.at(i)!=c)s.at(i)='*';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;
int gcd(int a,int b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int p,s,q;
    bool x[31]={0};
    map<int,int> m;
    for (;;){
        scanf("%d,%d",&p,&s);
        if (p==0 && s==0) break;
        m[p]=s;
        x[s]=1;
    }
    while (scanf("%d",&q)!=EOF) {
        int cnt=0;
        for (int i=31;i>-1;--i) {
            if (x[i]==1) cnt++;
            if (i==m[q]) {
                printf("%d\n",cnt);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3140
#include <stdio.h>

const int mod = 1e9 + 7;

char a[1100][1100];
int h, w;
int dp[1100][1100];

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

    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i > 0 && a[i - 1][j] != '#') {
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            }
            if (j > 0 && a[i][j - 1] != '#') {
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            }
        }
    }

    dp[h - 1][w - 1] %= mod;
    printf("%d\n", dp[h - 1][w - 1]);
}

Measured memory_bytes: 5504
from sys import stdin

N,M,C = map(int, input().split(' '))
B = stdin.readline().rstrip().split(' ')
A = [stdin.readline().rstrip().split(' ') for i in range(N)]

cnt = 0
for a in A :
  sum = 0
  for j in range(M):
    sum += int(a[j]) * int(B[j])
  sum += C
  if(sum > 0) :
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


int main(){
	ll n,d; cin >> n >> d;
	d *= d;
	ll ans = 0;
	ll x,y;
	Rep(n){
		cin >> x >> y;
		if(x*x + y*y <= d) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t[101]={0},ans=0;
  for(int i=0;i<12;i++){
    int b;
    cin>>b;
    t[b]++;
    if(t[b]%4==0){
      ans++;
    }
  }
  if(ans==3){
    cout<<"yes"<<endl;
  }else{
    cout<<"no"<<endl;
  }
  return(0);
}



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

const int K = 10000;

void counting_sort(int A[], int B[], int n) {
  int i;
  int C[K+1] = {};

  for (i = 1; i < n+1; i++) C[A[i]]++;

  int accum = 0;
  for (i = 0; i < K+1; i++) {
    accum += C[i];
    C[i] = accum;
  }

  for (i = n; i > 0; i--) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}
  

int main() {
  int i, n;
  int *A, *B;

  cin >> n;
  
  A = new int[n+1];
  B = new int[n+1];

  for (i = 1; i < n+1; i++) {
    cin >> A[i];
    B[i] = 0;
  }

  counting_sort(A, B, n);

  for (i = 1; i < n+1; i++) {
    if (i > 1) cout << " ";
    cout << B[i];
  }
  cout << endl;    

  return 0;
}



Measured memory_bytes: 18760
#include <stdio.h>
#include <string.h>
#include <math.h>
#define MIN(a,b) (a<b?a:b)
typedef long long int ll;
ll count = 0;

ll sitigosan(ll num)
{
    ll i;
    ll keta;
    ll cnt[3]={0};
    for(i=0; num>1; i++) {
        keta = num % 10;
        num /= 10;
        if(keta==3)cnt[0]++;
        if(keta==5)cnt[1]++;
        if(keta==7)cnt[2]++;
    }
    if(cnt[0]*cnt[1]*cnt[2]==0)
        return 0;
    else
        return 1;
}

void kurikaesi(ll n, ll num)
{
    ll i;
    ll temp = num;
    for(i=1; i<=3; i++) {
        num = temp*10 + (2*i+1);
        if(num <= n) {
            //printf("%lld\n",num);
            count += sitigosan(num);
            kurikaesi(n, num);
        }
    }
}

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

    kurikaesi(n, 0);

    printf("%lld",count);
    
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    int res = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i && a[i] <= a[i - 1]) {
            cnt++;
            res = max(res, cnt);
        }
        if (i && a[i] > a[i - 1]) {
            cnt = 0;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9 + 7;
vector<int> v;


int main(){
    int x;
    cin >> x;
    int k = 1;
    /*
    while(pow(k,5) < 10e9 * 2){
        k++;
    }
    */
    //cout << k << endl;
    for(int i=-130;i<130;i++){
        for(int j=-130;j<130;j++){
            if(pow(i,5) - pow(j,5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }


}

Measured memory_bytes: 4036
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
vector<ll> v1, v2;
int main()
{
    ll i, j, k;
    ll n, t, m;
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    sort(a+1, a+1+n);
    for(i = 1; i <= n; i++) {
        if(a[i] >= 0)
            v1.push_back(a[i]);
        else v2.push_back(a[i]);
    }
    ll unpo = ((ll)v1.size()) * (v2.size());
    if(unpo >= k) {
        ll l = -1e18;
        ll r = 0;
        while(l < r) {
            ll mid = (l+r) >> 1;
            ll tmp = k; ll sum = 0;
            for(i = 0; i < v1.size(); i++) {
                if(v1[i] == 0) ;
                else sum += upper_bound(v2.begin(), v2.end(), (mid-v1[i]+1) / v1[i])-v2.begin();
            }
            if(sum >= k) {
                r = mid;
            }
            else l = mid+1;
        }
        cout << l << endl;
    }
    else {
        ll l = 0;
        ll r = 1e18;
        k -= unpo;
        for(i = 0; i < v2.size(); i++) {
            v2[i] = -v2[i];
        }
        reverse(v2.begin(), v2.end());
        while(l < r) {
            ll mid = (l+r) >> 1;
            ll tmp = k; ll sum = 0;
            for(i = 0; i < v1.size(); i++) {
                if(v1[i] == 0) sum += v1.size()-i-1;
                else sum += max(0LL, upper_bound(v1.begin(), v1.end(), (mid) / v1[i])-v1.begin()-i-1);
            }
            for(i = 0; i < v2.size(); i++) {
                sum += max(0LL, upper_bound(v2.begin(), v2.end(), (mid) / v2[i])-v2.begin()-i-1);
            }
            if(sum >= k) {
                r = mid;
            }
            else l = mid+1;
        }
        cout << l << endl;
    }

    return 0;
}


Measured memory_bytes: 4084
# include <iostream>
# include <vector>
# include <algorithm>
# include <set>
# include <map>
# include <iomanip>
# include <string>
# include <cmath>

using namespace std;

const int N = 2e5 +100;
int n;
int a[N], used[N];
int cnt[N];

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

    for( int i = n; i >= 1; i -- ){
        if( cnt[i] % 2 == a[i] )
            continue;
        else{
            used[i]++;
            int x = sqrt( i );
            for( int j = 1; j <= x; j ++ ){
                if( i % j == 0 ){
                    cnt[j] ++;
                    if( i / j != j )
                        cnt[i/j] ++;
                }
            }
        }
    }
    int jnt = 0;
    for( int i = 1; i <= n; i ++) {
        if( cnt[i] % 2 != a[i] ){
            cout << -1;
            return 0;
        }
        if( used[i] ) jnt++;
    }
    cout << jnt << endl;
    for( int i = 1; i <= n; i ++ ){
        if( used[i] ) cout << i << ' ';
    }
    return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
int n,m,a[210][5010];
LL d[5010],sum[5010][5010],ans;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void add(int x1,int x2,int y1,int y2,int w)
{
    sum[x1][y1]+=w;
    sum[x1][y2+1]-=w;
    sum[x2+1][y1]-=w;
    sum[x2+1][y2+1]+=w;
}

void solve(int *a)
{
    static int l[5010],r[5010],stk[5010],top;
    stk[top=0]=0;
    repu(i,1,n)
    {
        for (; top && a[stk[top]]<a[i]; --top);
        l[i]=stk[top]+1,stk[++top]=i;
    }
    stk[top=0]=n+1;
    repd(i,n,1)
    {
        for (; top && a[stk[top]]<=a[i]; --top);
        r[i]=stk[top]-1,stk[++top]=i;
        add(i,r[i],l[i],i,a[i]);
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,2,n)
        d[i]=d[i-1]+getint();
    repu(i,1,n)
        repu(j,1,m)
            a[j][i]=getint();
    repu(i,1,m)
        solve(a[i]);
    repu(i,1,n)
    {
        repu(j,1,i)
        {
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
            ans=max(ans,sum[i][j]-d[i]+d[j]);
        }
        repu(j,i+1,n)
            sum[i][j]+=sum[i][j-1];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 200192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

int main(void){
  string t; cin >> t;
  int n = t.size();
  rep(i,n){
    if(i == n-1 && t.at(i) == '?') t.at(i) = 'D';
    else if(t.at(i) == '?') t.at(i) = 'D'; 
  }
  cout << t << endl;
  return 0;
}


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

int main() {
#ifdef LOCAL_DEFINE
  // freopen("data.in", "rt", stdin);
  // freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1);
	for(int i = 0; i < n; i++) {
		cin >> h[i + 1];
	}
	const int inf = 1e9;
	vector<int> dp(n + 1, inf);
	dp[1] = 0;
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i - j < 0) continue;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n] << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class CLower {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> H(n);
    for (auto &h: H) cin >> h;

    int ans = 0, cur = 0;
    for (auto h = H.rbegin() + 1; h != H.rend(); h++){
        if (*h >= *(h - 1)){
            cur++;
        } else{
            cur = 0;
        }
        ans = max(ans, cur);
    }

    cout << ans << endl;
}
};

int main() {
	CLower solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>   
using namespace std;      
int main(){               
    while(1){
        int n; cin>>n;
        if(n == 0) break;
        vector<int> a(n);
        int heikin=0;
        for(int i=0;i<n;i++){
            cin >> a[i];
            heikin += a[i];
        }
        heikin/=n;
        int ans =0;
        for(int i=0;i<n;i++){
            if(a[i]<=heikin) ans++;
        }
        cout << ans <<endl;
    }    
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, l, a, b, c, d, ans = 0;
    string s, t, r;

    cin >> s;
    s[3] = '8';

    cout << s << endl;
}

Measured memory_bytes: 764
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    capacity: usize,
    things: [(usize, i64); n]
  }
  let mut dp = vec![vec![0; capacity + 1]; n + 1];
  for item in 0..n {
    for cap in 0..capacity+1 {
      dp[item+1][cap] = dp[item][cap];
      if things[item].0 <= cap {
        dp[item+1][cap] = cmp::max(dp[item+1][cap], dp[item][cap - things[item].0] + things[item].1);
      }
    }
  }
  let ans = dp[n].iter().fold(0, |current, val| cmp::max(current, *val));
  println!("{}", ans);
}


Measured memory_bytes: 106748
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  int n=s.size();
  bool ans=true;
  for(int i=0;i<n;++i) {
    if(t[i]!=s[i]) ans=false;
  }
  puts(ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <cstring>
int Len;
char s[ 100005 ];
int main() {
	scanf ("%s", s);
	Len = strlen(s);
	printf ("%s\n", ((Len % 2 == 1) ^ (s[ 0 ] == s[ Len - 1 ])) ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
res = float("inf")
if x <= y:  # xx
    res = min(res, y - x)
if -x <= y:  # ox
    res = min(res, y + x + 1)
if x <= -y:  # xo
    res = min(res, -y - x + 1)
if -x <= -y:  # oo
    res = min(res, -y + x + 2)
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int dp[maxn*10];
int main(){
	int n;
	in(n);
	int ans=0;
	FOR(i,1,n){
		int c;
		in(c);
		dp[c]=dp[c-1]+1;
		ans=max(ans,dp[c]);
	}
	out(n-ans);
}


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

char Trump;
string card[4][13];// N, W, S, W
int point[2];
int num[256];

void make() {
  for(int i = 2; i <= 9; ++i)
    num['0'+i] = i;
  num['T'] = 10;
  num['J'] = 11;
  num['Q'] = 12;
  num['K'] = 13;
  num['A'] = 14;
}

int main() {
  make();
  while(cin >> Trump && Trump != '#') {
    for(int i = 0; i < 4; ++i) {
      for(int j = 0; j < 13; ++j) {
	cin >> card[i][j];
      }
    }
    fill(point, point+2, 0);
    int d = 0;
    for(int i = 0; i < 13; ++i) {
      pair<pair<int, int>,int> w = make_pair(make_pair(-1,0),0);
      for(int j = 0; j < 4; ++j) {
	pair<pair<int, int>,int> p;
	string &c = card[(d+j)%4][i];
	int a;
	if(c[1] == Trump)              a = 2;
	else if(c[1] == card[d][i][1]) a = 1;
	else                           a = 0;
	p = make_pair(make_pair(a, num[c[0]]), -j);
	w = max(w, p);
      }
      d = (d-w.second)%4;
      ++point[d%2];
    }
    if(point[0] > point[1])
      cout << "NS " << point[0]-6 << endl;
    else
      cout << "EW " << point[1]-6 << endl;
  }
  return 0;
}

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

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

    vector<double> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    double sum = 0;
    for(int i=0; i<n; i++){
        sum += 1 / a[i];
    }
    cout << fixed << setprecision(10) << 1 / sum << endl;
    return 0;
}

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

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int sl, tl;
    sl = s.size();
    tl = t.size();
    vector<char> svec(sl), tvec(tl);
    for (int i = 0; i <sl; i++){
        svec[i] = s[i];
    }
    for (int i = 0; i < tl; i++){
        tvec[i] = t[i];
    }
    char smin, smax, tmax;
    smin = *min_element(svec.begin(), svec.end());
    smax = *max_element(svec.begin(), svec.end());
    tmax = *max_element(tvec.begin(), tvec.end());
    int smaxco, tmaxco;
    smaxco = count(svec.begin(), svec.end(), smax);
    tmaxco = count(tvec.begin(), tvec.end(), tmax);
    if (smin < tmax){
            cout << "Yes" << endl;
    }else if(smin == tmax){
        if(smax == tmax && smaxco < tmaxco){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from itertools import combinations
 
 
def input():
    return sys.stdin.readline()[:-1]
 
 
def solve():
    a,b,c = map(int, input().split())
    if 4*a*b < (c-a-b)**2 and c-a-b>0:
        print('Yes')
    else:
        print('No')
 
    
 
 
if __name__ == "__main__":
    solve()

Measured memory_bytes: 14136
#include<cstdio>
int main()
{
	long long A,B;
	char op;
	while(scanf("%lld %c %lld",&A,&op,&B)!=EOF){
		if(op=='+')		printf("%lld\n",A+B);
		else		printf("%lld\n",A-B);
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200000];
int main(){
  int i;
  long long res = 0;
  map<int,int> mp;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    mp[A[i]+i]++;
  }
  for(i=(0);i<(N);i++){
    res += mp[i-A[i]];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// int N, A[2d5];
// {
//   ll res = 0;
//   map<int,int> mp;
//   rd(N,A(N));
// 
//   rep(i,N) mp[A[i]+i]++;
//   rep(i,N) res += mp[i-A[i]];
// 
//   wt(res);
// }


Measured memory_bytes: 22280
// finish date: 2018/01/06
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <limits>
#include <map>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int main() {
    int N, Y;
    cin >> N >> Y;
    int a=-1, b=-1, c=-1;
    Y /= 1000;
    rep(i, N+1) {
        if ((Y - N - 4 * i) % 9 == 0) {
            b = i;
            a = (Y - N - 4 * b) / 9;
            c = N - a - b;
            if (a >= 0 && b >= 0 && c >= 0) break;
        }
    }
    if (a < 0 || b < 0 || c < 0) cout << "-1 -1 -1" << endl;
    else cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int> > G;
int d[111],f[111],u[111];
void dfs(int v,int& p){
  if(u[v]) return;
  u[v]=1;
  sort(G[v].begin(),G[v].end());
  d[v]=++p;
  for(int u:G[v]) dfs(u,p);
  f[v]=++p;
}
signed main(){
  int n;
  cin>>n;
  G.resize(n,vector<int>());
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      c--;
      G[u].push_back(c);
    }
  }
  int p=0;
  for(int i=0;i<n;i++)
    if(!u[i]) dfs(i,p);
  for(int i=0;i<n;i++) cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;;
  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

bool isPrime(int x) {
    if(x < 2) return false;
    if(x < 4) return true;
    if(x % 2 == 0) return false;
    for(int d = 3; d * d <= x; d++) {
        if(x % d == 0) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int x = 1;
    while(n) {
        x += 5;
        if(isPrime(x)) {
            cout << x << " ";
            n--;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		int t2 = h2*60 + m2;
		int t1 = h1*60 + m1;
		int ans = t2 - t1 - k;

		System.out.println(ans);
	}
}


Measured memory_bytes: 27040
#include <cstdio>
int n,m,ans,q1,q2;
bool passed[10];
bool edge[10][10];
void f(int last,int pass)
{
    if(pass < n)
    {
        for(int i = 2;i <= n;i++)
            if(!passed[i] && edge[i][last])
            {
                passed[i] = true;
                f(i,pass+1);
                passed[i] = false;
            }
    }
    else ans++;
}
main()
{
    scanf("%d %d",&n,&m);
    while(m--)
    {
        scanf("%d %d",&q1,&q2);
        edge[q1][q2] = edge[q2][q1] = true;
    }
    passed[1] = true;
    f(1,1);
    printf("%d\n",ans);
}


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

int main() {
	int h, w, a, b;
	cin>>h>>w>>a>>b;
	for (int i = 1; i <= h; i ++) {
		for (int j = 1; j <= w; j ++) {
			putchar('0' + ((i<=b)^(j<=a)));
		}
		putchar('\n');
	}
    return 0;
}


Measured memory_bytes: 1280
import fractions

A, B, C, D = list(map(int, input().split()))
C_mult = (B // C) - ((A-1) // C)
D_mult = (B // D) - ((A-1) // D)

E = C * D // fractions.gcd(C, D)

inter = (B // E) - ((A-1) // E)
whole = B - A + 1
print(whole - C_mult - D_mult + inter)

Measured memory_bytes: 5052
//https://atcoder.jp/contests/abc045/tasks/arc061_a

#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
    string s;
    long total = 0;
    cin >> s;
    for(int i = 0;i<s.size();i++){
        for(int j = 1; j + i<=s.size();j++){
            if(j==s.size()){
                total+= stoll(s);
                //cout << s << endl;
            }else if(i == 0 || j + i ==s.size() ){
                total += stoll(s.substr(i,j)) * pow(2,s.size()-j-1);
                //cout << s.substr(i,j) << "," << pow(2,s.size()-j-1) << endl;
            }else{
                total += stoll(s.substr(i,j)) * pow(2,s.size()-j-2);
                //cout << s.substr(i,j) << "," << pow(2,s.size()-j-2) << endl;
            }
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, c;
    cin >> n >> c;

    const int T = (int)1e5;

    vector<int> a(T);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--; c--;

        for (int j = s; j <= t; j++) {
            a[j] |= 1 << c;
        }
    }

    int r = 0;
    for (int j = 0; j < T; j++) {
        int s = a[j];
        s = (s & 0x55555555) + (s >> 1 & 0x55555555);
        s = (s & 0x33333333) + (s >> 2 & 0x33333333);
        s = (s & 0x0f0f0f0f) + (s >> 4 & 0x0f0f0f0f);
        s = (s & 0x00ff00ff) + (s >> 8 & 0x00ff00ff);
        s = (s & 0x0000ffff) + (s >> 16);
        r = max(r, s);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
H = list(map(int, input().split()))

# 全部消せる
if N <= K:
    print(0)
    exit()


dp = [[float('inf')] * (N + 1) for i in range(N + 1)]
dp[0][0] = 0
# 最初に使うとする場合には、その高さ分使う必要がある
for i, h in enumerate(H, start=1):
    dp[i][1] = h


for i in range(1, N + 1):
    for j in range(2, N + 1):
        for x in range(1, i):
            dp[i][j] = min(dp[i][j], dp[x][j - 1] + max(0, H[i - 1] - H[x - 1]))


ans = float('inf')
for i in range(N + 1):
    ans = min(ans, dp[i][max(0,  N - K)])

print(ans)


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

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

long long MOD = 1000000000 + 7;
long long MAX = 10000000000000000;

int main(){
  cout << setprecision(10);
  int N,M; cin >> N >> M;
  int all = (1<<N) -1;
  cerr << all << endl;

  vector<ll> a(M);
  int b;
  vector<ll> c(M,0);
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b;
    for(int j = 0; j < b; j++){
      int tmp; cin >> tmp;
      tmp--;
      c[i] += (1 << tmp);
    }

  }

  vector<vector<ll>> dp(M+1, vector<ll>(all+1, MAX));
  dp[0][0] = 0;

  for(int i = 0; i < M; i++){
    for(int j = 0; j <= all; j++){
      // iを使う場合
      dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j] + a[i]);
      // iを使わない場合
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }

  cout << ( dp[M][all] == MAX ? -1 : dp[M][all] )  << endl;


}



Measured memory_bytes: 35412
#include <stdio.h>
#include <stdlib.h>

#define ll long long
#define DEBUG printf("Passing [%s] in Line %d\n" , __FUNCTION__ , __LINE__) ;

ll n , x ;

ll work(ll a , ll b) {
	ll t = a / b ;

	if (!(a % b)) return (t << 1) * b - b ;
	else return work(b , a % b) + (t << 1) * b ;
}

int main() {
	scanf("%lld %lld" , &n , &x) ;
	printf("%lld\n" , n + work(n - x , x)) ;

	return 0 ;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        A[i] += 1
        cnt += 1
        if i != N -1 and A[i] == A[i+1]:
            A[i] += 1
print(cnt)

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> A(Q), player(N, 0);
    Rep (i, Q) {
        cin >> A[i];
        A[i]--;
        player[A[i]]++;
    }

    Rep (i, N) {
        if (player[i] > Q-K) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;    
    int ans[200005]={};
    vector<int> vec;

    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a;
        ans[a-1]++;
    }
    for(int i=0;i<n;i++) cout<<ans[i]<<endl;

    return 0;

}

Measured memory_bytes: 4412
Module Module085B
    Sub Main(ByVal args() As String)
        Dim i, j As Integer
        Dim result As Integer : result = 0
        Dim tmp As Integer
        Dim flag As Boolean

        Dim N As Integer
        N = Console.ReadLine()
        Dim arr_I() As Integer
        ReDim arr_I(N - 1)

        For i = 0 To N - 1
            flag = False
            tmp = Integer.Parse(Console.ReadLine())
            arr_I(i) = tmp
            For j = 0 To i
                If j <> i And tmp = arr_I(j) Then
                    flag = True
                End If
            Next

            'ここまでに同じ直径の餅が読み込まれなかったらカウントを増やす
            If flag = False Then
                result = result + 1
            End If

        Next

        Console.Write(result)
    End Sub
End Module


Measured memory_bytes: 11220
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


def main():
    Q = int(input())
    y = 0
    lheap = []
    rheap = []
    lsum = 0
    rsum = 0
    for _ in range(Q):
        q = input()
        if q[0] == '1':
            # update
            _, a, b = map(int, q.split())
            y += b
            if len(lheap) == 0 or -lheap[0] <= a <= rheap[0]:
                heappush(lheap, -a)
                heappush(rheap, a)
                lsum += a
                rsum += a
            elif a < -lheap[0]:
                mov = -heappop(lheap)
                heappush(rheap, mov)
                heappush(lheap, -a)
                heappush(lheap, -a)
                lsum += a*2 - mov
                rsum += mov
            elif rheap[0] < a:
                mov = heappop(rheap)
                heappush(lheap, -mov)
                heappush(rheap, a)
                heappush(rheap, a)
                lsum += mov
                rsum += a*2 - mov
        else:
            # inquiry
            x = -lheap[0]
            minimum = abs(x * len(lheap) - lsum) // 2 + \
                abs(x * len(rheap) - rsum) // 2 + y
            print(x, minimum)


if __name__ == "__main__":
    main()


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	int b=0;
	int64_t money=1000;
	for(int s=1;s<n;++s){
		if(a.at(b)<a.at(s)){
			int64_t stock=money/a.at(b);
			money-=stock*a.at(b);
			money+=stock*a.at(s);
			b=s;
		}
		else if(a.at(s)<a.at(b))b=s;
	}
	cout<<money<<"\n"s;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M, X; cin >> N >> M >> X;
    int cnt_z = 0, cnt_n = 0;
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        if (0 <= a && a <= X) cnt_z++;
        if (X <= a && a <= N) cnt_n++;
    }
    printf("%d\n", min(cnt_z, cnt_n));
}


Measured memory_bytes: 3740
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long K = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        sc.close();

        long sum = 1+K;
        if(A < B){
            long sum1 = 1;
            while(sum1 < A){
                sum1++;
                K--;
            }
            sum1 += (B-A)*(K/2);
            if(K%2 == 1)
                sum1 += 1;
            sum = Math.max(sum, sum1);
        }
        System.out.println(sum);
   }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(3);
	for(int i = 0; i < 3; i++) scanf("%d", &a[i]);
	int ans = 1 << 30;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(i == j or j == k or k == i) continue;
				ans = std::min(ans, std::abs(a[i] - a[j]) + std::abs(a[j] - a[k]));
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 998244353;
#define int ll
int n, t, a, ans;
vector<int> g[100010], dd;

int dfs(int p, int nod, int d){
	dd[nod]=d;
	for(int i: g[nod]){
		if(i!=p){
			dd[i]=dd[nod]+1;
			dfs(nod, i, d+1);
		}
	}
}

vi xd(int nod){
	dd=vector<int> (n+1);
	dfs(0, nod, 0);
	return dd;
}

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>t>>a;
	for(int i=1, x, y; i<n; i++){
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	vi T=xd(t);
	vi A=xd(a);
	for(int i=1; i<=n; i++){
		if(T[i]<=A[i]) ans=max(ans, A[i]);
	}
	cout<<--ans;
}

Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
struct Node;
struct Edge {
    int idx;
    int a;
    int b;
    int c = 0;
};
vector<Node> V;
vector<Edge> E;
struct Node {
    int idx;
    vector<int> nbr;
    bool vst = false;
    int odd = 0;
    int dfs(int lastEdge) {
        //cout << idx;
        vst = true;
        for(int x : nbr) {
            if(E[x].a == idx) {
                if(!V[E[x].b].vst) {
                    odd += V[E[x].b].dfs(x);
                }
            } else {
                if(!V[E[x].a].vst) {
                    odd += V[E[x].a].dfs(x);
                }
            }
        }
        if(lastEdge != -1) E[lastEdge].c += odd;
        return odd;
    };
};
int main()
{
    int N, M;
    cin >> N >> M;

    V = vector<Node>(N);
    E = vector<Edge>(M);

    REP(i, N) {
        V[i] = Node();
        V[i].idx = i;
    }

    REP(i, M) {
        int a, b;
        cin >> a >> b;
        E[i] = Edge();
        E[i].idx = i;
        E[i].a = a-1;
        E[i].b = b-1;
        V[a-1].nbr.push_back(i);
        V[b-1].nbr.push_back(i);
        V[a-1].odd++;
    }

    if(M % 2 != 0) {
        cout << -1;
        return 0;
    }

    V[0].dfs(-1);

    REP(i, M) {
        if(E[i].c % 2 == 0) {
            cout << E[i].a+1 << " " << E[i].b+1 << endl;
        } else {
            cout << E[i].b+1 << " " << E[i].a+1 << endl;
        }
    }
}

Measured memory_bytes: 26368
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
long long n,m,k,tian;
int main()
{
    cin>>n>>m>>k;
    if(m>=n)
    {
        cout<<1;
        return 0;
    }
    if(k>=m)
    {
        cout<<-1;
        return 0;
    }
    if((n-m)%(m-k)>=1)
	{
		tian=1;
	}
    cout<<((n-m)/(m-k)+tian)*2+1;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
print(min(A*N, B))

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

int main(){
  char sub[1000000];
  int inicio = 0, fim = 0, h = 0;
  scanf("%s", sub);

  int n = strlen(sub);
  for(int i = 0; i < n; ++i){
    if(sub[i] == 'A' && h == 0){
      inicio = i;
      h = 1;
    }
    if(sub[i] == 'Z')
      fim = i;
  }

  printf("%d\n", fim-inicio+1);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> cnt(n);
	rep(i,n-1){
		int a;
		cin >> a;
		a--;
		cnt[a]++;
	}
	rep(i,n){
		cout << cnt[i] << "\n";
	}
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


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

int main() {
	int k, x,st,en;
	cin >> k >> x;
	st = x - (k - 1);
	en = x + (k - 1);
	for (st; st <= en; st++) {
		cout << st << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.lang.Math.*

fun main(args: Array<String>) {
    val (x, n) = readListInt()
    if (n == 0) {
        println(x)
        return
    }
    val p = readListInt()

    val booleans = BooleanArray(102) {true}
    repeat(n) {
        booleans[p[it]] = false
    }
    var m = Int.MAX_VALUE
    var ans = Int.MAX_VALUE
    for (i in 0 until 102) {
        if (booleans[i]) {
            val d = abs(x - i)
            if (d < m) {
                ans = i
            }
            m = min(d, m)
        }
    }
    println(ans)
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 36372
#include <cmath>
#include <iostream>
#include <iomanip>

/*
ax + by = c
dx + ey = f

x = (c-by)/a
d(c-by)/a + ey = f
dc/a - dby/a + ey = f
ey - dby/a = f - dc/a
y(e-db/a) = f - dc/a
y = (f-dc/a)/(e-db/a)

aex + bey = ce
bdx + bey = bf
aex - bdx = ce - bf
x(ae - bd) = ce - bf
x = (ce - bf)/(ae - bd)
by = c - ax
y = (c - ax)/b
*/
int main()
{
    while(true){
        double a, b, c, d, e, f;
        std::cin >> a >> b >> c >> d >> e >> f;
        if(std::cin.eof()) break;
        double x, y;
        if(b){
            x = (c*e - b*f) / (a*e - b*d);
            y = (c - a*x) / b;
        }else{
            y = (f-d*c/a)/(e-d*b/a);
            x = (c-b*y)/a;
        }
        if(x == -0) x = 0;
        if(y == -0) y = 0;
        std::cout << std::fixed << std::setprecision(3);
        std::cout << x << " " << y << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define MAXN  10000
#define mx    10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l,l1;
	ll i,j,m,mn,q,d,x,y,ans=0,sum=0,r,p,k,c;
	string s,s1;
//	cin>>t;
	cin>>n;
	ll a[n],cost[n+1];
	rep(i,0,n)cin>>a[i];
	cost[0]=0,cost[1]=0;
	cost[2]=abs(a[1]-a[0]);
	rep(i,3,n+1){
		cost[i]=min(cost[i-1]+abs(a[i-1]-a[i-2]),cost[i-2]+abs(a[i-1]-a[i-3]));
	}
//	rep(i,0,n+1)cout<<cost[i]<<" ";
cout<<cost[n];
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int M=(int)1e9+1,t=0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
// vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
// stack<int> s;
 
// void dfs(int v){
//     vis[v]=1;
//     for(int i:adj[v]){
//         if(!vis[i]){
//             dfs(i);
//         }
        
//     }
//     s.push(v);
//     return ;
    
// }
int pp=0;






signed main(){
    fio;
    int n;
    cin>>n;
    int dp[n][3];
    int ans=-1;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++) {
            cin>>dp[i][j];
            if(i==0) ans=max(ans,dp[i][j]);
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            int s=-1;
            for(int k=0;k<3;k++){
                if(k!=j) s=max(s,dp[i-1][k]);
            }
            dp[i][j]+=s;
            if(i==n-1) ans=max(ans,dp[i][j]);
        }
        
    }
    cout<<ans<<endl;

    

    

    


    

    
    
}

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

int main() {

  while(1) {
  int n;
  cin >> n;
  if(n == 0) break;
  int ok[3] = {};
  int cnt[3] = {};
  for(int q=0;q<n;q++) {
    string str;
    int num;
    cin >>str >> num;

    int lun,di,mid;

    int t=0;
    int hr,mn;
    for(int i=0;i<str.size();i++) {
      if(str[i] == ':') {
	hr = t;
	t = 0;
	continue;
      }
      t*=10;
      t+= str[i]-'0';
    }
    mn = t;

    int wait;
    if(t > num)  wait = num - t+60;
    else wait = num -t;

    int flg = 0;
    if(hr>=11 && hr<=14) {
      cnt[0]++;
      if(wait <= 8) ok[0]++;
    }
    else if(hr>=18 && 20>=hr) {
      cnt[1]++;
      if(wait <= 8) ok[1]++;
    }
    else if((21<=hr && hr<=23) || hr<=1) {
      cnt[2]++;
      if(wait <= 8) ok[2]++;
    }
  }

    if(cnt[0] == 0) cout << "lunch no guest"<<endl;
    else cout <<"lunch "<< (int)(100.0*ok[0]/cnt[0])<<endl;
	   
    if(cnt[1] == 0) cout << "dinner no guest"<<endl;
    else cout <<"dinner "<< (int)(100.0*ok[1]/cnt[1])<<endl;
    if(cnt[2] == 0) cout << "midnight no guest"<<endl;
    else cout << "midnight "<<(int)(100.0*ok[2]/cnt[2])<<endl;
}
  return 0;

}
  

Measured memory_bytes: 1208