akhauriyash/Code-Regression huggingface dataset:
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    if (B + C >= A) {
        ans = B + C - A;
    } else {
        ans = 0;
    }

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime"
	"runtime/pprof"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	buf := make([]byte, 0, 64*1024)
	sc.Buffer(buf, 1024*1024)
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
var memprofile = flag.String("memprofile", "", "write memory profile to `file`")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal("could not create CPU profile: ", err)
		}
		defer f.Close() // error handling omitted for example
		if err := pprof.StartCPUProfile(f); err != nil {
			log.Fatal("could not start CPU profile: ", err)
		}
		defer pprof.StopCPUProfile()
	}

	s := scanString()
	answer := countDigit(s)
	fmt.Println(answer)

	if *memprofile != "" {
		f, err := os.Create(*memprofile)
		if err != nil {
			log.Fatal("could not create memory profile: ", err)
		}
		defer f.Close() // error handling omitted for example
		runtime.GC()    // get up-to-date statistics
		if err := pprof.WriteHeapProfile(f); err != nil {
			log.Fatal("could not write memory profile: ", err)
		}
	}
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func countDigit(s string) int {
	cache := make([][]int, len(s)) // [pos][remainder]
	for i := 0; i < len(s); i++ {
		cache[i] = make([]int, 13)
	}
	mul := 1
	for i := len(s) - 1; i >= 0; i-- {
		v := s[i]
		digit := len(s) - 1 - i
		if v == '?' {
			for j := 0; j < 10; j++ {
				currentRemainder := j * mul % 13
				// 123:
				//   3 % 13 =  3
				//  23 % 13 = 10
				//  20 % 13 =  7
				// 123 % 13 =  6
				// 100 % 13 =  9
				if digit > 0 {
					for k := 0; k < 13; k++ {
						tmp := (currentRemainder + k) % 13
						cache[i][tmp] += cache[i+1][k]
						if cache[i][tmp] > 1000000007 {
							cache[i][tmp] %= 1000000007
						}
					}
				} else {
					cache[i][currentRemainder]++
					if cache[i][currentRemainder] > 1000000007 {
						cache[i][currentRemainder] %= 1000000007
					}
				}
			}
		} else {
			integer, _ := strconv.Atoi(string(v))
			currentRemainder := integer * mul % 13

			if digit > 0 {
				for k := 0; k < 13; k++ {
					tmp := (currentRemainder + k) % 13
					cache[i][tmp] += cache[i+1][k]
					if cache[i][tmp] > 1000000007 {
						cache[i][tmp] %= 1000000007
					}
				}
			} else {
				cache[i][currentRemainder]++
				if cache[i][currentRemainder] > 1000000007 {
					cache[i][currentRemainder] %= 1000000007
				}
			}
		}
		mul *= 10
		mul %= 13
	}
	return cache[0][5] % 1000000007
}


Measured memory_bytes: 16276
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int MOD = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h)  cin >> s[i];
    vector<vector<int>> u(h,vector<int>(w,0)),d(h,vector<int>(w,0)),r(h,vector<int>(w,0)),l(h,vector<int>(w,0));
    rep(i,h) rep(j,w){
        if(s[i][j]=='#'){
            u[i][j] = 0;l[i][j] = 0;
        }
        else{
            if(i==0 && j==0){
                u[i][j] = 1;
                l[i][j] = 1;
            }
            else if(i==0){
                u[i][j] = 1;
                l[i][j] = l[i][j-1] + 1;
            }
            else if(j==0){
                u[i][j] = u[i-1][j] + 1;
                l[i][j] = 1;
            }
            else{
                u[i][j] = u[i-1][j] + 1;
                l[i][j] = l[i][j-1] + 1;
            }
        }
    }
    for(int i=h-1; i>=0; i--) for(int j = w-1; j>=0; j--){
        if(s[i][j]=='#'){
            d[i][j] = 0;r[i][j] = 0;
        }
        else{
            if(i==h-1 && j==w-1){
                d[i][j] = 1;
                r[i][j] = 1;
            }
            else if(i==h-1){
                d[i][j] = 1;
                r[i][j] = r[i][j+1] + 1;
            }
            else if(j==w-1){
                d[i][j] = d[i+1][j] + 1;
                r[i][j] = 1;
            }
            else{
                d[i][j] = d[i+1][j] + 1;
                r[i][j] = r[i][j+1] + 1;
            }
        }
    }
    int ans = 0;
    rep(i,h) rep(j,w){
        ans = max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
    } 
    cout << ans << '\n';
}

