akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n, W, v; ll memo,w;
	int i,j,k;
	cin >> n >> W;
	ll a[100]; int val[100];
	for (i = 0; i < n; i++) {
		cin >> w >> v;
		if (i == 0)memo = w;
		a[i] = w - memo; val[i] = v;
	}
	if (memo > 300) {
		int dp[101][301];
		for (i = 0; i < 101; i++) {
			for (j = 0; j < 301; j++) {
				dp[i][j] = -1;
			}
		}
		dp[0][0] = 0; int ma = 0;
		for (i = 0; i < n; i++) {
			for (j = 100; j >= 0; j--) {
				for (k = 300; k >= 0; k--) {
					if (j + 1 <= 100 && k + a[i] <= 300 && memo*(j+1) + k+a[i] <= W && dp[j][k] >= 0) {
						dp[j + 1][k + a[i]] = max(dp[j + 1][k + a[i]], dp[j][k] + val[i]);
						ma = max(ma, dp[j + 1][k + a[i]]);
					}
				}
			}
		}
		cout << ma << endl;
	}
	else {
		int dp[30301]; for (i = 0; i < 30301; i++)dp[i] = -1;
		dp[0] = 0; int ma = 0;
		for (i = 0; i < n; i++) {
			for (j = 30300; j >= 0; j--) {
				if (j + a[i] + memo <= 30300&&dp[j]>=0&&j+a[i]+memo<=W) {
					dp[j + a[i] + memo] = max(dp[j + a[i] + memo], dp[j] + val[i]);
					ma = max(ma, dp[j + a[i] + memo]);
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e18
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    ll ans = INF,_max = 0, _tmp_ans=0, tmp;
    vector<int> a(n), b(n);
    REP(i,n) cin >> a.at(i);
    b = a;
    for(int bit=0; bit < (1<<n); bit++){
        if(__builtin_popcount(bit)>= k){
            a = b;
            _tmp_ans = 0;
            REP(i, n){
                if(bit & (1<<i)){
                    vector<int>::iterator iter = max_element(a.begin(),a.end()-(n-i)+1);
                    size_t index = distance(a.begin(), iter);
                    // REP(i,n) cout << a[i] << " ";
                    // cout << endl;
                    // cout << "max:" << a[index] << endl;
                    // cout << "max_count" << count(a.begin(), a.end()-(n-i), a[index]) << endl << endl;
                    if(a[index] > a[i]){
                        tmp = a[index] - a[i] + 1;
                        a[i] += tmp;
                        _tmp_ans += tmp;
                    }
                    else if(a[index] == a[i] and count(a.begin(), a.end()-(n-i)+1, a[index]) >= 2){
                        a[i] += 1;
                        _tmp_ans += 1;
                    }
                }
            }
            // REP(i,n) cout << a[i] << " ";
            // cout << "     " << _tmp_ans;
            // cout << endl;
            ans = min(ans, _tmp_ans);
        }
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 3660
n, k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)
af = [a[i]*f[i] for i in range(n)]

def check(x):
  r = 0
  for i in range(n):
    r += (max(0,(af[i]-x))+f[i]-1)//f[i]
  #print(r, x)
  if r<=k:
    return True
  else:
    return False
ok = 10**12+1
ng = -1
while ok-ng>1:
  mid = (ok + ng)//2
  if check(mid):
    ok = mid
  else:
    ng = mid
print(ok)

Measured memory_bytes: 113616
n = int(input())
spots = list(map(int,input().split()))
spots.append(0)

def get_amount(a,b):
  return abs(a-b)

amount = 0
for i in range(-1,n):
  amount += abs(spots[i]-spots[i+1])
for i in range(n):
  a = spots[i-1]
  b = spots[i]
  c = spots[i+1]
  if a >= b >= c or a <= b <= c:
    print(amount)
  elif a > b and c > b:
    print(amount - (min(a,c)-b)*2)
  else:
    print(amount - (b-max(a,c))*2)

Measured memory_bytes: 14172
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
            if(map.containsKey(a[i]))
                map.put(a[i], map.get(a[i])+1);
            else
                map.put(a[i], 1);
        }
        sc.close();

        if(map.size() == 1 && a[0] == 0){
            System.out.println("Yes");
            return;
        }
        if(N % 3 == 0){
        if(map.size() == 2){
            int count = 0;
            int x = 0;
            for(Integer key: map.keySet()){
                if(key == 0){
                    if(map.get(key) == N/3)
                        count++;
                } else {
                    if(map.get(key) == 2*N/3){
                        if(x == 0){
                            count++;
                        }
                        x++;
                    }
                }
            }
            if(count == 2){
                System.out.println("Yes");
                return;
            }
        }

        if(map.size() == 3){
            int cnt = 0;
            int sum = 0;
            for(Integer key: map.keySet()){
                sum ^= key;
                if(map.get(key) == N/3)
                    cnt++;
            }
            if(cnt == 3 && sum == 0){
                System.out.println("Yes");
                return;
            }
        }
        }

        System.out.println("No");

    }
}

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

ans = 0
active = 0

for i in range(n):
    if active < h[i]:
        ans += h[i] - active
        active += h[i] - active
    elif h[i] < active:
        active -= active - h[i]
#     print(active)
#     print(ans)

# print("-------")
print(ans)


Measured memory_bytes: 2940
N = int(input())
S = input()
count = 0
for i in range(N):
    tmpcount = 0
    tmp1 = list(set(S[:i]))
    tmp2 = list(set(S[i:]))
    for j in range(len(tmp1)):
        if tmp1[j] in tmp2:
            tmpcount += 1
    if tmpcount >= count:
        count = tmpcount
print(count)

Measured memory_bytes: 3060
from collections import defaultdict

N=int(input())
S=[input() for _ in range(N)]
d=defaultdict(int)
maxV=0
for s in S:
    d[s]+=1
    maxV=max(maxV, d[s])
ans=[]
for key, value in d.items():
    if value==maxV:
        ans.append(key)
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 101200
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

const int AMAX = 100000;
ll arr[AMAX + 1];

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

	REP(i,0,N){
		int x,y;
		cin >> x >> y;
		arr[x] += y;
	}
	for(int i = 0; i <= AMAX; i++){
		if(K <= arr[i]){
			cout << i;
			break;
		}
		K -= arr[i];
	}
	return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			ArrayList<Integer> x = new ArrayList<Integer>();
			ArrayList<Integer> y = new ArrayList<Integer>();
			x.add(-1);
			y.add(-1);
			for(int i=0;i<n;i++){
				x.add(sc.nextInt());
				y.add(sc.nextInt());
			}
			
			int m = sc.nextInt();
			int p, q;
			int count = 0;
			for(int i=0;i<m;i++){
				p = sc.nextInt();
				q = sc.nextInt();
				for(int j=count;j<x.size();j++){
					if(x.get(j)<p && y.get(j)<q){
						if(j==x.size()-1 || (x.get(j+1)>p && y.get(j+1)>q)){
							x.add(j+1, p);
							y.add(j+1, q);
							count = j+1;
						}else if(x.get(j+1)<p && y.get(j+1)<q){
							continue;
						}
						break;
					}
				}
			}
			System.out.println(x.size()-1);
		}	
	}	
}

