akhauriyash/Code-Regression huggingface dataset:
from pprint import pprint
# pprint(C)
import sys
from collections import Counter
from itertools import product, combinations

H, W, K = map(int, input().split())

C = []
for _ in range(H):
    C.append(input())

counter = Counter()
for row in C:
    counter.update(row)
n_blacks = counter['#']

if n_blacks < K:
    print(0)
    sys.exit()


board = ''
for row in C:
    board += row

bitboard = 0b0
for cell_index in range(len(board)):
    digit = len(board) - cell_index - 1
    if board[cell_index] == '#':
        bitboard |= 0b1 << digit
    else:
        bitboard |= 0b0 << digit

# print(board)
# 2 3 2
# ..#
# ###
# >>> ..####
# print('{:b}'.format(bitboard))
# 2 3 2
# ..#
# ###
# >>> 1111

def get_row_base_mask(n_col):
    ret = 0b0
    for c in range(n_col):
        ret |= 0b1 << c
    return ret

col_base_mask = get_row_base_mask(W)
# print('{:b}'.format(col_base_mask))
# sys.exit()

def get_col_base_maak(n_row):
    ret = 0b0


ans = 0
for mask_row in range(1<<H):
    for mask_col in range(1<<W):
        # mask_row, mask_col の場合
        black = 0
        for i in range(H):
            for j in range(W):
                # (i, j) が黒かどうかみたい
                if (mask_row >> i & 1) == 0 and (mask_col >> j & 1) == 0 and (C[i][j] == '#'):
                    black += 1
        # print('{:b} {:b} {}'.format(mask_row, mask_col, black))
        if black == K:
            ans += 1
        # b = '{:b}'.format(masked_board)

print(ans)

Measured memory_bytes: 9960
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();

        for (int i = N; i <= 999; ++i) {
            String s = Integer.toString(i);
            if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
                System.out.println(i);
                break;
            }

        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 32468
S = str(input())

if (S.count("N") !=0 and S.count("S") !=0) or (S.count("N") ==0 and S.count("S") ==0):
    if (S.count("W") !=0 and S.count("E") !=0) or (S.count("W") ==0 and S.count("E") ==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int K,S;
	long cnt = 0;
	cin >> K >> S;
	REP(i,K+1){
		REP(j,K+1){
			int z = S - i - j;

			if(z>=0 && z <= K && i+j == S - z){
				cnt++;
			}
		}
	}
	cout << cnt << endl; 
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;

    vector <int> E(N);
    
    int count = 0;
    for (int i = 0; i < N; i++){
        E[i] = count;
        if (S[i] == 'E'){
            count ++;
        }
    }

    count = 0;
    int max = 0;
    for (int i = N - 1; i >= 0; i--){
        if (E[i] + count > max){
            max = E[i] + count;
        }
        if (S[i] == 'W'){
            count ++;
        }
    }
    
    int ans = N - 1 - max;

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

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

typedef long long LL;


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

    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
    return 0;
}


Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a = sc.nextInt();
		
		int cnt = 1;
		while (a != 0) {
			System.out.println("Case " + cnt + ": " + a);
			a = sc.nextInt();
			cnt++;
		}
	}
}



Measured memory_bytes: 42048
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  map<char, int> po;
  po['s'] = r;
  po['r'] = p;
  po['p'] = s;
  string t;
  cin >> t;
  int score = 0;
  vector<bool> flag(n);
  REP(i, n) {
    if (i < k || t[i] != t[i - k] || flag[i - k]) {
      score += po[t[i]];
    } else {
      flag[i] = true;
    }
  }
  cout << score << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,L=0;cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;i++)cin>>l.at(i);
  sort(l.begin(),l.end());
  for(int j=n-1;j>=n-k;j--)L+=l.at(j);
  cout<<L<<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.typecons;
import std.range;
import std.container;

