akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long H, W;
vector<long long> v;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W ;
	long long S, s, ans;

	if((H % 3) == 0 || (W % 3) == 0){
		ans = 0;
		printf("%lld\n", ans);
		return 0;
	}

	long long w, h;
	v.clear();
	//左1/3、残りの右を上下に分割
	w = W / 3;
	h = H / 2;
	// H*w, h*(W-w), (H-h)*(W-w)
	for(long long i = -4; i <= 4; i++){
		if(w+i<1 || w+i>=W) continue;
		for(long long j = -4; j <= 4; j++){
			if(h+j<1 || h+j>=H) continue;
			long long a = H * (w+i);
			long long b = (h+j)*(W-(w+i));
			long long c = (H-(h+j))*(W-(w+i));
			if(a <= 0 || b <= 0 || c <= 0) continue;
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			if(S >= s && S > 0 && s > 0){
				v.push_back(S - s);
			}
		}
	}
	
	//上1/3、残りの下を左右に分割
	h = H / 3;
	w = W / 2;
	// h*W, (H-h)*w, (H-h)*(W-w) 
	for(long long i = -4; i <= 4; i++){
		if(h+i<1 || h+i>=H) continue;
		for(long long j = -4; j <= 4; j++){
			if(w+j<1 || w+j>=W) continue;
			long long a = (h+i) * W;
			long long b = (H-(h+i))*(w+j);
			long long c = (H-(h+i))*(W-(w+j));
			if(a <= 0 || b <= 0 || c <= 0) continue;
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			if(S >= s && S > 0 && s > 0){
				v.push_back(S - s);
			}
		}
	}

	//縦方向に3分割
	h = H / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			long long a = (h + i) * W;
			long long b = (h + j) * W;
			long long c = (H - (h+i) - (h+j)) * W;
			if(a <= 0 || b <= 0 || c <= 0) continue;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			if(S >= s && S > 0 && s > 0){
				v.push_back(S - s);
			}
		}
	}

	//横方向に3分割
	w = W / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			long long a = (w + i) * H;
			long long b = (w + j) * H;
			long long c = (W - (w+i) - (w+j)) * H;
			if(a <= 0 || b <= 0 || c <= 0) continue;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			if(S >= s && S > 0 && s > 0){
				v.push_back(S - s);
			}
		}
	}
	sort(v.begin(), v.end());
	ans = v[0];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    int N;
    cin >> N;
    ll ans = -1;
    rep(i,0,N){
        int a;
        cin >> a;
        if(ans == -1)ans = a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll n, x, m, mi = 1000;
	cin >> n >> x;
	REP(i, n) {
		cin >> m;
		x -= m;
		mi = min(mi, m);
	}
	cout << (n + x/mi) << 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;
using ll = long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)

int main()
{
    int N = 0;
    string S;
#if 0
	cin >> N;
#endif
#if 0
	cin >> S;
#endif
#if 1
    //vec_str v(N);
    vec_int v(3);
    rep(i, 3) cin >> v[i];
#endif

#if 0
    p pp = make_pair(1, 2);
    //cout << pp.first << endl;
    //cout << pp.second << endl;
#endif

    int ans = 0;
        
    int t = v[0];
    v[0] = v[1];
    v[1] = t;
    t = v[0];
    v[0] = v[2];
    v[2] = t;
    
    
    rep(i, 3)  cout << v[i] << " ";
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	scanf("%d\n",&N);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d \n",&H[i]);
	}
	int ans=0;
	int temp=0;
	for(int i=0;i<N-1;i++){
		if(H[i] >= H[i+1])temp++;
		else if(ans < temp){
			ans = temp;
			temp=0;
		}
		else {
			temp =0;
			continue;
		}
	}
	if(ans < temp)ans = temp;
	printf("%d",ans);

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> p(n);

    for (auto &&i : p)
    {
        cin >> i;
    }

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

    int ans = 0;

    for (int i = 0; i < k; i++)
    {
        ans += p[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10**5)

n = int(input())

p = [[] for i in range(n)]

for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u = u-1
    v = v-1
    p[u].append((v, w))
    p[v].append((u, w))

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

def dfs(num, zo):
    if c[num] != -1:
        return
    else:
        c[num] = zo
    for v, w in p[num]:
        if w % 2 == 0:
            dfs(v, zo)
        else:
            dfs(v, not zo)
dfs(0, 0)

for i in range(n):
    print(1 if c[i] else 0)

Measured memory_bytes: 83700
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S ;
  cin >> S;
  
  if (S[0] == S[1] ){
    cout << "Bad" << endl;
  }
  
  else if (S[1] == S[2]){
    cout << "Bad" << endl;
  }
  
  else if (S[2] == S[3] ){
    cout << "Bad" << endl;
  }
  
  
  else{
    cout << "Good" << endl;
  }
}

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

