akhauriyash/Code-Regression huggingface dataset:
try:
    s=input()
    t=input()
    ls=len(s)
    lt=len(t)
    ans=float('inf')
    for i in range(ls-lt+1):
        s2=s[i:i+lt]
        m=0
        #print(s2)
        for j in range(lt):
            if s2[j]!=t[j]:
                m+=1
        ans=min(ans,m)
    print(ans)
except EOFError as e:
    print(e)
            
            


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

int main()
{
	int a = 0, b = 0, c = 0;
	char op;

	cin >> a >> op >> b;

	while (op !='?') {
		if (op == '+')
			c = a + b;
		else if (op == '-')
			c = a - b;
		else if (op == '*')
			c = a * b;
		else if (op == '/')
			c = a / b;

		cout << c << endl;
		cin >> a >> op >> b;
	}
	
	return 0;
}



Measured memory_bytes: 3064
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var map = new char[h, w];
        var mapo = new int[h, w];
        var mapi = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++) map[i, j] = s[j];
        }
        for (int i = 0; i < h; i++) if (map[i, w - 1] == 'O') mapo[i, w - 1] = 1;
        for (int i = 0; i < w; i++) if (map[h - 1, i] == 'I') mapi[h - 1, i] = 1;
        for (int i = 0; i < h; i++)
            for (int j = w - 2; j >= 0; j--)
            {
                mapo[i, j] = mapo[i, j + 1];
                if (map[i, j] == 'O') mapo[i, j]++;
            }
        for (int i = 0; i < w; i++)
            for (int j = h - 2; j >= 0; j--)
            {
                mapi[j, i] = mapi[j + 1, i];
                if (map[j, i] == 'I') mapi[j, i]++;
            }
        var count = 0L;
        for (int i = 0; i < h - 1; i++)
            for (int j = 0; j < w - 1; j++)
                if (map[i, j] == 'J') count += mapo[i, j] * mapi[i, j];
        Console.WriteLine(count);
    }
}


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

