akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = []

for _ in range(n):
    ab.append(tuple(li()))
    
ans = 0
while ab:
    a,b = ab.pop()
    a += ans
    
    ans += b - (a%b) if a%b else 0
    
print(ans)

Measured memory_bytes: 16612
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int a, p; cin >> a >> p;

    int num = 3 * a + p;
    cout << num / 2 << ln;
}

    

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S, T;
    cin >> S >> T;
    ll m = 0;
    rep(i, S.size()) {
       ll c = 0;
       if (i + T.size() > S.size()) break;
       rep(j, T.size()) {
           if (S[i + j] == T[j]) c ++;
       }
       m = max(m, c);
    }
    cout << T.size() - m << '\n';
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
vector<ll> getNums(ll N) {
    vector<ll> num(N);
    REP(i, N) {
        cin >> num[i];
    }
    return num;
}
int main() {
    ll N;
    cin >> N;
    auto values = getNums(N);

    ll count = 0;
    sort(values.begin(), values.end());

    for (ll i = 0; i < N; ++i) {
        for (ll j = i + 1; j < N; ++j) {
            for (ll k = j + 1; k < N; ++k) {
                if (values[i] == values[j]) continue;
                if (values[j] == values[k]) continue;
                if (values[i] == values[k]) continue;

                if (values[i] + values[j] > values[k]) {
                    if (values[j] + values[k] > values[i]) {
                        if (values[k] + values[i] > values[j]) {
#ifdef SOURCE_TEST
                            cout << i << "," << j << "," << k << endl;
#endif

                            count++;
                        }
                    }
                }
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#define MAX 100010
#define X first
#define Y second
using namespace std;

int n,q,z;
int m[MAX];
vector<int> c[MAX];
stack<pair<char,int> > Q;

int u[MAX];

void DFS(int x,int g){
	u[x]=g;
	if(m[x])g=x;
	for(int i=0;i<c[x].size();i++){
		DFS(c[x][i],g);
	}
}

int FIND(int x){
	if(m[x])return x;
	int ret=FIND(u[x]);
	u[x]=ret;
	return ret;
}

int main(){

	while(cin>>n>>q&&n){

	for(int i=0;i<n;i++){
		c[i].clear();
		u[i]=0,m[i]=0;
	}

	for(int i=1;i<n;i++){
		cin>>z;z--;
		c[z].push_back(i);
	}

	m[0]++;
	for(int i=0;i<q;i++){
		pair<char,int> r;
		cin>>r.X>>r.Y;r.Y--;
		if(r.X=='M')m[r.Y]++;
		Q.push(r);
	}

	DFS(0,0);

	long long ans=0;

	while(!Q.empty()){
		if(Q.top().X=='M'){
			m[Q.top().Y]--;
		}
		else{
			ans+=FIND(Q.top().Y)+1;
		}
		Q.pop();
	}

	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 13476
#include<stdio.h>

int main(void) {
	int i, j, n, k;
	scanf("%d%d", &n, &k);
	int h[n];
	for (i = 0; i<n; i++) {
		scanf("%d", &h[i]);
	}
	for (i = 0; i<n; i++) {
		if (h[i] >= k)
			j++;
	}
	printf("%d", j);

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());
            var A = ReadLine().Split().Select(long.Parse).ToArray();

            var ans = 0L;
            for (int i = 0; i < N; i++)
            {
                ans = GetGcd(ans, A[i]);
            }
            WriteLine(ans);
        }

        public static long GetGcd(long a, long b)
        {
            if (b > a) GetGcd(b, a);
            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }
    }
}


Measured memory_bytes: 22880
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

void mizukinana(int out[8][8], int a[8][8], int b[8][8]) {
	int buf[8][8] = {{0}};
	int i, j, k;
	for (i = 0; i < 8; i++) {
		for (k = 0; k < 8; k++) {
			for (j = 0; j < 8; j++) {
				buf[i][j] = add(buf[i][j], mul(a[i][k], b[k][j]));
			}
		}
	}
	for (i = 0; i < 8; i++) {
		for (j = 0; j < 8; j++) {
			out[i][j] = buf[i][j];
		}
	}
}

int main(void) {
	int H, W, K;
	int horieyui[8][8] = {{0}};
	int tamurayukari[8][8] = {{0}};
	int i, j;
	if (scanf("%d%d%d", &H, &W, &K) != 3) return 1;
	for (i = 0; i < (1 << W); i += 2) {
		int valid = 1;
		for (j = 1; j < W; j++) {
			if (((i >> j) & 3) == 3) {
				valid = 0;
				break;
			}
		}
		if (valid) {
			for (j = 1; j <= W; j++) {
				if ((i >> (j - 1)) & 1) horieyui[j - 1][j - 2]++;
				else if ((i >> j) & 1) horieyui[j - 1][j]++;
				else horieyui[j - 1][j - 1]++;
			}
		}
	}
	for (i = 0; i < W; i++) tamurayukari[i][i] = 1;
	while (H > 0) {
		if (H & 1) mizukinana(tamurayukari, tamurayukari, horieyui);
		mizukinana(horieyui, horieyui, horieyui);
		H >>= 1;
	}
	printf("%d\n", tamurayukari[0][K - 1]);
	return 0;
}


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

    arr = factorization(N)
    ans = 0
    
    for i in range(len(arr)):
        for j in range(1,100):
            if arr[i][0] == 1:
                break
            elif arr[i][1] == 1:
                ans += 1
                break
            elif arr[i][1] == sum(range(0,j+1)):
                ans += j
                break
            elif arr[i][1] < sum(range(0,j+1)):
                ans += j-1
                break
    
    print(ans)
resolve()

Measured memory_bytes: 9508
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = new long[](n);
    foreach (ref e; a)
        e = lread();
    (a.length - a.sort().uniq.copy(a).length).writeln();
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar_water = 0
sugar = 0
for a in range(int(F / 100 / A) + 1):
    for b in range(int((F - a * 100 * A)/ 100 / B) + 1):
        if not a == b == 0:
            for c in range(int((a*A+b*B)*E/C)+1):
                for d in range(int(((a*A+b*B)*E-c*C)/D)+1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if con <= 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D)):
                            con = 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D))
                            sugar = c*C+d*D
                            sugar_water = 100*a*A+100*b*B+c*C+d*D
