akhauriyash/Code-Regression huggingface dataset:
package main

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

const MAX = 2000

type stack struct {
	container [MAX]int
	top int
}

func (s *stack) init() {
	s.top = 0
}

func (s *stack) push(x int) {
	s.top++
	s.container[s.top] = x
}

func (s *stack) isEmpty() bool {
	return len(s.container) == 0
}

func (s *stack) pop() (int, bool){
	if s.isEmpty() {
		return -1, false
	} else {
		v := s.container[s.top]
		s.top--
		return v, true
	}
}

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	scanner.Scan()
	s = scanner.Text()
	a := strings.Split(s, " ")
	// fmt.Println(a)
	var stack stack
	for _, v :=range a {
		switch v {
		case "+":
			v1, ok1 := stack.pop()
			v2, ok2 := stack.pop()
			if ok1 && ok2 {
				stack.push(v1+v2)
			}
			// fmt.Printf("%+v\n", stack)
		case "-":
			v1, ok1 := stack.pop()
			v2, ok2 := stack.pop()
			if ok1 && ok2 {
				stack.push(v2-v1)
			}
			// fmt.Printf("%+v\n", stack)
		case "/":
			v1, ok1 := stack.pop()
			v2, ok2 := stack.pop()
			if ok1 && ok2  && v1 != 0{
				stack.push(v2/v1)
			}
			// fmt.Printf("%+v\n", stack)
		case "*":
			v1, ok1 := stack.pop()
			v2, ok2 := stack.pop()
			if ok1 && ok2 {
				stack.push(v1*v2)
			}
			// fmt.Printf("%+v\n", stack)
		default:
			vv, _ := strconv.Atoi(v)
			stack.push(vv)
			// fmt.Printf("%+v\n", stack)
		}
	}
	ans ,_ := stack.pop()
	fmt.Println(ans)
}


Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(reader.readLine());
		String[] strArray = reader.readLine().split(" ");
		Set<Integer> hashSet = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			hashSet.add(Integer.parseInt(strArray[i]));
		}
		int q = Integer.parseInt(reader.readLine());
		strArray = reader.readLine().split(" ");
		int[] targets = new int[q];
		for (int i = 0; i < q; i++) {
			targets[i] = Integer.parseInt(strArray[i]);
		}		
	
		int ans = 0;
		for (int i = 0; i < q; i++) {
			if (hashSet.contains(targets[i])) {
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 27832
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int[] a = new int[3];
   for(int i=0;i<3;i++) a[i] = sc.nextInt();
 
   Arrays.sort(a);
   
   int ss = 0;
   int s = a[0];
   for(int i=1;i<3;i++) 
   {
     if(s==a[i])
     {
       ss++;
     }
     s = a[i];
   }
   
   String ans = "No";
   if(ss==1) ans = "Yes";
   System.out.print(ans);
 }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long

const int MOD = 1000000007;

signed main(){

  int  num = 0;
  int N;
  int L, Q;
  vector<int> x;
  vector<vector<int>> table;

  cin>>N;

  x.resize(N);

  for(int n = N; n > 0; n >>= 1, num++);

  table.resize(num+2, vector<int>(N));

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

  cin>>L>>Q;

  for(int i = 0; i < N; i++){
    table[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }

  for(int i = 1; i < (int)table.size(); i++){
    for(int j = 0; j < N; j++){

       table[i][j] = table[i-1][table[i-1][j]];

       //cout<<table[i-1][j]<<" ";
    }
    // cout<<endl;
  }


  for(int i = 0; i < Q; i++){
    int a, b;
    int ans = 0;

    cin>>a>>b;
    a--, b--;

    if(a > b) swap(a, b);

    for(int k = table.size()-1; k >= 0; k--){
      if(table[k][a] < b){
        a = table[k][a];
        ans += 1<<k;
      }
    }

    if(a != b) ans++;

    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 16640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



template <typename T>
class dijkstra
{
private:
    using P = pair<T, T>;
    struct edge{
        long long to;
        T cost;
    };
    long long vertex;   // 頂点数
    vector<vector<edge>> list;  //隣接リスト
    vector<T> distance;    // 距離
public:
    dijkstra(long long n, T infinity = 1e16);  // nは頂点の数、infinityは初期化に使う値
    void add_edge(long long v1, long long v2, T cost);    // 頂点v1から頂点v2に辺を張る
    void run(long long s);        // sは開始地点。
    T get_distance(long long v);    // 頂点vへの距離を返す
};

template <typename T>
dijkstra<T>::dijkstra(long long n, T infinity){
    vertex = n;
    list.resize(n);
    distance = vector<T>(vertex, infinity);
}

template <typename T>
void dijkstra<T>::add_edge(long long v1, long long v2, T cost){
    list[v1].push_back({ v2, cost });
}

template <typename T>
void dijkstra<T>::run(long long s){
    priority_queue<P, vector<P>, greater<P>> que;
 
    distance[s] = 0;    // 開始点の距離は0
    que.push(P(0, s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        T v = p.second;
        if(distance[v] < p.first) continue;
        for(auto e : list[v]){
            if(distance[e.to] > distance[v] + e.cost){
                distance[e.to] = distance[v] + e.cost;
                que.push(P(distance[e.to], e.to));
            }
        }
    }
}

template <typename T>
T dijkstra<T>::get_distance(long long v){
    return distance[v];
}



int main() {
    ll sx, sy, gx, gy, n;
    cin >> sx >> sy >> gx >> gy >> n;
    
    vector<ll> x(n), y(n), z(n);
    REP(i, n){
        cin >> x[i] >> y[i] >> z[i];
    }
    
    dijkstra<double> dik(n + 2);
    
    dik.add_edge(0, n + 1, sqrt(pow(gx - sx, 2) + pow(gy - sy, 2)));
    REP(i, n){
        dik.add_edge(0, i + 1, max(sqrt(pow(x[i] - sx, 2) + pow(y[i] - sy, 2)) - z[i], 0.0));
        dik.add_edge(i + 1, 0, max(sqrt(pow(x[i] - sx, 2) + pow(y[i] - sy, 2)) - z[i], 0.0));
        dik.add_edge(n + 1, i + 1, max(sqrt(pow(x[i] - gx, 2) + pow(y[i] - gy, 2)) - z[i], 0.0));
        dik.add_edge(i + 1, n + 1, max(sqrt(pow(x[i] - gx, 2) + pow(y[i] - gy, 2)) - z[i], 0.0));
    }
    REP(i, n - 1){
        for(int j = i + 1; j < n; j++){
            dik.add_edge(i + 1, j + 1, max(sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) - z[i] - z[j], 0.0));
            dik.add_edge(j + 1, i + 1, max(sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) - z[i] - z[j], 0.0));
        }
    }
    
    dik.run(0);
    
    printf("%.10lf\n", dik.get_distance(n + 1));
}

Measured memory_bytes: 22384
import itertools
import numpy as np
N,M, X= list(map(int,input().split()))
l = list(itertools.product([0,1], repeat=N))

C = np.array([ np.array(list(map(int,input().split())))for i in range(N)])

r = float('inf')
for i in l:
  cost = 0
  i = np.array(i).reshape( N,-1)
  f = i*C
  sum_f = f.sum(axis = 0)
  
  if all(sum_f[1:]>=X):
    if r >sum_f[0] :
      r = sum_f[0]
    
if r == float('inf') :
  print(-1)
else :
  print(r)

Measured memory_bytes: 27592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int cnt[n] = {};
    rep(i, 0, n - 1) {
        int a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    rep(i, 0, n) cout << cnt[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 4420
import math
a = [int(input()) for i in range(5)]

sum_num = 0

delta = 10

for num in a:
    if num % 10 != 0 and num % 10 < delta:
        delta = num % 10
    sum_num += math.ceil(num / 10) * 10

print(sum_num - 10 + delta)


Measured memory_bytes: 38384
/**
 *    author:  rasel kibria
 *    created: 05.07.2020
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string str;
    int ac=0;
    int wa =0;
    int tle=0;
    int re=0;

    cin>>n;
    while(n--)
    {
        cin>>str;
        if(str=="WA")wa++;
        if(str=="TLE")tle++;
        if(str=="AC")ac++;
        if(str=="RE")re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
    return 0;
}


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

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

using ll = long long;

int dx[] = {1,-1,0,0,0,0};
int dy[] = {0,0,1,-1,0,0};
int dz[] = {0,0,0,0,1,-1};

struct Dice {
    int v[6];
    Dice(){};
    Dice(const Dice &d){
        REP(i,6)v[i]=d.v[i];
    }
    Dice(int top, int front){
        v[4] = top;
        v[0] = front;
        v[5] = 7-top;
        v[1] = 7-front;
        int mn = min({top,front,7-top,7-front});
        int mn2 = 7;
        REP(i,6)if(i!=2 && i!=3 && v[i]!=mn){
            mn2 = min(mn2,v[i]);
        }
        int cnt = 0;
        while(v[4]!=mn)rotate(0),cnt++;
        if(v[4]==1 && v[0]==2){
            v[2]=3;
        }else if(v[4]==1 && v[0]==5){
            v[2]=4;
        }else if(v[4]==1 && v[0]==3){
            v[2]=5;
        }else if(v[4]==1 && v[0]==4){
            v[2]=2;
        }else if(v[4]==2 && v[0]==3){
            v[2]=1;
        }else{
            v[2]=6;
        }
        v[3]=7-v[2];
        while(cnt--)rotate(1);
    }
    void rotate(int d){
        vector<int> ids;
        if(d==1){
            ids = vector<int>({4,0,5,1});
        }else if(d==0){
            ids = vector<int>({4,1,5,0});
        }else if(d==3){
            ids = vector<int>({4,2,5,3});
        }else{
            ids = vector<int>({4,3,5,2});
        }
        REP(i,3)swap(v[ids[i]],v[ids[i+1]]);
        // abcd -> bacd -> bcad -> bcda
    }
};

int field[252][252][125];

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        REP(i,252)REP(j,252)REP(k,125)field[i][j][k] = -1;
        REP(i,252)REP(j,252)field[i][j][0] = 0;
        int cnt[7] = {};
        while(n--){
            int t,f;
            cin>>t>>f;
            Dice di(t,f);
            int x = 125, y = 125, z = 124;
            while(field[x][y][z-1]==-1)z--;
            while(true){
                int nd = -1, nv = -1;
                REP(d,4){
                    if(di.v[d]<4)continue;
                    int nx = x+dx[d];
                    int ny = y+dy[d];
                    if(field[nx][ny][z-1]==-1 && di.v[d]>nv){
                        nd = d;
                        nv = di.v[d];
                    }
                }
                if(nd==-1)break;
                x += dx[nd];
                y += dy[nd];
                di.rotate(nd);
                while(field[x][y][z-1]==-1)z--;
            }
            // printf("%d %d %d, t=%d, f=%d\n",x,y,z,di.v[4],di.v[0]);
            cnt[field[x][y][z-1]]--;
            cnt[field[x][y][z] = di.v[4]]++;
        }
        REP(i,6)printf("%d%c",cnt[i+1]," \n"[i==5]);
    }
    return 0;
}


Measured memory_bytes: 34160
#include <bits/stdc++.h>
#define REP(i, a, n) for(int i=a; i<n; i++)
using namespace std;

int n;
int dp[100001];
int x[1000];
vector<int> vi;
int main() {
    cin>>n;
    REP(i, 0, n+1) dp[i]=i;

    for(int i=6; i<n+1; i*=6){
        for(int j=i; j<n+1; j++){
            dp[j]=min(dp[j], dp[j-i]+1);
        }
    }
    for(int i=9; i<n+1; i*=9){
        for(int j=i; j<n+1; j++){
            dp[j]=min(dp[j], dp[j-i]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr ll INF=1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	int n;
	double x, y;
	char d;
	cin>>n;
	double LL=INF, L=INF, LR=INF;
	double RL=-INF, R=-INF, RR=-INF;
	double DD=INF, D=INF, DU=INF;
	double UD=-INF, U=-INF, UU=-INF;
	REP(i, n){
		cin>>x>>y>>d;
		if(d=='R'){
			CHMIN(LR, x);
			CHMAX(RR, x);
			CHMIN(D, y);
			CHMAX(U, y);
		}
		if(d=='L'){
			CHMIN(LL, x);
			CHMAX(RL, x);
			CHMIN(D, y);
			CHMAX(U, y);
		}
		if(d=='U'){
			CHMIN(DU, y);
			CHMAX(UU, y);
			CHMIN(L, x);
			CHMAX(R, x);
		}
		if(d=='D'){
			CHMIN(DD, y);
			CHMAX(UD, y);
			CHMIN(L, x);
			CHMAX(R, x);
		}
	}
	double ans=4*INF*INF;
	REP(i, 4e8){
		double t=i*0.5;
		double xmi=min({L, LL-t, LR+t});
		double xma=max({R, RL-t, RR+t});
		double ymi=min({D, DD-t, DU+t});
		double yma=max({U, UD-t, UU+t});
		CHMIN(ans, (xma-xmi)*(yma-ymi));
	}
	cout<<ans<<'\n';
	return 0;
}


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

int Nanketa(long long x){
  int keta = 1;
  while ( x / 10 > 0){
    keta++;
    x /= 10;
  } 
  return keta;
}
    
int main(){
  long long N;
  cin >> N;
  int ans = 10;
  double calc = sqrt(N);
  for (long long i = 1; i <= calc; i++){
    if ( N % i == 0){
      int A_keta = Nanketa(i);
      int B_keta = Nanketa(N / i);
      int f = max(A_keta, B_keta);
      ans = min(ans, f);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  string s;
  cin >> s;
  string t[] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  for(int i = 0; i < 7; i++){
    if(s == t[i]){
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

vector<int> Primes;

int main(void) {
	//Program Start

	int N;
	cin >> N;

	vector<ll> A(N);
	int minus_num = 0;
	ll tmp;
	rep(i, N) {
		cin >> tmp;
		if (tmp < 0) minus_num++;
		A[i] = abs(tmp);
	}

	ll min = A[0];

	for (int i = 1; i < A.size(); i++) {
		min = std::min(min, A[i]);
	}

	ll sum = 0;
	rep(i, N)
		sum += A[i];

	if (minus_num % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * min << endl;
	}



	/*
	int N, max;
	vector<int> A(N);

	int tmp;
	rep(i, N) {
		cin >> tmp;
		A[i] = tmp;
		max = std::max(max, tmp);
	}

	//Get primes
	for (int i = 2; i <= max; i++) {
		for (auto e : Primes) 
			if (i % e == 0) goto LoopEnd;
		Primes.push_back(i);
	LoopEnd:;
	}

	*/





ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


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

#define ll long long

ll n, k, r, s, p;
string t;
int score(char hand) {
    if(hand == 'r') return p;
    if(hand == 's') return r;
    return s;
}
int main() {
  cin >> n >> k >> r >> s >> p >> t;
  ll result = 0;
  vector<int> cnt(n, 0);
  for(int i = 0; i < n; i++) {
      if(i < k || t[i] != t[i - k] || cnt[i - k] == 1) {
          result += score(t[i]);
      } else {
          cnt[i] = 1;
      }
  }
  cout << fixed << result;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n)cin>>a[i];
    int q;cin>>q;
    while(q--){
        int op,l,r;
        cin>>op>>l>>r;
        if(op)cout<<*max_element(a+l+1,a+r+1)<<endl;
        else cout<<*min_element(a+l+1,a+r+1)<<endl;
    }
}
/* 
- min(b,eb,e): report the minimum element in ab,ab+1,...,ae−1ab,ab+1,...,ae−1
- max(b,eb,e): report the maximum element in ab,ab+1,...,ae−1

7
8 3 7 1 9 1 4
3
0 0 3
0 1 5
1 0 7
 */


Measured memory_bytes: 3216
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	int n, k;
	cin >> n >> k;

	vl a(n), dp(n, LLONG_MAX);

	invec(a,n);

	dp[0] = 0;

	fr(i,1,n)
	{
		fr(j,1,k+1)
		{
			if(i - j >= 0)
				dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]), dp[i]);
		}
	}

	cout << dp[n-1] << "\n";

}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
long int p = 1;
long int n, i;
long int m = (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10) + 7;
cin >> n;
for (i = 1; i <= n; i++){
	p = p * i;
	p = p % m;
}
cout << setprecision(10) << p << endl;
return 0;
}


