akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;

int main() {
       ll int x;
       cin >> x;
       ll int p = 100, step = 0;
       while(p < x){
        p += p/100;
        step++;
       }
       cout << step;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

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

    vector<int> H(N);
    for (int i = 0; i < N; ++i)
        cin >> H[i];

    vector<int> dp(N, numeric_limits<int>::max());
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int k = 1; k <= K && i + k < N; ++k)
            dp[i + k] = min(dp[i + k], dp[i] + abs(H[i] - H[i + k]));
    }

    cout << dp.back() << "\n";
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
def main():
    A,B = map(int,input().split())
    for i in range(1,1010):
        if int(0.08*i)==A and int(0.1*i)==B:
            print(i)
            return
    print('-1')

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/



// 素集合データ構造
struct UnionFind
{
	vector<int> par;
	vector<int> sizes;

	UnionFind(int n) : par(n), sizes(n, 1)
	{
		REP(i, n) par[i] = i;
	}

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


	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}

	int size(int x)
	{
		return sizes[find(x)];
	}
};

struct Edge
{
	int a, b, cost;

	bool operator<(const Edge& o) const
	{
		return cost < o.cost;
	}
};

struct Graph
{
	int n;  
	vector<Edge> es; 

	int kruskal()
	{
		sort(es.begin(), es.end());

		UnionFind uf(n);
		int min_cost = 0;

		REP(ei, es.size())
		{
			Edge& e = es[ei];
			if (!uf.same(e.a, e.b)) {
				min_cost += e.cost;
				uf.unite(e.a, e.b);
			}
		}

		return min_cost;
	}
};

//Graph input_graph()
//{
//	Graph g;
//	int m;
//	cin >> g.n;
//	m = g.n;
//	vp v;
//	REP(i, g.n)
//	{
//		ll a, b;
//		cin >> a >> b;
//		v.push_back(make_pair(a, b));
//	}
//	sort(ALL(v));
//
//	REP(i, m - 1)
//	{
//		Edge e;
//		e.a = i;
//		e.b = i+1;
//		e.cost = v[i + 1].first - v[i].first;
//		g.es.push_back(e);
//	}
//
//	vp vy;
//	REP(i, m)
//	{
//		vy.push_back(make_pair(v[i].second, i));
//	}
//
//	sort(ALL(vy));
//
//	REP(i, m - 1)
//	{
//		Edge e;
//		e.a = v[i].second;
//		e.b = v[i + 1].second;
//		e.cost = (v[i + 1].first - v[i].first);
//		g.es.push_back(e);
//	}
//	return g;
//}



