akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[][] sec = new int[n][2];
            for (int i = 0; i < sec.length; i++) {
                String s = sc.next();
                String t = sc.next();
                sec[i][0] = convert(s);
                sec[i][1] = convert(t);
            }
            
            Arrays.sort(sec, new Comparator<int[]>() {
                @Override
                public int compare(int[] o1, int[] o2) {
                    if (o1[1] == o2[1]) {
                        return o1[0] - o2[0];
                    }
                    return o1[1] - o2[1];
                }
            });
            
            int ans=1;
            for (int i = 0; i < sec.length; i++) {
                int cnt = 1;
                int ss = sec[i][0];
                for (int j = 0; j < sec.length; j++) {
                    if(i==j)continue;
                    int s = sec[j][0];
                    int t = sec[j][1];
                    if((s <= ss && ss < t )){
                        cnt++;
                        continue;
                    }
                }
                ans=Math.max(ans, cnt);
                ss = sec[i][1];
                cnt=1;
                for (int j = 0; j < sec.length; j++) {
                    if(i==j)continue;
                    int s = sec[j][0];
                    int t = sec[j][1];
                    if((s < ss && ss <= t )){
                        cnt++;
                        continue;
                    }
                }
                ans=Math.max(ans, cnt);
            }
            System.out.println(ans);
        }
    }

    static int convert(String s) {
        String[] ss = s.split(":");
        int h = Integer.parseInt(ss[0]);
        int m = Integer.parseInt(ss[1]);
        int se = Integer.parseInt(ss[2]);
        return h * 3600 + m * 60 + se;
    }
}

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



int main(){
  int N;
  cin>>N;
  
  map<int,int> dic;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    dic[a]++;
  }
  int sum=0;
  for(auto & x:dic){
    if(x.first>x.second){
      sum+=x.second;
    }
    else{
      sum+=(x.second-x.first);
    }
  }
  cout<<sum<<endl;
    
}

Measured memory_bytes: 7996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


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

	if (str == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	
	return 0;
	
}



Measured memory_bytes: 3600
#!/usr/bin/env python3
# coding: utf-8
import math
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    A, B, H, M = map(int, input().split())
    ah = math.tau * ((H * 60 + M) / (12 * 60))
    am = math.tau * (M / 60)

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