void main() {
	int n, day=1, cnt;
	scanf("%d\n", &n);
	int[][] as = new int[][n];
	int[] ds = new int[n];
	foreach(i; 0..n) {
		as[i] = readln.chomp.split.map!(a => a.to!int - 1).array;
	}
	auto q = DList!(Tuple!(int, int)).init;
	foreach(i, line; as) {
		q.insertBack(tuple(i.to!int, line[0]));
	}
	q.insertBack(tuple(-1, -1));
	for(;;) {
		auto x = q.front[0];
		auto y = q.front[1];
		q.removeFront;
		if (x < 0 && y < 0) {
			if (q.empty) break;
			++day;
			q.insertBack(tuple(-1, -1));
			continue;
		}
		if (as[x].empty || as[y].empty || as[x].front != y || as[y].front != x) continue;
		if (ds[x] == day || ds[y] == day) {
			q.insertBack(tuple(x, y));
			continue;
		}
		as[x].popFront;
		as[y].popFront;
		if (!as[x].empty) q.insertBack(tuple(x, as[x].front));
		if (!as[y].empty) q.insertBack(tuple(y, as[y].front));
		ds[x] = day;
		ds[y] = day;
		++cnt;
	}
	if (cnt == n*(n-1)/2) {
		day.write;
	}
	else {
		write(-1);
	}
}


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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	int max_length = -1;
	int sum_length = 0;

	for (int i = 0; i < N; i++) {
		cin >> L[i];
		if (L[i] > max_length) max_length = L[i];
		sum_length += L[i];
	}
	if (sum_length - max_length > max_length) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  vector<int> arr(x);
  for (int i = 0; i<x; i++){
    cin >> arr[i];
  }
  vector<vector<int> > B(1);
  for (int i = 0; i<x; i++){
    if (B.back().size() == 0){
      B.back().push_back(arr[i]);
    } else if (B.back().size() == 1){
      B.back().push_back(arr[i]);
    } else if (B.back().front() == B.back().back()){
      B.back().push_back(arr[i]);
    } else if (B.back().front() < B.back().back()){
      if (B.back().back() <= arr[i]){
        B.back().push_back(arr[i]);
      } else {
        B.push_back(vector<int>(1, arr[i]));
      }
    } else {
      assert(B.back().front()>B.back().back());
      if (B.back().back() >= arr[i]){
        B.back().push_back(arr[i]);
      } else {
        B.push_back(vector<int>(1, arr[i]));
      }
    }
  }
  cout << B.size();
    return 0;
}