int main()
{
	//Graph g = input_graph();
	Graph g;
	int m;
	cin >> g.n;
	m = g.n;
	vp v;
	REP(i, g.n)
	{
		ll a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(ALL(v));

	REP(i, m - 1)
	{
		Edge e;
		e.a = i;
		e.b = i + 1;
		e.cost = v[i + 1].first - v[i].first;
		g.es.push_back(e);
	}

	vp vy;
	REP(i, m)
	{
		vy.push_back(make_pair(v[i].second, i));
	}

	sort(ALL(vy));

	REP(i, m - 1)
	{
		Edge e;
		e.a = vy[i].second;
		e.b = vy[i + 1].second;
		e.cost = (vy[i + 1].first - vy[i].first);
		g.es.push_back(e);
	}

	cout << g.kruskal() << endl;
	return 0;
}

Measured memory_bytes: 8048
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 3000;
int a,b,k;
ll m[G][G], dp[G][G][4];
vec<vec<ll>> n;

int main() {
    fast;
    init(m, 0);
    init(dp, 0);
    cin>>a>>b>>k;
    n = vec<vec<ll>>(k, vec<ll>(3));
    for(int q=0; q<k; q++){
        int x,y,c; cin>>x>>y>>c; x--, y--;
        n[q] = {x, y, c};
        m[x][y] = c;
    }
    dp[0][0][1] = m[0][0];
    for(int w=1; w<b; w++){
        for(int e=1; e<4; e++){
            dp[0][w][e] = max(dp[0][w-1][e], dp[0][w-1][e-1]+m[0][w]);
        }
    }
    for(int q=1; q<a; q++){
        dp[q][0][0] = dp[q-1][0][1];
        dp[q][0][1] = dp[q-1][0][1]+m[q][0];
        for(int w=1; w<b; w++){
            dp[q][w][0] = max(dp[q][w-1][0],
                              *max_element(dp[q-1][w], dp[q-1][w]+4));
            for(int e=1; e<4; e++){
                dp[q][w][e] = max(dp[q][w-1][e], dp[q][w-1][e-1]+m[q][w]);
                if(e==1) dp[q][w][e] = max(dp[q][w][e], dp[q][w][0]+m[q][w]);
            }
        }
    }
    cout<<*max_element(dp[a-1][b-1], dp[a-1][b-1]+4);
}

Measured memory_bytes: 365692
package main

import "fmt"

func lcm(x, y int) int {
	gcd := func(x, y int) int {
		for y != 0 {
			x, y = y, x%y
		}
		return x
	}
	return x * y / gcd(x, y)
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	dC := b/c - (a-1)/c
	dD := b/d - (a-1)/d
	l := lcm(c, d)
	dCandD := b/l - (a-1)/l

	fmt.Println(b - a + 1 - (dC + dD - dCandD))
}


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

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vx;

const i64 mod=1e9+7;

// returns n = (b**p) mod m
i64 modpow(i64 b, i64 p, i64 m) {
    i64 n=1, a=b%m;
    while (p) {
        if (p & 1)
            n = (n*a) % m;

        a = (a*a) % m;
        p >>= 1;
    }
    return n;
}

// returns a^(-1) mod m
i64 modinv(i64 a, i64 m=mod) {
    return modpow(a, m-2, m) % m;
}

vx modfact_table(int n, int mod=1e9+7) {
    vx table(n+1);
    table[0] = 1;

    int i;
    for (i=1; i<=n; i++)
        table[i] = (table[i-1]*i) % mod;

    return table;
}

vx modfactinv_table(int n, i64 factn=-1, i64 mod=1e9+7) {
    vx table(n+1);
    int i;
    if (factn == -1) {
        factn = 1;
        for (i=1; i<=n; i++)
            factn = (factn*i) % mod;
    }
    table[n] = modinv(factn);
    for (i=n; i--;)
        table[i] = (table[i+1]*(i+1)) % mod;

    return table;
}

int main(void) {
    i64 H, W, A, B;
    cin >> H >> W >> A >> B;

    vx facts=modfact_table(H+W-2);
    vx factinvs=modfactinv_table(H+W-2, facts[H+W-2]);

    i64 res=0;
    int i;
    for (i=B; i<W; i++) {
        i64 former, latter;
        former = (facts[H-A-1+i]*factinvs[H-A-1]%mod)*factinvs[i] % mod;
        latter = (facts[W+A-2-i]*factinvs[A-1]%mod)*factinvs[W-1-i] % mod;

        res = (res + former*latter%mod) % mod;
    }

    cout << res << endl;
    return 0;
}


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int32_t main(){
sp;
int n,m;
cin>>n>>m;
int a[n+2];
memset(a,0,sizeof a);
for(int i=0; i<m; ++i){
    int l,r;
    cin>>l>>r;
    ++a[l];
    --a[r+1];
}
int ans=0;
for(int i=1; i<=n; ++i){
    a[i]+=a[i-1];
    if(a[i]==m)
        ++ans;
}
cout<<ans;
return 0;}


Measured memory_bytes: 1024
S = gets.chomp.split("").map(&:to_i)
zero_count = 0
one_count = 0
S.each do |num|
    if num == 0
        zero_count += 1
    else
        one_count += 1
    end
end

if zero_count >= one_count
    puts one_count*2
else
    puts zero_count*2
end


Measured memory_bytes: 7676
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s[n];
  int t[n];
  string x;
  for(int i=0;i<n;++i) cin>>s[i]>>t[i];
  cin >> x;
  
  bool sleep = false;
  int ts=0;
  for(int i=0;i<n;++i){
    if(sleep){
      ts+=t[i];
    }
    if(s[i]==x){
      sleep=true;
    }
  }
  
  printf("%d\n",ts);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int n;
  cin>>n;
  vector<pair<int,int>> p(n);
  rep(i,n){
    int a;cin>>a;
    p[i]=make_pair(a,i);
  }
  sort(all(p));
  vector<pair<int,int>> ans(n);

  rep(i,n){
    if(i<n/2){
      ans[i]=make_pair(p[i].second,p[n/2].first);
    }else{
      ans[i]=make_pair(p[i].second,p[n/2-1].first);
    }
  }
  sort(all(ans));
  rep(i,n){
    cout<<ans[i].second<<endl;
  }


  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;

    int ans = 0;

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) ans++;
    }

    cout << min(ans + 2 * k, n - 1) << endl;

    return 0;
}


Measured memory_bytes: 512
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n - 1)

	b := map[int]int{}
	for i := 0; i < n-1; i++ {
		b[a[i]]++
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(wr, b[i+1])
	}

}


Measured memory_bytes: 14416
N, M = map(int, input().split())

x = [0 for i in range(N)]
y = [0 for i in range(N)]
z = [0 for i in range(N)]

for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())

max = 0


