akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 212345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

map<int, int> mp;
vector<vector<ii>> g(1, vector<ii>());
vi ans;

int32_t main() {
    $
    int n;
    cin >> n;
    int x[22], y[22];
    int ans = 0;
    forn (0, n) {
        cin >> x[i];
    }
    forn (0, n) {
        cin >> y[i];
        ans += max(0, x[i] - y[i]);
    }
    cout << ans << '\n';
}   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-10;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// 外積、符号付面積の２倍　|a||b|sinθ
double cross(Point a, Point b){
	// return a.real() * b.imag() - a.imag() * b.real();
	return (conj(a) * b).imag();
}
// 点の位置関係　2点a,bから見た点cの位置関係
int ccw(Point a, Point b, Point c){
    // COUNTER_CLOCKWISE
    if(cross(b - a, c - a) > EPS) return 1;
    // CLOCKWISE
    if(cross(b - a, c - a) < -EPS) return -1;
    // ONLINE_BACK
    if(dot(b - a, c - a) < -EPS) return 2;
    // ONLINE_FRONT
    if(abs(b - a) + EPS < abs(c - a)) return -2;
    // ON_SEGMENT
    return 0;
}
// 点と直線の距離
double line_to_point_dis(Line l, Point p){
    Point a = l.first, b = l.second, c = p;
    return fabs(cross(c - a, b - a)) / fabs(abs(b - a));
}
// 点と線分の距離
double seg_to_point_dis(Line l, Point p){
    Point a = l.first, b = l.second, c = p;
    if(dot(b - a, c - a) < EPS) return abs(c - a);
    if(dot(a - b, c - b) < EPS) return abs(c - b);
    return line_to_point_dis(l, p);
}
// 線分と線分の距離
double seg_to_seg_dis(Line a, Line b){
    double res = seg_to_point_dis(a, b.first);
    res = min(res, seg_to_point_dis(a, b.second));
    res = min(res, seg_to_point_dis(b, a.first));
    res = min(res, seg_to_point_dis(b, a.second));
    return res;
}
// 線分の交差判定
bool is_cross(Line a, Line b){
    if(ccw(a.first, a.second, b.first) * ccw(a.first, a.second, b.second) <= 0 && ccw(b.first, b.second, a.first) * ccw(b.first, b.second, a.second) <= 0){
        return true;
    }
    return false;
}

int main(){
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        double x, y;
        Point p[4];
        for(int j = 0; j < 4; j++){
            cin >> x >> y;
            p[j] = {x, y};
        }
        Line s1 = {p[0], p[1]};
        Line s2 = {p[2], p[3]};
        double len = seg_to_seg_dis(s1, s2);
        if(is_cross(s1, s2)) len = 0.0;
        printf("%.10f\n", len);
    }
}


Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    long long int sum  = 0;
    
    int i = 0;
    for(i = 0; i < w-b; i++){
        sum += COM(h-a-1+b+i, b+i) * COM(a-1+w-b-1-i, a-1);
        sum %= MOD;
    }
    
    cout << sum << endl;
}



Measured memory_bytes: 12160
n = int(input())
s = input()
r = 0
g = 0 
for i in s:
  if i == 'R':
    r += 1
  elif i == 'G':
    g += 1
  
c = r*g*(n-r-g)
for j in range(1, n-1):
  for i in range(1, min(j, n - j -1) + 1):
    if (s[j] != s[j + i] ) and (s[j] != s[j - i]) and (s[j - i] != s[j + i]):
      c -= 1
print(c)

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