print(sugar_water, sugar)

Measured memory_bytes: 3064
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(void) {
    int n;
    string s;
    cin >> n >> s;

    int ne[n];
    ne[0] = (int)(s[0] == 'E');
    rep(i, n) {
        if(not i) i++;
        ne[i] = ne[i-1] + (int)(s[i] == 'E');
    }

    int mi = ne[n-1] - ne[0];
    rep(i, n) {
        if(not i) i++;
        int x = i - ne[i-1];
        x += ne[n-1] - ne[i];
        mi = min(mi, x);
    }
    cout << mi << endl;
}


Measured memory_bytes: 1796
<?php
list($H, $N) = ints();
$dp = array_fill(0, $N + 1, array_fill(0, $H + 1, 10**18));
$dp[0][0] = 0;
for($i = 1; $i <= $N; $i++){
  $dp[$i] = $dp[$i-1];
  $dpi = &$dp[$i];
  list($a, $b) = ints();
  for($j = 1; $j <= $H; ++$j){
    if($j - $a >= 0){
      chmin($dpi[$j], $dpi[$j-$a]+$b);
    }else{
      chmin($dpi[$j], $b);
    }
  }
}
//o($dp);
echo $dp[$N][$H];
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}

Measured memory_bytes: 756216
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    d:isize,
    }
    println!("{}",max(max(a*c,a*d),max(b*c,b*d)))
}

Measured memory_bytes: 2148
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    c = Counter(A)
    cnt = 0
    for key, val in c.items():
        if val > 2:
            if val % 2 == 0:
                c[key] = 2
                cnt += 1
            else:
                c[key] = 1
        elif val == 2:
            cnt += 1
    
    if cnt % 2 == 0:
        print(len(c))
    else:
        print(len(c) - 1)