Measured memory_bytes: 6196
#include<bits/stdc++.h>
using namespace std;
int n,ans[200010];
int main()
{
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		int temp;
		scanf("%d",&temp);
		ans[temp]++;
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4540
#include <iostream>
using namespace std;
int main(){
  int k,s;
  cin >> k >> s;
  int total_times = 0;
   for(int i=0;i<=k;++i){
     for(int j=0;j<=k;++j){
       int rem = s - i -j;
       //cout << i << " " << j << " " << rem << endl;
       if(rem<=k && rem >=0) total_times++;
     }
   }
 cout << total_times << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	S:=readBytes()
	var count int
	for _,s := range S{
		if s == 'x' {
			count++
		}
	}
	if 8 <= count {
		println("NO")
	} else {
		println("YES")
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
N, A, B, C, D = map(int, input().split())
S = input()
if "##" in S[A - 1: max(C, D)]:
	print("No")
	exit()
for i in range(B - 1, D):
	if S[i] == "." and S[i - 1] == ".":
		if D == N or C < D:
			print("Yes")
			exit()
		else:
			if S[i + 1] == ".":
				print("Yes")
				exit()
print("No")


Measured memory_bytes: 3512
from copy import *
N=int(input())
S=input()
DP=[[[[0]*2 for i in range(2)] for j in range(2)] for k in range(N)]
mod=10**9+7
for i in range(N):
  for j in range(2):
    for k in range(2):
      for l in range(2):
        DP[i][j][k][l]=[[],[],0]
if S[0]=='X':
  DP[0][0][1][0]=[[],[],1]
else:
  DP[0][0][0][1]=[[],[],1]
  DP[0][1][1][1]=[[1],[],mod-1]
g1=[1,1]
g2=[1,1]
inv=[0,1]
c=[1,2]
for i in range(2,N+5):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
  c.append((c[-1]+g2[i])%mod)

def add(x,y):
  for j in range(2):
    for i in range(len(y[j])-len(x[j])):
      x[j].append(0)
    for i in range(len(y[j])):
      x[j][i]=(x[j][i]+y[j][i])%mod
  x[2]=(x[2]+y[2])%mod

def integrate(p):
  p[2]=-p[2]%mod
  for j in range(2):
    p[j].append(0)
    for i in range(len(p[j])-2,-1,-1):
      p[j][i+1]=p[j][i]*inv[i+1]%mod
      p[j][i]=0

def fx0(p):
  integrate(p)
  p[0][0]=(p[0][0]-p[2])%mod

def f1x(p):
  integrate(p)
  for j in range(2):
    for i in range(len(p[j])):
      p[j][i]=-p[j][i]%mod
  p[2]=-p[2]%mod
  for i in range(2):
    p[i][0]=-sum(p[i])%mod
  p[1][0]=(p[1][0]-p[2])%mod

for i in range(N-1):
  if S[i+1]=='X':
    add(DP[i][1][1][0],DP[i][1][1][1])
    fx0(DP[i][1][1][0])
    add(DP[i][1][1][1],DP[i][1][0][1])
    add(DP[i][1][1][1],DP[i][0][1][1])
    add(DP[i][1][1][1],DP[i][0][0][1])
    f1x(DP[i][1][1][1])
    for j in range(2):
      add(DP[i+1][0][1][0],DP[i][1][1][j])
  else:
    t=[[],[],0]
    add(DP[i][0][1][0],DP[i][0][1][1])
    add(DP[i][1][1][0],DP[i][1][1][1])
    add(DP[i+1][1][1][1],DP[i][0][1][0])
    fx0(DP[i+1][1][1][1])
    add(t,DP[i][0][1][0])
    add(t,DP[i][1][1][0])
    f1x(t)
    fx0(DP[i][1][1][0])
    add(DP[i+1][0][0][1],DP[i][1][1][0])
    add(DP[i+1][0][0][1],t)

def f10(p,o,e):
  r=[0]*3
  q=deepcopy(p)
  integrate(q)
  r[0]=(sum(q[0])-q[2])*o%mod
  r[1]=(sum(q[1])+q[2])*o%mod
  for j in range(2):
    for i in range(len(p[j])):
      r[j]=(r[j]+p[j][i]*g1[i]*e)%mod
      r[j+1]=(r[j+1]-p[j][i]*g1[i]*c[i]*e)%mod
  r[0]=(r[0]+p[2]*inv[2]*e)%mod
  r[2]=(r[2]-p[2]*inv[2]*e)%mod
  return r

add(DP[-1][0][1][1],DP[-1][1][1][1])
add(DP[-1][0][1][0],DP[-1][1][1][0])
add(DP[-1][0][0][1],DP[-1][1][0][1])
X=[f10(DP[-1][0][1][1],1,0),f10(DP[-1][0][1][0],0,1),f10(DP[-1][0][0][1],1,mod-1)]
A=[sum(map(lambda x:x[i],X))%mod for i in range(3)]
print(*A)

Measured memory_bytes: 95408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	char C;
	cin >> C;
	char ans = (char)((int)C + 1);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32)::n,i,j,x,y
    integer(int32), allocatable:: a(:)
    logical:: pc, sc
    logical,allocatable:: t(:)


    read*, n
    allocate(a(n))
    read*, a(:)
    allocate(t(maxval(a)), source=.false.)
    pc = .true.
    do i=1,n
        j=1
        do while(j*j <= a(i))
            if (mod(a(i),j) == 0) then
                x = a(i)/j
                y = j
                if (t(x) .and. x > 1) pc = .false.
                if (t(y) .and. y > 1) pc = .false.
                t(x) = .true.
                t(y) = .true.
            end if
            if (.not. pc) exit
            j=j+1
        end do
        if (.not. pc) exit
    end do

    x = a(1)
    do i=2,n
        x = gcd(x,a(i))
    end do
    sc = x == 1

    if (pc) then
        print'(a)', "pairwise coprime"
    else if (sc) then
        print'(a)', "setwise coprime"
    else
        print'(a)', "not coprime"
    end if
contains
    function lcm(x,y) result(ret)
        integer(int32):: x,y,ret
        ret=x*y/gcd(x,y)
    end function
    recursive function gcd(x,y) result(ret)
        integer(int32):: x,y,ret
    
        if (mod(x,y) == 0) then
            ret = y
            return
        end if
    
        ret = gcd(y,mod(x,y))
    end function
end program main

Measured memory_bytes: 10872
from heapq import *

R = lambda: map(int, input().split())
n, m = R()
c = [[] for _ in range(m)]
for _ in range(n):
    a, b = R()
    if a <= m:
        heappush(c[m - a], -b)
r=0
for i in range(m - 1, -1, -1):
    if c[i]:
        r -= heappop(c[i])
        if i:
            f = len(c[i]) > len(c[i - 1])
            h, g = (c[i], c[i - 1]) if f else (c[i - 1], c[i])
            for x in g:
                heappush(h, x)
            if f:
                c[i - 1] = c[i]       
print(r)


Measured memory_bytes: 75040
def move(lon, lat, com):
    target, other, pop_index, insert_index = lon, lat, 0, 3
    if com == "E" or com == "W":
        target, other = lat, lon
    if com == "S" or com == "W":
        pop_index, insert_index = 3, 0
    target.insert(insert_index, target.pop(pop_index))
    other[0], other[2] = target[0], target[2]


longitude = [1, 2, 6, 5]
latitude = [1, 4, 6, 3]
values = list(input().split())
command = input()
for c in command:
    move(longitude, latitude, c)
print("{}".format(values[longitude[0] - 1]))



Measured memory_bytes: 5568
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())


if B > A:
    if A - B + (V - W) * T >= 0:
        print("YES")
    else:
        print("NO")
else:
    if B - A + (V - W) * T >= 0:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define  maxn 300005
#define pb push_back
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)
#define INF 1000000007
int N;
int V[30],Rmost[maxn][30],Lmost[maxn][30];
int dpL[1<<20],dpR[1<<20];
int arr[maxn];
int dp[maxn];
int main()
{  cin>>N; cin>>V[0];
  forup(i,1,N) scanf("%d",&arr[i]);
 int M=1;
 while(V[M-1])
   { V[M]=V[M-1]/2;
     M++; 
   }
  for(int i=0;i<M;i++)
   { int v=V[i];
     int j=1;
      while(j<=N)
       { int k=j+1; 
         while(k<=N&&arr[k]-arr[k-1]<=v)  k++;
         for(int x=j;x<k;x++) Rmost[x][i]=k-1;
       j=k;
       }
   j=N;
     while(j>=1)
      {int k=j-1;
      while(k>=1&&arr[k+1]-arr[k]<=v) k--;
      for(int x=j;x>k;x--)  Lmost[x][i]=k+1; 
      j=k;
      }
    }
    for(int i=0;i<(1<<M);i++) dpR[i]=N+1;
    for(int i=1;i<(1<<M);i++)
     {  for(int j=0;j<M;j++)
         if(i&(1<<j))
         {int L=dpL[i^(1<<j)];
          dpL[i]=max(dpL[i],Rmost[L+1][j]);

          int R=dpR[i^(1<<j)];
          dpR[i]=min(dpR[i],Lmost[R-1][j]); 
         } 
     } 
    forup(i,0,N+1)  dp[i]=-INF;
    for(int i=0;i<(1<<M);i+=2)
      {int j=((1<<M)-1)^i^1;
        dp[dpR[j]]=max(dp[dpR[j]],dpL[i]);
      }
     forup(i,1,N+1)
      dp[i]=max(dp[i],dp[i-1]);
     forup(i,1,N)
     {int L=Lmost[i][0],R=Rmost[i][0];
      int det=dp[R+1];
      if(det>=L-1)   puts("Possible");
      else           puts("Impossible");
     }  
  return 0;
}

