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

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  std::map<int, int> factors;
  for (int i = 2; i <= N; ++i)
  {
    int x = i;

    for (int p = 2; p*p <= i; ++p)
    {
      while ((x % p) == 0)
      {
        factors[p]++;
        x /= p;
      }
    }

    if (x != 1)
    {
      factors[x]++;
    }
  }

  int res = 0;
  for (int i = 2; i <= N; ++i)
  {
    if (!factors.count(i) || factors[i] < 2) continue;
    if (factors[i] >= 74) ++res;

    for (int j = i + 1; j <= N; ++j)
    {
      if (!factors.count(j) || factors[j] < 2) continue;

      if (factors[i] >= 24) ++res;
      if (factors[j] >= 24) ++res;

      if (factors[i] >= 4 && factors[j] >= 14) ++res;
      if (factors[j] >= 4 && factors[i] >= 14) ++res;

      for (int k = j + 1; k <= N; ++k)
      {
        if (!factors.count(k) || factors[k] < 2) continue;
        int cnt = (factors[i] >= 4 ? 1 : 0) + (factors[j] >= 4 ? 1 : 0) + (factors[k] >= 4 ? 1 : 0);
        if (cnt >= 2) ++res;
        if (cnt == 3) res += 2;
      }
    }
  }

  cout << res << "\n";

  return 0;
}


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

int mul[101];

int main()
{
    int n; std::cin >> n;
    for (int i = 1; i <= 9; ++i)
        for (int j = 1; j <= 9; ++j)
            mul[i * j] = 1;
    std::cout << (mul[n] ? "Yes" : "No");
}

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