if __name__ == '__main__':
    main()

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >>c >> d;
    vector<ll> seki(4);
    seki.at(0) = a*c;
    seki.at(1) = a*d;
    seki.at(2) = b * c;
    seki.at(3) = b * d;
    ll max = *max_element(seki.begin(), seki.end());
    printl(max);
}


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

int main() {
	int n,m,i,j,k,ans=0, cur=0, res=0;
	string s;
	cin >> s;
	n=s.size(); ans=n;
	for(i=1; i<n; i++){
		if(s[i]==s[i-1]){
			ans--;
			i+=2;
		}
	}
	
	cout << ans;
	return 0;
}

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

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

using ll=long long;
const int Nmax=3010;
int N;
double p[Nmax];
double dp[Nmax][Nmax];

void add(double &a,double b){
  a+=b;
}

int main(){
  cin >> N;
  for (int i=1;i<=N;i++){
    cin >> p[i];
  }
  dp[0][0]=1;
  for (int i=0;i<N;i++){
    for (int j=0;j<=i;j++){
      add(dp[i+1][j+1],dp[i][j]*p[i+1]);
      add(dp[i+1][j],dp[i][j]*(1-p[i+1]));
    }
  }
  double ans=0;
  for (int j=(N+1)/2;j<=N;j++)
    ans+=dp[N][j];
    
  cout << fixed << setprecision(10) << ans << endl;   
      
  
}

Measured memory_bytes: 69120
N = int(input())
x = []
y = []
for i in range(N):
  x1,y1 = map(int,input().split())
  x.append(x1)
  y.append(y1)
s = 0

for i in range(N - 1):
  for j in range(i + 1, N):
    s += ((x[i] - x[j])**2 + (y[i] - y[j])**2)**(1/2)
    
print(s * 2 / N)

Measured memory_bytes: 3064
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
if n==7 or n==5 or n==3:
    print("YES")
else:
    print("NO")

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------
int calc(int a){
    int res=0,k=10;
    REP(i,6){
        res=max(res,(a/k)*(a%k));
        k*=10;
    }
    return res;
}

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

    int n; cin>>n;
    REP(i,n){
        int a; cin>>a;
        int cnt=0;
        while(10<=a){
            a=calc(a);
            cnt++;
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> abc(n,vector<int>(3));
  for(int i=0;i<n;i++)
    cin>>abc.at(i).at(0)>>abc.at(i).at(1)>>abc.at(i).at(2);
  vector<vector<int>> dp(n,vector<int>(3));
  dp[0][0]=abc.at(0).at(0);
  dp[0][1]=abc.at(0).at(1);
  dp[0][2]=abc.at(0).at(2);
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1]+abc.at(i).at(0),dp[i-1][2]+abc.at(i).at(0));
    dp[i][1]=max(dp[i-1][2]+abc.at(i).at(1),dp[i-1][0]+abc.at(i).at(1));
    dp[i][2]=max(dp[i-1][0]+abc.at(i).at(2),dp[i-1][1]+abc.at(i).at(2));
  }
  cout<<max(max(dp.at(n-1).at(0),dp.at(n-1).at(1)),dp.at(n-1).at(2))<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,c,d,b,e,k;
