akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	ll n, m, k, c, b, i, j;
	ll x, t;
	cin >> n;
	ll a[n];
	ll mx = -1;
	ll pos = 0;
	FOR(i, n) {
		cin >> a[i];
		if (a[i] >= mx)
			pos = i;
		mx = max(mx, a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		ans += max(0ll, a[i] - a[i + 1]);
		if (a[i] - a[i + 1] > 0) {
			a[i + 1] = a[i];
		}
	}
	cout << ans;
	return 0;
}


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

using ll = long long;
constexpr int maxn = 1e5 + 100;

vector<int> vec[maxn] = {};
map<int, ll> dist[maxn] = {};

int weight[maxn] = {};

void build_weights(const int cur, const int prev){
    weight[cur] = 1;
    for(const auto next : vec[cur]){
        if(next == prev) continue;
        build_weights(next, cur);
        weight[cur] += weight[next]; } }

int find_centroid(const int cur, const int prev, const int full_weight){
    bool is_good = ( 2 * (full_weight - weight[cur]) <= full_weight);
    for(const auto next : vec[cur]){
        if(next == prev) continue;
        if(2 * weight[next] > full_weight) is_good = false;

        auto tmp = find_centroid(next, cur, full_weight);
        if(tmp != -1) return tmp; }
    if(is_good) return cur;
    return -1; }

ll rez = 0;
void rez_dfs(const int cur, const int prev, const ll cur_dist){
    rez += 2 * cur_dist;
    for(const auto next : vec[cur]){
        if(next == prev) continue;
        rez_dfs(next, cur, cur_dist + dist[cur][next]); } }

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

    for(int i = 0, x, y, z; i < n-1; ++i){
        cin >> x >> y >> z;
        vec[x].push_back(y);
        vec[y].push_back(x);
        dist[x][y] = dist[y][x] = z; }
    build_weights(1, 0);
    const auto root = find_centroid(1, 0, weight[1]);
    build_weights(root, 0);

    rez_dfs(root, 0, 0);

    ll good_edge = 1e9;
    for(const auto next : vec[root]){
        if(2 * weight[next] == weight[root]){
            good_edge = dist[root][next];
            break; }
        good_edge = min(good_edge, dist[root][next]); }

    rez -= good_edge;

    cout << (rez) << endl;
    return 0; }



Measured memory_bytes: 29952
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;

public class Main {
    public static Scanner sc;
    public static ArrayList<Integer> list;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);

        while (sc.hasNext()) {
            list = new ArrayList<>();
            list.add(sc.nextInt());
            list.add(sc.nextInt());
            list.add(sc.nextInt());
            
            if (list.get(0) == 0 && list.get(1) == 0 && list.get(2) == 0) {
                break;
            }
            
            Collections.sort(list);
            
            int n = sc.nextInt();
            
            for (int i = 0; i < n; i++) {
                double r = sc.nextDouble();
                double d = Math.sqrt(Math.pow(list.get(0), 2) + Math.pow(list.get(1), 2));
                
                //System.out.println(r + " " + d);
                
                if (r*2 > d) {
                    System.out.println("OK");
                } else {
                    System.out.println("NA");
                }
            }
        }
    }
}

Measured memory_bytes: 28008
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      100007

const int mod = 1e9 + 7;

int dp[MAXN][3], arr[MAXN][3];
int n;

int solve(int idx, int task)
{
   if (idx == n)
      return 0;
   if (dp[idx][task] != -1)
      return dp[idx][task];

   return dp[idx][task] = arr[idx][task] + max(solve(idx + 1, (task + 1) % 3), solve(idx + 1, (task + 2) % 3));
}