Measured memory_bytes: 67200
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define FOR(i,m,n) for(int i=(m); i<(n); i++)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RFOR(i,n,m) for(int i=(n);i>=(m); i--)
#define RREP(i,n) for(int i=(n-1); (i)>=0; i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = 100100100;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int n;
int happy[110000][3];
int dp[110000][3];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    FOR(i,1,n+1)
    {
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }
    FOR(i,1,n+1)
    {
        REP(place,3)
        {
            REP(placeY,3)
            {
                if(place == placeY) continue;
                dp[i][place] = max(dp[i][place], dp[i-1][placeY] + happy[i][place]);
            }
        }
    }
    int ans = 0;
    REP(place,3)
    {
        ans = max(ans, dp[n][place]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
n=int(input())
c=[0 for i in range(100)]

for i in range(n+1):
  s=str(i)
  if s[-1]==0:
    continue
  c[int(s[0])*10+int(s[-1])]+=1

ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=c[i*10+j]*c[i+j*10]
print(ans)

Measured memory_bytes: 73132
#include <iostream>

int main(){
    int x, y;
    std::cin >> x >> y;

    int ans = 0;
    ans += 100000 * (std::max(0, 4 - x));
    ans += 100000 * (std::max(0, 4 - y));

    if(1 == x * y){
        ans += 400000;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    
    int ans = 0;
    int x = 0;
    for(int i = 0; i < N; i++){
        cin >> x;
        ans += 2*min(x,K-x);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll Q = 0;
ll ret = 0;
priority_queue<ll, vector<ll>, less<ll>> L;
priority_queue<ll, vector<ll>, greater<ll>> R;
ll a = 0; //傾き0区間の値
ll b = 0; //bの累積

int main(void){
  
  I(Q);
  L.push(-INF);
  R.push(INF);

  ll c, x, y;
  REP(i, Q) {
    I(c);
    if (c == 1) {
      I(x);
      I(y);
      if (x < L.top()) a += L.top() - x;
      if (x > R.top()) a += x - R.top();
      b += y;
      if (x <= R.top()) {
        L.push(x);
        L.push(x);
      } else {
        R.push(x);
        R.push(x);
      }
      if (L.size() > R.size()) {
        R.push(L.top());
        L.pop();
      }
      if (L.size() < R.size()) {
        L.push(R.top());
        R.pop();
      }
    } else {
      cout << L.top() << " " << a+b << endl;
    }
  }

}


Measured memory_bytes: 4588
n=int(input())
def factorization(n):
  primen = []
  degree = []
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend#primen,degree
pn=[0]*(n+1)
for i in range(1,n+1):
  for j in factorization(i):
    pn[j[0]]+=j[1]
ans = 1
for k in range(2,n+1):
  ans*=(pn[k]+1)%(10**9+7)
print(ans%(10**9+7))


Measured memory_bytes: 3188
#include <iostream>

int digitTotal(int x)
{
	int d5 = x / 10000;
	int d4 = (x - d5 * 10000) / 1000;
	int d3 = (x - d4 * 1000 - d5 * 10000) / 100;
	int d2 = (x - d3 * 100 - d4 * 1000 - d5 * 10000) / 10;
	int d1 = x - d2 * 10 - d3 * 100 - d4 * 1000 - d5 * 10000;
	return d1 + d2 + d3 + d4 + d5;
}

int main()
{
	int n, a, b;

	std::cin >> n >> a >> b;

	int total;
	int sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		total = digitTotal(i);
		if (total >= a && total <= b)
			sum += i;
	}

	std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int w,h;
  char s[2];
  scanf("%d %d %s",&w,&h,s);
  FOR(h){
    FORJ(w){
      if(i==h/2&&j==w/2){
        PRC(s[0]);
      }else if(j==0){
        if(i==0||i==h-1){
          PRC('+');
        }else{
          PRC('|');
        }
      }else if(j==w-1){
        if(i==0||i==h-1){
          PRS("+");
        }else{
          PRS("|");
        }
      }else if(i==0||i==h-1){
        PRC('-');
      }else{
        PRC('.');
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2096
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        long k = scanner.nextLong();
        IntStream.range(0, n)
                .boxed()
                .collect(Collectors.toMap(i -> scanner.nextInt(), i -> scanner.nextLong(), Long::sum, TreeMap::new))
                .entrySet().stream()
                .reduce(k, (rem, entry) -> {
                    if (rem != null && (rem -= entry.getValue()) <= 0) {
                        System.out.println(entry.getKey());
                        return null;
                    }
                    return rem;
                }, Long::sum);
    }
}

Measured memory_bytes: 68600
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define ci(n) cin >> n
#define co(n) cout << n << endl
using namespace std;

int main(){
  int n;
  cin >> n;
  int a=6, b;
  while(a>=0){
    b=pow(2, a);
    if(n>=b) break;
    else a--;
  }
  co(b);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1000005;
typedef long long ll;
ll n;
int ans=0;
void f(ll x,ll a,ll b,ll c){
	if(x>n)
	    return;
	if(a&&b&&c) 
	    ans++;
	f(x*10+3,a+1,b,c);
	f(x*10+5,a,b+1,c);
	f(x*10+7,a,b,c+1);
}
int main(){
	scanf("%lld",&n);
	f(0,0,0,0);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    print(a + b if a + b < 10 else "error")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

# define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vpl ba(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ba[i] = make_pair(b, a);
    }
    sort(ba.begin(), ba.end());
    ll sum = 0;
    string ans = "Yes";
    for (auto a: ba){
        sum += a.second;
        if (sum > a.first) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3456
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(d => if (d.size == 1) '0' + d else d)).toSeq
    println(in.flatMap(_.tail.grouped(2).map(x => x(0) + ':' + x(1))).distinct.sorted.map(s =>
        if (s.takeWhile(_ != ':').size == 2 && s(0) == '0') s.tail else s
    ).mkString(" "))
}

Measured memory_bytes: 44704
// B - Kleene Inversion
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	ll a = 0, b = 0;

	vector<ll> A(N);
	for(int i=0; i<N; i++){
		cin>>A[i];
		for(int j=0; j<i; j++) a += A[i]<A[j];
	}

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) b += A[i]>A[j];

	ll kC2 = K*(K-1)/2 % MOD;
	a = a * K % MOD;
	b = b * kC2 % MOD;
	cout<< (a+b) % MOD << endl;
}

Measured memory_bytes: 256
a, b = [int(i) for i in input().split(" ")]
h = 96
w = 96
ca = 512 - a
cb = 512 - b

print(w, h)

m = [[False for j in range(0, h)] for i in range(0, w)]

for i in range(0, 32 * 3):
    for j in range(0, 32 * 3):
        m[i][j] =  (i // 3 + j // 3) % 2 == 1

for i in range(0, min(ca, 15)):
    for j in range(i * 6 + 3, i * 6 + 6):
        m[0][j] = False
        
ca -= min(ca, 15)

for i in range(0, min(ca, 15)):
    for j in range(i * 6 + 3, i * 6 + 6):
        m[j][0] = False
    
ca -= min(ca, 15)

k = 0
while ca > 0:
    for i in range(0, min(ca, 16)):
        m[3 * k + 2][6 * i + 3] = False
    ca -= min(ca, 16)
    k += 1
    for i in range(0, min(ca, 15)):
        m[3 * k + 2][6 * i + 6] = False
    ca -= min(ca, 15)
    k += 1
    
    
for i in range(0, min(cb, 15)):
    for j in range(i * 6 + 3, i * 6 + 6):
        m[95][j] = True
        
cb -= min(cb, 15)

if cb > 0:
    cb -= 1
    m[93][95] = True
    m[94][95] = True
    m[95][95] = True
    m[95][94] = True
    m[95][93] = True

for i in range(0, min(cb, 15)):
    for j in range(i * 6 + 3, i * 6 + 6):
        m[92 - j][95] = True
    
cb -= min(cb, 15)

k = 0
while cb > 0:
    for i in range(0, min(cb, 15)):
        m[92 - 3 * k][6 * i + 6] = True
    cb -= min(cb, 15)
    k += 1
    for i in range(0, min(cb, 16)):
        m[92 - 3 * k][6 * i + 3] = True
    cb -= min(cb, 16)
    k += 1

for i in range(0, 32 * 3):
    s = ""
    for j in range(0, 32 * 3):
        if m[i][j]:
            s = s + "#"
        else:
            s = s + "."
    print(s)

Measured memory_bytes: 39664
N, M, X = gets.chomp.split(' ').map(&:to_i)
C = Array.new
N.times do |i|
  C[i] = gets.chomp.split(' ').map(&:to_i)
end
min = Float::INFINITY
 
N.times do |i|
  combinations = (0..N-1).to_a.combination(i+1).to_a
  combinations.each do |combination|
    sum = Array.new(M+1, 0)
    (M+1).times do |k|
      (i+1).times do |j|
      	sum[k] += C[combination[j]][k]
      end
    end
    if sum.slice(1..-1).all?{ |value| value >= X }
      min = [min, sum[0]].min
    end
  end
end
 
p (min.infinite? ? -1 : min)

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
using namespace std;
const int N = 220;
int g[N][N], r[N];
int main(){
	memset(g, 0, sizeof(g));
	int n, m, R;
	cin >> n >> m >> R;
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= n; j ++) {
			g[i][j] = i==j?0:Inf;
		}
	}
	for(int i = 1; i <= R; i ++) {
		cin >> r[i];
	}
	for(int i = 1; i <= m; i ++) {
		int v, u, w;
		cin >> v >> u >> w;
		if(g[u][v] > w) {
			g[u][v] = g[v][u] = w;
		}
	}
	for(int k = 1; k <= n; k ++) {
		for(int i = 1; i <= n; i ++) {
			for(int j = 1; j <= n; j ++) {
				g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
			}
		}
	}
	sort(r+1, r+1+R);
	int ans = Inf;
	do{
		int ans1 = 0;
		for(int i =  1; i < R; i ++) {
			ans1 += g[r[i]][r[i+1]];
		}
		ans = min(ans, ans1);		
	}while(next_permutation(r+1,r+1+R));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    string s;
    ll len;
    ll b_left=0, a_right=0, both=0;
    ll cnt=0;
    rep(i,n){
        cin >> s;
        len = s.size();
        if(s[0] == 'B' && s[len-1] == 'A') both++;
        else{
            if(s[0] == 'B') b_left++;
            if(s[len-1] == 'A') a_right++;
        }
        rep(i,len-1){
            if(s[i] == 'A' && s[i+1] == 'B') cnt++;
        }
    }
    if(both > 0 && b_left == 0 && a_right == 0) both--;
    ll ans = cnt + min(b_left + both, a_right + both);
    cout << ans << endl;
    //cout << b_left << a_right << both;
}

Measured memory_bytes: 256
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
A.sort()
F.sort(reverse=True)
maxi = 0
for i in range(N):
    maxi = max(maxi,A[i]*F[i])
start=0
end = maxi
while True:
    count = 0
    value = (start+end)//2
    for i in range(N):
        count += max(0,A[i]-value//F[i])
    if count > K :
        if 2 > end-start:
            value +=1
            break
        start = value
    else:
        if 2 > end-start:
            break
        end = value
print(value)

Measured memory_bytes: 128968
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,t,i,j;(n=s.nextInt()+1)>1;){long[][]a=new long[n][n];for(i=0;i<n;a[i][i++]=0)Arrays.fill(a[i],n*n);for(t=s.nextInt();t-->0;)a[i=s.nextInt()][j=s.nextInt()]=a[j][i]=1;for(t=1;t<n;++t)for(i=1;i<n;++i)for(j=1;j<n;++j)if(a[i][j]>a[i][t]+a[t][j])a[i][j]=a[i][t]+a[t][j];t=0;for(long m:a[1])if(m<3)++t;System.out.println(t-1);}}}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

// うし木(一点更新区間取得) : 1-indexed
// min 更新 RMQ
// auto f = [](int a, int b) { return min(a, b); };
// SegmentTree<int, decltype(f)> seg(f, INT_MAX);
template <typename T, typename F>
struct SegmentTree {
    // using F = function<T(T, T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f, T ti) : f(f), ti(ti) {}

    void init(int n_) {
        n = 1;
        while (n < n_)
            n <<= 1;
        dat.assign(n << 1, ti);
    }

    void build(const vector<T> &v) {
        int n_ = v.size();
        init(n_);
        for (int i = 0; i < n_; i++)
            dat[n + i] = v[i];
        for (int i = n - 1; i; i--)
            dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }

    void set_val(int k, T x) {
        dat[k += n] = x;
        while (k >>= 1)
            dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }

    T query(int a, int b) {
        T vl = ti, vr = ti;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    auto f = [](int a, int b) { return min(a, b); };
    SegmentTree<int, decltype(f)> seg(f, pow(2, 31) - 1);
    seg.build(vi(n, pow(2, 31) - 1));
    rep(i, q) {
        int cond, a, b;
        cin >> cond >> a >> b;
        // debug(a);
        // debug(b);
        if (cond) {
            out(seg.query(a, b + 1));
        } else {
            seg.set_val(a, b);
        }
    }
}



Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	ll n, x=7, ans=1;
	cin >> n;
	if((n%2) == 0) {
		cout << "-1\n";
		return 0;
	}
	while(true) {
		if((x % n) == 0) {
			cout << ans << '\n';
			return 0;
		}
		x *= 10;
		x += 7;
		x %= n;
		ans++;
		if(ans > 1000001) {
			cout << -1 << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String line, str1;
        int m,h;
        for(;;) {
            line = br.readLine();
            if(line.equals("-")) break;
            m = Integer.parseInt(br.readLine());
            for(int i = 0; i < m; i++) {
                h = Integer.parseInt(br.readLine());
                str1 = line.substring(0, h);
                line = line.substring(h, line.length()) + str1;
            }
            sb.append(line).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 24576
N=input()
N=N.split()
sum=0
flag1=0
flag2=0
for i in N:
    if(i=="5"):
        flag1=1
    if(i=="7"):
        flag2=1
    sum=sum+int(i)
if(sum == 17 and flag1 == 1 and flag2 == 1):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> cnt;
    UnionFind(int N) : par(N),cnt(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++){
            par[i] = i;
            cnt[i] = 1;
        }
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        cnt[ry]+=cnt[rx];
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    UnionFind tree(n);
    V vec(n);
    rep(i,m){
        ll s,t;
        cin>>s>>t;
        s--;t--;
        vec[s]++;
        vec[t]++;
        tree.unite(s,t);
    }
    rep(i,k){
        ll s,t;
        cin>>s>>t;
        s--;t--;
        if(tree.same(s,t)){
            vec[s]++;
            vec[t]++;
        }
    }
  /*  for(auto i:vec){
        cout<<i<<" ";
    }
    cout<<endl;*/
    rep(i,n){
        ll sum=tree.cnt[tree.root(i)];
        cout<<sum-vec[i]-1<<" ";
    }
    cout<<endl;
}


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

using namespace std;

void Main() {
    string S1, S2, S3;
    cin >> S1;
    cin >> S2;
    cin >> S3;
    cout << S1[0] << S2[1] << S3[2] << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3620
#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>
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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d;
  while(cin>>d,d) {
    int n, m; cin >> n >> m;
    int sd[n+1]; FOR(i,0,n-1) cin >> sd[i];
    sd[n-1] = 0;
    sd[n] = d;
    int k[m]; FOR(i,0,m) cin >> k[i];
    sort(sd, sd + n + 1);
    sort(k, k + m);
    int j = 0;
    int ans = 0;
    FOR(i,0,m) {
      while(k[i] > sd[j+1]) j++;
      // j - j + 1?????????k[i]?????????
      ans += min(sd[j+1] - k[i], k[i] - sd[j]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3456
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] sar = s.Split(' ');
			int a = int.Parse(sar[0]);
			int b = int.Parse(sar[1]);
			int c = int.Parse(sar[2]);
			if (a < b && b < c)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 8836
#cording: utf-8

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

H_temperature = []
H_abs = []
for i in range(N):
    H_temperature.append(T - H[i]*0.006)
    H_abs.append(abs(A - H_temperature[i]))

min_ind = H_abs.index(min(H_abs))
print(int(min_ind + 1))


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

using namespace std;

typedef long long ll;

int transform(int arr[], int n, int to) {
	int cost = 0;
	for (int i = 0; i < n; i++) {
		cost += (arr[i] - to) * (arr[i] - to);
	}
	return cost;
}

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

	int arr[n];
	for (int i = 0; i < n; i++) cin >> arr[i];

	int minCost = INT_MAX;
	for (int to = -100; to <= 100; to++) {
		minCost = min(minCost, transform(arr, n, to));
	}

	cout << minCost << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let n: i64 = iter.next().unwrap().parse().unwrap();
    let k: i64 = iter.next().unwrap().parse().unwrap();
    if n % k == 0 {
        println!("0")
    } else {
        println!("1");
    }
}


Measured memory_bytes: 4352
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
//using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 300005;
/*template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n,k;
    cin>>n>>k;
    int d=n-2;
    d=(d*d+d)/2;
    if(k>d) cout<<-1<<endl;
    else
    {
        int arr[n+1];
        for(int i=0;i<=n;i++) arr[i]=i+1;
        arr[n]=2;
        vector<pii>edge;
        for(int i=2;i<=n;i++) edge.pb({1,i});
        int cur=2;
        while(d>k)
        {
            edge.pb({cur,arr[cur]});
            arr[cur]++;
            if(arr[cur]>n) arr[cur]=2;
            cur++;
            if(cur>n) cur=2;
            d--;
        }
        cout<<edge.size()<<endl;
        for(pii p:edge)
        {
            cout<<p.ff<<' '<<p.ss<<endl;
        }
    }
}



Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	string s,t;cin>>s>>t;
	bool f=true;
	rep(i,s.size()){
		if(s[i]!=t[i])f=false;
	}
	puts(f?"Yes":"No");
}




Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

struct edge {
    int64_t cost;
    int to;
};

struct vertex_routecost {
    int64_t routecost;
    int vertex;

    bool operator>(const vertex_routecost& right) const {
        return routecost > right.routecost;
    }
};

std::vector<edge> edges[100000];
int64_t d[100000];
static const int64_t INF = 1LL << 33;

int main() {
    int v, e, r;
    std::cin >> v >> e >> r;
    std::fill_n(d, v, INF);
    for (int i = 0; i < e; i++) {
        int s, t, d;
        std::cin >> s >> t >> d;
        edges[s].emplace_back(edge {d, t});
    }

    // dijkstra
    std::priority_queue<vertex_routecost, std::vector<vertex_routecost>, std::greater<vertex_routecost>> que;
    que.emplace(vertex_routecost {0, r});

    while (!que.empty()) {
        auto v = que.top(); que.pop();
        if (v.routecost >= d[v.vertex]) {
            continue;
        }
        d[v.vertex] = v.routecost;
        for (auto& e: edges[v.vertex]) {
            que.emplace(vertex_routecost {v.routecost + e.cost, e.to});
        }
    }


    for (int i = 0; i < v; i++) {
        if (d[i] == INF) {
            std::cout << "INF" << std::endl;
            continue;
        }
        std::cout << d[i] << std::endl;
    }


    return 0;
}



Measured memory_bytes: 21620
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  double ans = 0.0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ans += 1.0 / a;
  }
  ans = 1.0 / ans;
  cout << ans << endl;
  return 0;
}


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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(2*n);
    for (int i = 0; i < n; ++i) {
        int a; scanf("%d", &a);
        v[i] = make_pair(a, 0);
    }
    for (int i = 0; i < n; ++i) {
        int a; scanf("%d", &a);
        v[n+i] = make_pair(a, 1);
    }
    sort(v.begin(), v.end());
    int k = v[0].second, u = 1;
    ll ans = 1;
    for (int i = 1; i < 2*n; ++i) {
        if(u == 0){
            k = v[i].second;
            u = 1;
            continue;
        }
        if(v[i].second == k) u++;
        else {
            (ans *= u) %= MOD;
            u--;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>

int main()
{
	int a, b, c;
	int num[] = { 0, 0, 0 };
	int tmp = 0;

	scanf("%d%d%d", &a, &b, &c);

	num[0] = a;
	num[1] = b;
	num[2] = c;

	while (num[0] > num[1] || num[1] > num[2])
	{
		for (int i = 0;i < 2; i++)
		{
			if (num[i] > num[i+1])
			{
				tmp = num[i+1];
				num[i+1] = num[i];
				num[i] = tmp;
			}
		}
	}

	printf("%d %d %d\n", num[0], num[1], num[2]);
	

	return 0;
}

Measured memory_bytes: 1024
n,a,b,c,d=map(int,input().split())
i=n//a
j=n//c
if n%a==0:
    pass
else:
    i+=1
if n%c==0:
    pass
else:
    j+=1
x=b*i
y=d*j
if x<=y:
    print(x)
else:
    print(y)



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

int main(){
    int A,B; cin >> A >> B;
    int cnt=0;
    for(int i=A;i<=B;i++){
        if(to_string(i)[0]==to_string(i)[4] && to_string(i)[1]==to_string(i)[3]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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>;


int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a>=k){
        cout << k << endl;
    }
    else if(a+b >= k){
        cout << a << endl;
    }
    else{
        int minus = k - (a+b);
        cout << a - minus << endl;
    }

    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}



ll find_all(const string str, const string subStr) {
    vector<ll> result;
    ll k=0;
    ll subStrSize = subStr.size();
    ll pos = str.find(subStr);
    
    while (pos != string::npos) {
        k++;
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
    
    return k;
}

int main() {
   long double ans=0.0000000000000;
    li k,n;
    cin >> n >> k;
    for(li i=1;i<=n;i++){
        ll x=i;
        long double y=1/(long double)n;
        for(li j=1;j<=100000;j++){
            if(x>=k){ans += (long double)y;break;}
            x=x*2;
            y=(long double)y/2;
        }
    }
  cout << fixed << setprecision(11);
    cout << ans << endl;
    return 0;
}



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=9e18+1;
const int inf=2e9;
const ll lnf=9e18;

ll com[1010][1010]; // com[n][k] -> nCk
void comb_table(int N){
  for(int i=0;i<=N;++i){
    for(int j=0;j<=i;++j){
      if(j==0 or j==i) com[i][j]=1ll;
      else com[i][j]=(com[i-1][j-1]+com[i-1][j]);
    }
  }
}
//Add comb_table(1000); in main function.

int main(){
  cout << fixed << setprecision(15);
  itn n,a,b; cin >> n >> a >> b;
  comb_table(1e3);
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  rsort(v);
  ld mx=0;
  rep(i,a){
    mx+=v[i];
  }
  mx/=a;
  cout << mx << endl;
  ll kagen=v[a-1];
  int cnt1=0;
  int cnt2=0;
  rep(i,n){
    if(v[i]>kagen) cnt1++;
    if(v[i]==kagen) cnt2++;
  }
  //cout << cnt1 << endl;
  //cout << cnt2 << endl;
  if(cnt1){
    cout << com[cnt2][a-cnt1] << endl;
    return 0;
  }
  ll ans=0;
  for(int i=a;i<=b;i++){
    ans+=com[cnt2][i-cnt1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 10756
#include<stdio.h>

int main(){
  int i,N,T,nn;
  scanf("%d %d",&N,&T);
  nn=1001;
  int c[N],t[N];
  
  for(i=0;i<N;i++){
    scanf("%d %d",&c[i],&t[i]);
    if(t[i]<=T){
      if(c[i]<nn)
        nn=c[i];
    }
  }
  
 if(nn==1001)
   printf("TLE");
  
  else printf("%d",nn);
  
}
  
  

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Grand_Contest_035
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            var N = Sarray()[0];
            var ai = Sarray();
            var sumxor = 0L;
            for (var i = 0; i < N; ++i)
            { sumxor ^= ai[i]; }
            if(0==sumxor)
            { WriteLine("Yes"); }
            else
            { WriteLine("No"); }
            Console.SetOut(sw);
        }
    }
}


Measured memory_bytes: 22496
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var inputDict = new SortedDictionary<string, int>(StringComparer.OrdinalIgnoreCase);
			var maxCount = 1;
			for (int i = 0; i < N; i++)
			{
				var value = Console.ReadLine();

				if (inputDict.ContainsKey(value))
				{
					inputDict[value]++; ;
					if (maxCount < inputDict[value])
					{
						maxCount = inputDict[value];
					}
				}
				else
				{
					inputDict.Add(value, 1);
//					inputDict[value] = 1;
				}
			}

//			var answerList = inputDict.Where(x => x.Value == maxCount);
			foreach (var answer in inputDict.Where(x => x.Value == maxCount))
			{
					Console.WriteLine(answer.Key);
			}

		}
	}
}

Measured memory_bytes: 40536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________
	int n;
	cin >> n;
	int a[n];
	int cnt = 0;
	zip(i, 0, n)
	{
		cin >> a[i];
		if (i % 2 == 0 && a[i] % 2)
			cnt++;
	}
	cout << cnt << en;



	return 0;
}



Measured memory_bytes: 3636