akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int a,b,c;
int i[1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[1000];
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>s[n];
  for(int n=0;n<a;n++) cout <<s[n]<<'\n'<<s[n]<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b;
    string s;
    cin>>a>>s>>b;
    if(s=="+") cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define pb push_back
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define _max(v) *max_element(v.begin(), v.end())
#define _min(v) *min_element(v.begin(), v.end())

int main() 
{
    io;
    vector<ll> v;
    ll x,n, ans=0; cin >> n;
    rep(i,0,n) {cin >> x; v.pb(x); }
    rep(i,0,n-1){if(v[i+1]<v[i]) {ans+=v[i]-v[i+1]; v[i+1]=v[i];}}
    //rep(i,0,n) cout<< v[i] << " ";
//    cout << endl;
    if(n==1) cout<< 0<<endl;
    else    cout<< ans<< endl;
	return 0;
}


Measured memory_bytes: 5312
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll quick_pow(ll a,int times)
{
    ll res=1;
    while(times)
    {
        if(times&1) res=(res*a)%mod;
        a=(a*a)%mod; times>>=1;
    }
    return res;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll ans=quick_pow((ll)10,n);
    ans=(ans-quick_pow((ll)9,n)*2%mod+mod)%mod;
    ans=(ans+quick_pow((ll)8,n))%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1736
H,W,M = map(int, input().split())
# grid = [[0 for _ in range(W)] for _ in range(H)]
bombs = set()

hc = [0 for h in range(H)]
wc = [0 for w in range(W)]

for _ in range(M):
    h,w = map(int, input().split())
    h-=1
    w-=1
    bombs.add((h, w))
    hc[h] += 1
    wc[w] += 1

hmax = max(hc)
wmax = max(wc)

htable = []
for h in range(H):
    if hc[h] == hmax:
        htable.append(h)

wtable = []
for w in range(W):
    if wc[w] == wmax:
        wtable.append(w)

# print(uw, uh)
#print(grid)
#print(wc, uw)
#print(hc, uh)

found = False
for h in htable:
    for w in wtable:
        if (h,w) not in bombs:
            print(hmax + wmax)
            exit(0)

print(hmax + wmax - 1)

Measured memory_bytes: 156548
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int=parseInt(readline())
    a::Vector{Int}=parseMap(split(readline()))
    cnt::Vector{Int}=[0 for i in 1:10^6]
    for i in a
        cnt[i]+=1
    end
    ans::Int=0
    for i in a
        flag::Bool=true
        for j in 1:trunc(Int,sqrt(i))+1
            if i%j==0 && i>j
                if cnt[j]>0 || cnt[i÷j] > Int(j==1)
                    flag=false
                    break
                end
            end
        end
        if cnt[i]>1
            flag=false
        end
        if flag
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 204340
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt

readString = map BS.unpack . BS.words

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getString = readString <$> BS.getLine

checkRock :: Array Int Char -> Int -> Int -> Char -> Bool
checkRock ss i n c
  | i > n = True
  | c == '#' && c' == '#' = False
  | otherwise = checkRock ss (i + 1) n c'
  where
    c' = ss ! i

checkTriplet :: Array Int Char -> Int -> Int -> Char -> Char -> Bool
checkTriplet ss i n c1 c2
  | i > n = False
  | c2 == '#' && c' == '#' = False
  | c1 == '.' && c2 == '.' && c' == '.' = True
  | otherwise = checkTriplet ss (i + 1) n c2 c'
  where
    c' = ss ! i

main = do
  [n, a, b, c, d] <- getIntList
  [ss] <- getString
  let ss' = listArray (1, n) ss
  if b > c
    then if checkRock ss' a b '.' && checkRock ss' c d '.' then putStrLn "Yes" else putStrLn "No"
    else do
      if d > c
        then if checkRock ss' a d '.' == False then putStrLn "No" else do putStrLn "Yes"
        else if checkRock ss' a c '.' && checkTriplet ss' (b + 1) (d + 1) (ss' ! (b -1)) (ss' ! b) then putStrLn "Yes" else do putStrLn "No"


Measured memory_bytes: 6780
#include <stdio.h>

int main(void)
{
  int n,r,p,c,i,j;
  int cut[50],pile[50];

  for(;;){
    scanf("%d %d", &n, &r);
    if(n==0&&r==0) break;

    for(i=0;i<n;i++){
      pile[i]=i+1;
    }
    for(i=0;i<r;i++){
      scanf("%d %d", &p, &c);
      if(p==1) continue;
      for(j=0;j<c;j++){
	cut[j]=pile[n-p-c+j+1];
      }
      for(j=1;j<p;j++){
	pile[n-p-c+j]=pile[n-p+j];
      }
      for(j=0;j<c;j++){
	pile[n-c+j]=cut[j];
      }
    }
    printf("%d\n", pile[n-1]);
  }

  return 0;
}


Measured memory_bytes: 596
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self, n):
        return len({self.find(x) for x in range(1, n + 1)})

def com_2(n):
    if n == 1:return 0
    return n * (n - 1) // 2

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ab = ab[::-1]
uf = UnionFind(n)

rec = [n * (n - 1) // 2] * m
for i in range(m - 1):
    a, b = ab[i]
    if uf.check(a, b):
        rec[i + 1] = rec[i]
        continue
    a_size = uf.size[uf.find(a)]
    b_size = uf.size[uf.find(b)]
    temp = com_2(a_size) + com_2(b_size) - com_2(a_size + b_size)
    rec[i + 1] = rec[i] + temp
    uf.union(a, b)

rec = rec[::-1]
print(*rec, sep='\n')

Measured memory_bytes: 37816
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string s;
    string t;
    cin >> s;
    REP(i,s.size()){
        if(s[i]=='0'){
            t+="0";
        }else if(s[i]=='1'){
            t+="1";
        }else{
            if(t.size()!=0){
                t.pop_back(); 
            }
        }
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
bool isValid(vector<int>&h,int maxHt,int k){
	int cutsNeeded=0;
	for(int i=0;i<h.size();i++){
		   cutsNeeded+=(ceil((double)h[i]/maxHt)-1);
		   if(cutsNeeded>k) return false;
	}
	return true;
}
int b_s(vector<int>&h,int maxHt,int k){
 int s=1,e=maxHt;
 int ans;
 while(s<=e){
	 int mid=(long long)(s+e)/2;
     if(isValid(h,mid,k)){
       ans=mid;
	   e=mid-1;
	 }else{
	   s=mid+1;
	 }
 }
 return ans;
}
int main() {
   int n,k;
   cin>>n>>k;
   vector<int>h(n);
   int maxHt=INT_MIN;
   for(int i=0;i<n;i++){
	    cin>>h[i];
		maxHt=max(maxHt,h[i]);
   }
   int ans=b_s(h,maxHt,k);
   cout<<ans;
}


Measured memory_bytes: 4056
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

P = 10**9 + 7
N = 1000010
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    ans+=inv_t[ai]
    ans%=mod
print((pro*ans)%mod)

# pro2=1
# for ai in A:
#     pro2=(pro2*ai)%mod
#     pro=gcd(pro,ai)
# for ai in A:
#     count+=pro//ai
#     count%=mod
# print(count)

Measured memory_bytes: 72652
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace KPC2019
{
    class B2
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            // keymoonさんの回答と同じ書き方を試す
            // https://atcoder.jp/contests/keyence2019/submissions/10724495

            Console.WriteLine(
                Regex.IsMatch(S, "^.*keyence$") ||
                Regex.IsMatch(S, "^k.*eyence$") ||
                Regex.IsMatch(S, "^ke.*yence$") ||
                Regex.IsMatch(S, "^key.*ence$") ||
                Regex.IsMatch(S, "^keye.*nce$") ||
                Regex.IsMatch(S, "^keyen.*ce$") ||
                Regex.IsMatch(S, "^keyenc.*e$") ||
                Regex.IsMatch(S, "^keyence.*$") ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 16172
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val S = input.next()
    val T = input.next()
    val ST = StringBuilder()
    
    for(i in 0..(S.length - 1)) {
      ST.append(S[i])
      ST.append(T[i])
    }
    
    println(ST)
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
 ll n,a,b;
  cin >> n >> a >> b;
  
  cout << n/(a+b)*a+min(a,n-n/(a+b)*(a+b)) << endl;
  
}

Measured memory_bytes: 256
n,d = map(int,input().split())

ls = [[int(x) for x in input().split()] for _ in range(n)]
import math
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        can = 0
        for k in range(d):
            can += (ls[i][k]-ls[j][k])**2
        if int(math.sqrt(can)) == math.sqrt(can):
            cnt +=1
        
print(cnt)

Measured memory_bytes: 38384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  ll N;
  cin >> N;
  ll T[N];
  ll sum = 0;
  rep(i, N){
    cin >> T[i];
    sum += T[i];
  }
  ll M;
  cin >> M;
  ll P[M], X[M];
  rep(i, M){
    cin >> P[i] >> X[i];
    P[i]--;
    cout << sum - T[P[i]] + X[i] << endl;
  }
}


Measured memory_bytes: 256
S = input()
a = S[0] == 'S'
b = S[1] == 'S'
c = S[2] == 'S'
if (a and b and c ):
    print(0)
elif ( b or(a and c)):
    print(1)
elif(a or c):
    print(2)
else:
    print(3)

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DReplacing {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        map<int, int> m;
        int sum = 0;
        REP(i, N) {
            cin >> A[i];
            m[A[i]]++;
            sum += A[i];
        }

        int Q;
        cin >> Q;
        while (Q--) {
            int b, c;
            cin >> b >> c;
            sum += (c - b) * m[b];
            m[c] += m[b];
            m[b] = 0;
            cout << sum << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DReplacing solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int k = a[0], cnt = 1, bo = 0;
  for (int i = 1; i < n; i++)
  {
    if ((a[i] < k && bo == 1) || (a[i] > k && bo == -1)) {
      cnt++; bo = 0;
    } 
    else {
      if (a[i] > k) bo = 1;
      if (a[i] < k) bo = -1;
    }
    k = a[i];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k;
    if(k%10==2 || k%10==4 ||k%10==5 ||k%10==7|| k%10==9 )
        cout<<"hon"<<endl;

        if(k%10==0|| k%10==1|| k%10==6|| k%10==8 )
            cout<<"pon"<<endl;
        else if (k%10==3)
            cout<<"bon"<<endl;

    return 0;
}


Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMagic2 solver = new BMagic2();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMagic2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            int k = in.nextInt();

            while (b <= a) {
                b *= 2;
                k--;
            }
            while (c <= b) {
                c *= 2;
                k--;
            }

            out.println(k >= 0 ? "Yes" : "No");
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
    int n, x;
    cin >> n >> x;
    int d = 0, ans = 1;
    rep(i,n){
        int l;
        cin >> l;
        d += l;
        if(d <= x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int N, A, B;
    std::cin >> N >> A >> B;

    if ((B - A - 1) & 1) {
        std::cout << "Alice" << std::endl;
    }
    else {
        std::cout << "Borys" << std::endl;
    }

    return 0;
}


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

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy){
    cout<<'U';
  }
  rep(i,tx-sx){
    cout<<'R';
  }
  rep(i,ty-sy){
    cout<<'D';
  }
  rep(i,tx-sx){
    cout<<'L';
  }
  cout<<'L';
  rep(i,ty-sy+1){
    cout<<'U';
  }
  rep(i,tx-sx+1){
    cout<<'R';
  }
  cout<<"DR"
  rep(i,ty-sy+1){
    cout<<'D';
  }
  rep(i,tx-sx+1){
    cout<<'L';
  }
  cout<<'U';
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int kane[100],sum = 0;
    int i = 0,count = 0;
    int a,b;
    double heikinn,kazu = 0;
    while(scanf("%d,%d",&a,&b) != EOF){
        kane[i] = a * b;
        kazu += b;
        i++;
        count++;
    }
    for(i = 0; i < count; i++) sum += kane[i];
    heikinn = kazu / count;
    heikinn += 0.5;
    printf("%d\n%d\n",sum,(int)heikinn);
    return 0;
}

Measured memory_bytes: 592
n, m = map(int, input().split())
X = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()

X.sort()

if n == 1:
    print(X[-1]-X[0])
    exit()

Y = []
for i in range(m-1):
    Y.append(X[i+1]-X[i])
#print(Y)
Y.sort()
ans = sum(Y[0:-(n-1)])
print(ans)


Measured memory_bytes: 90964
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn solve(a: i32, b: i32, c: i32) -> i32 {
    if a == b {
        return c;
    } else if a == c {
        return b;
    }

    return a;
}

fn main() {
    let s = getline();
    let vec: Vec<i32> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();
    let a = vec[0];
    let b = vec[1];
    let c = vec[2];

    let ans = solve(a, b, c);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
	int h, w;
	int a[110], b[110];
	char s[110][110];
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
			if (s[i][j] == '#')
				a[i] = 1, b[j] = 1;
		}
	}
	//the actual point was to mark the resp row and col and then check for that row and col and print
	for (int i = 1; i <= h; i++) {
		if (a[i] == 1) {
			for (int j = 1; j <= w; j++)
				if (b[j] == 1) cout << s[i][j];
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
int main() {
	// your code goes here
	lli n,q,i,s=0,b,c;
	cin>>n;
	lli a[n];
	map<lli,lli>mp;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
		mp[a[i]]++;
	}
	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		s=s-b*mp[b];
		s=s+c*mp[b];
		mp[c]=mp[c]+mp[b];
		mp[b]=0;
		cout<<s<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define pb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define pii pair<int, int>

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) ans += (s[i] != t[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3812
def main():
    n = int(input())
    x = list(map(int, input().split(" ")))
    min = 1e9
    for i in range(1,101):
        na = 0
        for j in x:
            na += (j - i)**2
        if na < min:
            min = na
    print(min)
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 9124
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")
	nk := strings.Split(tmp, " ")

	tmp, _ = reader.ReadString('\n')
	s := strings.Trim(tmp, "\n")

	r := []rune(s)
	pos, _ := strconv.Atoi(nk[1])
	r[pos-1] = unicode.ToLower(r[pos-1])

	fmt.Println(string(r))
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define fr first
#define sc second
using namespace std;

int w,n;
typedef pair<int,int> P;
P dp[1001][1001];
bool chg[1001][1001];
vector <P> dat;

P rec(int idx,int wi){
    P p;
    if(chg[idx][wi]) return dp[idx][wi];
    if(idx == n){
        return P(0,wi);
    }
    else{
        if(wi - dat[idx].sc >= 0){
            p = rec(idx+1,wi-dat[idx].sc);
            p.first += dat[idx].fr;
            p = max(p,rec(idx+1,wi));
        }
        else p = rec(idx+1,wi);
    }
    chg[idx][wi] = true;
    return dp[idx][wi] = p;
}

int main(){
    int a = 0;
    while(cin >> w,w){
        memset(dp,-1,sizeof(dp));
        memset(chg,false,sizeof(chg));
        cin >> n;
        for(int i=0;i<n;i++){
            int t,m; scanf("%d,%d",&t,&m); dat.push_back(P(t,m));
        }
        P p = rec(0,w);
        cout << "Case " << ++a << ":\n" << p.fr << endl << w - p.sc << endl;
        dat.resize(0);
    }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 1000005;
int mul(int a, int b){
	return 1ll*a*b%mod;
}
int add(int a, int b){
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}
int dp[N];
int main(){
	fastio;
	int s;
	cin >> s;
	dp[s] = 1;
	for(int i = s; i >= 3; i--){
		for(int j = 3; j <= s; j++){
			dp[i] = add(dp[i], dp[i+j]);
		}
	}
	int ans = 0;
	for(int i = 3; i <= s; i++){
	//	cout << i <<" " << dp[i] << '\n';
		ans = add(ans, dp[i]);
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;
typedef long long ll;

ll n, a, b, c;

bool check(int m, vector<ll> d) {
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    d[i] -= m * b;
    if (d[i] <= 0) continue;
    sum += d[i];
  }
  return sum >= m * a - c;
}

int main(void) {
  cin >> n >> a >> b >> c;

  vector<ll> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end(), greater<ll>());

  int ok = 0, ng = 1e9;
  while (ng - ok > 1) {
    int m = (ok + ng) / 2;
    if (check(m, d)) ok = m;
    else ng = m;
  }

  cout << ok << endl;

  return 0;
}


Measured memory_bytes: 3100
import sys

h,w = [int(i) for i in input().split()]

sys.setrecursionlimit(100000)

s = [['#']*(w+2)] + [['#']+list(input())+['#'] for _ in range(h)] + [['#']*(w+2)]
#print(s)

cost = [[-1 if s[y][x] == '#' else float('inf') for x in range(w+2)] for y in range(h+2)]
cost[1][1] = 0
#print(cost)

move_que = [[1,1]]

def list_flatten(nested_list):
  flat_list = []
  fringe = [nested_list]
  
  while len(fringe) > 0:
    node = fringe.pop(0)
    if isinstance(node, list):
      fringe = node + fringe
    else:
      flat_list.append(node)

  return(flat_list)
      
def move(place):
  y,x = place
  if cost[y+1][x] != -1:
    if cost[y+1][x] > cost[y][x]+1:
      cost[y+1][x] = cost[y][x]+1
      move_que.append([y+1,x])       
      
  if cost[y-1][x] != -1:
    if cost[y-1][x] > cost[y][x]+1:
      cost[y-1][x] = cost[y][x]+1
      move_que.append([y-1,x])
  
  if cost[y][x+1] != -1:
    if cost[y][x+1] > cost[y][x]+1:
      cost[y][x+1] = cost[y][x]+1
      move_que.append([y,x+1])
  
  if cost[y][x-1] != -1:
    if cost[y][x-1] > cost[y][x]+1:
      cost[y][x-1] = cost[y][x]+1
      move_que.append([y,x-1])
  
while len(move_que) != 0:
  move(move_que[0])
  move_que = move_que[1:]

#print(cost)

if cost[h][w] == float('inf'):
  print(-1)
else:
  while_num = list_flatten(s).count('.')
  print(while_num - (cost[h][w]+1))


Measured memory_bytes: 41072
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string s, t;
    cin >> s >> t;

    vector<vector<ll>> s_appear_pos(26);
    for (ll i = 0; i < s.size(); i++) {
        s_appear_pos[s[i] - 'a'].push_back(i);
    }

    for (char c : t) {
        if (s_appear_pos[c - 'a'].empty()) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = -1;
    for (char c : t) {
        ll curr_pos = (ans == -1 ? -1 : ans % s.size());
        auto& v = s_appear_pos[c - 'a'];
        auto itr = upper_bound(v.begin(), v.end(), curr_pos);
        if (itr == v.end()) {
            //前へ戻る
            ans += s.size() - curr_pos + v.front();
            curr_pos = v.front();
        } else {
            ans += *itr - curr_pos;
            curr_pos = *itr;
        }
    }

    cout << ans + 1 << endl;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

using P = pair<int, int>;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  vector<P> p(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    p[i] = {a[i], i};
  }
  sort(p.rbegin(), p.rend());

  auto dp = make_vec<int>(n+1, n+1);
  for(int i = 0; i < n; i++){
    for(int j = 0; i + j < n; j++){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j] + p[i+j].first * (p[i+j].second - i));
      dp[i][j+1] = max(dp[i][j+1], dp[i][j] + p[i+j].first * ((n-1-j) - p[i+j].second));
    }
  }

  int ans = 0;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n; j++){
      if(i+j == n) ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '(') {
			cnt++;
		} else if (S[i] == '*') {
			cout << cnt << el;
			return;
		} else {
			cnt--;
		}
	}
}

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



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

public class Main {

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

  private void solve() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] ln = in.readLine().split(" ");
      final int A = atoi(ln[0]);
      final int B = atoi(ln[1]);
      final int Q = atoi(ln[2]);

      long[] s = new long[A+1];
      for (int i = 0; i < A; i++) {
        s[i] = atol(in.readLine());
      }
      s[A] = 1L << 40;

      long[] t = new long[B+1];
      for (int i = 0; i < B; i++) {
        t[i] = atol(in.readLine());
      }
      t[B] = 1L << 40;

      for (int q = 0; q < Q; q++) {
        long x = atol(in.readLine());
        long dist = 1L << 50;

        for (int c = 0; c < 2; c++) {
          long[] af = c == 0 ? s : t;
          long[] as = c == 0 ? t : s;

          for (int i = 0; i < 2; i++) {
            int posF = binarySearch(af, x) + i;
            long df = af[posF];

            for (int j = 0; j < 2; j++) {
              int posS = binarySearch(as, x) + j;
              long ds = as[posS];
              
              long d = Math.abs(x - df);
              d += Math.abs(df - ds);
              dist = Math.min(dist, d);
            }
          }
        }

        out.println(dist);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  private int binarySearch(long[] arr, long x) {
    int left = 0;
    int right = arr.length;

    return loop(arr, x, left, right);
  }

  private int loop(long[] arr, long x, int left, int right) {
    if(right - left < 2) return left;
    else {
      int mid = (left + right) / 2;
      if(arr[mid] <= x) return loop(arr, x, mid, right);
      else return loop(arr, x, left, mid);
    }
  }
}

Measured memory_bytes: 46964
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		boolean over = false;
		boolean zero = false;
		long big = (long)100000000*10000*1000000;
		long a = 1;
		for(int i=0;i<n;i++) {
			long ai = sc.nextLong();
			if(ai==0) {
				zero = true;
				break;
			}
			if((Math.log10(a)+Math.log10(ai))>18.2) {
				over = true;
			}
			if(a*ai>big) {
				over = true;
			}
			a = a*ai;
		}
		if(zero) {
			System.out.println(0);
		}else {
			if(over) {
				System.out.println(-1);
			}else {
				System.out.println(a);

			}
		}







	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 59552
fun main(args: Array<String>) {
    val S = next()
    val N = S.length
    var ans = N
    for (n in 0 .. N - 2) {
        if (S[n] != S[n + 1]) {
            ans = Math.min(Math.max(n + 1, N - n - 1), ans)
        }
    }
    println(ans)
}

fun next() = readLine()!!


Measured memory_bytes: 34416
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
long S[10000];
long T[500];

int main(){
	int n; scanf("%d",&n);
	for (int i = 0; i < n; ++i) scanf("%d", &S[i]);
	int q; scanf("%d",&q);
	for (int i = 0; i < q; ++i) scanf("%d",&T[i]);
	sort(S, S + n);
	sort(T, T + q);
	int cnt = 0;
	int k = 0;
	for (int i = 0; i < n; ++i){
		for (int j=k; j < q; ++j){
			if (S[i] == T[j]) { ++cnt, k=j+1; break; }
		}
	}
	cout << cnt << '\n';
}

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

Measured memory_bytes: 9588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int mod = 1e9 + 7;
inline ll inv(ll a){
	ll b = mod, x = 1, y = 0;
	while(b){
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		x -= t * y;
		swap(x, y);
	}
	return (mod + x % mod) % mod;
}
int pw(int n, int m){
	int res = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * (ll)n % mod;
		n = (ll)n * n % mod;
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, a, b; cin >> n >> a >> b;
	ll ans = (pw(2, n) + mod - 1) % mod;
	
	ll x = 1, y = 1;
	rep(i, a){
		x = x * (n - i) % mod;
		y = y * (i + 1) % mod;
	}
	ans = ans + mod - x * inv(y) % mod;
	
	for(int i = a; i < b; i++){
		x = x * (n - i) % mod;
		y = y * (i + 1) % mod;
	}
	ans = (ans + mod - x * inv(y) % mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

int main(int argc,char *argv[])
{
	int r;
	std::cin >> r;

	std::cout << r*r << std::endl;

	return 0;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# 
# s = input()

a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    cout << dup(a+b,2) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
c = [1]
for i in range(6):
    c.append(6**(i+1))
for i in range(5):
    c.append(9**(i+1))
INF = float("inf")
 
dp = [INF]*(n+1)
dp[0] = 0
 
for i in range(len(c)):
    for j in range(n+1):
        if j - c[i] < 0:
            continue
        else:
            dp[j] = min(dp[j], dp[j - c[i]] + 1)
 
print(dp[n])

Measured memory_bytes: 6900
s = input()
L, R, d = s.split()
L = int(L)
R = int(R)
d = int(d)

# print(L, R, d)

d1 = d
count = 0

while d1 < L:
    d1 += d
    # print(d1)

while d1 <= R:
    count += 1
    d1 += d

print(count)



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

int main() {
    int N; long long C, K;
    cin >> N >> C >> K;
    vector<long long> time(N);
    for (int i = 0; i < N; i++) {
        cin >> time[i];
    }
    sort(time.begin(), time.end());
    
    long long limit = time[0] + K;
    int wait = 0;
    long long ans = 1;
    
    for (int i = 0; i < N; i++) {
        if (limit < time[i] || wait == C) {
            limit = time[i] + K;
            wait = 1;
            ans++;
        } else {
            wait++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define mp make_pair
#define PI 3.14159265358979

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int d=h2*60+m2;
    int a=h1*60+m1;
    int diff=d-a;
    cout<<diff-k<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

  
        int n,m;
        cin >> n;
        string s;
        cin >> s;
        m=s.size();
        string ans="";
        for(int i=0; i<m; i++){
            int x=s[i]-'A';
            int z=(x+n)%26;
            char y=(char)('A'+z);
            ans+=y;
        }
        cout << ans;
              
        
        

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define ll long long
#define MOD 1000000007
int n;
struct node{
	int id,a;
}s[N];
bool cmp(node p,node q)
{
	return p.a<q.a;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i].a);
		s[i].id=i;
	}	
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<n;i++)
		printf("%d ",s[i].id);
	printf("%d\n",s[n].id);
	return 0;
}

Measured memory_bytes: 1536
use std::io;
use std::cmp;
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
  let a:usize;
  let n:usize;
  let b:usize;
  input!(n,a,b);

  println!("{}",cmp::min(n*a,b));

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ff first
#define ss second
///////////////////////////////////////////////////////////
const ll mod = 1e9 + 7 ;
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
//////////////////////////////////////////////////////////

void solve( ){
    int n ;
    cin >> n ;
    vector < int > a(n) ;
    for( int i = 0 ; i < n ; i++) cin >> a[i];
    vector < int > hash(n+1) ;
    hash[0] = 1 ;
    int ans = -1 ;
    for( int i = 0 ; i < n ; i++){
        hash[a[i]] = hash[a[i]-1];
        if(hash[a[i]]==1){
            ans = max(ans,a[i]);
        }
    }
    if(ans==-1){
        cout << -1 ;
        return ;
    }
    cout << n-ans ;
}
int main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test_case=1 ;
    //cin >> test_case ;
    //precal();
    for( int i = 1 ; i <= test_case ; i++){
        solve( );
    }
}
// 0 0 1 2
// 0 1 1 2


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mx  200005
vector<int> adj[mx];
vector<int> val(mx);
vector<int> lis(mx, -1);
vector<int> currseq;
void dfs(int a)
{
    auto it = lower_bound(currseq.begin(), currseq.end(), val[a]);
    int prevval = -1;
    int index = -1;
    if (it == currseq.end())
    {
        currseq.push_back(val[a]);
    }
    else
    {
        index = it - currseq.begin();
        prevval = currseq[index];
        currseq[index] = val[a];
    }
    lis[a] = currseq.size();
    for (int s : adj[a])
    {
        if (lis[s] == -1)
        {
            dfs(s);
        }
    }
    if (prevval == -1)
    {
        currseq.pop_back();
    }
    else
    {
        currseq[index] = prevval;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int q = 1; q <= n; q++)
    {
        cin >> val[q];
    }
    for (int q = 0; q < n-1; q++)
    {
        int a,b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1);
    for (int q = 1; q <= n; q++)
    {
        cout << lis[q] << endl;
    }
    return 0;
}


Measured memory_bytes: 24128
import sys
import heapq

readline = sys.stdin.readline


def main():
    _, a = readline().strip().split()
    pq = [-int(a)]
    heapq.heapify(pq)
    flag = True

    while flag:
        op = readline().strip()
        if op[0] == "i":
            _, a = op.split()
            heapq.heappush(pq, -int(a))
        elif op[1] == "x":
            a = heapq.heappop(pq)
            print(-a)
        else:
            flag = False

    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 45544
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
bl=[int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in bl:
            a[i][j]=0
flag=False
for i in range(3):
    total=0
    if sum(a[i])==0:
        flag=True
        break
    for j in range(3):
        total+=a[j][i]
    if total==0:
        flag=True
        break
    if flag:
        break
if a[0][0]+a[1][1]+a[2][2]==0:
    flag=True
elif a[2][0]+a[1][1]+a[0][2]==0:
    flag=True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064