akhauriyash/Code-Regression huggingface dataset:
import random
import numpy
import sys

grid=[[0 for i in range(3)] for j in range(3)]
a = [0 for i in range(3)]
b = [0 for i in range(3)]
testgrid = [[0 for i in range(3)] for j in range(3)]

grid[0]=list(map(int, input().split(" ")))
grid[1]=list(map(int, input().split(" ")))
grid[2]=list(map(int, input().split(" ")))

for a[0] in range(100):
  for b[0] in range(100):
    if (a[0]+b[0]) == grid[0][0]:
      testgrid[0][0] = a[0]+b[0]
      b[1] = grid[0][1]-a[0]
      b[2] = grid[0][2]-a[0]
      testgrid[0][1] = a[0]+b[1]
      testgrid[0][2] = a[0]+b[2]
      if testgrid[0] == grid[0]:
        a[1] = grid[1][0]-b[0]
        testgrid[1][0] = a[1]+b[0]
        testgrid[1][1] = a[1]+b[1]
        testgrid[1][2] = a[1]+b[2]
        if testgrid[1] == grid[1]:
          a[2] = grid[2][0]-b[0]
          testgrid[2][0] = a[2]+b[0]
          testgrid[2][1] = a[2]+b[1]
          testgrid[2][2] = a[2]+b[2]
          if testgrid == grid:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 19964
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
arr=[[] for i in range(n)]
for i in range(m):
    x,y=mii()
    arr[x-1].append(y-1)
chk=False

for i in arr[0]:
    if n-1 in arr[i]:
        print("POSSIBLE")

        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 87112
C=[list(map(int,input().split())) for _ in range(3)]

for i in range(1,3):
  if C[i][0]-C[0][0]==C[i][1]-C[0][1] and C[i][0]-C[0][0]==C[i][2]-C[0][2]:
    pass
  else:
    print("No")
    exit()
    
print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main() {
	string s;
	cin >> s;
	if (s.size() < 4)puts("No");
	else if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I')puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, K; cin >> N >> K;
    string s; cin >> s;
    
    vector<int> vCL; // continuous length
    for(int i=0; i<N; ++i){
        uint len=1;
        while(i<N-1 && s[i]==s[i+1]){ ++len; ++i; }
        vCL.push_back(len);
    }
    
    vector<int> vCSum(vCL.size()); // cumulative sum
    vCSum[0] = vCL[0];
    for(int i=1; i<(int)vCL.size(); ++i){
        vCSum[i] = vCSum[i-1] + vCL[i];
    }
    
    int begin;
    int end = s[0]=='0' ? 2*K-1 : 2*K; end=min(end, (int)vCSum.size()-1);
    int maxLen = vCSum[end];
    begin = s[0]=='0' ? 0 : 1;
    end += 2; end = min(end, (int)vCSum.size()-1);
    for(int i=2; i<(int)vCSum.size(); i+=2){
        maxLen = max(maxLen, vCSum[end] - vCSum[begin]); // (begin, end]
        
        begin += 2;
        end   += 2; end=min(end, (int)vCSum.size()-1);
    }
    cout << maxLen << endl;
    
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  ll n, k;
  cin >> n >> k;
  ll a, b;
  a = b = 0;
  for (ll i = 1; i <= n; i++) {
    if (i%k == 0) a++;
    if (k%2 == 0) {
      if (i%k == k/2) b++;
    }
  }
  dump(a*a*a + b*b*b);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a=0,b=0,sum=1;
  cin>>n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i=0; i<n-1; i++){
    if(vec.at(i)!=vec.at(i+1)){sum++;}
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;
vector<int>Sieve(int n)
{
    vector<int>v;
	bool prime[n+1];
	memset(prime, true, sizeof(prime));

	for (int p=2; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i += p)
				prime[i] = false;
		}
	}
	for (int p=2; p<=n; p++)
	if (prime[p])
		v.push_back(p);
    return(v);
}
int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int a[60001]={};
 int v;
 for(int x=1;x<=100;x++)
 {
     for(int y=1;y<100;y++)
     {
         for(int z=1;z<100;z++)
         {
            v=x*x+y*y+z*z+x*y+y*z+z*x;
            a[v]++;
         }
     }
 }
 int n;
 cin>>n;
 for(int i=0;i<n;i++)
    cout<<a[i+1]<<endl;