Measured memory_bytes: 61312
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5, MOD = 1e9 + 7;
int n, m, f[MAXN + 5];
bool p[MAXN + 5];

int main() {
	read(n), read(m);
	for (int x, i = 1; i <= m; ++i) {
		read(x);
		p[x] = 1;
	}
	f[0] = 1;
	f[1] = p[1] ? 0 : 1;
	for (int i = 2; i <= n; ++i)
		if (!p[i]) f[i] = (f[i - 1] + f[i - 2]) % MOD;
	write(f[n]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
typedef map<int,int> ma;
typedef set<int> se;
typedef vector<int> ve;
const int maxn=1e5+7;
const int mod=1e9+7;
const int N=1e5+7;
const int inf=1e9+7;
map<int,int> a;
int main() {
    int n,f=0,s;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&s);
        if(a[s]==1) f=1;
        else a[s]=1;
    }
    printf("%s\n",f==0?"YES":"NO");
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;


int main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  long long sum = 0;
  for (int i = 0; i < N; i++) sum += A[i] - 1;
  if (sum <= K) { cout << 1 << endl; return 0; }

  double epsilon = 0.1;
  int l = 1, r = pow(10, 9) + 1, m;
  while (r - l >= 2) {
    m = l + (r - l) / 2;
    sum = 0;
    for (int i = 0; i < N; i++) sum += (int) ((A[i] - epsilon) / m);

    if (sum <= K) r = m;
    else l = m;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3956
<?php

$count = trim(fgets(STDIN));

$rec_array = trim(fgets(STDIN));

$parts = explode(" ", $rec_array);

$array = array();

$string	 = '';
$i		 = 0;

if ($count % 2 == 0)
{

	for ($i = $count - 1; $i > 0; $i-=2)
	{
		$string .= $parts[$i]." ";
	}

	for ($i = 0; $i < $count; $i+=2)
	{
		$string .= $parts[$i]." ";
	}
}
else
{
	
		for ($i = $count-1; $i >= 0; $i-=2)
	{
		$string .= $parts[$i]." ";
	}
	

	
	for ($i = 1; $i < $count; $i+=2)
	{
		$string .= $parts[$i]." ";
	}
}


echo trim($string);
echo "\n";


Measured memory_bytes: 46436
#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;
    cin >> N;

    ll ans = 0LL;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += (ll)i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();
        long count = 0;
        for(long i = X;i <= Y;i *= 2){
            count++;
        }
        System.out.println(count);
    }
}


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