int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

   memset(dp, -1, sizeof dp);
   cin >> n;
   for (int i = 0; i < n; ++i)
   {
      cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
   }
   cout << max(solve(0, 0), max(solve(0, 1), solve(0, 2))) << endl;
   return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>x(n),y(n);
    vector<ll>plus(n),minus(n);
    for(ll i=0;i<n;i++) {
        cin >> x[i] >> y[i];
        plus[i]=x[i]+y[i];
        minus[i]=x[i]-y[i];
    }
    sort(plus.begin(),plus.end());
    sort(minus.begin(),minus.end());
    ll X=plus[n-1]-plus[0],Y=minus[n-1]-minus[0];
    ll ans=max(X,Y);
    cout << ans << endl;
}

Measured memory_bytes: 9592
fun main(args: Array<String>) {
  val (L, R) = readLine()!!.split(' ').map { it.toLong() }
  val min = (L .. Math.min(R, L+2019)).map { i -> (i + 1 .. Math.min(R, L+2019)).map { j -> i * j % 2019} }.flatMap { it }.min()
  println(min)
}

Measured memory_bytes: 141660
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll n, a, b;
  cin >> n >> a >> b;
  ll arr[n];
  fi(0, n)
    cin >> arr[i];

  fi(1, n)
    ans += min(b, (arr[i] - arr[i - 1]) * a);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=400005,mod=998244353;
int n,ans,num[N],g[N],tot; char s[N],t[N];
inline void inc(int& x,CI y)
{
    if ((x+=y)>=mod) x-=mod;
}
inline void dec(int& x,CI y)
{
    if ((x-=y)<0) x+=mod;
}
int main()
{
    RI i,j,k; for (scanf("%d%s",&n,s+1),k=1;k<=(n<<1);++k)
    if ((n<<1)%k==0&&(((n<<1)/k)&1))
    {
        for (num[++tot]=k,i=1;i<=(k>>1);++i)
        g[tot]=((g[tot]<<1)+s[i]-48)%mod,t[i]=s[i];
        for (i=(k>>1)+1;i<=n;++i) t[i]=((t[i-(k>>1)]-48)^1)+48;
        for (++g[tot],i=1;i<=n;++i) if (t[i]!=s[i])
        { g[tot]-=(t[i]>s[i]); break; }
    }
    for (i=1;i<tot;++i) for (j=i+1;j<=tot;++j)
    if (num[j]%num[i]==0) dec(g[j],g[i]);
    for (i=1;i<=tot;++i) inc(ans,1LL*num[i]*g[i]%mod);
    return printf("%d",ans),0;
}

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

int main(){
	int a[5],tmp;
	for(int i=0; i<5 ; i++){
		cin >> a[i];
	}
	for(int j=0;j<4;j++){
		for(int k=j+1;k<5;k++){
			if(a[j]<a[k]){
				tmp = a[j];
				a[j] = a[k];
				a[k] = tmp;
			}
		}
	}

	for(int l =0; l<4 ; l++) {
		cout << a[l] << " ";
	}
	cout << a[4] << "\n";
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int POW[11];
char S[11];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 11; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%s",S);

	int len;
	for(len = 0; S[len] != '\0'; len++);

	ll ans = 0;
	for(int state = 0; state < POW[len-1]; state++){

		int head = 0;
		ll work = 0,tmp;

		for(int loop = 0; loop < len-1; loop++){
			if(state & POW[loop]){
				tmp = 0;

				for(int i = head; i <= loop; i++){

					tmp = 10*tmp+(S[i]-'0');
				}
				work += tmp;
				head = loop+1;
			}
		}
		tmp = 0;
		for(int i = head; i <= len-1; i++){

			tmp = 10*tmp+(S[i]-'0');
		}
		work += tmp;

		ans += work;
	}

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

	return 0;
}


Measured memory_bytes: 256
# input
N, K = map( int, input().split() )
P    = [int(x) for x in input().split()]

# calc cumsum
C    = list()
cumsum = 0
for ii in range( len(P) ):
    E = (1+P[ii])/2
    C.append( cumsum + E )
    cumsum += E