Measured memory_bytes: 23232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main

{	
	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
		int T = fs.nextInt();
		int AC = 0,TLE =0, RE =0, WA = 0 ;
		while(T-- >0)
		{
			char ch = fs.next().charAt(0);
			if(ch == 'A') AC++;
			else if(ch == 'T') TLE++;
			else if(ch == 'R') RE++;
			else WA++;
				
		}
		System.out.println("AC x "+AC+"\nWA x "+WA+"\nTLE x "+TLE+"\nRE x "+RE);
	}


}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	int [] arrayIn(int n) throws IOException
	{
		int  arr[] = new int[n];
		arr[0] = 0;
		for(int i=1; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	

Measured memory_bytes: 48972
#require "pry-byebug"
A,B,M = gets.split.map(&:to_i)
ary_a = gets.split.map(&:to_i)
ary_b = gets.split.map(&:to_i)
ary_dec = []
M.times do |m|
  idx_a, idx_b, dec_total = gets.split.map(&:to_i)
  ary_dec << {a: idx_a, b:idx_b, total: dec_total}
end
min = ary_a.min + ary_b.min
ary_dec.each do |dec|
  a = dec[:a]
  b = dec[:b]
  total = dec[:total]
  tmp = (ary_a[a-1] + ary_b[b-1]) - total
  min = tmp if tmp < min
end
puts min


Measured memory_bytes: 39912
// 6/28 バーチャル参加
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

// mint dp[500010];

int main() {
    // dp[0] = 1;
    // rep(i, N) {
    //     // // Aは左のA以外から選べ得る
    //     // // dp[i + 1] *= (M - i);

    //     // // Bは2パターンある。
    //     // ll b = 0;
    //     // // A[i]をB[0~i-1]のどれかから選んだ場合
    //     // b += (M - 1);
    //     mint now = 0;

    //     // Aを過去のBの中から選んだ場合
    //     now += i * (M - i);

    //     // Aを過去のB以外から選んだ場合
    //     if (M - i * 2 > 0) {
    //         now += (M - i * 2) * (M - i - 1);
    //     }
        
    //     dp[i + 1] = dp[i] * now;

    //     printf("dp[%d] = %d\n", i+1, dp[i+1]);
    // }

    int N, M;
    cin >> N >> M;
    mint ans = 0;
    rep(i, N+1) {
      mint now = comb(N, i);  // 揃う場所が何通りあるか？
      now *= comb.p(M, N);
      now *= comb.p(M-i, N-i);
      if (i&1) now = -now;  // iが奇数の時にtrue。
      ans += now;
    }
    // ans *= comb(M, N);  // N色の選び方
    cout << ans.x << endl;
}

Measured memory_bytes: 18628
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int ns[] = new int[5];
		for(int i=0; i<ns.length; i++){
			ns[i] = scan.nextInt();
		}

		Arrays.sort(ns);

		for(int i = ns.length-1; i >= 0; i--){
			if(i>0){
				System.out.print(ns[i] + " ");
			}else{
				System.out.println(ns[i]);
			}
		}

	}
}