int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> a;

    for (int i = 0; i < (int)s.size(); i++){
        if (s[i] == s[i + 1]){
            a.push_back(1);
            i++;
        }else a.push_back(0);
    }

    ll ans = (a[0])?6:3;
    for (int i = 1; i < (int)a.size(); i++){
        if (a[i - 1] == 0) ans *= 2;
        else if (a[i] == 1) ans *= 3;
        ans %= MOD; 
    }

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

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-14
**/

#include <bits/stdc++.h>
using namespace std;

const int INF = 2e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m), d(m);
    vector<vector<int>> a(n);
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i] >> d[i];
        l[i]--; r[i]--;
        a[l[i]].push_back(i);
        a[r[i]].push_back(i);
    }
    
    stack<int> s;
    for (int i = 0; i < n; i++) {
        s.push(i);
    }
    
    vector<int> pos(n, INF);
    vector<bool> seen(n);
    while (!s.empty()) {
        int u = s.top();
        s.pop();
        if (seen[u]) continue;
        seen[u] = true;
        
        if (pos[u] == INF) {
            pos[u] = 0;
        }
        for (int i = 0; i < a[u].size(); i++) {
            int index = a[u][i];
            if (pos[l[index]] != INF && pos[r[index]] != INF) {
                if (pos[r[index]] - pos[l[index]] != d[index]) {
                    cout << "No" << '\n';
                    return 0;
                }
            }
            else if (pos[l[index]] != INF) {
                pos[r[index]] = pos[l[index]] + d[index];
                s.push(r[index]);
            }
            else {
                pos[l[index]] = pos[r[index]] - d[index];
                s.push(l[index]);
            }
        }
    }
    cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 13196
import sys

N, K = list(map(int, input().split()))

pre = N
while True:
    if N % K == 0 and N // K >= 1:
        print(0)
        sys.exit()
        
    if N > K:
        N = N % K
    else:
        N = abs(N-K)
    
    if pre <= N:
        print(pre)
        sys.exit()
    else:
        pre = N

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/


/****** define variable start ******/
ll n, k;
vl h;
/******* define variable end *******/

ll solve(){
    cin >> n >> k;
    h.resize(n);
    REP(i, n){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    ll ans = 0;
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }else{
        sort(h.begin(), h.end());
        REP(i, n-k){
            ans += h[i];
        }
    }
    cout << ans << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](auto lhs, auto rhs) {
        if (a[lhs] != a[rhs]) {
            return a[lhs] < a[rhs];
        } else {
            // 右から
            return lhs > rhs;
        }
    });

    int64_t l = numeric_limits<int64_t>::max();
    set<int64_t> s;
    int64_t ans = 0;
    for (auto ii : idx) {
        auto it = s.lower_bound(ii);
        if (it == s.begin()) {
            ++ans;
            s.insert(ii);
        } else {
            --it;
            s.erase(it);
            s.insert(ii);
        }
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    
    cin >> n;
    
    int a[100];
    
    for(int i=0; i<n;i++){
        cin >> a[i];
    }
    
    for(int i=0; i<n;i++){
        cout << a[n-i-1];
        if(i == n-1) cout << endl;
        else cout << ' ';
    }

    return 0;
}


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