int main()
{
  int64_t x;
  cin >> x;
  for (int64_t a = -1000; a <= 1000; a++) {
    for (int64_t b = -1000; b <= 1000; b++) {
      if ((a * a * a * a * a) - (b * b * b * b * b) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int r,c,i,j,sum;
	int data[101][101];
	
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&data[i][j]);
		}
	}
	
	for(i=0;i<r;i++){
		sum=0;
		for(j=0;j<c;j++){
			sum+=data[i][j];
		}
		data[i][c]=sum;
	}
	for(i=0;i<=c;i++){
		sum=0;
		for(j=0;j<r;j++){
			sum+=data[j][i];
		}
		data[r][i]=sum;
	}
	
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			if(j) printf(" ");
			printf("%d",data[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2036
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
    Date:12/06/2020
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
// ll mod=1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

const int N=3e3+5;
ss s,t;
int n1,n2;
int cache[N][N];
int dp(int idx1,int idx2)
{
    if(idx1==n1 or idx2==n2)
    return 0;
    int &ans=cache[idx1][idx2];
    if(ans!=-1)
    return ans;
    if(s[idx1]==t[idx2])
    ans=dp(idx1+1,idx2+1)+1;
    else
    ans=max({dp(idx1,idx2+1),dp(idx1+1,idx2)});
    return ans;
}
ss s1="";
void dp1(int idx1,int idx2)
{
    if (idx1==n1 or idx2==n2)
    return;
    int ans=cache[idx1][idx2];
    if(s[idx1]==t[idx2])
    {
        s1+=s[idx1];
        return dp1(idx1+1,idx2+1);
    }
    if(ans==cache[idx1+1][idx2])
    return dp1(idx1+1,idx2);
    return dp1(idx1,idx2+1);
}


bool test=0;
void solve()
{
    cin>>s>>t;
    n1=s.size();
    n2=t.size();
    memset(cache,-1,sizeof(cache));
    dp(0,0);
    dp1(0,0);
    cout<<s1;
}







signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin.exceptions(cin.failbit);
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// 	#endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		mp[x]++;
	}
	while(m--){
		if(mp.empty())break;
		int val = (mp.rbegin()->first);
		mp[val]--;
		if(mp[val] == 0)mp.erase(val);
		mp[val/2]++;
	}
	ll ans = 0;
	for(auto x : mp){
		ans += x.first*1LL*x.second;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
from math import gcd
from functools import reduce
from collections import defaultdict


def read():
    N = int(input().strip())
    XY = []
    for i in range(N):
        x, y = map(int, input().strip().split())
        XY.append((x, y))
    return N, XY


def solve(N, XY):
    ans = []
    XY.sort(key=lambda a: a[0] + a[1])
    x0, y0 = XY[0]
    x1, y1 = XY[-1]
    ans.append(abs(x1-x0) + abs(y1-y0))
    XY.sort(key=lambda a: a[1] - a[0])
    x0, y0 = XY[0]
    x1, y1 = XY[-1]
    ans.append(abs(x1-x0) + abs(y1-y0))
    return max(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 45828
using Kujikatsu003.Questions;
using Kujikatsu003.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Kujikatsu003.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/agc029/tasks/agc029_a
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            var blackCount = 0;
            long sum = 0;

            foreach (var c in s)
            {
                if (c == 'B')
                {
                    blackCount++;
                }
                else
                {
                    sum += blackCount;
                }
            }

            yield return sum;
        }
    }
}

namespace Kujikatsu003
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu003.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu003.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11744
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b;
    cin >> a >> b;
    if ( a % 2 == 0 || b % 2 == 0 ) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main(){
	int N=0,Q=0;
	int M=0,date[100];
	int ans=0;
	int day=0;

	while(1){
		for(int i=0;i<100;i++){
		date[i] = 0;
		}
		cin >> N >> Q;
		if(N==0&&Q==0) break;

		for(int i=0;i<N;i++){
			cin >> M;
			for(int j=0;j<M;j++){
				cin >> day;
				date[day] = date[day] + 1;
			}

		}

		int maxi=0;
		for(int i=1;i<100;i++){
			if(date[i] > date[maxi]){
				maxi =i;
			}
		}

		if(Q<=date[maxi]){ 
			cout << maxi << endl;
		}else{
			cout << 0 << endl;
		}

	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;


long long int a,b,c[200010],d[200010],ans =1,ant=1;

int main(){
  cin >> a ;
  
  for(int i=0;i<a;i++)
    cin >> c[i];
  
  if(a%2 ==0){
    
    for(int i=0;i<a;i++){
      if(i%2 ==0){
         d[(a+i)/2] = c[i];
      }
      else{
         d[(a-i)/2] = c[i];
      }
    }
    
  }
  
  else{
    
    for(int i=0;i<a;i++){
      if(i%2 == 0){
        d[(a-i)/2] = c[i];
                      
      }
      
      else{
         d[(a+i)/2] = c[i];
      }
    }
  }
  for(int i=0;i<a;i++)
  cout << d[i] <<" ";
  
  cout << endl;
}
      
      
 
   


Measured memory_bytes: 5248
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    vector<ll> sum(n + 1);
    rep(i,n)sum[i+1] = sum[i] + a[i];
    rep(i,n)sum[i+1] %= k;
    ll ans = 0;
    map<ll, ll> mp;
    rep(i,n+1){
        if(i >= k)mp[((sum[i-k] - (i - k)) % k + k) % k]--;
        ans += mp[((sum[i] - i) % k + k) % k]++;
        
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG

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

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

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;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi;
    vec<int> nums = gim(n);
    vec<int> dp {0};
    AToB(i, 1, n-1) {
        if (i == 1) {
            dp.add(abs(nums[1]-nums[0]));
        } else {
            int newV = min(
                    abs(nums[i]-nums[i-1]) + dp[i-1],
                    abs(nums[i]-nums[i-2]) + dp[i-2]
                    );
            dp.add(newV);
        }
    }
    print(dp[n-1]);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 1276
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)
var infty = 1000000000 * 2

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func mergeSort(s []int, left, right int) int {
	if left+1 >= right {
		return 0
	}
	mid := (left + right) / 2
	nCompareLeft := mergeSort(s, left, mid)
	nCompareRight := mergeSort(s, mid, right)
	nCompareMerge := merge(s, left, mid, right)

	return nCompareLeft + nCompareRight + nCompareMerge
}

func merge(s []int, left, mid, right int) int {
	nLeft := mid - left
	nRight := right - mid
	pLeft := make([]int, nLeft+1)
	pRight := make([]int, nRight+1)

	for i := 0; i < nLeft; i++ {
		pLeft[i] = s[left+i]
	}
	for i := 0; i < nRight; i++ {
		pRight[i] = s[mid+i]
	}

	// fmt.Println(pLeft, pRight)

	pLeft[nLeft] = infty
	pRight[nRight] = infty

	i := 0
	j := 0
	for k := left; k < right; k++ {
		if pLeft[i] <= pRight[j] {
			s[k] = pLeft[i]
			i++
		} else {
			s[k] = pRight[j]
			j++
		}
	}

	// fmt.Println(s)
	return right - left
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := nextInt()
	s := make([]int, n)
	for i := range s {
		var err error
		s[i], err = nextInt()
		if err != nil {
			fmt.Println(err)
			return
		}
	}

	//	fmt.Println(s)
	nCompare := mergeSort(s, 0, n)
	fmt.Println(stringifyArray(s))
	fmt.Println(nCompare)
}



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

namespace D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            long[] ab = RLongAr();
            long a = ab[0];
            long b = ab[1];

            if (a == b)
            {
                Console.WriteLine(a);
            }
            else
            {
                long res;
                if (a == 0)
                {
                    res = f(b);
                }
                else
                {
                    res = f(a - 1) ^ f(b);
                }

                Console.WriteLine(res);
            }

        }

        private static long f(long x)
        {

            if (x % 2 == 1)
            {
                return (((x + 1) / 2) % 2 == 0 ? 0 : 1);
            }
            else
            {
                return ((x / 2) % 2 == 0 ? 0 : 1) ^ x;
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 11220
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	char num[200001];
	scanf("%s",num);
	int i=0;
	int sum=0;
	while(num[i]!='\0'){
		int d = num[i]-'0';
	    sum+=d;
		i=i+1;
	}
	if(sum%9==0){
		printf("Yes");
	}
	else{
		printf("No");
	}
}

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

int n;
int h[100100];
int ans = 0, maxx = -1;

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)	h[i] = read();
	for(int i = 1; i < n; ++i) {
		if(h[i] >= h[i + 1])	ans++;
		else	maxx = max(maxx, ans), ans = 0;
	}
	maxx = max(maxx, ans);
	printf("%d\n", maxx);
	return 0;
}


Measured memory_bytes: 640
# coding: utf-8
import sys
from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as np
#import queue# queue,get(), queue.put()
def run():
    N = int(input())
    current = 0
    ways = []
    dic = {'(': 1, ')': -1}
    SS = read().split()

    for S in SS:
        path = [0]
        for s in S:
            path.append(path[-1]+ dic[s])
        ways.append((path[-1], min(path)))

    ways_pos = sorted([(a,b) for a,b in ways if a >= 0], key = lambda x:(x[1], x[0]), reverse=True)
    ways_neg = sorted([(a,b) for a,b in ways if a < 0], key = lambda x:(x[1] - x[0], -x[0]), reverse=True)[::-1]

    for go, max_depth in ways_pos:
        if current + max_depth >= 0:
            current += go
        else:
            print("No")
            return None

    for go, max_depth in ways_neg:
        if current + max_depth >= 0:
            current += go
        else:
            print("No")
            return None

    if current == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    run()

Measured memory_bytes: 198968
#include<bits/stdc++.h>
using namespace std;
typedef vector<double> vec;
typedef vector<vec> mat;
const double eps = 1e-8;
const double INF = 1e20;
 
bool gauss_jordan(const mat &A, const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      B[i][j]=A[i][j];
    }
  }
  for(int i=0;i<n;i++)B[i][n]=b[i];
 
   
 
 
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    }
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<eps)continue;
     
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j){
    for(int k=i+1;k<=n;k++){
      B[j][k]-=B[j][i]*B[i][k];
    }
      }
    }
  }
 
  if( abs(B[n-1][n]) < 1e-3)return true;
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      cout<<B[i][j]<<' ';
    }
    cout<<endl;
  }
 
   
  for(int i=0;i<n;i++){
    cout<<B[i][n]<<' ';
  }
  cout<<endl;
  cout<<endl;
  */
  for(int i=0;i<n;i++){
    if(abs(B[i][i])<eps){
      // if(abs(B[i][n])>eps)return true;
    }
  }
   
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      cout<<B[i][j]<<' ';
    }
    cout<<endl;
  }
  cout<<endl;
   
  vec x(n);
  for(int i=0;i<n;i++){
    x[i]=B[i][n];
  }
  */
  return false;//  return x;
}
 