int main(){
	int n,taro[3][10000],hanako[3][10000],c,d,e,taro2,hanako2,ba;
	while(true){
		memset(taro,1,sizeof(taro));
		memset(hanako,1,sizeof(taro));
		c=0;
		d=0;
		cin>>n;
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			cin>>taro[0][i];
		}
		for(int i=1;i<=2*n;i++){
			e=0;
			for(int j=0;j<n;j++){
				if(taro[0][j]==i){
					e++;
				}
			}
			if(e==0){
				hanako[1][d] = i;
				d++;
			}
			else{
				taro[1][c] = i;
				c++;
			}
		}
		taro2=n;
		hanako2=n;
		ba=0;
		while(true){
			
			for(int i=0;i<n;i++){
				if(taro[1][i]>ba && taro[2][i]!=0){
					taro[2][i]=0;
					taro2 -= 1;
					ba=taro[1][i];
					if(taro2==0)
					{
						goto Exit;
					}
					break;
				}
				if(i==n-1){
					ba=0;
				}
			}
			
		
			for(int i=0;i<n;i++){
				if(hanako[1][i]>ba && hanako[2][i]!=0){
					hanako[2][i]=0;
					hanako2 -= 1;
					ba=hanako[1][i];
					if(hanako2==0)
					{
						goto Exit;
					}
					break;
				}
				if(i==n-1){
					ba=0;
				}
			}
	
		}
		Exit:
		cout<<hanako2<<endl;
		cout<<taro2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,j,k,l,sum,ar[1000];
    while(scanf("%d",&t)!=EOF)
    {
        for(i=0;i<t;i++)
        {
            cin>>ar[i];
        }
        for(j=t-1;j>=0;j--)
        {
            if(j==0)
            {
                cout<<ar[j];
            }
            else
            {
                cout<<ar[j]<<" ";
            }
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  ll n;
  ll a[100], x, ans, tmp[100];
  while(cin>>n){
    for(int i=0; i<n; ++i){
      scanf("%lld",&a[i]);
    }
    x=0;ans=0;
    while(1){
      for(int i=0; i<n; ++i){
        tmp[i]=a[i]/n;
        a[i]=a[i]-tmp[i]*n;
        x+=tmp[i];
      }
      ans+=x;
      if(x==0)
        break;
//      cout<<x<<"::"<<endl;
      for(int i=0; i<n; ++i){
        a[i]+=x-tmp[i];
//        cout<<a[i]<<" ";
      }
//      cout<<endl;
      x=0;
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
import numpy as np

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [int(input()) - 1 for _ in range(d)]
last = np.zeros(26, dtype="i8")

satisfaction = 0
for i in range(d):
    last += 1
    last[t[i]] = 0
    satisfaction += s[i][t[i]]
    for j in range(26):
        satisfaction -= c[j] * (last[j])
    print(satisfaction)


Measured memory_bytes: 27692
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val S = Array(H) { next().toCharArray() }
    val whites = S.map { l -> l.count { it == '.' } }.sum()
    val steps = bfs(0, 0, S)[H - 1][W - 1]
    if (steps != -1) {
        println(whites - steps - 1)
    } else {
        println(-1)
    }
}

fun bfs(sx: Int, sy: Int, field: Array<CharArray>): Array<Array<Int>> {
    val W = field[0].size
    val H = field.size
    val dx = intArrayOf(0, 1, -1, 0)
    val dy = intArrayOf(1, 0, 0, -1)
    val que = ArrayDeque<Pair<Int, Int>>()
    que.addLast(Pair(sx, sy))
    val d = Array(H) { Array(W) { -1 } }
    d[sy][sx] = 0
    while (que.size > 0) {
        val p = que.removeFirst()
        for (i in dx.indices) {
            val nx = p.first + dx[i]
            val ny = p.second + dy[i]
            if ((nx in 0 until W) && (ny in 0 until H) && field[ny][nx] == '.' && d[ny][nx] == -1) {
                que.addLast(Pair(nx, ny))
                d[ny][nx] = d[p.second][p.first] + 1
            }
        }
    }
    return d
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}


int _runtimeTerror_()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    for(int i=0;i<n;++i)
        cin>>a[i];
    for(int i=0;i<m;++i)
        cin>>b[i];
    ll ans=0;
    for(int i=1;i<m;++i)
        b[i]+=b[i-1];
    ll sum=0;
    amax(ans,upper_bound(all(b),k-sum)-b.begin());
    for(int i=0;i<n;++i)
    {
        sum+=a[i];
        if(sum>k)
            break;
        ll x=upper_bound(all(b),k-sum)-b.begin();
        amax(ans,i+1+x);
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 6364
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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






int main() {
  int N,W; // 変数の宣言
  cin >> N>>W; // 標準入力
  int w[N],v[N];
  rep(i,N)
    cin >> w[i] >> v[i];
  ll dp[N+1][W+1]={0};
  
  for(int i=N-1;i>=0;i--){
    for(int j=0;j<=W;j++){
      if(j<w[i]){
	dp[i][j] = dp[i+1][j];
      }
      else{
	dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
      }
    }
  }
  
  cout << dp[0][W] << endl; // 標準出力
}


Measured memory_bytes: 82396
#include<stdio.h>

int main(void){
    int hight[10];
    for(int i=0;i<10;i++){
        scanf("%d",hight+i);
    }
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(hight[j+1]<hight[j]){
                int tmp=hight[j];
                hight[j]=hight[j+1];
                hight[j+1]=tmp;
            }
        }
    }
    for(int i=0;i<3;i++)
        printf("%d\n",hight[9-i]);
    return 0;
}


Measured memory_bytes: 2140
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

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 end */

using ll = long long;

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

  std::string t;
  std::cin>>t;

  bool n=false,w=false,s=false,e=false;

  for(const auto& m:t){
    if(m=='N')n=true;
    if(m=='W')w=true;
    if(m=='S')s=true;
    if(m=='E')e=true;
  }

  if((n^s)||(w^e))std::cout<<"No\n";
  else std::cout<<"Yes\n";

  return 0;
}

Measured memory_bytes: 3620
# https://atcoder.jp/contests/abc128/tasks/abc128_b



N = gets.to_i
points_by_city = Hash.new { |h, key| h[key] = [] }
number_by_point = {}
N.times do |i|
  city, point = gets.chomp.split
  points_by_city[city] << point.to_i
  number_by_point[point] = i + 1
end

points_by_city.keys.sort.each do |city|
  points_by_city[city].sort.reverse.each do |point|
    puts number_by_point[point.to_s]
  end
end


Measured memory_bytes: 1788
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val T, D = sc.nextInt
    val ta, tb = sc.nextInt
    val da, db = sc.nextInt
    var ans = 100000.0
    for (i <- 0 to D / da) {
      for (j <- 0 to (D - da * i) / db) {
        val num = ((ta * i * da + tb * j * db): Double) / ((i * da + j * db): Double)
        if (ans > math.abs(num - T)) {
          ans = math.abs(num - T)
        }
      }
    }
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 45236
import sys
import fractions

sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N = INT()

A = LIST()

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(A))


Measured memory_bytes: 92684
import java.io.PrintWriter
import java.lang.Exception
import kotlin.math.pow

// Helper
private val pw = PrintWriter(System.out)
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)
private fun readDoubles() = readStrings().map(String::toDouble)
private fun readStrings2() = readLn().split("").filter { it.isNotEmpty() }
private fun readInts2() = readStrings2().map(String::toInt)
private fun initArray(n:Int, v:String) = Array(n) { v }
private fun initIntArray(n:Int, v:Int) = IntArray(n) { v }
private fun println(value : Any) = pw.println(value)

