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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    int ma = *max_element(a.begin(), a.end());
    int nh = h+ma;
    imat dp(nh, ivec(n));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) dp[0][i] = 0;
    for (int i = 1; i < nh; i++) dp[i][0] = b[0] * ( 1 + (i)/a[0] - !((i) % a[0]));
    for (int i = 1; i < nh; i++){
        for (int j = 1; j < n; j++) dp[i][j] = fmin(dp[i][j-1], dp[fmax(i-a[j], 0)][j] + b[j]);
    }
    cout << dp[h][n-1] << endl;
}

Measured memory_bytes: 44544
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll gcd(ll a , ll b) {
    return (b > 0) ? gcd(b , a % b) : 1;
}
int main() {
    ll n , a , b , c , d;
    cin >> n >> a >> b >> c >> d;
    ll gg = a - b;
    int flag = 0;
    for(ll i = 0 ; i < n ; i++) {
        ll x = i , y = n - i - 1;
        ll Min = x * c - y * d;
        ll Max = x * d - y * c;
        if(gg <= Max && gg >= Min) {
            ll gl = gg - Min;
            ll x1 = x % (gl - 1) , y1 = y % (gl - 1);
            if(gcd(x1 , y1) == 1) {
                flag = 1;
                break;
            }
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())

A = [int(input()) for i in range(n)]

A.sort()

half = math.floor(n/2)
if n ==2:
    print(A[1]-A[0])
else:
    half_A = A[half]
    dif = A[half+1] - half_A*2 +A[half-1]
    if (n%2 == 1) & (dif>0):
        total = sum(A[half+1:])*2 - sum(A[:half-1])*2 -A[half] - A[half-1]
    elif (n % 2 == 1) & (dif<=0):
        total = sum(A[half+2:])*2 - sum(A[:half])*2 + A[half] + A[half+1]
    else:
        total = sum(A[half+1:])*2 - sum(A[:half-1])*2 -A[half-1] + A[half]
    
    print(total)


Measured memory_bytes: 81584
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N,K;

const int max_n = 200000+10;

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

    Int sum = 0;
    for(Int i = K;i <= N+1;i++) {
        sum += (i*(2*N-i+1))/2-(i*(i-1))/2+1;
        sum %= MOD;
    }

    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


ll power(ll a, ll b) {
    ll ans = 1;
    ll t = a;
    while (b) {
        if (b % 2) {
            ans = (ans * t) % 998244353;
        }

        t = (t * t) % 998244353;
        b /= 2;
    }

    return ans;
}

int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n;
    cin >> n;
    int fr[n];
    memset(fr, 0, sizeof fr);
    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        fr[e]++;

        if (i == 0 && e) {
            cout << 0;
            return 0;
        }
    }
    
    if (fr[0] != 1) {
        cout << 0;
        return 0;
    }


    int l = -1;
    for (int i = 0; i < n; i++) {
        if (fr[i] == 0) break;
        l = i;
    }

    for (int i = l + 1; i < n; i++) {
        if (fr[i]) {
            cout << 0;
            return 0;
        }
    }


    ll ans = 1;
    for (int i = 1; i < n - 1; i++) {
        if (fr[i] == 0) break;
        ans *= power(fr[i], fr[i + 1]);
        ans %= 998244353;
    }

    cout << ans;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = n-1;
    for(int i=2; i<1000001; i++){
        if(n%i == 0){
            ans = min(n/i + i - 2, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,p = inpl()
print((a*3+p)//2)

Measured memory_bytes: 66284
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T>
vector<T> divisor(T val) {
  vector<T> res;
  for (T i = 1; i * i <= val; ++i) {
    if (val % i == 0) {
      res.emplace_back(i);
      if (i * i != val) res.emplace_back(val / i);
    }
  }
  sort(ALL(res));
  return res;
}

int main() {
  int n; cin >> n;
  vector<ll> v(3); REP(i, 3) cin >> v[i];
  vector<int> s0(n), s1(n);
  REP(i, n) {
    string s; cin >> s;
    s0[i] = s[0] - 'A';
    s1[i] = s[1] - 'A';
  }
  // REP(i, n) cout << s0[i] << ' ' << s1[i] << endl;
  vector<int> ans(n);
  REP(i, n) {
    if (v[s0[i]] > v[s1[i]]) swap(s0[i], s1[i]);
    if (v[s0[i]] == v[s1[i]]) {
      if (i + 1 < n && (s1[i] == s0[i + 1] || s1[i] == s1[i + 1])) swap(s0[i], s1[i]);
    }
    if (v[s1[i]] == 0) {
      cout << "No\n";
      return 0;
    }
    ans[i] = s0[i];
    --v[s1[i]];
    ++v[s0[i]];
  }
  cout << "Yes\n";
  REP(i, n) cout << char('A' + ans[i]) << '\n';
  return 0;
}


Measured memory_bytes: 4520
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
	
	char hitachi[10];
	scanf("%s",hitachi);
	char h;
	char i;
	int m=0;
	if(strlen(hitachi)%2==1){
		printf("No");
		return 0;
	}
	while(m<strlen(hitachi)){
		if(hitachi[m]=='h'){
			m++;
			if(hitachi[m]=='i'){
				m++;
			}else{
				printf("No");
				return 0;
			}
		}else{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    numbers = string_to_int(inputs[0])
    counter = collections.Counter()

    for n in numbers:
        counter[n-1] += 1
        counter[n] += 1
        counter[n+1] += 1

    return counter.most_common(1)[0][1]


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var l = Input().ToInt();
		Array.Sort(l);

		long wa = 0;
		for(int i = n - 1; i >= 0; i--)
		{
			for(int j = i-1; j >= 0; j--)
			{
				var a = l[i];
				var b = l[j];
				var maxIndex = UpperBound(l, 0, j, a+b+1, Comparer<int>.Default);
				var minIndex = UpperBound(l, 0, j, Math.Max(a-b, b-a), Comparer<int>.Default);
				
				maxIndex = Math.Min(maxIndex, j);

				//Console.WriteLine("{0} {1} {2} {3}", k, k2, a, b);
				//Console.WriteLine("{0}+{1} {2} {3} //{4}", a, b, maxIndex, minIndex, maxIndex - minIndex);
				wa += Math.Max(0, maxIndex - minIndex);


			}
		}
		Console.WriteLine(wa);
	}
	

	public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
	{
	    int low = start;
	    int high = end;
	    int mid;
	    while (low < high)
	    {
	        mid = ((high - low) >> 1) + low;
	        if (comparer.Compare(arr[mid], value) <= 0)
	            low = mid + 1;
	        else
	            high = mid;
	    }
	    return low;
	}
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}

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

int getDays(int y, int m, int d){
    int days = 0;
    days += (y-1)/3 * (20*10+2*(20*5+19*5)) + (y-1)%3 * (20*5+19*5);
    days += (m-1)/2 * (20+19+!(y%3)) + (m-1)%2 * 20;
    days += d;
    return days;
}

int main(){
    int n;
    cin >> n;
    int mill = getDays(1000,1,1);
    for(int i=0;i<n;++i){
        int y, m, d;
        cin >> y >> m >> d;
        cout << mill - getDays(y, m, d) << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	input = input[0].split(" ");
	
	var N = parseInt(input[0], 10);
    var X = parseInt(input[1], 10);
  	var T = parseInt(input[2], 10);
   	
  	// console.log("%d %d %d", N, X, T);
  
  	var result = Math.trunc(N / X + 0.9) * T;
  
  
	//出力
	console.log('%d',result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29664
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	string S = inputVal<string>();
	sort(S.begin(), S.end());
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 x, y;
	std::cin >> x >> y;
	if (x%y == 0) { std::cout << "-1\n";return 0; }
	std::cout << x << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  cout << "ABC"+S << endl;
}

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

int main()
{
    int t;
    cin >> t;
    string s;
    cin >> s;
    if(s.length() <= t){
        cout << s << endl;
    }
    else
    {
        for(int i=0;i<t;i++){
            cout << s[i];
        }
        cout << "..."<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3580
# coding: utf-8

inf = 2**31-1

class SegTree:
  size = 0
  node = []

  def __init__(self, n):
    self.size = 1
    while self.size < n:
      self.size *= 2
    self.node = [inf]*(2*self.size-1)
  
  def update(self, k, x):
    k += self.size-1
    self.node[k] = x
    while k > 0:
      k = (k-1)//2
      self.node[k] = min(self.node[k*2+1], self.node[k*2+2])
  
  def query(self, l, r, k=0, a=0, b=None):
    if b == None:
      k = 0
      a = 0
      b = self.size
    if b <= l or r <= a:
      return inf
    if(l <= a and b <= r):
      return self.node[k]
    
    return min(self.query(l, r, k*2+1, a, (a+b)//2), self.query(l, r, k*2+2, (a+b)//2, b))
  
  def debug(self):
    for i in range(self.size):
      print(self.node[i+self.size-1], end=' ')
    print()

n, q = map(int, input().split(' '))
sg = SegTree(n)
for i in range(q):
  tp, a, b = map(int, input().split(' '))
  if tp == 0:
    sg.update(a, b)
  else:
    b += 1
    print(sg.query(a, b))



Measured memory_bytes: 8700
N = int(input())
H = list(map(int, input().split()))

cnt = 0
H = H[::-1]
for i in range(1, N):
    if H[i-1] >= H[i]:
        cnt += 1
    elif H[i-1] == H[i] - 1:
        cnt += 1
        H[i] -= 1
    else:
        cnt = 0

if cnt == len(H)-1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define INF 9999999999999999

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // cout<<fixed<<setprecision(15);  

    ll n;
    cin>>n;

    ll t1 = 0;

    for(ll i = 0 ; i < n ; i++)
    {
    	ll t2;
    	cin>>t2;
    	t1 = t1 ^ t2;
    }

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

}

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

int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;
  
  int C;
  if( op == '+' ){
    C = A + B;
  }else{
    C = A - B;
  }
  cout << C << endl;
}


Measured memory_bytes: 256
(defun hm (n)
  (if (oddp n)
      (cond ((= 105 n) 1)
            ((= 135 n) 1)
            ((= 165 n) 1)
            ((= 189 n) 1)
            ((= 195 n) 1)
            (t 0))
      0))

(let ((a (make-array 1 :element-type 'integer
                       :initial-element 0
                       :fill-pointer 1
                       :adjustable t))
      (n (read)))
  (loop for i from 1 upto 200 do
        (vector-push-extend (+ (hm i) (aref a (1- i))) a))
  (princ (aref a n)))


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

bitset<7> ZERO(string("0111111"));
bitset<7>  ONE(string("0000110"));
bitset<7>  TWO(string("1011011"));
bitset<7> THREE(string("1001111"));
bitset<7> FOUR(string("1100110"));
bitset<7> FIVE(string("1101101"));
bitset<7>  SIX(string("1111101"));
bitset<7> SEVEN(string("0100111"));
bitset<7> EIGHT(string("1111111"));
bitset<7> NINE(string("1101111"));
bitset<7> decode(int x){
	switch (x) {
		case 0: return ZERO;
		case 1: return ONE;
		case 2: return TWO;
		case 3: return THREE;
		case 4: return FOUR;
		case 5: return FIVE;
		case 6: return SIX;
		case 7: return SEVEN;
		case 8: return EIGHT;
		case 9: return NINE;
	}
}

int main(void){
	int n;
	int x;
	while(cin>>n,n!=-1){
		bitset<7> now;
		while(n--){
			cin>>x;
			bitset<7> sig(decode(x));
			sig^=now;
			cout<<sig<<endl;
			now=decode(x);
		}
	}
}

Measured memory_bytes: 3168
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
      
        List<Integer> div = new ArrayList<Integer>();
        for(int i=0;i<N;i++){
          div.add(sc.nextInt());
        }
          
        Collections.sort(div);
      int max = div.get(div.size()-1);
      boolean[] flg = new boolean[max+1]; 
      
      for(int i=0;i<div.size()-1;i++){
        int now = div.get(i);
        if(now == div.get(i+1)){
          flg[now] = true;
        }
        for(int j=now*2;j<max+1;j=j+now){
          flg[j] = true;
        }
      }
      
      int count = 0;
      for(int i=0;i<div.size();i++){
        if(!flg[div.get(i)]){
          count++;
        }
      }
      
      System.out.println(String.valueOf(count));
    }
}

Measured memory_bytes: 63428
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int P = int.Parse(str[2]);
		int[,]A = new int[M,3];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			A[i,2] = int.Parse(str2[2]);
		}
		var list = new List<int[]>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int[]>();
		}
		for(var i=0;i<M;i++){
			list[A[i,0]-1].Add(new int[3]{i,A[i,1]-1,A[i,2]});
		}
		var listA = new List<int>();
		listA.Add(0);
		long[]T = new long[N];
		int[]S = new int[N];
		int[]F = new int[N];
		F[0] = 1;
		while(listA.Count>0){
			var list2 = new List<int>(listA);
			listA.Clear();
			for(var i=0;i<list2.Count;i++){
				var i1 = list2[i];
				if(S[i1]==1){
					long a1 = T[i1] - P;
					for(var j=0;j<list[i1].Count;j++){
						int m1 = list[i1][j][0];
						int n2 = list[i1][j][1];
						long a2 = a1 + list[i1][j][2];
						if(F[n2]==0){
							S[n2]=1;
							listA.Add(n2);
                 			F[n2]=1;
						} else if(F[n2]>=1 && S[n2]==0){
                          	S[n2]=1;
                          	listA.Add(n2);
                        }
					}
				} else {
					long a1 = T[i1] - P;
					for(var j=0;j<list[i1].Count;j++){
						int m1 = list[i1][j][0];
						int n2 = list[i1][j][1];
						long a2 = a1 + list[i1][j][2];
                     	if(F[n2]>=2500 && S[n2]==0 && a2>T[n2]){
                       		S[n2] = 1;
                          	listA.Add(n2);
                        } else if(F[n2]>=1 && S[n2]==0 && a2>T[n2]){
							T[n2] = a2;
                          	F[n2]++;
                          	listA.Add(n2);
						} else if(F[n2]==0){
							T[n2] = a2;
							F[n2] = 1;
							listA.Add(n2);
						}
					}
				}
			}
		}
		if(S[N-1]==1){
			Console.WriteLine("-1");
		} else if(T[N-1]<=0){
			Console.WriteLine("0");
		} else {
			Console.WriteLine(T[N-1]);
		}
	}
}

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

int main(void){
    int n;
    
    cin >> n;
    
    vector<long long> h(n);
    
    rep(i, n){
        cin >> h.at(i);
    }
    
    int right = 0, mv_max = 0;
    
    for(int i = 1; i < n; i++){
        if(h.at(i-1) < h.at(i)){
            right = 0;
        } else {
            right++;
        }
        if(mv_max < right){
            mv_max = right;
        }
    }
    
    cout << mv_max << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)
int N, M;
vector<int> vec1, vec2;

class UnionFind 
{
    public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1)
    {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    void init(ll sz_) 
    {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) 
    { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) 
    {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) 
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() 
{
    cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b; a--; b--;
        vec1.push_back(a);
        vec2.push_back(b);
    }

    UnionFind G(N);
    int ans = 0;
    REP(i, M)
    {
        G.init(N);
        REP(j, M)
        {
            if(i == j) continue;
            G.merge(vec1[j], vec2[j]);
        }
        if(G.size(0) < N) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>

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

int calc( int i, int j, int H, int W, int K )
{
  int ret = 10000;
  ret = min( ret, i );
  ret = min( ret, j );
  ret = min( ret, H-1-i );
  ret = min( ret, W-1-j );
  return (ret + K - 1) / K;
}

int main( void )
{
  ios::sync_with_stdio(false);
  string S[801];
  int H, W, K;
  queue<P> q;
  int ret = 1000;
  cin >> H >> W >> K;
  for( int i=0; i<H; i++ ){
    cin >> S[i];
  }
  for( int i=0; i<H; i++ ){
    for( int j=0; j<W; j++ ){
      if( S[i][j] == 'S' ){
        q.push( P( i*1000+j, K ) );
        goto L1;
      }
    }
  }
L1:
  while( !q.empty() ){
    int px = q.front().first % 1000;
    int py = q.front().first / 1000;
    int cnt = q.front().second;
    q.pop();
    ret = min( ret, calc(py, px, H, W, K) );
    if( ret == 0 ) break;
    if( cnt > 0 ){
      if( px > 0   && S[py][px-1] == '.' ){ S[py][px-1] = 'S'; q.push( P(py*1000+px-1, cnt-1) );   }
      if( px < W-1 && S[py][px+1] == '.' ){ S[py][px+1] = 'S'; q.push( P(py*1000+px+1, cnt-1) );   }
      if( py > 0   && S[py-1][px] == '.' ){ S[py-1][px] = 'S'; q.push( P((py-1)*1000+px, cnt-1) ); }
      if( py < H-1 && S[py+1][px] == '.' ){ S[py+1][px] = 'S'; q.push( P((py+1)*1000+px, cnt-1) ); }
    }
  }
  cout << ret+1 << endl;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  
  vector<string> a(H);
  vector<bool> goodx(H,false);
  vector<bool> goody(W,false);
  
  for(int i=0;i<H;++i){
    cin>>a[i];
  }
  
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(a[i][j]=='#'){
        goodx[i]=true;
        goody[j]=true;
      }
    }
  }
  
  for(int i=0;i<H;++i){
    if(goodx[i]){
      for(int j=0;j<W;++j){
        if(goody[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
    
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int len=s.size();
    ll ans=0,p=1,now=0,cnt[2020]={0};
    cnt[0]=1;
    for(int i=len;i--;)
    {
        now=(now+ll(s[i]-'0')*p)%2019;
        ans+=cnt[now]++;
        p=p*10%2019;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3740
import math

N = int(input())
p = []
fac = math.factorial(N)
for _ in range(N):
    x, y = list(map(int, input().split()))
    p.append([x, y])

t = []
def dfs(a, b):
    if len(b) == N:
        return t.append(b)
    for i in range(len(a)):
        dfs(a[:i] + a[i+1:], b + [a[i]])
dfs(p, [])
total = 0
for i in range(len(t)):
    for j in range(len(t[i]) - 1):
        total += math.sqrt((t[i][j][0] - t[i][j+1][0]) ** 2 + (t[i][j][1] - t[i][j+1][1]) ** 2)
print(total / fac)

Measured memory_bytes: 9076
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
# 2019/04/06
# AtCoder Beginner Contest 123 - A

# Input
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

# Calc
if e - a > k:
    ans = ":("
else:
    ans = "Yay!"

# Output
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e6+4;
const int MAAX=2e9+5;
const int MOD=1e9+7;
int n;
int sz(int x)
{
    int ret=0;
    while(x)
        x/=10,ret++;
    return ret;
}
int fir(int x)
{
    while(x>9)
        x/=10;
    return x;
}
int last(int x)
{
    return x%10;
}
in main()
{
    cin>>n;
   int fr[10][10]={0},fr2[10]={0};
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    fr[fir(i)][last(i)]++;
  }
for(int i=0;i<=9;i++)
{
    for(int j=0;j<=9;j++)
    {

        ans+=fr[i][j]*(fr[j][i]);
    }
}
  cout<<ans<<endl;

    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int h, n;
	cin >> h >> n;
	int a[n], b[n];
	for(int i=0; i<n; i++) cin >> a[i] >> b[i];

	ll d[n][h+1];
	for(int j=0; j<=h; j++) d[0][j]=((j+a[0]-1)/a[0])*b[0];
	for(int i=1; i<n; i++){
		for(int j=0; j<=h; j++){
			d[i][j]=min(d[i-1][j], ((j+a[i]-1)/a[i])*(ll)b[i]);
			if(j>=a[i]) d[i][j]=min(d[i-1][j], d[i][j-a[i]]+b[i]);
		}
	}
	cout << d[n-1][h] << endl;
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  int a,b;
  vector<pair<int,int>> aaa(2*n);
  for(int i=0;i<n;i++){
    cin >> a >> b;
    aaa[2*i]={a,1};
    aaa[2*i+1]={b+1,-1};
  }
  sort(all(aaa));
  int ans=0;
  int total=0;
  for(int i=0;i<2*n-1;i++){
    total+=aaa[i].second;
    if(aaa[i].first!=aaa[i+1].first){
      ans=max(ans,total);
    }
  }
  total+=aaa[2*n-1].second;
  ans=max(ans,total);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4420
#include <iostream>

using namespace std;

long long pow5(long long x) {
  return x * x * x * x * x;
}

int main() {
  int X;
  cin >> X;
  for (long long A = 1; A <= 150; ++A) {
    for (long long B = 0; B < A; ++B) {
      if (pow5(A) + pow5(B) == X) {
        cout << A << " " << -B << endl;
        return 0;
      }
      if (pow5(A) - pow5(B) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

char s[1234567];
int n, k;
int main() {
	scanf("%s %d", s, &k);
	n = strlen(s);
	fo(i,0,n) {
		if (s[i]=='a') continue;
		int cst = 26 - (s[i]-'a');
		if (k >= cst) {
			s[i] = 'a';
			k -= cst;
		}
	}
	k %= 26;
	while (k) {
		if (s[n-1]=='z') s[n-1] = 'a';
		else s[n-1]++;
		k--;
	}
	puts(s);

	return 0;
}

Measured memory_bytes: 384
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

ll dp[100005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<((n*(n-1))/2);
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  string S, T;
  cin >> S >> T;
  if(S.at(0) == T.at(2) && S.at(1) == T.at(1) && S.at(2) == T.at(0)){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
ans=n
for i in range(n+1):
    cnt=0
    t=i #入力nをtとjに分けて考える(6の累乗分と9の累乗分への分割)
    while t>0:
        cnt+=t%6 #tを6で割ったあまり(=1円として引き出す分)
        t//=6 #tを6で割ったときの商に置き換える
    j=n-i
    while j>0: #9の場合も同じようにやる
        cnt+=j%9
        j//=9
    ans=min(ans,cnt)
    #n回1円で引き出すのと、6または9の累乗円を使って引き出すのとどっちが回数少ないか
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int BS(int *a,int *b,int mid,int n,int m);
int main(){
  int a[100000];
  int b[50000];
  int n,m,i,j,cnt,mid;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
if(n%2!=0){
  mid=(n+1)/2;
}
else{
  mid=(0+n)/2;
}
  /*printf("%d\n",mid);*/
  cnt=BS(a,b,mid,n,m);

  printf("%d\n",cnt);
  return 0;
}


int BS(int *a,int *b,int mid,int n,int m){
  int cnt=0,i,j;
  for(i=0;i<m;i++){
    if(b[i]==a[mid]){
      cnt++;
    }
    else if(b[i]<a[mid]){
      for(j=mid-1;j>=0;j--){
        if(a[j]==b[i]){
          cnt++;
          break;
        }
      }
    }

    else if(b[i]>a[mid]){
      for(j=mid+1;j<n;j++){
        if(a[j]==b[i]){
          cnt++;
          break;

        }
      }
    }

  }
  return cnt;
}

Measured memory_bytes: 1184
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        m: i32,
        a: [i32; m]
    }

    let days: i32 = a.iter().sum();
    if days <= n {
        println!("{}", n - days);
    } else {
        println!("-1");
    }

}


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

using namespace std;

int n;
int c[200010];
vector<int> g[200010];
int dep[200010];
int fa[200010][20];
int sz[200010];
long long ans[200010];
vector<int> stck[200010];

inline void dfs(int x){
	for(int i=1;i<20;i++)
		fa[x][i] = fa[fa[x][i-1]][i-1];

	sz[x] = 1;
	for(auto ch: g[x])
		if(ch != fa[x][0]) {
			dep[ch] = dep[x] + 1;
			fa[ch][0] = x;
			dfs(ch);
			sz[x] += sz[ch];
		}
}

inline void swim(int&x,int h){
	for(int i=0;h>0;i++){
		if(h&1)x=fa[x][i];
		h>>=1;
	}
}

int N;
inline void dfs1(int x){
	for(auto ch: g[x]){
		if(ch!=fa[x][0]) {
			dfs1(ch);

			int num = sz[ch];
			while(!stck[c[x]].empty()) {
				int temp = *stck[c[x]].rbegin();
				swim(temp, dep[temp] - dep[x]);
				if(temp == x){
					temp = *stck[c[x]].rbegin();
					num -= sz[temp];
					stck[c[x]].pop_back();
				}else{
					break;
				}
			}
			ans[c[x]] -= (long long)num*(num+1)/2LL;
		}
	}
	stck[c[x]].push_back(x);
}

int main(){
	//freopen("f.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",c+i);
	}
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	fa[1][0]=1;
	dep[1] = 1;
	dfs(1);

	for(int i=1;i<=n;i++){
		ans[i] = (long long) n*(n+1)/2LL;
	}
	dfs1(1);

	for(int i=1;i<=n;i++){
		if(i == c[1])continue;

		int num = n;
		while(!stck[i].empty()) {
			int temp = *stck[i].rbegin();
			num -= sz[temp];
			stck[i].pop_back();
		}

		ans[i] -= (long long)num * (num+1)/2LL;
	}

	for(int i=1;i<=n;i++){
		printf("%lld\n",ans[i]);
	}

	return 0;
}

Measured memory_bytes: 61540
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int min = list.stream().min(Comparator.naturalOrder()).get();
	
		System.out.println(max - min);
	}
}


Measured memory_bytes: 30804
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

const int MOD=1e9+7;
void solve() {
    cini(n);
    cinai(a,n);

    vi pre(n+1);
    for(int i=1; i<=n; i++) 
        pre[i]=pre[i-1]+a[i-1];

    int ans=0;
    for(int i=0; i<n; i++) {
        int sum=(pre[n]-pre[i+1])%MOD;
        int prod=(a[i]*sum)%MOD;
        ans=(ans+prod)%MOD;
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 6360
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

class Main {
//    static int[] primes;
//    static List<Integer> primeList;
//    static {
//        int length = (int) Math.sqrt(500000000) + 1;
//        primes = new int[length];
//        int max = (int) Math.sqrt(length) + 1;
//        for (int i = 2; i < max; i++) {
//            if (primes[i] == 1) {
//                continue;
//            }
//            int cur = i * i;
//            while (cur < length) {
//                primes[cur] = 1;
//                cur += i;
//            }
//        }
//
//        primeList = new ArrayList<>();
//        for (int i = 2; i < length; i++) {
//            if (primes[i] == 0) {
//                primeList.add(i);
//            }
//        }
//    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int K = in.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }

        int sum = 0;
        for (int a : A) {
            sum += a;
        }

        SortedSet<Integer> factors = new TreeSet<>(Comparator.reverseOrder());
        int max = (int) Math.sqrt(sum);
        for (int i = 1; i <= max; i++) {
            if (sum % i == 0) {
                factors.add(i);
                factors.add(sum / i);
            }
        }
        boolean hasResult = false;
        for (int i : factors) {
            if (helper(i, K, A)) {
                System.out.println(i);
                hasResult = true;
                break;
            }
        }
        if (!hasResult) {
            System.out.println(1);
        }
    }

    private static boolean helper(int i, int k, int[] A) {
        PriorityQueue<Integer> q1 = new PriorityQueue<>(Comparator.reverseOrder()), q2 = new PriorityQueue<>();
        int sum = 0;
        for (int j = 1; j < A.length; j++) {
            int e = A[j] % i;
            q1.add(e);
            sum += e;
        }

        q2.add(-sum);
        while (q1.peek() - q2.peek() > i || (q1.peek() - q2.peek() == i && q1.peek() - i > q2.peek())) {
            int x = q1.poll();
            int y = q2.poll();
            q2.add(x - i);
            if (y + i < 0) {
                q2.add(y + i);
            } else {
                q1.add(y + i);
            }
        }

        return q1.stream().mapToInt(Integer::intValue).sum() <= k;
    }
}

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

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

        String line;

        while(!((line = br.readLine()).equals("0"))){
            int n = Integer.parseInt(line);
            String[] input = br.readLine().split(" ");
            int[] data = new int[n];

            double sum = 0;
            double squaresum = 0;
            double average;

            for(int i = 0; i < n; i++){
                data[i] = Integer.parseInt(input[i]);
                sum += data[i];
            }

            average = sum/n;

            for(int i = 0; i < n; i++){
                squaresum += Math.pow(data[i]-average , 2);
            }

            double variance = squaresum / n;

            System.out.println(Math.sqrt(variance));
        }
    }
}

Measured memory_bytes: 24996
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int l=s.size();
    for(int i=0; i<l; i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1; j<l; j++)
            if(s[j]=='F')
            {cout<<"Yes";
            return 0;}
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    map<string,int> m;
    string s;
    ll k;
    cin >> s >> k;
    const ll n = s.length();
    for(ll i = 0;i < n;i++){
        for(ll j = 1;j <= n;j++){
            ll len = j;
            if(i + j > n)len = s.length() -1;
            if(len > k)continue;
            m[s.substr(i,len)]++;
        }
    }
    ll cnt = 1;
    for(auto a : m){
        if(cnt == k){
            cout << a.first << "\n";
            return 0;
        }else cnt++;
    }
    return 0;
}

Measured memory_bytes: 4780
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }

    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < M; i++) {
        if (A[i] < X) {
            ans1++;
        }
        else if (A[i] > X) {
            ans2++;
        }
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
int main(){
    ll n,k;cin >> n >> k;
    vl v(n);rep(i,n)cin >> v[i];
    ll now=0,next=k-1;
    rep(i,n-k){
        next++;
        if(v[next]>v[now])cout << "Yes" <<endl;
        else cout << "No" <<endl;
        now++;
    }
} 

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


public class A
{
  
    public static void Main(string[] args)
    {
        int t = 1;
        while (t > 0)
        {
            var arr = Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
            if(arr.Sum() >= 22)
            {
                Console.WriteLine("bust");
            } else
            {
                Console.WriteLine("win");
            } 
            t--;
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int h; cin >> h;
  int n ; cin >> n;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x; h -= x;
  }
  cout << (h > 0 ? "No" : "Yes");
}


Measured memory_bytes: 384
import re
import sys
from fractions import gcd
from functools import reduce
from itertools import product

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B, T = il()
    ans = (T + 0.5) // A * B
    return int(ans)


if __name__ == "__main__":
    print(solve())


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ull a, b, c, k;
  cin >> a >> b >> c >> k;

  ll max = 0;
  if (a <= k) {
    max += a;
  } else {
    max += k;
    cout << max;
    return 0;
  }
  k -= a;

  if (b <= k) {
    // do nothing
  } else {
    cout << max;
    return 0;
  }
  k -= b;

  if (c <= k) {
    max -= c;
  } else {
    max -= k;
  }

  cout << max;
}

Measured memory_bytes: 3636