akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;

}

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

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

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

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

ll N = 0;
ll X, Y;
ll t;
ll ret = 0;
string s;
ll table[2001][2001];
ll klist[2001];

ll dist(ll i, ll j) {
  if (i < j) return j - i;
  else return i - j;
}

void input() {
  IN(N);
  IN(X);
  IN(Y);
}

void solve() {
  FOR(i, 1, N) {
    klist[i] = 0;
  }
  FOR(i, 1, N+1) {
    FOR(j, i+1, N+1) {
      // table[i][j] = j - i;
      klist[j-i] += 1;
    }
  }

  FOR(i, 1, Y+1) {
    FOR(j, X+1, N+1) {
      if (j <= i) continue;
      ll sho = dist(i, X) + dist(j, Y) + 1;
      if (j-i > sho) {
        klist[j-i] -= 1;
        klist[sho] += 1;
      }
    }
  }
  
  FOR(i, 1, N) {
    PRINT(klist[i]);
  }

}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
x = int(input())
a=199
if 400<=x<=400+a:
    print(8)
elif 600<=x<=600+a:
    print(7)   
elif 800<=x<=800+a:
    print(6) 
elif 1000<=x<=1000+a:
    print(5) 
elif 1200<=x<=1200+a:
    print(4) 
elif 1400<=x<=1400+a:
    print(3) 
elif 1600<=x<=1600+a:
    print(2) 
else:
    print(1)

Measured memory_bytes: 9192
rows, cols = map(int, input().split())
mat = [input() for _ in range(rows)]

print_row = [False for _ in range(rows)]
print_col = [False for _ in range(cols)]

for i in range(rows):
  for j in range(cols):
    if mat[i][j] == '#':
      print_row[i] = True
      print_col[j] = True

for i in range(rows):
  print_newline = False
  for j in range(cols):
    if print_row[i] and print_col[j]:
      print(mat[i][j], end="")
      print_newline = True
  if print_newline:
    print()


Measured memory_bytes: 4468
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long T[] = new long[N];
            long a = 1;
            for(int i=0; i<N; i++){
                T[i] = in.nextLong();
                a = lcm(a,T[i]);
            }
            out.println(a);

        }
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * (n /gcd(m, n));
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

Measured memory_bytes: 23380
def main():
    from collections import Counter

    s = input()

    ctr = Counter(s)
    ctr.update({'0': 0, '1': 0})

    ans = min(ctr.values()) * 2

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3444
#include <stdio.h>

#define BUF_SIZE 1000
#define ARR_SIZE 100

void print_arr(int arr[], int size)
{
  int i;
  for(i = 0; i < size; i++){
    if(i > 0) printf(" ");
    printf("%d", arr[i]);
  }

  printf("\n");
  return ;
}

int selection_sort(int arr[], int size)
{
  int i, j;
  int count= 0;
  int flag = 0;

  for(i = 0; i < size; i++){
    int minj;
    minj = i;
    for(j = i; j < size; j++){
      if(arr[j] < arr[minj]){
        minj = j;
        flag = 1;
      }
    }

    int tmp;
    tmp = arr[i];
    arr[i] = arr[minj];
    arr[minj] = tmp;

    if(flag) count++;
    flag = 0;
  }

  return count;
}
int main(void)
{
  char buf[BUF_SIZE];
  int arr[ARR_SIZE];
  int size, i;
  int count;

  fgets(buf, BUF_SIZE, stdin);
  sscanf(buf, "%d", &size);

  for(i=0; i < size; i++) scanf("%d", &arr[i]);

  count = selection_sort(arr, size);

  print_arr(arr, size);
  printf("%d\n", count);

  return 0;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;

        int n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
         ll x=a[n-1];
         int f=0;
        for(int i=n-2;i>=0;i--)
        {
            if(f&1)
                x-=a[i];
            else
                x+=a[i];

            f++;

        }
        int ans[n];
        ans[n-1]=x;
        for(int i=n-2;i>=0;i--)
        {
            ans[i]=2*(a[i]-(ans[i+1]/2));
        }
        for(int  i=0;i<n;i++)
            cout<<ans[i]<<' ';
        cout<<endl;


    }