internal fun abc169b() {
    val N = readInt()
    val A = readLongs()
    val sup = 10.0.pow(18.0).toLong()
    var ans = A[0]
    if(A.indexOf(0L) > 0) {
        println(0)
        return
    }
    try {
        for (i in 1 until N) {
            if(isOverflow(ans, A[i])) {
                throw Exception("overflow")
            }
            ans *= A[i]
        }
        if(ans > sup) throw Exception("over")
        println(ans.toLong().toString())
    } catch (e: Exception) {
        println(-1)
    }
}

internal fun isOverflow(a:Long, b:Long): Boolean {
    val prod = a * b
    return (prod / b != a)
}

fun main(args: Array<String>) {
    abc169b()
    pw.flush()
}


Measured memory_bytes: 62020
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
ll dist(ll x,ll y)
{
	ll p=x*x+y*y;
	return ceil(sqrt(p));
}
void solve()
{
	int n,d;
	cin>>n>>d;
	int ans=0;
	forn(i,n)
	{
		ll a,b;
		cin>>a>>b;
		//cout<<dist(a,b)<<endl;
		if(dist(a,b)<=d)ans++;
	}
	cout<<ans<<endl;
	
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
   // cin>>t;
   // seive();
    while(t--)
	solve();
    return 0;
}

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

int main() {
  long A, B;
  int count = 0;

  cin >> A >> B;

  for (long K = 0; K < max(A, B); K++) {
    if (abs(A - K) == abs(B - K)) {
      cout << K;
      count++;
      break;
    }
  }

  if (count == 0){
    cout << "IMPOSSIBLE";
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

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

		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		int alice = 0;
		int bob = 0;

		for (int i = 0; i <N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, (i1,i2) -> { return i2 - i1; });

		for (int i = 0; i < N; i++) {
			if (i%2 == 0) {
				alice += a.get(i);
			} else {
				bob += a.get(i);
			}
		}

		System.out.println(alice - bob);
	}



	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }

	}

}


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

using namespace std;

