akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
list1 = list(map(int,input().split()))
dp = [10**9]*n
dp[0] = 0

for i in range(1,n):
    for j in range(1,k+1):
        if i - j < 0:
            break
        dp[i] = min(dp[i],dp[i-j]+abs(list1[i]-list1[i-j]))

print(dp[-1])

Measured memory_bytes: 52448
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int h,w,n;
    scanf("%d%d%d", &h, &w, &n);
    int tmp=MAX(h,w);
    printf("%d\n", (n-1+tmp)/tmp);


    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

const INF int = 2e9
const N = 1e4+2

var dp = make([]int, N)
var h, n int
var a []int
var b []int

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func rec(h int) int {
    if h <= 0 {
        return 0
    }
    if dp[h] != -1 {
        return dp[h]
    }
    var cur = INF
    for i := 0; i < n; i++ {
        cur = min(cur, rec(h-a[i])+b[i])
    }
    dp[h] = cur
    return dp[h]
}

func main() {
    for i := range dp {
        dp[i] = -1
    }
    fmt.Scan(&h, &n)
    a = make([]int, n);
    b = make([]int, n);
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i], &b[i])
    }
    fmt.Println(rec(h))
}

Measured memory_bytes: 1536
n=int(input())
a=list(map(int, input().split()))
l = [a[0]]
for i in range(1, n):
  l.append(l[i-1]+a[i])

ans = 0
for i in range(n):
  ans = (ans + (l[n-1] - l[i])*a[i]) % 1000000007

print(ans)

Measured memory_bytes: 31524
/* https://www.youtube.com/watch?v=dQw4w9WgXcQ hello. -bedirhan */
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (10 <= n < 100)
    {
        n = n % 10;
    }
    else if (100 <= n < 1000)
    {
        n = (n % 100) % 10;
    }
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon";
    }
    else if (n == 0 || n == 1 || n == 6 || n == 8)
    {
        cout << "pon";
    }
    else
    {
        cout << "bon";
    }
}


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