int n;
double t[10];
 
bool check(int x){
  mat A(n+2,vec(n+2));
  vec b(n+2);
   
 
  int c1=0;
  for(int i=0;i<n+3;i++){
    if(x==i)continue;
    for(int j=0;j<n+2;j++){
      A[c1][j]=pow(i,j);
      if(j==n+1)A[c1][j]=0;
    }
    b[c1]=t[i];
    c1++;
    if(c1==n+2)break;
  }
  /*
  for(int i=0;i<A.size();i++){
    for(int j=0;j<A[i].size();j++){
      cout<<A[i][j]<<' ';
    }
    cout<<b[i]<<endl;
  }
  cout<<endl;
  */
  if( gauss_jordan(A,b))return true;
 
  return false;
}
 
void solve(){
  for(int i=0;i<n+3;i++){
    if(check(i)){
      cout<<i<<endl;
      return;
    }
  }
}
 
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n+3;i++)cin>>t[i];
    solve();
  }
  return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = 0;
    if(n==1){cout << 1 << endl; return 0;}
    for(int i = 0; i < n; i++){
        if(s[i] != s[i+1]){ans++;}
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, C;
    scanf("%d%d%d", &a, &b, &C);
	int deg;
	double rad;
	double PI = acos(-1);  
	rad = C * PI / 180;
    double S, L, h;
    S = (double)(a * b * sin(rad) / 2);
    double c = sqrt(pow(a, 2) - 2*a*b*cos(rad) + pow(b, 2));
    L = (double)(a + b + c);
    h = (double)(2 * S / a);
    printf("%lf\n%lf\n%lf\n", S, L, h);

    return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, M;
    cin >> N >> M;

    vector<int> ans;
    ans.resize(N,-1);

    bool ok = 0;
    int minn = INF32;

    rep(i,M){
      int s, c;
      cin >> s >> c;
      s--;
      minn = min(minn,s);
      if(ans[s]==-1) ans[s] = c;
      else{
        if(ans[s]!=c) ok = 1;
      }
    }

    // -1 -> 0 
    rep(i,N){
      if(ans[i]==-1) ans[i]=0;
    }

    if(N>1){
      if(minn!=0) ans[0] = 1;
      else if(ans[minn]==0) ok = 1;
    }

    if(ok) cout << -1 << endl;
    else{
      rep(i,N) cout << ans[i];
      cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll N, M;
	cin >> N >> M;
	if(N == 1 && M == 1){
		cout << 1 << endl;
	}
	else if (N == 1) {
		cout << M - 2 << endl;
	}
	else if (M == 1) {
		cout << N - 2 << endl;
	}
	else  {
		cout << (N - 2)*(M - 2) << endl;
	}


	
	return 0;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(N):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])