if __name__ == "__main__":
    main()


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> ans(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
		ans.at(A.at(i)-1)=i+1;
	}
	for(int i=0;i<N;i++){
		cout << ans.at(i) << " " ;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trvii(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<"("<<a[zz].F<<","<<a[zz].S<<") ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define trsetii(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll

int main()
{
    fast();
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<nl;
}


Measured memory_bytes: 3608
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	L, R := sc.nextInt(), sc.nextInt()
	for i := 0; i <= int(1e+6); i++ {
		n := 2019 * i
		if L <= n && n <= R {
			fmt.Println(0)
			return
		}
	}
	min := 2018
	for i := L; i <= R-1; i++ {
		for j := L + 1; j <= R; j++ {
			if i*j%2019 < min {
				min = i * j % 2019
			}
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#define YesNo(c) ((c) ? "Yes" : "No")
#ifdef LOCAL
#define dump(x) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << #x " = " << (x) << endl;
#else
#define dump(x)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.fst << ", " << p.snd << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.fst >> p.snd; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    string s; cin >> s;
    map<pair<string,string>, int> m;
    rep (k,1<<n) {
        string a,b;
        rep (i,n) (k&(1<<i) ? a : b).push_back(s[i]);
        m[mp(a,b)]++;
    }
    int sum = 0;
    rep (k,1<<n) {
        string a,b;
        rep (i,n) (k&(1<<i) ? a : b).push_back(s[2*n-1-i]);
        sum += m[mp(a,b)];
    }
    cout << sum << endl;
}


Measured memory_bytes: 91904
#include <iostream>

int main(){
  int h;
  int key[251];
  std::cin >> h;
  for(int i=0; i<h; i++){ std::cin >> key[i]; }

  for(int i=0; i<h; i++){
    std::cout << "node " << i+1 << ": ";
    std::cout << "key = " << key[i] << ", ";
    if( i>0 ){ std::cout << "parent key = " << key[(i-1)/2] << ", "; }
    if( i*2+1<h ){ std::cout << "left key = " << key[2*i+1] << ", "; }
    if( i*2+2<h ){ std::cout << "right key = " << key[2*i+2] << ", "; }
    std::cout << std::endl;
  }
  return 0;
}



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

int main(){
        int n,i,ans=0,it_l,it_r;
        cin >> n;
        vector<char> c(n);
        for(i=0;i<n;++i) cin >> c.at(i);
        it_l = 0; it_r = n-1;
        while(it_l<it_r){
                if(c.at(it_l)=='W'){
                        while(c.at(it_r)!='R'){
                                --it_r;
                                if(it_l==it_r) break;
                        }
                        if(it_l<it_r){
                                ++ans;
                                --it_r;
                        }
                }
                ++it_l;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;
public class Main{
	static Scanner sc=new Scanner(System.in);
	static Main app=new Main();
	
	void sub(int ans){
		
		System.out.println(ansdown(ans)+" "+ansup(ans));	
	}
	
	public static int ansdown(int temp){
		int ans=0;
		for(int i=2;i<temp;i++){
			boolean judge=true;
			for(int j=2;j<i;j++){
				if(i%j==0){
					judge=false;
					break;
				}
			}if(judge){
				ans=i;
			}
		}
		return ans;
	}
	public static int ansup(int temp){
		boolean finish=true;
		temp++;
		while(finish){
			boolean judge=true;
			for(int i=2;i<temp;i++){
				if(temp%i==0){
					judge=false;
					break;
				}
			}
			if(judge){
				finish=false;
			}else{
				temp++;
			}
		}
		return temp;
	}
	public static void main(String[] args) {
		while(sc.hasNextInt())app.sub(sc.nextInt());
	}
}

Measured memory_bytes: 17260
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
LL a,b;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>a>>b;
    if(a<=0 && 0<=b){
        cout<<"Zero"<<endl;
    }else if(0<=a){
        cout<<"Positive"<<endl;
    }else{
        cout<<((b-a+1)%2==0?"Positive":"Negative")<<endl;
    }
    return 0;
}

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

using namespace std;

long long dp[1001][1001];
char grid[1000][1000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			cin >> grid[i][j];
		}
	}
	
	dp[0][0] = 1;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if(grid[i][j] == '.'){
				dp[i+1][j] = (dp[i+1][j] + dp[i][j])%1000000007;
				dp[i][j+1] = (dp[i][j+1] + dp[i][j])%1000000007;
			}
		}
	}
	
	cout << dp[n-1][m-1] << endl;
	
	return 0;
}

Measured memory_bytes: 9088
//agc022_a.cpp
//Sat Oct 27 14:51:37 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	unordered_map<char, int> mp;
	for (int i=0;i<s.size();i++){
		mp[s[i]] = 1;
	}


	if (s.size() != 26){
		char ans = '0';
		for (char i='a';i<='z';i++){
			auto itr = mp.find(i);
			if (itr != mp.end()){
				continue;
			}else {
				ans = i;
				break;
			}
		}
		cout << s << ans << endl;
	}else{
		int pos = s.size()-1;
		for (int i=s.size()-2;i>=0;i--){
			if (s[i]<s[pos]){
				break;
			}else{
				pos = i;
			}
		}
		if (pos == 0){
			cout << -1 << endl;
		}else {
			unordered_map<char,int>mp2;
			for (int j=0;j<=pos-1;j++){
				mp2[s[j]] = 1;
			}
			char ans = '0';
			for (char k=s[pos-1];k<='z';k++){
				auto itr = mp2.find(k);
				if (itr != mp2.end()){
					continue;
				}else {
					ans = k;
					break;
				}
			}
			cout << s.substr(0,pos-1) << ans << endl; 
		}
	}

}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/29/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,K; cin>>N>>K;
  vector<double> P(N); for(auto& p : P) cin>>p;
  for (auto& p : P) p = (p+1)/2;
  double sum = 0;
  double max_sum = 0;
  for (int i = 0; i < K; i++)
    sum += P[i];
  max_sum = sum;
  for (int i = K; i < N; i++) {
    sum -= P[i-K];
    sum += P[i];
    max_sum = max(max_sum, sum);
  }
  cout << fixed << setprecision(7) << max_sum << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <numeric>