int main() {
    string S, T;
    cin >> S >> T;

    string S2 = S + S;
    bool flag = false;
    for (int i = 0; i < S.size(); i++) {
            string S3 = "";
        for (int j = i; j < i + S.size(); j++) {
            S3 += S2.at(j);
        }
        if (S3 == T) {
            flag = true;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, sum[227][227], f[227][227][227], g[227][227][227];
char s[227];
int ask(int u, int d, int l, int r)
{
	return sum[d][r] - sum[u - 1][r] - sum[d][l - 1] + sum[u - 1][l - 1];
}
int check(int u, int d, int l, int r)
{
	return ask(u, d, l, r) == 0 || ask(u, d, l, r) == (d - u + 1) * (r - l + 1);
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++)
			sum[i][j] = (s[j] == '#' ? 1 : 0);
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			sum[i][j] = sum[i][j] + sum[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			sum[i][j] = sum[i][j] + sum[i - 1][j];
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++)
			for (int k = m; k >= 1; k--)
				if (f[i][j][k + 1] && check(i, j, k, f[i][j][k + 1]))f[i][j][k] = f[i][j][k + 1];
				else if (check(i, j, k, k))f[i][j][k] = k;
	for (int i = 1; i <= m; i++)
		for (int j = i; j <= m; j++)
			for (int k = n; k >= 1; k--)
				if (g[i][j][k + 1] && check(k, g[i][j][k + 1], i, j))g[i][j][k] = g[i][j][k + 1];
				else if (check(k, k, i, j))g[i][j][k] = k;
	if (f[1][n][1] == m) { cout << 0 << endl; return 0; }
	int res = 1;
	while (1)
	{
		for (int i = 1; i <= n; i++)
			for (int j = i; j <= n; j++)
				for (int k = 1; k <= m; k++)
					if (f[i][j][f[i][j][k] + 1])
						f[i][j][k] = f[i][j][f[i][j][k] + 1];
		for (int i = 1; i <= m; i++)
			for (int j = i; j <= m; j++)
				for (int k = 1; k <= n; k++)
					if (g[i][j][g[i][j][k] + 1])
						g[i][j][k] = g[i][j][g[i][j][k] + 1];
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
			{
				int now = m;
				for (int k = i; k <= n; k++)
				{
					while (now && g[j][now][i] < k)now--;
					f[i][k][j] = max(f[i][k][j], now);
				}
				now = n;
				for (int k = j; k <= m; k++)
				{
					while (now && f[i][now][j] < k)now--;
					g[j][k][i] = max(g[j][k][i], now);
				}
			}
		if (f[1][n][1] == m) { cout << res << endl; return 0; }
		res++;
	}
	return 0;
}

Measured memory_bytes: 77696
N=int(input())
r=[]
bi=[]
for i in range(N):
    a,b=map(int,input().split())
    bi.append(b)
    if a%b==0:
        r.append(0)
    else:
        r.append(b-a%b)
push=0
bi=bi[::-1]
r=r[::-1]
for i in range(N):
    if i==0:
        push=r[i]
    else:
        push+=(r[i]-push)%bi[i]
print(push)

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

int main() {
	long long N, Q, NOW = 0;
	cin >> N >> Q;
	vector<long long> V(N), ANS;
	for (int i = 0; i < N; i++) V[i] = i;
	ANS.push_back(0);
	ANS.push_back(1);
	for (int i = 0; i < Q; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		if (A == NOW || B == NOW) NOW = A + B - NOW;
		swap(V[A], V[B]);
		if (NOW != 0) ANS.push_back(V[NOW - 1]);
		if (NOW != N - 1) ANS.push_back(V[NOW + 1]);
	}
	sort(ANS.begin(), ANS.end());
	ANS.erase(unique(ANS.begin(), ANS.end()), ANS.end());
	cout << ANS.size() << endl;
}

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main()
    {
        var data = Console.ReadLine().Split();
        var x = int.Parse(data[0]);
        var n = int.Parse(data[1]);
        var p = Console.ReadLine().Split().Where(s => s != "").Select(s => int.Parse(s)).ToList();

        Console.WriteLine(
            Enumerable
                .Range(0, 102)
                .Where(i => !p.Contains(i))
                .OrderBy(i => Math.Abs(x - i))
                .ThenBy(i => i)
                .First()
        );
    }
}


Measured memory_bytes: 28560
def combination(n, m):
    perm = 1
    dup = 1
    for i in range(m):
        perm *= (n-i)
        dup *= (m-i)
    return perm // dup
    

n, m = map(int, input().split())

print(combination(n, 2) + combination(m, 2))


Measured memory_bytes: 2940
n = int(input())
num_list = [ int(v) for v in input().split() ]
num_list[0] -= 1
for i in range(n-1):
    if num_list[i] < num_list[i+1]:
        num_list[i+1] -= 1

ans = "Yes"
for i in range(n-1):
    if num_list[i] > num_list[i+1]:
        ans = "No"
        break
print(ans)


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

const int MAX = 2010000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll COMS(int x, int y){
  return COM(x+y+2, x+1);
}

int main(){
  COMinit();
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll ans = (COMS(r2, c2) - COMS(r2, c1-1) - COMS(r1-1, c2) + COMS(r1-1, c1-1))%mod;
  if(ans < 0){
    ans += mod;
  }
  cout  << ans << endl;
  return 0;
}


Measured memory_bytes: 47360
n = gets.to_i
heights = gets.split.map(&:to_i)

def water(n, heights)
  from = heights.find_index { |height| height > 0 }
  (from...n).each do |index|
    break if heights[index].zero?
    heights[index] -= 1
  end
  heights
end

ans = 0
until heights.max.zero?
  heights = water(n, heights)
  ans += 1
end

puts ans


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


int main()
{
  int n;
  cin>>n;
int p=10;
  int ans=0;
  int temp=n;
  while(temp>0)
  {
    ans=ans*p+(temp%10);
    temp=temp/10;
    
  }
  //cout<<ans<<" "<<n<<endl;
  if(ans==n)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}

Measured memory_bytes: 3592
n = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(n)]
a[0] = b[0]
a[1] = b[0]
a[n-1] = b[n-2]
for i in range(1,n-1):
    a[i] = b[i-1]
    if a[i] > b[i]:
        a[i] = b[i]