int main(){
    string s, t;
    cin >> s >> t;
    bool f = true;
    if (s.size() + 1 != t.size()) f = false;
    if (f) for (int i = 0; i < s.size(); ++i){
        if (s[i] != t[i]){ f = false; break; }
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3620
def judge(n):
    result = 0
    j = n
    for i in range(1, len(str(n)) + 1):
        result += j % 10
        j = int(j / 10)

    return result

def main():
    N, A, B = map(int, input().split())
    ans = 0

    for i in range(1, N + 1):
        if A <= judge(i) <= B:
            ans += i

    print(ans)

main()

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
// https://emtubasa.hateblo.jp/entry/2019/02/14/000000_2
int main(){
  string S;
  int N;
  cin >> S ; N = S.length();
  int ans = INF;
  for(int i = 0; i < N-1; i ++){
    if(S[i]!=S[i+1]) {
      ans = min(ans,max(i+1,N-i-1));
    }
  }
  if(ans==INF) ans = N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import math
n = int(input())
loc = list()

def getDist(x,y):
    return math.sqrt((x[0] - y[0])**2 + (x[1]-y[1])**2)

def fac(n):
    if n == 0:
        return 1
    if n == 1:
        return 1
    return n * fac(n-1)

for i in range(n):
    x,y = list(map(int,input().split(" ")))
    loc.append((x,y))

total = 0
for i in range(n):
    for j in range(i):
        total += getDist(loc[i],loc[j]) * 2 * (n-1) * fac(n-2)

avg = total / fac(n)
print(avg)




Measured memory_bytes: 3064
from sys import stdin
input = stdin.readline

def Judge(N, S):
    for i in range(N-1):
        if S[i] == S[i+1]:
            return i+1, i+2
    for i in range(N-2):
        if S[i] == S[i+2]:
            return i+1, i+3
    else:
        return -1, -1

S = list(input().strip())
N = len(S)
a, b = Judge(N, S)
print(a, b)

Measured memory_bytes: 9788
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
int main()  {
    int n;
    cin>>n;
    vi v1(n);
    for(auto&x:v1)
        cin>>x;
    vi v2(n);
    for(int i=0;i<n;i++)
    {
        v2[v1[i]-1] = i+1;
    }
    for(auto x:v2) cout<<x<<" ";
    return 0;
}

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    ab = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1])
    
    ans = 0
    pre = -1
    for a, b in ab:
        if a >= pre:
            ans += 1
            pre = b
    print(ans)

if __name__ == "__main__":
    main()

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

public class Main {
    
    class Answer {
        int N, K;
        
        public long solve() {
            long min = 1;
            for (int i = 0; i < N; i++) {
                min = Math.min(min*2, min+K);
            }
            return min;
        }
        
        public void main(FastScanner in, PrintWriter out) {
            N = in.nextInt();
            K = in.nextInt();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p(o[i][j] + " "); }
                pl("");
            }
        }
        public void ck(Object o1, Object o2) { pl(o1 + " " + o2); }
        public void ckk(Object o1, Object o2, Object o3) { pl(o1 + " " + o2 + " " + o3); }
        public void ckkk(Object o1, Object o2, Object o3, Object o4) { 
            pl(o1 + " " + o2 + " " + o3 + " " + o4);
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main problem = new Main();
        Answer ans = problem.new Answer();
        ans.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 21460
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
unsigned long long q,s,h,d,n,m2;
int main()
{
	cin>>q;q*=4;
	cin>>s;s*=2;
	cin>>h;m2=min(min(q,s),h);cin>>d;cin>>n;
	if(d>=m2*2){cout<<n*m2;return 0;}
	if(n&1)cout<<(n-1)/2*d+m2;
	else cout<<(n/2)*d;
}

Measured memory_bytes: 764
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))