Measured memory_bytes: 52336
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(void){
    int H, N;
    cin >> H >> N;
    vector<int> dp(H + 1, INF);
    dp[0] = 0; 
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        for(int j = 0; j < H; j++){
            int nj = min(j + A, H);
            dp[nj] = min(dp[nj], dp[j] + B);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,fst[N],to[N*2],nxt[N*2],l,fa[N],b[N],Ans;
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
}
void dfs(int x)
{
	int tmp=0,s=0;
	for (int i=fst[x];i;i=nxt[i])
	if (to[i]!=fa[x])
	{
		fa[to[i]]=x;
		dfs(to[i]);
		s|=tmp&b[to[i]];
		tmp|=b[to[i]];
	}
	int t=0;
	while(((1<<t<s))||((1<<t)&tmp))t++;
	//cout<<t<<endl;
	b[x]=tmp^(1<<t)^(tmp&((1<<t)-1));
	Ans=max(Ans,t);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	dfs(1);
	/*int ans=0;
	while(Ans>1)Ans>>=1,ans++;*/
	printf("%d\n",Ans);
} 

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

int main()
{
	vector<int> v(5);
	for (auto& i : v) {
		cin >> i;
	}

	int k;
	cin >> k;

	bool yes = true;
	for (auto& i : v) {
		for (auto& j : v) {
			if (k < abs(i - j)) {
				yes = false;
			}
		}
	}

	if (yes) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}


	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	ll N, T;
	cin >> N >> T;
	ll t1, t_st=0;
	ll sum=0;
	ll stock = 0;
	ll t_stock = 0;
	rep(i, N) {
			cin >> t1;
			if (T > t1 - t_st) {
				sum += t1 - t_st;
			}
			else {
				sum += T;
			}
		t_st = t1;
	}
	cout << sum+T << endl;
	return 0;

}