int main(){
  long n,k,b;
  cin >> n >> k;
  if(n >= k){
    b = n % k;
    b = min(b, k-b);
  }
  else
    b = min(n, k-n);
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

struct Perm {
  VI data;

  Perm(int sz) : data(sz) {}
  Perm(VI x) : data(x) {}

  Perm operator*(const Perm &rhs) const {
    VI ans(SZ(data));
    for (int i = 0; i < SZ(data); ++i) {
      ans[i] = data[rhs.data[i]];
    }
    return ans;
  }

  Perm Inv() const {
    VI ans(SZ(data));
    for (int i = 0; i < SZ(data); ++i) {
      ans[data[i]] = i;
    }
    return ans;
  }

  Perm Pow(int k) const {
    Perm ans(SZ(data));
    for (int i = 0; i < SZ(data); ++i) { ans.data[i] = i; }
    Perm coef = *this;

    while (k) {
      if (k & 1) { ans = ans * coef; }
      k >>= 1;
      coef = coef * coef;
    }
    return ans;
  }
};

void Out(const Perm &p) {
  for (int v : p.data) { cout << v + 1 << " "; }
  cout << "\n";
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int N, K;
  cin >> N >> K;

  Perm p(N), q(N);
  for (int i = 0; i < N; ++i) {
    cin >> p.data[i]; --p.data[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> q.data[i]; --q.data[i];
  }

  if (K == 1) { Out(p); return 0; }
  if (K == 2) { Out(q); return 0; }

  const int njumps = (K - 2) / 6;
  Perm coef = (q * p.Inv() * q.Inv() * p).Pow(njumps);

  Perm a = coef * p * coef.Inv();
  Perm b = coef * q * coef.Inv();
  int cur_b = 6 * njumps + 2;

  while (cur_b < K) {
    tie(a, b) = make_pair(b, b * a.Inv());
    ++cur_b;
  }

  Out(b);
}



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

int a[105];
int n;
int ans, ans2;

int f(int x)
{
	return x * x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		cnt += a[i];
	}
	if (cnt % n == 0)
	{
		int aver = cnt / n;
		for (int i = 1; i <= n; i++) ans += f(a[i] - aver);
		cout << ans << endl;
	}
	else
	{
		int aver = cnt / n;
		for (int i = 1; i <= n; i++) ans += f(a[i] - aver);
		aver++;
		for (int i = 1; i <= n; i++) ans2 += f(a[i] - aver);
		cout << min(ans, ans2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;


void testcase() {
	int x, y; cin >> x >> y;
	if (y < 2 || y % 2 == 1 || y < x* 2 || y > x*4) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 3636
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

I = []
for i, a in enumerate(A):
	I.append((a, i))
I.sort()

print(*[i+1 for a, i in I])


Measured memory_bytes: 65116
#include<stdio.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);
  A = (A == 1) ? A + 13 : A;
  B = (B == 1) ? B + 13 : B;
  if(A < B)
    printf("Bob\n");
  else if(A > B)
    printf("Alice\n");
  else
    printf("Draw\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = b - a;
		int h = 0;
		for (int i = 1; i <= c; i++) {
			h += i;
		}
		System.out.println(h - b);
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //set the number of strings
        int n = sc.nextInt();
        String[] arr = new String[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.next();
        }
        //get the lexicographically smallest one
        String res = dubiousDocument(arr);
        System.out.println(res);
    }
    private static String dubiousDocument(String[] arr) {
        int[][] map = new int[arr.length][26];
        //find the number of each character in each string
        for (int i = 0; i < arr.length; i++) {
            for (char c : arr[i].toCharArray()) {
                map[i][c - 'a']++;
            }
        }
        int[] minMap = new int[26];
        //find the minimum number of each character
        for (int j = 0; j < 26; j++) {
            minMap[j] = Integer.MAX_VALUE;
            for (int i = 0; i < arr.length; i++) {
                if (map[i][j] == 0) {
                    //if the character is not existed in one of strings, we should skip it
                    minMap[j] = 0;
                    break;
                } else {
                    minMap[j] = Math.min(minMap[j], map[i][j]);
                }
            }
        }
        //convert minMap to string
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < minMap[i]; j++) {
                sb.append((char)('a' + i));
            }
        }
        return sb.toString();
    }
}


Measured memory_bytes: 21844
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var S, T []string

func main() {
	sc.Split(bufio.ScanWords)
	tmpS, tmpT := nextStr(), nextStr()

	S = strings.Split(tmpS, "")
	T = strings.Split(tmpT, "")

	var indxs []int
	for i := 0; i < len(S)-len(T)+1; i++ {
		next := 0
		for j := i; j < i+len(T); j++ {
			//fmt.Println(i, j, next)
			if S[j] == T[next] || string(S[j]) == "?" {
				//fmt.Println(string(S[i]), S[i], T[next], next, i)
				if next == len(T)-1 {
					indxs = append(indxs, i+len(T)-1)
					//fmt.Println(i, j, next, indxs)
					break
				}
				next++
				continue
			}
			break
		}
	}

	if len(indxs) == 0 {
		fmt.Println("UNRESTORABLE")
		return
	}

	var cad []string
	for _, indx := range indxs {
		j := 0
		tmpStr := ""
		for i := 0; i < len(S); i++ {
			if i >= indx-len(T)+1 && i <= indx {
				tmps := string(T[j])
				tmpStr += tmps
				j++
			} else if string(S[i]) == "?" {
				tmpStr += "a"
			} else {
				tmpStr += S[i]
			}
		}
		cad = append(cad, tmpStr)
	}
	//fmt.Println(cad)
	sort.Strings(cad)
	fmt.Println(cad[0])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long //10^18
#define ull unsigned long long //10^19
using namespace std;
int main() {
  //ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  int n;cin>>n;
  string s,t;cin>>s>>t;
  string r;
  for(int i=0;i<n;i++){
    r+=s[i];r+=t[i];
  }
  cout<<r;
}


Measured memory_bytes: 256
using System;

namespace _060b
{
    class Program
    {
        static void Main(string[] args)
        {
            float[] read = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            Console.WriteLine(read[2]%Gcd(read[0],read[1])==0?"YES":"NO");
        }
        public static float Gcd(float a, float b){
            float x = 0;
            while(true){
                if(a%b==0){
                    return b;
                }else{
                    x = a % b;
                    a = b;
                    b = x;
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;



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

    int cnt = 0;
    for (int i = 0; i < S.length(); i++)
    {
        /* code */
        if(S[i] != S[S.length() - 1 - i]){
            cnt++;
        }
    }
    int ans = cnt / 2;
    cout << ans << endl;


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ALDS1_3
{
    class Progarm
    {
        static void Main()
        {
            var i = new LinkedList<string>();
            var l = int.Parse(Console.ReadLine());
 
            for (var j = 0; j < l; j++)
            {
                var _t = Console.ReadLine().Split();
                 
                if (_t.Length == 1)
                {
                    if (_t[0] == "deleteFirst")
                        i.Remove(i.First);
                    else
                        i.Remove(i.Last);
                }
                else
                {
                    if (_t[0] == "insert")
                        i.AddFirst(_t[1]);
                    else
                    {
                        var node = i.First;

                        while (node != null)
                        {
                            if (node.Value == _t[1])
                            {
                                i.Remove(node);
                                break;
                            }
                            node = node.Next;
                        }
                    }
                }        
            }

            Console.WriteLine(string.Join(" ", i.ToArray()));
         }
    }
}

Measured memory_bytes: 144076
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<climits>
const int MAXN = 22;
const int INF = INT_MAX/3;
int graph[MAXN][MAXN];

using namespace std;

void dijkstra(int s,int* d,int n){
  bool visited[MAXN];
  fill(visited, visited+n+1,false);
  fill(d, d+n+1, INF);
  d[s] = 0;
  while(true){
    int minv  = -1;
    for(int i = 1;i <= n;i++){
      if((not visited[i]) and (d[i] < d[minv] or minv == -1)) minv = i;
    }
    if(minv == -1)break;
    visited[minv] = true;
    for(int i = 1;i <= n;i++){
      d[i] = min(d[i],graph[minv][i] + d[minv]);
    }
  }
}

int main(){
  int n ,m;
  scanf("%d",&n);
  scanf("%d",&m);
  //cin >> n;
  //cin >> m;
  fill(*graph,*(graph+MAXN),INF);
  for(int i = 0;i < m;i++){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    //cin >> a >> b >> c >> d;
    graph[a][b] = c;
    graph[b][a] = d;
  }
  int x1,x2,y1,y2;
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  int d[MAXN];
  dijkstra(x1,d,n);
  int min1 = d[x2];
  dijkstra(x2,d,n);
  int min2 = d[x1];
  cout << y1 - y2 - min1 - min2 << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    LL dp[100200][5] = {0};     // 0 は初期値, 1 は A, 2 は AB , 3 は ABC
    dp[0][0] = 1;

    int N = S.size();
    rep(i,N+1){
        rep(j,4){
            if(S[i] != '?')dp[i+1][j] += dp[i][j] % MOD;
            else dp[i+1][j] += dp[i][j] * 3 % MOD;
        }
        if(S[i] == 'A')dp[i+1][1] += dp[i][0] % MOD;
        if(S[i] == 'B')dp[i+1][2] += dp[i][1] % MOD;
        if(S[i] == 'C')dp[i+1][3] += dp[i][2] % MOD;
        if(S[i] == '?'){
            dp[i+1][1] += dp[i][0] % MOD;
            dp[i+1][2] += dp[i][1] % MOD;
            dp[i+1][3] += dp[i][2] % MOD;
        }
        dp[i+1][1] %= MOD;
        dp[i+1][2] %= MOD;
        dp[i+1][3] %= MOD;
    }

    cout << dp[N][3] << endl;
}



Measured memory_bytes: 4352
import math
n,k = map(int, input().split())
res = float(0)
orig = math.ceil(math.log2(k) )
count = 0
for i in range(1, n+1):
    if i > k:
        count += pow(2,orig)
    else:
        # iからスコアがk以上になるにはt回連続で表じゃないといけない
        t = math.ceil(math.log2(k) - math.log2(i))
        tt = pow(2, orig - t )
        count += tt
res = count / (n*pow(2,orig))
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    vector<int> A(3); rep(i, 3) cin >> A[i];

    // 降順にソート
    sort(A.rbegin(), A.rend());

    // 3 * A[0] にするの必要な数
    int rest = A[0] - A[1] + A[0] - A[2];

    int ans = 0;
    if (rest & 1) {
        // 奇数の場合
        ans = (rest + 3) / 2;
    } else {
        // 偶数の場合
        ans = rest / 2;
    }

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


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

using namespace std;
typedef pair<int, int> Pii;

int highestWorth(vector<Pii> item, int weight)
{
    int item_len = item.size();

    int dp[item_len][weight + 1];

    for (int i = 0; i < item_len; i++)
    {
        for (int j = 0; j <= weight; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
                continue;
            }

            int beforeWorth = j - item[i].second;
            if (beforeWorth >= 0)
            {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][beforeWorth] + item[i].first);
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], beforeWorth);
            }
        }
    }

    return dp[item_len - 1][weight];
}

int main()
{
    int N, W;
    vector<Pii> item;
    cin >> N >> W;

    item.push_back(make_pair(0, 0));

    for (int i = 0; i < N; i++)
    {
        int v_i, w_i;
        cin >> v_i >> w_i;

        item.push_back(make_pair(v_i, w_i));
    }

    cout << highestWorth(item, W) << endl;
}


Measured memory_bytes: 7056
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val n = sc.nextInt()
    println(problem2020a(h, w, n))
}

fun problem2020a(h: Int, w: Int, n: Int): Int {
    var sum = 0
    var count = 0
    while (sum < n) {
        sum += Math.max(h, w)
        count++
    }
    return count
}

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

 using namespace std;
 int main() {
   char b;
   cin >> b;
   if (b == 'A') cout << "T" << endl;
   else if (b == 'T') cout << "A" << endl;
   else if (b == 'C') cout << "G" << endl;
   else cout << "C" << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N; cin >> N;
    vec x(N); readv(x);
    int L, Q; cin >> L >> Q;
    vec a(Q), b(Q);
    REP(i, Q){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    mat m(N, vec(20, INF));
    REP(i, N) m[i][0] = Upper_bound(x, x[i] + L) - 1;
    int n = 0;
    while(m[0][n] < N - 1){
        REP(i, N) m[i][n + 1] = m[m[i][n]][n];
        n++;
    }

    /*
    REP(i, N){
        cout << i << ",";
        REP(j, 20){
            cout << m[i][j] << ",";
        }
        cout << endl;
    }*/

    REP(i, Q){
        int a0 = min(a[i], b[i]), b0 = max(a[i], b[i]);
        int ans = 0, y = a0;
        while(y < b0){
            int n = Lower_bound(m[y], b0) - 1;
            if(n == -1) n++;
            y = m[y][n];
            ans += (1 << n);
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 22656
H, W, K = list(map(int, input().split()))

c = [None] * H

for i in range(H):
  c[i] = list(input())

res = 0

for h in range(2 ** H):
  for w in range(2 ** W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0 and c[i][j] == '#':
          cnt += 1
    #print(cnt)
    if cnt == K:
      res += 1

print(res)

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    private static int h;
    private static int w;
    private static boolean[][] land;

    private static boolean dfs(int x, int y) {
        if(!land[x][y]) return false;

        land[x][y] = false;
        for(int dx = -1; dx <= 1; dx++) {
            for(int dy = -1; dy <= 1; dy++) {
                int nx = x + dx;
                int ny = y + dy;
                if(0 <= nx && nx < h && 0 <= ny && ny < w) dfs(nx, ny);
            }
        }
        return true;
    }

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

        while(true) {
            w = sc.nextInt();
            h = sc.nextInt();
            if(w == 0 && h == 0) break;

            land = new boolean[h][w];
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                    int tmp = sc.nextInt();
                    land[i][j] = tmp == 1;
                }
            }

            int res = 0;
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                    if(dfs(i, j)) res++;
                }
            }
            System.out.println(res);
        }

        sc.close();
    }
}


Measured memory_bytes: 44888
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array
const ll MOD=1e9+7;

ll pow(ll a, ll b) {
	ll res=1;
	while (b>0) {
		if (b&1) res*=a, res%=MOD;
		b/=2;
		a*=a;
		a%=MOD;
	}
	return res;	
}

int main() {
	ll n;
	cin >> n;
	ll total=pow(10LL, n);
	ll one=pow(9LL, n)*2%MOD;
	ll none=pow(8LL, n);
	ll ans=((total-one+MOD)%MOD+none)%MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  string ans = "";
  for(char c : s){
    if(c == '1' || c == '0'){
      ans += c;
    }else{
      if(s.size()) ans = ans.substr(0, ans.size() - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

noOfInputs = int(input())
for i in range(noOfInputs):
	numsInStr = input().split()
	nums = []
	for n in numsInStr:
		nums.append(int(n))

	largest = max(nums)	
	nums.remove(max(nums))
	#print(nums)

	if (largest**2 == sum([i**2 for i in nums])):
		print('YES')
	else:
		print('NO')

Measured memory_bytes: 7612
N,W=map(int,raw_input().split())
vw=[map(int,raw_input().split()) for i in xrange(N)]
dp=[[0]*(W+1) for _ in xrange(N+1)]
for i in xrange(N):
    for j in xrange(W+1):
        if vw[i][1]>j:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-vw[i][1]]+vw[i][0])
print(dp[N][W])

Measured memory_bytes: 23260
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

M = 10 ** 9 + 7

def input():
  return stdin.readline().strip()

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

def bitcount(a, N):
  return sum((a & (1 << i)) > 0 for i in range(N))

def topbit(a, N):
  return next(i for i in range(N-1, -1, -1) if (a & (1 << i)) > 0)

def swap(x, i, j):
  y = x & ~(1 << i) & ~(1 << j)
  if (x & (1 << i)) > 0:
    y |= 1 << j
  if (x & (1 << j)) > 0:
    y |= 1 << i
  return y

def solve(N, A, B):
  if N == 1:
    ans = [A & 1, B & 1]
    return ans
  C = A ^ B
  t = topbit(C, N)
  AA = swap(A, t, N-1)
  BB = swap(B, t, N-1)
  D = AA ^ 1
  ans = []
  if B & (1 << t) > 0:
    ans.extend(swap(x, t, N-1) for x in solve(N-1, AA, D))
    ans.extend(swap(x, t, N-1) | (1 << t) for x in solve(N-1, D, BB))
  else:
    ans.extend(swap(x, t, N-1) | (1 << t)for x in solve(N-1, AA, D))
    ans.extend(swap(x, t, N-1) for x in solve(N-1, D, BB))
  return ans

N, A, B = reads()
if bitcount(A ^ B, N) % 2 == 0:
  print("NO"); exit()
print("YES")
print(*solve(N, A, B))


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

VI dp, p, q;

int rec(int n){
    if(dp[n] != -1) return dp[n];
    else if(n == p.size()-1) return dp[n] = 1;

    if(q[n+1] < q[n]) return dp[n] = 1;
    else return dp[n] = rec(n+1) + 1;

}
int main(void){
    int N; cin >> N;
    p.assign(N,0);
    q.assign(N,0);
    dp.assign(N,-1);
    REP(i,N){
        cin >> p[i];
        p[i]--;
        q[p[i]] = i;
    }

    REP(i,N){
        dp[i] = rec(i);
    }
    int ans = INT_INF;
    REP(i,N) chmin(ans, N-dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
using namespace std;
int main(){
	int A,B,C,K, res;
	cin >> A >> B >> C >> K;
	if(K<=A) res = K;
	else if(K<=A+B) res = A;
	else res = 2*A-K+B;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn solve(s: String) -> String{
    s.replace(",", " ")
}

#[allow(dead_code)]
fn main() {
    input!{
        s: String
    }
    println!("{}", solve(s));
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   



int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll h,w; cin>>h>>w;
  
  ll MAX_V=10;
  vector<vector<ll>> matrix(MAX_V,vector<ll>(MAX_V,INF));
  for(i=0;i<MAX_V;i++)matrix[i][i]=0;
  for(i=0;i<MAX_V;i++){
    for(j=0;j<MAX_V;j++){
      cin>>buf;
      matrix[i][j]=buf;
    }
  }
  for(j=0;j<MAX_V;j++){
    for(i=0;i<MAX_V;i++){
      for(o=0;o<MAX_V;o++){
        chmin(matrix[i][o],matrix[i][j]+matrix[j][o]);
      }
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>buf;
      if(buf!=-1)
      result+=matrix[buf][1];
    }
  }
  cout<<result<<endl;



  return 0;
}

Measured memory_bytes: 256
def solve(n, ddd):
    dsd = {d: i for i, d in enumerate(ddd)}
    child_cnt = [1] * n
    child_dist = [0] * n
    buf = []
    srt = sorted(dsd.items(), reverse=True)
    for d, i in srt[:-1]:
        cc = child_cnt[i]
        pd = d - (n - cc * 2)
        if pd == d or pd not in dsd:
            return -1
        pi = dsd[pd]
        buf.append((pi + 1, i + 1))
        child_cnt[pi] += cc
        child_dist[pi] += child_dist[i] + cc

    md, mi = srt[-1]
    if md != child_dist[mi]:
        return -1
    return buf


n = int(input())
ddd = list(map(int, (input() for _ in range(n))))
res = solve(n, ddd)
if res == -1:
    print(-1)
else:
    print('\n'.join('{} {}'.format(*l) for l in res))


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

typedef long long ll;

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

	ll A, B, Q;
	cin >> A >> B >> Q;

	vector<ll> s(A);
	vector<ll> t(B);

	vector<ll> x(Q);

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

	for(int i = 0; i < B; i++) {
		cin >> t[i];
	}

	for(int i = 0; i < Q; i++) {
		cin >> x[i];
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	for(int i = 0; i < Q; i++) {
		ll xs = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
		ll xt = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

		//cerr << "xs " << xs << endl;
		//cerr << "xt " << xt << endl;

		ll m = 100000000000;

		if(xs < A && xt < B)
			m = max(s[xs], t[xt]) - x[i];
		if(0 <= xs - 1LL && 0 <= xt - 1LL)
			m = min(m, x[i] - min(s[xs - 1LL], t[xt - 1LL]));
		if(0 <= xs - 1LL && xt < B) {
			m = min(m, t[xt] + x[i] - s[xs - 1LL] * 2LL);
			m = min(m, t[xt] * 2LL - s[xs - 1LL] - x[i]);
		}
		if(0 <= xt - 1LL && xs < A) {
			m = min(m, s[xs] + x[i] - t[xt - 1LL] * 2LL);
			m = min(m, s[xs] * 2LL - t[xt - 1LL] - x[i]);
		}

		cout << m << endl;
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

void yes(){
	cout << "Yes" << endl;
	return;
}

void Main()
{
	vvi a(3, vi(3));
  	rep(i,3) rep(j,3) cin >> a[i][j];
	int n;
  	cin >> n;
  	vi b(n);
  	rep(k,n) {
      	cin >> b[k];
      	rep(i,3) rep(j,3) if(a[i][j] == b[k]) a[i][j] = 0;
    }
  
  	/*rep(i,3) {
      	rep(j,3) cout << a[i][j] << " " ;
      	cout << endl;
    }
    */
  	rep(i,3) {
      	if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
			yes();
    		return;
        }
    }
  	rep(j,3) {
		if(a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0) {
			yes();
    		return;
        }
	}
  	if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
		yes();
    	return;
    }
  	if(a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) {
		yes();
    	return;
    }
  	cout << "No" << endl;
	return;
}

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

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C8

type Pair = (Int, Int)

main :: IO ()
main = do
  [n,m] <- readInts
  ps <- sortOn fst <$> replicateM n readPair
  print $ solve 0 m ps


solve :: Int -> Int -> [Pair] -> Int
solve _ _ [] = 0
solve !n m ((a,b):ps)
    | n+b >= m    = a*(m-n)
    | otherwise = a*b + solve (n+b) m ps

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO Pair
readPair = do
  [x,y] <- readInts
  return (x,y)

Measured memory_bytes: 56700
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var S = input[0][0];
  var T = input[1][0];
  var vec_S = [];
  var vec_T = [];
  for (var i = 0; i < S.length; i ++){
    vec_S.push(S.substr(i,1));
    vec_T.push(T.substr(i,1));
  }
  var ans = 0;

  for (var i = 0; i < vec_S.length; i ++){
    if (vec_S[i] !== vec_T[i]) ans ++;
  }

  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 44244
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d[i];
  sort(d.begin(),d.end());
  int res = 1;
  for (int i = 1; i < N; i++) if (d[i - 1] != d[i]) res++;
  cout << res;
}   

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

int H=3,W=3;
set<vector<vector<short>>> memo;

struct STATE {
    int f;
    int g;
    vector<vector<short>> b;

    bool operator < (const STATE& tgt) const {
	return f > tgt.f; // ?¨????
    }
};
inline bool is_searched(const STATE& s) {
    return (memo.find(s.b) != memo.end());
}
inline void searched(const STATE& s) {
    memo.insert(s.b);
}
inline bool is_goal(const STATE& s) {
    for(int i=0; i<H; i++) {
	for(int j=0; j<W; j++) {
	    if( i == H-1 and j == W-1 )  return true;
	    if( s.b[i][j] != (i*W)+j+1 ) return false;
	}
    }
}

inline void where0(const STATE& s, int& h, int& w) {
    for(int i=0; i<H; i++)
	for(int j=0; j<W; j++)
	    if( s.b[i][j] == 0 ) {
		h = i;
		w = j;
	    }
}

inline int manhattan_dis(const int tgt, const int h, const int w) {
    if(tgt == 0 ) return 0;
    int tgt_h = (tgt-1)/W;
    int tgt_w = (tgt-1)%W;
    return abs(tgt_h - h) + abs(tgt_w - w);
}

inline int heuristic(const vector<vector<short>>& b) {
    int ans = 0;
    for(int i=0; i<H; i++) {
	for(int j=0; j<W; j++) {
	    ans += manhattan_dis(b[i][j],i,j);
	}
    }
    return ans;
}

const int dx[] = { 1, 0,-1, 0}; 
const int dy[] = { 0, 1, 0,-1};
inline vector<STATE> adjcency(const STATE& cur) {
    int h,w;   where0(cur,h,w);
    vector<STATE> ans;
    vector<vector<short>> b = cur.b;
    
    for(int i=0; i<4; i++) { // 4??????
	int nh = h+dy[i], nw = w+dx[i];
	if( nh >= 0 and nh < H and nw >= 0 and nw < W ) {
	    swap(b[nh][nw], b[h][w]);
	    int heu = heuristic(b);
//	    if( cur.g+1+heu <= 24 )
		ans.push_back( STATE{cur.g+1+heu, cur.g+1, b} );
	    swap(b[nh][nw], b[h][w]);
	}
    }
    return ans;
}
    
STATE astar(const STATE& init) {
    
    priority_queue<STATE> pq;              // ?????????????°?????????????????????????????????????
    pq.push(init);                         // ????????? STATE ????????£??????
    
    while( pq.size() ) {                   // ?????\???????????????????????§????????§???
	STATE cur = pq.top(); pq.pop();    // ?????£??¨????????????????????¶??????????????§???
	if( is_searched(cur) ) continue;   // ??????????????¢?´¢????????§...
	if( is_goal(cur) ) return cur;     // ??´??????????????´????????????

	searched(cur);                     // cur ?????¢?´¢???????????¨????????????????????????
	
	for(STATE& next : adjcency(cur)) { // ?????????????????¨?????????????????§???
	    if( is_searched(next) ) continue;
	    pq.push(next);
	}
    }
    // ???????????\?????£??????????????¨??????...????????????????????£?????£????????¨???...
    return init;
}

int main() {

//    cin >> H >> W;
    vector<vector<short>> b(H,vector<short>(W));
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) cin >> b[i][j];

    int h = heuristic(b);
    STATE init{h,0,b};
    
    STATE lst = astar(init);
    cout << lst.g << endl;

//    cout << memo.size() << endl;

}

Measured memory_bytes: 6960
#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 Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h) cin >> m[i];
    vector<vector<ll>> dp(h+10,vector<ll>(w+10,0));
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i==1 && j==1) continue;
            if(m[i-1][j-1]=='#') dp[i][j] = 0;
            else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[h][w] << endl;
}

Measured memory_bytes: 9344
#include <iostream>
#include <iomanip>

using namespace std;
int main (){
  double a, b;
  cin >> a >> b;
  cout << setprecision(10) << fixed << int(a / b) << " " << int(a) % int(b) << " " << a / b << endl;
  //printf("%.10lf", int(a / b), " ", int(a) % int(b), " ", a / b);
  return 0;
}


Measured memory_bytes: 3200
K = str(input())
D = int(input())
L = len(K)
mod = 10 ** 9 + 7

dp = [[[0] * 2 for _ in range(D)] for _ in range(L+1)]
dp[0][0][0] = 1

for i in range(L):
    nd = int(K[i])
    for j in range(D):
        for k in range(2):
            #lim = 9 if k == 1 else nd
            for d in range(10):
                nk = k
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[i+1][(j+d) % D][nk] += dp[i][j][k]
                dp[i+1][(j+d) % D][nk] %= mod

ans = (dp[L][0][0]+dp[L][0][1]-1+mod) % mod

#for i in range(L+1):
#    print(dp[i])
print(ans)

Measured memory_bytes: 120604
#include <iostream>
using namespace std;
int main()
{
    long long int n, w;
    cin >> n >> w;
    long long int m[n + 10], v[n + 10];
 
    long long int tong = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> m[i] >> v[i];
        tong += v[i];
    }
    long long int f[tong + 10];
    for (int i = 1; i <= tong; i++)
    {
        f[i] = 1000000000;
    }
    f[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int t = tong; t >= v[i]; t--)
        {
            f[t] = min(m[i] + f[t - v[i]], f[t]);
        }
    }
    for (int t = tong; t >= v[1]; t--)
    {
        if (f[t] <= w)
        {
            cout << t;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
N = int(input())
a = [ int(input()) for _ in range(2**N) ]
while len(a) != 1:
    b = []
    for tmp in range(0,len(a)-1,2):
        if a[tmp] > a[tmp+1]:
            b.append(a[tmp]-a[tmp+1])
        elif a[tmp] == a[tmp+1]:
            b.append(a[tmp])
        else:
            b.append(a[tmp+1]-a[tmp])
    a = b
print(a[0])

Measured memory_bytes: 18596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


int main(){
  ll i,j;
  ll n,s,t;
  cin>>n>>s>>t;

  ll d[n+1][n+1];
  for(i=1;i<=n;i++){
      cout<<"? "<<s<<" "<<i<<endl;
      cout.flush();
      ll x;
      cin>>x;
      d[s][i]=x;
  }
  for(i=1;i<=n;i++){
      cout<<"? "<<i<<" "<<t<<endl;
      cout.flush();
      ll x;
      cin>>x;
      d[i][t]=x;
  }

  vector<P> v;
  for(i=1;i<=n;i++){
      if(i!=s&&i!=t&&d[s][i]+d[i][t]==d[s][t]){
          v.pb(P(d[s][i],i));
      }
  }
  v.pb(P(d[s][t],t));
  sort(v.begin(),v.end());


  ll tem=0;

  vector<ll> ans;
  ans.pb(s);

  while(tem!=v.size()-1){
      ans.pb(v[tem].se);
      ll prev=v[tem].se;
      ll syu=0;
      for(i=tem+1;i<v.size();i++){
          cout<<"? "<<prev<<" "<<v[i].se<<endl;
          cout.flush();
          ll x;
          cin>>d[prev][v[i].se];
          if(d[s][prev]+d[prev][v[i].se]==d[s][v[i].se]){
              syu=1;
              tem=i;
              ans.pb(v[i].se);
          }
          if(syu==1) break;
      }
  }
  cout<<"!";
  for(i=0;i<ans.size();i++) cout<<" "<<ans[i];
  cout<<endl;
  cout.flush();

  return 0;
}


Measured memory_bytes: 4652
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
max_value, min_value = -1, -1
for i in range(m):
  tmp_min_value, tmp_max_value = map(int, input().split())
  min_value = max([min_value, tmp_min_value]) if min_value >= 0 else tmp_min_value
  max_value = min([max_value, tmp_max_value]) if max_value >= 0 else tmp_max_value

min_value = min_value if min_value <= n else n
max_value = max_value if max_value <= n else n

ret = max_value - min_value + 1
if ret < 0:
  ret = 0
print(ret)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K; cin >> N >> K;
    vector<double> p(N);
    REP(i,N) {
        cin >> p[i];
        p[i] = (p[i]+1) / 2.0;
    }
    vector<double> acc(N+1);
    acc[0] = 0;
    FOR(i,1,N+1){
        acc[i] = acc[i-1] + p[i-1];
    }

    double ans = -1;
    FOR(i,K,N+1){
        ans = max(acc[i]-acc[i-K],ans);
    }
    cout << ans << endl;


}


Measured memory_bytes: 3456
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  IN(K); IN(S);

  int ans = 0;
  REP(X, K+1)
    REP(Y, min(S-X+1,K+1)) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K)
        ++ans;
    }
  OUT(ans);

  return 0;
}


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

using namespace std;
int main()
{
   int x;
   cin>>x;
   if (x%10==2 or x%10==5 or x%10==4 or x%10==7 or x%10==9)cout<<"hon";
   else if (x%10==0 or x%10==1 or x%10==6 or x%10==8)cout<<"pon";
   else cout<<"bon";
}





Measured memory_bytes: 3608