class SegmentTree:
    def __init__(self, value, N=0, comp=lambda x,y: x<=y, reverse=False):
        M = max(len(value),N)
        N = 2**(len(bin(M))-3)
        if N < M: N *= 2
        self.N = N
        self.node = [0] * (2*N-1)
        for i in range(N):
            self.node[N-1+i] = i
        self.value = [None] * N
        for i, v in enumerate(value):
            self.value[i] = v
        self.comp = lambda x, y: True if y is None else False if x is None else comp(x,y)^reverse
        for i in range(N-2,-1,-1):
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.value[left_i], self.value[right_i]
            if self.comp(left_v, right_v):
                self.node[i] = left_i
            else:
                self.node[i] = right_i

    def set_input(self, n, v):
        self.value[n] = v
        i = (self.N-1) + n
        while i > 0:
            i = (i-1)//2
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.value[left_i], self.value[right_i]
            if self.comp(left_v, right_v):
                new_i = left_i
            else:
                new_i = right_i
            if new_i == self.node[i] and new_i != n:
                break
            else:
                self.node[i] = new_i

    def get_input(self, n):
        if n is None:
            return None
        else:
            return self.value[n]

    def get_output(self, a=0, b=-1):
        return self.get_input(self.get_output_index(a,b))

    def get_output_index(self,
                         a=0, b=-1,
                         k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left_i = self.get_output_index(a,b,2*k+1,l,(l+r)//2)
            right_i = self.get_output_index(a,b,2*k+2,(l+r)//2,r)
            left_v, right_v = self.get_input(left_i), self.get_input(right_i)
            if left_v is None and right_v is None:
                return None
            elif self.comp(left_v, right_v):
                return left_i
            else:
                return right_i

N, M = inpl()
AB = [ inpl() for _ in range(N) ]
AB.sort()
A = [ ab[0] for ab in AB ]
B = [ ab[1] for ab in AB ]
sg = SegmentTree(B, reverse=True)
ans = 0
n = 0
for m in range(1,M+1):
    while n < N and A[n] <= m:
        n += 1
    p = sg.get_output_index(0, n)
    if p is not None:
        ans += sg.get_input(p)
        sg.set_input(p, None)
print(ans)

Measured memory_bytes: 112924
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;



int main() {
	int n,ans=0;
	char s[600][600];
	cin >> n;

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


	for (int i = 0; i < n; i++) {
			bool flg = true;
			for (int k = 0; k < n&&flg; k++) {
				for (int l = 0; l < k&&flg; l++) {
					if (s[i+k][l] != s[i+l][k]) {
						flg = false;
					}
				}
			}
			if (flg) {
				ans+=n-i;
			}
		}


	for (int i = 1; i < n; i++) {
		bool flg = true;
		for (int k = 0; k < n&&flg; k++) {
			for (int l = 0; l < k&&flg; l++) {
				if (s[ k][i+l] != s[l][i+k]) {
					flg = false;
				}
			}
		}
		if (flg) {
			ans += n - i;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  long ans=99999999999999;
  long i=1;
  while(i<=sqrt(N)){
    if((N/i)*i==N)ans = min(i+N/i-2,ans);
	i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
weight = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (N + 1)
dp[0] = 0
for i in range(N + 1):  # dpで0~N本のマッチを探索
    for a in A:  # Aに入ってるもの（作れる数字）を探索
        if i + weight[a] < N + 1:  # i+(今回作る数字に必要なマッチ)本のマッチがN以下だったらOk
            dp[i + weight[a]] = max(dp[i + weight[a]], dp[i]
                                    * 10 + a)
print(dp[N])


Measured memory_bytes: 14692
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		if (N == M) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

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


Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int main(){
    char op;
    int a,b;
    while(1){
        cin>>a>>op>>b;
        if(op == '?'){
            break;
        }
        if(op == '+'){
            cout<<a+b<<endl;
        }else
        if(op == '-'){
            cout<<a-b<<endl;
        }else
        if(op == '*'){
            cout<<a*b<<endl;
        }else
        if(op == '/'){
            cout<<a/b<<endl;
        }
    }
    
}


Measured memory_bytes: 3132
// AOJ 0010 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0010&lang=jp)
#include<cstdio>
#include<cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

double sqr( double x )
{ return x*x; }

int main()
{
	scanf( "%d", &n );
	while( n-- )
	{
		double x1, y1, x2, y2, x3, y3;
		scanf( "%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3 );

		double a = sqrt(sqr(x3-x2)+sqr(y3-y2)), b = sqrt(sqr(x1-x3)+sqr(y1-y3)), c = sqrt(sqr(x2-x1)+sqr(y2-y1));
		double cosA = (sqr(b)+sqr(c)-sqr(a))/(2*b*c), cosB = (sqr(c)+sqr(a)-sqr(b))/(2*c*a), cosC = (sqr(a)+sqr(b)-sqr(c))/(2*a*b);
		double sinA = sqrt(1-sqr(cosA)), sinB = sqrt(1-sqr(cosB)), sinC = sqrt(1-sqr(cosC));
		double sin2A = 2*sinA*cosA, sin2B = 2*sinB*cosB, sin2C = 2*sinC*cosC;
		double px = (sin2A*x1+sin2B*x2+sin2C*x3)/(sin2A+sin2B+sin2C), py = (sin2A*y1+sin2B*y2+sin2C*y3)/(sin2A+sin2B+sin2C);

		printf( "%.3f %.3f %.3f\n", px, py, sqrt(sqr(x1-px)+sqr(y1-py)) );
	}

	return 0;
}

Measured memory_bytes: 1088
package main

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

const Inf = 1001001001

func main() {
	N, M := ReadInt(), ReadInt()
	adjL := make([][]int, N)
	for i := 0; i < M; i++ {
		u, v := ReadInt()-1, ReadInt()-1
		adjL[u] = append(adjL[u], v)
	}
	S, T := ReadInt()-1, ReadInt()-1
	dist := make([][]int, N)
	for i := 0; i < N; i++ {
		dist[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			dist[i][j] = Inf
		}
	}
	dist[S][0] = 0
	q := make([][]int, 0)
	q = append(q, []int{S, 0})
	for len(q) > 0 {
		v, l := q[0][0], q[0][1]
		q = q[1:]
		nl := (l + 1) % 3
		for _, u := range adjL[v] {
			if u == T && nl == 0 {
				fmt.Println((dist[v][l] + 1) / 3)
				return
			}
			if dist[u][nl] == Inf {
				dist[u][nl] = dist[v][l] + 1
				q = append(q, []int{u, nl})
			}
		}
	}
	fmt.Println(-1)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 27840
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int []a = new int [n];
		int []b = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = atcoder(a[i]);
		}
		
		int cnt = 0;
		int min = 0;
		int now = 0;
		Arrays.sort(b);
		for(int i = 0 ; i < n ;i++) {
			if(b[i] < 0) {
				cnt++;
			}
			else if(now != b[i]) {
				min++;
				now = b[i];
			}
		}
		
		
		if(cnt == n) {
			System.out.println(1+" "+Math.min(8, cnt));
		}
		else {
			System.out.println(min+" "+(cnt+min));
		}
		
		
	}
	
	static int atcoder(int a) {
		if(a>= 3200) return -1;
		if(a>= 2800) return 8;
		if(a>=2400) return 7;
		if(a>=2000) return 6;
		if(a>=1600) return 5;
		if(a>=1200)return 4;
		if(a>=800) return 3;
		if(a>=400) return 2;
		return 1;
	}

}


Measured memory_bytes: 21204
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[1000001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,m;
lld x,y,n1,b=0,a,n2,h,z,c;
vector<vector<lld> > v(200001);
vector<bool > visited(200001,false);
vector<lld> w(200001),pa(200001);

queue<lld> q;
void bfs()
{
    q.pu((lld)1);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        if(visited[x]==true)
            continue;
        visited[x]=true;
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            if(visited[v[x][i]]==false)
            {
                w[v[x][i]] = w[x]+1;
                pa[v[x][i]] =x;
                q.pu(v[x][i]);
            }
        }
    }
}
void solve()
{
    cin>>n>>k;
    vector<lld> v;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);
    }
    sort(all(v));
    a=0;
    for(i=0;i<n-min(k,n);i++)
    {
        a+=v[i];
    }
    cout<<a;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
     //getfac(p1);
    //check the value by which modulo is to be taken
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
           solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 10356
n = gets.to_i
te = n.times.map{ gets.split.map(&:to_i) }.sort_by!{|x|x[1]}

b = 0
f = true
te.each do |t,e|
    
  if e < b + t
    puts "No"
    exit
  else
    b = b + t
  end
end

puts "Yes"

Measured memory_bytes: 22520
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int cnt = 0;
		for(int i = 0; i < 3; i++) {
			if(str.substring(i, i + 1).equals("1")) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22612
object methods {
  def solver(): Unit = {
 
    val tempList: Seq[Seq[String]] = {
      for (line <- io.Source.stdin.getLines()) yield {
        line.split(' ').toSeq
      }
    }.toSeq
    val N: Long = tempList(0)(0).toLong
    val alphaList: List[String] = List("z", "a", "b", "c", "d", "e", "f", "g",
    "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
    "v", "w", "x", "y")
 
    val lst = divide(List(N))
    val lstInit = lst.init.reverse
    val lstInitStr: List[String] = lstInit.map(x => alphaList(x.toInt))
 
    println(lstInitStr.mkString)
  }
 
  def divide(nList: List[Long]): List[Long] = {
    val nDivide: Long = nList.last
 
    val rest: Long = nDivide % 26L
    val restList: List[Long] = nList.init :+ rest
 
    val sho: Long = nDivide / 26L
    val shoList: List[Long] = if(rest == 0L) restList :+ (sho - 1L) else restList :+ sho
 
    if(shoList.last == 0L) shoList
    else divide(shoList)
  }
 
}
 
object Main extends App {
  methods.solver
}

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

#define endl '\n'

int const N = 100010;
vector<int> adjf[N], adjb[N];
int pai[N], rnk[N];

int find(int x){
    if (pai[x] == x) return x;
    return pai[x] = find(pai[x]);
}

bool same(int a, int b){
    return find(a) == find(b);
}

void join(int a, int b){
    a = find(a);
    b = find(b);
    if (same(a, b)) return;
    if (rnk[a] > rnk[b]){
        pai[b] = a;
        rnk[a] += rnk[b];
    } else{
        pai[a] = b;
        rnk[b] += rnk[a];
    }
}

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

    int n, m, k; cin >> n >> m >> k;
    for (int i=1; i<=n; i++){
        pai[i] = i;
        rnk[i] = 1;
    }
    for (int i=0; i<m; i++){
        int u,v; cin >> u >> v;
        adjf[u].push_back(v);
        adjf[v].push_back(u);
        join(u, v);
    }
    for (int i=0; i<k; i++){
        int u,v; cin >> u >> v;
        adjb[u].push_back(v);
        adjb[v].push_back(u);
    }

    for (int i=1; i<=n; i++){
        int ans = rnk[find(i)] - 1 - adjf[i].size();
        for (int x : adjb[i]) if (same(x, i)) ans--;
        cout << ans << " ";
    }
    cout << endl;
    
}

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

int main()
{    
  int n;
  scanf("%d",&n);
  int sum=0;
  for(int i=1;i<=n;i++)
  {
    int tmp;
    scanf("%d",&tmp);
    sum+=tmp-1;
  }
  printf("%d",sum);
}


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

double dabs(double a) {
    if (a < 0.0) return -1.0 * a;
    else return a;
}
int main(void) {
    int n;cin>>n;
    double x[n],y[n];
    for (int i = 0; i < n; i++) cin>>x[i];
    for (int i = 0; i < n; i++) cin>>y[i];
    // p = 1
    double result1 = 0.0;
    for (int i = 0; i < n; i++) result1 += dabs(x[i] - y[i]);

    // p = 2
    double result2_tmp = 0.0;
    for (int i = 0; i < n; i++) result2_tmp += pow(x[i] - y[i], 2);
    double result2 = sqrt(result2_tmp);

    // p = 3
    double result3_tmp = 0.0;
    for (int i = 0; i < n; i++) result3_tmp += pow(dabs(x[i] - y[i]), 3);
    double result3 = pow(result3_tmp, 1 / 3.0);

    // p = inf
    double result4 = -1.0;
    for (int i = 0; i < n; i++) {
        double tmp = dabs(x[i] - y[i]);
        if (tmp > result4) result4 = tmp;
    }
    printf("%.6f\n%.6f\n%.6f\n%.6f\n", result1, result2, result3, result4);
    return 0;
}


Measured memory_bytes: 3396
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
	int a, b;
	int ans;
	cin >> a >> b;
	if (b%a == 0) {
		ans = a + b;
	}
	else {
		ans = b - a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int X, A, B;
  scanf ("%d %d %d", &X, &A, &B);
  if (A-B>=0){
    printf("delicious");
  }else if (B-A<=X){
    printf("safe");
  } else if (B-A>X) {
    printf ("dangerous");
  }
  return 0;
}


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

using ll = long long;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using val = valarray<T>;

using pi = pair<int,int>;

#define rep(a,b) for(int a=0; a<b; ++a)
#define Rep(a,b,c) for(int a=b; a<c; ++a)
#define ran(a,b) for(auto &a:b)
#define all(v) v.begin(),v.end()

int main(){
	int W, H; cin >> W >> H;
	vector<vector<int>> c(H, vector<int>(W)), d(W, vector<int>(H));
	for(int i=0; i<H; ++i) for(int j=0; j<W; ++j) cin >> c[i][j], d[j][i] = c[i][j];
	
	map<vector<int>,int> S;
	for(int i=0; i<H; ++i) {
		S[c[i]]++;
		if(S.size() > 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	if(S.size() != 2) {
		cout << "no" << endl;
		return 0;
	}
	auto itr = S.begin();
	if(itr->second == H / 2 || (++itr)->second == H / 2) {
	} else {
		cout << "no" << endl;
		return 0;
	}
	
	S.clear();
	for(int i=0; i<W; ++i) {
		S[d[i]]++;
		if(S.size() > 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	if(S.size() != 2) {
		cout << "no" << endl;
		return 0;
	}
	itr = S.begin();
	if(itr->second == W / 2 || (++itr)->second == W / 2) {
	} else {
		cout << "no" << endl;
		return 0;
	}
	
	cout << "yes" << endl;
}


Measured memory_bytes: 10704
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 1501
#define MAX2 1001

int main() {
	static int h[MAX], w[MAX];
	static int H[MAX*MAX2], W[MAX*MAX2];
	for (int N, M; scanf("%d%d", &N, &M), N;) {
		memset(h, 0, sizeof(h));
		memset(w, 0, sizeof(w));
		memset(H, 0, sizeof(H));
		memset(W, 0, sizeof(W));

		for (int i = 0; i < N; i++) {
			scanf("%d", &h[i]);

		}
		for (int i = 0; i < M; i++) {
			scanf("%d", &w[i]);
		}

		for (int i = 0; i < N; i++) {
			int a = 0;
			for (int j = i; j < N; j++) {
				a += h[j];
				H[a]++;
			}
		}
		for (int i = 0; i < M; i++) {
			int a = 0;
			for (int j = i; j < M; j++) {
				a += w[j];
				W[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < MAX*MAX2; i++) {
			ans += H[i] * W[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 12964
import java.util.*;
public class Main {
    public static void main(String[]args){
        // 標準入力
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A <= 9 && B <= 9)  System.out.println(A*B);
        else System.out.println("-1");
    }   
       
}       

Measured memory_bytes: 22740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    ll m=1;
    rep(i,k) m*=3;
    ll ans=0;
    for(int i=0;i<m;i++){
        vec p(k);
        ll n=i;
        ll a1=a,b1=b,c1=c;
        for(int j=0;j<k;j++){
            p[j]=n%3;
            n/=3;
        }
        for(int j=0;j<k;j++){
            if(p[j]==0) a1*=2;
            if(p[j]==1) b1*=2;
            if(p[j]==2) c1*=2;
        }
        if(a1+b1+c1>ans) ans=a1+b1+c1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
Bn = list(map(int,input().split()))
ans = 0
for i in range(N):
    An = list(map(int,input().split()))
    score = 0
    for b,a in zip(Bn,An):
        score += b*a
    score+=C
    if score>0:
        ans +=1
print(ans)

Measured memory_bytes: 3060
N = int(input())
A =list(map(int,input().split()))
def insertionSort(A, N):
    print(" ".join(map(str,A)))
    for i in range(1,N):
        v = A[i]
        j = i -1
        while j >=0 and A[j] >v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))


insertionSort(A,N)



Measured memory_bytes: 5600
inf = 100100100
ans = inf
H, W, K = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = [int(x) for x in input()]
for i in range(2**(H-1)):
    group = [0]
    g = 0
    for j in range(H-1):
        if (i >> j) & 1:
            g += 1
        group.append(g)
    g += 1
    c = [[0 for _ in range(W)] for __ in range(g)]
    for j in range(H):
        for k in range(W):
            c[group[j]][k] += S[j][k]
    num = g-1
    now = [0]*g
    def large(now):
        for n in now:
            if n > K:
                return True
        else:
            return False
    def v_vec(twodlis, k):
        ans = []
        for lis in twodlis:
            ans.append(lis[k])
        return ans
    for k in range(W):
        for n in range(len(now)):
            now[n] = now[n] + v_vec(c,k)[n]
        if large(now):
            now = v_vec(c,k)
            num += 1
            if large(now):
                num = inf
                break
 
    ans = min(ans, num)
print(ans)

Measured memory_bytes: 62428
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 998244353
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m;
vector<ll>g[100005];
map<ll,ll>viz;
void dfs(ll node){
viz[node]=1;
for(auto it : g[node]){
    if(viz[it]){
        continue;
    }
    dfs(it);
}
}
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
    ll x,y;
    cin>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
}
ll cnt=0;
for(ll i=1;i<=n;i++)
{
    if(viz[i]){
        continue;
    }
    dfs(i);
    cnt++;
}
cout<<cnt-1<<endl;
}


Measured memory_bytes: 18224
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//BELOW
void solve(void)
{
  int H, W, k;
  cin >> H >> W >> k;
  vector<vector<char>> MAZE(H, vector<char>(W));
  pair<int, int> START, GOAL;
  for (int h = 0; h < H; h++)
  {
    for (int w = 0; w < W; w++)
    {
      cin >> MAZE[h][w];
      if (MAZE[h][w] == 'S')
      {
        START.first = h;
        START.second = w;
        MAZE[h][w] = '.';
      }

      if (MAZE[h][w] == 'G')
      {
        GOAL.first = h;
        GOAL.second = w;
        MAZE[h][w] = '.';
      }
    }
  }
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  vector<vector<int>> dist(H, vector<int>(W, INF));

  queue<pair<int, int>> q;
  q.push(START);
  dist[START.first][START.second] = 0;
  while (!q.empty())
  {
    pair<int, int> point = q.front();
    q.pop();
    if (point == GOAL)
      break;

    for (int i = 0; i < 4; i++)
    {
      int nx = point.second + dx[i];
      int ny = point.first + dy[i];
      if (nx >= 0 && ny >= 0 && nx < W && ny < H && MAZE[ny][nx] != '#' && dist[ny][nx] == INF)
      {
        q.push(pair<int, int>(ny, nx));
        dist[ny][nx] = dist[point.first][point.second] + 1;
      }
    }
  }

  int res = INF;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (dist[i][j] <= k)
      {
        chmin(res, (i + k - 1) / k);
        chmin(res, (j + k - 1) / k);
        chmin(res, (H - 1 - i + k - 1) / k);
        chmin(res, (W - 1 - j + k - 1) / k);
      }
    }
  }
  cout << res + 1 << endl;

  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 9284
import sys
from io import StringIO
import unittest
from collections import Counter

def resolve():
    n = int(input())
    a = sorted(list(map(int, input().split())))

    counter = Counter(a)

    ans = 0

    for key, value in counter.items():
        if key == 0:
            tmp = counter[key + 1] + value
        else:
            tmp = counter[key + 1] + counter[key] + counter[key - 1]

        if ans < tmp:
            ans = tmp

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 17048
#include <cstdio>

int main() {
	int h, w;
	while(scanf("%d%d", &h, &w) == 2 && (h || w)) {
		for(int i = 1; i <= h; i++) {
			if(i == 1 || i == h) for(int j = 1; j <= w; j++) putchar('#');
			else {
				putchar('#');
				for(int j = 1; j <= w - 2; j++) putchar('.');
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
constexpr long long int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	long long int a=0,b=1;
	for(int i=0;i<N;i++){
		cin>>L>>R;
		if(L==1){
			a*=R;
			b*=R;
		}
		else if(L==2){
			a+=R;
			b+=R;
		}
		else{
			a-=R;
			b-=R;
		}
	}
	cout<<-a<<" "<<(b-a)<<endl;
	
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
  int N, K, S;
  cin >> N >> K >> S;
  for (int n = 0; n < K; ++n) {
    cout << S << ' ';
  }
  for (int n = 0; n < N-K; ++n) {
    if (S >= 3) {
      cout << S-1 << ' ';
    } else {
      cout << 3 << ' ';
    }
  }
  
  return 0;  
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i, a in enumerate(A):
    S.append(S[i]+A[i])
S.sort()
cur = 0
add = 1
ans = 0
for i in range(N):
    if S[i] == S[i+1]:
        ans += add
        add += 1
    else:
        add = 1

print(ans)


Measured memory_bytes: 26136
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int L,R,d;
	scan(L>>R>>d);
	int ans=0;
	for(int i=L;i<=R;i++){
		if(i%d==0) ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 3592
S = [i for i in input()]
T = input()
tmp = S.copy()

key = len(T)

SS = []
for i in range(len(S)-key+1):
    idx, flg = 0, 0
    for j in range(i, i+key):
        if S[j] != T[idx] and S[j] != '?':
            flg = 1
            break
        idx += 1
    if flg == 0:
        idx = 0
        for j in range(i, i+key):
            S[j] = T[idx]
            idx += 1
        SS.append(S)
        S = tmp.copy()

if SS:
    idx = 0
    for i in SS:
        idx_2 = 0
        for j in i:
            if j == '?':
                SS[idx][idx_2] = 'a'
            idx_2 += 1
        idx += 1
    print(''.join(min(SS)))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
import itertools

def main():

    data = []
    while True:
        n, x = map(int, input().split())
        if [n, x] == [0, 0]: break
        data.append([n, x])

    for [n, x] in data:
        _list = list(range(1, n+1))
        comb = set(itertools.combinations(_list, 3))
        print(sum((True if sum(i) == x else False) for i in comb))


main()

Measured memory_bytes: 45656
#include<iostream>
using namespace std;
int main(){
 unsigned c,c1,c5,c10,c50,c100,c500;
 cin>>c1>>c5>>c10>>c50>>c100>>c500;
 c=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;
 cout<<(c>=1000)<<endl;

 return 0;
}

Measured memory_bytes: 1160
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static public void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] aArray = new int[n];
		for (int i = 0; i < n; i++) {
			aArray[i] = scan.nextInt();
		}
		scan.close();

		long count = 0L;
		long sum = 0L;
		Map<Long, Integer> sumMap = new HashMap<>();
		sumMap.put(0L, 1);
		for (int i = 0; i < n; i++) {
			sum += aArray[i];
			if (sumMap.containsKey(sum)) {
				int sumCount = sumMap.get(sum);
				count += sumCount;
				sumMap.put(sum, sumCount + 1);
			} else {
				sumMap.put(sum, 1);
			}
		}
		System.out.println(count);
	}
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n,k;cin>>n>>k;
    ll ans=k;
    rep(i,n-1)ans*=k-1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val log2 = Math.log(2.0)
    val p = (1..Math.min(n, k)).map { 1 / Math.pow(2.0, Math.ceil(Math.log(k.toDouble() / it) / log2)) }.sum()
    if (k <= n) {
        println(p / n + (n - k).toDouble() / n)
    } else {
        println(p / n)
    }
}


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

int K, X;

int main() {
    cin >> K >> X;
    int left = X - (K - 1);
    // left = max(left, -1000000);

    int right = X + (K - 1); 
    // right = min(right, 1000000);

    for (int i = left; i <= right; i++) {
        cout << i << " ";
    }
    printf("\n");
}


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



int main()
{
	long long int r,D,x,i,j;
	cin >> r >> D >> x;
	
	for(i=0;i<10;i++)
	{
		j = r*x-D;
		cout << j << endl;
		x=j;
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  int res = INT_MAX;
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }

  for (int i = 0; i <= n-k; i++)
  {
    int l = v[i];
    int r = v[i+k-1];
    res = min(res, r - l + min(abs(l),abs(r)));
  }

  cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

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

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

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

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

const int MAX = 1000 * 100 + 47;
const int MIN = 404;
const int MOD = INF;

LL DP[111][2];

int main()
{
    // freopen("in.txt", "r", stdin);
    int n, p;
    cin >> n >> p;
    
    DP[0][0] = 1;

    FOR(i, 0, n)
    {
        int x;
        cin >> x;
        x &= 1;
        DP[i+1][x]+=DP[i][0];
        DP[i+1][x^1] += DP[i][1];
        DP[i+1][0] += DP[i][0];
        DP[i+1][1] += DP[i][1];
    }
    cout << DP[n][p] << endl;
    
    return 0;
}





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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if(r <= x && x <= (w-r) && r <= y && y <= (h-r)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3104
n = int(input())
a = n//15
b = n//3
c = n//5
wa = 0
for n in range(n+1):
    wa += n
for n in range(a+1):
    wa +=15*n
for n in range(b+1):
    wa -=3*n
for n in range(c+1):
    wa -=5*n
print(wa)

Measured memory_bytes: 9128