Measured memory_bytes: 256
using System;
using System.Linq;


public class Test
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		if(n >= 64) {
            Console.WriteLine("64");
        }
        else if(n >= 32 && n <64){
             Console.WriteLine("32");
        }
        else if(n >= 16 && n <32){
             Console.WriteLine("16");
        }
        else if(n >= 8 && n < 16){
             Console.WriteLine("8");
        }
        else if(n >= 4 && n < 8){
             Console.WriteLine("4");
        }
        else if(n >= 2 && n < 4){
             Console.WriteLine("2");
        } else {
             Console.WriteLine("1");
        }
    }


}

Measured memory_bytes: 13140
#include<stdio.h>
int main(void){
	int n,i;
	long long ans=0;
	int a[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++){
		if(a[i+1]<a[i]){
			ans+=a[i]-a[i+1];
			a[i+1]=a[i];
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2452
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const int INF = pow(2,29);
const int MOD = 1000000007;
const int N_MAX = 50;
const int C_MAX = 10 * N_MAX;

int a[N_MAX], b[N_MAX], c[N_MAX];
vector<vector<vector<int>>> dp(N_MAX+1, vector<vector<int>>(C_MAX+1, vector<int>(C_MAX+1, -1)));

int dfs(int n, int x, int y) {
  // cout << n << x << y << endl;
  if (dp[n][x][y]!=-1) return dp[n][x][y];
  if (n==0) {
    if (x==0&y==0) return dp[n][x][y] = 0;
    else return dp[n][x][y] = INF;
  }
  int result = 0;
  if (x<a[n-1]||y<b[n-1]) return dp[n][x][y] = dfs(n-1, x, y);
  else result = min(dfs(n-1, x, y), dfs(n-1, x-a[n-1], y-b[n-1])+c[n-1]);
  return dp[n][x][y] = result;
}

int main() {
  int N, ma, mb; cin >> N >> ma >> mb;
  rep(i, N) cin >> a[i] >> b[i] >> c[i];
  int result = INF;
  for(int i=1; i*max(ma, mb)<=N*10; i++) {
    int tmp = dfs(N, i*ma, i*mb);
    if (tmp>=0) result = min(result, tmp);
  }

  // cout << dfs(3,1,2) << endl;
  if (result==INF) result=-1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 52096
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s;
    cin >> s;
    REP(i,s.size()) cout << "x";

    return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブScanner scan = new Scanner(System.in);

        Scanner scan = new Scanner(System.in);

        // 入力値の個数
        int n = scan.nextInt();

        // カウント
        int count = 0;

        boolean flag = true;

        // 入力値のリスト
        ArrayList<Integer> list = new ArrayList();

        for(int i = 0; i < n; i++) {
        	list.add(scan.nextInt());
        }

        // 入力された値を表示
        for(int i = 0; i < list.size(); i++) {

        	// 値が奇数ならフラグflase
        	if((int)list.get(i)%2 != 0) {
        		flag = false;
        	}

        	//System.out.println("listの"+ i + "番目 => " + list.get(i));
        }


        while(flag) {
        	for(int i = 0; i < list.size(); i++) {


            	list.set(i, (int)list.get(i)/2);
            	//System.out.println("listの"+ i + "番目 => " + list.get(i));
            	if((int)list.get(i)%2 != 0) {
            		flag = false;
            	}


            }
        	count++;
        }

        System.out.println(count);
	}

}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

struct UnionFind
{
    std::vector<int> nodes;

    explicit UnionFind(int n)
    {
        nodes = std::vector<int>(n, -1);
    }

    int getRoot(int x)
    {
        if (nodes[x] < 0)
            return x;
        return nodes[x] = getRoot(nodes[x]);
    }

    void unite(int x, int y)
    {
        x = getRoot(x), y = getRoot(y);
        if (x == y)
            return;
        if (nodes[x] > nodes[y])
            std::swap(x, y);
        nodes[x] += nodes[y];
        nodes[y] = x;
    }
};

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

    int n, m;
    cin >> n >> m;
    auto uf = UnionFind(n);
    int a, b;
    REP(_, 0, m)
    {
        cin >> a >> b;
        uf.unite(a - 1, b - 1);
    }

    int ans = 0;
    REP(i, 0, n)
    ans = max(ans, -uf.nodes[uf.getRoot(i)]);
    cout << ans << endl;
}

Measured memory_bytes: 3988
N=int(input())
s=list(map(int,input().split(" ")))
r=1
before=None
if N<=2:
  pass
else:
  flag=None
  for i,z in enumerate(s):
    if flag==None:
      if before == None:
        before=z
      if before<z:
        flag=True
        before=z
      elif before>z:
        flag=False
        before=z
    elif flag==True:
      if z<before:
        flag=None
        before=z
        r+=1
      else:
        before=z
    else:
      if z>before:
        flag=None
        before=z
        r+=1
      else:
        before=z

print(r)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
   cin>>a[i];
  sort(a,a+n,greater<long long int>());
  long long int sum=0;
  sum+=a[0];
  int k=n-2;
  for(int i=1;i<n;i++)
   {
   	    if(k==0)break;
    if(k==1) {sum+=a[i];break;}
    sum+=2*a[i];
    k-=2;

   
   }
  cout<<sum<<endl;
  return 0;
} 