string a;
map<string,int> s;
int main(){
  for(cin>>n;i<n;i++){
    cin>>a;
    s[a]++;
  }
  for(const auto& x:s)m=max(x.second,m);
  for(auto it=s.begin();it!=s.end();it++){
    if(it->second==m){
      cout<<it->first<<endl;
    }
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m, k;
  cin >> n >> m >> k;
  vll a(n + 1), b(m + 1);
  REP(i, n + 1) {
    cin >> a[i];
  }

  REP(i, m + 1) {
    cin >> b[i];
  }

  rep(i, n) {
    a[i + 1] += a[i];
  }

  rep(i, m) {
    b[i + 1] += b[i];
  }

  ll ans = 0;
  rep(i, n + 1) {
    ll cnt = i;
    ll remain = k - a[i];
    if (remain >= 0) {
      auto itr = upper_bound(all(b), remain);
      ll dist = distance(b.begin(), itr);
      cnt += dist - 1;
      chmax(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}


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


int main() {
	//code
	int n;
	cin>>n;
	int a[n];
	map<int,int>m;
	for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;}
        int count=0;
       if(m.count(1)&&m[1]==1) cout<<1;
       else if(m.count(1)&&m[1]>1) cout<<0;
       else{
     for(int i=0;i<n;i++){
        if(m[a[i]]==1){
            int p=0;
        for(int j=2;j<=sqrt(a[i]);j++){
                if(a[i]%j==0){
            // cout<<a[i]<<"-"<<j<<"-"<<a[i]/j<<endl;
                  if(m.count(j)||m.count(a[i]/j)){
                    p=1; break;}}
        }
        if(p==0) count++;}}
       cout<<count;}
	return 0;
}


Measured memory_bytes: 13700
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 1000

using namespace std;

int N, ans, cnt, sum;
bool flg;

int main() {
	string s;
	cin >> N ;
	cin >> s;
	
	ans++;
	rep(i, N-1) {
		if (s[i] != s[i + 1]) ans++;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<math.h>
using namespace std;
int main(void){
    // Here your code !
    int N;
    cin>>N;
    int s[N];
    int sum=0,min_10=101;
    for(int i=0;i<N;i++){
        cin>>s[i];
        if(s[i]%10){
            min_10=fmin(min_10,s[i]);
        }
        sum+=s[i];
    }
    
    if(sum%10!=0){
        cout<<sum;
    }
    else{
        if(min_10==101)cout<<0;
        else{
            cout<<sum-min_10;
        }
    }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
	Scanner s = new Scanner(System.in);
	double r = s.nextDouble();
	double pi = Math.PI;
	
	double area = pi * r * r;
	double length = 2 * pi * r;
	System.out.printf("%f %f\n", area, length);
    }
}


Measured memory_bytes: 28332
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red(a);
  vector<int> green(b);
  vector<int> mushoku(c);

  rep (i, a) {
    cin >> red[i];
  }
  rep (i, b) {
    cin >> green[i];
  }
  rep (i, c) {
    cin >> mushoku[i];
  }

  sort(red.rbegin(), red.rend());
  sort(green.rbegin(), green.rend());
  sort(mushoku.rbegin(), mushoku.rend());

  vector<int> total;
  rep (i, x) {
    total.push_back(red[i]);
  }
  rep (i, y) {
    total.push_back(green[i]);
  }
  rep (i, c) {
    total.push_back(mushoku[i]);
  }

  sort(total.rbegin(), total.rend());
  ll ans = 0;
  rep (i, x + y) {
    ans += total[i];
  }
  P(ans);

  return 0;
}

Measured memory_bytes: 3572
# string
# a, b, c = input().split()
# str_list = list(input().split())

# number
# a, b, c = map(int, input().split())
# num_list = list(map(int, input().split()))

# lows
# str_list = [input() for _ in range(n)]

# many inputs
# num_list = []
# for i in range(n): num_list.append(list(map(int, input().split())))

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(n):
    p[i] -= 1

ans = int(-1e14)
for i in range(n):
    tmp = []
    cycle = 0
    index = i
    while True:
        index = p[index]
        tmp.append(c[index])
        cycle += c[index]
        if i == index:
            break
    
    l = len(tmp)
    t = 0
    for j in range(l):
        t += tmp[j]
        if j >= k:
            break
        cur = t
        if cycle > 0:
            e = int((k-j-1) / l)
            cur += e * cycle
        ans = max(cur, ans)
        
print(ans)



Measured memory_bytes: 80916
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main()
{
    ll N, K, Q; cin >> N >> K >> Q;
    vector<int> gain(N+1, 0);
    REP(i, Q) { int a; cin >> a; gain[a]++; }
    FOR(i, 1, N) {
        cout << (K + gain[i] - Q > 0 ? "Yes" : "No") << endl;
    }
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 400400;

char S[MAX];

int C[26];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	scanf("%s", S);
	int n = strlen(S);

	FOR (i, 0, n)
	{
		C[S[i] - 'a']++;
	}

	LL res = n * (LL)(n + 1) / 2;

	FOR (i, 0, 26)
	{
		res -= C[i] *(LL) (C[i] + 1) / 2;
	}

	cout<<res + 1<<endl;

}


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

struct UnionFind {
    vector<int> par;  // par[i]: parent of i

    UnionFind(int N) : par(N) {  // initialize by making every node a root node
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {  // find the root of a given node
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {  // return true if x and y belong to the same tree
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    UnionFind uf(n + 1);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(p[i], i + 1)) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	ll total = 0;
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=n; ++j){
			for(int k=1; k<=n; ++k){
				total += __gcd(i,__gcd(j,k));
			}
		}
	}

	cout << total << "\n";


}


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

int main() {
  char c;
  cin >> c;
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}


// 高速素因数分解
// https://atcoder.jp/contests/abc177/editorial/82
// 2 <= i < nの数iについてi % p = 0となる最小の素数pをi番目にもつ配列を返す
vector<ll> minprime(ll n){
	vector<ll> res(n, 0);
	for(ll i = 2; i < n; i++){
		if(res[i]) continue;
		for(ll j = 1; i * j < n; j++){
			res[i * j] = i;
		}
	}
	return res;
}
vector<ll> mp = minprime(1000001);

// minprimeを用いた素因数分解
map<ll,int> prime_factors(ll n){
	map<ll,int> ret;
	while(n > 1){
		ll d = mp[n];
		ret[d]++;
		n /= d;
	}
	return ret;
}

vector<bool> isused(1000001, false);

bool ispairwise(int n){
	auto pf = prime_factors(n);
	for(auto [p,c]: pf){
		if(isused[p]) return false;
		isused[p] = true;
	}
	return true;
}

void Main(){
	int n; cin >> n;
	int g;
	cin >> g;
	bool pairwise = ispairwise(g);
	Rep(n-1){
		int t; cin >> t;
		g = gcd(g, t);
		if(pairwise){
			pairwise = ispairwise(t);
		}
	}
	if(pairwise){
		cout << "pairwise coprime\n";
	}else if(g == 1){
		cout << "setwise coprime\n";
	}else{
		cout << "not coprime\n";
	}
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int cnt = 0, ans = 0;
  for(int i = 0; i < s.size() - t.size() + 1; i++) {
    string a = s.substr(i, t.size());
    for(int j = 0; j < a.size(); j++) {
      if(a.at(j) == t.at(j)) cnt++;
    }
    if(cnt > ans) {
      ans = cnt;
    }
    cnt = 0;
  }
  cout << t.size() - ans << endl;
}

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


int main()
{
	int n, m;
	while(~scanf("%d %d",&n, &m))
	{
		int ans = 0;
		while(n > 0)
		{
			n = n - m * 2 - 1;
			ans ++;
		}
		cout << ans << endl;
	}
	
	return 0;
}
//1 2 3 4 5 6
//    1     1
//1 2 3 4 5 6 7 8 9 10 11 12 13 14
//      1               1   
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//        1                      1              1


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll res = 0;
    REP(pos, 60){
    	ll x = 0;
    	REP(i, N){
    		if(A[i]>>pos & 1) x++;
    	}
    	ll y = x*(N-x);
    	ll z = (1ll<<pos);
    	y %= mod;
    	z %= mod;
    	res += (y*z)%mod;
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int s=0;
	int gh;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&gh);
		if(gh%2) s++;
	}
	if(s%2) puts("NO");
	else puts("YES");
	return 0;
}

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

long double dp[309][309][309], dp2[309][309][309]; int N, A[4];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int a; cin >> a; A[a]++;
	}
	dp[A[1]][A[2]][A[3]] = 0; dp2[A[1]][A[2]][A[3]] = 1;
	for (int k = N; k >= 0; k--) {
		for (int j = N; j >= 0; j--) {
			for (int i = N; i >= 0; i--) {
				if (i + j + k == 0 || dp2[i][j][k] < 1e-20) continue;

				long double E = 1.0L * N / (i + j + k);
				long double K = dp[i][j][k] / dp2[i][j][k];
				if (i >= 1) {
					dp2[i - 1][j][k] += dp2[i][j][k] * i / (i + j + k);
					dp[i - 1][j][k] += (K + E) * dp2[i][j][k] * i / (i + j + k);
				}
				if (j >= 1) {
					dp2[i + 1][j - 1][k] += dp2[i][j][k] * j / (i + j + k);
					dp[i + 1][j - 1][k] += (K + E) * dp2[i][j][k] * j / (i + j + k);
				}
				if (k >= 1) {
					dp2[i][j + 1][k - 1] += dp2[i][j][k] * k / (i + j + k);
					dp[i][j + 1][k - 1] += (K + E) * dp2[i][j][k] * k / (i + j + k);
				}
			}
		}
	}
	printf("%.12Lf\n", dp[0][0][0]);
	return 0;
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define in(type,a) type a;cin >> a
using ll = long long;

