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

#define mp make_pair
#define pb push_back
#define ppb pop_back

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")
#define in insert
#define rem remove

int main()
{

	ll n;
	cin >> n;
	vpl a(n);

	forn(i, n)
	{
		cin >> a[i].first;
		a[i].second = i+1;
	}

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

	ll sum = 0;

	set<ll> s;
	s.insert(0);
	s.insert(n+1);

	forn(i, n)
	{
		auto low = s.lower_bound(a[i].second);
		auto high = s.upper_bound(a[i].second);
		if(low != s.begin())	//cause of how lowerbound works
			low--;

		if(high == s.end())		//to point at end
			high--;

		sum += a[i].first * (a[i].second - *low) * (*high - a[i].second);
		s.insert(a[i].second);
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
ll exp(int a, int x){
    if (x == 0) return 1;
    ll p = exp(a,x/2);
    p *= p;
    p %= mod;
    if (x & 1){
        p *= a;
        p %= mod;
    }
    return p;
}
ll choose(int n, int k){
    ll ans = 1;
    for (int i = 1; i <= k; i++){
        ans *= (n-i+1);
        ans %= mod;
        ans *= exp(i,mod-2);
        ans %= mod;
    }
    return ans;
}
int main(){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    ll ans = exp(2,n)-1;
    ans += mod-choose(n,a);
    ans %= mod;
    ans += mod-choose(n,b);
    ans %= mod;

    printf("%lld",ans);


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] h = new int[100];
        String str, substr1, substr2;
        while(true){
            int m=0;
            str = sc.next();
            if(str.charAt(0) == '-') break;
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h[i] = sc.nextInt();
            }
            for(int i=0;i<m;i++){
                substr1 = str.substring(0,h[i]);
                substr2 = str.substring(h[i]);
                str = substr2 + substr1;
            }
            System.out.println(str);
        }
    }
}


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