Measured memory_bytes: 5108
#include "stdio.h"

char A[20];
char B[20];
char C[20];
int aLast;
int bLast;

int main() {
	scanf("%s", A);
	scanf("%s", B);
	scanf("%s", C);
	for (int i = 0; i < 20; i++) {
		if (A[i] == NULL && A[i-1]!=NULL) {
			aLast = i-1;
			break;
		}
	}
	for (int i = 0; i < 20; i++) {
		if (B[i] == NULL && B[i - 1] != NULL) {
			bLast = i-1;
			break;
		}
	}
	if (A[aLast]==B[0] && B[bLast]==C[0]) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}

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

int main() {
  int A, B, cnt, a, b, c, d, e;
  cin >> A >> B;
  cnt = 0;
  
  for (int i = A; i < B + 1; i++) {
    a = i / 10000;
    b = (i % 10000) / 1000;
    c = (i % 1000) / 100;
    d = (i % 100) / 10;
    e = i % 10;
    
    if (a == e && b == d) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);

    bool A=false,B=false,C=false,D=false;

    if(b-a<=k && c-a<=k && d-a<=k && e-a<=k)
        A=true;
    if(c-b<=k && d-b<=k && e-b<=k)
        B=true;
    if(d-c<=k && e-c<=k)
        C=true;
    if(e-d<=k)
        D=true;

    if(A&&B&&C&&D)
        printf("Yay!");
    else
        printf(":(");
}



Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 12, mod = 998244353;
const long long INF = 1000000000000000000ll;

int T[maxN];
long long dp[maxN][maxN];

