akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
long long n, k;
vector<long long> dis;
long long sum = 0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> k >> n;
	dis.resize(n);
	long long lst, now;
	cin >> lst;
	int one = lst;

	for (int i = 1; i < n; i++) {
		cin >> now;
		dis[i - 1] = now - lst;
		lst = now;
	}
	
	dis[n - 1] = k - now + one;
	sort(dis.begin(), dis.end());

	for (int i = 0; i <= n - 2; i++) {
		sum += dis[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 200005;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (b >= a) {
        cout << "unsafe\n";
    }
    else {
        cout << "safe\n";
    }
}

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

using namespace std;

int main(){
	int x = 0;
	vector<int> record;
	record.push_back(x);
	int N; cin >> N;
	string s; cin >> s;
	for(int i = 0; i < N; ++i){
		if(s[i] == 'I'){
			x++;
			record.push_back(x);
		}else if(s[i] == 'D'){
			x--;
			record.push_back(x);
		}
	}
	int ans = *max_element(record.begin(), record.end());
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    
    //                                 (POLICY BASED DS)
    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/pb_ds/tree_policy.hpp>
    // using namespace __gnu_pbds;
    // template<typename T>
    // using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
    // template<typename T>
    // using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    //                      ( find_by_order( )  ,  order_of_key( ) )
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz size()
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define ncr(n,r) ( n >= r ? ((((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod) : (ll)0)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return ans; 
    }
    
    // vector<ll> adj[MAX];
    // ll visit[MAX];
    // void dfs(ll node){
    //     visit[node]=1;
    //     for(auto i : adj[node]){
    //         if(!visit[i]) dfs(i);
    //     }
    // }
    
    // ll spf[MAX];
    // void sieve(){
    //     sidha(i,1,MAX)  spf[i]=i;
    //     for(ll i=4;i<MAX;i+=2)  spf[i]=2;
    //     for(ll i=3;i*i<=MAX;i++){
    //         if(spf[i]==i){
    //             for(ll j=i*i;j<MAX;j+=i){
    //                 if(spf[j]==j)   spf[j]=i;
    //             }
    //         }
    //     }
    // }

    int main()
    {
        boost;
        ll n;
        cin>>n;
        if(n)   cout<<0;
        else    cout<<1;
        return 0;
    }
    

Measured memory_bytes: 3644
/**
 *    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 n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int ans = 0, bf = 0;
    rep(i, n) {
        if(bf && a[i]) {
            ++ ans;
            a[i] --;
            bf = 0;
        } 
        ans += a[i] / 2;
        bf = a[i] % 2;
    }
    cout << ans << 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: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a, b; cin >> a >> b;
    int d = a/b;
    int r = a%b;
    printf("%d %d %.5f\n", d,r,(double)a/(double)b);
    return 0;
}



Measured memory_bytes: 3200
import java.util.Scanner;

/**
 * A - A?C
 * AtCoder 社は、毎週土曜日にコンテストを開催しています。
 * コンテストには ABC と ARC の 2 つの種類があり、毎週どちらか一方が開催されます。
 * ABC が開催された次の週には ARC が開催され、ARC が行われた次の週には ABC が開催されます。
 * 先週開催されたコンテストを表す文字列 S が与えられるので、今週開催されるコンテストを表す文字列を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 先週開催されたコンテスト
        String s = sc.next();

        System.out.println( s.equals( "ABC" ) ? "ARC" : "ABC" );

        sc.close();
    }
}

Measured memory_bytes: 35620
while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    chessbord = ''
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                chessbord += '#'
            else:
                chessbord += '.'
        chessbord += '\n'
    print(chessbord)

Measured memory_bytes: 7696
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m,a[55],b[55],li[55][55];

int main(){
	cin >> n >> m;
	REP(i,0,m) cin >> a[i] >> b[i], li[a[i]][b[i]]=true, li[b[i]][a[i]]=true;
	
	int c=0;
	REP(i,0,m){
		li[a[i]][b[i]]=false;
		li[b[i]][a[i]]=false;
		
		queue<int> qu;
		set<int> st;
		qu.push(a[i]);
		while(!qu.empty()){
			auto p=qu.front(); qu.pop();
			
			REP(j,1,n+1){
				if(st.count(j)) continue;
				if(li[p][j]) st.insert(j), qu.push(j);
			}
		}
		
		if(st.size()!=n) c++;
		li[a[i]][b[i]]=true;
		li[b[i]][a[i]]=true;
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
w = n.times.map{ gets.chomp }
ju = true

if w.sort.uniq.count != w.count
    puts 'No'
    exit
end

la = w[0][0]
w.each {|i|
    if la != i[0]
        ju = false
        break
    end
    la = i[i.length-1]
}

puts ju ? 'Yes' : 'No'


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (int i = 0; a > 0 && c > 0;i++) {
		if (i % 2 == 1) {
			a = a-d;
		}
		else {
			c = c-b;
		}
	}

	if (c<=0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;

int N,L;
int main()
{
    while(cin>>N>>L)
    {
        bool flag=false;
        bool bigg=false;
        int sum=0;        
        for(int i=1;i<=N;i++)
        {
            sum+=L+i-1;
            if(L+i-1==0)
                flag=true;
            if(L+i-1>0)
                bigg=true;
        }           
        if(flag)
            cout<<sum<<endl;
        else if(bigg)
            cout<<sum-L<<endl;
        else
            cout<<sum-(L+N-1)<<endl;
    }
}

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

int main(int argc, char *argv[]){
  int N;
  cin >> N;
  int i;
  int a[N];
  for(i=0; i<N; ++i){
    cin >> a[i];
  }
  int ans = 0;
  for(i=0; i<N; ++i){
    if(a[a[i]-1] == i+1){
      ans++;
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#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 N, K;
  cin >> N >> K;
  int minA = 1000000, x = N + 1;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (minA > A[i]) {
      minA = A[i];
      x = i;
    }
  }
  int ans = 0;
  // if (x <= (K - 1)) {
    for (int i = 0; i <= N - K; i++){
      ans++;
      if (i == N - K) break;
      i += K - 2;
      if (i > N - K - 1) {
        i = N - K - 1;
      }
    }
  // }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3724
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	string s, t;
	cin >> s >> t;
	if (t.length() == s.length() + 1 && s == t.substr(0, t.length() - 1))
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b){
        printf("a < b\n");
    }else if (a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2036
import java.util.Scanner;
public class Main {
	static int cur;
	static String S;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		for (int l=0; l<k; l++){
			S = sc.next();
			cur = 0;
			int a = parse();
			assert (cur == S.length());
			System.out.println(a);
		}
	}
	static int parse() {
		return expression();
	}
	static int digit(){
		assert(Character.isDigit(S.charAt(cur)));
		int n = S.charAt(cur) -'0';
		cur++;
		return n;
	}
	static int number() {
		int n = digit();
		while ((cur < S.length()) && Character.isDigit(S.charAt(cur)))
			n = n*10 + digit();
		return n;
	}
	static int expression(){
		int sum = term();
		while (S.charAt(cur) != '='){
			if (S.charAt(cur) == '+'){
				cur++;
				sum+=term();
			}
			else if (S.charAt(cur)=='-'){
				cur++;
				sum-=term();
			}
			else break;
		}
		return sum;
	}
	static int factor(){
		if (S.charAt(cur)!='(') return number();
		cur++;
		int n = expression();
		assert(S.charAt(cur)==')');
		cur++;
		return n;
	}
	static int term(){
		int a = factor();
		while (true) {
			if (S.charAt(cur) == '*'){
				cur++;
				a*=factor();
			}
			else if (S.charAt(cur) == '/'){
				cur++;
				a/=factor();
			}
			else break;
		}
		return a;
	}
}

Measured memory_bytes: 25956
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> xpy, xmy;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        xpy.pb(x + y);
        xmy.pb(x - y);
    }
    sort(xpy.begin(), xpy.end());
    sort(xmy.begin(), xmy.end());
    cout << max(xpy.back() - xpy[0], xmy.back() - xmy[0]) << '\n';
    return 0;
}

Measured memory_bytes: 6696
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

bool f(const vector<ll>& b)
{
	if (b.size() == 0) return true;

	bool flag = false;
	for (ll i = 0; i < b.size(); ++i)
	{
		if (b[i] > i + 1)
		{
			flag = false;
			break;
		}

		if (b[i] == i + 1)
		{
			flag = true;
			break;
		}
	}
	if (!flag) return false;

	for (ll i = b.size()-1; i >= 0; --i)
	{
		if (b[i] == i + 1)
		{
			vector<ll> tmp_b(b.size()-1);
			for (ll j = 0; j < b.size()-1; ++j)
			{
				if (j < i) tmp_b[j] = b[j];
				if (j >= i) tmp_b[j] = b[j+1];
			}

			bool retval = f(tmp_b);

			if (retval)
			{
				//trace = true;
				cout << i + 1 << endl;
				return true;
			}
			else
			{
				return false;
			}
		}
	}

	return false;
}

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

	ll N;
	cin >> N;

	vector<ll> b(N);
	for (ll i = 0; i < N; ++i) cin >> b[i];

	bool retval = f(b);

	if (!retval)
	{
		cout << -1 << endl;
	}

	//system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#define INF 0x3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
const int c=1e9+7;
long long pow_mod(ll a, ll b)
{
    long long sum = 1;
    while (b) {
        if (b & 1) {
            sum = (sum * a) %c;
            b--;
        }
        b /= 2;
        a = a * a % c;
    }
    return sum%c;
}
int main()
{
    //cout<<pow_mod(1,100);
    ll n;
    cin>>n;
    cout<<((pow_mod(10,n)-pow_mod(9,n)*2+pow_mod(8,n))%c+c)%c;
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using Graph = vector < vector<int>>;
using ll = long long;
const int INF = 1001001001;


int main() {
	string t;
	cin >> t;
	int n = t.size();
	if (t[0] =='?') {
		t[0] = 'D';
	}
	for (int i = 1; i < n; i++) {
		if (t[i] == '?') {
			t[i]='D';
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3720
import copy

N = int(input())

As = list(map(lambda i: int(i), input().split()))

ns = [0 for i in range(N)]

for a in As:
    ns[a-1] += 1

def get_comb(arr):
    res = 0
    for a in arr:
        if a == 0:
            continue
        res += a*(a-1)/2
    return int(res)

ba = get_comb(ns)

for a in As:
    print(ba - get_comb([ns[a-1]]) + get_comb([ns[a-1]-1]))
    

Measured memory_bytes: 26908
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N;
  cin>>N;
  int count1=0,count4=0;
  rep(i,0,N){
    int X;
    cin>>X;
    if(X%2==1)
      count1++;
    else if(X%4==0)
      count4++;
  }
  string ans="No";
  if(count1+count4==N){
    if(count1<=count4+1)
      ans="Yes";
  }
  else{
    if(count1<=count4)
      ans="Yes";
  }
  cout<<ans;
  }



Measured memory_bytes: 256
a,b,c,d = gets.chomp.split("").map(&:to_i)

8.times do |i|
  op_arr = ("00" + i.to_s(2))[-3..-1]

  result = a
  arr = []
  if op_arr[0] == "1" then
    result += b
    arr << "+"
  else
    result -= b
    arr << "-"
  end

  if op_arr[1] == "1" then
    result += c
    arr << "+"
  else
    result -= c
    arr << "-"
  end

  if op_arr[2] == "1" then
    result += d
    arr << "+"
  else
    result -= d
    arr << "-"
  end

  if result == 7 then
    puts "#{a}#{arr[0]}#{b}#{arr[1]}#{c}#{arr[2]}#{d}=7"
    exit
  end
end


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

int INF = - 1'000'000'000;

int main(){
    int n, m; long long p;
    cin >> n >> m >> p;
    struct edge{
        int from, to, cost;
    };
    vector<edge> es(m);
    for (int i = 0; i < m; i++){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--; es[i].to--;
    }
    vector<pair<long long, int>> distance(n, {INF, 0});
    distance[0] = {0, 0};
    for (int i = 0; i < 2 * n; i++){
        bool update = false;
        for (int j = 0; j < m; j++){
            edge e = es[j];
            if (distance[e.from].first != INF && distance[e.to].first - p * distance[e.to].second < distance[e.from].first + e.cost - p * distance[e.from].second - p){
                distance[e.to].first = distance[e.from].first + e.cost;
                distance[e.to].second = distance[e.from].second + 1;
                update = true;
                if (i >= n - 1 && e.to == n - 1){
                    cout << - 1 << endl;
                    exit(0);
                }
            }
        }
        if (!update) break;
    }
    if (distance[n - 1].first == INF) cout << - 1 << endl;
    else cout << max((long long)0, distance[n - 1].first - p * distance[n - 1].second) << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

N, K = map(int, raw_input().split())

ans = (N / K) ** 3

if K % 2 == 0:
    ans += ((N + (K / 2)) / K) ** 3

print ans

Measured memory_bytes: 2812
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <map>

using namespace std;

int main() {
    int n,m;
    cin >> n;
    map<int,string> s,t;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    cin >> m;
    for(int i = 0; i < m; i++) {
        cin >> t[i];
    }
    
    int price = 0;
    int a[101] = {};
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(s[i] == t[j]) {
                a[i]--;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(s[i] == s[j]) {
                a[i]++;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        if(price < a[i]) {
            price = a[i];
        }
    }
    cout << price;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        char[] s = scanner.next().toCharArray();
        char first = s[0];
        char second = 0;
        int n = s.length;
        int ans = 1;
        for(int i = 1; i < n; i++) {
            if (second == 0) {
                if (first == s[i]) {
                    if (i + 1 < n) {
                        second = s[i+1];
                        first = s[i];
                        ans++;
                        i++;
                    }
                    else {
                        //nothing
                    }
                }
                else {
                    first = s[i];
                    ans++;
                }
            }
            else {
                ans++;
                first = s[i];
                second = 0;
            }
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 25300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstring>
#include <unordered_set>
#include <chrono>
#include <cassert>

//#pragma GCC optimize("Ofast,unroll-loops,fast-math,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
const int SZ = 5e5 + 4;
const int inf = 2e9;
int hashpow = 41;
int mod = 1e9 + 7;

int a, b, c, k;

inline void read() {
    cin >> a >> b >> c >> k;
}

inline void solve() {
    int cnt = 0;
    while (b <= a) {
        b *= 2;
        ++cnt;
    }
    while (c <= b) {
        c *= 2;
        ++cnt;
    }
    if (cnt > k) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

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

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3648
x = [int(input()) for _ in range(5)]
y = []
sum_x = 0
for i in range(5):
    if x[i]%10 != 0:
        sum_x += (x[i]//10)*10+10
        y.append(x[i]%10)
    else:
        sum_x += x[i]
if len(y) != 0:
     sum_x = sum_x + min(y) - 10
print(sum_x)
 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,k; cin>>n>>k;
	if(2*k-1<=n) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath> // fabs, pow, sqrt, sin, fmod
#include <chrono> // system_clock 
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    vector<int> c(26);
    rep(i, 26) {
        cin >> c.at(i);
    }

    vector<vector<int>> s(D, vector<int>(26));
    rep(d, D) {
        rep(i, 26) {
            cin >> s.at(d).at(i);
        }
    }

    vector<int> t(D);
    /*
    rep(d, D) {
        cin >> t.at(d);
        t.at(d)--;
    } 
    */

    rep(d, D) {
        int max = 0;
        t[d] = 1;
        rep(i, 26) {
            if(max < s[d][i]) {
                max = s[d][i];
                t[d] = i;
            }
        }
    }

    //スコア計算
    int score = 0;

    vector<int> last(26);
    rep(i,26) last[i]= -1;

    rep(d, D) { //d:day
        last[t.at(d)] = d;
        //cout << "s: " << s[d][t[d]] << endl;
        score += s[d][t[d]];
        //cout << "score" << d << " " << score << endl; 
        rep(i, 26) { //i:contest
            score -= c[i] * (d - last[i]);
        }
        //cout << score << endl;
    }

    rep(d, D) {
        cout << t[d]+1 << endl;
    }
    
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,arr[100005],terbesar;
vector <pii> daftar;
int main()
{
	scan(n);
	for(int i=1;i<=n;i++)
		scan(arr[i]);
	sort(arr+1,arr+n+1);
	terbesar=arr[n];
	for(int i=1;i<=n-1;i++)
		daftar.eb(min(terbesar-arr[i],arr[i]),arr[i]);
	sort(all(daftar));
	cout<<terbesar<<" "<<daftar.back().se<<endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int luja(int n,int p){
    int count=0;
    while(n>0){
        n/=p;count+=n;
    }
    return count;
}
int main(void){
    vector<int>v(1001,1);vector<int>prime;
    v.at(0)=0;v.at(1)=0;
    int count;
    for(int i=2;i*i<=1000;i++){
        if(v.at(i)==1){
            for(int j=2;i*j<=1000;j++){
                v.at(i*j)=0;
            }
        }
    }
    rep(i,1001){
        if(v.at(i)==1)prime.push_back(i);
    }
    int n;cin>>n;ll ans=1;
    rep(i,prime.size()){
        ans=(ans*(luja(n,prime.at(i))+1))%1000000007;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int powmod(int x, int y, int mod)
{
    int res = 1;
    x %= mod;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve()
{
}

int main()
{
    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++)
        cin >> a[i];

    ll ans = 0;

    ll mx = a[0];

    for (ll i = 1; i < n; i++)
    {
        if (a[i] >= mx)
        {
            // ans += mx - a[i];
            mx = a[i];
        }
        else if (a[i] < mx)
        {
            ans += mx - a[i];
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5180
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

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

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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

const int mx = 1e5+123;
int h[mx], dp[mx], n;

int solve ( int i )
{
    if ( i == n ) return 0;

    if ( dp[i] != -1 ) return dp[i];

    int ret1 = inf, ret2 = inf;

    if ( i+1 <= n ) ret1 = abs ( h[i] - h[i+1] ) + solve ( i+1 );
    if ( i+2 <= n ) ret2 = abs ( h[i] - h[i+2] ) + solve ( i+2 );

    return dp[i] = min ( ret1, ret2 );
}

int main()
{
    optimize();

    cin >> n;
    for ( int i = 1; i <= n; i++ ) cin >> h[i];

    mem ( dp, -1 );
    cout << solve ( 1 ) << endl;

    return 0;
}


















Measured memory_bytes: 9028
use std::collections::HashSet;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n : u64 = read();
    let v = read_vec::<u64>();
    let u = v.iter().filter(|&x| x < &3200).map(|x| x/400).collect::<HashSet<u64>>().len();
    let o = v.iter().filter(|&x|x >= &3200).count();
    let ans_u = if u == 0{
        1
    } else {
        u
    };
    let ans_o = u + o;
    println!("{} {}",ans_u, ans_o );
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    string s1, s2;
    
    cin >> s1 >> s2;
    
    for(int i = 0; i < 3; i++){
        if(s1[i] != s2[2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m,i,j,k;
  scanf("%d %d",&n,&m);
  int a[n][m];
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      scanf("%d",&a[i-1][j-1]);
    }
  }
  int b[m];
  for(j=1;j<=m;j++){
    scanf("%d",&b[j-1]);
  }
  int c[n];
  for(k=1;k<=n;k++){
    c[k-1]=0; //????????????0???
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      c[i-1]+=a[i-1][j-1]*b[j-1];
    }
    printf("%d\n",c[i-1]);
  }
  return 0;
}

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


int main(){
  int d,n,m,ans,In;
  vector<int> vec;

  while(cin >> d && d){
    ans = 0;
    vec.clear();
    vec.push_back(0);
    cin >> n >> m;
    for(int i=0;i<n-1;i++){
      cin >> In;
      vec.push_back(In);
    }
    vec.push_back(d);
    sort(vec.begin(),vec.end());
    for(int i=0;i<m;i++){
      cin >> In;
      vector<int>::iterator it = lower_bound(vec.begin(),vec.end(),In);
      //cout << (*it) << " " << (*(it-1)) << endl;
      ans += abs((*it)-In)<abs((*(it-1))-In)?abs((*it)-In):abs((*(it-1))-In);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,y;
	while(cin>>n,n){
		vector<pair<double,int> > data;
		cin>>y;
		for(int i=0;i<n;i++){
			int b,r,t;
			double res;
			cin>>b>>r>>t;
			if(t==1)res=1.0+(double)y*r/100;
			else res=pow(1.0+(double)r/100,(double)y);
			data.push_back(make_pair(res,b));
		}
		sort(data.begin(),data.end(),greater<pair<double,int> >());
		cout<<data[0].second<<endl;
	}
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;
int main() {
    int t,d,l;
    while(cin>>t>>d>>l){
        if(!t&&!d&&!l)return 0;
        int ans=0;
        int x=0;
        rep(i,0,t){
            int p;
            cin>>p;
            if(p>=l)x=d;
            else x--;
            if(x>0)ans++;
        }
        cout<<max(0,ans-1)<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3092
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int p[13];
int main(void){
   int n;cin >> n;
   vector<int> d(n);rep(i,n) cin >> d[i];
   
   p[0]++;
   rep(i,n){
      p[d[i]]++; 
      if(d[i] == 0 || p[d[i]] == 3){
         cout << 0 << endl;
         return 0;
      }
   }
   int ans = -1;
   for(int s = 0;s < (1 << 12);s++){
      vector<int> d2(24,0);
      d2[0]++;
      for(int i = 1;i <= 11;i++){
         if(p[i] == 0) continue;
         else if(p[i] == 1){
            if((s >> i) & 1){
               d2[i] = 1;
            }else{
               d2[24 - i] = 1;
            }
         }else{
            d2[i] = d2[24 - i] = 1;
         }
      }
      if(p[12] == 1){
         d2[12] = 1;
      }else if(p[12] == 12){
         cout << 0 << endl;
         return 0;
      }
      
      //時差の最小値を求める
      vector<int> t; //点が存在する時刻を格納する
      for(int i = 0;i < 24;i++){
         if(d2[i]) t.pb(i);
      }
      t.pb(24);
      
      int dmin = 100;
      for(int i = 0;i < t.size() - 1;i++){
         mins(dmin,t[i+1] - t[i]);
      }
      maxs(ans,dmin);
   }
   cout << ans << endl;
   return 0;
   
}

Measured memory_bytes: 256
c[60000],j,n;main(i){for(i=2;i*i<5e4;i++)for(j=i;!c[i]&&j<5e4;c[j+=i]=1);for(;scanf("%d",&j),*c=j;n=!printf("%d\n",n))for(i=2;i<=j/2;n+=!(c[i]+c[j-i++]));exit(0);}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf = hell, N=305;
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll h, w, k, f,res=inf, ans;
	cin>>h>>w>>k;
	char c;
	ll a[h+1][w+1];
	rep(i,1,h+1){
		rep(j,1,w+1){
			cin>>c;
			a[i][j]=c-'0';
		}
	}
	map<ll,vector<ll> > mapa;	
	rep(mask,0,(1<<(h-1))){
		ans=0;
		mapa.clear();
		rep(i,1,h+1){
			mapa[ans].pb(i);
			if((mask>>(i-1))&1)ans++;
		}
		vector<ll> cnt(ans+1,0);
		rep(i,1,w+1){
			f=1;
            if(ans>=inf)continue;
			vector<ll> tmp(ans+1,0);
			for(auto x : mapa){
				for(auto y : x.se)
					tmp[x.fi]+=a[y][i];
				if(cnt[x.fi]+tmp[x.fi]>k)f=0;
			}
			for(auto x : mapa){
				f==1?cnt[x.fi]+=tmp[x.fi]:cnt[x.fi]=tmp[x.fi];
				if(cnt[x.fi]>k)ans=inf;
			}
			if(f==0)ans++;
		}
		res=min(res,ans);
	}
	cout<<res<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($y = 0; $y < $H; $y++){
    fscanf(STDIN, "%s", $str);
    $map[$y] = str_split($str);
    for($x = 0; $x < $W; $x++){
        if($map[$y][$x] == "#"){
            $list[$y][$x] = 1;
        }
    }
}
$count = 0;
while($list){
    $nextList = [];
    foreach($list as $y => $xs)foreach($xs as $x => $_){
        if($x && $map[$y][$x-1] == ".")$nextList[$y][$x-1] = $map[$y][$x-1] = "#";
        if($y && $map[$y-1][$x] == ".")$nextList[$y-1][$x] = $map[$y-1][$x] = "#";
        if($x < $W-1 && $map[$y][$x+1] == ".")$nextList[$y][$x+1] = $map[$y][$x+1] = "#";
        if($y < $H-1 && $map[$y+1][$x] == ".")$nextList[$y+1][$x] = $map[$y+1][$x] = "#";
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=500000;
long double a[N];
long double pre[N];
long double c(int n){

long double test=(n+1)*1.0/2*1.0;
return test;

}
int main()
{
    int n,k;
    long double ans=0.0;
    scanf("%d%d",&n,&k);
    long double tmp=0.0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=c(a[i]);
        if(i<k){
            tmp+=pre[i];
        }
    }

    for(int i=k;i<=n;i++){
    tmp+=pre[i];
    tmp-=pre[i-k];
    ans=max(ans,tmp);
    }
    cout<<fixed<<setprecision(8)<<ans;
}


Measured memory_bytes: 10048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main(){
    int n,k,p[1050]={0},sum=0;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> p[i];
    }
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++){
            if(p[j]<p[i]){
                int temp=p[j];
                p[j]=p[i];
                p[i]=temp;
            }
        }
    for(int i=1;i<=k;i++)
        sum +=p[i];
    cout << sum <<endl;
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
    int x,n,a;
    cin >> x >> n;
    vector<int> d(102);
    
    rep(i,n){
        cin >> a;
        d[a]=1;
    }
    P ans = {9999,-1};
    for(int i = 0; i < 102; i++){
        if (d[i]==1) continue;
        int dis = abs(x-i);
        ans = min(ans, P(dis, i));
    }
    cout << ans.second << endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s=sc.next();
int d=Character.getNumericValue(s.charAt(3));
int c=Character.getNumericValue(s.charAt(2));
int b=Character.getNumericValue(s.charAt(1));
int a=Character.getNumericValue(s.charAt(0));
String op1="",op2="",op3="";
if(a+b+c+d==7){op1="+";op2="+";op3="+";
}else if(a+b+c-d==7){op1="+";op2="+";op3="-";
}else if(a+b-c+d==7){op1="+";op2="-";op3="+";
}else if(a-b+c+d==7){op1="-";op2="+";op3="+";
}else if(a+b-c-d==7){op1="+";op2="-";op3="-";
}else if(a-b+c-d==7){op1="-";op2="+";op3="-";
}else if(a-b-c+d==7){op1="-";op2="-";op3="+";
}else{op1="-";op2="-";op3="-";}
System.out.println(a+op1+b+op2+c+op3+d+"=7");
}}

Measured memory_bytes: 23124
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 1e5+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[105][N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> candies(n);
    rep (i, 0, n) cin >> candies[i];

    vector<ll> pref(N);
    for (int i = 0; i <= k; ++i) {
        if (i <= candies[0]) dp[0][i] = 1;
        pref[i] = add(dp[0][i], i-1 >= 0 ? pref[i-1] : 0);
    }
    for (int i = 1; i < n; ++i) {
        vector<ll> curr_pref(N);
        for (int must = 0; must <= k; ++must) {
            dp[i][must] = sub(pref[must], must-min(candies[i], must)-1 >= 0 ? pref[must-min(candies[i], must)-1] : 0);
            curr_pref[must] = add(dp[i][must], must-1 >= 0 ? curr_pref[must-1] : 0);
        }
        pref = curr_pref;
    }

    cout << dp[n-1][k] << endl;
    
    return 0;
}

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

#define NIL -1
#define INF 1000000001

using namespace std;


void maxHeapify(int i, vector<int> &heap_array){
    int H = (int)heap_array.size(); // H+1
    int left = 2*i;
    int right= 2*i+1;
    int largest;
    if(left < H && heap_array[left] > heap_array[i]) largest = left;
    else largest = i;
    if(right< H && heap_array[right]> heap_array[largest]) largest = right;

    if(largest != i){
        swap(heap_array[largest],heap_array[i]);
        maxHeapify(largest,heap_array);
    } 
}

void heapIncrease(vector<int> &heap_array,int key,int i){
    if(key < heap_array[i]) return;
    heap_array[i] = key;
    while(i > 1 && heap_array[i/2] < heap_array[i]){
        swap(heap_array[i],heap_array[i/2]);
        i = i/2;
    }
}

void insert(vector<int> &heap_array,int key){
    heap_array.push_back(-INF);
    int size = (int)heap_array.size() -1;
    heapIncrease(heap_array,key,size);
}

int heapExtract(vector<int> &heap_array){
    int size = (int) heap_array.size()-1;
    if(size < 1) return -1;
    int maximum = heap_array[1];
    heap_array[1] = heap_array[size];
    heap_array.pop_back();
    maxHeapify(1,heap_array);
    return maximum;
}

int main(){
    int temp;
    vector<int> heap_array;
    heap_array.push_back(INF);
    char command[20];
    while(true){
        scanf("%s",command);
        if(strcmp(command,"end") ==0) break;
        else if(command[0] == 'i'){
            scanf("%d",&temp);
            insert(heap_array,temp);
        }else{
            temp = heapExtract(heap_array);
            if( temp> -1){
                printf("%d\n",temp);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 6888
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.14159265;
const ll MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 105;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
char text[MAXN];
char text2[MAXN];
char ans[MAXN * 2];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld", a * b / __gcd(a, b));
    return 0;
}

Measured memory_bytes: 256
S = input()
res = 'AC'
count = 0
if S[0] != 'A':
    res = 'WA'
       
for i in range(2, len(S)):
    if S[i] == 'C':
        count += 1
    elif S[i].isupper():
        res = 'WA'
        break

if S[-1].isupper():
    res = 'WA'
    
if S[1].isupper():
    res = 'WA'
    
if count != 1:
    res = 'WA'
        
print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i <= N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

map<ll, ll> M;

void prime_factor(ll N){

bool C = 1;

while(C){

C = 0;

    rep(i, 2, sqrt(N)){

    if(N%i == 0){M[i]++;N /= i;C = 1;break;}
   
    }

}

M[N]++;

}

int main(){
ll N, Ans = 0, cnt;cin >> N;

rep(i, 1, N - 2){

    cnt = 1;prime_factor(N - i);
  
  for(auto x : M ){

    cnt *= x.second + 1;//cout << x.first << " " << x.second << endl;

  }
  
  M.clear();

  Ans += cnt;

}

cout << Ans + 1;

}

Measured memory_bytes: 3680