return(0);
}


Measured memory_bytes: 3868
#include <iostream>

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

   int ns = S.size();
   int nt = T.size();
   bool flag = true;
   for(int i=ns-1; i>=ns-nt; --i){
      if(S[i]!='?'){
	 flag = false;
	 break;
      }
   }
   if(flag){
      for(int i=0; i<ns; ++i){
	 if(i<ns-nt){
	    if(S[i]=='?') std::cout << 'a';
	    else std::cout << S[i];
	 }else std::cout << T[i-ns+nt]; 
      }
      std::cout << std::endl;
      return 0;
   }
   for(int i=ns-nt; i>=0; --i){
      flag = true;
      for(int j=0; j<nt; ++j){
	 if(!(S[i+j]==T[j] || S[i+j]=='?')){
	    flag = false;
	    break;
	 }
      }
      if(flag){
	 for(int j=0; j<ns; ++j){
	    if(j<i || j>i+nt-1){
	       if(S[j]=='?') std::cout << 'a';
	       else std::cout << S[j];
	    }else{
	       std::cout << T[j-i];
	    }
	 }
	 std::cout << std::endl;
	 return 0;
      }
   }
   std::cout << "UNRESTORABLE" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
    int x,k,a,b,i;
    cin>>x;
    map<int,int>mp;
    for(i=1;i<=100;i++){
        if(i*i*i*i*i==x){cout<<i<<" 0";return 0;}
    }i=-101;
    while(1){
        a=i*i*i*i*i;
    mp[a]=i;
    k=a-x;
    if(mp[k]){cout<<i<<" "<<mp[k];return 0;}
    i++;
    }
    return 0;
}

Measured memory_bytes: 3588
N,M,K = map(int,input().split())
ans = "No"

for a in range(N+1):
  if N - 2*a != 0:
    if (K - a*M) % (N - 2*a) == 0:
      if M >= (K - a*M) / (N - 2*a) >= 0:
        ans = "Yes"
print(ans)

Measured memory_bytes: 61988
from sys import stdin
N, X, Y = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]

ans = [0]*N


for i in range(1, N+1):
    for j in range(i+1, N+1):
        d = min(j-i, abs(i-X)+1+abs(Y-j))
        ans[d] += 1
        #ans.append(j-i)
        #print(min(j-i, abs(i-X)+1+abs(Y-j)), i, j)

#print(N)
for k in range(1, N):
    print(ans[k])


Measured memory_bytes: 46300
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll a;
	double d;
	cin >> a >> d;
	ll b = round(d * 100);
	ll res = (a * b)/100;
	cout << res << '\n';
}


Measured memory_bytes: 3776
import numpy as np
n = int(input())
c = []
for _ in range(n):
    x, y = map(int, input().split())
    c.append((x, y))

s = 0
for i in range(n):
    for j in range(n):
        xi, yi = c[i]
        xj, yj = c[j]
        d = np.sqrt((xi - xj)**2 + (yi - yj)**2)
        s += d
print(s / n)


Measured memory_bytes: 21652
//package atcoder// TODO: ←消す

fun main(args: Array<String>) = ABC161B.main()

object ABC161B {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (N, M) = readInts()
        val A = readInts()

        val voteSum = A.sum()
        val goodItems = A.filterNot { 4 * it * M < voteSum }
        val ans = (M <= goodItems.size).yesOrNo()
        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 38000
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M, a;
  cin >> N >> M;
  VI A(N+1, 0);
  REP2(i, 1,  N+1)
  {
    cin >> a;
    A.at(i) = (A.at(i-1) + a) % M;
  }
  ll ans = 0;
  map<ll, ll> ct;
  REP(i, N+1)
  {
    if (ct.count(A.at(i)))
    {
      ans += ct.at(A.at(i));
      ct.at(A.at(i))++;
    }
    else ct[A.at(i)] = 1;
  }
  cout << ans << endl;