void solve()
{
	int n, s;
	scanf ("%d%d", &n, &s);
	FOR(i, 1, n+1)
		scanf ("%d", T+i);
	dp[0][0] = 1ll;
	FOR(i, 1, n+1) FOR(v, 0, s+1)
	{
		dp[i][v] = dp[i-1][v] * 2 % mod;
		if (T[i] <= v)
			dp[i][v] = (dp[i][v] + dp[i-1][v - T[i]]) % mod;
	}
	
	printf("%lld\n", dp[n][s]);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 75836
import sys
n=10**6
s=[True]*n
s[0]=False
s[1]=False
for x in xrange(2, int(n**0.5)+1):
    if s[x]:
        for i in xrange(x+x,n,x):
            s[i]=False
for x in sys.stdin.readlines():
    x=int(x)+1
    cnt=0
    for i in xrange(x):
        if s[i]:
            cnt=cnt+1
    print cnt

Measured memory_bytes: 12104
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, k;
	cin>>n>>m>>k;
    int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	x1--;
	y1--;
	x2--;
	y2--;
	char grid[n][m];
	int dist[n][m];
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin>>grid[i][j];
			dist[i][j] = INT_MAX;
		}
	}
 
    int d[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};
	queue<pair<int, int> > q;
	dist[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		for (int i=0; i<4; i++) {
			int nx = x;
			int ny = y;
			int nd = dist[x][y]+1;
			for (int j=1; j<=k; j++) {
				nx += d[i][0];
				ny += d[i][1];
 
				if (nx<0 || nx>=n || ny<0 || ny>=m || grid[nx][ny]=='@' || dist[nx][ny]<nd) {
					break;
				}
				if (dist[nx][ny]>nd) {
					dist[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dist[x2][y2];
	cout<<(INT_MAX==ans ? -1 : ans)<<endl;
	return 0;
}
 

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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int s = 0;
    int max_price = 0;
    for(int i = 0; i < n; i++){
        int p;
        scanf("%d", &p);
        if(p > max_price){
            max_price = p;
        }
        s += p;
    }
    s -= max_price/2;
    printf("%d\n", s);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        // int n = 200000;
        // int k = 200000;
        
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // int[] array = new int[n];
        // array[0] = 1;
        
        int de = 0;
        while (k-- > 0) {
            int[] start = new int[n];
            int[] end = new int[n];
            for(int i = 0; i < n; i++) {
                start[i] = Math.max(0, i-array[i]);
                end[i] = Math.min(n-1, i+array[i]);
            }
            
            // imos法: 累積和の区間版
            // sum[i]: 時刻iで放送中の番組数
            int[] sum = new int[n+1];
            for (int i = 0; i < n; i++) {
                // 時刻start[i]で放送番組が1増える
                // 時刻end[i]+1で放送番組が1減る
                sum[start[i]]++;
                sum[end[i] + 1]--;
            }
            for (int i = 0; i < n; i++) {
                sum[i + 1] += sum[i];
            }
            
            long tmp = 0;
            for (int i = 0; i < n; i++) {
                array[i] = sum[i];
                tmp += array[i];
            }
            
            long aa = (long)n;
            
            if (tmp == aa * n) {
                for (int i = 0; i < n; i++) {
                    System.out.print(array[i]);
                    if (i != n - 1) {
                        System.out.print(" ");
                    } else {
                        System.out.println();
                    }
                }
                // System.out.println(k);
                return;
            }
            
            // System.out.println(Arrays.toString(sum));
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(array[i]);
            if (i != n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 63204
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

// http://tubo28.me/algorithm/manacher/
std::vector<int> manacher(const std::string &s) {
		int n = s.size();
		std::vector<int> rad(n);
		int c = 0;
		for (int r = 0; r < n; ++r) {
				int l = c - (r - c);
				if (r + rad[l] < c + rad[c]) {
						rad[r] = rad[l];
				} else {
						int rr = c + rad[c];
						int rl = r - (rr - r);
						while (rl >= 0 && rr < n && s[rl] == s[rr]) ++rr, --rl;
						rad[r] = rr - r;
						c = r;
				}
		}
		return rad;
}

std::string insert_dollar(const std::string &s) {
		int n = s.size();
		std::string res(n * 2 + 1, '$');
		for (int i = 0; i < n; ++i) {
				res[i * 2 + 1] = s[i];
		}
		return res;
}

bool is_palindrome(int l, int r, const std::vector<int> &rad) {
		l = l * 2 + 1;
		r = (r - 1) * 2 + 1;
		int c = (l + r) / 2;
		return r < c + rad[c];
}

int count_even_parindrome(int k, const std::vector<int> &rad) { return (rad[2 * k + 2] - 1) / 2; }

int count_odd_parindrome(int k, const std::vector<int> &rad) { return (rad[2 * k + 1] + 1) / 2; }

int main(){

	string s;
	cin>>s;

	long long z[26]={};
	for(int i=0;i<s.size();i++) z[s[i]-'a']++;

	long long n=s.size();
	long long cnt=(1+n)*n/2;
	for(int c=0;c<26;c++) cnt-=(1+z[c])*z[c]/2;

	long long res=cnt+1;
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    if(a==b && a!=c) printf("Yes\n");
    if(b==c && b!=a) printf("Yes\n");
    if(a==c && a!=b) printf("Yes\n");
    if(a!=b && a!=c && b!=c) printf("No\n");
    if(a==b && b==c) printf("No\n");
    return 0;
}


Measured memory_bytes: 128
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n):
  check = c
  for j in range(m):
    check += b[j]*a[i][j]
    if j == m-1:
      if check > 0:
        count += 1
      else:
        pass
print(count)

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  
  int num =100*r+10*g+b;
  if(num%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3596
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y+=[c];X+=[a,b]
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X+=[a];Y+=[b,c]
def g(X):s=dict(enumerate(sorted(set(X))));return s,len(s),{s[i]:i for i in s}
s,K,h=g(X);t,L,w=g(Y);V=[[0]*(K+2)for i in r(L+2)];U=[i[:]for i in V];v=[i[:]for i in V]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L+1):
 for j in r(K+1):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

Measured memory_bytes: 551516
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int w;
	int a, b;
	cin >> w >> a >> b;
	if (a > b){
		swap(a, b);
	}
	if (b <= a + w){
		cout << 0 << endl;
	}
	else{
		cout << b - a - w << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --n;

    bool flag = true;
    if(abs(a-b) > n*d) flag = false;
    else {
        int x = c+d;
        if(!(1&n)) {
            int res = abs(a-b)%x;
            if((n/2+1)*c-(n/2-1)*d > res && n/2*d-n/2*c < res) {
                flag = false;
            }
        } else {
            int res = abs(a-b)%x;
            if((n/2+1)*c-n/2*d > res || (n/2+1)*d-n/2*c < res) {
                flag = false;
            }
        }
    }

    cout << (flag ? "YES":"NO") << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lcm(ll a,ll b){return a/__gcd(a,b)*b;}
int main()
{
    int a,b;cin>>a>>b;
    cout<<lcm(a,b);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    vector<ll> s[n];
    ll ans=0;
    //vector<ll> t[(1<<3)];
    for(int i=0;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        s[i].push_back(a);
        s[i].push_back(b);
        s[i].push_back(c);
    }
    
    for(int i=0;i<(1<<3);i++){
        ll t[n];
        for(int k=0;k<n;k++){
            ll p=0;
            for(int j=0;j<3;j++){
                //cout<<s[k][j]<<"WWWW"<<endl;
                if(i&(1<<j)){
                    p-=s[k][j];
                }
                else p+=s[k][j];
            }
            t[k]=p;
        }
        sort(t,t+n,greater<>());
        ll pre=0;
        for(int k=0;k<m;k++){
            pre+=t[k];
        }
        //cout<<pre<<endl;
        if(ans<pre)ans=pre;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long h;
  long long n;
  long long a;
  long long tt = 0;

  cin >> h >> n;

  // vector<int> a(n);
  for(int i = 0; i < n; i++){
    // cin >> a[i];
    cin >> a;
    tt += a;
  }
  if(h <= tt){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl ;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<atcoder/all>
using namespace atcoder;
int main(){
  int n,m;
  std::cin>>n>>m;
  dsu d(n);
  for(int i=0;i<m;i++){
    int a,b;
    std::cin>>a>>b;
    a--; b--;
    d.merge(a,b);
  }
  int cnt=d.groups().size();
  int ans=cnt-1;
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 9036
# Track and Field Competition

a1=Array.new()
a2=Array.new() #finalist
a3=Array.new()

24.times { |i|
  n, t=gets.split.map(&:to_f)
  a1<<[n, t]
  if i%8==7
    a1.sort_by! { |item| item[1] }
    a2=a2+a1[0..1]
    a3=a3+a1[2..-1]
    a1.clear
  end
}

a3.sort_by! { |item| item[1] }
a2=a2+a3[0..1]

a2.each { |each|
  puts "#{each[0].to_i} #{each[1]}"
}

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

using namespace std;

int a[100005];

int in()
{
    int a;
    scanf("%d",&a);
    return a;
}

int main()
{
    int n=in(),ans=0;
    for(int i=0;i<n;i++)
    {
        int aa=in();
        if(aa>100000)
            ans++;
        else
            a[aa]++;
    }
    for(int i=1;i<=100000;i++)
    {
        if(a[i]>i){
            ans+=(a[i]-i);
        }
        else if(a[i]<i)
        ans+=a[i];
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256