print(sum(a))

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e3 + 7;
const int N = 2e5 + 7;
const int M = 22;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);



void solve1()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for( int i = 0; ; i++ ){
        if( (i & 1) == 0 ){
            c -= b;
            if( c <= 0 ){
                cout << "Yes";
                return;
            }
        }else{
            a -= d;
            if( a <= 0 ){
                cout << "No";
                return;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=2e5+10;
int f[maxn];
int ans[maxn];
int a[maxn];
int sum[maxn];
int find1(int x)
{
    if(f[x]==x)
    {
        return x;
    }
    else
    {
        f[x]=find1(f[x]);
        return f[x];
    }

}
void add(int x,int y)
{
    int t1,t2;
    t1=find1(x);
    t2=find1(y);
    f[t2]=t1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
        f[i]=i;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        add(x,y);
        a[x]++;a[y]++;//x的直接朋友，y的直接朋友
    }
    for(int i=1;i<=n;i++)
    {

        sum[find1(i)]++;
    }

    for(int i=1;i<=n;i++)
    {
        ans[i]=sum[f[i]]-1-a[i];
    }
    for(int i=1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        if(find1(x)==find1(y))
        {
            ans[x]--;ans[y]--;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=1)
            cout<<" ";
        cout<<ans[i];
    }
    cout<<'\n';







}


Measured memory_bytes: 2688
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut a: u32 = read();
    let mut b: u32 = read();
    a -= 1;
    b -= 1;
    let n = 100;
    let mut ans = vec![vec![' '; n]; n];
    for i in 0..n {
        for j in 0..n {
            ans[i][j] = if i < n / 2 {
                '.'
            } else {
                '#'
            };
            if i % 2 == 1 && j % 2 == 1 {
                if i < n / 2 && b > 0 {
                    ans[i][j] = '#';
                    b -= 1;
                }
                if i >= n / 2 && a > 0 {
                    ans[i][j] = '.';
                    a -= 1;
                }
            }
        }
    }
    println!("{} {}", n, n);
    for i in 0..n {
        println!("{}", ans[i].iter().cloned().collect::<String>());
    }
}


Measured memory_bytes: 4352
package main

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

func main() {
	N := nextInt()
	As := nextInts(N)
	fmt.Println(solve(As))
}

func solve(As []int) int {
	isPrime, _ := Sieve(1e6 + 1)

	counts := make(map[int]int)
	for _, a := range As {
		counts[a]++
	}

	if counts[1] == 1 {
		return 1
	}
	if counts[1] >= 2 {
		return 0
	}

	ans := 0
	for _, a := range As {
		if counts[a] >= 2 {
			continue // ng
		}
		if isPrime[a] {
			ans++
			continue
		}
		nums := factorize(a)
		ok := true
		for _, num := range nums {
			if counts[num] >= 1 {
				ok = false
				break
			}
		}
		if ok {
			ans++
		}
	}
	return ans
}

func Sieve(max int) ([]bool, []int) {
	isPrime := make([]bool, max+1)
	for i := 2; i <= max; i++ {
		isPrime[i] = true
	}
	primes := []int{}
	for i := 2; i <= max; i++ {
		if !isPrime[i] {
			continue
		}
		for j := 2 * i; j <= max; j += i {
			isPrime[j] = false
		}
		primes = append(primes, i)
	}
	return isPrime, primes
}

func factorize(n int) []int {
	nums := []int{}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			nums = append(nums, i)
			if i*i != n {
				nums = append(nums, n/i)
			}
		}
	}
	return nums
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 19732
def abc169_d():

    def prime_factorize(n: int) -> list:
        ''' nの素因数分解 '''
        arr = []
        while n % 2 == 0:
            arr.append(2)
            n = n // 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                arr.append(f)
                n = n // f
            else:
                f += 2
        if n != 1:
            arr.append(n)
        return arr

    N = int(input())
    primes = prime_factorize(N)
    ans = 0

    from collections import Counter
    for _, v in Counter(primes).items():
        u = 1
        while True:
            tmp = (u+2) * (u+1) // 2
            if tmp <= v: u += 1
            else: break
        ans += u
    print(ans)