int main() {
    in(int, p);
    in(int, q);
    in(int, r);
    cout << p+q+r-max({p,q,r}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

inline void no_ans()
{
  puts("-1");
  exit(0);
}
const int N = 2e5+1;
int A[N], B[N], n;
inline int mod(int i)
{
  return B[(n-1+i)%n] + B[(i+1)%n];
}
set<ii> st;
inline void insert(int i)
{
  if (B[i] > A[i]) st.insert(mp(B[i], i));
}
int main()
{

  while (~scanf("%d", &n))
    {
      ll ans = 0;  
      for (int i = 0; i < n; ++i) scanf("%d", A+i);
      for (int i = 0; i < n; ++i) scanf("%d", B+i);
      for (int i = 0; i < n; ++i) insert(i);
      while (!st.empty())
	{
	  int i = st.rbegin()->second;
	  st.erase(--st.end());
	  int _mod = mod(i);
	  if (_mod > B[i]) no_ans();
	  int old_bi = B[i];
	  if ((B[i]-A[i])%_mod == 0) B[i] = A[i];
	  else
	    {
	      B[i] %= _mod;
	      insert(i);
	    }
	  ans += (old_bi - B[i]) / _mod;
	}
      for (int i = 0; i < n; ++i) if (A[i] != B[i]) no_ans();
      printf("%lld\n", ans);
    }
}


Measured memory_bytes: 11136
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	  int n;
	  cin>>n;
	  cout<<n*n*n<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Problem 96
    https://atcoder.jp/contests/abc139/tasks/abc139_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    cout << (N - 1) * N / 2 << '\n';
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:usize = read();
    let d:i64 = read();
    let x:i64 = read();
    let a:Vec<i64> = (0..n).map(|_| read()).collect();

    let mut ans:i64 = 0;
    for el in a.iter() {
        let mut cnt:i64 = 0;
        loop {
            if cnt*el + 1 <= d { ans += 1; }
            else { break; }
            cnt += 1;
        }
    }

    println!("{}", ans+x);
    
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		T=1;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			int n;
			cin>>n;
			int arr[n];
			for(int i=0;i<n;i++)
				cin>>arr[i];
			ll prefix[n]={0};
			prefix[n-1]=arr[n-1];
			for(int i=n-2;i>=0;i--)
				prefix[i]=(arr[i]+prefix[i+1])%1000000007;
			/*for(int i=0;i<n;i++)
				cout<<prefix[i]<<" ";*/
			ll sum=0;
			for(int i=0;i<n-1;i++){
				int p=((arr[i]%1000000007)*(prefix[i+1]%1000000007))%1000000007;
				sum=(sum+p)%1000000007;
			}
			cout<<sum;
		}
		return 0;
	}


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



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

        int n = sc.nextInt();
        int[]S = new int[n];
        for(int i=0;i<n;i++){
            S[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] T = new int[q];
        for(int i=0;i<q;i++){
            T[i] = sc.nextInt();
        }

        int count = 0;
        for(int i=0;i<q;i++){
            for(int j=0;j<n;j++){
                if(T[i] == S[j]){
                    count++;
                    break;
                }
            }
        }

        System.out.println(count);
    }    
}