Measured memory_bytes: 256
N = int(input())
data_plus = []
data_minus = []
for i in range(N):
  datum = list(map(int, input().split()))
  if datum[2] > 0:
    data_plus.append(datum) 
  else:
    data_minus.append(datum)

finish = 0
for cx in range(101):
  for cy in range(101):
    ok = 1
    for i in range(1,len(data_plus)):
      if (abs(cx - data_plus[i][0]) - abs(cx - data_plus[0][0]) 
          + abs(cy - data_plus[i][1]) - abs(cy - data_plus[0][1])
          != data_plus[0][2] - data_plus[i][2]):
        ok = 0
        break
    if ok:
      ok2 = 1
      H = abs(cx - data_plus[0][0]) + abs(cy - data_plus[0][1]) + data_plus[0][2]
      for i in range(len(data_minus)):
        if H - abs(cx - data_minus[i][0]) - abs(cy - data_minus[i][1]) > 0:
          ok2 = 0
      if ok2:
        print(cx, cy, H)
        finish = 1
    if finish == 1:
      break
  if finish == 1:
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double p = 1;
        int x = i;
        while(x < k){
            p*=0.5;
            x*=2;
        }
        ans += p/n;
    }
    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    double a,b,c,C,s;
    cin>>a>>b>>C;
    s=0.5*a*b*sin(pi*C/180);
    c=sqrt(a*a+b*b-2*a*b*cos(pi*C/180));
    printf("%.8lf\n",s);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*s/a);
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int a, b;
    cin >> a >> b;
    reps(i, 10000) {
        Int x = i * 108 / 100 - i;
        Int y = i * 110 / 100 - i;
        if (x == a && y == b) {
            PUTS(i)
            return 0;
        }
    }
    PUTS("-1");
}