Measured memory_bytes: 17236
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  vector<int> nums;//連続した数の個数
  if(s[0] == '0') nums.push_back(0);//1が0個
  for(int i=0;i<s.size();){
    int j=i;
    while(j<s.size() && s[j] == s[i]) ++j;
    nums.push_back(j-i);
    i = j;
  }
  if(s.back() == '0') nums.push_back(0);//1が0個
  
  // 累積和
  vector<int> sums((int)nums.size() + 1, 0);
  for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];
  
  int res = 0;
  for(int left = 0;left<sums.size();left+=2){
    int right = left + k*2+1;
    if(right >= sums.size()) right = (int)sums.size() - 1;
    res = max(res,sums[right] - sums[left]);
  }
  cout << res << endl;
}

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

int H, W;
int field[110][110];

void display() {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << field[i][j] << " ";
    }
    cout << endl;
  }
}

int main() {
  cin >> H >> W;
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  // 蛇のように塗っていけばOK
  int pos = 0;
  int idx = 0;
  for (int i = 0; i < H; ) {
    if (i & 1) {
      for (int j = pos; j >= 0; j--) {
        field[i][j] = idx + 1;
        a[idx]--;
        pos = j - 1;
        bool flag = false;
        if (a[idx] == 0) {
          idx++;
          flag = true;
        }
        if (j == 0) {
          pos = j;
          i++;
        }
        if (flag) break;
      }
    } else {
      for (int j = pos; j < W; j++) {
        field[i][j] = idx + 1;
        a[idx]--;
        pos = j + 1;
        bool flag = false;
        if (a[idx] == 0) {
          idx++;
          flag = true;
        }
        if (j == W - 1) {
          pos = j;
          i++;
        }
        if (flag) break;
      }
    }
  }

  // 解答
  display();

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string S;
  cin >> S;

  int flag2 = 0;
  FOR(i,'a','z'){
    int flag = 0;
    REP(j,S.size()){
      if(S.at(j) == i&&flag == 1){
        flag2 = 1;
        break;
      }else if(S.at(j) == i){
        flag = 1;
      }
    }
    if(flag2 == 1){
      break;
    }
  }

  if(flag2 == 1){
    cout << "no" << endl;
  }else{
    cout << "yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;cin >> n;
	
	vector<ll> v;
	REP(i,n)
	{
		ll tmp;cin >> tmp;
		v.PB(tmp);
	}
	
	int ans = 0;
	
	while(1)
	{
		REP(i,v.size())
		{
			if(v[i]%2 == 1)
			{
				cout << ans << endl;
				return 0;
			}
			else
			{
				v[i] /= 2;
			}
		}
		ans++;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;


void Main()
{
	std::string str;
	std::cin >> str;
	std::map<char, int> count;
	for (auto c : str)
	{
		++count[c];
	}
	if (std::all_of(count.begin(), count.end(), [](auto&& p)
		{
			return p.second == 2;
		}))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}

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

Measured memory_bytes: 256
N = int(input())
T = ("3","5","7")

from collections import deque
que = deque(list(T))

ans = 0
while que:
  num = que.popleft()
  if int(num) > N:
    continue
  if len(set(num)) == 3:
    ans += 1
  for t in T:
    que.append(num + t)

print(ans)

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

int main() {
	int n; cin >> n;
	vector<int>	a(n + 1), b(n);
	for (auto&& x : a)cin >> x;
	for (auto&& x : b)cin >> x;

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += min(a[i]+a[i+1], b[i]);
		int minus = min(a[i], b[i]);
		a[i] -= minus, b[i] -= minus;
		a[i + 1] -= min(a[i + 1], b[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 10000

int main(void){
    int n,a[MAX];
    int i;
    int max,min;
    long int sum;
    scanf("%d",&n);
    if(n<=0||10000<n){
        return 0;
    }
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        if(a[i]<-1000000||1000000<a[i]){
            return 0;
        }
    }
    min=max=sum=a[0];
    
    for(i=1;i<n;i++){
        if(a[i]<min){
            min=a[i];
        }
        if(a[i]>max){
            max=a[i];
        }
        sum+=a[i];
    }
    
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N+1);
  int i;
  int c = 1;
  int m = 0; //count
  //  cin >> N;
  for(i=1;i<=N;i++){
    cin >> d.at(i);
    cin.ignore();
  }
  for(i=1;i<=N;i++){
    c = d.at(c);
    m++;
    if(c == 2){
      cout << m;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
    

vector<ll> dp[100010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;

    vector<ll> d;
    for(int i=1; i*i<=m; i++){
        if(m%i == 0){
            d.push_back(i);
            if(i*i != m){
                d.push_back(m/i);
            }
        }
    }

    sort(d.begin(), d.end(), greater<ll>());

    //vdebug(d);

    int res;
    for(auto dd : d){
        if(dd*n <= m){
            res = dd;
            break;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	set<int> st;
	bool varied = true;
	for (int i = 0; i < (int)s.size(); i++) varied &= st.emplace(s[i]).second;

	if (varied) cout << "yes" << "\n";
	else cout << "no" << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys

import numpy as np


def main(n,k,p,c):
    ans = -10**9
    for i in range(n):
        x = i
        t = k
        count = 0
        l = True
        sub = 0
        ln = 0
        while True:
            x = p[x] - 1
            if l:
                count += c[x]
                ln += 1
                if x == i:
                    if t > ln:
                        if count > 0:
                            sub += (t // ln - 1) * count
                            t %= ln
                            t += ln
                        else:
                            t = 0
                    l = False
            sub += c[x]
            t -= 1
            ans = max(sub, ans)
            if t < 1:
                break
    return ans


# >>> numba compile >>>
if sys.argv[-1]=='ONLINE_JUDGE':
  from numba.pycc import CC
  cc=CC('my_module')
  cc.export('main','i8(i8,i8,i8[:],i8[:])')(main)
  cc.compile()
  exit()
from my_module import main
# <<< numba compile <<<
(n, k), p, c = [np.int_(i.split()) for i in open(0)]
print(main(n,k,p,c))


Measured memory_bytes: 28024
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll n;

    std::array<ll, 10000> f = {};
    std::cin >> n;
    for (ll x = 1; x <= 100; ++x) {
        for (ll y = 1; y <= 100; ++y) {
            for (ll z = 1; z <= 100; ++z) {
                ll temp = ((x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z)) / 2.0;
                if (temp <= 10000) {
                    ++f[temp - 1];
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        std::cout << f[i] << std::endl;
    }
}

Measured memory_bytes: 3672
N = int(input())

res = 2 * 32


def g(a):
    if a < 10:
        return a
    return a % 10 + g(a // 10)


def f(a, b):
    return g(a) + g(b)


for a in range(1, N):
    b = N - a
    res = min(res, f(a, b))

print(res)

# N, D1, D2 = [int(a) for a in input().split()]
# import math
#
# table = [
#     [False for _ in range(N * 2)]
#     for _ in range(N * 2)
# ]
#
# xd1 = [
#     (x, D1 - (x * x)) for x in range(int(math.ceil(math.sqrt(D1))) + 1)
# ]
# xd1_ = [(x, y, int(math.sqrt(y))) for x, y in xd1 if y >= 0]
# xd1 = [(x, yy) for x, y, yy in xd1_ if y == yy * yy]
#
# xd2 = [
#     (x, D2 - (x * x)) for x in range(int(math.ceil(math.sqrt(D2))) + 1)
# ]
# xd2_ = [(x, y, int(math.sqrt(y))) for x, y in xd2 if y >= 0]
# xd2 = [(x, yy) for x, y, yy in xd2_ if y == yy * yy]
#
#
# def check(x, y):
#     return 0 <= x < 2 * N and 0 <= y < 2 * N
#
#
# def solve(skip):
#     res = []
#
#     for i in range(N * 2):
#         for j in range(N * 2):
#             if skip != 0:
#                 skip -= 1
#                 continue
#             if table[i][j]:
#                 continue
#
#             res.append((i, j))
#             if len(res) == N * N:
#                 return res
#
#             for x, y in xd1:
#                 p, q = x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#             for x, y in xd2:
#                 p, q = x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#                 p, q = -x + i, -y + j
#                 if check(p, q):
#                     table[p][q] = True
#     return None
#
#
# for s in range(N * N):
#     res = solve(s)
#     if res is None:
#         continue
#     for x, y in res:
#         print(x, y)
#     break


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

int main() {
    int n, k;

    cin >> n >> k;

    int p[n];
    for (int i = 1; i <= n; i++) {
        int a = i;
        int b = 1;
        while (a < k) {
            a *= 2;
            b *= 2;
        }
        p[i - 1] = b;
    }

    sort(p, p + n, greater<int>());

    double a = 0.0;
    int b = p[0];

    for (int i = 0; i < n; i++) {
        a += (p[0] / p[i]);
    }

    cout << fixed << setprecision(12) << a / p[0] / n << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int a[3];

int main()
{
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

    int res = 0;
    res += a[2] - a[1];
    a[0] += a[2] - a[1];
    a[1] = a[2];

    if((a[2] - a[0]) % 2 == 0) res += (a[2] - a[0]) / 2;
    else res += (a[2] - a[0] + 1) / 2 + 1;

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


Measured memory_bytes: 256
#import <stdio.h>
int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    for(int i=0;i<=w+1;i++){
        printf("#");
    }
    printf("\n");
    for(int i=0;i<h;i++){
        char s[105] = {'\0'};
        scanf("%s",s);
        printf("#%s#\n",s);
    }
    for(int i=0;i<=w+1;i++){
        printf("#");
    }
    printf("\n");
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;
int a[200100];
vector<int> v;

int main(){
	cin>>n>>k;
	REP(i,n){
		cin>>a[i];
	}
	
	sort(a,a+n);
	int ss=0;
	for(int i=1;i<n;i++){
		if(a[i-1]!=a[i]){
			v.push_back(i-ss);
			ss=i;
			//cout<<ss<<endl;
		}
	}
	v.push_back(n-ss);
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<(int)v.size()-k;i++){
		ans+=v[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2168
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 100005;
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll mini = MOD;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        if(x<mini)   
        {
            mini = x;
            ans++;
        }
    }
    cout<<ans;
}

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

typedef long long ll;

unordered_map<ll, ll> prime_factrize(ll x){
    unordered_map<ll, ll> primes;
    if (x % 2 == 0){
        primes[2] = 0;
        while (x % 2 == 0){
            primes[2] += 1;
            x /= 2;
        }
    }
    ll f = 3;
    while (f * f <= x){
        if (x % f == 0){
            x /= f;
            primes[f] += 1;
        }
        else{
            f += 2;
        }
    }
    if (x > 1){
        primes[x] += 1;
    }
    return primes;
}

unordered_map<ll, ll> lcm_prime(unordered_map<ll, ll>& a, unordered_map<ll, ll>& b){
    unordered_map<ll, ll> c(a);
    for (auto b_iter=b.begin(); b_iter!=b.end(); b_iter++){
        auto a_iter = a.find(b_iter->first);
        if (a_iter != a.end()) c[b_iter->first] = max(a_iter->second, b_iter->second);
        else c[b_iter->first] = b_iter->second;
    }
    return c;
}

unordered_map<ll, ll> divide_prime_facts(unordered_map<ll, ll> a, unordered_map<ll, ll> b){
    for (auto b_iter=b.begin(); b_iter!=b.end(); b_iter++){
        auto a_iter = a.find(b_iter->first);
        if (a_iter != a.end()) a_iter->second = a_iter->second - b_iter->second;
    }
    return a;
}

ll modpow(ll a, ll b, ll mod){
    ll res = 1;
    while (b > 0){
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod){
    return modpow(a, mod - 2, mod);
}

void disp_unordered_map(unordered_map<ll, ll> x){
    for (auto iter = x.begin(); iter != x.end(); iter++){
        cout << iter->first << ": " << iter->second << " ";
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    int x;
    unordered_map<ll, ll> L;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        unordered_map<ll, ll> p = prime_factrize(a[i]);
        for (auto iter = p.begin(); iter != p.end(); iter++){
            auto L_iter = L.find(iter->first);
            if (L_iter == L.end()){
                L[iter->first] = iter->second;
            }
            else{
                L_iter->second = max(L_iter->second, iter->second);
            }
        }
    }

    ll MOD = 1000000007;
    ll l = 1;
    for (auto iter = L.begin(); iter != L.end(); iter++){
        l *= modpow(iter->first, iter->second, MOD);
        l %= MOD;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += l * modinv(a[i], MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求める
#冪乗を求める関数を求める
#2のn乗をmで割ったあまりを求める
def pow(a,n,m):
  if n==0:
    return 1
  else:
    k=pow(a*a%m,n//2,m)
    if n%2==1:
      k=k*a%m
    return k
#次は組み合わせを計算する
#まずは前処理をする
inv=[0 for i in range(200001)]
finv=[0 for i in range(200001)]
inv[1]=1
finv[1]=1
for i in range(2,200001):
  #逆元の求め方p=(p//a)*a+p%a a^(-1)=-(p//a)*(p%a)^(-1)
  inv[i]=(-(1000000007//i)*inv[1000000007%i])%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007

#nが10^7程度であればnCk=n!*(k!)*((n-k)!)を求めればいい
#nがそれより大きい時は間に合わない。ここでkが小さいことに着目すると
#nCk=n*(n-1).....*(n-k+1)*(k!)^(-1)で求められることがわかる
a_num=1
b_num=1
for i in range(n-a+1,n+1):
  a_num=i*a_num%1000000007
for i in range(n-b+1,n+1):
  b_num=i*b_num%1000000007
print((pow(2,n,1000000007)-1-a_num*finv[a]-b_num*finv[b])%1000000007)

  













Measured memory_bytes: 24784
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    int A[3];
    cin >> N >> A[0] >>A[1] >>A[2];
    int l[N];
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }
    ll minCost = 1ll << 60;
    for(int p = 0; p < pow(4,N); p++){
        int tmpP = p;
        int currentId = 0;
        int id[N];
        for(int i = 0; i < N; i++){
            id[i] = -1;
        }
        while (currentId < N){
            int tmp = tmpP % 4;
            tmpP = (tmpP - tmp ) / 4;
            id[currentId] = tmp;
            currentId++;
        }

        int sum[3];
        ll currentCost = 0;
        for(int i = 0; i < 3; i++){
            sum[i] = 0;
        }
        for(int i = 0; i < N; i++){
            if(id[i] == 3){
                continue;
            }
            if(sum[id[i]] > 0){
                sum[id[i]] += l[i];
                currentCost += 10;
            }else{
                sum[id[i]] += l[i];
            }
        }
        for(int i = 0; i < 3; i++){
            currentCost += abs(sum[i] - A[i]);
        }
        if(sum[0] == 0 || sum[1] == 0 || sum[2] == 0){
            continue;
        }
        minCost = min(minCost,currentCost);
    }
    cout << minCost << endl;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n-1):
         p[i+1] += p[i]
maxsum = 0
if n == k:
    print((p[n-1]+k)/2)
    exit()
for i in range(n-k):
         maxsum = max(maxsum,p[i+k]-p[i])
print((maxsum+k)/2)

Measured memory_bytes: 25060
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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



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

int main() {
    
    ll A, B;
    cin >> A >> B;
    
     if(A < B){
       ll tmp = A;
       A = B;
       B = tmp;
     }
    
     ll r = A % B;
     while(r != 0){
       A = B;
       B = r;
       r = A % B;
     }
    ll g = B;
    std::set<ll> sns;
    sns.insert(1);
    ll y = 2;
    while (g >= y * y) {
        if (g % y == 0) {
            sns.insert(y);
            g /= y;
        } else {
            y++;
        }
    }
    sns.insert(g);
    cout << sns.size() << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1e12;

struct Edge {
  int from, to, cost;
  Edge(int from, int to, int cost): from(from), to(to), cost(cost) {}
};

int N, M;
vector<Edge> es;
vector<ll> p;

void bellmanFord(int s) {
  p.at(s) = 0;
  rep(i, N * 2) {
    rep(j, M) {
      Edge e = es.at(j);
      if (p.at(e.from) != INF && p.at(e.to) > p.at(e.from) + e.cost) {
        if (i < N - 1) {
          p.at(e.to) = p.at(e.from) + e.cost;
        } else {
          p.at(e.to) = -INF; // ループしているところには -INF をいれる
        }
      }
    }
  }
}

int main() {
  int P;
  cin >> N >> M >> P;
  p.resize(N, INF);

  rep(i, M) {
    int A, B, C;
    cin >> A >> B >> C;
    A--; B--;
    C = -(C - P);

    es.emplace_back(A, B, C);
  }

  bellmanFord(0);

  if (p.at(N - 1) == -INF) {
    cout << "-1" << endl;
  } else {
    cout << max(0ll, -p.at(N - 1)) << endl;
  }
  return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 7;

int a[MAX], b[MAX], c[MAX], d[MAX];
vector<int> g[MAX];
int mt[MAX];
bool used[MAX];

bool kuhn(int v)
{
	if(used[v])
		return false;
	used[v] = true;
	for(int to: g[v])
		if(mt[to] == -1)
		{
			mt[to] = v;
			return true;
		}
	for(int to: g[v])
		if(kuhn(mt[to]))
		{
			mt[to] = v;
			return true;
		}
	return false;
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> a[i] >> b[i];
	FOR(i, 0, n)
		cin >> c[i] >> d[i];
	FOR(i, 0, n)
		FOR(j, 0, n)
			if(a[i] < c[j] && b[i] < d[j])
				g[i].PB(j);
	FILL(mt, -1);
	int ans = 0;
	FOR(i, 0, n)
	{
		FILL(used, 0);
		ans += kuhn(i);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

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

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
string s;
int main()
{
    int n;
    cin >> n;
    cin >> s;
    int l = 0, r = n-1;
    int ans = 0;
    while (l <= r)
    {
      
      while (l < n && s[l] == 'R') ++l;
      while (r >= 0 && s[r] == 'W') --r;
      if (l>r) break;
      if (l == r){
        if (s[l] == 'R') l++;
        else r--;
        break;
      }
      //debug(l,r,ans);

      if (l == n) break;
      if (r == -1) break;
      ans++;
      s[l]='R';
      s[r]='W';
      l++;--r;
    }
    //debug(l,r);
    for (int i = l; i < n; ++i)
      if (s[i] == 'R') ans++;
    for (int i = r; i >= 0; --i)
      if (s[i] == 'w') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>
int main(void) {
int i,j,d[10];
for(i=0;i<10;i++) scanf("%d",&d[i]);
for(i=0;i<9;i++) for(j=i+1;j<10;j++)
	if(d[i]<d[j]) d[i]+=d[j],d[j]=d[i]-d[j],d[i]-=d[j];
printf("%d\n%d\n%d\n",d[0],d[1],d[2]);
return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    li n, k;
    cin >> n >> k;

    vector<li> hs(n);
    for (int i = 0; i < n; ++i) {
        cin >> hs[i];
    }

    vector<li> dp(n, 1LL << 50);
    dp[0] = 0;
    for (int to = 1; to < n; ++to) {
        for (int d = 1; d <= k; ++d) {
            li fr = to - d;
            if (fr < 0) {
                continue;
            }
            dp[to] = min(dp[to], dp[fr] + abs(hs[fr] - hs[to]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S;
        cin >> S;
        string ans = S.substr(0, 3);
        cout << ans << endl;
}


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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> H(N);
    priority_queue<int> memo;
    
    
    for(int i=0; i<N; i++) cin >> H.at(i);
    
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(i==N-1) {
            memo.push(cnt);
            break;
        }
        
        if(H.at(i+1) <= H.at(i)) cnt++;
        else{
            memo.push(cnt);
            cnt = 0;
        }
    }
    cout << memo.top();
}
        

Measured memory_bytes: 1276
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    prev = -1
    ans = 0
    for i in range(N):
        ans += B[A[i]-1]
        if A[i]==prev+1:
            ans+=C[prev-1]
        prev=A[i]
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21596
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P = sc.nextInt();
		int even = 0;
		int odd = 0;
		for(int i=0; i<N; i++) {
			if(sc.nextInt()%2==0)
				even++;
			else
				odd++;
		}
		long ans = 1;
		ans <<=  even;
		if(odd==0) {
			if(P==1)
				ans = 0;
		} else {
			ans <<= odd-1;
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
N,M = map(int,input().split())
H = list(map(int,input().split()))

bridge = [[] for i in range(N+1)]

for i in range(M):
    A,B = map(int,input().split())
    bridge[A].append(B)
    bridge[B].append(A)

ans = 0
count = 0

for i in range(1,N+1):
    tmp = bridge[i]
    tmp = list(set(tmp))
    flag = True
    for j in range(len(tmp)):
        if H[i-1] <= H[tmp[j]-1]:
            flag = False
    if flag == False and len(bridge[i]) != 0:
        continue
    elif flag == True and len(bridge[i]) != 0:
        ans += 1
            
    if len(bridge[i]) == 0:
        ans +=1
        
print(ans)

Measured memory_bytes: 32104
#include <stdio.h>

int main(){
    double a, b;
    
    scanf("%lf %lf", &a, &b);
    int int_a,int_b;
    int_a = a; int_b = b;
    printf("%d %d %f\n", int_a/int_b, int_a%int_b, a/b);
}



Measured memory_bytes: 2044
import sys
import datetime
def input(): return sys.stdin.readline().rstrip()

def main():
    Y, M, D = map(int, input().split('/'))
    if datetime.date(Y, M, D) <= datetime.date(2019, 4, 30):
        print('Heisei')
    else:
        print('TBD')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3312
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const int maxn=10005;

struct point
{
    double x,y;
    void input()
    {
        scanf("%lf%lf",&x,&y);
    }
}f[maxn];

struct node
{
    int u,v;
    double len;
}s[maxn*3];

int set[maxn];
int n,m;

inline double dis(const point &a,const point &b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

bool operator <(const node &a,const node &b)
{
    return a.len>b.len;
}

inline int find(const int &x)
{
    if(x==set[x])return x;
    else return set[x]=find(set[x]);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        f[i].input();
        set[i]=i;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&s[i].u,&s[i].v);
        s[i].len=dis(f[s[i].u],f[s[i].v]);
    }
    sort(s,s+m);
    double ans=0;
    for(int i=0;i<m;i++)
        if(find(s[i].u)!=find(s[i].v))set[find(s[i].u)]=find(s[i].v);
        else ans+=s[i].len;
    printf("%.3f\n",ans);
    return 0;
}

Measured memory_bytes: 1752
# -*- coding: utf-8 -*-
n = int(input())
ln = list(map(int, input().replace('W', '0 ').replace('E', '1 ').split()))

# 先頭だけ先に計算（do-while相当）
w_sum = 0                           # 西側で振り返る人
sum_min = e_sum = sum(ln) - ln[0]   # 東側で振り返る人

for i in range(1, n-1):
    #sum_min = min(sum_min, sum(ln[i+1:n]) + (i - sum(ln[0:i])))
    w_sum += 1 if ln[i-1] == 0 else 0
    e_sum -= ln[i]
    sum_min = min(sum_min, w_sum + e_sum)

# 末尾も個別に計算
else:
    w_sum += 1 if ln[n-1] == 0 else 0
    sum_min = min(sum_min, w_sum)


print(sum_min)


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

long long MAX = 100000000000000;

int main()
{
    long long n,h,p;
    cin>>n;

    vector<pair<long long, long long> > X;

    for(int i=0; i<n; i++)
    {
        cin>>h>>p;
        X.push_back(make_pair(h+p,p));
    }

    sort(X.begin(),X.end());
    for(int i=0; i<n; i++)
        X[i].first = X[i].first-X[i].second;

    long long dp[n+1][n+1];
    for(int i=0; i<n+1; i++)
    {
        for(int j=0; j<n+1; j++)
        {
            dp[i][j] = MAX;
        }
    }
    dp[0][0] = 0;



    for(int i=1; i<n+1; i++)
    {
        dp[0][i] = 0;
        for(int j=1; j<n+1; j++)
        {
            dp[j][i] = min(dp[j][i],dp[j][i-1]);
            if(dp[j-1][i-1]<=X[i-1].first)
            {
                dp[j][i] = min(dp[j][i],dp[j-1][i-1]+X[i-1].second);
            }
        }
    }

    long long ans = 0;
    for(int i=1; i<n+1; i++)
    {
        if(dp[i][n]<MAX)
            ans = i;
    }
    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 195968