for j in range(8):
    sum = [0 for i in range(N)]
    for i in range(N):
        if j == 0:
            sum[i] = x[i] + y[i] + z[i]
        elif j == 1:
            sum[i] = x[i] + y[i] - z[i]
        elif j == 2:
            sum[i] = x[i] - y[i] + z[i]
        elif j == 3:
            sum[i] = x[i] - y[i] - z[i]
        elif j == 4:
            sum[i] = - x[i] + y[i] + z[i]
        elif j == 5:
            sum[i] = - x[i] + y[i] - z[i]
        elif j == 6:
            sum[i] = - x[i] - y[i] + z[i]
        elif j == 7:
            sum[i] = - x[i] - y[i] - z[i]

    sum.sort()

    max_tmp = 0
    for i in range(M):
        max_tmp = max_tmp + sum[N - i - 1]

    if max_tmp > max:
        max = max_tmp

print(max)

Measured memory_bytes: 3188
// problem: "https://atcoder.jp/contests/abc149/tasks/abc149_d"

#include<bits/stdc++.h>

using namespace std;

int maxP(int n,char c,int k,map<char,vector<int>>&M,string &t,int r,int s,int p)
{
    if(n < 0)
        return 0;

    if(M[c][n] == -1)
    {
        int m = 0;

        if(c != 'r' && t[n] == 's')
            m = max(m,maxP(n-k,'r',k,M,t,r,s,p)+r);

        if(c != 's' && t[n] == 'p')
            m = max(m,maxP(n-k,'s',k,M,t,r,s,p)+s);

        if(c != 'p' && t[n] == 'r')
            m = max(m,maxP(n-k,'p',k,M,t,r,s,p)+p);

        if(c == 'r')
        {
            m = max(m,maxP(n-k,'p',k,M,t,r,s,p));
            m = max(m,maxP(n-k,'s',k,M,t,r,s,p));
        }

        if(c == 'p')
        {
            m = max(m,maxP(n-k,'r',k,M,t,r,s,p));
            m = max(m,maxP(n-k,'s',k,M,t,r,s,p));
        }

        if(c == 's')
        {
            m = max(m,maxP(n-k,'p',k,M,t,r,s,p));
            m = max(m,maxP(n-k,'r',k,M,t,r,s,p));
        }

        M[c][n] = m;
    }

    return M[c][n];
}

int main()
{
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;

    string t;
    cin>>t;

    map<char,vector<int>>M;
    M['r'] = vector<int>(n+1,-1);
    M['s'] = vector<int>(n+1,-1);
    M['p'] = vector<int>(n+1,-1);
    M['n'] = vector<int>(n+1,-1);

    int i,S;
    S = 0;
    for(i=n-1;i>n-1-k;i--)
        S += maxP(i,'n',k,M,t,r,s,p);       // define

    cout<<S;

    return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>

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

using namespace std;

int main(){
    
    int N;
    cin>>N;
    if(N%2==0){
        cout<<std::fixed<<std::setprecision(10)<<0.5<<endl;
        
    }
    else{
        cout<<std::fixed<<std::setprecision(10)<<(double)(N/2+1)/N<<endl;
        
    }
}

Measured memory_bytes: 3692
n,p=map(int,input().split())
a=list(map(int,input().split()))
temp1=0
temp0=0
for i in range(n):
  if a[i]%2==0:
    temp0=temp0+1
  else:
    temp1=temp1+1
if p%2==0:
  if temp1==0:
    print(2**n)
  else:
    print(2**(n-1))
else:
  if temp1==0:
    print(0)
  else:
    print(2**(n-1))
  

Measured memory_bytes: 9172
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val ans = IntArray(n) { 0 }

    for (i in n-1 downTo 0) {
        val num = aa[i]
        var idx = (i+1)*2

        var cnt = 0
        while (idx <= n) {
            cnt += ans[idx-1]
            idx += (i+1)
        }

        if (num == 0) {
            ans[i] = if (cnt % 2 == 0) 0 else 1
        } else {
            ans[i] = if (cnt % 2 == 1) 0 else 1
        }
    }

    val ansCnt = ans.count { it == 1 }
    println(ansCnt)

    if (ansCnt > 0) {
        println(ans.mapIndexed { index, i -> if (i == 1) index+1 else 0 }.filter { it != 0 }.joinToString(separator = " "))
    }
}

Measured memory_bytes: 65532
from math import gcd

N=int(input())
A=list(map(int,input().split()))

if N==2:
    print(max(A))
else:
    r1=max(gcd(A[0],A[1]),gcd(A[1],A[2]),gcd(A[2],A[0]))
    a=gcd(A[2],gcd(A[0],A[1]))

    for i in range(3,N):
        r1=max(gcd(A[i],r1),a)
        a=gcd(a,A[i])
    print(r1)

