akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const ll IINF = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  map<ll, set<ll>> dict;
  vector<ll> nums;
  ll n;
  cin >> n;
  // vector<ll>nums;
  for (ll i = 0; i < n; i++) {
    ll num;
    cin >> num;
    nums.push_back(num);
    if (dict.count(num) == 0) {
      dict[num] = set<ll>{};
    }
    dict[num].insert(i);
  }

  map<ll, ll> normalLens;
  map<ll, ll> decrementedLens;
  ll normalLensSum = 0;
  for (auto kv : dict) {
    normalLens[kv.first] = (kv.second.size() >= 1)
                               ? (kv.second.size() * (kv.second.size() - 1) / 2)
                               : 0;
    normalLensSum += normalLens[kv.first];
    decrementedLens[kv.first] =
        (kv.second.size() >= 2)
            ? ((kv.second.size() - 1) * (kv.second.size() - 2) / 2)
            : 0;
  }

  for (ll i = 0; i < n; i++) {
    cout << (normalLensSum - normalLens[nums[i]] + decrementedLens[nums[i]])
         << endl;
  }
}

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
string a;
int c,f;
int main()
{
    cin>>a;
    int l=a.length();
    for(int i=0;i<l;i++)
    {
        if(a[i]==67)
        {
            c=i;
            for(int j=i;j<l;j++)
            {
                if(a[j]==70)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/* FUCK U*/
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iterator>
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5+50;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f first
#define s second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

void solve(){
    int n,k,count;
   
    cin>>n>>k;
    for(int i=n;i<=k;++i){
       string str=to_string(i);
        if(str.at(0)==str.at(4) && str.at(1)== str.at(3))
            count++;
    }
    cout<<count<<endl;    

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

Measured memory_bytes: 3720
// clang++ -std=c++14 -stdlib=libc++ -O2 ./*.cpp

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int N;
  cin >> N;
  char S[N + 1];
  int K;
  cin >> S >> K;
  char x = S[K - 1];
  for (size_t i = 0; i < N; i++) {
    if (S[i] != x) {
      S[i] = '*';
    }
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, m, s[11][11], k[11], p[11], res;

signed main() {
    cin >> n >> m;
    rep(i,m) {
        cin >> k[i];
        rep(j,k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,m) cin >> p[i];
    rep(b,1<<n) {
        int pp[11] = {};
        rep(i,m) rep(j,k[i]) (pp[i] += b>>s[i][j]&1) %= 2;
        bool ok = 1;
        rep(i,m) if (p[i]!=pp[i]) ok = 0;
        res += ok;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int selectionSort(int *A, int n) {
	int i,j;
	int tmp, min_index;
	int count = 0;

	for (i = 0; i < n; i++) {
		min_index = i;
		for (j = i; j < n; j++) {
			if (A[j] < A[min_index]) min_index = j;
		}
		tmp = A[i];
		A[i] = A[min_index];
		A[min_index] = tmp;

		if (i != min_index) count++;
	}

	return count;
}

int main() {
	int i, n;
	int A[N];
	int count;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &A[i]);

	count = selectionSort(A, n);

	for (i = 0; i < n-1; i++) 
		printf("%d ", A[i]);
	printf("%d\n", A[i]);
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin >> n >> m;
    V a(n);
    int sm = 0;
    REP(i,n){

    cin >> a[i];
    sm+=a[i];
    }
    int count = 0;
    REP(i,n){
        if(a[i]*4*m>=(sm) )count++;//割り算はなるべく掛け算にすると、>→>=
    }
    if(m<=count) cout << "Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100000,vector<ll>(3,0));
int main(){
  ll n;
  cin >> n;
  char s[n][11];
  string str[n];
  rep(i,n){
    rep(j,10){
      cin >> s[i][j];
    }
    s[i][10] = '\n';
    sort(s[i],s[i]+10);
  }
  rep(i,n){
    str[i] = "";
    rep(j,10){
      str[i] += s[i][j];
    }
  }
  sort(str,str+n);
  string tmpstr = "";
  ll sum = 0;
  ll tmpsum = 0;
  rep(i,n){
    // MSG(tmpstr);
    // MSG(str[i]);
    if(tmpstr == str[i]){
      tmpsum++;
    }else{
      tmpstr = str[i];
      if(tmpsum != 0){
        sum += tmpsum * (tmpsum+1) / 2;
        tmpsum = 0;
      }
    }
  }
  if(tmpsum != 0){
    sum += tmpsum * (tmpsum+1) / 2;
    tmpsum = 0;
  }
  cout << sum;
  // rep(i,n){
  //   MSG(i);
  //   cout << str[i] << endl;
  // }
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  int a, b;
  cin >> a >> b;
  if(!(__builtin_popcount(a ^ b) & 1)) {
    cout << "No";
    return 0;
  }
  cout << "Yes\n";
  function<vector<int>(int, int, int)> solve = [&](int x, int y, int dep) {
    if(dep == 1) return (vector<int>) {x, y};
    if((x & 1) != (y & 1)) {
      int to = (x >> 1) ^ 1;
      vector<int> a = solve(x >> 1, to, dep - 1);
      vector<int> b = solve(to, y >> 1, dep - 1);
      for(int &i : a) i = (i << 1) ^ (x & 1);
      for(int i : b) a.push_back((i << 1) ^ (y & 1));
      return a;
    } else {
      vector<int> a = solve(x >> 1, y >> 1, dep - 1);
      vector<int> b = solve(a[0], a[1], dep - 1);
      vector<int> res = {(a[0] << 1) ^ (x & 1)};
      a.erase(a.begin());
      for(int i : b) res.push_back((i << 1) ^ !(x & 1));
      for(int i : a) res.push_back((i << 1) ^ (x & 1));
      return res;
    }
  };
  vector<int> res = solve(a, b, n);
  for(int i : res) cout << i << " ";
  return 0;
}


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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()

const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}
int gcd(int a,int b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp){
    ll res=1;
    while(exp){
        exp--;
        res*=base;
    }
    return res;
}
void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
void solve () {

    string s;
    cin >> s;
    cout << s[0]<<s[1]<<s[2]<<"\n";


}




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

const string YES = "Yes";
const string NO = "No";

int solve(long long N, std::vector<long long> t, std::vector<long long> x, std::vector<long long> y)
{
    for (int i = 1; i <= N; i++)
    {
        long long dt = t[i] - t[i - 1];
        long long dx_dy = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (dt < dx_dy || dt % 2 != dx_dy % 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> t(N + 1, 0);
    std::vector<long long> x(N + 1, 0);
    std::vector<long long> y(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", &t[i]);
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, std::move(t), std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>0)
        printf("Positive");             
    else if(b>=0)
        printf("Zero");          
    else if((a&1)^(b&1))
        printf("Positive");
    else 
        printf("Negative");
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }.reversed()
    var current = 0
    var max = 0
    var heigth = l[0]
    for (i in 1 until l.size) {
        if (heigth <= l[i]) current += 1
        else {
            max = Math.max(max, current)
            current = 0
        }
        heigth = l[i]
    }
    println(Math.max(max, current))
}


Measured memory_bytes: 52344
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::Ordering;

/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let n = read::<usize>();
    let mut a = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut b = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut c = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();

    a.sort();
    b.sort();
    c.sort();

    let mut ans = 0;
    for i in 0..n {
        ans += a.lower_bound(&b[i]) * (n-c.upper_bound(&b[i]));
    }
    println!("{}", ans);
}


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

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

	long long int ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		if (1e9+7 < ans) {
			ans %= (int)(1e9 + 7);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define ll long long

inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = (1LL * rez * a);
        a = (1LL * a * a), n /= 2;
    }
    return rez;
}

int main() {
    int n,k;
    ll rez = 1;
    scanf("%d%d", &n, &k);
    rez = lgput(k-1, n-1);
    rez *= k;
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

inline bool pal (string s) {
    string l = s;
    reverse(all(l));
    return s == l;
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (pal(s) && pal(s.substr(0, (sz(s) - 1) / 2)) && pal(s.substr((sz(s) + 3) / 2 - 1, sz(s) - (sz(s) + 3) / 2 + 1))) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3668
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 998244353;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll cnt = 1;
  int n = (int)s.size();
  rep(i, 0, n - 1) {
    if (s[i] == s[i + 1])
      ++cnt;
    else
      break;
  }
  if (cnt == n) {
    cout << cnt * k / 2 << '\n';
    return 0;
  }

  ll ans = 0;
  rep(i, 0, n - 1) {
    if (s[i] == s[i + 1]) {
      ans++;
      i++;
    }
  }
  ans *= k;
  if (s[0] == s[n - 1]) {
    ll tnc = 1;
    while (s[n - tnc - 1] == s[n - 1]) ++tnc;
    ans -= (k - 1) * (cnt / 2 + tnc / 2 - (cnt + tnc) / 2);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,f,g,h,j,k,l,arr[100001],vis[100001];
int main()
{
	vector<int > v;
	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>arr[i];
		vis[arr[i]]++;
		vis[arr[i]-1]++;
		vis[arr[i]+1]++;
		v.push_back(vis[arr[i]]);
			v.push_back(vis[arr[i]-1]);
				v.push_back(vis[arr[i]-1]);
	}
	sort(v.begin(),v.end());
	cout<<v[v.size()-1];
}


Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define rep_m(i, s, n) for(int i = s; i > n; i--)
#define N 2000
#define W 2000

int main() {
    int n, w;
    cin >> n >> w;
    int l[n][w];
    int r[n][w];
    int d[n][w];
    int u[n][w];
    char s[n][w];
    
    rep(i, 0, n) {
        rep(j, 0, w) {
            cin >> s[i][j];
        }
    }

    int count = 1;
    rep(i, 0, n) {
        count = 1;
        rep(j, 0, w) {
            if(s[i][j] == '#') {
                l[i][j] = 0;
                count = 1;
            }
            else {
                l[i][j] = count;
                count++;
            }
        }
        count = 1;
        rep_m(j, w-1, -1) {
            if(s[i][j] == '#') {
                r[i][j] = 0;
                count = 1;
            }
            else {
                r[i][j] = count;
                count++;
            }
        }
    }

    rep(i, 0, w) {
        count = 1;
        rep(j, 0, n) {
            if(s[j][i] == '#') {
                u[j][i] = 0;
                count = 1;
            }
            else {
                u[j][i] = count;
                count++;
            }
        }
        count = 1;
        rep_m(j, n-1, -1) {
            if(s[j][i] == '#') {
                d[j][i] = 0;
                count = 1;
            }
            else {
                d[j][i] = count;
                count++;
            }
        }
    }

    int ans = 0;
    rep(i, 0, n) {
        rep(j, 0, w) {
            ans = max(ans, r[i][j]+l[i][j]+u[i][j]+d[i][j]-3);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 66688
#include<iostream>
#include<string>
#include<map>
#include<set>

using namespace std;

int main(void){
  std::ios_base::sync_with_stdio();
  
  multimap<string,int> indexs;
  set<int> indexn;
  set<int>::iterator ites;
  map<string,int>::iterator item;
  string inps,tmps;
  int inpi;

  while(cin>>inps>>inpi){
	  indexs.insert(map<string,int>::value_type(inps,inpi));
  }
   item=indexs.begin();
	  tmps=(*item).first;
	  cout<<tmps<<endl;
	  while(indexs.end()!=item){
		  if(tmps!=(*item).first){
			  ites=indexn.begin();
			  while(indexn.end()!=ites){
				  cout<<(*ites);
				  ites++;
				  if(indexn.end()==ites) cout<<endl;
				  else cout<<" ";
			  }
			  tmps=(*item).first;
			  cout<<tmps<<endl;
			  indexn.clear();
		  }
		  indexn.insert((*item).second);
		  item++;
	  }
	  ites=indexn.begin();
	  while(indexn.end()!=ites){
			cout<<(*ites);
			ites++;
			if(indexn.end()==ites) cout<<endl;
			else cout<<" ";
	  }
	  indexn.clear();
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define mod 1000000007
#define maxi 1e18
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define pi 3.141592653589
using namespace std;
int main()
{
	fast;
	int n,a,b,c;
	cin>>n;
	ll dp[n][3];
	fl(i,0,n)
	{
		cin>>a>>b>>c;
		fl(j,0,3)
		{
			dp[i][j] = 0;
		}
		if(i==0)
		{
			dp[0][0]=a;
			dp[0][1]=b;
			dp[0][2]=c;
		}
		else
		{
			fl(j,0,3)
			{
				if(j==0)
				{
					dp[i][j] = max(dp[i-1][1]+a,dp[i-1][2]+a);
				}
				else if(j==1)
				{
					dp[i][j] = max(dp[i-1][0]+b,dp[i-1][2]+b);
				}
				else
				{
					dp[i][j] = max(dp[i-1][0]+c,dp[i-1][1]+c);	
				}
			}
		}
	}
	ll res=-1;
	fl(i,0,3)
	{
		res = max(res,dp[n-1][i]);
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 2560
import math
import numpy as np
def resolver(A, B, H, M):
    minute = H * 60 + M

    thetaH = minute * math.pi * 2 / 60 / 12
    thetaM = M * math.pi * 2 / 60

    Hpoint = np.array((0, A))
    Mpoint = np.array((0, B))

    cosH = math.cos(thetaH)
    sinH = math.sin(thetaH)
    cosM = math.cos(thetaM)
    sinM = math.sin(thetaM)
    Hpoint = Hpoint * np.matrix([
        [cosH, -1 * sinH],
        [sinH, cosH]
    ])

    Mpoint = Mpoint * np.matrix([
        [cosM, -1 *sinM],
        [sinM, cosM]
    ])
    
    Hpoint = Hpoint.A[0]
    Mpoint = Mpoint.A[0]

    dx = Hpoint[0] - Mpoint[0]
    dy = Hpoint[1] - Mpoint[1]

    distance = math.sqrt(dx**2 + dy**2)

    print(distance)

def main():
    A,B,H,M = map(int, input().split())

    

    resolver(A, B, H, M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    double l;
    cin >> l;
    double che = l/3.00;
    double ans = pow(che,3);
    cout << fixed<<setprecision(20);
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
char a[maxn];
int n,k,val[5];
int dp[maxn][3];
int main()
{
    scanf("%d%d%d%d%d%s",&n,&k,&val[0],&val[1],&val[2],a+1);
    bool flag=0;
    int cmax=0,p;
    for(int i=1;i<=k;i++){
        for(int j=i;j<=n;j+=k){
            if(a[j]=='r') p=0;
            else if(a[j]=='s') p=1;
            else if(a[j]=='p') p=2;
            int r=max(j-k,0);
            dp[j][0]=max(dp[r][1],dp[r][2]);
            dp[j][1]=max(dp[r][0],dp[r][2]);
            dp[j][2]=max(dp[r][1],dp[r][0]);
            dp[j][(p+2)%3]=max({dp[r][(p+1)%3]+val[(p+2)%3],dp[r][p]+val[(p+2)%3],dp[j][p]});
        }
        cmax=max({dp[i][0],dp[i][1],dp[i][2]});
    }
    int sum=0;
    for(int i=n,t=k;t>0;i--,t--){
        sum+=max({dp[i][0],dp[i][1],dp[i][2]});
    }
    printf("%d\n",sum);
}
/*
    dp[i][j][1^A[i]]=dp[i-1][j][1^A[i]];
    dp[i][j][A[i]]=max(dp[i-1][j][A[i]]+1, dp[i-1][j-1][1^A[i]]+1);

17
AAAAABBBCCBBBBCCC
100 1 10

*/


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

int kaijo(int num) {
	int result = num;
	for (int i = num - 1; i >= 1; i--) {
		result = result * i;
	}

	return result;
}

int main() {

	int N, K;

	cin >> N >> K;

	int ans = 0;

	ans = kaijo(N) / (kaijo(K) * kaijo(N - K));

	//cout << ans << endl;

	cout << N - K + 1 << endl;

	return 0;



}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MIN(a,b) ((a) < (b) ? (a) : (b))

int main() {
  int n,k;
  int total=0;
  
  cin >> n >> k;
  
  for (int i=0;i<n;i++){
    int x;
    cin >> x;
    total += min(x, k-x);
  }
  
  cout << total * 2 << endl;
}


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

int main(){

    int n;
    cin >> n;
    vector<vector<int> > f(n,vector<int>(10,0));
    vector<vector<ll> > p(n,vector<ll>(11,0));

    rep(i,n){
        rep(j,10){
            cin >> f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }

    ll ans=-1*1e+15;

    for(int i=1;i<1024;i++){
        int d[10];
        int t=1;
        for(int j=0;j<10;j++){
            d[j]=(i/t)%2;
            t*=2;
        }
        vector<int> cnt(n,0);
        for(int j=0;j<10;j++){
            if(d[j]){
                for(int k=0;k<n;k++){
                    if(f[k][j]){
                        cnt[k]++;
                    }
                }
            }
        }
        ll temp=0;
        for(int j=0;j<n;j++){
            temp+=p[j][cnt[j]];
        }
        ans=max(ans,temp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let c = sc.chars();
    let s: Vec<char> = "keyence".chars().collect();
    if c.len() < s.len() {
        println!("NO");
        return;
    }

    let n = c.len();
    let mut head = 0;
    for i in 0..n {
        if s[head] == c[i] {
            head += 1;
        } else {
            break;
        }
        if head == s.len() {
            break;
        }
    }

    let mut tail = 0;
    for i in (0..n).rev() {
        if s[s.len() - 1 - tail] == c[i] {
            tail += 1;
        } else {
            break;
        }
        if tail == s.len() {
            break;
        }
    }

    if head + tail >= s.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int in[5050];
ll dp[5050];
int main() {
	ll N, A, B, i, j;
	scanf("%lld %lld %lld", &N, &A, &B);
	in[0] = 0, in[N + 1] = N + 1;
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	dp[0] = 0;
	for (i = 1; i <= N + 1; i++) {
		dp[i] = LL_INF;

		ll sum = 0;
		for (j = i - 1; j >= 0; j--) {
			if (in[j] < in[i]) {
				dp[i] = min(dp[i], dp[j] + sum);
			}

			if (in[j] < in[i]) sum += B;
			else sum += A;
		}
	}
	return !printf("%lld\n", dp[N + 1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
typedef long double ld;
ll INF = 1000000009;
ll MOD = 1000000007;

ld pi=3.14159265358979;

void solve(){

    ld a,b;
    cin >>a >> b;
    ld h,m;
    cin >> h >> m;
    ld x=(h*60+m)/2;
    ld y=6*m;
    ld z = abs(x-y);
    //cout << z << endl;
    ld p = z/180*pi;
    //cout << p << endl;
    //cout << cos(pi*(3/2)) << endl;
    ld ans_ = a*a+b*b-2*a*b*cos(p);
    cout << setprecision(12) << sqrt(ans_) << endl;
    
}

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


Measured memory_bytes: 4188
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

int n = 0;
long oV[100001] = { 0 };
long eV[100001] = { 0 };

int main()
{
    cin >> n;
    P cntOdd, cntEven;
    P oddN, evenN;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        if (i % 2 != 0) {
            oV[x] += 1;
        } else {
            eV[x] += 1;
        }
    }
    int O1 = 0;
    int E1 = 0;
    int O2 = 0;
    int E2 = 0;

    for (int i = 0; i < 100001; i++) {
        if (oV[i] != 0) {
            if (cntOdd.first <= oV[i]) {
                if (cntOdd.second < cntOdd.first) {
                    cntOdd.second = cntOdd.first;
                    oddN.second = oddN.first;
                }
                cntOdd.first = oV[i];
                oddN.first = i;
            }
            if (cntOdd.first > oV[i] && cntOdd.second < oV[i]) {
                cntOdd.second = oV[i];
                oddN.second = i;
            }
        }

        if (eV[i] != 0) {
            if (cntEven.first <= eV[i]) {
                if (cntEven.second < cntEven.first) {
                    cntEven.second = cntEven.first;
                    evenN.second = evenN.first;
                }
                cntEven.first = eV[i];
                evenN.first = i;
            }
            if (cntEven.first > eV[i] && cntEven.second < eV[i]) {
                cntEven.second = eV[i];
                evenN.second = i;
            }
        }
    }
    /*
    cout << "O1: " << O1 << endl;
    cout << "O2: " << O2 << endl;
    cout << "odd first count: " << cntOdd.first << endl;
    cout << "odd second count: " << cntOdd.second << endl;

    cout << "E1: " << E1 << endl;
    cout << "E2: " << E2 << endl;
    cout << "even first count: " << cntEven.first << endl;
    cout << "even second count: " << cntEven.second << endl;
    */

    if (oddN.first != evenN.first) {
        int ans = n / 2 - cntOdd.first + n / 2 - cntEven.first;
        cout << ans << endl;
    } else {
        int ansCandidate1 = n / 2 - cntOdd.first + n / 2 - cntEven.second;
        int ansCandidate2 = n / 2 - cntOdd.second + n / 2 - cntEven.first;

        cout << ((ansCandidate1 < ansCandidate2) ? ansCandidate1 : ansCandidate2) << endl;
    }
    return 0;
}


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

using namespace std;
int main(){
  string s;
  int k;
  cin>>k;
  cin>>s;
  string ans="";
  for(int i=0;i<(int)s.length();i++){
    int now=s[i]-'A';
    now=(now+k)%26;
    ans+=char('A'+now);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int 
ll a[200005],b[200005],c[200005];
int main(){
  ll i,j,k,n;
  cin>>n;
  b[0]=c[n+1]=0;
  for(i=1;i<=n;i++) cin>>a[i];
  b[1]=a[1];
  for(i=2;i<=n;i++) b[i]=max(b[i-1],a[i]);
  c[n]=a[n];
  for(i=n-1;i;i--) c[i]=max(c[i+1],a[i]);
  for(i=1;i<=n;i++){
   cout<<max(b[i-1],c[i+1])<<"\n"; 
  }
}

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

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

    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        vector<int> bs = {as[i - 1], as[i], as[i + 1]};
        sort(bs.begin(), bs.end());
        if (bs[1] == as[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
k=int(input())
import functools,math
sum = 0

# 3つ同じ場合
for a in range(1,k+1):
    sum += a
# 2つ同じ場合, ABBとする。
for a in range(1,k+1):
    for b in range(1,k+1):
        if a==b:
            continue
        sum += math.gcd(a,b)*3
# すべて異なる場合
for a in range(1,k+1):
    for b in range(a+1,k+1):
        for c in range(b+1,k+1):
            sum += functools.reduce(math.gcd, [a,b,c]) * 6
            #print (a,b,c,functools.reduce(math.gcd, [a,b,c]))
print (sum)

Measured memory_bytes: 9620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#define ll long long
#define pr(a) cerr<<#a<<"="<<a<<endl
#define pri(a,lo) {cerr<<#a<<"={";for (int ol=0;ol<=lo;ol++)cerr<<a[ol]<<",";cout<<"}"<<endl;}
using namespace std;
#define N 1000100
map<int,int> a[3],b;
map<int,int>::iterator it;
char ch[N];
int i,o,p,t;
int main()
{
	scanf("%s",ch);
	int l=(int)strlen(ch);
	a[0][0]=a[1][0]=1;
	ch[l]='T',l++;int f=1;
	for (i=0;i<l;i++)
	{
		if (ch[i]=='T')
		{
			//pr(t);pr(o);
			b.clear();
			for (it=a[o].begin();it!=a[o].end();it++)
			{
				int x=(*it).first;
				b[x+t]=1;
				if (f==0) b[x-t]=1;
			}
			a[o]=b;
			t=0;
			o^=1;
			f=0;
		}
		else t++;
	}
	scanf("%d %d",&o,&p);
	if (a[0][o]==1&&a[1][p]==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int N, W;
vi v, w;

vvi dp(105, vi(10005, -1));

ll dfs(int i, int rest) {
    if (dp[i][rest] != -1) return dp[i][rest];
    ll res;
    if (i == N) res = 0;
    else if (rest < w[i]) res = dfs(i+1, rest);
    else res = max(dfs(i+1, rest-w[i])+v[i], dfs(i+1, rest));

    dp[i][rest] = res;
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> W;
    v.resize(N);
    w.resize(N);
    REP(i, N) {
        cin >> v[i] >> w[i];
    }

    cout << dfs(0, W) << endl;

    return 0;
}



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

int main(){
  long long int a,b,c;
  cin >> a >> b >> c;
  if(a<b) swap(a,b);
  if(b<c) swap(b,c);
  if(a<b) swap(a,b);
  int k;
  cin >> k;
  for(int i=0; i<k;i++) a = a*2;
  cout << a+b+c << endl;
  return 0;
}

Measured memory_bytes: 888
N = int(input())
T, A  = map(int, input().split())
H = list(map(int, input().split()))

dif = []
for i in range(N):
    temp = T - H[i] * 0.006
    dif.append(abs(A - temp))

ans = dif.index(min(dif)) + 1
print(ans)


Measured memory_bytes: 3060
import math
a, b, x = map(int, input().split())
h = x/a**2

if b == h:
    print(0)
elif h >= b/2:
    tanth = a / (b - h) / 2
    theta = math.degrees(math.atan(tanth))
    print(90 - theta)
else:
    tanth = 2 * a * h / b**2
    theta = math.degrees(math.atan(tanth))
    print(90 - theta)


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

int n,m,a,b,c;
string s,t;

int main() {
  cin >> n;
  int d=0,t=0;
  while(d<abs(n)) t++, d+=t;
  cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	if (a < b) {
		cout << 0 << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Multiple of 2 and N
            int n = int.Parse(Console.ReadLine());
            
            if (n % 2 == 0)
            {
                Console.WriteLine(n);
            }
            else
            {
                Console.WriteLine(n * 2);
            }            
        }
    }
}

Measured memory_bytes: 13140
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

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

  ll cnt = 0;
  rep(i, n) {
    cnt += (i+1)%2 and a[i]%2;
  }
  cout << cnt << el;
}


Measured memory_bytes: 3628
import collections
n = int(input())
a = list(map(int, input().split()))

a.sort()

ma = max(a)
f = [1] * (ma + 1)

count = collections.Counter(a)
ans = 0

for i in a:
    if f[i]:
        if count[i] == 1:
            ans += 1
        for j in range(i, min(ma + i, ma + 1), i):
            f[j] = 0

print(ans)

Measured memory_bytes: 43296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}



int main(int argc, char const *argv[]) {
  ll x; cin >> x;

  vector<int> v;
    for (int i = 1; i * i <= x;i++){
        if(x%i==0){
            v.push_back(i);
            if(i*i!=x){
                v.push_back(x / i);
            }
        }
    }
  sort(all(v));
  //show(v);
  rep(i,sz(v)){
    int a,b;
    for(int j=-1000; j<=1000; j++){
      a=j,b=a-v[i];
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define db double
#define myp pair<ll,ll>
using namespace std;
const int N=5e5+10;
int n,l;
myp q[N]; //pair<v,v*t> 比较时不会产生精度误差 
int head,tail;
int main(){
	ll v,t,temp_v=0,temp=0;
	db now_t;
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&t,&v);
		q[head++]=make_pair(v,v*t);
		temp_v+=v,temp+=v*t;
		while(temp_v>l){
			if(temp_v-q[tail].first>=l) temp_v-=q[tail].first,temp-=q[tail].second,tail++;
			else now_t=db(q[tail].second)/q[tail].first,q[tail].first-=temp_v-l,temp_v=l,temp=(temp-q[tail].second+now_t*q[tail].first+0.5),q[tail].second=(now_t*q[tail].first+0.5);
		}
		while(head-2>=tail&&db(q[head-1].second)/q[head-1].first<db(q[head-2].second)/q[head-2].first) q[head-2].first+=q[head-1].first,q[head-2].second+=q[head-1].second,head--;
		printf("%.10lf\n",db(temp)/temp_v);
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << min(N * A, B);
}

Measured memory_bytes: 256