  return 0;
}

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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template <class Z> Z getint() {
  char c = getchar();
  bool neg = c == '-';
  Z res = neg ? 0 : c - '0';
  while (isdigit(c = getchar())) res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class Z> void putint(Z a, char c = '\n') {
  if (a < 0) putchar('-'), a = -a;
  int d[40], i = 0;
  do d[i++] = a % 10; while (a /= 10);
  while (i--) putchar('0' + d[i]);
  putchar(c);
}

template <class T, class Op, class Inv> struct weighted_dsu {
  const Op op;
  const T e;
  const Inv inv;
  vector<int> p, sz;
  vector<T> d;
  weighted_dsu(int n, Op _op, T _e, Inv _inv) :
    op(_op), e(_e), inv(_inv), p(n, -1), sz(n, 1), d(n, e) {}
  pair<int, T> root(int v) const {
    T a = e;
    while (p[v] != -1) a = op(a, d[v]), v = p[v];
    return {v, a};
  }
  void unite(int u, int v, T w) {
    T du, dv;
    tie(u, du) = root(u), tie(v, dv) = root(v);
    assert(u != v);
    if (sz[u] < sz[v]) swap(u, v), swap(du, dv), w = inv(w);
    p[v] = u;
    sz[u] += sz[v];
    d[v] = op(op(du, w), inv(dv));
  }
  T diff(int u, int v) const {
    T du, dv;
    tie(u, du) = root(u), tie(v, dv) = root(v);
    assert(u == v);
    return op(dv, inv(du));
  }
  bool same(int u, int v) const { return root(u).first == root(v).first; }
  int size(int v) const { return sz[root(v).first]; }
};
template <class T, class Op, class Inv>
auto make_weighted_dsu(int n, Op op, T e, Inv inv) {
  return weighted_dsu<T, Op, Inv>(n, op, e, inv);
}

int main() {
  int n = getint<int>();
  int q = getint<int>();
  auto wd = make_weighted_dsu(n, plus<int>(), 0, negate<int>());
  while (q--) {
    if (getint<int>() == 0) {
      int u = getint<int>();
      int v = getint<int>();
      int w = getint<int>();
      if (wd.same(u, v)) {
        assert(wd.diff(u, v) == w);
      } else {
        wd.unite(u, v, w);
      }
    } else {
      int u = getint<int>();
      int v = getint<int>();
      if (wd.same(u, v)) {
        putint(wd.diff(u, v));
      } else {
        putchar('?');
        putchar('\n');
      }
    }
  }
}



Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		char[] c = sc.next().toCharArray();

		int i = 0;
		int j = 0;
		int k = 0;

		int an = a.length;
		int bn = b.length;
		int cn = c.length;

		char s = a[i++];
		while (i <= an && j <= bn && k <= cn) {
			if (s == 'a') {
				if (i == an) {
					System.out.println("A");
					break;
				}
				s = a[i++];
			} else if (s == 'b') {
				if (j == bn) {
					System.out.println("B");
					break;
				}
				s = b[j++];
			} else {
				if (k == cn) {
					System.out.println("C");
					break;
				}
				s = c[k++];
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


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



public class Main {

	private static final int BIG_NUM  = 2000000000;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long sum = 0;
		int minimum = BIG_NUM,maximum = -BIG_NUM;

		try {

			int N = Integer.parseInt(br.readLine());

			String first[] = br.readLine().split("[\\s]+");
			int array[] = new int[first.length];

			for(int i = 0; i < first.length; i++){

				array[i] = Integer.parseInt(first[i]);
				minimum = Math.min(minimum, array[i]);
				maximum = Math.max(maximum, array[i]);
				sum += array[i];
			}

			System.out.printf("%d %d %d\n",minimum,maximum,sum);

		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}




Measured memory_bytes: 31676
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n, m] <- readInt
  s      <- map (\(k : ss) -> (k, ss)) <$> readInts m
  p      <- readInt
  print $ solve n m s p

solve n m s p = a
 where
  bits   = replicateM n [True, False]
  lights = zipWith (\(k, s) p -> (k, p, s)) s p
  a      = length $ filter and $ map (\b -> map (\l -> f b l) lights) bits

f bit (k, p, ss) =
  (length $ filter (== True) $ map (\s -> bit !! (s - 1)) ss) `mod` 2 == p


Measured memory_bytes: 1020
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t result = 0;
  for (int64_t a = 1; a <= N-1; ++a) {
    int64_t max_b = (N-1) / a;
    result += max_b;
    // cerr << max_b << endl;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

string s;

signed main()
{
    cin >> s;
    int a = 0, b = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            a++;
        }
        else b++;
    }
    cout << min(a, b) * 2 << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
const double inf = 1e18;
struct e{
    int x, y;
    char p;
}a[maxn];
int n;
double F(double mid)
{
    double maxx = -inf, minx = inf, maxy = -inf, miny = inf;
    for (int i = 0; i < n; ++i){
        double xx = a[i].x, yy = a[i].y;
        if(a[i].p == 'L') xx-=mid;
        else if(a[i].p == 'R') xx+=mid;
        else if(a[i].p == 'U') yy+=mid;
        else yy-=mid;
        minx = min(minx, xx);
        maxx = max(maxx, xx);
        miny = min(miny, yy);
        maxy = max(maxy, yy);
    }
    return (maxx - minx) * (maxy - miny);
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a[i].x >> a[i].y >> a[i].p;
    }
    double l = 0, r = 1e8;
    for (int i = 0; i < 100; ++i){
        double len = (r - l) / 3;
        double lmid = l + len, rmid = l + 2 * len;
        if (F(lmid) < F(rmid)) r = rmid;
        else l = lmid;
    }
    cout << fixed << F((l + r) / 2) << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int f(int x,int r,int d) {
  return r*x-d;
}
int main(){
  int r,d,x; cin>>r>>d>>x;
  int s=x;
  rep(i,10){
    cout<<f(s,r,d)<<endl;
    s=f(s,r,d);
  }


}


Measured memory_bytes: 256
S=[int(input()) for i in range(5)]
K=int(input())

def antenna(s,k):
    while True:
        for i in range(5):
            for j in range(5):
                if i!=j:
                    if abs(s[i]-s[j])>k:
                        return ':('
        return 'Yay!'

print(antenna(S,K))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define dbl double
#define pi acos(-1)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pb push_back

ll ara[1000005];

map<ll,ll>vis;
map<ll,ll>vis1;
map<ll,ll>pos;
map<ll,ll>high;
map<ll,ll>low;
map<string,ll>mp;
vector<ll>vec;
vector<ll>v;
stack<ll>q;
string str1[100];
string str2[100];
priority_queue<ll>pq;
ll dp[1000005],t,k;
ll mn=1000000;
ll call(ll id)
{
    if(id==t )
        return 0;
    if(dp[id]!=-1)
        return dp[id];
    for(ll i=1; i<=k; i++)
    {
        ll p=10000000;
        if(id+i<=t)
            p=call(id+i)+abs(ara[id+i]-ara[id]);
        if(dp[id]==-1)
            dp[id]=p;
        else
            dp[id]=min(p,dp[id]);
    }
    return dp[id];

}
int main()
{

    // ll t;
    memset(dp,-1,sizeof(dp));
    sc2(t,k);
    for(ll i=1; i<=t; i++)
    {
        sc1(ara[i]);
    }
    cout<<call(1)<<endl;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n, m, x;
vi c;
vi US;
vvi a;
int ans = INT_MAX;

void dfs(int cnt = -1, int sum = 0, vi US = vi(m, 0), int choice = -1){
    if(cnt == n){
        bool ok = true;
        rep(i, m) if(US[i] < x) ok = false;
        if(ok) ans = min(ans, sum);
        return;
    }
    else{
        if(choice == 1){
            sum += c[cnt];
            rep(i, m) US[i] += a[cnt][i];
        }
        cnt++;
        dfs(cnt, sum, US, 0);
        dfs(cnt, sum, US, 1);
    }
}

void Main(){
    cin >> n >> m >> x;
    c = vi(n);
    a = vvi(n, vi(m));
    US = vi(m, 0);

    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    
    // dfs で 2^n 通りを全探索
    dfs();
    if(ans == INT_MAX) cout << -1 << endl;
    else cout << ans << endl;
    return;
}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
#define pi acos(-1)
using namespace std;
int main()
{
    ll n,m,i,j,k,l,x,y,t;

    k=0;

    string s;

    cin>>s;

    x=0;

    for(i=0; i<3; i++)
    {

        if(s[i]=='R')
        {
            x++;
            k=max(k,x);
        }
        else
        {
            k=max(k,x);
            x=0;
        }
    }

    cout<<k<<endl;


}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;



int main() {
	long long n, m; cin >> n >> m;

	long long a[100000], b[100000];

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

	map<long long,long long> mp;

	for (int i = 0; i < n; i++) {
		mp[a[i]] += b[i];
	}
	long long ans = 0;
	for (pair<long long, long long> x : mp) {
		if (x.second <= m) {
			m -= x.second;
			ans += x.first * x.second;
		}
		else {
			ans += x.first * m;
			break;
		}
	}

	cout << ans << endl;









}

Measured memory_bytes: 8064
import itertools as it

a,b,c = map(int,input().split())
k = int(input())

allcase = list(it.product([0,1,2,3],repeat=k))

for case in allcase:
  nums = [a,b,c]
  for step in case:
    if step == 3:
      continue
    nums[step] *= 2
  if nums[0] < nums[1] and nums[1] < nums[2]:
    print('Yes')
    exit()
print('No')

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

int main()
{
  int h, w;
  cin >> h >> w;

  string c;
  for( int i = 0; i < h; i++ ) {
    cin >> c;
    cout << c << endl;
    cout << c << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String args[]){
    	Scanner str =new Scanner(System.in);
    	StringBuffer buf =new StringBuffer();
        int[] num={};
        int count =0;
        int sum =0;
    	    int a = str.nextInt();
    	    int b = str.nextInt();
    	    int c = str.nextInt();
    	    for (int i=1;i<= c;i++){
    	    	if(c%i==0){
    	    		if(a<=i&&i<=b){
    	    			sum++;
    	    		}
    	    	}
    	    }

    	System.out.println(sum);
    }
}

Measured memory_bytes: 26284
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        System.out.println(N < 10 && M < 10 ? N * M : -1);
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#define N 100005
using namespace std;
typedef long long ll;
struct P{
	int x,y,id;
}a[N<<1];
int R,C,n,l[N],r[N],m,cnt=0;
ll w[N],sum[N<<3];
pair<int,int> b[N<<3];
bool pan(int x,int y){
	if(!x||!y||x==R||y==C) return 1;
	return 0;
}
int calc(P x){
	if(!x.x) return C-x.y;
	if(x.x==R) return R+C+x.y;
	if(!x.y) return C+x.x;
	if(x.y==C) return (R-x.x)+C+C+R;
}
int main(){
	scanf("%d%d%d",&R,&C,&n);
	int o=n;n=0;
	for(int i=1,x1,y1,x2,y2;i<=o;i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(!pan(x1,y1)||!pan(x2,y2)) continue;
		m++;
		a[n+1].x=x1;a[n+1].y=y1;a[n+1].id=(n+2)/2;
		a[n+2].x=x2;a[n+2].y=y2;a[n+2].id=(n+2)/2;
		l[m]=calc(a[n+1]);
		r[m]=calc(a[n+2]);
		if(l[m]>r[m]) swap(l[m],r[m]);
		n+=2;
	}
	for(int i=1;i<=m;i++) w[i]=1LL*rand()*rand();
	int tot=0;
	for(int i=1;i<=m;i++){
		b[i]=make_pair(l[i],-i);
		b[i+m]=make_pair(r[i],i);
	}
	sort(b+1,b+m+m+1);
	for(int i=1;i<=m+m;i++){
		if(i==1||b[i].first!=b[i-1].first) cnt++;
		if(b[i].second<0) l[-b[i].second]=cnt;
		else r[b[i].second]=cnt;
	}
	for(int i=1;i<=m;i++) sum[l[i]]^=w[i],sum[r[i]]^=w[i];
	for(int i=1;i<=cnt;i++) sum[i]^=sum[i-1];
	for(int i=1;i<=m;i++){
		if(sum[r[i]]^sum[l[i]-1]) return puts("NO"),0;
	}
	puts("YES");
	return 0;
}

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

using namespace std;

int main()
{
    int n , rem;

    cin>>n;
    while(n)
    {   
        rem = n%10;
        n = n / 10;
        if(rem==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 300050;
long long N, A, B;

long long num[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> A >> B;
    
    if (A + B - 1 > N) {
        std::cout << -1 << std::endl;
        return 0;
    } else if (A * B < N) {
        std::cout << -1 << std::endl;
        return 0;
    }

    num[1] = B;
    if (2 <= A) {
        int rest = N - B;
        for (int i = 2; i <= A; i++) {
            num[i] = rest / (A - 1);
        }
        for (int j = 1; j <= rest % (A - 1); j++) {
            num[1 + j]++;
        }
    }
    
    int tmp_base = 0;
    for (int i = 1; i <= A; i++) {
        for (int j = num[i]; 1 <= j; j--) {
            std::cout << tmp_base + j << " ";
        }
        tmp_base += num[i];
    }

    std::cout << std::endl;
    
    return 0;

}

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

i = N - 1
while i > 0:
  if H[i-1] > H[i] + 1:
    print('No')
    break
  if H[i-1] == H[i] + 1:
    H[i-1] -= 1
  i -= 1
if i==0:
  print('Yes')

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a, b;
    int size, count;
    cin >> a >> b;
    size = a.length();
    count = 0;
    for (int i = 0; i < size; i++)
    {
        char c, d;
        c = a[i];
        d = b[i];
         if (c==d)
        {
            //cout << c << d << "/n" << endl;
            count++;
        }
    }
    if(count == size)
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n)
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of each digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of digits
	unsigned digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	string a, b;
	cin >> a >> b;

	if (a.size() < b.size()) {
		cout << "LESS" << rt;
		return 0;
	}
	else if (a.size() > b.size()) {
		cout << "GREATER" << rt;
		return 0;
	}

	else {
		rep(i, a.size()) {
			if ((int)a[i] > (int)b[i]) {
				cout << "GREATER" << rt;
				return 0;
			}
			else if ((int)a[i] < (int)b[i]) {
				cout << "LESS" << rt;
				return 0;
			}
		}
	}
	cout << "EQUAL" << rt;

	please AC;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int s=0,n,b;
	string ss;
	cin>>n;
	while(n--){
		cin>>b>>ss>>b;
		if(ss[0]=='(')s-=b;
		else s+=b;
		if(!s)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3168
#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 = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(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 n; cin >> n ;
    vector<ll> A(n); rep(i, n) cin >> A[i];

    ll sum_xor = 0;
    rep(i, n){
        sum_xor = sum_xor ^ A[i];
    }
    vector<ll> res(n);
    rep(i, n){
        res[i] = sum_xor ^ A[i];
    }
    rep(i, n){
        cout << res[i] << " ";
    }
    cout << ln;
}


Measured memory_bytes: 6336
#include <iostream>
using namespace std;
  
#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
  
bool same(int d[][6],int q,int r){
 int tmp,cnt,j,a=1,i,k;
 check if(cnt==6)a=0;
  
 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check if(cnt==6)break;
    m
   }
   check if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  if(cnt==6)break;
  y y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  a=0;
 }
  
 if(cnt==6)return true;
 return false;
}

int main(){
 int n,judge=0;
 cin >> n;
 int d[n][6];
  
 for(int i=0;i<n;i++){
  for(int j=0;j<6;j++){
   cin >> d[i][j] ;
  }
 }
  
 for(int q=0;q<n-1;q++){
  for(int r=q+1;r<n;r++){
  if(same(d,q,r))judge++;
  }
 }

 if(judge>0)cout << "No" << endl ;
 else cout << "Yes" << endl ;
  
 return 0;
}

Measured memory_bytes: 3088
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		ll c[2]={},a;

		for(int i=0;i<3;i++){
			cin >> a;
			if(a==5){
				c[0]++;
			}else if(a==7){
				c[1]++;
			}
		}

		if(c[0]==2&&c[1]==1){
			cout << "YES" << endl;
		}else{
			cout << "NO" <<endl;
		}

		
		return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	while(1)
	{
		int card[14]={0};
		bool two=0,two2=0,three=0,four=0,strate=0;
		for(int i=0;i<5;i++)
		{
			int temp;
			if(scanf("%d,",&temp)==EOF)
				return 0;
			card[temp]++;
		}
		for(int i=1;i<14;i++)
		{
			if(card[i]==2)
			{
				if(two)
					two2=true;
				else
					two=true;
			}
			else if(card[i]==3)
				three=true;
			else if(card[i]==4)
				four=true;
			else if(i+5<14)
			{
				bool flag=false;
				for(int j=0;j<5;j++)
				{
					if(card[i+j]!=1)
					{
						flag=true;
						break;
					}
				}
				if(!flag)
					strate=true;
			}
		}
		if(four)
			printf("four card\n");
		else if(two && three)
			printf("full house\n");
		else if(card[1]==1&&card[10]==1&&card[11]==1&&card[12]==1&&card[13]==1 || strate)
			printf("straight\n");
		else if(three)
			printf("three card\n");
		else if(two && two2)
			printf("two pair\n");
		else if(two)
			printf("one pair\n");
		else
			printf("null\n");
	}
	return 0;
}

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

int main()
{

    int n;
    long long int sum=0;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        if (i%3 == 0 || i %5 ==0 || i % 15 ==0)
        {

        }
        else{
            sum+=i;
        }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n;
	cin>>n;
	if(n>=400&&n<=599)
	{
		cout<<8;
	}
	else if(n>=600&&n<=799)
	{
		cout<<7;
	}
	else if(n>=800&&n<=999)
	{
		cout<<6;
	}
	else if(n>=1000&&n<=1199)
	{
		cout<<5;
	}
	else if(n>=1200&&n<=1399)
	{
		cout<<4;
	}
	else if(n>=1400&&n<=1599)
	{
		cout<<3;
	}
	else if(n>=1600&&n<=1799)
	{
		cout<<2;
	}
	else if(n>=1800&&n<=1999)
	{
		cout<<1;
	}
	return 0;
}

Measured memory_bytes: 3644
import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res

x = readInt()

for a in range(-120,120):
	for b in range(-120,120):
		if a**5-b**5==x:
			print(a,b)
			exit()

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1e5 + 100;

ll A[N] , B[N] , C[N];
ll fin[3*N];

int main(){
	fio; cout<<fixed<<setprecision(25);	
	int x , y , a , b , c;
	cin >> x >> y >> a >> b >> c;
	for(int i = 0; i < a ; ++i){
		cin >> A[i];
		A[i] *= -1;
	}
	for(int i = 0; i < b ; ++i){
		cin >> B[i];
		B[i] *= -1;
	}
	for(int i = 0; i < c ; ++i){
		cin >> C[i];
		C[i] *= -1;
	}
	sort(A , A+a);
	sort(B , B+b);
	sort(C , C+c);
	int curr = 0;
	for(int i = 0;i < min(a ,x) ; ++i){
		fin[curr++] = A[i];
	}
	for(int i = 0;i < min(b , y) ; ++i){
		fin[curr++] = B[i];
	}
	for(int i = 0;i < c ; ++i){
		fin[curr++] = C[i];
	}
	sort(fin , fin+curr);
	ll ans = 0;
	for(int i = 0; i < x+y ; ++i){
		ans += fin[i];
	}
	cout << -1*ans << endl;












	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n,m;vector<Pii> e[N];bool vis[N],a[N],b[N];
bool ok,exi;int tote;int cnt[3],col[N];ll res;
void dfs(int u, int x){
	vis[u]=1;col[u]=x;cnt[x]++;exi|=a[u]&&b[u];
	rep(i,0,SZ(e[u])-1){
		tote++;
		if(!vis[e[u][i].fi])dfs(e[u][i].fi,(x+e[u][i].se)%3);
		else ok|=(col[u]+e[u][i].se-col[e[u][i].fi])%3>0;
	}
}
int main() {
	read(n);read(m);
	while(m--){
		int u,v;read(u);read(v);a[u]=1;b[v]=1;
		e[u].pb(Pii(v,1));e[v].pb(Pii(u,2));
	}
	rep(i,1,n)if(!vis[i]){
		ok=0;exi=0;tote=0;rep(j,0,2)cnt[j]=0;
		dfs(i,0);int all=cnt[0]+cnt[1]+cnt[2];
		if(!ok){
			if(exi){
				res+=1LL*all*(all-1)/2;
				rep(j,0,2)res-=1LL*cnt[j]*(cnt[j]-1)/2;
			}
			else res+=tote/2;
		}
		else res+=1LL*all*all;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
 
string S, T;
 
int main(void) {
  cin >> S >> T;
 
  vector<string> ans;
  REP(i, 0, S.length() - T.length() + 1) {
    bool f = true;
    REP(j, 0, T.length()) f = f && (S[i + j] == T[j] || S[i + j] == '?');
    if(f) {
      string s = S;
      REP(j, 0, T.length()) s[i + j] = T[j];
      REP(j, 0, s.length()) if(s[j] == '?') s[j] = 'a';
      ans.push_back(s);
    }
  }
 
  sort(ans.begin(), ans.end());
  if(ans.size() > 0) cout << ans[0] << endl;
  else cout << "UNRESTORABLE" << endl;
}

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

using namespace std;

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

    int N;

    cin >> N;

    vector<int> d(N);

    for(int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

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

    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


def getDistanceSP(segment, point):
    p = point
    p1, p2 = segment
    if (p2 - p1).dot(p - p1) < 0:
        return abs(p - p1)
    if (p1 - p2).dot(p - p2) < 0:
        return abs(p - p2)
    return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)


def getDistance(s1, s2):
    a, b = s1
    c, d = s2
    if intersect(s1, s2):  # intersect
        return 0
    return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))


def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if a.cross(b) > 0:
        return 1  # COUNTER_CLOCKWISE
    elif a.cross(b) < 0:
        return -1  # CLOCKWISE
    elif a.dot(b) < 0:
        return 2  # ONLINE_BACK
    elif abs(a) < abs(b):
        return -2  # ONLINE_FRONT
    else:
        return 0  # ON_SEGMENT


def intersect(s1, s2):
    a, b = s1
    c, d = s2
    return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0


def getCrossPoint(s1, s2):
    a, b = s1
    c, d = s2
    base = d - c
    d1 = abs(base.cross(a - c))
    d2 = abs(base.cross(b - c))
    t = d1 / (d1 + d2)
    return a + (b - a) * t


if __name__ == '__main__':

    n = int(input())

    for _ in range(n):
        l = list(map(int, input().split()))
        s1 = [Vector2(l[0], l[1]), Vector2(l[2], l[3])]
        s2 = [Vector2(l[4], l[5]), Vector2(l[6], l[7])]

        x = getCrossPoint(s1, s2)
        print(x.x, x.y)



Measured memory_bytes: 6172
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int H, W;
char grid[51][51];

struct Data {
    int id, top, left, down, right;
    Data() {
        id = -1;
        top = left = -1;
        down = right = 100;
    }
};

bool Loop(int dst, int src, const vector<vector<int>> &g,
          vector<bool> &visit)
{
    if (dst == src)
        return true;

    if (visit[src])
        return false;

    visit[src] = true;
    for (unsigned i = 0; i < g[src].size(); ++i) {
        if (Loop(dst, g[src][i], g, visit))
            return true;
    }

    return false;
}

bool Solve()
{
    unordered_map<char, Data> hash;
    int id = 0;

    // 登録
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            if (grid[i][j] != '.') {
                char c = grid[i][j];

                if (hash.count(c) == 0) {  // 未登録
                    hash[c].id = id++;
                    hash[c].top = hash[c].down = i;
                    hash[c].left = hash[c].right = j;
                }
                else { // 登録済み
                    hash[c].top = min(hash[c].top, i);
                    hash[c].down = max(hash[c].down, i);
                    hash[c].left = min(hash[c].left, j);
                    hash[c].right = max(hash[c].right, j);
                }
            }

    vector<vector<int>> g(id, vector<int>());
    // 長方形の確認
    auto it = hash.begin();
    while (it != hash.end()) {
        for (int y = it->second.top; y <= it->second.down; ++y)
            for (int x = it->second.left; x <= it->second.right; ++x) {
                int src = it->second.id;

                if (grid[y][x] == '.')
                    return false;
                else if (grid[y][x] != it->first &&
                         count(g[src].begin(), g[src].end(),
                               hash[grid[y][x]].id) == 0)
                    g[src].push_back(hash[grid[y][x]].id);
            }
        ++it;
    }

    // ループが存在するかのチェック
    for (unsigned i = 0; i < g.size(); ++i) {
        vector<bool> visit(id, false);
        visit[i] = true;

        for (unsigned j = 0; j < g[i].size(); ++j)
            if (Loop(i, g[i][j], g, visit))
                return false;
    }

    return true;
}

int main()
{
    int T;

    cin >> T;
    while (T--) {
        cin >> H >> W;

        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                cin >> grid[i][j];

        if (Solve())
            cout << "SAFE\n";
        else
            cout << "SUSPICIOUS\n";
    }

    return 0;
}

Measured memory_bytes: 1184
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    while True:
        h, w = ZZ()
        if h == 0 and w == 0: break
        for i in range(h): print('#' * w)
        print('')

    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 5624