Measured memory_bytes: 20704
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int[]>[] channel = Enumerable.Repeat(0,nc[1]).Select(_ => new List<int[]>()).ToArray();
        for (int i = 0; i < nc[0]; i++)
        {
            int[] stc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            channel[stc[2] - 1].Add(new int[] { stc[0], stc[1] });
        }
        int[] imos = new int[100010];
        for (int i = 0; i < channel.Length; i++)
        {
            int[][] a = channel[i].OrderBy(x => x[0]).ToArray();
            int endind = 0;
            imos[0]++;
            for (int j = 0; j < a.Length; j++)
            {
                if(endind != a[j][0])
                {
                    imos[endind]--;
                    imos[a[j][0] - 1]++;
                    endind = a[j][1];
                }
                endind = a[j][1];
            }
            imos[endind]--;
        }
        int current = 0;
        int max = 0;
        for (int i = 0; i < imos.Length; i++)
        {
            current += imos[i];
            max = Math.Max(max, current);
        }
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 30772
# AOJ 0026 Dropping Ink
# Python3 2018.6.15 bal4u

paper = [[0 for i in range(15)] for j in range(15)]
base = 2

while True:
	try:
		x, y, s = list(map(int, input().split(',')))
	except EOFError:
		break
        
	x += 2
	y += 2
	if s == 3:
		paper[x-2][y] += 1
		paper[x+2][y] += 1
		paper[x][y-2] += 1
		paper[x][y+2] += 1

	if s >= 2:
		paper[x-1][y-1] += 1
		paper[x-1][y+1] += 1
		paper[x+1][y-1] += 1
		paper[x+1][y+1] += 1

	paper[x][y] += 1
	paper[x-1][y] += 1
	paper[x+1][y] += 1
	paper[x][y-1] += 1
	paper[x][y+1] += 1

cnt = max = 0;
for x in range(2, 12):
	for y in range(2, 12):
		if paper[x][y] == 0:
			cnt += 1
		if paper[x][y] > max:
			max = paper[x][y]

print(cnt, max, sep='\n')


Measured memory_bytes: 5616
n = gets.to_i
dp = Array.new(n){[0,0,0]}
gets.split.map(&:to_i).each_with_index do |abc,j|
  dp[0][j] = abc
end
(1..n-1).each do |i|
  gets.split.map(&:to_i).each_with_index do |abc,j|
    dp[i-1].each_with_index do |abc2,k|
      next if j == k
      dp[i][j] = [abc + abc2, dp[i][j]].max
    end
  end
end
p dp[n-1].max


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

double min(double p, int n, int *x, int *y) {
    double d = 0.0;
    for (int i = 0; i < n; i++) {
        d += pow(abs(x[i] - y[i]), p);
    }
    return pow(d, 1 / p);
    return d;
}