Measured memory_bytes: 256
from math import sqrt
n, d = map(int, input().split())
xs = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        a = 0
        for k in range(d):
            a += (xs[i][k]-xs[j][k])**2
        if int(sqrt(a))**2 == a:
            ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, d, a;
    cin >> n >> d >> a;
    vector<Pii> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v));

    vector<Pii> attack;
    int v_idx = 0, a_idx = 0, acm = 0;
    while (v_idx < n) {
        if (a_idx == attack.size()) {
            attack.emplace_back(v[v_idx].first + 2 * d, 
                                (v[v_idx].second - a * acm - 1) / a + 1);
            acm += (v[v_idx].second - a * acm - 1) / a + 1;
            v_idx++;
        }
        else if (attack[a_idx].first >= v[v_idx].first) {
            if (v[v_idx].second > a * acm) {
                attack.emplace_back(v[v_idx].first + 2 * d, 
                                    (v[v_idx].second - a * acm - 1) / a + 1);
                acm += (v[v_idx].second - a * acm - 1) / a + 1;
            }
            v_idx++;
        }
        else {
            acm -= attack[a_idx].second;
            a_idx++;
        }
    }
    ll ans = 0;
    for (auto &i: attack) {
        ans += i.second;
        //cerr << i.first _ i.second << endl;
    }
    cout << ans << endl;


}