int main() {
    long N, MOD = 1e9 + 7;
    cin >> N;
    long p = 10, q = 8, r = 2 * 9;
    for (int i = 1; i < N; ++i) {
        p *= 10;
        p = p % MOD;
        q *= 8;
        q = q % MOD;
        r *= 9;
        r = r % MOD;
    }
    long ans = (p + q - r) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3644
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  n = int(input())
  #XL = [[int(i) for i in input().split()] for _ in range(n)]
  L = []
  for i in range(n):
    x, l = map(int, input().split())
    L.append((x-l, x+l))
  L = sorted(L, key = itemgetter(1))
  r_max = -10 ** 18
  ans=0
  for i in range(n):
    l_end, r_end = L[i]
    if r_max <= l_end:
      ans+=1
      r_max = r_end
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll bin_pow(ll x, ll n, ll mod){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

ll nCk_mod(ll n, ll k, int mod) {
	if(k > n || n <0 || k <0) return 0;
	ll ret = 1;
	for(ll i=n-k+1; i<n+1; i++) ret = ( ret * i) % mod;
	for(ll i=1; i<k+1; i++) ret = ( ret * bin_pow(i, mod-2, mod)) % mod;
	return ret;
}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, a, b;
	cin >>n >>a >>b;

	ll sm = bin_pow(2, n, MD) - 1;
	ll z1 = nCk_mod(n, a, MD);
	ll z2 = nCk_mod(n, b, MD);
	(sm += 2LL*MD - (z1 + z2) %MD  )%=MD;
	cout << sm <<"\n";
	return 0;
}

Measured memory_bytes: 256
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;

vector<int> a[N];
int res = 1, mod = 1e9 + 7, k;

void go(int x, int p) {
    pr(x, p);
    int c = 0;
    for(auto&& it : a[x]) {
        if(it != p) {
            go(it, x);
            int d = k - c - 1 - (p != 0);
            pr(x, it, c, d);
            res = int((res * (ll)d) % mod);
            c++;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n >> k;
    rep(i, 0, n - 1) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(v);
        a[v].emplace_back(u);
    }
    go(1, 0);
    res = int((res * (ll)k) % mod);
    cout << res << endl;
}

Measured memory_bytes: 9216
#include<stdio.h>

int main() {
	int a[100][100], b[100][100], m, n, l, i, j, k;
	long long c = 0;
	scanf("%d %d %d", &m, &n ,&l);
	for(i = 0; i < m; ++i) {
		for(j = 0; j < n; ++j) {
			scanf("%d", &a[i][j]);
		}
	}
	for(i = 0; i < n; ++i) {
		for(j = 0; j < l; ++j) {
			scanf("%d", &b[i][j]);
		}
	}
	for(i = 0; i < m; ++i) {
		for(j = 0; j < l; ++j) {
			for(k = 0; k < n; ++k) {
				c += a[i][k] * b[k][j];
			}
			if(j == l - 1) {
				printf("%lld\n", c);
				c = 0;
				continue;
			}
			printf("%lld ", c);
			c = 0;
		}
		// printf("\n");
	}
	// puts("");
	return 0;
}


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

int main()
{
    int l, r, minr = 2019;
    cin >> l >> r;
    if (r - l >= 2019)
        minr = 0;
    l %= 2019;
    r %= 2019;
    if (l > r)
    {
        int t = r;
        r = l;
        l = t;
    }
    if (l == r)
        minr = 0;
    for (int i = l; i <= r; i++)
    {
        for (int j = i+1; j <= r; j++)
        {
            if ((i*j)%2019 < minr)
            {
                minr = (i*j) % 2019;
            }
        }
    }
    cout << minr;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#define NIL -1
#define MAX 100005

struct Node{
  int p,l,r;
};

Node T[MAX];
int n,D[MAX];

void print(int u) {
  int i,c;
  cout << "node " << u << ": " ;
  cout << "parent" << " = " << T[u].p << ", ";
  cout << "depth" << " = " << D[u] << ", ";
  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for(int i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;;
}



void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}


int main() {
  int c,l,r;
  int N;
  cin >> N;
  rep(i,N) T[i].l = T[i].r = T[i].p = NIL;
  rep(i,N) {
    int v,d;
    cin >> v >> d;
    rep(i,d) {
      cin >> c;
      if(i == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  rep(i,N) if(T[i].p == NIL) r = i;
  rec(r,0);

  rep(i,N) print(i);

  return 0;
}



Measured memory_bytes: 7704
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  long long X, K, D;
  cin >> X >> K >> D;

  X = std::abs(X);

  long long div = std::min(K, X / D);
  K -= div;
  X -= div * D;
  if (K % 2 == 0)
  {
    cout << X << endl;
  }
  else
  {
    cout << std::abs(X - D) << endl;
  }

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 - y2 + y1;
    y3 = y2 + x2 - x1;
    x4 = x1 - y2 + y1;
    y4 = y1 + x2 - x1;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,m,i,a,b,minb[111111],ans=0,r=0;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
minb[i]=100000000;
for(i=0;i<m;i++){
scanf("%d%d",&a,&b);
if(b<minb[a])
minb[a]=b;
}
for(i=1;i<n;i++){
if(minb[i]<=n){
if(i>=r){
ans++;
r=minb[i];
}
else if(minb[i]<r)
r=minb[i];
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 512
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());
            for (long a = -200; a <= 200; a++)
            {
                for (long b = -200; b < 200; b++)
                {
                    if (a*a*a*a*a - b*b*b*b*b == x)
                    {
                        Console.WriteLine($"{a} {b}");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 27536
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
char m[2222][2222];
int up[2222][2222];
typedef pair<int, int>pii;
int get(vector<int>v, int g)
{
	//for (int i = 0; i < v.size(); i++)printf("%d ", v[i]); printf("\n");
	v.push_back(0);
	vector<pii>now;
	now.push_back(make_pair(0, -1));
	now.push_back(make_pair(0, 0));
	int maxi = g;
	for (int i = 0; i < v.size(); i++)
	{
		for (;;)
		{
			if (now[now.size() - 1].second < v[i])break;
			pii z = now[now.size() - 1];
			now.pop_back();
			maxi = max(maxi, (i + 1 - now[now.size() - 1].first)*z.second);
		}
		now.push_back(make_pair(i + 1, v[i]));
	}
	//printf("%d\n", maxi);
	return maxi;
}
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < mx; i++)scanf("%s", m[i]);
	for (int i = 0; i < mx; i++)for (int j = 0; j < my; j++)up[i][j] = -1;
	for (int i = 0; i < mx - 1; i++)
	{
		for (int j = 0; j < my - 1; j++)
		{
			up[i + 1][j] = up[i][j];
			if ((m[i][j] == '#') ^ (m[i][j + 1] == '#') ^ (m[i + 1][j] == '#') ^ (m[i + 1][j + 1] == '#'))up[i + 1][j] = i;
		}
	}
	int maxi = 0;
	for (int i = 0; i < mx; i++)
	{
		vector<int>v;
		for (int j = 0; j < my - 1; j++)v.push_back(i - up[i][j]);
		maxi = max(maxi, get(v, i + 1));
	}
	printf("%d\n", maxi);
}

Measured memory_bytes: 23936
from collections import deque

class Node:
    def __init__(self, data):
        self.data = data
        self.children = []

def main():
    N, M = map(int, input().split())
    dic = {}
    for i in range(1, N + 1):
        dic[i] = Node(i)
    for i in range(0, M):
        A, B = map(int, input().split())
        dic[A].children.append(dic[B])
        dic[B].children.append(dic[A])

    answerDic = {}
    q = deque()
    q.append(dic[1])
    while len(q) > 0:
        current = q.popleft()
        for child in current.children:
            if child.data not in answerDic.keys() :
                answerDic[child.data] = current.data
                q.append(child)

    print('Yes')
    for key in range(2, N + 1):
        print(answerDic[key])

if __name__ == "__main__":
    main()

Measured memory_bytes: 54584
from itertools import product
N = int(input())
S = input()
S = [int(s) for s in S]
ans = 0
for q in product(range(10),repeat=3):
    qi = q[0] # PyPyならこんなことしなくてもOK
    i = 0
    for s in S:
        if s==qi:
            if i==2:
                ans += 1
                break
            else:
                i+=1
                qi = q[i] # PyPyならこんなことしなくてもOK
print (ans)

Measured memory_bytes: 3444
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

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

  int n;
  cin >> n;
  vector<vector<int>> x(3, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> x[j][i];
    }
  }
  vector<vector<int>> dp(n + 1, vector<int>(3));
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + x[j][i - 1]);
      }
    }
  }
  cout << *max_element(dp[n].begin(), dp[n].end());
}


Measured memory_bytes: 6908
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

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

int main() {
  ll n,m;
  while(cin >> n >>m, n||m) {
    int p[m];
    REP(i,m) {
      cin >> p[i];
    }

    double res = 0;
    double sum = 0;
    for (int i=1; i<(1<<m); ++i) {
      int num = 0;
      for (int j=i; j!=0; j>>=1) num += j&1;
      ll lcm = 1;
      for (int j=0; j<m; ++j) {
        if (i>>j&1) {
          lcm = lcm / gcd(lcm, p[j]) * p[j];
          if (lcm > n) break;
        }
      }
      double hoge = n/lcm;
      if (num % 2 == 0) {
        res -= n / lcm;
        sum -= lcm*hoge*(hoge+1)/2;
      } else {
        res += n / lcm;
        sum += lcm*hoge*(hoge+1)/2;
      }
    }
    if (res == n) {
      printf("%.12f\n", 0.0);
    } else {
      double a = n*(n+1)/2;
      printf("%.12f\n",(a-sum)/((double)n-res));
//      cout << res << " " << sum << endl;
    }

  }
}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    long long ans = 0;
    
    for(int i = 0; i < (1 << (n-1)); i++){
        long long sum = 0;
        long long a = s.at(0) - '0';
        
        for(int j = 0; j < (n-1); j++){
            if(i & (1 << j)){
                sum += a;
                a = 0;
            }
            a = 10 * a + (s.at(j + 1) - '0');
                
        }
        sum += a;
        ans += sum;
    }
    
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

// デバッグ用
#define _DEBUG
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
// ここまで
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
int main() {
    int N;
    cin >> N;
    vector<int> k(N + 1);
    REP(i, N) { cin >> k[i]; }
    int cnt = 0;
    while(true) {
        int s = -1;
        int temp = cnt;
        for(int i = 0; i < N + 1; i++) {
            if(s == -1) {
                if(0 < k[i]) {
                    s = i;
                }
            } else {
                if(k[i] < 1) {
                    s = -1;
                    cnt++;
                }
            }
            k[i]--;
        }
        if(temp == cnt) {
            cout << cnt;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque, Counter

N = int(input())
X = [[] for i in range(N)]
L = [0]*N
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)
    L[x-1] += 1
    L[y-1] += 1

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

C = Counter(P)
##### Settings
unit = 0
merge = lambda a, b: a + b
adj_bu = lambda a, i: (a+1)/C[P[i]]
adj_td = lambda a, i, p: ((XX[p]*L[p]-XX[i]*C[p])/max(1,L[p]-1)+1)/max(1,C[i])
adj_fin = lambda a, i: a*max(1,C[i])/L[i]
#####

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])

    ac = unit
    for j in reversed(X[i]):
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)

print(*XX, sep = "\n")

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

int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};


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

    vector<int> a(m);
    for(int i=0; i<m; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());

    int dp[10010];
    for(int i=0; i<=n; i++) dp[i] = -100000;
    dp[0] = 0;

    for(int i=1; i<=n; i++){
        for(int j=0; j<m; j++){
            if(i - num[a[j]] >= 0) dp[i] = max(dp[i], dp[i - num[a[j]]]+1);
        }
    }

    int k = dp[n];
    for(int i=0; i<k; i++){
        for(int j=0; j<m; j++){
            if(dp[n - num[a[j]]] + 1 == dp[n] && n - num[a[j]] >= 0) {
                cout << a[j];
                n -= num[a[j]];
                break;
            } 
        }
    }
    cout << endl;

    return 0;
}

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

