akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CCandies solver = new CCandies();
        solver.solve(1, in, out);
        out.close();
    }

    static class CCandies {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();

            int[] a1 = IntMath.sum(in.ints(n));
            int[] a2 = IntMath.sum(in.ints(n));
            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, a1[i + 1] + a2[n] - a2[i]);
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static int[] sum(int[] a) {
            int[] sum = new int[a.length + 1];
            for (int i = 0; i < a.length; i++) {
                sum[i + 1] = sum[i] + a[i];
            }
            return sum;
        }

    }
}



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

#define ll long long
#define endl '\n'

ll num[100001];
ll M = 1e18;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, i;
    cin >> N;
    ll p = 1;
    for (i = 0; i < N; i++) {
        cin >> num[i];
        if (!num[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (i = 0; i < N; i++) {
        if (p > M / num[i]) {
            cout << -1 << endl;
            return 0;
        }
        p *= num[i];
        // if (p < 0 || p > 1e18) {
        //     cout << -1 << endl;
        //     return 0;
        // }
    }
    cout << p << endl;
    return 0;
}


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

int main(){
  int n,l;
  cin >> n >> l;
  int su=0,mi=101;
  for(int i=0;i<n;i++){
    su+=l+i;
    if(abs(mi)>abs(l+i))
      mi=l+i;
  }
  cout << su-mi << endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	map<string, int> ma;
	rep(i, n) {
		string s; cin >> s;
		ma[s]++;
	}
	int maxv = 0;
	for (auto u : ma) {
		maxv = max(maxv, u.second);
	}
	for (auto u : ma) {
		if (maxv == u.second) {
			cout << u.first << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 25216
#include<iostream>
using namespace std;
int main()
{
	int R;
	cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else if(2800<=R<=4208){
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    H, W, K = map(int, input().split())
    B = [[int(c == '#') for c in input()] for _ in range(H)]

    def cnt_bk_cell(mask_r, mask_c):
        """未着色かつ黒のセルを数える"""
        ret = 0
        for r in range(H):
            if (mask_r >> r) & 1: continue  # 着色行は計上対象外
            for c in range(W):
                if (mask_c >> c) & 1: continue  # 着色列は計上対象外
                if B[r][c]: ret += 1
        return ret

    ans = 0
    for mask_r in range(1 << H):  # 2**12
        for mask_c in range(1 << W):
            if K == cnt_bk_cell(mask_r, mask_c): ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
### constant

MAX_INT = (1 << 31) - 1

### main

while true
  m, n = gets.strip.split(' ').map{|s| s.to_i}
  break if m == 0 && n == 0

  carvs = []
  for i in (0...n)
    tw = gets.strip.to_i
    carvs << [i * 10, i + 1, tw]
  end

  wqueue = []

  pn = 0
  pcs = m.times.map{[]}

  outs = []
  t = 0

  while ! carvs.empty? || ! wqueue.empty? || pn > 0
    ## out
    if pn > 0
      for i in (0...m)
        while ! pcs[i].empty? && pcs[i].last[1] <= t
          c = pcs[i].pop
          pn -= 1
          outs << c[0]
          #puts "#{t}: OUT: #{c}"
          #p pcs
        end
      end
    end

    ## arrive
    if ! carvs.empty?
      t0, id, tw = carvs[0]
      if t0 <= t
        carvs.shift
        wqueue << [id, tw]
        #puts "#{t}: ARRIVE: #{[id, tw]}"
      end
    end

    ## park
    while pn < 2 * m && ! wqueue.empty?
      parked = false

      min_l_i = -1
      min_l_t = MAX_INT
      min_e_i = -1
      min_e_t = MAX_INT

      for i in (0...m)
        pcn = pcs[i].length

        if pcn == 0
          c = wqueue.shift
          c[1] += t
          pcs[i] << c
          pn += 1
          parked = true
          #puts "#{t}: PARK: #{c} -> #{[i, 0]}"
          #p pcs
          break
        elsif pcn == 1
          c = wqueue.first
          dt = pcs[i].first[1] - (t + c[1])

          if dt >= 0
            if min_l_t > dt
              min_l_t = dt
              min_l_i = i
            end
          else
            if min_e_t > -dt
              min_e_t = -dt
              min_e_i = i
            end
          end
        end
      end

      if ! parked
        i0 = (min_l_i >= 0) ? min_l_i : min_e_i
        c = wqueue.shift
        c[1] += t
        pcs[i0] << c
        pn += 1
        #puts "#{t}: PARK: #{c} -> #{[i0, 1]}"
        #p pcs
      end
    end

    t += 1
  end

  puts outs.join(' ')
end

Measured memory_bytes: 6156
//118B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0, m=0, k=0, menu=0;
    cin >> n >> m;
    vector<int>L(m+1,0);
    rep(i, n){
        cin >> k;
        rep(j, k){
            cin >> menu;
            L[menu] +=1;
        }
    }
    //rep(i, m+1) cout <<L[i] << endl;
    cout << count(L.begin(), L.end(), n) << endl;
}

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

using namespace std;
    void leftrotate(string &s , int d);
    void rightrotate(string &s, int d);

int main()
{   string S,T; bool test=0;;
    cin >> S >> T ;
    if(S==T){cout<<"Yes"; test=true;}
    else {for(int i=0 ;i<S.size();i++)
    {
        rightrotate(S,1);
        if(S==T){cout << "Yes"; test=true; break;}
    }}

    if(test==false){cout<<"No";}

    return 0;
}

   void leftrotate(string &s , int d)
   {

    reverse(s.begin(), s.begin()+d);
    reverse(s.begin()+d, s.end());
    reverse(s.begin(), s.end());

    }

    void rightrotate(string &s, int d)
{
   leftrotate(s, s.length()-d);
}

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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << char(a.at(0) - 32);
  cout << char(b.at(0) - 32);
  cout << char(c.at(0) - 32) << endl;
}

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

using namespace std ;

#define i64 long long int

int main()
{
    ios_base::sync_with_stdio(false);
    i64 a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a*b>c*d)
    {
        cout<<a*b<<endl;
    }
    else
    {
        cout<<c*d<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
int pp[1000010] = {};
int min_val[1000010] = {};
int mm[1000010] = {};
string S[1000010];
bool use[1000010] = {};
typedef struct {
    ll a;
    ll b;
    ll c;
} P;


void solve(){
    ll N;
    cin >> N;
    rep(i,0,N) cin >> S[i];
    // if(N >= 5000) exit(1);
    ll c0 = 0, c1 = 0;
    rep(i,0,N) min_val[i] = 1e9;
    rep(i,0,N){
        int r = 0;
        for(auto &e: S[i]){
            if(e == '('){
                c0++;
                pp[i]++;
                r++;
            }else{
                c1++;
                r--;
                pp[i]--;
            }
            min_val[i] = min(min_val[i], r);
            mm[i] = max(mm[i], r);
        }
    }
    if(c0 != c1){
        print("No");
        return;
    }
    ll cur = 0;
    bool ok = true;
    ll cnt = 0;
    // rep(i,0,N){
    //     print(pp[i], min_val[i]);
    // }
    vector<P> lp, lp2;
    rep(i,0,N){
        if(pp[i] >= 0){
            lp.push_back({pp[i], min_val[i], mm[i]});
        }else{
            lp2.push_back({pp[i], min_val[i], mm[i]});
        }
    }
    sort(lp.begin(), lp.end(), [](P l1, P l2){return l1.b > l2.b;});
    sort(lp2.begin(), lp2.end(), [](P l1, P l2){return l1.a - l1.b > l2.a - l2.b;});
    for(auto &e: lp){
        if(cur + e.b < 0){
            ok = false;
            break;
        }
        cur += e.a;
    }
    for(auto &e: lp2){
        if(cur + e.b < 0){
            ok = false;
            break;
        }
        cur += e.a;
    }


    if(ok){
        print("Yes");
    }else{
        print("No");
    }
}

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

Measured memory_bytes: 69852
#include <iostream>

using namespace std;

void swap(int& x, int& y){
    int tmp;
    tmp = x;
    x = y;
    y = tmp;
}

int main(){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if(b<a){
        swap(a,b);
    }
    if (c<b){
        swap(b,c);
        if(b<a){
            swap(a,b);
        }
    }
    cout << a << " " << b << " " << c << endl; 
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int a, b, c, sum = 0;

int main(){
	cin >> a >> b >> c;
	sum = a * 100 + b * 10 + c;

	if (sum % 4 == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int s1 = N / 1000, s2 = (N - s1 * 1000) / 100, s3 = (N - s1 * 1000 - s2 * 100) / 10, s4 = (N - s1 * 1000 - s2 * 100 - s3 * 10);
   if (((s1 == s2) && (s2 == s3)) || ((s2 == s3) && (s3 == s4))) 
     cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

# Level nバーガーの層数とパティの総数
burgers = [0] * (N + 1)
patty = [0] * (N + 1)
burgers[0] = 1
patty[0] = 1
for i in range(1, N + 1):
    burgers[i] = 3 + burgers[i - 1] * 2
    patty[i] = 1 + patty[i - 1] * 2


def f(n, x):
    if n == 0 and x == 1:
        return 1
    elif x == 1:
        return 0
    elif x < 2 + burgers[n - 1]:
        return f(n - 1, x - 1)
    elif x == 2 + burgers[n - 1]:
        return patty[n - 1] + 1
    elif x < burgers[n]:
        return patty[n - 1] + 1 + f(n - 1, x - 2 - burgers[n - 1])
    else:
        return patty[n]


print(f(N, X))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<'\n';
  return(0);
}


Measured memory_bytes: 3600
n, m = gets.split.map(&:to_i)

MOD = 1_000_000_007

as = Array.new(n + 5, 0)
m.times do
  a = gets.to_i
  as[a] = -1
end

as[0] = 1

1.upto(n) do |i|
  next if as[i] == -1
  
  sum = 0

  if i > 0 && as[i - 1] != -1
    sum += as[i - 1]
  end

  if i > 1 && as[i - 2] != -1
    sum += as[i - 2]
  end

  as[i] = sum % MOD
end

p as[n]


Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    vector<int> x(3);
    rep(i, 2) {
        int y;
        scan(y);
        x[y - 1]++;
    }
    rep(i, 3) {
        if (x[i] == 0)
            print(i + 1);
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, q;
int a[50], b[50], c[50], d[50];

int ans;

void dfs(vector<int> &v){
	if(v.size() == n){
		int score = 0;
		rep(i,q){
			if(v[b[i]] - v[a[i]] == c[i]) score += d[i];
		}
		chmax(ans, score);
		return;
	}
	int last;
	if(v.empty()) last = 1;
	else last = v[v.size()-1];
	for(int add = last; add <= m; add++){
		vector<int> w = v;
		w.push_back(add);
		dfs(w);
	}
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	rep(i,q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	ans = 0;
	vector<int> w;
	dfs(w);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
signed main(){

	//%MOD下での階乗
	ll ex[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		ex[i]=ex[i-1]*i%MOD;
	}
	//%MOD下での階乗の逆数
	ll inv[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		inv[i]=mod_pow(i,MOD-2,MOD);
	}
	for(int i=1;i<SIZE;i++){
		inv[i]=inv[i-1]*inv[i]%MOD;
	}

	ll N, K;
	cin>>N>>K;
	vll A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(), A.end());

	// map<int, int> left, right;	//各整数の最初,最後の座標
	// for(int i=0;i<N;i++){
	// 	int a=A[i];
	// 	if(left.find(a)==left.end())
	// 		left[a]=i;
	// 	right[a]=i;
	// }

	ll ans=0;

	for(int i=0;i<N;i++){
		int a=A[i];
		int small=i, big=N-i-1;


		//cout<<a<<" "<<small<<" "<<big<<endl;

		ll S=ex[big]*inv[big-(K-1)]%MOD*inv[K-1]%MOD;
		ll B=ex[small]*inv[small-(K-1)]%MOD*inv[K-1]%MOD;

		if(small<K-1)
			B=0;
		if(big<K-1)
			S=0;

		//cout<<S<<" "<<B<<endl;

		ll temp=(B-S+MOD)%MOD*a%MOD;
		(ans+=(temp+MOD)%MOD)%=MOD;
	}

	cout<<(ans)%MOD<<endl;


	return 0;
}

Measured memory_bytes: 4472
n = int(input())
s = input()
b_lst=[]
w_lst=[]
b_cnt=0
w_cnt=0
for i in range(len(s)):
    b_lst.append(b_cnt)
    w_lst.append(w_cnt)
    if s[i]=="#":
        b_cnt+=1
    if s[len(s)-i-1]==".":
        w_cnt+=1
b_lst.append(b_cnt)
w_lst.append(w_cnt)
w_lst.reverse()

ans=10**9
for b,w in zip(b_lst,w_lst):
    if ans > b+w:
        ans=b+w
print(ans)

Measured memory_bytes: 12820
/**********************************************
 *Author*        :jxf378440404
 *Created Time*  : 2018/9/29 19:59:46

 *********************************************/

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

map<int,int> cnt1;
map<int,int> cnt2;
int a[MaxN + 5];

int main()
{
	int n,ans1,ans2,p1,p2;
	while(~scanf("%d",&n)){
		cnt1.clear();cnt2.clear();
		ans1 = 0;ans2 = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d",&a[i]);
			if(i & 1){
				cnt1[a[i]]++;
				if(ans1 < cnt1[a[i]]){
					p1 = a[i];
					ans1 = cnt1[a[i]];
				}
			}
			else {
				cnt2[a[i]]++;
				if(ans2 < cnt2[a[i]]){
					p2 = a[i];
					ans2 = cnt2[a[i]];
				}
			}
		}
		if(p1 == p2){
			if(ans1 == ans2){
				int sum1 = 0,sum2 = 0;
				for(int i = 1;i <= n;i++){
					if(p1 == a[i]) continue;
					if(i & 1) sum1 = max(sum1,cnt1[a[i]]);
					else sum2 = max(sum2,cnt2[a[i]]);
				}
				if(sum1 >= sum2) ans1 = sum1;
				else ans2 = sum2;
			}
			else if(ans1 < ans2){
				ans1 = 0;
				for(int i = 1;i <= n;i += 2){
					if(a[i] != p2) ans1 = max(ans1,cnt1[a[i]]);
				}
			}
			else{
				ans2 = 0;
				for(int i = 2;i <= n;i += 2){
					if(a[i] != p1) ans2 = max(ans2,cnt2[a[i]]);
				}
			}
		}
		printf("%d\n",n - ans1 - ans2);
	}
	return 0;
}

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

int main()
{
    int N;
    cin>>N;
    
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin>>a[i];
    }
    
    sort(a.begin(),a.end(),[](int a,int b)->int{return a>b;});

    int aScore=0,bScore=0;
    for (int i=0; i<N; i++) {
        if(i%2==0)
        {
            aScore+=a[i];
            continue;
        }
        bScore+=a[i];
    }
    
    cout<<aScore-bScore<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

q = factorization(n)

ans = 0
for i in range(len(q)):
    l = q[i][1]
    if q[i][0] == 1:
        continue

    for j in range(1,l+1):
        l -= j
        if l < 0:
            break
        else:
            ans += 1
print(ans)
    

Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << char(a[0]+('A'-'a')) << char(b[0]+('A'-'a')) << char(c[0]+('A'-'a')) << endl;
  return 0;
}


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

constexpr int MAX_N=2001;

using ll=long long int;

int n,k,maxLabel;

std::vector<int> books[11];

ll memo[11][MAX_N];

ll solve(int label,int m) {
	if(memo[label][m]>0)
		return memo[label][m];
	if(m==0)
		return 0;
	if(label>=maxLabel)
		return 0;

	ll res=solve(label+1,m);

	for(int i=0;i<books[label].size()&&i<m;++i)
		res=std::max(res,solve(label+1,m-i-1)+books[label][i]+i*(i+1));

	return memo[label][m]=res;
}

int main() {
	std::cin>>n>>k;
	int c,g;
	for(int i=0;i<n;++i){
		std::cin>>c>>g;
		books[g-1].push_back(c);
		maxLabel=std::max(maxLabel,g);
	}
	for(int i=0;i<10;++i)
		std::sort(books[i].begin(),books[i].end(),std::greater<int>());

	for(int i=0;i<maxLabel;++i) {
		for(int j=1;j<books[i].size();++j)
			books[i][j]+=books[i][j-1];
	}

	std::cout<<solve(0,k)<<std::endl;
	return 0;
}

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

const int MAXN = 3000001;
bool flag[MAXN];

int main() {
  int n, a, b;
  while(cin >> n >> a >> b && (n|a|b)) {
    int cnt = 0;
    fill(flag, flag+MAXN, false);
    flag[0] = true;
    for(int i = 0; i <= n; ++i) {
      if(!flag[i]) continue;
      if(1 <= i && i <= n) cnt += 1;
      flag[i+a] = flag[i+b] = true;
    }
    cout << n-cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 4088
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

int inverse(int a){
	return power(a, p - 2);
}

int *fact, *fact_inv;

int comb(int n, int k){
	if(k < 0 || n < k || n < 0){
		return 0;
	}
	else{
		return MOD(fact[n] * MOD(fact_inv[k] * fact_inv[n - k]));
	}
}

signed main(){
	int B, W, i;
	scanf("%lld%lld", &B, &W);
	fact = (int *)malloc(sizeof(int) * (B + W + 1));
	fact[0] = 1;
	for(i = 1; i <= B + W; i++){
		fact[i] = MOD(fact[i - 1] * i);
	}
	fact_inv = (int *)malloc(sizeof(int) * (B + W + 1));
	for(i = 0; i <= B + W; i++){
		fact_inv[i] = inverse(fact[i]);
	}
	int *a = (int *)malloc(sizeof(int) * (B + W + 1));
	int *b = (int *)malloc(sizeof(int) * (B + W + 1));
	int *c = (int *)malloc(sizeof(int) * (B + W + 1));
	for(i = 0; i < W; i++){
		a[i] = 0;
	}
	for(i = W; i < B + W; i++){
		a[i] = MOD(a[i - 1] + comb(i - 1, W - 1) * inverse(power(2, i)));
	}
	a[B + W] = 1;

	for(i = 0; i < B; i++){
		b[i] = 0;
	}
	for(i = B; i < B + W; i++){
		b[i] = MOD(b[i - 1] + comb(i - 1, B - 1) * inverse(power(2, i)));
	}
	b[B + W] = 1;

	for(i = 0; i < B + W; i++){
		c[i] = MOD(1 - a[i] - b[i]);
	}
	c[B + W] = 0;

/*	for(i = 0; i <= B + W; i++){
		printf("a[%lld] = %lld\n", i, a[i]);
	}
	printf("\n");

	for(i = 0; i <= B + W; i++){
		printf("b[%lld] = %lld\n", i, b[i]);
	}
	printf("\n");

	for(i = 0; i <= B + W; i++){
		printf("c[%lld] = %lld\n", i, c[i]);
	}
	printf("\n");
*/
	for(i = 1; i <= B + W; i++){
		printf("%lld\n", MOD(a[i - 1] + inverse(2) * c[i - 1]));
	}
	return 0;
}

Measured memory_bytes: 9984
n = int(input())
A = [int(input()) for x in range(n)]

right = [0]
left = [0]

for a in A:
   left.append(max(a, left[-1]))

for a in reversed(A):
   right.append(max(a, right[-1]))

for i in range(n):
   print(max(left[i], right[n-i-1]))


Measured memory_bytes: 15636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m,stx,sty,ans;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
bool vis[25][25];
char s[25][25];
struct node{
	int x,y,d;
	node(){
		
	}
	node(int xx,int yy,int dd){
		x = xx; y = yy; d = dd;
	}
};
void bfs(int x,int y){
	queue<node> q;
	q.push(node(x,y,0));
	vis[x][y] = 1;
	while(!q.empty()){
		int nx = q.front().x,ny = q.front().y,nd = q.front().d;
		q.pop();
		for(int i = 0;i < 4;i++){
			int tx = nx + dx[i],ty = ny + dy[i];
			if(tx >= 0 & tx < n && ty >= 0 && ty < m && !vis[tx][ty] && s[tx][ty] != '#'){
				q.push(node(tx,ty,nd+1));
				if(nd + 1 > ans){
					ans = nd + 1;
					stx = tx;
					sty = ty;
				}
				vis[tx][ty] = 1;
			}
		}
	}
	return;
}
int main(){
// 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%d %d",&n,&m);
	for(int i = 0;i < n;i++) scanf("%s",s[i]);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(s[i][j] == '.'){
				memset(vis,0,sizeof(vis));
				bfs(i,j);
			}
		}
	}
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

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

int main() {
    int n, x, result = 0;
    cin >> n >> x;
    int a[n];
    for (int i = 0; cin >> a[i]; i++) {
    }
    sort(a, a + n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (sum <= x) {
            result++;
        }
    }
    if (sum < x) {
        result--;
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
int i,n;
    scanf("%d",&n);
    int nums[n];
    n--;
    for(i = 0;i <= n;i++){
        scanf("%d",&nums[i]);
    }
    for(i = 0;1;i++){
        printf("%d",nums[n - i]);
        if(i == n){
            break;
        }
        printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
import Control.Monad

main = do
  handn <- (map read . words) <$> getLine :: IO [Int]
  let h = handn !! 0 :: Int
  pic <- replicateM h getLine :: IO [String]

  -- mapM_ (putStrLn . show) handn
  -- mapM_ putStrLn pic

  let ans = foldl (\a b -> b:b:a) [] $ reverse pic
  mapM_ putStrLn ans

Measured memory_bytes: 1276
import sys
sys.setrecursionlimit(10**9)

def rec_w(y, x):
    ans[y][x] = cnt
    if x+1 < W and grid[y][x+1] != '#' and ans[y][x+1] == 0:
        rec_w(y, x+1)
    if x-1 >= 0 and grid[y][x-1] != '#' and ans[y][x-1] == 0:
        rec_w(y, x-1)
def rec_h(y, x):
    if y+1 >= H:
        return
    if ans[y+1][x] == 0:
        rec_h(y+1, x)
    ans[y][x] = ans[y+1][x]
def rec_hm(y, x):
    if y-1 < 0:
        return
    if ans[y-1][x] == 0:
        rec_hm(y-1, x)
    ans[y][x] = ans[y-1][x]

H, W, K = map(int, input().split())
grid = [list(input()) for h in range(H)]
ans = [[0 for w in range(W)] for h in range(H)]
cnt = 1
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            rec_w(h, w)
            cnt += 1
for h in range(H-1):
    for w in range(W):
        if ans[h][w] == 0:
            rec_h(h, w)
for w in range(W):
    if ans[H-1][w] == 0:
        rec_hm(H-1, w)
for a in ans:
    print(' '.join(map(str, a)))

Measured memory_bytes: 83820
program B
    integer :: N, L, m = 1000000, mi = 0, s = 0, nm
    read*,N, L
    do i = 0, N - 1, 1
        nm = L + i
        s = s + nm
        if (abs(nm) < m) then
            m = abs(nm)
            mi = nm
        endif
    enddo
    print*, s - mi
end program B

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;


ll ans;

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	ll n, k;
	ll r, s, p;
	string t, T[100010];
	cin >> n >> k >> r >> s >> p >> t;

	for (int i = 0; i < n; i++)
	{
		T[i % k] += t[i];
	}

	for (int i = 0; i < k; i++)
	{
		if (T[i][0] == 'r')
		{
			ans += p;
		}
		if (T[i][0] == 's')
		{
			ans += r;
		}
		if (T[i][0] == 'p')
		{
			ans += s;
		}
      	bool jud = true;
		for (int j = 1; j < T[i].length(); j++)
		{
			if (T[i][j] == T[i][j - 1])
            {
              	if (jud)
                {
                  	jud = false;
                  	continue;
                }
              	else
                {
                  	
                }
            }

			if (T[i][j] == 'r')
			{
				ans += p;
			}
			if (T[i][j] == 's')
			{
				ans += r;
			}
			if (T[i][j] == 'p')
			{
				ans += s;
			}
          	jud = true;
		}
	}
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double res = v[0];
	for (int i = 1; i < n; i++) {
		res = (res + v[i]) / 2;
	}
	cout << setprecision(10) << res << endl;
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <stdlib.h>
#define H 500005

void buildMaxHeap();
void maxHeapify(int);
int A[H],n;

  int main(){
  int i;

  scanf("%d",&n);

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

  buildMaxHeap();

  for(i=1; i <= n; i++){
    printf(" %d",A[i]);
  } 
    printf("\n");
  

  return 0;
}


void maxHeapify(int i){
  int l,r;
  int largest;
  int s;

  l=2*i;
  r=2*i+1;


  if(l <= n && A[l] > A[i]){
    largest=l;
  }
  else {
    largest=i;
  }

  if(r <=n && A[r] > A[largest]){
    largest=r;
  }

  if(largest!=i){
    s=A[i];
    A[i]=A[largest];
    A[largest]=s;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int j;
  for(j=n/2; j >=1; j--){
    maxHeapify(j);
  }
}

Measured memory_bytes: 2552
N = 3
S = [list(map(int, input().split())) for _ in range(N)]
n_guess = int(input())
guesses = set([int(input()) for _ in range(n_guess)])
dic = {}
for r in range(N):
  for c in range(N):
    dic[S[r][c]]=(r,c)

for g in guesses:
  if g in dic:
    (r, c) = dic[g]
    S[r][c] = -1

ans = 'No'
for i in range(N):
  if sum(S[i]) == -3:
    ans='Yes'
    
for i in range(N):
  if sum([S[_][i] for _ in range(N)]) == -3:
    ans='Yes'
    
if all([S[i][N-i-1]==-1 for i in range(N)]) or \
   all([S[i][i]==-1 for i in range(N)]):
   	ans = 'Yes'
print(ans)

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

int main(){
  int s;
  cin>>s;
  int a,b;
  a=s/100;
  b=s%100;
  
  if(a==0||a>12){
    if(b==0||b>12){
      cout<<"NA"<<endl;
    }else{
      cout<<"YYMM"<<endl;
    }
  }else{
    if(b==0||b>12){
      cout<<"MMYY"<<endl;
    }else{
      cout<<"AMBIGUOUS"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
const int N=100010,hs=19260817;
int cnt;
int p[N];
bool w[N];
map <ll,int> g;
inline ll gi() {
    ll x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void pre(int n) {
    for(int i=2;i<=n;i++) {
	if(!w[i]) p[++cnt]=i;
	for(int j=1;j<=cnt&&i*p[j]<=n;j++) {
	    w[i*p[j]]=1;
	    if(i%p[j]==0) break;
	}
    }
}
int main() {
    int n,t=0,ans=0;
    cin>>n;
    pre(100000);
    for(int i=1;i<=n;i++) {
	ll x=gi(),s1=0,s2=0;
	for(int j=1;p[j]<=320;j++)
	    if(x%p[j]==0) {
		int t=0,q=p[j];
		while(x%q==0) x/=q,++t;
		if(t%=3) {
		    s1=s1*hs+q,s2=s2*hs+q;
		    if(t==2) s1=s1*hs+q;
		    else s2=s2*hs+q;
		}
	    }
	if(x>1) {
	    ll y=sqrt(x)+1e-9;
	    if(y*y==x) s1=(s1*hs+y)*hs+y,s2=s2*hs+y;
	    else if(x<=100000&&!w[x]) s1=s1*hs+x,s2=(s2*hs+x)*hs+x;
	    else {++ans;continue;}
	}
	if(!s1) {t=1;continue;}
	++g[s1];
	if(g[s1]>g[s2]) ++ans;
    }
    cout<<ans+t;
    return 0;
}

Measured memory_bytes: 10624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.Queue;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,m =fr.nextInt() ,a[] =new int[n] ,i ,j ,k ;	ArrayList<ArrayList<Integer>> g =new ArrayList<>() ;
 		for (i =0 ; i<n ; ++i)	g.add(new ArrayList<>()) ;	boolean mrk[] =new boolean[n] ;
 		while (m-->0) {
 			i =fr.nextInt()-1 ;	j =fr.nextInt()-1 ;
 			g.get(i).add(j) ;	g.get(j).add(i) ;
 		}
 		Queue<Integer> q =new LinkedList<>() ;	q.add(0) ;	mrk[0] =true ;
 		while (!q.isEmpty()) {
 			i =q.poll() ;
 			for (j =0 ; j<g.get(i).size() ; ++j) {
 				k =g.get(i).get(j) ;	if (mrk[k])	continue;
 				a[k] =i+1 ;	mrk[k] =true ;	q.add(k) ;
 			}
 		}
 		for (k =0 ; k<n ; ++k) {
 			if (!mrk[k])	break;
 		}
 		if (k==n) {
 			op.println("Yes") ;
 			for (i =1 ; i<n ; ++i)	op.println(a[i]) ;	
 		}
 		else 	op.println("No") ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(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();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 76196
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    int[] ar = new int[n];
    for(int i=0;i<n;i++){
      ar[i] = sc.nextInt();
    }
    for(int j=0;j<n;j++){
      if(ar[j] >= k){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 50216
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<math.h>
#include<string.h>
#include<queue>

using namespace std;

#define M  100000+100
#define mod 1000000007
typedef long long ll;

int a[M];
ll kpow(ll x,ll n) {
    ll res = 1;
    x%=mod;
    while (n) {
        if(n&1) res = res*x%mod;
        x = x*x %mod;
        n >>=1;
    }
    return res;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    // c(n,m) = n!/m!/(n-m)!
    ll res = 1;
    for(int i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*kpow(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}
int main()
{
    int x,y;
    cin>>x>>y;
    //cout<<Lucas(x,y);
    if(x==y)
    {
        if(x%3!=0)
            cout<<"0";
        else
        {
            ll t=x/3;
            cout<<Lucas(t*2,t);
        }
    }
    else
    {
        int maxx=max(x,y),minn=min(x,y);
        int dif=maxx-minn;
        maxx=maxx-2*dif;
        minn=minn-dif;
        if(maxx<0||minn<0)
           cout<<"0";
        else
        {
            if(maxx%3!=0) cout<<"0";
            else
            {
                ll t=dif+maxx/3*2;
                cout<<Lucas(t,maxx/3);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main(){
  // 入力
  long int N;
  cin >> N;
  vector<string> S(N);
  for (long int i=0; i<N; i++) {
    cin >>S[i];
  }

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

  long int result = N;
  for (long int i=1; i<N; i++) {
    if (S[i-1] == S[i]) {
      result--;
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std; 
long long int maxProductSubarrayOfSizeK(long long int A[],long long int n,long long int k) 
{  
    sort(A, A + n); 
    long long int product = 1;    
    if (A[n - 1] <= 0 && (k & 1))
	{ 
        for (int i = n - 1; i >= n - k; i--) 
            product = ((product*(A[i]%1000000007))%1000000007+1000000007)%1000000007; 
        return product%1000000007; 
    } 
    long long int i = 0; 
    long long int j = n - 1;  
    if (k & 1)
	{ 
        product = ((product*(A[j]%1000000007))%1000000007+1000000007)%1000000007; 
        j--; 
        k--; 
    }
    k >>= 1; 
    for (long long int itr = 0; itr < k; itr++)
	{ 
        long long int left_product = A[i] * A[i + 1]; 
        long long int right_product = A[j] * A[j - 1];  
        if (left_product >= right_product) { 
            product = ((product*(left_product%1000000007))%1000000007+1000000007)%1000000007; 
            i += 2; 
        } 
        else { 
            product = ((product*(right_product%1000000007))%1000000007+1000000007)%1000000007; 
            j -= 2; 
        } 
    } 
    return product%1000000007; 
} 
int main() 
{ 
    long long int n,k;
	cin>>n>>k;
	long long a[n+5];
	for(int i=0;i<n;i++)
	cin>>a[i];
    cout << maxProductSubarrayOfSizeK(a, n, k); 
  
    return 0; 
} 

Measured memory_bytes: 5156
<?php
# 整数の入力
fscanf(STDIN, "%d", $num);

$array = explode(" ",trim(fgets(STDIN)));

$count = 0;
for($i=0;$i<$num;$i++){
  $product = $array[$i];
  while($product % 2 == 0){
    $product = $product / 2;
    $count++;
  }
}

echo $count;

Measured memory_bytes: 4856
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define LL long long
const int maxn = 1e6+33;
const int mod = 1e9+7;

int num[maxn];

struct node
{
    int l,r;
    bool friend operator < (node a,node b){
        return a.r<b.r;
    }
}q[maxn];
int n,m;
void add(int x,int p)
{
    for(int i=x;i<=n;i+=i&-i)
        num[i]+=p;
}

int query(int x)
{
    int ans=0;
    for(int i=x;i>=1;i-=i&-i){
        ans+=num[i];
    }
    return ans;
}


int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&q[i].l,&q[i].r);
    }
    sort(q+1,q+1+m);
    int ans=0;
    for(int i=1;i<=m;i++){
        int to = query(q[i].r)-query(q[i].l);
        if(to==0){
            add(q[i].r,1);
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;

}


Measured memory_bytes: 5120
#include <stdio.h>
#include <map>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)


int N;
int main(void) {
	auto m = new std::map<int, bool>();
	int in = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &in);
		if (m->find(in) != m->end()) {
			printf("NO\n");
			return 0;
		}
		m->insert(std::make_pair(in, true));
	}
	printf("YES\n");
	return 0;
}
 

Measured memory_bytes: 9600
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MOD (1000000007)
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  int mat = 0, maa = 0;
  for(int i = 0; i < n; i++){
    mat = max(mat, t[i]);
    maa = max(maa, a[i]);
  }
  if(mat != maa){
    cout << 0 << endl;
    return 0;
  }

  bool ng = false;
  int c[n];
  c[0] = 1;
  if(a[0] < t[0]) ng = true;
  for(int i = 1; i < n; i++){
    if(t[i - 1] < t[i]){
      if(a[i] < t[i]) ng = true;
      c[i] = 1;
    }
    else c[i] = t[i];
  }
  c[n - 1] = 1;
  if(a[n - 1] > t[n - 1]) ng = true;
  for(int i = n - 2; i >= 0; i--){
    if(a[i] > a[i + 1]){
      if(a[i] > t[i]) ng = true;
      c[i] = 1;
    }
    else c[i] = min(c[i], a[i]);
  }

  ll sum = 1;
  for(int i = 0; i < n; i++){
    sum = (sum * c[i]) % MOD;
  }

  if(!ng) cout << sum << endl;
  else cout << 0 << endl;

  return 0;
}


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

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


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define q_type vector<ll>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int rem[200001];
int solve(vector<int>& vec, int ind, int cur)
{
    if(ind>=vec.size()) return vec.size()-cur+1;

    if(rem[ind] == -1)
        rem[ind] = min({solve(vec, ind+1, cur+(vec[ind]==cur)), solve(vec, ind+1, cur)});

    return rem[ind];
}


int main()
{
    for(int i = 0; i<200001; ++i) rem[i] = -1;
    int n;
    cin>>n;
    vector<int> vec(n);
    for(auto& it : vec) cin>>it;

    int ans = solve(vec, 0, 1);
    cout<<(ans==vec.size()?-1:ans)<<endl;
}

Measured memory_bytes: 11136
min_n = 124
max_n = -1

for _ in range(5):
    temp = int(input())
    min_n = min(min_n,temp)
    max_n = max(max_n,temp)

distance = int(input())
if max_n-min_n > distance:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using Match = pair<int, int>;

const bool DEBUG = true;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
    reverse(a[i].begin(), a[i].end());
    // 次の人を末尾から探せるように反転しておく
  }

  vector<Match> queue;

  auto check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();  // 次の対戦相手
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      // i<->jなら次の試合のキューに追加
      Match m(i, j);
      if (m.second < m.first) swap(m.first, m.second);
      queue.push_back(m);
    }
  };

  // キューの初期化
  for (size_t i = 0; i < n; i++) check(i);

  int day = 0;
  while (queue.size() > 0) {
    day++;

    // 要素のユニークを取る
    sort(queue.begin(), queue.end());
    queue.erase(unique(queue.begin(), queue.end()), queue.end());

    // 前のキューをprev_queueにうつしてqueueを空にする
    vector<Match> prev_queue;
    swap(prev_queue, queue);

    for (auto &&m : prev_queue) {
      // 試合を行う
      int i = m.first, j = m.second;
      a[i].pop_back();  // 試合結果を削除
      a[j].pop_back();
    }

    for (auto &&m : prev_queue) {
      // 試合が終了したペアについて新しく試合ができるかチェック
      int i = m.first, j = m.second;
      check(i);
      check(j);
    }
  }

  for (size_t i = 0; i < n; i++) {
    if (a[i].size() != 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
ll cnt[100002]={};
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n,m,c=0;
       cin>>n>>m;
       ll a[n+1];
       for(int i=1;i<=n;i++) cin>>a[i];
       while(m--)
       {
           ll x,y;
           cin>>x>>y;
           if(a[x]==a[y]) {cnt[x]=1e5;cnt[y]=1e5;}
           cnt[x]=max(max(a[x],a[y]),cnt[x]);
           cnt[y]=max(max(a[x],a[y]),cnt[y]);
       }
       for(int i=1;i<=n;i++)
       {
           if(cnt[i]==0||cnt[i]==a[i]) c++;
       }
       cout<< c;
    }
    return 0;
}


Measured memory_bytes: 5204
s=str(input())
n=len(s)

a=''
for i in range(n):
        if i%2==0:
                a+='1'
        else:
                a+='0'
c=0
d=0
for j in range(n):
        if s[j]==a[j]:
                c+=1
        else:
                d+=1
print(min(c,d))

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

using namespace std;

int main ()

{
	int row, column, N;

	cin >> row >> column >> N;

	int large;

	large = max (row, column);

	int operation;

	if (N%large == 0)
	{
		operation = N/large;
	}

	else operation = (N/large) +1;

	cout << operation;
}



Measured memory_bytes: 256