akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const long long p = 5 * pow(10, 15);
int main(){
  string s;
  long long k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); i++){
    if (k <= pow((int)s[i] - 48, p)){
      cout << s[i] << endl;
      break;
    }
    k -= pow((int)s[i] - 48, p);
  }
  return 0;
}


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

using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n,h[100002],o,t,dp[100002],k1;
int rec(int i)
{
    if(i==n-1) return 0;
    if(dp[i]!=1e9)return dp[i];
    for(int k=1; k<=k1; k++)
        if(i+k<=n-1)
        {
            o=rec(i+k)+abs(h[i]-h[i+k]);
            dp[i]=min(o,dp[i]);
        }

    return dp[i];
}
int main()
{
    cin>>n>>k1;

    loop(i,n)
    {
        cin>>h[i];
        dp[i]=1e9;
    }
    int ans=rec(0);
    cout<<ans;
}



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

const int mod = 1e9 + 7;

string s[1005];
int f[1005][1005];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = '$' + s[i];
	}
	f[0][1] = 1;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		if (s[i][j] == '.') {
			f[i][j] = f[i - 1][j] + f[i][j - 1];
			f[i][j] %= mod;
		}
	}
	cout << f[n][m] << '\n';
}


Measured memory_bytes: 8508
import java.util.ArrayList;
import java.util.Scanner;

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

		ArrayList<Integer> card = new ArrayList<Integer>();

		int n = s.nextInt() * 2;

		for(int i = 0; i < n; i++){
			card.add(i+1);
		}


		int m = s.nextInt();
		for(int i = 0; i < m; i++){
			int k = s.nextInt();
			if(k != 0){
				cut(card, k);

			}
			else{
				riffle(card, n);
			}
		}

		for(int i = 0; i < n; i++){
			System.out.println(card.get(i));
		}

	}

	public static void cut(ArrayList<Integer> a, int n){
		ArrayList<Integer> b = new ArrayList<Integer>();

		for(int i = 0; i < n; i++){
			b.add(a.get(i));
		}

		for(int i = 0; i < n; i++){
			a.remove(0);
		}

		for(int i = 0; i < n; i++){
			a.add(b.get(i));
		}
	}

	public static void riffle(ArrayList<Integer> a, int n){
		ArrayList<Integer> b = new ArrayList<Integer>();

		for(int i = n/2; i < n; i++){
			b.add(a.get(i));
		}

		int c = 0;
		for(int i = 1; i < n; i=i+2){
			a.add(i, b.get(c++));
		}
		for(int i = 0; i < b.size(); i++){
			a.remove(a.size()-1);
		}
	}


}

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

int W[105], V[105];
long long dp[2][100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, w;
    cin >> N >> w;
    
    for(int i=1; i<=N; i++)
        cin >> W[i] >> V[i];
    
    int prev = 0, curr = 1;
    
    for(int i=1; i<=100000; i++)
        dp[0][i] = (long long) 1e15;
    
    for(int i=1; i<=N; i++, swap(prev, curr))
    {
        for(int j=0; j<=100000; j++)
        {
            dp[curr][j] = dp[prev][j];
            
            if(i >= 1 && j >= V[i])
                dp[curr][j] = min(dp[curr][j], dp[prev][ j - V[i] ] + W[i]);
        }
    }
    
    for(int i=100000; i>=0; i--)
        if(dp[prev][i] <= w)
        {
            cout << i << "\n";
            return 0;
        }
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h, a; cin >> h >> a;
    cout << (h + (a - 1))/a << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val lines = readAllLines()
    val reduced = lines.filter { !it.matches(Regex("\\.+")) }
    val w = reduced[0].length
    val isWhiteLineArray = BooleanArray(w)
    for (i in 0 until w) {
        var isWhiteLine = true
        for (j in 0 until reduced.size) {
            val c = reduced[j][i]
            isWhiteLine = isWhiteLine && c == '.'
        }
        isWhiteLineArray[i] = isWhiteLine
    }
    for (i in 0 until reduced.size) {
        for (j in 0 until w) {
            if (!isWhiteLineArray[j]) print(reduced[i][j])
        }
        println()
    }
}