Measured memory_bytes: 4800
package main

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

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		s1 := scanner.Text()
		scanner.Scan()
		s2 := scanner.Text()
		s1, s2 = " " + s1 , " " + s2
		c := make([][]int, len(s1))
		for i := range c {
			c[i] = make([]int, len(s2))
		}

		LCS := 0

		for i := 1; i < len(s1); i++ {
			for j := 1; j < len(s2); j++ {
				if s1[i] == s2[j] {
					c[i][j] = c[i-1][j-1] + 1
				} else {
					c[i][j] = max(c[i-1][j], c[i][j-1])
				}
				LCS = max(LCS, c[i][j])
			}
		}
		fmt.Println(LCS)
	}
}



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

long long a[55],b[55],c[55],d[55];
int main(void){
    
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    
    for(int i=0;i<n;i++){
        long long minute=1000000000;
        int ans=-1;
        for(int j=0;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < minute){
                minute=abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans=j;
            }
        }
        cout<<ans +1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

case X
when 3, 5, 7
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 14436
import sys
from itertools import combinations
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w, k = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
cnt = 0

for i in range(h+1):
    for a in np.array(list(combinations(li, i))):
        a = a.T
        for j in range(w+1):
            for b in np.array(list(combinations(a, j))):
                t = np.count_nonzero(b == '#')
                if t == k:
                    cnt += 1
print(cnt)


Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n;

struct he{
		ll t, x, y;
	};
he arr[nax];

bool cmp(he s1, he s2){
		return s1.t<s2.t;
	}

int main(){
	IOS
	cin >> n;
	arr[0].t=0, arr[0].x=0, arr[0].y=0;
	for(int i=1;i<=n;i++){
		cin >> arr[i].t >> arr[i].x >> arr[i].y;
	}
	sort(arr, arr+n+1, cmp);
	for(int i=0;i<n;i++){
		ll d=abs(arr[i].x-arr[i+1].x)+abs(arr[i].y-arr[i+1].y);
		ll t=arr[i+1].t-arr[i].t;
		if(d<=t&&d%2==t%2) continue;
		else{
			cout << "No" << '\n'; return 0;
 		}
	}
	cout << "Yes" << '\n';
}


Measured memory_bytes: 5932
def main():
    N = int(input())
    C = [[0]*10 for _ in range(10)]
    for num in range(1, N+1):
        s = str(num)
        px = int(s[0])
        sf = int(s[-1])
        C[px][sf] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += C[i][j] * C[j][i]
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin>>N;
    vector<string> s(N+10);
    int Acnt = 0;
    int Bcnt = 0;
    int both = 0;

    for(int i=0; i<N; i++){
        cin>>s[i];
        int l = s[i].size()-1;
        if(s[i][l] == 'A' && s[i][0] == 'B') both++;
        else{
            if(s[i][l] == 'A') Acnt++;
            if(s[i][0] == 'B') Bcnt++;
        }
    }

    int ans = 0;

    for(int i=0; i<N; i++){
        for(int j=0; j<(int)s[i].size(); j++){
            string tmp = "";
            for(int k=j; (k<j+2 && k<(int)s[i].size()); k++) tmp += s[i][k];
            if(tmp == "AB") ans++;
        }
    }

    if(Acnt == 0 && Bcnt == 0) ans += max(both-1,0);
    else ans += both + min(Acnt,Bcnt);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3672
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int N = 205;
ll table[N][N];
ll gcd(ll x,ll y)
{
	if(y == 0)	return x;
	return gcd(y,x % y);
}
int main()
{
	int k;scanf("%d",&k);
	ll res = 0;
	for(int i = 1;i <= 200;++i)
	{
		for(int j = 1;j <= 200;++j)
			table[i][j] = gcd(i,j);
	}
	for(int i = 1;i <= k;++i)
	{
		for(int j = 1;j <= k;++j)
		{
			for(int c = 1;c <= k;++c)
			{
				res += table[i][table[j][c]];
			}
		}
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n;
    sci(n);
    vector<double> coin(n+1);
    rep(i,1,n){
        cin >> coin[i];
    }
    vector<vector<double>> dp(n+1,vector<double>(n+1));
    dp[0][0] = 1.0;
    rep(i,1,n) dp[0][i] = 0.0;
    rep(i,1,n){
        rep(j,0,n){
            dp[i][j] = (dp[i-1][j-1] * coin[i]) + (dp[i-1][j]*(1-coin[i]));
        }
    }
    double ans = 0;
    rep(i,(n/2)+1,n){
        ans += dp[n][i];
    }
    cout.precision(10);
    cout << fixed << ans << endl;
}

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

class Main{
    static int[][] map;
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    int n = Integer.valueOf(sc.readLine());
	    for(int k=1; k<=n; k++){
		String st = sc.readLine();
		map = new int[14][14];
		for(int i=3; i<11; i++){
		    st = sc.readLine();
		    for(int j=3; j<11; j++)
			map[i][j] = st.charAt(j-3)-'0';
		}
		int x = Integer.valueOf(sc.readLine())+2;
		int y = Integer.valueOf(sc.readLine())+2;
		solve(x,y);
		System.out.println("Data "+k+":");
		for(int t=3; t<11; t++){
		    for(int u=3; u<11; u++)
			System.out.print(map[t][u]);
		    System.out.println();
		}
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
    static void solve(int x, int y){
	if(map[y][x]==1){
	    map[y][x]=0;
	    for(int i=-3; i<0; i++){
		solve(x+i,y);
		solve(x,y+i);
	    }
	    for(int i=1; i<4; i++){
		solve(x+i,y);
		solve(x,y+i);
	    }
	}
    }
}

Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  int flag = (s[0])-'0';
  int ans = 0;
  REP(i,1,s.size()){
    if((flag+'0')==s[i]){
      flag = 1-flag;
      s[i] = flag+'0';
      ans++;
    }
  flag = s[i]-'0';
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
from collections import Counter

N = int(input())
S = []
S_append = S.append
for _ in range(N):
    S_append(input())

M = int(input())
T = []
T_append = T.append
for _ in range(M):
    T_append(input())

SC = Counter(S)
TC = Counter(T)

dif = SC - TC
if len(dif):
    print(max(dif.values()))
else:
    print(0)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		long answer = 0;
		for(int i = 1; i <= N; i++) {
			if(i%3 != 0) {
				if(i%5 != 0) {
					answer += i;
					//System.out.println(i);
				}

			}
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 27188
#include <stdio.h>

int main(void) {
	int n,k;
	char s[256];
  	scanf("%d %d",&n,&k);
  	scanf("%s",s);
  	k = k - 1;
    if (s[k] == 'A'){
        s[k] = 'a';
    }else if (s[k] == 'B'){
        s[k] = 'b';
    }else if (s[k] == 'C'){
        s[k] = 'c';
    }
  	printf("%s",s);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,T;
	cin >> N >> T;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	int mini = inf;
	priority_queue<int> q;
	for(int i=0;i<N;i++){
		mini = min(mini,a[i]);
		if(a[i]-mini > 0 ){
			q.push(a[i]-mini);
		}
	}
	int ans = 0;
	int ok = q.top();
	while(!q.empty()){
		int front = q.top();
		if(front == ok)ans++;
		else break;
		q.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1276
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
int main()
{
    int n;
    char a[100],b[100],c[100];
    scanf("%d%s%s%s",&n,a,b,c);
    int sum=0;
    REP(i,n){
        if(a[i]==b[i]&&a[i]==c[i]&&b[i]==c[i]);
        else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])sum+=1;
        else sum+=2;
    }
    printf("%d\n",sum);
    return 0;
}

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

void code()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll cnt=0;
    for(ll i=0;i<n;i++)
    {
      if(s[i]!=t[i])
        cnt++;
    }
    cout<<cnt<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    while(t--)
    {
        code();
    }
}

Measured memory_bytes: 3844
import scala.io.StdIn.{readInt,readLine}

object Main extends App {
  def eval(math:Int,eng:Int,jp:Int) = {
    if(math == 100 || eng == 100 || jp == 100) "A"
    else if((math+eng)/2 >= 90) "A"
    else if((math+eng+jp)/3 >= 80) "A"
    else if((math+eng+jp)/3 >= 70) "B"
    else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) "B"
    else "C"
  }

  println {
    Iterator.continually(readInt).takeWhile(_ != 0).map { n =>
      {
        for(i<- 1 to n) yield {
          val score = readLine.split(" ").map(_.toInt)
          eval(score(0),score(1),score(2))
        }
      }.mkString("\n")
    }.mkString("\n")
  }
}

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

int main(){
	int n;
	string s;
	cin>>n>>s;
	vector<int>vW(n+1,0),vE(n+1,0);
	for(int i=0;i<n;i++){
		vW[i+1]+=vW[i];
		if(s[i]=='W') vW[i+1]++;
		vE[i+1]+=vE[i];
		if(s[i]=='E') vE[i+1]++;
	}
	int ans=999999999;
	for(int i=0;i<n;i++){
		int now=vW[i]+(vE[n]-vE[i+1]);
		if(ans>now) ans=now;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 1;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x = 0, y,z,w,h, sum= 0, ans = 0;
string s, t;
int main() {
	cin >> n; vector<pair<int,int>> a(n);
	vector<int> b(n);
	rep(i, n) {
		cin >> x >> y;
		a[i] = { x,y };
		b[i] = i;
	}ld su = 0;
	do {
		rep(i, n - 1) {
			su += sqrt(pow(a[b[i]].first - a[b[i + 1]].first, 2) + pow(a[b[i]].second - a[b[i + 1]].second, 2));
		}sum++;
	} while (next_permutation(ALL(b)));
	cout << fixed << setprecision(10) << (ld)su / sum << endl;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

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

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}
u64 dp[100010];
int main() {
  cout << setprecision(18);
  u32 N;
  cin >> N;
  vector<i32> h(N);
  ArrayInput(h);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (u32 i = 2; i < N; ++i) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>

#define N 50
#define LONG long long

int n;
int k;
int pos[N][2];

int main() {
  std::cin >> n >> k;
  std::vector<int> xs(n);
  std::vector<int> ys(n);

  for(int i = 0; i < n; i++) {
    std::cin >> pos[i][0] >> pos[i][1];
    xs[i] = pos[i][0];
    ys[i] = pos[i][1];
  }
  std::sort(xs.begin(), xs.end());
  std::sort(ys.begin(), ys.end());

  LONG area;
  LONG min_area = LLONG_MAX;
  int num = 0;

  for(int x1 = 0; x1 < n; x1++) {
    for(int x2 = x1; x2 < n; x2++) {
      for(int y1 = 0; y1 < n; y1++) {
        for(int y2 = y1; y2 < n; y2++) {
          num = 0;
          int x_1 = xs.at(x1);
          int x_2 = xs.at(x2);
          int y_1 = ys.at(y1);
          int y_2 = ys.at(y2);

          for(int i = 0; i < n; i++) {
            int x = pos[i][0];
            int y = pos[i][1];
            if(x_1 <= x && x <= x_2 && y_1 <= y && y <= y_2)
              num++;
          }
          if(k <= num) {
            area = 1LL * (y_2 - y_1) * (x_2 - x_1);
            min_area = std::min(min_area, area);
          }
        }
      }
    }
  }

  std::cout << min_area << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main(void) {
	string w;
	cin >> w;
	if (w == "Sunny") {
		cout << "Cloudy";
	}
	else if (w == "Cloudy") {
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}
	return 0;
}

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

const int N=1e5+1e3+7,M=2e3+1e2+7;

struct node{
	int x,y;
}p[N];

int n,k,ab[M][M],aw[M][M],sw[M][M],sb[M][M],ans;

int sum(int x1,int y1,int x2,int y2,int s[][M])
{
	x2=min(x2,k*2-1);
	y2=min(y2,k*2-1);
	if(x1==0&&y1==0)
		return s[x2][y2];
	if(x1==0)
		return s[x2][y2]-s[x2][y1-1];
	if(y1==0)
		return s[x2][y2]-s[x1-1][y2];
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}

void pre(int s[][M],int a[][M])
{
	s[0][0]=a[0][0];
	for(int j=1;j<2*k;j++)
		s[0][j]=s[0][j-1]+a[0][j];
	for(int i=1;i<2*k;i++)
	{
		s[i][0]=s[i-1][0]+a[i][0];
		for(int j=1;j<2*k;j++)
			s[i][j]=s[i-1][j]+s[i][j-1]+a[i][j]-s[i-1][j-1];
	}
}

int qrb(int x1,int y1,int x2,int y2)
{
	int ret=sum(x1,y1,x2,y2,sb);
	if(x2>k*2-1)
		ret+=sum(0,y1,x2%(k*2),y2,sb);
	if(y2>k*2-1)
		ret+=sum(x1,0,x2,y2%(k*2),sb);
	if(x2>k*2-1&&y2>k*2-1)
		ret+=sum(0,0,x2%(k*2),y2%(k*2),sb);	
	return ret;
}

int qrw(int x1,int y1,int x2,int y2)
{
	int ret=sum(x1,y1,x2,y2,sw);
	if(x2>k*2-1)
		ret+=sum(0,y1,x2%(k*2),y2,sw);
	if(y2>k*2-1)
		ret+=sum(x1,0,x2,y2%(k*2),sw);
	if(x2>k*2-1&&y2>k*2-1)
		ret+=sum(0,0,x2%(k*2),y2%(k*2),sw);	
	return ret;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].x,&p[i].y),p[i].x%=2*k,p[i].y%=2*k;
		char op[3];
		scanf("%s",op);
		if(op[0]=='B')
			ab[p[i].x][p[i].y]++;
		else
			aw[p[i].x][p[i].y]++;
	}
	pre(sb,ab),pre(sw,aw);
	for(int i=0;i<k;i++)
		for(int j=0;j<k;j++)
		{
			int vb=qrb(i,j,i+k-1,j+k-1)+qrb(i+k,j+k,i+2*k-1,j+2*k-1);
			int vw=qrw(i+k,j,i+k*2-1,j+k-1)+qrw(i,j+k,i+k-1,j+2*k-1);
			int v=vb+vw;
			ans=max(ans,max(v,n-v));
		}
	printf("%d",ans);
}

Measured memory_bytes: 70400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

vector<int> primes;
const int sieve_size = 1000;
vector<bool> sieve(sieve_size + 1, true);
void prime_sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (int i = 2; i <= sieve_size; i++) {
    if (!sieve[i])
      continue;
    primes.push_back(i);
    for (int j = i * i; j <= sieve_size; j += i)
      sieve[j] = false;
  }
}

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

  prime_sieve();

  vector<int> v(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    int n = i;
    for (auto p : primes) {
      while (n % p == 0) {
        v[p]++;
        n /= p;
      }
    }
  }

  ll ans = 1;
  rep(i, N + 1) if (v[i] != 0) ans = ans * (v[i] + 1) % mod;
  cout << ans << endl;
}

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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int n,x,i;
    cin>>n;
    pll arr[n+1];
    for(i=1;i<=n;i++)
    {
       cin>>x;
       arr[i] = mp(x,i);
    }
    sort(arr+1,arr+n+1);
    for(int j=1;j<=n;j++)
    {
     cout<<arr[j].second<<" ";
    }
 
}

Measured memory_bytes: 5132
int G(int x,int y){return y?G(y,x%y):x;}
long long L(long long x,long long y){return x/G(x,y)*y;}
n[3],a[3],m[3];main(i,x){
	for(;scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),*m;){
		for(i=3;i--;)for(x=n[i]=1;(x=a[i]*x%m[i])>1;n[i]++);
		printf("%lld\n",L(n[0],L(n[1],n[2])));
	}
}