int main() {
  int N , count ;
  cin >> N ;
  count = N ;
  vector<int> mochi(N);
  for ( int i = 0 ; i < N ; i++ ){
    cin >> mochi.at(i);
  }
  for ( int i = 0 ; i < N ; i++ ){
    for ( int j = 0 ; j < i ; j++ ){
      if ( mochi.at(i) == mochi.at(j) ){
        count--;
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const int MAX_N = 1e5 + 2;
vector<vector<P>> G(MAX_N);
vector<int> ans(MAX_N);

void dfs(int v, int w, int c) {
    if (ans[v] != -1) return;

    if (w % 2) ans[v] = 1 - c;
    else ans[v] = c;

    for (auto p : G[v]) {
        dfs(p.first, p.second, ans[v]);
    }
}

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

    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    rep(i, N) {
        ans[i] = -1;
    }

    dfs(0, 0, 0);

    rep(i, N) cout << ans[i] << endl;

    return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;


int main() {
    int n,q; cin >> n >> q;
    dsu uf(n);
    rep(i,q) {
        int t,u,v; cin >> t >> u >> v;
        if (t == 0) {
            uf.merge(u,v);
        } else {
            if (uf.same(u,v)) printf("%d\n", (int)1);
            else printf("%d\n", (int)0);
        }
    }
    return 0;
}


Measured memory_bytes: 3932
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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 solve() {
    int ans = 0;
    int temp;
    int temp2 = 10;
    rep(i,0,5){
        cin >> temp;
        if(temp%10 == 0){
            ans += temp;
        }
        else{
            temp2 = min(temp2, temp%10);
            ans += temp - temp%10 + 10;
        }
    }
    ans -= (10-temp2);
    cout << ans;
}

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

Measured memory_bytes: 384
import sys
A, B = map(int, input().split())

if 100*A%8 == 0:
    ans1 = int(A/0.08)
else:
    ans1 = int(A/0.08) + 1
ans2_max = int(ans1 + ans1*0.1)

ans2 = int(B/0.1)

if ans2 > ans2_max:
    print(-1)
    sys.exit()

while True:
    if int(ans1*0.08) == A and int(ans1*0.1) == B:
        print(ans1)
        break
    if ans1 > ans2_max:
        print(-1)
        break
    ans1 += 1



Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };
std::vector<int>G[100000];
std::vector<int>I[100000];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	int n, a[200];
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	int g = a[0];
	for (int i = 1;i < n;i++) {
		g = gcd(g, a[i]);
	}
	int ans = 0;
	while (true) {
		if (g % 2 == 1)break;
		else ans++, g /= 2;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,p,q;
	cin>>n>>p>>q;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll out=0;
	rep(i,n)out+=in[i];
	rep(i,n)in[i]=-(p*q-i*p-in[i]);
	sort(all(in));
	ll now=out;
	rep(i,n){
		ll t=-in[i];
		now+=t+2*p*i;
		out=max(out,now);
	}
	cout<<out<<endl;
}

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

int main() {
  vector<vector<int> > c(3, vector<int>(3));
  for(int i=0;i<3;i++) {
    for(int j=0;j<3;j++) {
      cin >> c[i][j];
    }
  }

  int d = 0;
  int e = 0;
  int f = 0;
  int g = 0;

  bool yes = true;

  for(int i=0;i<3;i++) {
    if(i==0) {
      d = c[i][1] - c[i][0];
      e = c[i][2] - c[i][1];
      f = c[1][i] - c[0][i];
      g = c[2][i] - c[1][i];
    } else {
      if(c[i][1] - c[i][0] != d || c[i][2] - c[i][1] != e || c[1][i] - c[0][i] != f || c[2][i] - c[1][i] != g) {
        yes = false;
        break;
      }
    }
  }

  if(yes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
namespace kozaiyApp
{
    public class B
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            long ans = 0;

            for (long i = 1; i <= N; i++)
            {
                if ((i % 3 != 0) && (i % 5 != 0))
                {
                    ans += i;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  vector<long> R(N + 1);
  for (long i = 1; i < N + 1; i++) {
    R.at(i) = R.at(i - 1) + A.at(i - 1);
  }
  long sum = R.at(N);
  long ans = 2e18;
  for (long i = 1; i < N; i++) {
    long tmp = sum - R.at(i);
    ans = min(ans, abs(tmp - R.at(i)));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;

ll calc(ll a) {
    ll cnt = (a+1) / 2;
    ll ans = cnt % 2;
    if (a % 2 == 0) ans ^= a;
    return ans;
}

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

    ll ans = calc(b) ^ calc(a-1);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;
static const int MAX = 100005;
ll N;

ll summ(ll n) {
  return (n*(n+1))/2;
}

int main() {
  cin >> N;
  cout << summ(N - 1) << endl;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 10, M = 1010, INF = 0x3f3f3f3f;

int n, a, b, c;
int l[N];

int dfs(int u, int sa, int sb, int sc, int cnt)
{
	if (u == n)
	{
		if (!sa || !sb || !sc) return INF;
		else return abs(a - sa) + abs(b - sb) + abs(c - sc) + (cnt - 3) * 10;
	}
	
	int res = INF;
	res = min(res, dfs(u + 1, sa + l[u], sb, sc, cnt + 1));
	res = min(res, dfs(u + 1, sa, sb + l[u], sc, cnt + 1));
	res = min(res, dfs(u + 1, sa, sb, sc + l[u], cnt + 1));
	res = min(res, dfs(u + 1, sa, sb, sc, cnt));
	return res;
}

int main()
{
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i ++ ) cin >> l[i];
	cout << dfs(0, 0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
import os
import sys
import numpy as np

def solve(N, U, V, AB):
    G = [[] for _ in range(N+1)]
    for ab in AB:
        a, b = ab
        G[a].append(b)
        G[b].append(a)
    P1 = np.zeros(N+1, dtype=np.int64)
    def dfs1(u):
        st = [u]
        while st:
            v = st.pop()
            p = P1[v]
            for u in G[v]:
                if p != u:
                    st.append(u)
                    P1[u] = v
    dfs1(U)
    path_u2v = [U]
    v = V
    while v != U:
        v = P1[v]
        path_u2v.append(v)
    path_u2v.reverse()
    l = len(path_u2v)
    half = (l-2) // 2
    c = path_u2v[half]
    ng = path_u2v[half+1]
    Depth = np.zeros(N+1, dtype=np.int64)
    def dfs2(c):
        st = [c]
        P = np.zeros(N+1, dtype=np.int64)
        while st:
            v = st.pop()
            p = P[v]
            d = Depth[v]
            for u in G[v]:
                if p != u and u != ng:
                    st.append(u)
                    P[u] = v
                    Depth[u] = d + 1
    dfs2(c)
    c_ = path_u2v[l-1-half]
    v = c_
    while v != c:
        Depth[v] = 0
        v = P1[v]
    d = l%2
    ans = max(Depth) + half + d
    return ans

def main():
    N, u, v = map(int, input().split())
    if N==2:
        print(0)
        return
    AB = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(N-1, 2)
    ans = solve(N, u, v, AB)
    print(ans)

main()


Measured memory_bytes: 48988
#include<stdio.h>
int main(){
  int t1, t2, t3;
  scanf("%d%d%d",&t1, &t2, &t3);
  if(t1==1 && t2==1){
    printf("Open\n");
  }else if(t3==1){
    printf("Open\n");
  }else{
    printf("Close\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    using P = pair<int, int>;
    auto f = [](P a){ return P(-a.second, a.first); };
    while(cin >> n, n){
        n++;
        vector<vector<P>> v(n);
        for (int i = 0; i < n; ++i) {
            int m;
            cin >> m;
            for (int j = 0; j < m; ++j) {
                int x, y;
                scanf("%d %d", &x, &y);
                v[i].emplace_back(x, y);
            }

        }

        for (int k = (int)v[0].size()-1; k >= 0; --k) {
            v[0][k].first -= v[0][0].first;
            v[0][k].second -= v[0][0].second;
        }
        int ans = 0;
        for (int i = 1; i < n; ++i) {
            int ok = 0;
            if(v[0].size() != v[i].size()) continue;
            for (int l = 0; l < 2; ++l) {
                for (int j = 0; j < 4; ++j) {
                    auto X = v[i][0];
                    for (auto &&k : v[i]) {
                        k.first -= X.first;
                        k.second -= X.second;
                    }
                    for (auto &&k : v[i]){
                        k = f(k);
                    }
                    int cnt = 0;
                    for (int k = 0; k < v[i].size(); ++k) {
                        if(v[0][k] == v[i][k]) cnt++;
                    }
                    if(cnt == v[i].size()) ok = 1;
                }
                reverse(v[i].begin(),v[i].end());
            }
            if(ok) cout << i << "\n";
        }
        puts("+++++");
    }
    return 0;
}


Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        String s = stdin.readLine();
        long win = s.chars().filter(ch -> ch == 'o').count();
        long possibility = 15 - s.length();
        String ans = (win + possibility >= 8) ? "YES" : "NO";
        stdout.println(ans);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}

Measured memory_bytes: 26964
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    rep(i,b){
        if(a*i % b == c){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
}


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

int gcd(int a, int b) {
  if(a%b==0) return b;
  else return gcd(b, a%b);
}

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> dist(N);
  for(int i=0;i<N;i++) {
    int a;
    cin >> a;
    dist[i] = abs(a-X);
  }

  int ans = 0;
    for(int i=0;i<N;i++) {
      if(i==0) ans = dist[i];
      else {
        if(ans>dist[i]) ans = gcd(ans, dist[i]);
        else ans = gcd(dist[i], ans);
      }
    }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
typedef long long ll;

ll N,A,B;
vector<ll> h;

bool judge(long long x){
   ll basic = x * B;
   ll diff = abs(A-B);
   vector<ll> ht = h;
   REP(i,ht.size()) ht[i] -= basic;
   ll cnt = 0;
   REP(i,ht.size()) {
   	if(ht[i] % diff == 0 && ht[i] >= 0) cnt += ht[i] / diff;
   	else if(ht[i] >= 0) cnt += ht[i] / diff + 1;
   }
   if(cnt <= x) return true;
   return false;
}

long long BinarySearchLowest(long long low, long long high){
   while(high-low>1){
      long long mid=(low+high)/2;
      if(judge(mid))high = mid;
      else low = mid;
   }
   return high;
}

int main() {

	cin >> N >> A >> B;
	h.resize(N);
	REP(i,N) cin >> h[i];

	ll sum = 0;
	REP(i,h.size()) sum += h[i];
	if(sum == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << BinarySearchLowest(0,1e10) << endl;

	return 0;
}

Measured memory_bytes: 1792
// ロジックを簡略化して, 再提出.
// a[c[0] - '0']++; -> a[c[0] - 'A']++;
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define a first
#define b second
#define all(x) x.begin(), x.end()
int a[26];

int main(){
    
    // 1. 入力情報.
    int N, K;
    scanf("%d %d", &N, &K);
    rep(i, N){
        char c[22];
        scanf("%s", c);
        a[c[0] - 'A']++;
    }
    
    // 2. データを保存.
    vector<int> v;
    rep(i, 26) if(a[i]) v.push_back(a[i]);
    
    // 3. 最大で何回のKUPCを開催できるか？
    // ex.
    // 6 2
    // DAWN
    // DAYLIGHT
    // DAZZLE
    // BAKERY
    // BARRIER
    // ABSENCE
    // -> 3回 が 正しいので, ロジック修正.
    int ans = 0;
    while(1){
        int k = K;
        sort(all(v));
        reverse(all(v));
        rep(i, v.size()){
            if(v[i] > 0) v[i]--, k--;
            if(!k) break;
        }
        if(k) break;
        else  ans++;
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include <stdio.h>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

int main(void)
{
	int A, B;
	cin >> A >> B;
	int ans = A + B / 2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = np.array(read().split(), np.int64)

def main(N, A):
    k = N * (N + 1) // 2
    t = A.sum() // k
    if k * t != A.sum():
        return False
    B = np.empty_like(A)
    B[1:] = A[1:] - A[:-1]
    B[0] = A[0] - A[-1]
    B -= t
    if np.any(B % N != 0):
        return False
    B //= (-N)
    return np.all(B >= 0)

print('YES' if main(N, A) else 'NO')

Measured memory_bytes: 33192
#include<bits/stdc++.h>
using namespace std;
int n,pos[100009];
long long ans;
set<int>l,r;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		pos[x]=i;
	}
	l.insert(-pos[n]);
	r.insert(pos[n]);
	for(int i=n-1;i>=1;i--) {
		int l1,l2,r1,r2;
		set<int>::iterator it;
		it=l.lower_bound(-pos[i]);
		if(it==l.end()) l1=l2=0;
		else {
			l1=-*it;
			it=l.lower_bound((*it)+1);
			if(it==l.end()) l2=0;
			else l2=-*it;
		}
		it=r.lower_bound(pos[i]);
		if(it==r.end()) r1=r2=n+1;
		else {
			r1=*it;
			it=r.lower_bound((*it)+1);
			if(it==r.end()) r2=n+1;
			else r2=*it;
		}
		ans+=1ll*(pos[i]-l1)*(r2-r1)*i+1ll*(r1-pos[i])*(l1-l2)*i;
		l.insert(-pos[i]);
		r.insert(pos[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
vector< vector< int > > prime;


void func(int N){
    for(int i=2; i<=N; ++i){
        vector<int> p(25, 0);
        int n=i;
        for(int j=0; j<25;){
            if(n == 1){
                break;
            }
            if(n % primes[j] == 0){
                p[j] += 1;
                n /= primes[j];
            }else{
                j++;
            }
        }
        prime[i-2] = p;
    }
}

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

    prime.resize(N-1);
    func(N);

    vector<int> pp(25, 0);
    for(int i=2; i<=N; ++i){
        for(int j=0; j<25; ++j){
            pp[j] += prime[i-2][j];
        }
    }

    /*
    2 * 4 * 4
    2 * 24
    4 * 14
    74
    */
    long ans = 0;
    for(int i=0; i<25; ++i){
        for(int j=i+1; j<25; ++j){
            for(int k=j+1; k<25; ++k){
                if(pp[i]>=2 && pp[j]>=4 && pp[k]>=4){
                    ans++;
                }
                if(pp[i]>=4 && pp[j]>=2 && pp[k]>=4){
                    ans++;
                }
                if(pp[i]>=4 && pp[j]>=4 && pp[k]>=2){
                    ans++;
                }
            }
            if(pp[i]>=2 && pp[j]>=24){
                ans++;
            }
            if(pp[i]>=24 && pp[j]>=2){
                ans++;
            }

            if(pp[i]>=4 && pp[j]>=14){
                ans++;
            }
            if(pp[i]>=14 && pp[j]>=4){
                ans++;
            }
        }
        if(pp[i]>=74){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import System.Random

main :: IO ()
main = do
    n <- fmap read getLine
    as0 <- (replicateM n (map read . words <$> getLine)) :: IO [[Int]]
    let as =  [0,0,0] : as0
    putStrLn $ yesOrHai $ hantei as

hantei :: [[Int]] -> Bool
hantei [] = True
hantei [ x ] = True
hantei (x:y:xs) =   if abs((x!!0)-(y!!0)) >= abs((x!!1 +x!!2)-(y!!1+y!!2)) && abs((x!!0)-(y!!0)-((x!!1 +x!!2)-(y!!1+y!!2))) `mod` 2 == 0 then hantei (y:xs)
                    else False

yesOrHai :: Bool -> String
yesOrHai True = "Yes"
yesOrHai False = "No"

Measured memory_bytes: 82300
# coding: utf-8
# Your code here!
N,D=map(int,input().split())
X=[]

for _ in range(N):
    X.append(list(map(int,input().split())))

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        temp=0
        for k in range(D):
            #print(i,j,k)
            temp+=(X[i][k]-X[j][k])**2
        if temp**0.5==(temp**0.5)//1:
            ans+=1
            
            
print(ans)



Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d", &a);
    scanf("%d %d", &b, &c);
    
    for (b==b;b <= c ;b++){
    	if (b % a == 0){
    		printf("OK\n");
    		return 0;
		}
		else {
			continue;
		}
	}
	printf("NG\n");
	return 0;
}


Measured memory_bytes: 1628
import math


def submit():
    x = int(input())
    max_prime = 100003
    sieve = [True for _ in range(max_prime + 1)]
    sieve[0] = False
    sieve[1] = False

    # 篩に掛ける
    cur = 2
    while True:
        if sieve[cur]: # curの倍数は消す
            m = 2
            while cur * m <= max_prime:
                sieve[cur * m] = False
                m += 1
        
        cur += 1
        while not sieve[cur]:
            cur += 1

        if cur > math.sqrt(max_prime):
            break

    # x以上で素数のものを探す
    for i in range(x, max_prime + 1):
        if sieve[i]:
            print(i)
            return


if __name__ == "__main__":
    submit()

Measured memory_bytes: 3956
/*Lower_Rating*/
/*Dwango Programming Contest 6th A*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
using namespace std;

#define LL long long
#define DB double
#define MOD 998244353
#define Pr pair<DB,int>
#define X first
#define Y second
#define MAXN 50
#define INF 20000000000000000LL
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return 1LL*a*b%MOD;}

int n,t[MAXN+5],F,res;
string s[MAXN+5],x;

int main()
{
    n=read();
    for(int i=1;i<=n;i++)
        cin>>s[i],t[i]=read();
    cin>>x;
    for(int i=1;i<=n;i++){
        if(F)res+=t[i];
        if(x==s[i])F=1;
    }
    printf("%d\n",res);
}


Measured memory_bytes: 256
def main():
    from collections import deque

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    es = []
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(b)
        g[b].add(a)
        es.append((a, b))

    cnt = 0
    for e in es:
        v = 0

        dq = deque()
        dq.append(v)
        used = [False] * N
        used[v] = True

        while dq:
            v = dq.popleft()
            for u in g[v]:
                if used[u]: continue
                if (v, u) == e or (u, v) == e: continue
                used[u] = True
                dq.append(u)

        if all(used): continue
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3316
while 1:
    n=int(input())
    if n==0:break
    for _ in range(n):
        x1,y1,z1,w1,x2,y2,z2,w2=map(int,input().split())
        print((x1*x2) - (y1*y2) -(z1*z2) -(w1*w2),
              (x1*y2) + (y1*x2) + (z1*w2) - (w1*z2),
              (x1*z2) - (y1*w2) + (z1*x2) + (w1*y2),
              (x1*w2) + (y1*z2) - (z1*y2) + (w1*x2))

Measured memory_bytes: 7556
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
mod = 10**9+7

ans = 1
for i in range(1,N+1):
    ans *= i
    ans %= mod

print(ans)

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

int main(){
    int a;
    cin >> a;
    AAA:;
    int saidai = a/2;
    for (int i = 2; i < saidai; i++){
        if (a%i == 0){
            a++;
            goto AAA;
        }
    }
    cout << a << "\n";
}

Measured memory_bytes: 256
import Foundation

func main() {
    let abc = readLine()!.split(separator: " ").map { Int($0)! }
    let K = Int(readLine()!)!
    let A = abc[0]
    let B = abc[1]
    let C = abc[2]
    
    for i in 0...K {
        for j in 0...K {
            for k in 0...K {
                if A<<i < B<<j && B<<j < C<<k && (i+j+k)<=K {
                    print("Yes")
                    return
                }
            }
        }
    }
    print("No")
}

main()


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

public class Main {
    static ArrayList<Integer> [] adj;
    static boolean [] vis;
    static int left; static int right;
    static int edges;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        adj = new ArrayList[200001];
        for (int i = 1; i <= 200000; i++) adj[i] = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt(); int y = sc.nextInt();
            adj[x].add(y + 100000);
            adj[y + 100000].add(x);
        }
        vis = new boolean[200001];
        long res = 0;
        for (int i = 1; i <= 200000; i++) {
            if (!vis[i]) {
                left = 0; right = 0; edges = 0;
                dfs(i, -1);
                res = res + ((long) right * left);
            }
        }
        out.println(res - n);
        out.close();
    }

    static void dfs(int cur, int par) {
        if (cur <= 100000) left++; else right++;
        vis[cur] = true;
        for (Integer next: adj[cur]) {
            if (next == par) continue;
            else if (vis[next]) edges++;
            else {
                edges++;
                dfs(next, cur);
            }
        }
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 75708
#include<stdio.h>
#include<string.h>
     
int main(){
    char s[20];
    scanf("%s", s);
     
    int dex = 0;
    char arr[11] = {'\0'};
    int l = strlen(s);
    
	for(int i = 0; i < l;i++){
        if(s[i] == '0'){
          arr[dex] = '0';
          dex++;
        }
		
	else if (s[i] == '1'){
          arr[dex] = '1';
          dex++;
        }
		
	else if(s[i] == 'B'){
          if (dex != 0){
            dex--;
            arr[dex] = '\0';
          }
        }
      }
	printf("%s", arr);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
    
using namespace std;
    
int main() {
    int N, ans = 0;

    scanf("%d", &N);
    int a;
    for(int i = 0; i < N; i++) {
        scanf("%d", &a);
        ans += a - 1;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll h, w, c, ans = 0, s[110000];
int main() {
	cin >> h >> w >> c;
	REP(i, w)cin >> s[i];
	REP(i, h) {
		ll now = 0;
		REP(j, w) {
			ll a;
			cin >> a;
			now += a * s[j];
		}
		if (now + c > 0)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    ll ans = 0;
    while (true) {
        bool ok = true;
        rep(i,N) {
            if (B[i] < A[i]) {
                cout << -1 << ln;
                return 0;
            }
            if (B[i] > A[i]) {
                if (B[i] <= B[(i+N-1)%N] || B[i] <= B[(i+1)%N]) {
                    ok = false;
                    continue;
                }
                if (B[i]-A[i] < B[(i+N-1)%N] + B[(i+1)%N]) {
                    cout << -1 << ln;
                    return 0;
                }
                ans += (B[i]-A[i])/(B[(i+N-1)%N] + B[(i+1)%N]);
                B[i] = (B[i]-A[i])%(B[(i+N-1)%N] + B[(i+1)%N]) + A[i];
                if (B[i] != A[i]) ok = false;
            }
        }
        if (ok) {
            cout << ans << ln;
            return 0;
        }
    }
}

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

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

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

    double L; cin >> L;

    printf("%.16f\n",L*L*L/27);

    return 0;

}

Measured memory_bytes: 256
M=9999;main(n,i,j,k,a,b,c){
	double p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
		for(a=i=0;i<n;i++){
			for(b=k=0;k<M;k++){
				x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
				for(c=j=0;j<n;j++){
					if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
				}
				if(b<c)b=c;
			}
			if(a<b)a=b;
		}
	}
exit(0);}

Measured memory_bytes: 644
module Main where

import Data.List

main :: IO ()
main = do
  [_, _, x] <- (map read . words) <$> getLine
  contents <- map (map read . words) . lines <$> getContents
  print $ solve x contents

solve :: Int -> [[Int]] -> Int
solve target points = if null master_cost then -1 else minimum master_cost
  where
    table = to_table points
    allcase = filter (not . null) . subsequences $ table
    master_cost = map get_cost . filter (correct target) . map result $ allcase

result :: [(Int, [Int])] -> (Int, [Int])
result ((c, p):ps) = (c + cc, zipWith (+) p pp)
  where
    (cc, pp) = result ps

result [] = (0, repeat 0)


to_table :: [[Int]] -> [(Int, [Int])]
to_table = map (\p -> (head p, tail p))

correct :: Int -> (Int, [Int]) -> Bool
correct target (_, ps) = all (>= target) ps

get_cost :: (Int, [Int]) -> Int
get_cost (c, _) = c


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


typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int i=0;i<v.size();i++){ cout<<v[i]; if(i<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                1000006
#define MOD                 1000000007
#define PI                  acos(-1)

ll arr[MAXN];
string s;

int main()
{
    fastIO();
    cin>>s;
    ll sum=0;
    char ch='0';
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='>'){
            ll val=0;
            for(int j=i;j>=0;j--){
                arr[j+1]=val;
                val=val+1;
                if(s[j]=='<')break;
                if(j==0)arr[j]=val;
                i=j;
            }
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='<'){
            arr[i+1]=max(arr[i]+1,arr[i+1]);
        }
    }
    for(int i=0;i<=s.size();i++){
        sum+=arr[i];
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 5020
from sys import stdin

SX, SY, TX, TY = map(int, stdin.readline().rstrip().split())


# S->T
# とりあえず上
print('U' * (TY - SY), end='')
print('R' * (TX - SX), end='')

# T->S
print('D' * (TY - SY), end='')
print('L' * (TX - SX), end='')

# S->T 2回目
# 左へ大回り
print('L', end='')
print('U' * (TY - SY + 1), end='')
print('R' * (TX - SX + 1), end='')
print('D', end='')

# T->S 2回目
# 右へ大回り
print('R', end='')
print('D' * (TY - SY + 1), end='')
print('L' * (TX - SX + 1), end='')
print('U')


Measured memory_bytes: 3064
<?php
while(1)
{
  $d = $a = -PHP_INT_MAX;
  
  fscanf(STDIN, "%d", $n);
  if(!$n)
    break;
  for($i = 0; $i < $n; $i++)
  {
    fscanf(STDIN, "%d", $m);
    $d = max($d + $m, $m);
    $a = max($a, $d);
  }
  echo $a . "\n";
}

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

int main() {
  vector<char> a(3);
  int counter = 0;
  for(int i = 0; i < 3; i++){
    cin >> a.at(i);
    if(a.at(i) == 'o') counter++;
  }
  cout << 700 + 100 * counter << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;lint ans=1,tmp=1;cin>>n;
    for(int i=0;i<n;i++)ans*=3;
    vector<int> vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    for(int i=0;i<n;i++){
        if(vec[i]%2==0)tmp*=2;
    }
    cout<<ans-tmp<<endl;
}



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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n ;
    cin>> n ;
    vi h(n+1), dp(n+1, inf) ;
    for(int i=1 ; i<=n ; i++) cin>> h[i] ;
    dp[1]=0 ;
    for(int i=2 ; i<=n ; i++) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) ;
    cout<< dp[n] ;
  }


Measured memory_bytes: 1024
from numpy import sign
n=int(input())
a=list(map(int,input().split()))
a_abs=list(map(abs,a))
a_abs.sort()

plmi=1
for i in a:
    plmi*=sign(i)

if plmi==-1:
    ans=sum(a_abs[1:])-a_abs[0]
elif plmi==1 or plmi==0:
    ans=sum(a_abs)
print(ans)

Measured memory_bytes: 23292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int D =int.Parse(input[1]);
            int x = int.Parse(input[2]);
            int N = 10;
            int[] ans = new int[N];
            for (int i = 0; i < N; i++)
            {
                ans[i] = r * x - D;
                x = ans[i];
            }
            foreach (var item in ans)
            {
                Console.WriteLine(item);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void){
    int A;
    int B;
    do{
    
        scanf("%d%d",&A,&B);
         
    }while(A >16 || B>16);

       if(A > 8 || B > 8){
            printf(":(\n");
        }else{
            printf("Yay!\n");
        }
    
}

Measured memory_bytes: 128
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N >> M;
    ll ans = min(N, M / 2);
    N -= ans;
    M -= ans * 2;
    if(!N) {
    	ans += M / 4;
    }
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3620
from bisect import bisect
from collections import deque

N,M = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(M):
    b,c = map(int, input().split())
    bc.append((c,b))

bc.sort(key=lambda x:x[0], reverse=True)
bc = deque(bc)
a.sort()
ans = 0
for ai in a:
    if bc==deque([]):
        ans += ai
        continue
    c,b = bc[0]
    if ai<c:
        ans += c
        if b-1==0:
            bc.popleft()
            continue
        bc[0] = (c,b-1)
    else:
        ans += ai
# print(bc)
print(ans)


Measured memory_bytes: 22884
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF	9999999999
#define pb push_back
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
typedef long long int ll; 
typedef vector<ll> vi;
typedef vector<vi> vii;


int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll c=0,cnt=0,a[n];
	FOR(i,n) 
	{
		cin>>a[i];
		if(a[i]%4==0) c++;
		else if(a[i]%2==0) cnt++;
	}
	if(c*2>=n)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	ll diff=n-c*2;
	// ll d=ceil((double)diff/2);
	if(diff==1)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(cnt>=diff)
	{
		cout<<"Yes"<<endl;

	}
	else cout<<"No"<<endl;

	
	return 0;
}

Measured memory_bytes: 1024