fun readAllLines(): List<String> {
    val hw = readLine()!!.split(" ")
    val h = Integer.parseInt(hw[0])
    return (0 until h).map { readLine()!! }
}


Measured memory_bytes: 36744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, M, Q;
  ll s[SIZE], t[SIZE];

  scanf("%d%d%d", &N, &M, &Q);

  for(int i=1;i<=N;i++) scanf("%lld", s+i);
  for(int i=1;i<=M;i++) scanf("%lld", t+i);
  s[0] = -LLINF;
  t[0] = -LLINF;
  s[N+1] = LLINF;
  t[M+1] = LLINF;

  N += 2;
  M += 2;

  ll *S = s;
  ll *T = t;


  for(int i=0;i<Q;i++){
    ll x;
    ll ans = LLINF;

    scanf("%lld", &x);

    for(int j=0;j<2;j++){

      ll *p = lower_bound(S, S+N, x);
      int q = upper_bound(T, T+M, *p) - lower_bound(T, T+M, x);

      if(q > 0)
        ans = min(ans, abs(*p - x));

      p--;
      q = upper_bound(T, T+M, x) - lower_bound(T, T+M, *p);

      if (q > 0)
        ans = min(ans, abs(*p - x));

      swap(T, S);
      swap(N, M);
    }

    ll *p = lower_bound(S, S+N, x);
    ll *q = lower_bound(T, T+M, x);

    ll a = min(abs(x - *p), abs(x - *(p-1)));
    ll b = min(abs(x - *q), abs(x - *(q-1)));

    ans = min(ans, a + b + min(a, b));

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

  return 0;
}


Measured memory_bytes: 3712
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    int ans = 0;
    if(K != 1){
      ans = N-K;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<queue>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  string S;
  cin>>N>>K;
  REP(i,N)cin>>S[i];
  if(S[K-1] == 'A')S[K-1]='a';
  if(S[K-1] == 'B')S[K-1]='b';
  if(S[K-1] == 'C')S[K-1]='c';  
  REP(i,N)cout<<S[i];
  
  
  
  return 0;
}


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