void chmin(long& x, long y)
{
	if (x > y || x < 0)
		x = y;
}

void core()
{
	long N;
	cin >> N;

	long K;
	cin >> K;

	string hs_str;
	std::vector<long> hs(N + 1, 0);
	for (long i = 1; i <= N; ++i)
	{
		cin >> hs_str;
		hs[i] = stoi(hs_str);
	}

	vector<long> dp(N + 1, -1);

	dp[1] = 0;
	//chmin(dp[2], dp[1] + std::abs(hs[1] - hs[0]));
	for (long i = 2; i <= N; ++i)
	{
		for (long j = std::max<long>(1, i - K); j < i; ++j)
			chmin(dp[i], dp[j] + std::abs(hs[i] - hs[j]));
	}

	long ret = dp[N];
	cout << ret;
}

int main()
{
	core();
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int W = in.i();
        int inf = Integer.MAX_VALUE / 2;
        int[][] dp = new int[N + 1][N * 1000 + 1];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(dp[i], inf);
        }
        dp[0][0] = 0;

        for (int i = 1; i <= N; i++) {
            int w = in.i();
            int v = in.i();
            for (int j = 0; j < v; j++) {
                dp[i][j] = dp[i - 1][j];
            }
            for (int j = v; j <= N * 1000; j++) {
                if (dp[i - 1][j - v] + w <= W) {
                    dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - v] + w);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        int ans = -1;
        for (int i = N * 1000; i >= 0; i--) {
            if (dp[N][i] < inf) {
                ans = i;
                break;
            }
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 84016
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    vs c(3);
    rep(i,3) cin >> c[i];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = 1
  try:
    for i in range(1, n + 1):
      x = c.get(i)
      r = r * pow(p, x, M) % M
      p = x; n -= p
  except:
    pass
print((r, 0)[n > 1])

Measured memory_bytes: 22636
// SeeAlso: https://atcoder.jp/contests/abc138/tasks/abc138_c

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 50

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N;
int v[MAX];
int main() {   
    cin >> N;
    priority_queue<int, vector<int>, greater<int>> pq;
    REP(i, N) {
        cin >> v[i];
        pq.push(v[i]);
    }

    double ans = pq.top();
    pq.pop();

    REP(i, (N-1)) {
        ans = (ans+pq.top()) / 2.0;
        pq.pop();
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	In := readLineInt()
	A, B, C := In[0], In[1], In[2]
	fmt.Println(max(C-(A-B), 0))
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

//func min(a ...int) int {
//	result := int(^uint(0) >> 1)
//
//	for _, i := range a {
//		if result > i {
//			result = i
//		}
//	}
//
//	return result
//}

func max(a ...int) int {
	result := 0

	for _, i := range a {
		if result < i {
			result = i
		}
	}

	return result
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int n = s.length();

    map<ll, int> mp;
    VI dp(n+1, INF);
    mp[0] = 0;
    dp[0] = 0;
    int mask = 0;
    REP(i,n){
        int x = s[i] - 'a';
        mask ^= (1 << x);
        REP(j,26){
            if (mp.count(mask ^ (1 << j))){
                dp[i+1] = min(dp[i+1], dp[mp[mask ^ (1 << j)]] + 1);
            }
        }
        if (mp.count(mask)){
            dp[i+1] = min(dp[i+1], dp[mp[mask]] + 1);
        }
        if (mp.count(mask) == 0 || (mp.count(mask) > 0 && dp[mp[mask]] > dp[i+1])){
            mp[mask] = i + 1;
        }
    }
    cout << dp[n] << endl;

    // REP(i,n+1) cout << dp[i] << " ";
    // cout << endl;

    return 0;
}

Measured memory_bytes: 13700
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    string n;
    cin >> n;

    char before = ' ';
    int cnt = 0;
    bool flag = false;
    for(auto itr = n.begin(); itr != n.end(); itr++){
        if(before == *itr){
            cnt ++;
            if(cnt >= 3) flag = true;
        }else{
            before = *itr;
            cnt = 1;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648