Measured memory_bytes: 69180
import math

def maxLen(a,b):
    return max(len(str(a)),len(str(b)))

n = int(input())

divisors = list()

minLen = 100000

for i in range(1,int(math.sqrt(n)+1)):
    if n % i == 0:
        # The tow divisors 
        a = i
        b = n//i
        if minLen > maxLen(a,b):
            minLen = maxLen(a,b)
print(minLen)
        
    

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    rec = [0]

    for a in A:
        if rec[-1] + 1 == a:
            rec.append(a)

    if rec == [0]:
        print(-1)
    else:
        print(len(A) - len(rec[1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 87376
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        v.push_back(arr[i]);
    }
    sort(arr,arr+n);
    int mid1=arr[(n/2)-1],mid2=arr[n/2];
    for(int i=0;i<n;i++){
        int cur=v[i];
        if(cur<=mid1)
            cout<<mid2<<endl;
        else
            cout<<mid1<<endl;

    }
    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
using namespace std;
int main(){
  string s,t,temp,min;
  bool cleated=false,can_change,no_q=true;
  cin >> s >> t;
  for(int i=0;i<s.length();i++){
    if(s[i]=='?') no_q=false;
    if(s[i]==t[0] || s[i]=='?'){
      can_change=true;
      for(int j=0;j<t.length();j++){
        if((s[i+j]!=t[j]&&s[i+j]!='?')||i+j>s.length()){
          can_change=false;
          break;
        }
      }
        if(can_change==true){
          temp="";
          for(int j=0;j<s.length();j++){
            if(j>=i&&j-i<t.length()){
              temp+=t[j-i];
            }else if(s[j]=='?'){
              temp+='a';
            }else{
              temp+=s[j];
            }
          }
          if(cleated==false){
            min=temp;
            cleated=true;
          }else{
            min = (min<temp)?min : temp;
          }
        }
      }
  }
  if(no_q==true) cout << s<< endl;
  else if(cleated==false) cout <<"UNRESTORABLE"<<endl;
  else cout << min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
long long h,n,a[100007],cnt;
int main(){
	ios::sync_with_stdio(false);
	cin>>h>>n;
	for (int i=1; i<=n; i++) {cin>>a[i]; cnt+=a[i];}
	if (cnt>=h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 1024
inf = input().split()
N = int(inf[0])
M = int(inf[1])
ls = []
m = 0
pair = [0,N]
for i in range(M):
  inf = input().split()
  L = int(inf[0])
  R = int(inf[1])
  pair[0] = max(pair[0], L)
  pair[1] = min(pair[1], R)
  if pair[0]>pair[1]:
    print(0)
    break
else:
  print(pair[1]-pair[0]+1)

Measured memory_bytes: 45288
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    //freopen("test.in");
    int a,b,c;
    cin >> a >> b >> c;
    int d=100*a+10*b+c;
    if (d%4) cout << "NO" << endl;
     else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

struct dijkstra {
  using lli = long long int;
  vector<vector<pair<lli, lli>>> e;
  int n;
  lli inf = 1e18;
  dijkstra(int n) : n(n) { e.resize(n); }
  void add(int a, int b, lli c) { e[a].push_back(make_pair(b, c)); }
  void biadd(int a, int b, lli c) {
    add(a, b, c);
    add(b, a, c);
  }
  vector<lli> get(int s) {
    vector<lli> dist(n, inf);
    dist[s] = 0;
    using p = pair<lli, lli>;
    priority_queue<p, vector<p>, greater<p>> que;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      lli d = que.top().first;
      lli cur = que.top().second;
      que.pop();
      if (dist[cur] < d)
        continue;
      dist[cur] = d;
      for (auto s : e[cur]) {
        lli wei = s.second;
        lli to = s.first;
        if (dist[to] > dist[cur] + wei) {
          dist[to] = dist[cur] + wei;
          que.push(make_pair(dist[cur] + wei, to));
        }
      }
    }
    return dist;
  }
};
void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  dijkstra dij(N);
  rep(i, M) dij.biadd(A[i] - 1, B[i] - 1, 1);
  auto dist = dij.get(0);
  vector<int> ans(N);
  rep(i, N) {
    if (dist[i] > N) {
      cout << "No" << endl;
      return;
    }
  }
  rep(i, N) {
    if (i) {
      for (auto s : dij.e[i]) {
        if (dist[s.first] + 1 == dist[i]) {
          cout << s.first + 1 << endl;
          break;
        }
      }
    } else {
      cout << "Yes" << endl;
    }
  }
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

int main()
{
    int s;
    cin >> s;
    int h, m;
    h = s/3600;
    m = (s-h*3600)/60;
    s = s%60;
    cout << h << ":" << m << ":" << s << endl;;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<vector>
int main ()
{
	long n { 0 },a { 0 },sum { 0 },kq { 0 };
	std::cin >> n;
	std::vector<int> vect (2,0);
	std::cin >> a; sum = a;
	while(--n > 0)
	{
		std::cin >> a;
		kq += sum * a;
		sum += a;
	}
	std::cout << kq;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a[10000] = { 0 }, b[10000] = { 0 }, c[10000] = { 0 };
	int n;
	int d[10000], e[10000], f[10000], g[10000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
		d[i] = a[i] * a[i];
		e[i] = b[i] * b[i];
		f[i] = c[i] * c[i];
		g[i] = d[i] + e[i] + f[i];
	}
	for (int j = 0; j < n; j++) {
		if (g[j] == 2*d[j] || g[j] == 2*e[j] || g[j] == 2*f[j]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main(){
    int students[30];
    int n;
    for(int i=0;i<30;i++){
        students[i] = 1;
    }
    for(int i=0;i<28;i++){
        cin >> n;
        students[n-1] = 0;
    }
    for(int i=0;i<30;i++){
        if(students[i]){
            cout << i+1 << endl;
        }
    }
}

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

int main() {
  string S;
  cin >> S;
  
  if(S[0]==S[1]){
    cout << "Bad" << endl;
    }
  else if(S[1]==S[2]){
    cout << "Bad" << endl;
    }
  else if(S[2]==S[3]){
    cout << "Bad" << endl;
    }
  else{
    cout << "Good" << endl;
  }
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = b;
  if(a >= 6 && a <= 12) ans /= 2;
  else if(a <= 5) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

#define LOCAL  1
#define UPLOAD 2

#define ll long long
const long long INF = 1LL << 60;

template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

const long long mod=1e9+7;
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  vector<ll> h;
  ll K = input();

  for(int i=0;i<N;i++){
    h.push_back(input());
  }
  
  vector<ll> dp;
  dp.resize(N+1, INF);
  
  dp[0] = 0;
  for(int i=1;i<=N;i++){
    for(int k=1;k<=K;k++){
      if(i-k < 0)continue;
      chmin(dp[i], dp[i-k]+abs(h[i]-h[i-k]));
    }
  }

  output(dp[N-1]);

  return 0;
}

Measured memory_bytes: 1908
N,D = map(int,input().split())
X = [list(map(int,input().split())) for l in range(N)]
import numpy as np
X = np.array(X)
ans = 0
for i in range(N):
    for j in range(i,N):
        if(i!=j):
            dis = np.sqrt(sum((X[i] - X[j])**2))
            if(dis.is_integer()):
                ans += 1
                
print(ans)

Measured memory_bytes: 12492