Measured memory_bytes: 600
n = int(input())
now_ls = list(map(int, input().split()))
target_ls = list(map(int, input().split()))
if sum(now_ls) < sum(target_ls):
    print(-1)
else:
    ans = 0
    lack = 0
    surplus_ls = []
    for i in range(n):
        if now_ls[i] < target_ls[i]:
            ans += 1
            lack += target_ls[i] - now_ls[i]
        else:
            surplus_ls.append(now_ls[i] - target_ls[i])
    surplus_ls.sort()
    while lack > 0:
        ans += 1
        nex = surplus_ls.pop()
        lack -= nex
    print(ans)




Measured memory_bytes: 24360
package main

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

var isProduct = true

func main() {
	nextReader = newScanner()

	n := nextInt()
	l := nextInt()

	min := 0
	sums := 0

	for i := 0; i < n; i++ {
		score := l + i - 1 + 1

		debugln(i, score)
		sums += score

		delta := abs(score)

		if i == 0 || delta < abs(min) {
			min = score
		}

	}

	fmt.Println(sums - min)
}

func abs(i int) int {
	return int(math.Abs(float64(i)))
}

func debugln(s ...interface{}) {
	if !isProduct {
		fmt.Println(s...)
	}
}

func debug(s ...interface{}) {
	if !isProduct {
		fmt.Print(s...)
	}
}
func debugf(f string, s ...interface{}) {
	if !isProduct {
		fmt.Printf(f, s...)
	}
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

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


Measured memory_bytes: 640
//string ver
#include<iostream>
#include<string> //s.size()
#include<cctype> //toupper

using namespace std;

string toUpper(string s);

int main(){
  string w,t; //word, text
  int c=0;
  
  cin >> w;
  w = toUpper(w);
  while (1) {
    cin >> t;
    if (t == "END_OF_TEXT") break;
    t = toUpper(t); //string 自作でやらんと
    if (w == t) c++; 
  }
  cout << c << endl;
}

string toUpper(string s) {
  string t = s;
  for ( int i = 0; i < s.size(); i++) {
    t[i] = toupper(s[i]);
  }
  return t;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll n, ans = 0, tmp = 10;

int main() {
  cin >> n;
  if (n % 2 == 0) {
    while (n >= tmp) {
      ans += n / tmp;
      tmp *= 5;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        string s[3];
        REP(i,3) cin>>s[i];

        int cur=0;
        int idx[3]={};
        while(true){
                if(idx[cur]==s[cur].size()){
                        cout<<(char)('A'+cur)<<endl;
                        return 0;
                }
                cur=s[cur][idx[cur]++]-'a';
        }
}


Measured memory_bytes: 256
L, R = map(int, input().split()) 
mod = 2019
ij_mod_min = 2019
for i in range(L,R):
    for j in range(i+1, R+1):
        ij_mod = ((i%mod)*(j%mod))%mod
        if ij_mod_min > ij_mod:
            ij_mod_min = ij_mod
        if ij_mod_min == 0:
            break
    else:
        continue
    break
print(ij_mod_min)

Measured memory_bytes: 39536
W, H, x, y = map(int, input().split())

if W % 2 == 0 and H % 2 == 0 and x == W // 2 and y == H // 2:
    is_mullt_ans = 1
else:
    is_mullt_ans = 0

print(W * H / 2, is_mullt_ans)

Measured memory_bytes: 2940
use std::io;

fn main(){
    let mut num = String::new();
    io::stdin().read_line(&mut num);
    let num :u32 
        = num.trim().parse::<u32>().unwrap();
    if num < 1200 && num >= 1{
        println!("ABC");
    }else if num >= 1200 && num <= 3000 {
        println!("ARC");
    };  
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, 0, n) cin >> x[i];
    int ans = 0;
    rep(i, 0, n){
        if(abs(x[i]) < abs(x[i] - k)) ans += abs(x[i]);
        else ans += abs(x[i] - k);
    }
    cout << ans*2 << endl;
    return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count;
  count = 0;
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(S[i] != S[S.size()-1-i]){
      S[S.size()-1-i] = S[i];
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

typedef pair<int, int> pii;
priority_queue < pii > q;
int N, M;
vector<vector<pii>> A;

int main() {
	cin >> N >> M;
	A.resize(M+1);
	for (int n = 0; n < N; n++) {
		int a, b;
		cin >> a >> b;
		if (a > M)continue;
		A[a].push_back(pii(b, a));
	}
	int ans = 0;
	for (int m = M - 1; m >= 0; m--) {
		for (pii a : A[M - m]) {
			q.push(a);
		}
		if (q.size() > 0) {
			ans += q.top().first;
			q.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
n = input()
  
S = [int(x) for x in raw_input().split()]
  
q = input()
  
T = [int(x) for x in raw_input().split()]
  
C = 0

 
for key in T:
  left = 0
  right = n
  while left<right:
    mid = (right + left)/2
    if key==S[mid]:
      C += 1
      break
    elif key<S[mid]:
      right = mid
    elif key>S[mid]:
      left = mid+1
 

print C

Measured memory_bytes: 14584
#include <iostream>
using namespace std;
int main()
{
    int64_t n;
    std::cin >> n;

    [=]() {
        int i = 1;
    CHECK_NUM:
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            goto END_CHECK_NUM;
        }
    INCLUDE3:
        if (x % 10 == 3)
        {
            cout << " " << i;
            goto END_CHECK_NUM;
        }
        x /= 10;
        if (x)
            goto INCLUDE3;
    END_CHECK_NUM:
        if (++i <= n)
            goto CHECK_NUM;

        cout << endl;
    }();
    return 0;
}


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

int main() {
    int A,B,C,D;cin >> A >> B >> C >> D;
    while (true){
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
 
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
int p(char s){
    return s-'0';
}
 
int main(){
    
   
    string a;
    cin>>a;
    
    
    int n=sz(a);
    int dp[n][2];
    fo(i,n){
        dp[i][0]=INT_MAX;
        dp[i][1]=INT_MAX;
    }
     dp[0][0] = a[0] -'0';
       dp[0][1] =10 - (a[0] - '0') + 1;
    fo(i,n){
        for(int j =0;j<2;j++){
               if( j == 0){
                   dp[0][i] = min(dp[0][i-1] + (a[i]-'0'),dp[1][i-1] + (a[i]-'0'));
               }
               else{
                   dp[1][i] = min(dp[0][i-1] + 11 -(a[i] -'0'),dp[1][i-1] + (10- (a[i]-'0') -1));
               }
        }
        
        

        
    }
    cout << min(dp[0][n-1],dp[1][n-1]) << endl;
    
}

Measured memory_bytes: 9220
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in p2(in a){
  return 1LL<<a;
}
struct unifnd{
  VI ht,pr;
  in fnd(in a){
    in ta=a;
    while(a!=pr[a])a=pr[a];
    in tt=ta;
    while(ta!=a){
      tt=pr[ta];
      pr[ta]=a;
      ta=tt;
    }
    return a;
  }
  void uni(in a, in b){
    a=fnd(a);
    b=fnd(b);
    if(a==b)return;
    if(ht[b]<ht[a])swap(a,b);
    pr[a]=b;
    ht[b]+=(ht[a]==ht[b]);
  }
  void ini(in n){
    ht.resize(n);
    pr.resize(n);
    forn(i,n){
      ht[i]=0;
      pr[i]=i;
    }
  }
};
unifnd tfd;
vector<double> x,y,a;
vector<double> bspan;
vector<pair<double,pair<in,in> > > egs;
double sq(double d){
  return d*d;
}
double dist(in i, in j){
  return sqrt(sq(x[i]-x[j])+sq(y[i]-y[j]));
}
vector<double> btot;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  x=y=a=vector<double>(n);
  forn(i,n){
    cin>>x[i]>>y[i]>>a[i];
  }
  forn(i,n){
    forn(j,i){
      egs.PB(MP(dist(i,j),MP(i,j)));
    }
  }
  sort(all(egs));
  bspan.resize(p2(n));
  bspan[0]=2e9;
  in ta,tb;
  forn(msk,p2(n)){
    if(!msk)
      continue;
    double tsm=0;
    in tcnt=0;
    tfd.ini(n);
    forn(i,n){
      if(msk&p2(i)){
	tsm+=a[i];
	++tcnt;
      }
    }
    for(auto& eg:egs){
      ta=eg.second.first;
      tb=eg.second.second;
      if((msk&p2(ta))&&(msk&p2(tb))){
	if(tfd.fnd(ta)!=tfd.fnd(tb)){
	  tfd.uni(ta,tb);
	  tsm-=eg.first;
	}
      }
    }
    bspan[msk]=max(0.0,tsm/tcnt);
  }
  btot.resize(p2(n));
  btot[0]=2e9;
  forn(msk,p2(n)){
    if(!msk)
      continue;
    for(in lmsk=msk;lmsk>0;lmsk=(lmsk-1)&msk){
      btot[msk]=max(btot[msk],min(btot[msk^lmsk],bspan[lmsk]));
    }
  }
  cout<<setprecision(15);
  cout<<btot[p2(n)-1]<<endl;
  return 0;
}


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

using namespace std;

bool isPal(string, int);

int main() {

    string strIn;
    string str1;
    string str2;
    int n;

    cin >> strIn;

    n = strIn.size();

    for(int i=0; i<(n-1)/2; i++) {
        str1 += strIn.at(i);
    }
    for(int i=0; i<(n-1)/2; i++) {
        str2 += strIn.at(n-1-i);
    }


    if(isPal(strIn, n)) {
        if(isPal(str1, (n-1)/2) && isPal(str2, (n-1)/2)) {
            cout << "Yes" << endl;
        }else{
             cout << "No" << endl;
        }
    }else{
       cout << "No" << endl;
    }

    return 0;
}

bool isPal(string strP, int n) {

    string strQ = "";

    for(int i=0;i<n;i++) {

        strQ += strP.at(n-1-i);

    }

    if(strP == strQ) {
        return true;
    }else{
        return false;
    }

}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef 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;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll D[N][2],P[N];
  REP(i,N){
    cin>>D[i][0]>>D[i][1];
    if(D[i][0]==D[i][1]) P[i]=1;
    else P[i]=0;
  }
  
  bool CAN=false;
  for(int i=0; i<=N-3; ++i){
    if(P[i]*P[i+1]*P[i+2]==1) CAN=true;
  }
  if(CAN) COYe;
  else CONo;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    ll ans=N*(N-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// Daydream

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

string input;
string str[4] = {"dream", "dreamer", "erase", "eraser"};

// eraserdreamerdreameraserdreameraserdreamdreamereraser
// dreamereraser
bool DFS(int n, int spaces) {
    // cout << string(spaces, ' ') << "\e[34mstartDFS()" << spaces << endl;

    if (n == input.size()) {
        // cout << string(spaces, ' ') << "\e[34mendDFS()" << spaces << endl;
        return true;
    }

    for (int i = 0; i < 4; i++) {
        // cout << "\e[m" << string(spaces, ' ') << str[i] << endl;
        if (n + str[i].size() <= input.size() && input.substr(n, str[i].size()) == str[i]) {
            if (DFS(n + str[i].size(), n+str[i].size())) {
                // cout << string(spaces, ' ') << "\e[34mendDFS()" << spaces << endl;
                return true;
            }
        }
    }
    // cout << string(spaces, ' ') << "\e[34mendDFS()" << spaces << endl;
    return false;
}

int main() {
    cin >> input;
    if (DFS(0, 0)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    // cout << "\e[m";
    return 0;
}


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

int main()
{

        int n,m;
        cin >> n >> m;
        int A[n][m];
        for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                        A[i][j] = 0;
                }
        }
        int b[m];
        for (int i = 0; i < m; ++i) {
                b[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                        int tmp;
                        cin >> tmp;
                        A[i][j] = tmp;
                }
        }
        for (int i = 0; i < m; ++i) {
                int tmp;
                cin >> tmp;
                b[i] = tmp;
        }
        for (int i = 0; i < n; ++i) {

                int ans = 0;
                for (int j = 0; j < m; ++j) {
                        ans += (A[i][j] * b[j]);
                }
                cout << ans << endl;
        }

}



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



int main(){
	int t;
	cin>>t;
	while(t--){
		int x,y,w,h;
		cin>>x>>y>>w>>h;
		int n,ans=0;
		cin>>n;
		while(n--){
			int s,t;
			cin>>s>>t;
			if(x<=s&&y<=t&&s<=x+w&&t<=y+h)ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin>>s;
    cout <<"0 0 ";
    ll a,d;
    a=1000000000;
    d=(s-1)/a+1;
    cout << a<<" "<<1<<" "<<a*d-s<<" "<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(m);
    unordered_set<int> fo, fn;
    for(int i = 0; i < m; i++){
        cin >> ab[i].first >> ab[i].second;
        if(ab[i].first == 1){
            fo.insert(ab[i].second);
        }
        if(ab[i].second == n){
            fn.insert(ab[i].first);
        }
    }
    for(int i : fo){
        if(fn.count(i)){
            cout << "POSSIBLE" << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 10056
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ans = "No"
for i in range(n // 4 + 1):
    for j in range(n // 7 + 1):
        if i * 4 + j * 7 == n:
            ans = "Yes"
            break
print(ans)

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

const int mo=int(1e9+7);
int n,k,f[2010][2010][2],ans;

void work()
{
	scanf("%d %d",&n,&k);
	f[0][0][1]=1;
	for (int i=0; i<n; i++)
		for (int j=i; ~j; j--)
			{
				f[i][j][1]=(f[i][j][1]+f[i][j][0])%mo;
				if (j)  f[i][j-1][0]=(f[i][j-1][0]+f[i][j][0])%mo;
				f[i+1][j][0]=(f[i+1][j][0]+f[i][j][1])%mo;
				f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][1])%mo;				
			}
	ans=f[n][n-k][0];
	for (int i=1; i<=n-k-1; i++)  ans=2*ans%mo;
	printf("%d",ans);
}

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


Measured memory_bytes: 30208