abc169_d()

Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }

    vector<int> dp(n, 1e9);
    dp[0] = 0;
    rep(i,n){
        rep(j,k) {
            if (i+j+1<n) {
                dp[i+j+1] = min(dp[i+j+1], dp[i] + abs(h[i]-h[i+j+1]));
            }
        }
    }
    cout << dp[n-1] << endl;
}


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

int main(){

    int N,count;
    count=0;
    cin >>N;
    vector<long int> A(N+1);
    vector<long int> B(N);
    for (int i=0;i<N+1;i++){
      cin >>A.at(i);
      }
    for (int i=0;i<N;i++){
      cin >>B.at(i);
      }

      long int yoryoku;
      long int total=0;
      for(int i=0;i<N;i++){
      if(A.at(i)<B.at(i)){
        yoryoku=B.at(i)-A.at(i);
        total+=A.at(i);
      }else{
        yoryoku=0;
        total+=B.at(i);
      }

      if(yoryoku>=A.at(i+1)){
        total+=A.at(i+1);
        A.at(i+1)=0;
      }else{
        total+=yoryoku;
        A.at(i+1)-=yoryoku;
      }
      }


    cout<<total<<endl;


}


Measured memory_bytes: 1792
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

A, B = [0], [0]

for i in range(n):
    A.append(a[i]+A[i])

for i in range(m):
    B.append(b[i]+B[i])

ans = 0
j = m