int main() {
    int n, x[100], y[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    for (int i = 1; i <= 3; i++) {
        printf("%lf\n", min(i, n, x, y));
    }
    double max = 0;
    for (int i = 0; i < n; i++) {
        int diff = abs(x[i] - y[i]);
        max = diff > max ? diff : max;
    }
    printf("%lf\n", max);
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const int N = 18;

LL pw[maxn],ans,d; 
void solve(int stp,LL num,LL res,bool fir) {
	if (stp<=1) {
		if (stp) res*=10-fir;
		if (!num) ans+=res;
		return ;
	}
	LL mul=pw[stp-1]-1;
	for (int i=fir?0:-9;i<=9;i++) {
		LL _=num-mul*i;
		if (_%10||abs(_)>pw[stp]) continue;
		solve(stp-2,_/10,res*(10-abs(i)-fir),0);
	}
}
int main()
{
	#ifdef Amberframe
		freopen("arc075f.in","r",stdin);
		freopen("arc075f.out","w",stdout);
	#endif
	scanf("%lld",&d);pw[0]=1ll;
	for (int i=1;i<=N;i++) pw[i]=pw[i-1]*10;
	for (int i=1;i<=N;i++) solve(i,d,1,1);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
x,n=map(int,input().split())
q=list(map(int,input().split()))
q=q+[100000000]
p=list(map(lambda i:abs(x-i),q))

p.sort()
if n==0:
  print(x)
  sys.exit()
for i in range(len(p)):
  if p[i]!=(i+1)//2:
    if i==0:
      print(x)
      sys.exit()
    elif i==1:
      print(x-1)
      sys.exit()
    elif p[i-1]==p[i-2]:
      print(x-p[i-1]-1)
      sys.exit()
    else:
      if x-p[i-1] in q:
        print(x+p[i-1])
      else:
        print(x-p[i-1])
      sys.exit()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll int
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define pll pair<ll,ll>
const ll maxn= 2e5+10;
const ll mod = 5000000  ;
const ll base= 1e7;
ll st[4*maxn];
ll  get(ll id,ll left,ll right,ll x,ll y)
{
    if (y<x) return 0;
    if (left>y||right<x)
        return 0;
    if (x<=left&&right<=y)
    {
        return st[id];
    }
    ll mid =(left+right)/2;
    return (get(id*2,left,mid,x,y)+get(id*2+1,mid+1,right,x,y))%mod;

}
void update(ll id,ll left,ll right, ll pos,ll diff)
{
    if (pos<left||pos>right)
        return ;
    if (left==right)
    {
        st[id]=diff;
        return;
    }
    ll mid =(left+right)/2;
    update(id*2,left,mid,pos,diff);
    update(id*2+1,mid+1,right,pos,diff);
    st[id]=(st[id*2]+st[id*2+1])%mod ;

}
pll a[maxn];
ll b[maxn];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*  if (fopen("D_tst.INP","r"))
      {
          freopen("D_tst.INP","r", stdin);
          freopen("D_tst_1.cpp", "w",stdout);
      }*/
      ll t;
       cin>> t;
       ll cnt=8;
       for(int i=400;i<=1999;i+=200)
       {
           if (t<=i+199)
           {
               cout <<cnt;
               return 0;
           }
           cnt--;
       }


}
/*10 1
56 12 68 23 41 29 97 69 79 76
1 3 5
*/


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
 cin>>a>>b>>c>>d;
 while(1)
 {
 	c=c-b;
 	if(c<=0)
 	{
 		cout<<"Yes";
 		break;
	}
	a=a-d;
	if(a<=0)
	{
		cout<<"No";
		break;
	}
 }
  return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.StringTokenizer;
import java.util.function.BiConsumer;
import java.util.function.UnaryOperator;
import java.util.stream.IntStream;

import static java.lang.Math.*;

public class Main {
    private static final int[] xMove = {-1, 0, 1, 0};
    private static final int[] yMove = {0, -1, 0, 1};

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();

        final int[][] distances = new int[n][n + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= n; j++) {
                distances[i][j] = min(min(i, n - i - 1), min(j - 1, n - j));
            }
        }

        final boolean[][] hasGone = new boolean[n][n + 1];
        final UnaryOperator<Integer> bfs = point -> {
            final int x = (point - 1) / n;
            final int y = (point - 1) % n + 1;
            final int distance = distances[x][y];
            hasGone[x][y] = true;

            final Deque<Point> queue = new ArrayDeque<>();
            queue.add(new Point(x, y));
            while (!queue.isEmpty()) {
                final Point current = queue.pollFirst();
                for (int i = 0; i < 4; i++) {
                    final int nextX = current.x + xMove[i];
                    final int nextY = current.y + yMove[i];
                    if (nextX == -1 || nextX == n || nextY == 0 || nextY == n + 1) {
                        continue;
                    }

                    final int nextDistance = distances[current.x][current.y] + (hasGone[current.x][current.y] ? 0 : 1);
                    if (nextDistance < distances[nextX][nextY]) {
                        queue.add(new Point(nextX, nextY));
                        distances[nextX][nextY] = nextDistance;
                    }
                }
            }

            return distance;
        };

        final long count = IntStream.range(0, n * n)
            .map(i -> bfs.apply(scanner.nextInt()))
            .sum();

        System.out.println(count);
    }

    private static class Point {
        final int x;
        final int y;

        Point(final int x, final int y) {
            this.x = x;
            this.y = y;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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


Measured memory_bytes: 59424
a=[],m=l=0,n=c='';require("fs").readFileSync("/dev/stdin","utf8").trim().split(' ').some(function(i){a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

Measured memory_bytes: 7644
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >>N;
    vector<double> X(N);
    vector<string> U(N);
   for(int i = 0;i < N;i++){
       cin >> X[i] >> U[i];
   }
   double ans = 0;
   for(int i = 0; i < N;i++){
       if(U[i] == "JPY") ans += X[i];
       else ans += X[i] * 380000.0; 
   }
   cout << fixed << setprecision(5);
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int a[200005],b[200005];
int main()
{
    int n;   cin>>n;
    for(int i=1;i<=n;i++)
    {
        int t;  scanf("%d",&t);
        a[i]=i-t;
        b[i]=i+t;
    }
    sort(b+1,b+n+1);
    //for(int i=1;i<=n;i++) cout<<b[i]<<" ";
    //cout<<endl;
    for(int i=1;i<=n;i++)
    {
        ll r=lower_bound(b+1,b+n+1,a[i])-b;
        ll l=upper_bound(b+1,b+n+1,a[i])-b;
        if(a[i]<b[1]) continue;
        //cout<<l<<" "<<r<<endl;
        ans+=l-r;
    }
    cout<<ans;
    return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int ans = 0;
	while (a >= b) {
		ans++;
		b *= 2;
	}
	while (b >= c) {
		ans++;
		c *= 2;
	}
	if (ans <= k)cout << "Yes" << endl;
	else cout << "No" << endl;

}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
n = len(s)
s = s[::-1]
dp = [[0]*13 for _ in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
x = 1
for i in range(1,n):
    x = (x*10) % 13
    if s[i] == '?':
        for j in range(10):
            for k in range(13):
                dp[i][(k+(j*x) % 13) % 13] += dp[i-1][k]
                dp[i][(k+(j*x) % 13) % 13] %= mod
    else:
        y = int(s[i])
        for j in range(13):
            dp[i][(j+(y*x) % 13) % 13] += dp[i-1][j]
            dp[i][(j+(y*x) % 13) % 13] %= mod
print(dp[-1][5])


Measured memory_bytes: 65384
# -*- coding: utf-8 -*-

n = int(raw_input())
tp = hp = 0
for i in range(n):
    ts, hs = map(str, raw_input().split())
    if ts > hs:
        tp += 3
    elif ts < hs:
        hp += 3
    else:
        tp += 1
        hp += 1
print "%d %d" %(tp, hp)

Measured memory_bytes: 6436
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int left, right;
    left = right = 0;
    for(int i = 0; i < m; i++) {
        int a; cin >> a;
        if(a < x) left++;
        else right++;
    }
    cout << min(left, right) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

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

  ll a[n+1], c[n+1], cp[n+1], sum = 0;
  c[0] = 0; cp[0] = 0;
  for(int i=1; i<=n; i++) {
    cin >> a[i];

    c[i] = c[i-1] + a[i];
    cp[i] = cp[i-1];
    if(a[i] > 0) {
      sum += a[i];
      cp[i] += a[i];
    }
  }

  ll ans = 0;
  for(int i=1; i + k <= n + 1; i++){
    ans = max(ans, sum - (cp[i+k-1]-cp[i-1]));
    ans = max(ans, sum - (cp[i+k-1]-cp[i-1]) + (c[i+k-1]-c[i-1]));
  }

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


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename X, typename Y> ostream &operator<< (ostream &fout, const pair<X, Y> &p)
{ fout << '{' << p.first << ", " << p.second << "} "; return fout; }

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e3 + 5;

bool vis[MAX][MAX];

int main()
{
    ll h, w; cin >> h >> w;
    vector<string> v(h); cin >> v;

    ll nb = 0, nw = 0;
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            if (v[i][j] == '#') nb++;
            else nw++;
        }
    }

    queue<mt> q;
    vis[0][0] = true;
    q.push(mt(0, 0, 1));

    while (!q.empty()) {
        mt t = q.front(); q.pop();
        ll x, y, l; tie(x, y, l) = t;

        if (x == h - 1 && y == w - 1) {
            cout << nw - l << endl; exit(0);
        }

        ll dx[] = {-1, 1,  0, 0};
        ll dy[] = { 0, 0, -1, 1};
        for (ll i = 0; i < 4; i++) {
            ll nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= h) continue;
            if (ny < 0 || ny >= w) continue;
            if (vis[nx][ny]) continue;
            if (v[nx][ny] == '#') continue;

            q.push(mt(nx, ny, l + 1));
            vis[nx][ny] = true;
        }
    }

    cout << -1 << endl;

    return 0;
}


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

std::vector<std::vector<int>> t_arr;
std::vector<int> visited, depth_arr;
int loop_node = -1;

int dfs(int current, int depth){
  depth_arr[current] = depth;
  visited[current] = 1;

  int max_depth = -1;
  for(auto&& it: t_arr[current]){
    if(visited[it] != 1) continue;
    if(max_depth < visited[it]){
      max_depth = depth_arr[it];
      loop_node = it;
    }
  }
  if(max_depth >= 0) return 1;

  for(auto&& it: t_arr[current]){
    if(visited[it]) continue;
    if(dfs(it, depth+1)) return 1;
  }
  visited[current] = 2;
  return 0;
}

int main(){
  int N,M;
  std::cin >> N >> M;
  t_arr = decltype(t_arr)(N);
  visited = decltype(visited)(N);
  depth_arr = decltype(depth_arr)(N, -1);
  for(int i = 0; i < M; i++){
    int a,b;
    std::cin >> a >> b;
    a--; b--;
    t_arr[a].push_back(b);
  }

  for(int n = 0; n < N; n++){
    if(visited[n]) continue;
    if(dfs(n, 0)) break;
  }
  if(loop_node == -1){
    std::cout << -1 << std::endl;
    return 0;
  }

  std::vector<int> loop;
  int current = loop_node;
  while(current != -1){
    loop.push_back(current);
    int max_depth = depth_arr[current], max_node = -1;
    for(auto&& it: t_arr[current]){
      if(visited[it] != 1) continue;
      if(max_depth < depth_arr[it]){
        max_depth = depth_arr[it];
        max_node = it;
      }
    }
    current = max_node;
  }

  std::cout << loop.size() << std::endl;
  for(auto&& it: loop) std::cout << it+1 << " ";
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 384
n, h = [int(x) for x in input().split()]
a = []
b = []
for _ in range(n):
    x, y = [int(x) for x in input().split()]
    a.append(x)
    b.append(y)

l = list(zip(a, b))

a.sort()
b.sort(reverse=True)
p = a[-1]

c = 0
d = 0
for y in b:
    if y < p:
        break
    if d >= h:
        print(c)
        exit()
    c += 1
    d += y

if (h - d) % p == 0:
    c += ((h - d) // p)
else:
    c += ((h - d) // p + 1)
print(c)


Measured memory_bytes: 18464
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int h, w;
  string mat[30][30];

  cin >> h >> w;
  for (int i= 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> mat[i][j];
    }
  }

  for (int i = 0; i < h ;++i) {
    for (int j = 0; j < w; j++) {
      if (mat[i][j] == "snuke") {
        printf("%c%d\n", 'A'+j, i+1);
        return 0;
      }
    }
  }



  return 0;
}



Measured memory_bytes: 256
from itertools import product
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for a in A:
        if a[2] > 0:
            t = a
            break
    for x, y in product(range(0, 101), repeat = 2):
        H = t[2] + abs(t[0] - x) + abs(t[1] - y)
        for a in A:
            if a[2] == 0 and H > abs(a[0] - x) + abs(a[1] - y):
                break
            elif a[2] != 0 and a[2] != H - abs(a[0] - x) - abs(a[1] - y):
                break
        else:
            ansx, ansy = x, y
            break
    H = t[2] + abs(t[0] - ansx) + abs(t[1] - ansy)
    print('{} {} {}'.format(ansx, ansy, H))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> L(N);
  rep (i, N) cin >> L[i];
  sort(L.begin(), L.end());
  unordered_map<long, long> um;
  rep (i, N) um[L[i]]++;
  vector<long> accum(1010);
  for (long i = 1; i < 1010; i++) accum[i] = accum[i-1] + um[i];
  reverse(L.begin(), L.end());
  long ans = 0;
  for (long i = 0; i < N; i++) for (long j = i + 1; j < N; j++) {
    long abs = L[i] - L[j];
    long candidate = N - j - 1;
    long cannotUse = accum[abs];
    long tmp = candidate - cannotUse;
    if (tmp < 0) tmp = 0;
    ans += tmp;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
// 2011/02/06 Tazoe

#include <iostream>
#include <string>
using namespace std;

struct food{
	string f;
	int w;
	int s;
};

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		struct food F[10];
		for(int i=0; i<n; i++)
			cin >> F[i].f >> F[i].w >> F[i].s;

		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(F[i].w<F[j].w){
					struct food tmp = F[i];
					F[i] = F[j];
					F[j] = tmp;
				}

		for(int i=0; i<n-1; i++){
			int sum = 0;
			for(int j=i+1; j<n; j++)
				sum += F[j].w;

			if(F[i].s>=sum)
				continue;

			int k;
			for(k=i+1; k<n; k++)
				if(F[k].s>=sum+F[i].w-F[k].w)
					break;

			struct food tmp = F[k];
			for(int j=k; j>i; j--)
				F[j] = F[j-1];
			F[i] = tmp;
		}

		for(int i=0; i<n; i++)
			cout << F[i].f << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

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

    vector<int> weight(N),value(N);
    int max_val=0;
    REP(i,N) {
        cin >> weight[i] >> value[i];
        chmax(max_val,value[i]);
    }

    auto dp = make_vec<ll>(N+1,N * max_val + 1);
    fill_v(dp,inf);
    dp[0][0]=0;

    REP(i,N) REP(j,N * max_val + 1){
        if(j < value[i]) {
            dp[i+1][j] = dp[i][j];
        } else {
            dp[i+1][j] = min(dp[i][j],dp[i][j-value[i]]+weight[i]);
        }
    }

    ll ans=0;
    REP(j,N * max_val + 1) if(dp[N][j] <= W) ans = j;

    pl(ans)

    return 0;
}

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

int main(){

    int H,W,K;  
    cin >> H >> W >> K;
    string c[H];

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

    int count = 0;
    int ans = 0;
    for(int maski = 0;maski < (1<<H);maski++){
        for(int maskj = 0;maskj < (1<<W);maskj++){
            
        count = 0;

        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){

                if((((maski>>i)&1)==0)&&(((maskj>>j)&1)==0)&&(c[i][j]=='#')){
                    count++;
                }
            }
        }

        if(count == K) ans++;



    }
    }

    cout << ans << endl;
   

}

Measured memory_bytes: 3580
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int x)
{
  int result = 8;
  for (int left = 400; result >= 1; left += 200) {
    if (left <= x && x <= left + 199) return result;
    --result;
  }
  throw 1;
}

int main()
{
  int x;
  std::cin >> x;

  std::cout << std::setprecision(20);
  std::cout << solve(x) << std::endl;
}


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

typedef long long ll;
typedef vector<ll> vi;

vi v;
int n;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll t;
    while(cin >> n)
    {
        v = vi(n+2,0); t = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> v[i];
            t += labs(v[i]-v[i-1]);
        }
        t += labs(v[n]-v[n+1]);
        for(int i = 1; i <= n; i++)
            cout << t - labs(v[i]-v[i-1]) - labs(v[i]-v[i+1]) + labs(v[i-1]-v[i+1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 2048
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



//メイン関数
int main()
{
	string s, t;
	cin >> s >> t;
	int ssiz = s.size();
	int tsiz = t.size();
	vector<vector<int>> dp(ssiz + 1, vector<int>(tsiz + 1, 0));

	REP(i, ssiz)REP(j, tsiz)
	{
		dp[i + 1][j + 1] = (s[i] == t[j]
			? max(dp[i][j] + 1, max(dp[i + 1][j], dp[i][j + 1]))
			: max(dp[i + 1][j], dp[i][j + 1]));
	}
	/*
	cout << dp[ssiz][tsiz] << endl;
	REP(i, ssiz)
	{
		REP(j, tsiz)
		{
			cerr << dp[i][j] << " ";
		}
		cerr << endl;
	}
	*/
	string res;
	int h = ssiz;
	int w = tsiz;
	while(h > 0 && w > 0)
	{
		if(s[h - 1] == t[w - 1])
		{
			if(dp[h][w] == dp[h - 1][w - 1] + 1)
			{
				res += s[h - 1];
				h--;
				w--;
				continue;
			}
		}
		if(dp[h][w] == dp[h - 1][w])h--;
		else w--;
	}
	reverse(res.begin(),res.end());
	cout << res <<endl;
	cin >> s;


	return 0;
}


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

#define int int64_t

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

    int x; cin >> x;
    int n = 0;
    while(x >= 5){
        if(x >= 500){
            x -= 500;
            n += 1000;
        }
        else{
            x-=5;
            n += 5;
        }
    }
    cout << n << "\n";
    
}

Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    string s;
    cin >> s;

    int ans = 0;
    if (s[0] == 'R') {
        ans++;
        if (s[1] == 'R') {
            ans++;
            if (s[2] == 'R') {
                ans++;
            }
        }
    } else {
        if (s[1] == 'R') {
            ans++;
            if (s[2] == 'R') {
                ans++;
            }
        } else {
            if (s[2] == 'R') {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
//by tzupengwang™
#include<algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n ;
ll e , t ;
ll s[ 100005 ] ;

void init() {
  scanf( "%d%lld%lld" , &n , &e , &t ) ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    scanf( "%lld" , &s[ i ] ) ;
  }
  s[ 0 ] = 0 , s[ n + 1 ] = e ;
}

ll dp[ 100005 ] ;
ll dp1[ 100005 ] ;

void process() {
  ll mn = 0 ;
  int pt = 0 ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    while ( ( s[ i ] - s[ pt + 1 ] ) * 2 > t ) {
      mn = min( ( -2 * s[ pt + 1 ] ) + dp[ pt ] , mn ) ;
      pt ++ ;
    }
    ll tmn = 100000000000000000LL ;
    if ( pt > 0 ) {
      tmn = min( tmn , 2 * s[ i ] + mn ) ;
    }
    tmn = min( tmn , dp[ pt ] + t ) ;
    dp[ i ] = tmn ;
  }
  printf( "%lld\n" , dp[ n ] + e ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

class Plogram
{
    static void Main()
    {
        var n = Console.ReadLine().Split();
        int N = int.Parse(n[0]);
        int M = int.Parse(n[1]);

        var array = new int[N][];
        int count = 0;

        for(int i = 0; i < N; i++)
        {
            array[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }

        for(int i = 1; i <= M; i++)
        {
            for(int j = 0; j < N; j++)
            {
                if (array[j].Skip(1).Any(x => x == i) == false)
                {
                    break;
                }
                if(j == N - 1)
                {
                    count++;
                }
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13524
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long ans = 1;
for(int i = 1;i <= n;i++){
  ans *= i;
  ans = ans % (1000000000+ 7);
}

System.out.println(ans);

}
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> A(n,0),B(n,0);
  rep(i,n){
    cin>>A.at(i);
    B.at(i)=A.at(i);
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int MAX=B.at(0);
  if(B.at(0)!=B.at(1)){
    rep(i,n) (A.at(i)==MAX) ?cout<<B.at(1)<<endl :cout<<MAX<<endl;
  }else rep(i,n)cout<<MAX<<endl;
}

Measured memory_bytes: 3200