ans = 0.0
if( N==K ):
    ans = C[-1]
for ii in range( K, N ):
    E = C[ii] - C[ii-K]
    if( ans < E ):
        ans = E

# output        
print( ans )

Measured memory_bytes: 24548
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }
    rep(i, h) {
        bool ok = 1;
        rep(j, w) {
            if(a[i][j] == '#') ok = 0;
        }
        if(ok) {
            rep(j, w) {
                a[i][j] = 'x';
            }
        }
    }
    rep(i, w) {
        bool ok = 1;
        rep(j, h) {
            if(a[j][i] == '#') ok = 0;
        }
        if(ok) {
            rep(j, h) {
                a[j][i] = 'x';
            }
        }
    }
    rep(i, h) {
        bool ok = 0;
        rep(j, w) {
            if(a[i][j] != 'x') {
                cout << a[i][j];
                ok = 1;
            }
        }
        if(ok) cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9
#define NIL -1
#define N 100

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

    sort(h.begin(), h.end());

    int ans = INF;
    for(int i = 0; i < n - k + 1; i++) {
        int tmp = h[i + k - 1] - h[i];
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1152
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[]array=str.split("");
        if(array[0].equals(array[2]) && array[1].equals(array[2]))
        System.out.println("No");
        else
        System.out.println("Yes");
     }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,c,x,i,j,k,ans=0;
    cin >> a >> b >> c >> x;
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(x == 500*i+100*j+50*k) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		List<Double>b =new ArrayList<Double>();
		for(int i=0;i<a;i++)b.add((double)scan.nextInt());
		Collections.sort(b);
		double ans=0;
		for(;b.size()>1;) {
			double x=b.get(0);
			double y=b.get(1);
			ans=(x+y)/2;
			b.remove(0);
			b.remove(0);
			b.add(ans);
			Collections.sort(b);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    ll n;
    cin >> n;
    ll c=0;
    string ans = "No";
    foi(0,n)
    {
        ll a,b;
        cin >> a >> b;
        if(a==b)
            c++;
        else
            c=0;
        if(c>=3)
            ans = "Yes";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;



int main(){
    ll N; cin>>N;
    REP(i, N) {
        ll A; cin >> A;
        if(A % 2 == 0){
            if(A % 3 ==0 || A % 5 ==0){

            }
            else{
                cout<<"DENIED"<<endl; return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
int arr[ 1005 ] = {};
int main( void ){
	// initialize();
	ll N;
	cin >> N;
	const auto &vec = prime_factorize( N );
	ll ans = 0;
	for(auto v:vec){
		int cnt = 0, B = v.b;
		rep( i, 1, v.b + 1 ){
			if (B < i)
				break;
			B -= i;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans << endl;
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3720
import sys
for line in sys.stdin:
    v = list(map(int, line.split(",")))
    k = [sum(v[:i]) for i,j in enumerate(v[:-1])]
    l = v[-2]/(v[-1]+v[-2]) * k[-1]
    n = [a-l if a-l >= 0 else 1e10 for a in k]
    print(n.index(min(n)))

Measured memory_bytes: 7596
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

vector<ll> ret;
vector<long long> divisor(long long n)
{
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    
    ll N; cin >> N;
    ll ans=0;

    FOR(i,1,N+1){
        ll res = N/i;
        ans += res*(res+1)*i/2;
    }

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


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

int main() {
int n ;
cin >> n;
int ar[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

cout << ar[n-1];	
return 0;
}

Measured memory_bytes: 256
while True:
    c = input().split()
    n, x = int(c[0]), int(c[1])
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)



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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int a, b, arr[3];

    cin >> a >> b;

    arr[0] = a+b;
    arr[1] = a-b;
    arr[2] = a*b;

    sort(arr, arr+3);

    cout << arr[2] << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

ll gcd(ll a, ll b){
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

bool is_prime(int x){
    double tmp = sqrt(x) + 1;
    if (x == 1) return true;
    REP(i, tmp){
        if (i < 2) continue;
        if (x % i == 0) return false;
    }
    return true; 
}

int main() {

    ll A, B;
    cin >> A >> B;

    ll g = gcd(A, B);
    //double tmp = sqrt(g) + 1;
    ll ans = 1;
    for(ll i = 2; i * i < g; i++){
        if (g % i == 0){
        //cout << i << endl;
            ans++;
            while (g % i == 0) g /= i;
        }
    }
    if (g != 1) ans++;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;


void selectionSort(vector<int> A,int N) { // N 個の要素を含む 0-オリジンの配列 A
	int count = 0;
	for (int i = 0; i < N-1;++i) {
		int minj = i;
		for (int j = i; j < N ;++j) {
			if (A[j]<A[minj]) {
				minj = j;
			}
		}
		if (i!=minj) {
			int tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			count++;
		}
	}
	rep(i,N-1) {
		cout << A[i] << " ";
	}
	cout << A[N - 1] << endl;
	cout << count << endl;
}
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) {
		cin >> a[i];
	}
	selectionSort(a,N);
	return 0;
}





Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
void fastio()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;
	return ans;
}
 
void solve()
{
	ll int n,i;
	cin>>n;
	vector<pair<ll int ,ll int> > v;
	rep(i,n)
	{
		ll int x,y;
		cin>>x>>y;
		v.pb(mp(x,y));

	}
	
	ll int a, b,c,d=1e10;
	ll int e=-1e10,f=-1e10,g=-1e10,h=-1e10;

	ll int ans=-1e17;
	
	rep(i,n)
	{
		 a=min(a,v[i].first+v[i].second);
		 b=min(b,v[i].first-v[i].second);
		 c=min(c,-v[i].first+v[i].second);
		 d=min(d,-v[i].first-v[i].second);
		  e=max(e,v[i].first+v[i].second);
		 f=max(f,v[i].first-v[i].second);
		 g=max(g,-v[i].first+v[i].second);
		 h=max(h,-v[i].first-v[i].second);


		
	}
	// cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	// cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;
	ans=max(e-a,ans);
	ans=max(f-b,ans);
	// ans=max(g-c,ans);
	// ans=max(h-d,ans);
	cout<<ans<<endl;
}

int main()
{ 
	fastio();
    ll int t;
    // cin>>t;
    t=1;
    while(t--)
    {
    	solve();
    }
}

	
		
	
	
	
	





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

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for(ll i = a; i <= b; i++)

const ll MOD = 1e9 + 7;
ll n, sum, res, arr[200010];

void process()
{
    For(i, 1, n)
    sum += arr[i];
    For(i, 1, n)
    {
        sum -= arr[i];
        res = (res + (arr[i] * (sum % MOD)) % MOD) % MOD;
    }
    cout << res << "\n";
}

void input()
{
    cin >> n;
    For(i, 1, n)
    cin >> arr[i];
}

int main()
{
    input();
    process();
}

Measured memory_bytes: 5168
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] p = new int[n];
    int min = 100000*2;
    int count = 0;
    
    for(int i=0; i<n; i++) {
      p[i] = Integer.parseInt(str[i]);
      min = Math.min(p[i],min);
      if(p[i]<=min)
        count++;
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 60996
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashMap;

class Main
{
    public static String getId(int p, int x) {
        return String.format("%06d", p) + String.format("%06d", x);
    }
    
    public static void main(String args[])
    {
        class Io {
            public BufferedReader br;
            public StringBuilder stb;

            public Io() {
                InputStreamReader ir = new InputStreamReader(System.in);
                this.br = new BufferedReader(ir);
                this.stb = new StringBuilder();
            }
            
            public ArrayList<Integer> inputInts() {
                String[] inputParts = {""};
        
                try { 
                    inputParts = br.readLine().split(" ");
                }
                catch (IOException e) {
                    System.out.println("Error " + e.getMessage());
                    e.printStackTrace();
                }

                int n = inputParts.length;
                ArrayList<Integer> ints = new ArrayList<>();
                for (int i = 0; i < n; i++) {
                    ints.add(Integer.valueOf(inputParts[i]));
                }
                return ints;
            }

            public void appendToAnswer(String s) {
                stb.append(s).append("\n");
            }

            public void printAnswer() {
                System.out.print(stb.toString());
            }
        }

        Io io = new Io();
        ArrayList<Integer> ints = io.inputInts();
        int N = ints.get(0), M = ints.get(1);
        HashMap<Integer, ArrayList<Integer>> prefs = new HashMap<>();
        HashMap<Integer, ArrayList<Integer>> cities = new HashMap<>();

        for (int i = 1; i <= N; i++) {
            prefs.put(i, new ArrayList<Integer>());
        }

        for (int i = 1; i <= M; i++) {
            ints = io.inputInts();
            int p = ints.get(0), y = ints.get(1);
            prefs.get(p).add(i);
            ArrayList<Integer> attrs = new ArrayList<>(3);
            attrs.add(p);
            attrs.add(y);
            cities.put(i, attrs);
        }

        for (int i = 1; i <= N; i++) {
            if (prefs.get(i).size() > 1) {
                prefs.get(i).sort((Integer city_a, Integer city_b) -> cities.get(city_a).get(1) - cities.get(city_b).get(1));
            }
        }

        for (int i = 1; i <= N; i++) {
            int size = prefs.get(i).size();
            for (int j = 0; j < size; j++) {
                cities.get(prefs.get(i).get(j)).add(j + 1);
            }
        }

        for (int i = 1; i <= M; i++) {
            ArrayList<Integer> city = cities.get(i);
            io.appendToAnswer(getId(city.get(0), city.get(2)));
        }
        io.printAnswer();
    }
}


Measured memory_bytes: 186472
#include<stdio.h>

int main(void)


{


 long long int a[10000],min=1000000,max=-1000000,sum=0;


 int n,i;


 scanf("%d",&n);


 for(i=0;i<n;i++){


    scanf("%lld",&a[i]);


    if(a[i]>=max){


       max=a[i];


     }


     if(a[i]<=min){


        min=a[i];


     }


     sum+=a[i];


   }


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


   return 0;


}


    

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (true) {
      c -= b;
      if (c <= 0) {
        cout << "Yes" << endl;
        return 0;
      }
      
      a -= d;
      if (a <= 0) {
        cout << "No" << endl;
        return 0;
      }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vii vector<vector<int>>
#define mii map<int,int>
#define pb push_back
#define mod 1e9 + 7;
const int INF = 1e9 + 5;
#define PQ priority_queue<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl "\n"

using namespace std;

int main(){

	int n;
	cin>>n;
	vi h(n), dp(n, INT_MAX);
	dp[0]=0;
	for(int i=0; i<n; i++)cin>>h[i];

	for(int i=0; i<n; i++){
		for(int j:{i+1, i+2}){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}

	cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        int num = Integer.parseInt(line);

        ArrayList<String> list = new ArrayList<String>();

        for (int i = 0; i < num; i++) {
            list.add(br.readLine());
        }


        findCard("S", list);
        findCard("H", list);
        findCard("C", list);
        findCard("D", list);

        /*

        for (int i = 1; i <= 13; i++) {
            if(list.contains("S " + i) == false){
                System.out.println("S " + i);
            }
        }

        for (int i = 1; i <= 13; i++) {
            if(list.contains("H " + i) == false){
                System.out.println("H " + i);
            }
        }

        for (int i = 1; i <= 13; i++) {
            if(list.contains("C " + i) == false){
                System.out.println("C " + i);
            }
        }

        for (int i = 1; i <= 13; i++) {
            if(list.contains("D " + i) == false){
                System.out.println("D " + i);
            }
        }
        */
    }

    static void findCard(String mark, ArrayList list){
    	for (int i = 1; i <= 13; i++) {
            if(list.contains(mark + " " + i) == false){
                System.out.println(mark + " " + i);
            }
        }
    }

}

Measured memory_bytes: 24064
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
int A[1000000+5],fre[1000000+5];
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    

    int val[n];
    for(int i=0;i<n;i++)
    cin>>val[i],fre[val[i]]++;

    sort(val,val+n);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        

        if(A[val[i]]==0&&fre[val[i]]==1)
        cnt++;
        if(A[val[i]]==1)
        continue;
        
        for(int j=val[i];j<=1000000;j+=val[i])
        {
            A[j]=1;
        }
    }
    cout<<cnt;
    

return 0;
}

Measured memory_bytes: 20804
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
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; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	set<int> s;
	REP(i, n) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if (s.size() == n) {
		put("YES");
	} else {
		put("NO");
	}
	return 0;
}



Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=1e5+50;

int n;
ll ans,C,x[N],val[N],nor[N],rev[N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	cin>>n>>C;
	rep(i,1,n)scanf("%lld%lld",x+i,val+i); 
	ll sum=0;
	rep(i,1,n){
		sum+=val[i];
		cmax(ans,-x[i]+sum); 
		nor[i]=-x[i]*2+sum;
	}
	sum=0;
	dec(i,n,1){
		sum+=val[i];
		cmax(ans,-C+x[i]+sum); 
		rev[i]=(-C+x[i])*2+sum;
	}
	rep(i,2,n)cmax(nor[i],nor[i-1]);
	dec(i,n-1,1)cmax(rev[i],rev[i+1]);
	int p;
	sum=0,p=1;
	rep(i,1,n){
		sum+=val[i];
		while(p<=n&&x[i]+(C-x[p])*2>C)++p;
		Pr("nor:i=%d,w=%lld\n",i,rev[p]-x[i]+sum); 
		if(p)cmax(ans,rev[p]-x[i]+sum);
	}
	sum=0,p=n;
	dec(i,n,1){
		sum+=val[i];
		while(p>=1&&C-x[i]+2*x[p]>C)--p;
		Pr("rev:i=%d,w=%lld\n",i,nor[p]-C+x[i]+sum); 
		if(p)cmax(ans,nor[p]-C+x[i]+sum);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int n,k;
  int i;
  int r,s,p;
  char t[100006];
  char hand[100006];
  ll ans = 0;

  scanf("%d %d", &n, &k);
  scanf("%d %d %d", &r, &s, &p);
  scanf("%s", t);

  for(i = 0;i < k;i++){
    if(t[i] == 'r'){
      ans += p;
      hand[i] = 'p';
    }
    else if(t[i] == 's'){
      ans += r;
      hand[i] = 'r';
    }

    else{
      ans += s;
      hand[i] = 's';
    }
  }

  for(i = k;i < n;i++){
    if(i + k < n){
      if(t[i] == 'r'){
        if(hand[i - k] == 'p'){
          if(t[i + k] == 'r') hand[i] = 's';

          else if(t[i + k] == 's') hand[i] = 'p';

          else hand[i] = 'r';
        }

        else{
          ans += p;
          hand[i] = 'p';
        }
      }

      else if(t[i] == 's'){
        if(hand[i - k] == 'r'){
          if(t[i + k] == 'r') hand[i] = 's';

          else if(t[i + k] == 's') hand[i] = 'p';

          else hand[i] = 'r';
        }

        else{
          ans += r;
          hand[i] = 'r';
        }
      }

      else{
        if(hand[i - k] == 's'){
          if(t[i + k] == 'r') hand[i] = 's';

          else if(t[i + k] == 's') hand[i] = 'p';

          else hand[i] = 'r';
        }

        else{
          ans += s;
          hand[i] = 's';
        }
      }
    }

    else{
      if(t[i] == 'r'){
        if(hand[i - k] != 'p') ans += p;
      }

      else if(t[i] == 's'){
        if(hand[i - k] != 'r') ans += r;
      }

      else{
        if(hand[i - k] != 's') ans += s;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 384
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=1000000007
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  n=len(s)
  _d=I()


  dp=[[[0]*(_d+1) for _ in range(2)]for __ in range(n+1)]
  dp[0][0][0]=1

  for i in range(n):
    nd=int(s[i])
    for j in range(2):
      for k in range(_d):
        for d in range(10):

          ni=i+1
          nj=j
          nk=k

          if nj==0:
            if d>nd:
              continue
            if d<nd:
              nj=1

          nk+=d
          nk%=_d

          dp[ni][nj][nk]+=dp[i][j][k]
          dp[ni][nj][nk]%=mod

  return (dp[n][0][0]+dp[n][1][0]-1)%mod

# main()
print(main())


Measured memory_bytes: 88804
#include <iostream>
#include <algorithm>
using namespace std; 
int arrCount[200005] = { 0 }; 
bool cmp(int iNum1, int iNum2)
{ 
    return iNum1 > iNum2;
}
int main()
{
    int n, m, i, t, iSum=0,maxn(1); 
    cin >> n >> m; 
    for (i = 1; i <= n; ++i)
    { 
        cin >> t;
        ++arrCount[t]; 
        maxn=(t>maxn?t:maxn);
    }
    sort(arrCount, arrCount + maxn+1,cmp); 
    for (i = m; i<=maxn; ++i)
    { 
        iSum += arrCount[i]; 
    }
    cout << iSum << endl; 
    return 0; 
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class C
{
    static void Main()
    {
        int[] intRecord = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        var N = intRecord[0];
        var M = intRecord[1];

        int p_i = 0;
        var S_i = string.Empty;
        var ac = new int[N];
        var temp = new int[N];
        int ACCount = 0;
        int WACount = 0;

        for (int i = 0; i < M; i++)
        {
            string[] lineRecord = Console.ReadLine().Trim().Split(' ');
            p_i = int.Parse(lineRecord[0]) - 1;
            S_i = lineRecord[1];

            if (ac[p_i] == 1) continue;
            if (S_i == "WA" && temp[p_i] != null) temp[p_i]++;
            else if (S_i == "WA" && temp[p_i] == null) temp[p_i] = 1;
            else if (S_i == "AC")
            {
                WACount += temp[p_i];
                ACCount++;
                ac[p_i] = 1;
            }
        }

        Console.WriteLine(ACCount.ToString() + " " + WACount.ToString());
    }

}

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

int main(){
  int i;
  float x[6];
  int y1, y2, re1, re2;

  while(cin >> x[0]){
    for(i=1; i<6; i++){
      cin >> x[i];
    }

    //normalize
    x[1]/=x[0]; x[2]/=x[0]; x[0]=1;

    //subtraction
    x[4]-=x[3]*x[1]; x[5]-=x[3]*x[2]; x[3]=0;

    //normalize
    x[5]/=x[4]; x[4]=1;

    //subtraction
    x[2]-=x[1]*x[5]; x[1]=0;

    y1=(int)(x[2]*10000); y2=(int)(x[5]*10000);
    re1=y1%10; re2=y2%10;
    if(re1<5) y1-=re1;
    else y1+=10-re1;
    if(re2<5) y2-=re2;
    else y2+=10-re2;
    printf("%.3f %.3f\n", (float)y1/10000.0f, (float)y2/10000.0f);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}


int main(){
	int n;
	scanf("%d",&n);
	int cnt=0;
	FOR(i,0,n){
		int u;
		scanf("%d",&u);
		if(i%2==0 && u%2==1)cnt++;
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 3824