for i in range(n+1):
    if A[i] > k:
        break
    while (A[i]+B[j]) > k:
        j -= 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 47516
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int p,q,r;cin>>p>>q>>r;
  int res = min({p+q, p+r, q+r});
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans = 0, x, y, ct;
	cin >> n;
	vector<int> a(n), c(n);
	vector<vector<pair<int, int>>> v(n);

	for (i = 0; i < n; i++) {
		cin >> a[i];
		for (j = 0; j < a[i]; j++) {
			cin >> x >> y;
			x--;
			v[i].push_back({ x, y });
		}
	}

	for (i = 0; i < (1 << n); i++) {
		ct = 0;
		for (j = 0; j < n; j++) {
			if ((i & (1 << j))) {
				ct++;
				c[j] = 1;
			}
			else c[j] = 0;
		}

		bool match = true;
		for (j = 0; j < n; j++) {
			if (!c[j]) continue;
			for (k = 0; k < a[j]; k++) {
				if ((v[j][k].second == 1) && (!c[v[j][k].first])) 
					match = false;
				else if ((v[j][k].second == 0) && (c[v[j][k].first])) 
					match = false;
			}
		}

		if (match) {
			ans = max(ans, ct);
		}
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX(a,b) (a>b)? a:b
#define MIN(a,b) (a<b)? a:b
#define SUM(a,b) a+b
#define INF 1e9
int main(void){
    int n, ma=-INF, mi=INF;
    long int sum=0;
    scanf("%d",&n);
    int ary[n];
    for(int i=0;i<n;i++) scanf("%d",&ary[i]);
    for(int i=0;i<n;i++){ma=MAX(ma,ary[i]),mi=MIN(mi,ary[i]),sum=SUM(sum,ary[i]);}
    printf("%d %d %ld\n",mi,ma,sum);
}



Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void factorization(long long n,map<ll,ll>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll gg = 0;
    map<ll, ll> ans;
    for (ll i = 0; i < n; i++) gg = gcd(gg, a[i]);
    bool flag1 = (gg == 1 ? true : false);
    for (ll i = 0; i < n; i++) {
        factorization(a[i], ans);
    }
    bool flag2 = true;
    for (ll i = 0; i < n; i++) {
        map<ll, ll> tmp;
        factorization(a[i], tmp);
        for (auto i:tmp){
            if (i.second - ans[i.first] != 0) {
                flag2 = false;
                goto end;
            }
        }
    }
    end:
    if (flag2) cout << "pairwise coprime" << endl;
    else if(flag1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


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

using namespace std;

#define debug(x) cout << #x << "::" << x << endl;
#define debug2(x, y) cout << #x << "::" << x << " " << #y << "::" << y << endl;
#define debug3(x, y, z) cout << #x << "::" << x << " " << #y << "::" << y <<" "<< #z << "::" << z << endl;

#define For(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
const ll mod = 1e13 + 7;
const int MAX = 5 * 1e3 + 5;
typedef pair<int, int> pii;

void add(ll &a, ll b)
{
    a = (a + b) % mod;
    if (a < 0) a += mod;
}

int main() {

    int n;
    cin>>n;

    vector<ll> a(n);
    For(i,0,n) cin>>a[i];
    
    vector<vector<ll>> dp(n,vector<ll>(n));

    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j){
                dp[i][j] = 0;
            }else {
                ll sum = 0;
                dp[i][j] = mod;
                for(int k=i;k<=j;k++) sum+=a[k];
                for(int k=i;k<j;k++){
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+sum);
                }
            }
        }
    }

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

}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char d[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>d[i][j];
    }
  }
  for(int i = 0;i<H;i++){
    for(int j=0;j<W;j++){
      if(d[i][j]=='#'){
        if(d[i-1][j]=='.'&&d[i+1][j]=='.'&&d[i][j-1]=='.'&&d[i][j+1]=='.'){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
	int n,m,sum=0;
	while(cin>>n){
		if(n==0) return 0;
		for(int i=0; i<n/4; i++){
			cin >> m;
			sum += m;
		}
		cout << sum << endl;
		sum=0;
	}
}

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

using namespace std;
typedef long long ll;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    vector<int> pw2(10);
    pw2[0] = 1;
    for (int i = 1; i < 10; i++) {
        pw2[i] = 2 * pw2[i - 1];
    }
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k - i; j++) {
            if (a < b * pw2[i] && b * pw2[i] < c * pw2[j]) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, w;
    cin >> h >> w;
    vstr a(h);
    rep(i, h) cin >> a[i];

    int count = 0;
    rep(i, h) rep(j, w) if (a[i][j] == '#') count++;

    if (count == h+w-1) puts("Possible");
    else puts("Impossible");
    return 0;
}

Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				if v := t[i][j] + u[i][k]; t[i+1][k] < v {
					t[i+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


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

int main(){
  int n,m,p,x,i,j,sum;
  cin >> n;
  int t[n];
  for (j=0;j<n;j++) cin >> t[j];
  cin >> m;
  int z[n];
  for (i=0;i<m;i++) {
    for (j=0;j<n;j++) z[j] = t[j];
    sum = 0;
    cin >> p >> x;
    p -= 1;
    z[p] = x;
    for (j=0;j<n;j++) sum += z[j];
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,j=0;
  cin>>a>>b;
  int ans=100*a/8;
  while(ans*8/100<a+1){
      if(ans*8/100==a&&ans/10==b){
          j=1;
          break;
      }
      ans+=1;
  }
  if(j==0){
      cout<<-1<<endl;
  }
  else{
      cout<<ans<<endl;
  }
  return 0;
}


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

#include <iostream>
#include <string>
using namespace std;

int isPrime(int p){
        if(p<=1) return 0;
        if(p==2 || p==3 || p==5 || p==7) return 1;
        if(p==4 || p==6 || p==8 || p==9) return 0;

        int i;
        int ret = 1;
        for(i=2; i*i<=p; i++){
                if(p%i==0 && i!=p){
                        ret = 0;
                        break;
                }
        }
        return ret;
}

int factor(int n, int p){
        int ret = 0;
        int q = n;
        int r = 0;
        while(r==0){
                r = q%p;
                if(r==0){
                        q = q/p;
                        ret++;
                }
        }
        return ret;
}

int main(int argc, char* argv[]){
        int N;

        cin >> N ;
        int ans = 0;
        for(int i=1; i<=N; i=i+2){
                int c = 1;
                for(int j=1; j<=i; j++){
                        if(isPrime(j)){
                                int k = factor(i, j);
                                if(k>0){ c = c*(k+1); }
                        }
                }
                if(c==8){ ans++; }
        }
        printf("%d\n", ans);
        return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int64_t dp[201][1000001];

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> S(N);
    for(int i=0; i<N; i++) cin >> S[i];
    sort(S.rbegin(), S.rend());

    create_mod_tables(1000);
    dp[0][X] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<=100000; j++){
            add(dp[i+1][j%S[i]], dp[i][j]);
            add(dp[i+1][j], dp[i][j] * (N-i-1));
        }
    }

    int64_t ans = 0;
    for(int j=0; j<=100000; j++) add(ans, j*dp[N][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 569600
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True


def main():
    N, K = MI()
    A = LI()
    LEN = 61
    ans = 0

    for d in range(LEN, -2, -1):
        if d != -1 and (K & (1 << d)) == False:
            continue

        tmp = 0
        for e in range(LEN, -1, -1):
            mask = 1 << e
            num = 0
            for j in range(N):
                if A[j] & mask > 0:
                    num += 1

            if e > d:
                if K & mask > 0:
                    tmp += mask * (N - num)
                else:
                    tmp += mask * num
            elif e == d:
                tmp += mask * num;
            else:
                tmp += mask * max(num, N - num)

        ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65132
#include <stdio.h>

#define LIMIT 1000000007

long a[2000];

long count(int s) {
   long ans;
   int i;

  if (a[s]>=0) return a[s];
  ans=1;
  for (i=3;i+3<=s;i++) ans=(ans+count(s-i))%LIMIT;
  a[s]=ans;
  return ans;
}

int main(){
   int i,s;

   scanf("%d",&s);
   for (i=4;i<=s;i++) a[i]=-1;
   a[3]=1;
   printf("%ld\n",count(s));
   return 0;
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

priority_queue<int> pq[3];

int solve(int i){
    if(pq[0].size()==1&&pq[1].size()==1) return 0;
    if(pq[2].size()==1&&pq[1].size()==1) return 0;
    if(i==0){
        if(pq[1].top()<pq[2].top()){
            //cout<<pq[2].top()<<endl;
            pq[1].push(pq[2].top());
            pq[2].pop();
        }
        else {
            //cout<<pq[1].top()<<endl;
            pq[2].push(pq[1].top());
            pq[1].pop();
        }
    }
    else {
        if(pq[0].top()<pq[1].top()){
            //cout<<pq[1].top()<<endl;
            pq[0].push(pq[1].top());
            pq[1].pop();
        }
        else {
            //cout<<pq[0].top()<<endl;
            pq[1].push(pq[0].top());
            pq[0].pop();
        }
    }
    return 1+solve(1-i);
}

int main(){
    int i,j;
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0) return 0;
        priority_queue<int> pq2[3];
        for(i=0;i<3;i++){
            int k;
            cin>>k;
            for(j=0;j<k;j++) {
                int x;
                cin>>x;
                pq2[i].push(x);
            }
            pq2[i].push(0);
        }
        pq[0]=pq2[0];
        pq[1]=pq2[1];
        pq[2]=pq2[2];
        //int ans=min(solve(0),solve(1));
        int ans=solve(0);
        pq[0]=pq2[0];
        pq[1]=pq2[1];
        pq[2]=pq2[2];
        int ans2=solve(1);
        ans=min(ans,ans2);
        cout<<((ans<=m) ? ans : -1)<<endl;
    }
}


Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void){
    ll N , K ;
    cin >> N >> K ;
    ll h[N] ;
    rep(i , N ){
        cin >> h[i] ;
    }
    ll ans = 1e9; ;
    ll tmp ;
    sort(h , h +N) ;
    rep(j , N - K + 1 ){
        tmp = h[j + K - 1] - h[j] ;
        if(ans > tmp){
            ans = tmp ;
        }
    }
    cout << ans << endl;
    return 0 ;
}
    
  

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	long x[10000];

	long co = 0;

	for (long i = 0; i < 10000; i++)
	{
		cin >> x[i];

		if (x[i] == 0)
		{
			break;
		}
		co += 1;
	}

	for (long i = 0; i < co; i++)
	{
		cout << "Case" << " " << i + 1 << ':' << " " << x[i] << endl;
	}
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int dp[1001][1001];
int main()
{
    int q;
    cin >> q;
    rep(i, q) {
        string A, B;
        cin >> A >> B;
        rep(i, A.size()) {
            rep(j, B.size()) {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
                if (A[i] == B[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
        }
        cout << dp[(int)A.size()][(int)B.size()] << endl;
    }
    return 0;
}


Measured memory_bytes: 7092
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

for Z in range(-100,102):
    if X<Z<=Y and max(x)<Z and min(y)>=Z:
        print('No War')
        break
else:
    print('War')

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long D[44][44][44];
char p[44][44];
void Calc(int b, int e, int pv) {
	int i, j, k, ii, jj;
	if (b == e) {
		D[b][e][pv] = 1;
		return;
	}
	if (b == pv || e == pv) return;
	for (i = pv; i > b; i--) {
		for (j = pv; j < e; j++) {
			if (!D[i][j][pv])continue;
			for (ii = b; ii < i; ii++) {
				for (jj = e; jj > j; jj--) {
					if (p[ii][jj] == '1') {
						D[b][e][pv] += D[i][j][pv] * D[b][i - 1][ii] * D[j + 1][e][jj];
					}
				}
			}
		}
	}
}
int main() {
	int i, j, k, l, DEBUG = 0;
	scanf("%d", &n);
	n *= 2;
	for (i = 1; i <= n; i++) {
		if(!DEBUG)scanf("%s", p[i] + 1);
		else {
			for (j = 1; j <= n; j++) {
				if (i != j)p[i][j] = '1';
				else p[i][j] = '0';
			}
		}
	}
	for (int l = 1; l <= n; l += 2) {
		for (i = 2; i <= n - l + 1; i++) {
			int b = i, e = i + l - 1;
			for (k = b; k <= e; k++) {
				Calc(b, e, k);
			}
		}
	}
	long long res = 0;
	for (i = 2; i <= n; i++) {
		if (p[1][i] == '1')res += D[2][n][i];
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int num = 0, count = 0, ans = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  
  cin >> a >> b;
  
  if(a >= 10 || b >= 10)
  {
    cout << -1 << endl;
  }else{
    cout << a * b << endl;
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int a, b, c;
int n;
int N[2];
pp d[100010];

ll ans;

ll s;
priority_queue<int> pq;
void Init(){ while(pq.size()) pq.pop(); s=0; }
void Put(int x, int ms){
	pq.push(-x); s += x;
	while(int(pq.size()) > ms){
		s += pq.top(); pq.pop();
	}
}

ll dp[100010];

int main()
{
	read(a, b, c); n = a+b+c; N[0]=a; N[1]=b;
	for(int i=0; i<n; ++i){
		int a, b, t; read(a, b, t);
		ans += t; a-=t; b-=t;
		d[i]={a, b};
	}
	sort(d, d+n, [](const pp&a, const pp&b){
		return a.y-a.x < b.y-b.x;
	});
	Init();
	for(int i=0; i<n; ++i){
		Put(d[i].x, a);
		dp[i] += s;
	}
	Init();
	for(int i=n-1; 0<i; --i){
		Put(d[i].y, b);
		dp[i-1] += s;
	}
	
	printf("%lld\n", ans + *max_element(dp+a-1, dp+n-b));
	return 0;
}


Measured memory_bytes: 2428
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class sh18_b {
public:
    void solve(istream& in, ostream& out) {
        string s;
        int w;
        in >> s >> w;
        string res;
        int n = s.size();
        for (int j = 0; j < n; j += w) {
            res += s[j];
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	sh18_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll a,b;
    char op;
    cin >> a >> op >> b;
    if(op=='+')
    {
        cout << a+b << endl;
        return 0;
    }else
    {
        cout << a-b << endl;
        return 0;
    }

    
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(){
	int n,k,i;
	char s[51];
	scanf("%d%d%s",&n,&k,s);k--;
	for(i=0;i<n;i++){
		if(i==k)printf("%c",s[i]+32);
		else printf("%c",s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
#include<math.h>
#include<stdio.h>
int main()
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)printf("Yes\n");
    else printf("No\n");
    return 0;
}




Measured memory_bytes: 2700
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k,m,g,a[200005],b[200005];
double ans,c[200005],d[200005];
int main(){
	in(n);in(k);
    for(int i=1;i<=n;i++)in(a[i]),g=max(g,a[i]);
    for(int i=1;i<=g;i++)b[i]=b[i-1]+i;
	for(int i=1;i<=n;i++)c[i]=1.0*b[a[i]]*(1.0/a[i]);
	for(int i=1;i<=n;i++)d[i]=d[i-1]+c[i];
    for(int i=1;i+k-1<=n;i++){
        double sum=d[i+k-1]-d[i-1];
        ans=max(ans,sum);
    }
	printf("%.10lf\n", ans);
	return 0;
}


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

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

    int X, Y; cin >> X >> Y;

    cout << (X % Y == 0 ? -1 : X) << endl;
}


Measured memory_bytes: 256
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=1e5+5;
const ll M=1e3+5;
const ll mod=998244353;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b,ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b,ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b,ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  ll n;
  cin>>n;
  ll ans=(n*(n-1))/2;
  //ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 2005
const LL mod=1000000007;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL C[Max][Max];
void Compare_C () {// play table
    C[0][0]=1;
    for(int i=1;i<Max;i++){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    Compare_C();
    int b,r,c;
    scanf("%d%d",&c,&b);
    r=c-b+1;
    for(int i=1;i<=b;i++){
        printf("%lld\n",(C[b-1][i-1]*C[r][i])%mod);
    }
    return 0;
}


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

using namespace std;
#define ll long long

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

    int a = n%10;
    if(a == 2|| a== 4|| a==5|| a==7 || a== 9)
        cout<<"hon"<<endl;
    else if( a== 3)
        cout<<"bon"<<endl;
    else
        cout<<"pon"<<endl;

    return 0;
}


Measured memory_bytes: 3628
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define MOD 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;
typedef long double ld;

string s;

int main() {
    Data_Nerd

	cin >> s;

    if(s == "Sunny")
    	puts("Cloudy");
    else if(s == "Cloudy")
    	puts("Rainy");
    else
    	puts("Sunny");

    return 0;
}


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

int n,k;
vector<pair<int,int> > g[100005];
int c[100005];

void dfs(int x,int p,int col){
    int cur=0;
    for(int i=0;i<g[x].size();i++){
        int y=g[x][i].first,z=g[x][i].second;
        if(y==p)continue;
        cur++;
        if(cur==col)cur++;
        k=max(k,cur);
        c[z]=cur;
        dfs(y,x,cur);
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(make_pair(b,i));
        g[b].push_back(make_pair(a,i));
    }
    dfs(1,-1,0);
    cout<<k<<endl;
    for(int i=1;i<n;i++){
        cout<<c[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 9344