#include <algorithm>
#include <iterator>

int main()
{
  int x[5];
  for (int& v : x) std::cin >> v;
  
  std::sort(std::begin(x), std::end(x), [](int l, int r) { return (l - 1) % 10 > (r - 1) % 10; });
  
  std::cout << std::accumulate(std::begin(x), std::end(x) - 1, x[4], [](int r, int v) { return (v + 9) / 10 * 10 + r; }) << std::endl;
}

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

int main(){
  long long int n,k;
  cin>>n>>k;
  map<long long int,long long int> ans;

  for(int i = 0;i<n;i++){
    int a,b;
    cin>>a>>b;
    ans[a]+=b;
  }

  long long int m=0;

  for(auto &element:ans){
    m+=element.second;
    if(m>=k){
      cout<<element.first<<endl;
      break;
      return 0;
    }
	}
  return 0;
}


Measured memory_bytes: 4224
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool cmp(mp A,mp B){
	return A>B;
}
int main(){
	int n;
	mp a[200000+10];
	cin>>n;
	rb(i,1,n){
		cin>>a[i].FIR;
		a[i].SEC=i;
	}
	sort(a+1,a+1+n,cmp);
	rb(i,1,n){
		if(a[1].SEC==i){
			cout<<a[2].FIR<<endl;
		}
		else{
			cout<<a[1].FIR<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
struct Bit {
  vector<int> bit;
  Bit(int N) : bit(N+1) {};
  void add(int a, int w) {
    while(a < bit.size()) {
      bit[a] += w;
      a += a & -a;
    }
  }
  int sum(int a) {
    int s = 0;
    while(a > 0) {
      s += bit[a];
      a -= a & -a;
    }
  return s;
  }
};
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<P> p(N);
  REP(i, N) {
    lint X, Y;
    cin >> X >> Y;
    //X = i ; Y = i;
    p[i] = make_pair(X, Y);
  }
  sort(ALL(p), [](auto const &a, auto const &b) { return a.second < b.second; });
  map<lint, lint> ymap;
  REP(i, N) ymap[p[i].second] = i;
  sort(ALL(p));
  vector<lint> y(N);
  REP(i, N) y[i] = ymap[p[i].second];
  vector<lint> cnt(N);
  Bit bitleft(N);
  Bit bitright(N);
  FOR(i, 1, N+1) bitright.add(i, 1);
  REP(i, N) {
    cnt[i] = (cnt[i] + power(2, i, MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, N-1-i, MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, y[i], MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, N-1-y[i], MOD) - 1 + MOD) % MOD;
    bitright.add(y[i]+1, -1);
    cnt[i] = (cnt[i] - power(2, bitleft.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitleft.sum(N) - bitleft.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitright.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitright.sum(N) - bitright.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    bitleft.add(y[i]+1, 1);
  }
  lint ans = 0;
  REP(i, N) ans = (ans + power(2, N, MOD) - 1 - cnt[i] + MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 21916
n = int(input())
h = list(map(int, input().split()))

dp = [0] * len(h)
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2]  + abs(h[i] - h[i - 2]))

print(dp[-1])

Measured memory_bytes: 20444
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<Int> l(n);
  for(Int i=0;i<n;i++) cin>>l[i];
  Int ans=1e9;
  function<void(Int, Int, Int, Int, Int)> dfs=
    [&](Int x,Int y,Int z,Int k,Int s){
      if(k==n){
        if(x!=0&&y!=0&&z!=0){
          Int t=s-30;
          t+=abs(x-a);
          t+=abs(y-b);
          t+=abs(z-c);
          chmin(ans,t);
        }
        return;
      }
      dfs(x,y,z,k+1,s);
      dfs(x+l[k],y,z,k+1,s+10);
      dfs(x,y+l[k],z,k+1,s+10);
      dfs(x,y,z+l[k],k+1,s+10);
    };
  dfs(0,0,0,0,0);
  cout<<ans<<endl;
  return 0;
}


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

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

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


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

  map<string, int> work;
  int max = 1;
  rep(i,n){
    string tmp;
    cin >> tmp;
    if(work.find(tmp) != work.end()){
      work[tmp]++;
      if(max < work[tmp])max = work[tmp];
    }
    else{
      work[tmp] = 1;
    }
  }
  
  for(auto i = work.begin();i != work.end();i++ ){
    if( i->second == max){
      cout << i->first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int p[100001];
	for(int i=1; i<=n; i++){
		scanf("%d", &p[i]);
	}
	vector<int> v[100001];
	for(int i=0; i<m; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int c=0;
	set<int> conn[100000];
	set<int> st;
	for(int i=1; i<=n; i++){
		st.insert(i);
	}

	while(!st.empty()){
		auto itrb=st.begin();
		int b=*itrb;
		vector<int> w;
		w.push_back(b);
		st.erase(itrb);
		conn[c].insert(b);
		while(!w.empty()){
			int x=w.back();
			w.pop_back();
			for(int i=0; i<v[x].size(); i++){
				if(st.find(v[x][i])!=st.end()){
					w.push_back(v[x][i]);
					st.erase(v[x][i]);
					conn[c].insert(v[x][i]);
				}
			}
		}
		c++;
	}
	int count=0;
	for(int k=0; k<c; k++){
		for(auto itr=conn[k].begin(); itr!=conn[k].end(); itr++){
			int x=*itr;
			if(conn[k].find(p[x])!=conn[k].end()) count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 15488
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T inf;
template<> constexpr int inf<int> = 1e9;
template<> constexpr ll inf<ll> = 1e18;
template<> constexpr ld inf<ld> = 1e30;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define all(x) begin(x),end(x)
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define scf(x) scanf("%d",&x),x!=0
#define scff(x, y) scanf("%d%d",&x,&y),x!=0&&y!=0
#define scdd(x, y) ld x,y;scanf("%Lf%Lf",&x,&y);
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORR(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define fin(x,y) ld x,y; while(~scanf("%Lf,%Lf",&x,&y))

int swap(int a, int b, int c) {
  if (a%2||b%2||c%2) return 0;
  int na = b/2 + c/2;
  int nb = a/2 + c/2;
  int nc = a/2 + b/2;
  if (na==a&&nb==b&&nc==c) return -1;
  else {
    int ys = swap(na, nb, nc);
    if (ys == -1) return ys;
    else return ys + 1;
  }
}

int main() {
  scii(A,B) sci(C);
  printf("%d\n", swap(A,B,C));
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _n = get!(usize);
    let aa = get!(String).split_whitespace().map(|a| a.parse::<i32>().unwrap()).collect::<Vec<_>>();
    match (aa.iter().min(), aa.iter().max()) {
        (Some(min), Some(max)) => println!("{}", max - min),
        _ => ()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,string> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool cmp(P a, P b) {
  return a.first>b.first;
}

vector<P> m(vector<P> a) {
  if(a.size()==1) return a;
  if(a.size()==2) {
    inplace_merge(a.begin(),a.begin()+1,a.end(),cmp);
    return a;
  }
  vector<P> b,c;
  for(int i=0; i<a.size(); i++) {
    if(i<a.size()/2) b.push_back(a[i]);
    else c.push_back(a[i]);
  }
  b=m(b);
  c=m(c);
  copy(c.begin(), c.end(), back_inserter(b)); 
  inplace_merge(b.begin(),b.begin()+(b.size()-c.size()),b.end(),cmp);
  return b;
}

int main() {
  int n;
  bool ck=false;
  while(cin >> n && n) {
    if(ck) cout << endl;
    ck=true;
    vector<P> a(n);
    rep(i,n) {
      string s;
      int x,y,z;
      cin >> s >> x >> y >> z;
      a[i].F=x*3+z;
      a[i].S=s;
    }
    a=m(a);
    rep(i,n) cout << a[i].S << "," << a[i].F << endl;
  }
  return 0;
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  set<int> N;
  int n;
  for (int i{}; i < 4; ++i) {
    scanf("%d", &n);
    N.insert(n);
  }

  printf(N.find(1) != N.end() &&
      N.find(9) != N.end() &&
      N.find(7) != N.end() &&
      N.find(4) != N.end() ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double a[2],b[2],c[2],ans[2];
  for(;;){
    if(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&a[0],&a[1],&b[0],&b[1],&c[0],&c[1]) == EOF) break;
    if(a[0] == b[0]) printf("%.6lf %.6lf\n",-c[0],c[1]);
    else{
      double x = (a[1]-b[1])/(a[0]-b[0]);
      c[0]-=a[0];
      c[1]-=a[1];
      ans[0] = c[0]*(1-x*x)/(x*x+1)+c[1]*2*x/(x*x+1);
      ans[1] = c[0]*2*x/(x*x+1)+c[1]*(x*x-1)/(x*x+1);
      printf("%.6lf %.6lf\n",ans[0]+a[0],ans[1]+a[1]);
    }
  }
  return 0;
}

Measured memory_bytes: 1240
#include<iostream>
using namespace std;
int main()
{
	int n;cin>>n;
	while(n>0)
	{
		if(n%10==9)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		n=n/10;
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 2005;

ll dp[MAX][MAX];

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    vector<P> p;
    rep(i,n) p.emplace_back(a[i],i);
    sort(p.rbegin(),p.rend());
    REP(i,n+1) {
        int pi = p[i-1].second;
        rep(l,i+1) {
            int r = i-l;
            if (l == i) dp[i][l] = dp[i-1][l-1]+(ll)(pi-l+1)*a[pi];
            else if (l == 0) dp[i][l] = dp[i-1][l]+(ll)(n-r-pi)*a[pi];
            else dp[i][l] = max(dp[i-1][l-1]+(ll)(pi-l+1)*a[pi],dp[i-1][l]+(ll)(n-r-pi)*a[pi]);
        }
    }
    ll ans = 0;
    rep(i,n+1) ans = max(ans,dp[n][i]);
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
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;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


int main(){
    int N,K; cin>>N>>K;
    int a[N]; CINA(a,N);
    REP(count,min(K,50)){
        int b[N+1] = {0};
        REP(i,N){
          int left = max(0,i-a[i]);
          int right = min(N-1,i+a[i]);
          ++b[left];
          --b[right+1];
        }
        for(int i=1;i<N;++i){
            b[i] += b[i-1];
        }
        REP(i,N){
            a[i] = b[i];
        }
    }
    REP(i,N){
        if(i<N-1){ cout << a[i] << " ";}
        else{ cout << a[i] << "\n";}
    }
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int K, T;
    cin >> K >> T;

    int sum = 0;
    vector<int> a(T);
    REP(i, T) {
        cin >> a[i];
        sum += a[i];
    }

    int ans = 0;
    REP(i, T) {
        if (a[i] - 1 > sum - a[i]) {
            ans += (a[i] -1) - (sum - a[i]);
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int K,ans;
  scanf("%d",&K);
  if(K % 2 == 0){
    ans = K * K / 4;
  }else{
    ans = (K - 1) * (K + 1) / 4;
  }
  printf("%d",ans);
  return 0;
}

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

int abs(int num) {
  if (num < 0) return -num;
  else return num;
}

int main() {
  int n, start;
  cin >> n >> start;
  int xx[n];
  int distance[n];

  for (int k = 0; k < n; k++) {
    cin >> xx[k];
    distance[k] = abs(start - xx[k]);
  }
  sort(xx, xx + n);
  sort(distance, distance + n);

  int ans = distance[0];
  int rep = 2;
  for (int k = 1; k < n; k++) {
    if (abs(start - xx[k]) % ans != 0) {
      ans = abs(start - xx[0]);
      ans /= rep;
      rep++;
      k = 0;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

typedef long long ll;

int main(){
  int n,m,c,ans=0,sum[20]={},b[20],a[20][20];
  scanf("%d %d %d",&n,&m,&c);
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      sum[i]+=a[i][j]*b[j];
    }
    if(sum[i]+c>0) ans++;
  }

  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 256
from math import ceil
A, B, C = map(int, input().split())
ABC = [A, B, C]
big = max(ABC)
smal = min(ABC)
mid = sum(ABC) - big - smal

ans = big - mid
smal += ans
if (big - smal) % 2 == 0:
    ans += (big - smal) / 2
else:
    ans += (big - smal) / 2 + 1.5
print(int(ans))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var x = xy[0];
                var y = xy[1];
                if (x == 0)
                {
                    if (y == 0)
                        break;
                }
                if (x > y)
                {
                    var X = x;
                    x = y;
                    y = X;
                }
                Console.WriteLine("{0} {1}",x,y);
            }
        }
    }
}

Measured memory_bytes: 9800
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string S){
    REP(i, S.size())
        printf("%c", 'x');
    cout << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val pay = if(N % 1000 > 0) (N / 1000 + 1) * 1000 else N
    
    println(pay - N)
  }
}

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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 200000
#define MOD 100000007
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

int n;
vector<int> memo, v;

int main(void){
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  memo.assign(n, INF);
  v.resize(n);
  for(auto &i : v) cin >> i;

  memo[0] = 0;
  memo[1] = abs(v[0] - v[1]);
  for(int i = 2; i < v.size(); i++) {
    memo[i] = min(memo[i-1] + abs(v[i]-v[i-1]), memo[i-2] + abs(v[i]-v[i-2]));
  }


  cout << memo[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  vvll eds(n);
  rep(i, m) { ll a, b;
    cin >> a >> b;
    a--, b--;
    eds[a].push_back(b);
    eds[b].push_back(a);
  }
  vll ans(n, -1);
  queue<ll> que;
  que.push(0);
  ans[0] = 0;
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for(ll v : eds[u]){
      if(ans[v] == -1){
        que.push(v);
        ans[v] = u;
      }
    }
  }

  cout << "Yes" << endl;
  rep(i, n - 1) { cout << ans[i + 1] + 1 << endl; }

  return 0;
}


Measured memory_bytes: 12860
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

int main(){
string S;cin >> S;
ll K, L, cnt1 = 0;cin >> K;
map<char, ll> M;
map<string, ll> Ans;

L = S.size();

rep(i, 0, L)M[S[i]]++;

for(auto x : M ){

  cnt1++;

  if(cnt1 > 5)break;

  char c = x.first;

  rep(i, 0, L){

    if(S[i] == c){

      ll j = i;

      while(j < min(i + 5, L)){

        Ans[S.substr(i, j - i + 1)]++;
        
        j++;

      }

    }

  }

}
  
cnt1 = 0;

for(auto x : Ans ){
  
  cnt1++;
  
  if(cnt1 == K)cout << x.first << endl;

}

}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x;
    int count=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x==(i*500)+(j*100)+(k*50)){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/

double ki(int x) {
	double a=(double)1 / 2 * x*(x + 1);
	return (double)a / x;

}

int main(void) {
	int N, K;
	int p[200000];
	scanf("%d%d", &N, &K);
	rep(i, N) {
		scanf("%d", &p[i]);
	}
	
	int Y[200001] = { 0 };
	int sum = 0;
	rep(i, N) {
		sum += p[i];
		Y[i + 1] = sum;
	}
	int max = 0;
	int index = 0;
	rep(i, N + 1) {
		if (i == N - K + 1) break;
		if (Y[i + K] - Y[i] > max) {
			max = Y[i + K] - Y[i];
			index = i;
		}
	}
	double sum2 = 0;
	int count = 0;
	for (int i = index; count < K; i++) {
		sum2 += ki(p[i]);
		count++;
	}
	printf("%f\n", sum2);

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	bool exY = false;
	for(int i = 0;i < n;i++){
		char c;
		cin >> c;
		if(c == 'Y'){
			exY = true;
		}
	}
	
	if(exY){
		cout << "Four" << endl;
	}else{
		cout << "Three" << endl;
	}
	
	return 0;
}

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

int main() {
    int N;string S;cin >> N >> S;
    int count = 0;
    for (int i = 0;i < N - 2;i++){
        if (S[i] == 'A'){
            if (S[i + 1] == 'B'){
                if (S[i + 2] == 'C') count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{
  long to,cap,rev;//capは残りどれだけ流せるか, revはv[to][rev]が自分への逆辺を表す
  edge(){}
  edge(long t,long c,long r):to(t),cap(c),rev(r){}
};
class flow{
  long n;
  vector<vector<edge>>v;
  vector<bool>used;
  public:
  
  long dfs(long s,long t,long f){
    if(s==t)return f;
    used[s]=1;
    for(long i=0;i<v[s].size();i++){
      edge e=v[s][i];
      if(!used[e.to]&&e.cap>0){
        long r=dfs(e.to,t,min(f,e.cap));
        if(r>0){
          v[s][i].cap-=r;v[e.to][e.rev].cap+=r;
          return r;
        }
      }
    }
    return 0;
  }
  long solve(long s,long t){//最大流を求める
    long ans=0;
    while(1){
      used.clear();used=vector<bool>(n,0);
      long f=dfs(s,t,LONG_MAX);
      if(f==0)return ans;
      else ans+=f;
    }
  }
  flow(){}
  flow(const vector<vector<edge>>&v_)
    :n(v_.size()),v(vector<vector<edge>>(v_.size())){
      for(long i=0;i<n;i++)for(long j=0;j<v_[i].size();j++){
        edge e=v_[i][j];
        v[i].push_back(edge(e.to,e.cap,v[e.to].size()));//辺の追加
        v[e.to].push_back(edge(i,0,v[i].size()-1));//逆辺の追加
      }
    }
};

int main(){
  long N;cin>>N;
  vector<long>a(N),b(N),c(N),d(N);
  for(long i=0;i<N;i++)cin>>a[i]>>b[i];
  for(long i=0;i<N;i++)cin>>c[i]>>d[i];
  vector<vector<edge>>A(2*N+2);
  for(long i=0;i<N;i++){
    A[0].push_back(edge(i+1,1,0));
    A[N+1+i].push_back(edge(2*N+1,1,0));
  }
  for(long i=0;i<N;i++)for(long j=0;j<N;j++){
    if(a[i]<c[j]&&b[i]<d[j])A[i+1].push_back(edge(j+1+N,1,0));
  }
  flow f(A);cout<<f.solve(0,2*N+1);
}

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    string s, t; cin>>s>>t;

    map<char, char> m;

    for(int i=0; i<s.length(); i++){
        if(m.find(s[i])==m.end()){
            m[s[i]] = t[i];
        }
        else{
            if(m[s[i]]!=t[i]){
                cout<<"No\n";
                return 0;
            }
        }
    }

    m.clear();

    swap(s, t);

    for(int i=0; i<s.length(); i++){
        if(m.find(s[i])==m.end()){
            m[s[i]] = t[i];
        }
        else{
            if(m[s[i]]!=t[i]){
                cout<<"No\n";
                return 0;
            }
        }
    }

    cout<<"Yes\n";
    
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> M;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
void solve() {
  int K=M;
  vb.resize(N + 1);
  vb[0] = 0;
  rep(i, 0, N - 1) { vb[i + 1] = vb[i] + va[i]; }
  priority_queue<int> pq;

  vi wa;
  rep(i, 0, N - 1) {
    // vb[i] ~ vb[i+K]

    if (i + K  <=  N) {
      pq.push(vb[i+K] - vb[i]);
    }
  }
  int ansp = pq.top();
  double ans = (ansp + K)/(2.0);
  printf("%11lf\n",ans);

}
signed main() {
  input();
  solve();
  return 0;
}


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

vector<int> RGB;

int count(int k,int n){
  if(k==2){
    if(n%RGB[k]==0) return 1;
    else return 0;
  }

  int r=0,i;
  for(i=0;i<=n/RGB[k];i++){
    r+=count(k+1,n-RGB[k]*i);
  }

  return r;
}
int main(){
  int r=0,n,i,j;
  for(i=0;i<3;i++){
    cin>>j;
    RGB.push_back(j);
  }
  sort(RGB.rbegin(),RGB.rend());

  cin>>n;
  
  r=count(0,n);

  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int ret = s.size();
    for(int i = 1;i <= n;i++) {
        if(s[i] != s[i-1]) {
            ret = min(ret,max(i,n-i));
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 512
<?php
list($H, $N) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, $H + 1, 10**18);
$dp[0] = 0;
for($i = 1; $i <= $N; $i++){
  list($a, $b) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  for($j = 1; $j <= $H; $j++){
    if($j - $a >= 0){
      if($dp[$j]>$dp[$j-$a]+$b)$dp[$j] = $dp[$j-$a]+$b;
    }else{
      if($dp[$j]>$b)$dp[$j] = $b;
    }
  }
}
echo $dp[$H];

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a;
    int n;
    double x[100];
    string y[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        if(y[i]=="BTC"){
            a+=x[i]*380000;
        }
        else a+=x[i];
    }
    cout<<a<<endl;
}
//＼(^q^)／ｵﾜﾀ


Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;
int main() {
  
	string S;
	cin >> S;
	int X = atoi(S.c_str());
  
  int answer = 0;
   int n = X / 500;
   answer += n * 1000;
   X -= (n * 500);
   n = X / 5;
   answer += n * 5;
  
  cout << answer << endl;
}

Measured memory_bytes: 256
import sys

X = int(input())

divider = []
for i in range(1,int(X**(1/2))+1):
    if X%i == 0:
        divider.append(i)
        divider.append(X//i)

for x in divider:
    B = -(x//2)
    while (B+x)**5-B**5<=X:
        if (B+x)**5-B**5==X:
            print(B+x,B)
            sys.exit()
        B+=1

Measured memory_bytes: 63740
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {

  cout << fixed << setprecision(16);

  double N, M, D;
  cin >> N >> M >> D;

  double ans;
  if( D == 0 ){
    ans = (M-1.0)/N;
    cout << ans << endl;
  }else{
    ans = 2.0*(N-D)/(N*N)*(M-1.0);
    cout << ans << endl;
  }
}

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

//nap some ok
struct nap{
	vector<long long> v,w;
	long long N,W;
	vector< vector<long long> > dp;
	nap(long long n,long long wmax){
		N=n;W=wmax;
		v.resize(n);
		w.resize(n);
		vector<long long> wv(W+1,0);
		for(int i=0;i<n+1;++i){
			dp.push_back(wv);
		}
	}
	void calc(){
		for(int i=0;i<N;++i){
			for(int j=0;j<W+1;++j){
				if(j<w[i]){
					dp[i+1][j]=dp[i][j];
				}else{
					dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
				}
			}
		}
	}
	long long maxval(long long w){
		return dp[N][w];
	}
};
  
  
int main(){
	int n,w;
	cin >> n >> w;
	nap na(n,w);
	for(int i=0;i<n;++i){
		cin >> na.v[i] >> na.w[i];
	}
	na.calc();
	cout << na.maxval(w) << endl;
}


Measured memory_bytes: 13196