using namespace std;

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int x = a + b, y = c + d;
	if(x > y) printf("Left\n");
	else if (x == y) printf("Balanced\n");
	else printf("Right\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      for (int k = 0; k < 10; ++k) {
        int a = -1, b = -1, c = -1;
        for (int l = 0; l < n; ++l) {
          if ((s[l] - '0') == i) {
            a = l;
            break;
          }
        }
        for (int l = a + 1; l < n; ++l) {
          if ((s[l] - '0') == j) {
            b = l;
            break;
          }
        }
        for (int l = b + 1; l < n; ++l) {
          if ((s[l] - '0') == k) {
            c = l;
            break;
          }
        }
        if (a != -1 && b != -1 && c != -1) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define VEC(kata, num) (kata*)malloc(num * sizeof(kata))
#define DB puts("ok")
#define SENTINEL 1000000007
typedef long long lli;


int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a < 6) {
        printf("0");
    } else if(a < 13) {
        printf("%d",b/2);
    } else {
        printf("%d",b);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(ll, n);
  cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
*A, = map(int, input().split())
ac = [0]*(N+1)
for i in range(1, N+1):
    ac[i] = ac[i-1] + A[i-1]

def f(pos1, pos2):
    v1 = ac[pos1]
    v2 = ac[i]-ac[pos1]
    v3 = ac[pos2]-ac[i]
    v4 = ac[N]-ac[pos2]
    return max(v1,v2,v3,v4)-min(v1,v2,v3,v4)

ans = 10**20
for i in range(2, N):
    pos1 = bisect_left(ac, ac[i]//2, 1, i-1)
    pos2 = bisect_left(ac, (ac[i]+ac[N])//2, i+1, N)
    ans = min(ans, f(pos1, pos2), f(pos1-1, pos2), f(pos1, pos2-1), f(pos1-1, pos2-1))

print(ans)

Measured memory_bytes: 120176
function Main(input) {
  input = input.split('\n');
  a = input[0];
  s = input[1];
  //var n = 0;
 
  if(a >= 3200){
    console.log(s);
  }else{
    console.log('red');
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
n=int(input())
a=[int(j) for j in input().split()]
p=[0]*n
d=[0]*n
for i in range(n):
    p[i]=a[i]+p[i-2]
    if (i&1):
        d[i]=max(p[i-1],a[i]+d[i-2])
    else:
        d[i]=max(d[i-1],a[i]+d[i-2])
print(d[-1])

Measured memory_bytes: 39868
n,x=map(int, input().split())
m=[]
ans=0
for i in range(n):
    mi=int(input())
    m.append(mi)
for i in range(n):
    a=n+(x-sum(m))//m[i]
    if a>=ans:
        ans=a
    else:
        continue
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
using i64 = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);

  for(auto& x : A) cin >> x;

  vector<int> cnt(N + 1,0);

  int ans = 1;

  for(auto x : A){
    cnt[x] = cnt[x - 1] + 1;
    ans = max(ans , cnt[x]);
  }

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

Measured memory_bytes: 1792
N=int(input())
P=[tuple(map(int,input().split())) for i in range(N)]
ans=N
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        p=P[i][0]-P[j][0]
        q=P[i][1]-P[j][1]
        cost=0
        for k in range(N):
            if (P[k][0]-p,P[k][1]-q) not in P:
                cost+=1
        ans=min(ans,cost)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python
"""AtCoder Beginner Contest 174: A - Air Conditioner
https://atcoder.jp/contests/abc174/tasks/abc174_a
"""


def main():
    X = int(input())

    if 30 <= X:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

int main(){

    int p; cin >> p;
    int ans = 0;
    ans += 10000 * (p/10000);
    p -= p - (p % 10000);

    ans += 5000 * (p/5000);
    p -= p - (p % 5000);

    ans += 1000 * (p/1000);
    p -= p - (p % 1000);

    ans += 500 * (p/500);
    p -= p - (p % 500);

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


Measured memory_bytes: 3092
A, B, C = map(int, input().split())
A, B, C = max(A, B, C), (A+B+C-max(A,B,C)-min(A,B,C)), min(A, B, C)
if (B + C) % 2 == 1:
	print((2 * A - B - C)//2 + 2)
else:
	print((2 * A - B - C)//2)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define MAXN 1000000

int N;
int A[MAXN],B[MAXN];

int main(){
  cin>>N;
  for(int i=0;i<N+1;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  long long ans=0;
  for(int i=0;i<N;i++){
    if(B[i]<A[i]){
      ans+=B[i];
      A[i]-=B[i];
    }
    else if(B[i]<A[i]+A[i+1]){
      ans+=B[i];
      A[i+1]-=B[i]-A[i];
      A[i]=0;
    }
    else{
      ans+=A[i]+A[i+1];
      A[i]=0;
      A[i+1]=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (h[i] <= h[i-1]) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
        swap(a, b);
    }
    if (a > c) {
        swap(a, c);
    }
    if (b > c) {
        swap(b, c);
    }
    cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pint pair<int,int>

int C[20];
int x[20100];

int dp[20100][300];

const int inf = 1LL << 60;

void calib(int &a){
  if( a < 0 ){ a = 0;}
  if( a > 255){ a = 255;}
  return;
}

void chmin(int &a, int b){ if ( a > b ){ swap(a,b);} return;}

signed main(void){
  int n,m; 
  while(cin >> n >> m){
    if( n == 0 && m == 0 ){ return 0;}
    
    for(int i = 1; i <= m; i++){ cin >> C[i];}
    for(int i = 1; i <= n; i++){ cin >> x[i];}
    
    for(int i = 0; i < 20100; i++){
      for(int j = 0; j < 300; j++){ 
        dp[i][j] = inf;
      }
    }
    
    dp[0][128] = 0;
   
    for(int i = 1; i <= n; i++){ 
      // i-1個目からi個目にかけての遷移を見る
      for(int val = 0; val <= 255; val++){ 
        if( dp[i-1][val] == inf ){ continue;}
        for(int k = 1; k <= m; k++){ //どの系列を選ぶか
         int res = val+C[k];
         calib(res);
         chmin( dp[i][res], dp[i-1][val]+(x[i]-res)*(x[i]-res) );
          
        }
      }
    }
    
    int ans = inf;
    
    for(int i = 0; i <= 255; i++){ 
      chmin(ans,dp[n][i]);
      
    }
    
    cout << ans << endl;
    
  }//while
  
  return 0;
}


Measured memory_bytes: 50368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int myGCD(int a, int b) {
	while(1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {
	int a, b, c, k;
	cin >> k;
	ll sum = 0;
	for (a = 1; a <= k; a++) {
		for (b = 1; b <= k; b++) {
			for (c = 1; c <= k; c++) {
				sum += myGCD(a, myGCD(b, c));
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
# https://atcoder.jp/contests/abc105/tasks/abc105_b

def main():
    N = int(input())
    for i in range(N//4 + 1):
        for j in range(N // 7 + 1):
            if 4 * i + 7 * j == N:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()




Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N;
    cin >> N;
    if((N < 7)&&(N%4 == 3)){
    	cout <<"No";
    }else if ((N < 14)&&(N%4 == 2)){
    	cout <<"No";
    }else if ((N < 21)&&(N%4 == 1)){
    	cout <<"No";
    }else{
    	cout <<"Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    int f=0;
    for(int i=0; i<9;i++){//掛け算
        for(int j=0; j<9;j++){

        if(N==(i+1)*(j+1)){//判定
            f=1;
        }
        }
    }
     if(f==1){
         cout << "Yes"<<endl;
     }else{
         cout << "No" <<endl;
     }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,w[50],r[50],b[50],cnt,i,j,k,x,y,mn;
	char buf[51];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	{
		scanf("%s",buf);
		w[i]=0;	r[i]=0;	b[i]=0;
		for(j=0;j<m;j++)	{
			if(buf[j]=='W')	w[i]++;
			if(buf[j]=='R')	r[i]++;
			if(buf[j]=='B')	b[i]++;
		}
	}
	mn=n*m;
	for(i=1;i<n-1;i++)	{
		for(j=2;j<n;j++)	{
			cnt=0;
			for(k=0;k<i;k++)	cnt+=r[k]+b[k];
			for(k=i;k<j;k++)	cnt+=w[k]+r[k];
			for(k=j;k<n;k++)	cnt+=w[k]+b[k];
			mn=min(mn,cnt);
//			printf("i=%d j=%d cnt=%d\n",i,j,cnt);
		}
	}
	printf("%d\n",mn);			
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

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

    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

    System.out.println(transferTask(a, b, c));
  }

  private static int transferTask(int a, int b, int c) {
    int result = c - (a - b);
    if(result < 0) {
      return 0;
    }
    return c - (a - b);
  }
}

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

using namespace std;

int main(){
    int n;
    long x;
    cin >> n >> x;
    long prev,now;
    long ans=0;
    cin >> prev;
    for(int i=1;i<n;i++){
        cin >> now;
        if(now+prev>x){
            ans+=now+prev-x;
            int t=now+prev-x;
            t-=now;
            if(t>0){
                now=0;
            }
            else{
                now-=t+now;
            }

        }
        prev=now;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

long long X, Y;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> X >> Y;
  long long res = 0;
  while(X <= Y){
    X = X*2;
    ++res;
  } 
  cout << res << "\n";
  return 0;  
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final int MODULUS = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(H, W, K));

        sc.close();
    }

    static int solve(int H, int W, int K) {
        int[] wayNums = new int[W];
        wayNums[0] = 1;

        for (int i = 0; i < H; ++i) {
            int[] nextWayNums = new int[wayNums.length];
            for (int code = 0; code < 1 << (W - 1); ++code) {
                if (isValid(code)) {
                    for (int pos = 0; pos < W; ++pos) {
                        int nextPos = computeNextPos(pos, code);

                        nextWayNums[nextPos] = addMod(nextWayNums[nextPos], wayNums[pos]);
                    }
                }
            }

            wayNums = nextWayNums;
        }

        return wayNums[K - 1];
    }

    static int addMod(int x, int y) {
        return (x + y) % MODULUS;
    }

    static boolean isValid(int code) {
        return !Integer.toBinaryString(code).contains("11");
    }

    static int computeNextPos(int pos, int code) {
        if ((code & (1 << pos)) != 0) {
            return pos + 1;
        } else if (pos != 0 && (code & (1 << (pos - 1))) != 0) {
            return pos - 1;
        } else {
            return pos;
        }
    }
}

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

typedef long long ll;

ll _gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

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


bool isPrime(ll n){
	bool f = true;
	for(int j=2;j*j<=n;++j){
		if(n%j== 0){
			f = false;
			break;
		}
	}
	return f;
}

vector<ll> v;


bool iVP(int n){
	for(int j=0;j<v.size();++j){
		if(gcd(v[j],n) != 1 || n ==v[j]){
			return false;
		}
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin >> a >> b;
	
	ll res = 0;
	ll n = gcd(a,b);
	
	//cout << n <<endl;
	for(ll i=2;i*i<=n;++i){
		//cout <<n << " " << i <<endl;
		if(n%i==0){
			res++;
			n/=i;
			while(n%i==0){
				n/=i;
			}
		}
	}
	if(n != 1) res++;
	
	cout<< res + 1  <<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;
#define PI 3.1415926535

int  main()
{
	int A,B,H,M;
	cin >> A >> B >> H >> M;
	double k;
	//長針
	double l = M*6;
	//tannsinn
	double s = (H*30) + (0.5*M);
	k = (s - l);
	if (k > 120)
		k = 360 - k;
	if (k < 0)
		k *= -1;

	int h = H, m = M;
    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

	double ans = (double)(A*A + B*B) - (double)2*A*B*cos(rad);

	printf("%.12f\n", sqrt(ans));
	// printf("%f", k);
	// printf("%Lf", rad);
	return (0);
}


Measured memory_bytes: 4148
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int n, k;
vector<int> w;
bool f(int p){
  int l = 0, r = n - 1;
  int wei = 0;
  int cnt = 0;
  FOR(i,0,n){
    if(w[i] > p) return false;
    if(wei + w[i] <= p){
      wei += w[i];
    } else {
      cnt++;
      wei = w[i];
    }
  }
  if(wei) cnt++;
  return cnt <= k;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>k;
  w.resize(n);
  FOR(i,0,n) cin>>w[i];
  // 二分探索
  int l = 0, r = 2e9;
  while(r - l > 1){
    int m = (r + l) / 2;
    if(f(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s;
        cin>>s;
        ll res=INF;
        for(char i='a';i<='z';i++){
            string s1=s;
            ll num=0;
            while(1){
                if(Size(s1)==0)break;
                bool c=true;
                rep(j,Size(s1)){
                    if(s1[j]!=i){
                        c=false;
                        break;
                    }
                }
                if(c){
                    chmin(res,num);
                    break;
                }
                num++;
                string s2="";
                rep(j,Size(s1)-1){
                    if(s1[j]==i||s1[j+1]==i)s2=s2+i;
                    else s2=s2+s1[j];
                }
                swap(s1,s2);
            }
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 3624