Measured memory_bytes: 3956
#include<iostream>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int x,y;
  cin>>x>>y;
  int d=0;
  n--;
  while(n--){
    int ny,nx;
    cin>>nx>>ny;
    int v=ny-y;
    int h=nx-x;
    d+=abs(v)+abs(h)-((v*h>0)?min(abs(v),abs(h)):0);
    y=ny;
    x=nx;
  }
  cout<<d<<endl;
}

Measured memory_bytes: 1160
(* --------------Encoder-------------- *)
(* -----function----- *)
(*
let encoder = 0
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
(*
let decoder ans = ""
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(*
let processor dat = 0
*)

(* -------test------- *)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*
let () = print_endline (decoder (processor encoder))
*)
(* ------------------------------------ *)
let mod1 x y = 
        if x mod y > 0 then
                1
        else
                0

let () = Scanf.scanf "%d %d %d %d" (fun tlife tattack alife aattack -> 
        let tturn = (tlife / aattack) + mod1 tlife aattack in
        let aturn = (alife / tattack) + mod1 alife tattack in
        if tturn >= aturn then
                "Yes"
        else
                "No"
) |> print_endline



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> s.at(i).at(j);
    }
  }
  vector<vector<int>> a(h, vector<int>(w, 0));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(s.at(i).at(j) == '#') {
        if(j > 0) a.at(i).at(j-1)++;
        if(j+1 < w) a.at(i).at(j+1)++;
        if(i > 0) {
          a.at(i-1).at(j)++;
          if(j > 0) a.at(i-1).at(j-1)++;
          if(j+1 < w) a.at(i-1).at(j+1)++;
        } 
        if(i+1 < h) {
          a.at(i+1).at(j)++;
          if(j > 0) a.at(i+1).at(j-1)++;
          if(j+1 < w) a.at(i+1).at(j+1)++;
        }
      }      
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(s.at(i).at(j) == '#') {
        cout << s.at(i).at(j);
      } else {
        cout << a.at(i).at(j);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  vi h(n);
  int mx = INT_MIN;
  for (int &i : h)
    cin >> i;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    mx = max(mx, h[i]);
    if (h[i] < mx - 1) {
      ok = false;
      break;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4000
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

int N;
string S;
ll ans;
ll r = 0;
ll g = 0;
ll b = 0;

int main(){
	
	cin>>N>>S;
	REP( i, N ){
		if( S[i] == 'R' ) r++;
		if( S[i] == 'G' ) g++;
		if( S[i] == 'B' ) b++;
	}
	
	ans = r*g*b;
	
	FOR( i, 1, N ){
		REP( j, N ){
			if( (j+2*i) >= N ) continue;
			if( (S[j] != S[j+i]) && (S[j+i] != S[j+2*i]) && (S[j+2*i] != S[j]) ) ans--;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,x[N],cnt2,cnt4;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
		if(x[i]%4==0)cnt4++;
		else if(x[i]%2==0)cnt2++;
	}
	n-=max(cnt2-1,0);
	if(cnt4+cnt4+1>=n)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 640
def main():
    N, C = map(int, input().split())
    D = []
    c = []
    for i in range(C):
        D.append(list(map(int, input().split())))
    for i in range(N):
        c.append(list(map(int, input().split())))

    c1 = []
    c2 = []
    c3 = []
    for i in range(N):
        for j in range(N):
            if (i+j)%3==0:
                c1.append(c[i][j])
            elif (i+j)%3==1:
                c2.append(c[i][j])
            else:
                c3.append(c[i][j])
    c1_cost = [0 for _ in range(C)]
    c2_cost = [0 for _ in range(C)]
    c3_cost = [0 for _ in range(C)]
    for i in range(C):
        for cc in c1:
            c1_cost[i] += D[cc-1][i]
        for cc in c2:
            c2_cost[i] += D[cc-1][i]
        for cc in c3:
            c3_cost[i] += D[cc-1][i]
    cost = []
    for i in range(C):
        for j in range(C):
            if i!=j:
                for k in range(C):
                    if j!=k!=i:
                        cost.append(c1_cost[i]+c2_cost[j]+c3_cost[k])
    return min(cost)

if __name__=="__main__":
    print(main())


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

using namespace std;

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

	if (K % 2 == 0) {
		cout << (K / 2) * (K / 2) << endl;
	}
	else {
		cout << (K / 2) * (K / 2 + 1) << endl;
	}
}






Measured memory_bytes: 3576
#include<stdio.h>
int main()
{
	long long int a,b,k;
	scanf("%lld %lld %lld",&a,&b,&k);
	if(a>=k)
	{
		printf("%lld %lld",a-k,b);
	}
	else
	{
		if(b+a>=k)
		{		
			printf("0 %lld",b-k+a);
		}
		else
		{
			printf("0 0");
		}
	}
}




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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  rep(i, s.size() - 1) if (s[i] == s[i+1]) {
    out("Bad");
    return 0;
  }
  out("Good");
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    string word[4] = {"dream", "dreamer", "erase", "eraser"};
    for(int i = 0; i < 4; i++) {
        reverse(all(word[i]));
    }

    for(int i = 0; i < s.length();) {
        bool flag = false;
        for(int j = 0; j < 4; j++) {
            if(s.substr(i, word[j].length()) == word[j]) {
                flag = true;
                i += word[j].length();
            }
        }
        if(!flag) {
            cout << "NO" << endl;
            exit(0);
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



signed main() {
    ll n;
    cin >> n;
    
    ll dist = 0;
    ll time = 0;
    
    vll t(n+1), x(n+1), y(n+1);
    t[0] = 0; x[0] = 0; y[0] = 0;
    
    rrep(i, n) {
        cin >> t[i] >> x[i] >> y[i];
        time = t[i] - t[i-1];
        dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (time % 2 != dist % 2) {
            mes("No");
            re0;
        }
        
        if (dist > time) {
            mes("No");
            re0;
        }
        
        
        
        
    }
    mes("Yes");
    
    
    
    
    
   
    
    
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    for(int in=0;in<n;in++) {
        cin >> a.at(in) >> b.at(in);
    }
    for(int im=0;im<m;im++) {
        cin >> c.at(im) >> d.at(im);
    }

    int ans, dis, distmp;
    for(int in=0;in<n;in++) {
        ans = 0;
        dis = 1e9;
        distmp;
        for(int im=0;im<m;im++) {
            distmp = abs(a.at(in)-c.at(im)) + abs(b.at(in)-d.at(im));
            if(dis>distmp) {
                dis = distmp;
                ans = im+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int GCD(int a,int b){
    int r = a % b;
    if(r==0){
        return b;
    }
    GCD(b,r);
}

int main(){
    int a,b;

    cin >> a >> b;

    cout << GCD(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    int64_t val;
    cin >> val;
    if(val%2==1) {
        cout << 0 << endl;
        return 0;
    }
    // There are a plenty of 2, so we consider the number of 5.
    val /= 2;
    int64_t power5 = 1;
    int cnt5 = 0;
    while(val > power5) {
        power5 *= 5;
        cnt5++;
    }
    int64_t prev = 0;
    int64_t ans = 0;
    // count # of 5
    while(power5>1) {
        int64_t c = val / power5;
        debug("%lld: count: %ld\n",power5, c-prev);
        ans += (c - prev) * cnt5;
        power5 /= 5;
        cnt5--;
        prev = c;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[10000];
ll T[10000];

ll dp[2005][2005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, N)
    {
        cin >> S[i];
    }
    REP(i, M)
    {
        cin >> T[i];
    }
    memset(dp, 0, sizeof(dp));
    //! 空文字列同士ok
    REP(i, std::max(N, M) + 1)
    {
        dp[i][0] = dp[0][i] = 1;
    }
    REP(i, N)
    {
        REP(j, M)
        {
            dp[i + 1][j + 1] = MOD + dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
            if (S[i] == T[j])
            {
                dp[i + 1][j + 1] += dp[i][j];
            }
            dp[i + 1][j + 1] %= MOD;
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}

Measured memory_bytes: 31744
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC091B - Two Colors Card Game

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();    // 1 <= n,m <= 100
        String[] s = new String[n];   // 1 <= 長さ <= 101 
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        int m = sc.nextInt();
        String[] t = new String[m];
        for (int j = 0; j < m; j++) {
            t[j] = sc.next();
        }
 
        int loop = n > m ? n : m;
        int max = 0;
        for (int k = 0; k < n; k++) {
            int count = 0;
            for (int l = 0; l < loop; l++) {
                if (l < n) {
                    if (s[k].equals(s[l])) ++count;
                }
                if (l < m) {
                    if (s[k].equals(t[l])) --count;
                }
            }
            if (max < count) max = count;
        }
        
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e6+5;

int n,a[N][3],ans[N][3]; 

int solve(int i,int j)
{
    if(i>=n)    return 0;
    
    if(ans[i][j]!=-1)   return ans[i][j];
    
    return ans[i][j] = a[i][j] + max( solve(i+1,(j+1)%3), solve(i+1,(j+2)%3));
}

int main() 
{ 
    BOOST
    
    cin>>n;
    
    memset(ans,-1,sizeof(ans));
    
    for(int i=0;i<n;i++)    cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    // for (int k = 0; k < 3; k++)
    //     ans[n][k] = 0;

    // for (int i = n - 1; i >= 0; i--)
    // {
    //     for (int j = 0; j < 3; j++)
    //     {
    //         ans[i][j] = a[i][j] + max(ans[i + 1][(j + 1) % 3], ans[i + 1][(j + 2) % 3]);
    //     }
    // }

    cout<<max( max(solve(0,0),solve(0,1)), solve(0,2) );
    return 0; 
} 

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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n , k;
    cin >> n >> k;

    vector<int> a(n);
    for (int &x : a)
        cin >> x;

    sort(a.begin() , a.end());

    int rem = max(0 , n - k);

    long long ans = 0;
    for (int i = 0; i < rem ;i++)
        ans += a[i];

    cout << ans;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef set<int> set;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000009
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
	return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
	return (x > y) ? y : x;
}

int gcd(int n1, int n2)
{
	if (n2 != 0) return gcd(n2, n1 % n2);
	else return n1;
}
const int max1 = 1e5 + 5;
vector<int>arr[max1 + 1];
int dp[max1] = {0};
bool visited[max1] = {false};
int no_edges[max1 + 1] = {0};
void dfs(int v)
{	if (!visited[v])
	{	visited[v] = true;
		for (int i = 0; i < arr[v].size(); i++)
		{	int t = arr[v][i];
			dp[t] = Max(dp[t], dp[v] + 1);
			--no_edges[t];

			if (no_edges[t] == 0)
			{
				dfs(t);
			}
		}

	}

}

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

	for (int i = 0; i < m; i++)
	{	int a, b;
		cin >> a >> b;
		arr[a].push_back(b);
		no_edges[b]++;
	}
	for (int i = 1; i <= n; i++)
	{	if (visited[i] == false && no_edges[i] == 0)
			dfs(i);
	}
	int answer = 0;
	for (int i = 1; i <= n; i++)
	{	if (dp[i] > answer)
			answer = dp[i];
	}
	cout << answer;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int r1 = sc.nextInt();
		int r2= sc.nextInt();

		pr.printf("%.7f\n", (double)r1 * r2 / (r1 + r2));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

int main()
{
    int N;
    cin >> N;
    int Aij;
    vector<vector<int>> A(N, vector<int>(N-1));
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> Aij;
            A[i][j] = Aij-1;
        }
    }
    vector<int> i_cur(N, 0);
    set<int> s;
    set<int> changed;
    for(int i=0; i<N; i++){
        changed.insert(i);
    }
    long long res = 0;
    while(true){
        //for(int i=0; i<N; i++){
        for(auto i : changed){
            if(i_cur[i]==N-1) continue;
            if(s.count(i)) continue;
            auto i_next = A[i][i_cur[i]];
            if(i_cur[i_next]==N-1) continue;
            if(A[i_next][i_cur[i_next]] == i){
                s.insert(i);
                s.insert(i_next);
            }
        }
        if(s.empty()){
            for(int i=0; i<N; i++){
                if(i_cur[i]!=N-1){
                    cout<<"-1"<<endl;
                    return 0;
                }
            }
            cout<<res<<endl;
            return 0;
        }

        changed.clear();
        for(auto v : s){
            i_cur[v]++;
            changed.insert(v);
        }

        res++;
        s.clear();
    }

}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll n, k;

    cin >> n >> k;

    vector<ll> h;  

    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        h.push_back (temp);
    }

    sort(ALL(h), greater<ll>());

    for (ll i = k; i < n; i++) {
        ans += h[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420