int main()
{
	int W, H, N;
	cin >> W >> H >> N;
	int a[100][3];
	for (int i = 0; i < N; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	int l, r, d, u;
	l = 0;
	r = W;
	d = 0;
	u = H;
	for (int i = 0; i < N; i++) {
		if (a[i][2] == 1) {
			l = max(a[i][0],l);
		}
		else if (a[i][2] == 2) {
			r = min(a[i][0],r);
		}
		else if (a[i][2] == 3) {
			d = max(a[i][1],d);
		}
		else if (a[i][2] == 4) {
			u = min(a[i][1],u);
		}
		if (r <= l || u <= d) {
			break;
		}
	}
	if (l < r && d < u) {
		cout << (r - l) * (u - d) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
answer = {
    "1":[1,2,3,4,5,6,7,8,9],
    "2":[2,4,6,8,10,12,14,16,18],
    "3":[3,6,9,12,15,18,21,24,27],
    "4":[4,8,12,16,20,24,28,32,36],
    "5":[5,10,15,20,25,30,35,40,45],
    "6":[6,12,18,24,30,36,42,48,54],
    "7":[7,14,21,28,35,42,49,56,63],
    "8":[8,16,24,32,40,48,56,64,72],
    "9":[9,18,27,36,45,54,63,72,81]
}

N = int(input())
a = 0
for value in answer.values():
  if N in value:
    a = 1

if a == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 x;
  cin >> x;
  if (x / 100 * 5 < x % 100)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int main() {
	int N;
	cin >> N;
	int a=0, b=0, c=0, x, y, z;
	std::cout << N+N*N+N*N*N << '\n';
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int n;
string a, b, c;

int main(void)
{
	cin >> n;
	cin >> a >> b  >>  c;
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == b[i] && b[i] == c[i]) continue;
		if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans++;
		else ans += 2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int inf=0x3f3f3f3f;
string a,b;
int ans=inf;
int main()
{
	cin>>a>>b;
	for(int i=0;i+b.size()-1<a.size();++i)
	{
		int cnt=0;
		for(int j=0;j<b.size();++j)
		if(a[i+j]!=b[j])++cnt;
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
char s[15],_s[15];
int main(){
	scanf("%s",s);
	scanf("%s",_s);
	int len=strlen(s),sp=true;
	for(int i=0;i<len;++i)
		sp&=(s[i]==_s[i]);
	puts(sp?"Yes":"No");
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int ans = 0, now = 0;
    rep(i, 0, N - 1) {
        if(A[i] >= A[i + 1]) now++;
        else now = 0;
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n;
	while(cin >> n){
		int t = n / 100;
		if(n % 100 <= t * 5)
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
} 

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1;

int n, W;
int dp[100001];

int main() {
	fill(dp, dp + 100001, INF);
	dp[0] = 0;

	cin >> n >> W;
	for (int i = 0; i<n; i++) {
		int v, w;
		cin >> v >> w;
		for (int j = 100000; j >= v; j--) {
			dp[j] = min(dp[j], dp[j - v] + w);
		}
	}

	for (int i = 100000; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3500
#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;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
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");
    int n; cin >> n;
    vi p(n);
    rep(i,n) cin >> p[i];

    vi len(n+1);
    rep(i,n){
        len[p[i]] = len[p[i]-1] + 1;
    }
    int ans = n - *max_element(all(len));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

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

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  sort(all(a));
  cout << a[n / 2] - a[n / 2 - 1] << '\n';
}


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

int main(void){

  int i, n, x, max, min;
  long sum;
  //int *N;
  min = 1000000;
  max = -1000000;

  sum=0;
  scanf("%d", &n);
  //N = (int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    scanf("%d", &x);
    sum += x;
    if(min > x){
      min = x;
    }
    if(max < x){
      max = x;
    }
  //  printf("%d\n", sum);
  }


//    printf("%d\n", N[i]);


  printf("%d %d %ld\n", min, max, sum);

  return 0;

}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
#define INFTY 1000005
int n,m,P[INFTY],A[INFTY],B[INFTY],C[INFTY];
long long cnt[INFTY];
int main(){
    //cout<<endl;
    cin>>n>>m;
    for(int i=0; i<=n; i++) {cnt[i]=0;}
    for(int i=1; i<=m; i++) cin>>P[i];           
    for(int i=1; i<m; i++) {
        if(P[i+1]-P[i]>=0){ cnt[P[i]]++; cnt[P[i+1]]--;}
        else { cnt[P[i]]--; cnt[P[i+1]]++;}
    }
    for(int i=1; i<n; i++){
        cnt[i]+=cnt[i-1];
    }
    
    for(int i=1; i<n; i++) cin>>A[i]>>B[i]>>C[i];
    long long ans=0;
    for(int i=1; i<n; i++){
        if(A[i]*cnt[i]>B[i]*cnt[i]+C[i]) ans+=B[i]*cnt[i]+C[i];
        else ans+=A[i]*cnt[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a, int day) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i <= day; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
  }
  return sum;
  // return max((int)1e6 + sum, 0);
}

int simulate(vi a) { return simulate(a, D - 1); }

void solve() {
  int best = simulate(ans);

  //
  {
    vi a = ans;
    for (int i = 0; i < D; i++) {
      int bst = -INF, idx = 0;
      for (int j = 0; j < 26; j++) {
        a[i] = j;
        int x = simulate(a, i);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }
    if (best < simulate(a)) ans = a, best = simulate(ans);
  }

  //
  srand((unsigned)time(NULL));
  int loop = 20;
  bool lastIsNew = true;
  while (loop--) {
    vi a = ans;
    if (!lastIsNew) {
      int change = D / 2;
      while (change--) {
        a[rand() % D] = rand() % 26;
      }
    }

    for (int i = 0; i < D; i++) {
      vi b = a;
      int idx = 0, bst = simulate(b);
      for (int j = 0; j < 26; j++) {
        b[i] = j;
        int x = simulate(b);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }

    lastIsNew = false;
    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
      lastIsNew = true;
    }
  }
}

int main() {
  input();
  ans = vi(D, 0);
  solve();
  output();
}


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

int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	vector<int>sorted(arr.begin(),arr.end());
	sort(sorted.begin(),sorted.end());
	int median = sorted[n/2];
	for(int i=0; i<n; i++){
		if(arr[i]>=median) cout<<sorted[n/2-1]<<'\n';
		else cout<<median<<'\n';
	}
}

Measured memory_bytes: 4768
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

H, W = map(int, input().split())
ans = 0
if H == 1 or W == 1:
    ans = 1
else:
    ans = (-H//2) * (-W//2) + (H//2) * (W//2)
print(ans)

# print(-(-H // 2))
# print(-(-W // 2))
# print(H // 2)
# print(W//2)

# print(4 * 2 + 3 * 1)


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

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

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int64_t area=1,x=-1,y=-1;
    int c=0;
    for(i=0;i<n-1;i++)
    {
        if(c==2)break;
        if(a[i]==a[i+1])
        {
            c++;
            area*=a[i];
            i++;
        }
    }
    if(c<2)cout<<0<<endl;
    else cout<<area<<endl;
}


Measured memory_bytes: 3784
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        List<Integer> ins = new ArrayList<>();
        for(int i = 0;i < n;i++){
            ins.add(sc.nextInt());
        }
        int prev = 0;
        int r = 0;
        for(int i = 1;i < n + 1;i++){
            if(prev + ins.get(i - 1) <= x){
                r++;
            }
            prev = prev + ins.get(i - 1);
        }
        System.out.println(++r);
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int flag;
char s[1000];
main()
{
	scanf("%s",&s);
	int n=strlen(s);
	for (int i=0;i<n;i++)
		if (s[i]=='9')
			flag=1;
	if (flag)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;

public class Main {
		
		public static void main(String[] args) {
			Scanner scn = new Scanner(System.in);
			int n=scn.nextInt();
			int k=scn.nextInt();
			int ans=n-2*k;
			if(ans<0)
				System.out.println("0");
			else
				System.out.println(ans);
		}
		public static int gcd(int a,int b)
		{
			if(a==0)return b;
			int l= gcd(b%a,a);
			return l;
		}

		
}

Measured memory_bytes: 22612
import sys
import numpy as np
read = sys.stdin.read

N, T, *AB = map(int, read().split())
AB = np.array(AB).reshape(N, 2)
AB = AB[np.argsort(AB[:, 0], axis=0)]

dp = np.zeros(T, np.int64)
answer = []

for a, b in AB:
    answer.append(dp[-1] + b)
    if a > T:
        continue

    dp[a:] = np.maximum(dp[:T - a] + b, dp[a:])

answer.append(dp.max())
print(max(answer))

Measured memory_bytes: 12616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    int ans = 0;
    ans += X / 500 * 1000;
    ans += X % 500 / 5 * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100005)

N = int(input())

edges = {n: [] for n in range(N+1)}

for _ in range(N-1):
    a, b, c = map(int, input().split())

    edges[a].append((b, c))
    edges[b].append((a, c))

Q, K = map(int, input().split())
xy = []
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))


d = [-1] * (N+1)
d[K] = 0


def dfs(n: int):
    for m, c in edges[n]:
        if d[m] == -1:
            d[m] = d[n] + c
            dfs(m)


dfs(K)

for x, y in xy:
    print(d[x] + d[y])

Measured memory_bytes: 153648
N, K = gets.chomp.split(' ').map(&:to_i)

queues = gets.chomp.split(' ').map(&:to_i)
items = []


def dequeue(queues, max_try, try_left, try_right)
  items = []
  try_queues = queues.dup
  items.concat(try_queues.shift(try_left))
  items.concat(try_queues.pop(try_right))
  try_return = max_try - try_left - try_right
  if try_return > 0
    items.sort! { |a, b| a<=>b }
    try_return.times { items.shift if items.size > 0 && items[0] < 0 }
  end
  items.inject(0, &:+)
end

max_challenges = [ N, K ].min
puts (max_challenges.downto(0).map do |try_to_get|
  try_to_get.downto(0).map do |try_get_left|
    try_get_right = try_to_get - try_get_left
    dequeue(queues, K, try_get_left, try_get_right)
  end.max
end).max


Measured memory_bytes: 3836
import * as fs from 'fs';

const a: number[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(Number);

a.sort(function (a, b) {
    if (a > b) return 1;
    if (a < b) return -1;
    return 0;
});
console.log(a[0] + a[1]);



Measured memory_bytes: 7500
//SAIKH SERAJ FAHIM, CSE-19-HSTU, BANGLADESH.

#include<iostream>
using namespace std;
int main()
{
    int n,a;
    cin>>n;
    for(int i=1000;; i=i+1000)
    {
        a=i-n;
        if(a<0)
            continue;
        else if(a>=0)
        {
            cout<<a<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a)%mod,n/2))%mod;
	else
	  return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}


int main()
 {
      IOS;
 string a,b,r="";
 cin>>a>>b;
 ll ans=INT_MAX;
   for(int i=0;i<=a.length()-b.length();i++)
   {
   	ll c=0;
   	for(int j=0;j<b.length();j++)
   	{
   		if(b[j]==a[i+j])
   		c++;
	   }
	   ll k=b.length()-c;
	   ans=min(ans,k);
   }
   cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;


  if (n % (a + b) == 0){
    cout << a * (n / (a + b)) << endl;
  }
  else {
    cout << a * (n / (a + b)) + min(a, n - (n / (a + b)) * (a + b)) << endl;
  }
  
  
  

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def binary_search(n, A):
    count = 0
    left = 0
    right = len(A)
    while left < right:
        mid = int((left + right) / 2)
        if A[mid] == n:
            return True
        elif A[mid] > n:
            right = mid
        else:
            left = mid + 1
    return False


if __name__ == '__main__':
    n = input()
    S = map(int, raw_input().split())
    q = input()
    T = map(int, raw_input().split())

    count = 0
    for i in xrange(len(T)):
        if binary_search(T[i], S):
            count += 1
    print count

Measured memory_bytes: 14828
k,s=[int(i) for i in input().split()]
ans=0
chk=set([])
for i in range(k+1):
    for j in range(i,k+1):
        tmp=s-i-j
        if 0<=tmp<=k and i<=j<=tmp:
            if i==j==tmp:
                ans+=1
            elif i==j or i==tmp or j==tmp:
                ans+=3
            else:
                ans+=6
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long


    int main (){

        int n; cin >>n;
        int arr[n] ;
        int db[n];
         for (int i =0 ; i <n ;i ++)
             cin >>arr[i];

         db[0]=0 , db[1] = abs (arr[0]-arr[1]);

            for (int i =2 ; i< n ;i++){
                db[i] = min ( db[i-1]+abs(arr[i]-arr[i-1]),db[i-2]+abs(arr[i]-arr[i-2]));
            }
            cout << db[n-1]<<endl;



    return 0;
}




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

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

int a[50];
int n, p;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin>>n>>p,n|p) {
		rep(i, n)a[i]=0;
		int s=p;
		int i=0;
		while(1) {
			if(s==0) {
				s = a[i];
				a[i] = 0;
			}else {
				s--;
				a[i]++;
				if(s==0 && a[i]==p)break;
			}
			i = (i+1)%n;
		}
		cout<<i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3156
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
#include <map>
#include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
	void reverse(std::vector<int>* vec) {
		std::reverse(vec->begin(), vec->end());
	}
	int max(std::vector<int>* vec) {
		return *std::max_element(vec->begin(), vec->end());
	}
}

int main(void) {

	AtCoder::Num s, buf;
	AtCoder::input(&s);

	const int n = s[0];

	AtCoder::input(&s);
	buf = s;
	AtCoder::reverse(&buf);

	AtCoder::Ans* ans = new AtCoder::Ans();

	AtCoder::Num res;
	res.push_back(0);
	
	const int size = (n - 1);
	for (int i = 0; i < size; i++) {
		if (buf[i] <= buf[i + 1]) {
			ans->increment();
			res.push_back(ans->getResult());
		} else {
			ans->decrement(ans->getResult());
		}
	}
	ans->decrement(ans->getResult());

	ans->increment(AtCoder::max(&res));

	ans->showResult();

	delete(ans);

	return 0;
}


Measured memory_bytes: 2292
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
int s[10][2];

int main()
{
   int T;
   cin>>T;
   double HH=0;
   for(int i=0;i<T;i++)
   {
       scanf("%d%d",&s[i][0],&s[i][1]);
   }
   for(int i=0;i<T;i++)
    for(int j=i+1;j<T;j++)
   {
      HH+=sqrt((s[i][0]-s[j][0])*(s[i][0]-s[j][0])+(s[i][1]-s[j][1])*(s[i][1]-s[j][1]))*1.0;
   }
printf("%.10lf\n",HH*2.0/T);


}


Measured memory_bytes: 256
h,w,K=map(int,input().split())
mod=10**9+7
dp=[[0]*(w+1) for _ in range(h+1)]
dp[0][0]=1
for i in range(h):
    for j in range(w):
        for k in range(2**(w-1)):
            ok=True
            for l in range(w-2):
                if (k>>l)&1 and (k>>(l+1))&1:
                    ok=False
            if ok:
                if j>=1 and (k>>(j-1))&1:
                    dp[i+1][j-1]+=dp[i][j]
                    dp[i+1][j-1]%=mod
                elif j<=w-2 and (k>>j)&1:
                    dp[i+1][j+1]+=dp[i][j]
                    dp[i+1][j+1]%=mod
                else:
                    dp[i+1][j]+=dp[i][j]
                    dp[i+1][j]%=mod

print(dp[h][K-1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
  int N, D;
  cin >> N >> D;
  
  int x;
  int range = 2 * D + 1;
  x = (N-1)/range + 1;
  cout << x << endl;
  
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n, m, dp[395];

int main() {
	cin >> n;
	
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	
	for_(i,0,n) {
		int s, l, p;
		cin >> s >> l >> p;		
		for_(d,s,l+1) for_(j,0,395) if (j >= d && dp[j-d] >= 0) dp[j] = max(dp[j], dp[j-d] + p);
	}
	
	cin >> m;
	vector< int > ans(m);
	
	for_(i,0,m) {
		int w;
		cin >> w;
		
		ans[i] = dp[w];
		
		if (ans[i] <= 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	for_(i,0,m) cout << ans[i] << endl;
}

Measured memory_bytes: 1200
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    n = int(readline())
    a = list(map(int, readline().split()))
    counter = Counter(a)

    keys = list(counter.keys())
    keys.sort(reverse=True)

    ans = 0

    for num1 in keys:
        c1 = counter[num1]
        x = 1
        while x <= num1:
            x *= 2
        num2 = x - num1
        if num1 == num2:
            cnt = c1 // 2
            ans += cnt
            counter[num1] -= cnt * 2
        else:
            c2 = counter[num2]
            cnt = min(c1, c2)
            ans += cnt
            counter[num1] -= cnt
            counter[num2] -= cnt

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 137400
/* be name khoda */

// #define stream_enable
#define long_enable

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>

// #include <bits/stdc++.h>
// #include <numeric>
// #include <iomanip>
// #include <cmath>
// #include <bitset>
// #include <fstream>

using namespace std;

#ifdef stream_enable
#define cin sss
#endif

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;

const ll MOD = 1000000007;

const long long BIG = 1446803456761533460LL;
const int Big = 336860180;

#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).ff << ", " << (x).ss << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].ff << ", " << (x)[i1_dap].ss << ")" << endl; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 100010;

map<string, ll> mpp;

void MAIN() {

    mpp["SUN"] = 0;
    mpp["MON"] = 1;
    mpp["TUE"] = 2;
    mpp["WED"] = 3;
    mpp["THU"] = 4;
    mpp["FRI"] = 5;
    mpp["SAT"] = 6;
    string s;
    cin >> s;
    cout << ((14 - mpp[s] - 1) % 7 + 1) << '\n';

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,n;
    scanf("%d%d%d",&a,&b,&c);
    if((a+b) <= (b+c))
        n = a+b;
    else 
        n = b+c;
    if(n <= (a+c))
        printf("%d\n",n);
    else
        printf("%d\n",a+c);
        return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;;);
    let mut ws = vec![];
    for i in 0..vs.len() {
        ws.push((vs.iter().take(i).sum::<i64>() - vs.iter().skip(i).sum::<i64>()).abs());
    }
    ws.sort();
    println!("{}", ws[0]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int B;
    cin >> A >> B ;
    int ans;

    if (B%A==0){
        ans=A+B;
    }
    else {
        ans=B-A;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())


#n,*a = [int(i) for i in read().split()]

    
a = [[int(i) for i in readline().split()] for _ in range(3)]
n,*b = [int(i) for i in read().split()]

res = [0]*1000
for i in b:
    res[i] = 1

ok = 0
for i in range(3):
    if res[a[i][0]] == res[a[i][1]] == res[a[i][2]] == 1:
        ok = 1

for i in range(3):
    if res[a[0][i]] == res[a[1][i]] == res[a[2][i]] == 1:
        ok = 1

if res[a[0][0]] == res[a[1][1]] == res[a[2][2]] == 1:
    ok = 1

if res[a[0][2]] == res[a[1][1]] == res[a[2][0]] == 1:
    ok = 1

if ok:
    print("Yes")
else:
    print("No")












    
    
    
    
    
    


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main( void ){
    char S[24];
    scanf("%s", S);
    if(strcmp(S ,"SUN")==0){
        printf("7\n");
    } else if(strcmp(S ,"MON")==0) {
        printf("6\n");
    } else if(strcmp(S ,"TUE")==0) {
        printf("5\n");
    } else if(strcmp(S ,"WED")==0) {
        printf("4\n");
    } else if(strcmp(S ,"THU")==0) {
        printf("3\n");
    } else if(strcmp(S ,"FRI")==0) {
        printf("2\n");
    } else {
        printf("1\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e+9+7;
int main(){
    //入力
    int N;
    cin >> N;

    vector<int> x(N+1,0);
    for(int i=2;i<=N;i++){
        int num=i;
        for (int j = 2; j <= num; j++) {
            while (num%j == 0) {
                x.at(j)++;
                num /= j;
            }
        }
    }

    ll ans=1;
    for(int i=2;i<=N;i++){
        ans*=(x.at(i)+1);
        ans%=INF;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    bool c = false,f = false;
    rep(i,n){
        if(s[i] == 'C') c = true;
        else if(s[i] == 'F' && c == true) f = true;
    }   
    cout << ((f) ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<int>x(N);
  rep(i,N)cin >> x[i];
  vector<ll>v(N);
  vector<ll>a(N);
  rep(i,N)if(x[i] >= 0)v[i] = x[i];else v[i] = x[i] * 2; 
  rep(i,N)if(x[i] <= 0)a[i] = x[i];else a[i] = x[i] * 2;
  ll ans = INF * 10;
  rep(i,N - K + 1){
    if(v[i] < 0 && v[i + K - 1] < 0)ans = min(ans,v[i] * -1);
    else if(v[i] < 0 && v[i + K - 1] > 0)ans = min(ans,v[i] * -1 + v[i + K - 1]);
    else ans = min(ans,v[i + K - 1]);
  } 
  rep(i,N - K + 1){
    if(a[i] < 0 && a[i + K - 1] < 0)ans = min(ans,a[i] * -1);
    else if(a[i] < 0 && a[i + K - 1] > 0)ans = min(ans,a[i] * -1 + a[i + K - 1]);
    else ans = min(ans,a[i + K - 1]);
  } 
  cout << ans << endl;
  return 0;
}  

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

int main() {
    int n;
    cin>>n;
    long long x, prev = -1; long long ans = 0;
    for(int i=0; i<n; i++) {
        cin>>x;
        if(prev == -1) {
            prev = x;
        } else {
            ans += max(0LL, prev - x);
            prev = max(prev, x);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() }
    val odd = mutableMapOf<Int, Int>()
    val even = mutableMapOf<Int, Int>()
    list.indices.forEach {
        val num = list[it]
        var target = odd
        if(it % 2 == 0) {
            target = even
        }
        if(target.containsKey(num)) {
           target[num] = target[num]!! + 1
        } else {
            target[num] = 1
        }
    }
    val oddKeys = odd.keys.sortedByDescending { odd[it] }
    val evenKeys = even.keys.sortedByDescending { even[it] }
    var cnt = 0
    if(oddKeys.first() == evenKeys.first()) {
        if(oddKeys.count() == 1 && evenKeys.count() == 1) {
            cnt = n/2
        } else if(oddKeys.count() == 1) {
            cnt = odd[oddKeys[0]]!! + even[evenKeys[1]]!!
        } else if(evenKeys.count() == 1) {
            cnt = even[evenKeys[0]]!! + odd[oddKeys[1]]!!
        } else {
            cnt = even[evenKeys[0]]!! + odd[oddKeys[1]]!!
            cnt = Math.max(cnt, even[evenKeys[1]]!! + odd[oddKeys[0]]!!)
        }
    } else {
        cnt = even[evenKeys[0]]!! + odd[oddKeys[0]]!!
    }
    val ans = n - cnt;
    println(ans)
}

Measured memory_bytes: 58204
#include <stdio.h>          // printf(), scanf()
#define MAX_N 500000
 
typedef struct node_tbl
{
    int key;
    int parent;
    int left;
    int right;
} node;
 
const int nil = -1;
node t[MAX_N + 1];
int root;
int ix;
 
void
insert(int k)
{
    int y = nil;
    int x = root;
    int z = ix++;
 
    t[z].key = k;
    t[z].left = nil;
    t[z].right = nil;
 
    while (x != nil)
    {
        y = x;
        if (t[z].key < t[x].key)
            x = t[x].left;
        else
            x = t[x].right;
    }
 
    t[z].parent = y;
    if (y == nil)
        root = z;
    else
    {
        if (t[z].key < t[y].key)
            t[y].left = z;
        else
            t[y].right = z;
    }
}
 
void
inorder(int u)
{
    if (u == nil)
        return;
 
    inorder(t[u].left);
    printf(" %d", t[u].key);
    inorder(t[u].right);
}
 
void
preorder(int u)
{
    if (u == nil)
        return;
 
    printf(" %d", t[u].key);
    preorder(t[u].left);
    preorder(t[u].right);
}
 
int main(void)
{
    char command[8];
    int n;
    int x;
    int i;
 
    root = nil;
    ix = 0;
    scanf("%d", &n);
    for (i = 0; i < n; ++i)
    {
        scanf("%s", command);
        if(command[0] == 'i')
        {
            scanf("%d",&x);
            insert(x);
        }else if(command[0] == 'p')
        {
            inorder(root);
            printf("\n");
            
            preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
#define maxn 240
int L[maxn];
int main(){
	int N, ans = 0;
	cin >> N;
	for(int i = 0; i < 2 * N; i += 1) cin >> L[i];
	sort(L, L + 2 * N);
	for(int i = 0; i < 2 * N; i += 2) ans += L[i];
	cout << ans;
} 

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{


    ll n, ans=0;
    vector<ll> v;
    cin >> n;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    ll mn = v[0];
    for(ll i = 0; i < n; i++)
    {

        if(v[i] <= mn)
        {

            ans++;
            mn = v[i];
        }
    }
    cout << ans;
}


Measured memory_bytes: 2420