akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

string s,t;
int n,m;

string restore(int start){
    string ret;
    rep(i,start){
        if(s[i]=='?') ret.PB('a');
        else ret.PB(s[i]);
    }
    rep(i,m){
        ret.PB(t[i]);
    }
    FOR(i,start+m,n){
        if(s[i]=='?') ret.PB('a');
        else ret.PB(s[i]);
    }
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    cin >> s >>t;
    n=SZ(s),m=SZ(t);
    vstr res;
    if(n<m){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=0; i+m<=n; i++){
        bool can=true;
        rep(j,m){
            if(s[i+j]!=t[j] && s[i+j]!='?') {
                can=false;
                break;
            }
        }
        if(can){
            res.PB(restore(i));
        }
        // if(can){
        //     rep(j,m){
        //         s[i+j]=t[j];
        //     }
        //     rep(j,n){
        //         if(s[j]=='?') cout<<'a';
        //         else cout<<s[j];
        //     }
        //     cout<<endl;
        //     return 0;
        // }
    }
    if(res.size()>0){
        sort(all(res));
        cout<<res[0]<<endl;
    }
    else cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 3648
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    prev = -1
    ans = 0
    for a in A:
        ans += B[a-1]
        if prev == a-1:
            ans += C[a-2]
        prev = a
    print(ans)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61220
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;

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

	vec v(N);

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

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

	double ans = v[0];

	for(int i=1;i<N;++i)
	{
		ans += v[i];
		ans /= 2;
	}
	
	printf("%.10f\n", ans);

	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
 
def num_counter(s):
    form = []
    idx = 0
    visited = {}
    
    for ss in s:
        if ss not in visited:
            visited[ss] = idx
            idx += 1
        form.append(visited[ss])
    
    return form
    
S_form = num_counter(S)
T_form = num_counter(T)

if S_form == T_form:
    print('Yes')
else:
    print('No')

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

abc = [(0, 0, 0)]
for i in range(N):
    a, b, c = [int(x) for x in input().split()]
    abc.append((a, b, c))

dp = [[0, 0, 0] for _ in range(N + 1)]

for i in range(1, N + 1):
    dp[i][0] = abc[i][0] + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = abc[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = abc[i][2] + max(dp[i - 1][0], dp[i - 1][1])

print(max(dp[N][0], dp[N][1], dp[N][2]))



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
#解法2
w = input()
ls = [0]*26
#各文字の出現回数リスト
for i in range(len(w)):
  ls[ord(w[i])-97] += 1
  #ASCIIコードに対応した配列を+1する
flag = 0
for i in range(len(ls)):
  if ls[i]%2 == 0:
    continue
  else:
    flag += 1
    break
if flag == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
n =  int(input())
a,b,c,d = 0,0,0,0
for _ in [0]*n:
  s = input()
  if s[0] == "B" and  s[-1] == "A":
    d += 1
  elif s[0] == "B":
    b += 1
  elif s[-1] == "A":
    a += 1
  for i in range(len(s)-1):
    if s[i:i+2] == "AB":
      c += 1
if a == 0 and b == 0:
  c += max(d-1,0)
else:
   c += d + min(a,b)
print(c)

Measured memory_bytes: 3064
//Vivek Shah
#include <bits/stdc++.h>
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define llt int test;cin>>test;while(test--)
#define pb push_back
#define setto(n) cout << fixed<< setprecision(n)
#define fi first
#define se second
#define sz(i) int(i.size())
#define all(v) v.begin(),v.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) s.length()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define INF LONG_MAX
#define LOW LONG_MIN

using namespace std; 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
#define MAX 100010

int a, b, c;
int main(){
	boost;
	cin>>a>>b>>c;
	if(a+b>=c){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	int n = s.size();
	int firstA = n, endZ = 0;
	rep(i, 0, n) {
		if (s[i] == 'A') {
			firstA = min(firstA, i);
		}
		if (s[i] == 'Z') {
			endZ = max(endZ, i);
		}
	}

	cout << endZ - firstA + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int X;
void input(){
    fast_io();
    cin >> X;
}

int solve(){
    for (int k = 1; k < 3600; k++)
    {
        if(k*X%360==0) {cout << k << endl; return 0;}
    }
    
    return 0;
}   

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

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

using namespace std;

template< typename T>
struct edge { 
   int from, to; 
   T cost; 
   edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< typename T>
using EDGE = vector< edge< T > >;

template< typename T>
vector< T > bellman_ford(EDGE< T > &es, int V, int s) {
   const auto INF = numeric_limits< T >::max();
   vector< T > dist(V, INF);
   dist[s] = 0;
   for (int i = 0; i < V - 1; i++) {
      for (auto &e : es) {
         if (dist[e.from] == INF) continue;
         dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
   }
   for (auto & e : es) {
      if (dist[e.from] == INF) continue;
      if (dist[e.from] + e.cost < dist[e.to]) return vector< T >();
   }
   return dist;
}

const int MAXN = 2501;
bool used1[MAXN];
bool used2[MAXN];
vector<int> G1[MAXN], G2[MAXN];

void bfs1(int s) {
   used1[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G1[cur]) {
         if (used1[g]) continue;
         used1[g] = true;
         q.push(g);
      }
   }
}

void bfs2(int s) {
   used2[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G2[cur]) {
         if (used2[g]) continue;
         used2[g] = true;
         q.push(g);
      }
   }
}

int main() {
   int N, M, P;
   cin >> N >> M >> P;
   int A[M], B[M], C[M];
   for (int i = 0; i < M; i++) {
      cin >> A[i] >> B[i] >> C[i];
      A[i]--;
      B[i]--;
      C[i] = -1 * (C[i] - P);
      G1[A[i]].push_back(B[i]);
      G2[B[i]].push_back(A[i]);
   }
   memset(used1, false, sizeof(used1)); 
   memset(used2, false, sizeof(used2)); 

   bfs1(0);
   bfs2(N - 1);
   
   EDGE< int > edges;
   
   for (int i = 0; i < M; i++) {
      if (!used1[A[i]]) continue;
      if (!used1[B[i]]) continue;
      if (!used2[A[i]]) continue;
      if (!used2[B[i]]) continue;
      edges.emplace_back(A[i], B[i], C[i]);
   }
   
   auto res = bellman_ford(edges, N, 0);
   if (res.empty()) cout << "-1" << endl;
   else cout << max(0, -1 * res[N - 1]) << endl;
   return 0;
}


Measured memory_bytes: 768
import numpy as np

H, N = map(int,input().split())

A = np.zeros(N, dtype = int)
B = np.zeros(N, dtype = int)

for i in range(N):
    A[i],B[i] = map(int,input().split())
    
dp = np.full(H+1, np.inf)

dp[0] = 0
for i in range(1,H+1):
    dp[i] = np.amin( dp[np.maximum(i-A,0)] + B )

print(int(dp[H]))

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  map<char, ll> mp;
  REP(i, n){
    string s;
    cin >> s;
    mp[s[0]]++;
  }
  string s = "MARCH";
  n = s.size();
  ll ans = 0;
  REP(i, n-2) FOR(j, i+1, n-1) FOR(k, j+1, n){
    ans += mp[s[i]]*mp[s[j]]*mp[s[k]];
  }
  cout << ans << endl;
  return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef vector<pair<int, int>> Testimony;

void getHonesty(Testimony t, vector<int> &h, int honest){
	for(auto itr = t.begin(); itr != t.end(); itr++){
		if(itr->second == honest){
			h.push_back(itr->first);
		}
	}
	sort(h.begin(), h.end());
}

int getBitCount(int b){
	int ret = 0, v = b;
	while(v > 0){
		if((v % 2) == 1){
			ret++;
		}
		v /= 2;
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<Testimony> VT;
	for(int i=1; i<=N; i++){
		int k;
		cin >> k;
		Testimony t;
		for(int j=1;  j<=k; j++){
			int x, y;
			cin >> x >> y;
			t.push_back({x, y});
		}
		sort(t.begin(), t.end());
		VT.push_back(t);
	}

	int ans = 0;
	for(int b = 0; b < (1<<N); b++){ //bは選び方に対応
		int conflict = 0;
		for(int i=0; i<N; i++){
			if(b & (1<<i)){ //正直者と仮定した人の証言を確認する
				Testimony t = VT[i];
				vector<int> u;
				getHonesty(t, u, 1); //uにはiさんが正直者だと証言した人の番号が入る。
				for(int j=0; j<u.size(); j++){
					if( b & (1 << (u[j]-1)) ){
						//not conflict.
					}
					else{
						conflict = 1;
						break;
					}
				}
				vector<int> v;
				getHonesty(t, v, 0); //vにはiさんが不親切だと証言した人の番号が入る。
				for(int j=0; j<v.size(); j++){
					if( b & (1 << (v[j]-1)) ){
						conflict = 1;
						break;
					}
					else{
						//not conflict.
					}
				}
			}
		}
		if(conflict == 0){
			ans = max(ans, getBitCount(b));
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while ((scan.hasNext())) {
			Path2D.Double tri = new Path2D.Double();
			tri.moveTo(scan.nextDouble(), scan.nextDouble());
			tri.lineTo(scan.nextDouble(), scan.nextDouble());
			tri.lineTo(scan.nextDouble(), scan.nextDouble());

			Point2D.Double pt = new Point2D.Double(scan.nextDouble(), scan.nextDouble());

			if(tri.contains(pt)){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}

		}
	}
}

Measured memory_bytes: 12000
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    char s;
    cin >> s;
    if (s <= 'z' && s >= 'a') cout << 'a';
    else cout << 'A';
    return 0;
}




Measured memory_bytes: 3608
#include<iostream>
using namespace std;
bool a[1000000010];
int main(){
	for(int i=1;i<=1000000000;i++) a[i]=false;
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(a[x]==false) a[x]=true;
		else{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 976768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  ll sum = 0;

  REP(i, 1, n){
    if(i % 3 == 0) continue;
    if(i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3676
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e3 + 5;
const int M = 1e6 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int h,w,ch,cw,dh,dw,ans,comp[N][N],compSz,vis[N][N],v[M];
vector<int> g[M];
char s[N][N];

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

bool valid(int x, int y) {

    return x >= 1 && x <= h && y >= 1 && y <= w;

}

void dfs(int x, int y) {

    comp[x][y] = compSz;
    vis[x][y] = 1;

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

        int nx = x + dx[i];
        int ny = y + dy[i];

        if(valid(nx, ny) && !vis[nx][ny] && s[nx][ny]=='.') dfs(nx, ny);

    }

}

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> h >> w >> ch >> cw >> dh >> dw;

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

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(!vis[i][j] && s[i][j] == '.') {
                ++compSz;
                dfs(i, j);
            }
        }
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            for (int a = i - 2; a <= i + 2; ++a) {
                for (int b = j - 2 ; b <= j + 2; ++b) {
                    if(valid(a, b) && comp[i][j] != comp[a][b] && s[a][b] == '.') {
                        g[comp[i][j]].pb(comp[a][b]);
                    }
                }
            }
        }
    }

    queue<int> q;
    q.push(comp[ch][cw]);
    v[comp[ch][cw]] = 1;

    while(!q.empty()) {

        int sz = q.size();

        while (sz--) {

            int c = q.front();
            q.pop();

            if(c == comp[dh][dw]) return cout << ans << '\n', 0;

            for(auto i : g[c]) {

                if(!v[i]) {
                    v[i] = 1;
                    q.push(i);
                }

            }

        }

        ++ans;

    }

    cout << "-1\n";

    return 0;
}

Measured memory_bytes: 76140
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>A;
    cout<<N*N - A<<endl;
}

Measured memory_bytes: 256
//final_report
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>
#include<stack>
#include <climits>

#define INF INT_MAX

using namespace std;


int n=0;
int A[30000000];

void initRMQ(int size){
	n=1;
	while(n<=size){
		n*=2;
	}
	for(int i=0;i<2*n-1-1;i++){
		A[i]=INF;
	}
}

void updata(int k,int x){
	k+=n-1;
	A[k]=x;
	while(k>0){
		k=(k-1)/2;
		A[k]=min(A[k*2+1],A[k*2+2]);
	}
}

int query(int x,int y,int k,int l,int n){
	if(n<=x||y<=l){
		return INF;
	}
	if(x<=l&&n<=y){
		return A[k];
	}
	int v1=query(x,y,k*2+1,l,(l+n)/2);
	int v2=query(x,y,k*2+2,(l+n)/2,n);
	return min(v1,v2);
}

int query2(int x,int y){
	return query(x,y,0,0,n);
}

int main(){
	int N,l,a;
	cin>>N>>l;

	initRMQ(N);

	for(int i=0;i<N;i++){
		cin>>a;
		updata(i,a);
	}
	int j=0;
	while(1){
		cout <<query2(j, j+l);
		if(j+l-1==N-1)break;
		cout<<' ';
		j++;
	}
	cout<<endl;

	return 0;

}










Measured memory_bytes: 11300
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む]
		string[] line = Console.ReadLine().Split(' ');
		long A = long.Parse(line[0]);
		long B = long.Parse(line[1]);
		long C = long.Parse(line[2]);
		long K = long.Parse(line[3]);

		long ans = 0;

		if( K <= A){
				ans = K;
		}
		else{
				K -= A;
				ans = A;
				K -= B;
				if(K > 0){
						ans -= K;
				}
		}

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 17912
def calc(N, K, Q, A):
    d = {}
    for a in A:
        d[a] = 1 + (d[a] if a in d else 0)
    ans = [
        'Yes' if K - Q + (d[i + 1] if i + 1 in d else 0) > 0 else 'No'
        for i in range(N)
        ]
    return '\n'.join(ans)


(N, K, Q) = tuple([int(s) for s in input().split(' ')])
A = [int(input()) for _ in range(Q)]
print(calc(N, K, Q, A))

Measured memory_bytes: 11580
#include <stdio.h>
int main() {
	int n[4], sum;
	scanf("%d", &n[0]);
	n[3] = n[0] % 10;
	n[2] = (n[0] % 100 - n[3]) / 10;
	n[1] = (n[0] % 1000 - n[2]) / 100;
	n[0] = (n[0] - n[1]) / 1000;
	for (int i = 0; i < 8; i++) {
		sum = n[0];
		for (int j = 0; j < 3; j++) {
			if (((i >> j) & 1) == 0) {
				sum -= n[j + 1];
			} else {
				sum += n[j + 1];
			}
		}
		if (sum == 7) {
			for (int j = 0; j < 4; j++) {
				printf("%d", n[j]);
				if (j != 3) {
					printf("%c", ((i >> j) & 1) == 0 ? '-' : '+');
				}
			}
			printf("=7\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int A, B, C;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;

  if (A <= C && C <= B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#chr(num)文字
#ord(文字)数値
#ord("A") = 65
n = int(input())
s = input()
r = 65





lst = []
for c in s:
    new_character = chr((ord(c)-65+n)%26+65)
    lst.append(new_character)

print("".join(lst))

Measured memory_bytes: 3060
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll a[N];
    rep(i, N) cin >> a[i];
    for(ll i = 0; i < N; i += 2){
        if(a[i] % 2) ans++;
    }
    pt(ans);
}

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

using namespace std;

#define ll long long


int main() {
    string s;
    cin>>s;
    if(s.size()<2) {
        cout<<"No\n";
        return 0;
    }
    int n=s.size();
    for(int i=0;i<n-1;i++) {
        if(s[i]=='A' && s[i+1]=='C') {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

dp = [[0 for i in range(3)] for j in range(n+1)]


ans = 0
for l in range(k):
    hand = []
    for j in range(l, n, k):
        hand.append(t[j])

    dp = [[0 for i in range(3)] for j in range(len(hand)+1)]

    for i in range(len(hand)):
        if hand[i] == "r":
            dp[i+1][2] = max(dp[i][0], dp[i][1]) + p
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][0] = max(dp[i][1], dp[i][2])

        elif hand[i] == "s":
            dp[i+1][2] = max(dp[i][0], dp[i][1])
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][0] = max(dp[i][1], dp[i][2]) + r
        else:
            dp[i+1][2] = max(dp[i][0], dp[i][1])
            dp[i+1][1] = max(dp[i][0], dp[i][2]) + s
            dp[i+1][0] = max(dp[i][1], dp[i][2])
    ans += max(dp[len(hand)])

print(ans)


Measured memory_bytes: 89564
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    V=[int(_) for _ in input().split()]
    V.sort()
    ss=V[0]
    for i in range(1,n):
        ss=(ss+V[i])/2
    print(ss)

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

class Erathostenes {
private:
    vector<int> primes;
public:
    Erathostenes(int n);
    vector<int> get_prime();
    ~Erathostenes();
};

Erathostenes::Erathostenes(int n) {
    vector<bool> prime_flags(n+10, true);
    prime_flags[0] = prime_flags[1] = false;
    for (int i = 2; i*i <= n; ++i) {
        if (prime_flags[i]) {
            primes.push_back(i);
            for (int j = i; j <= n; j+=i) {
                prime_flags[j] = false;
            }
        }
    }
    for (int i = 0; i <= n; ++i) {
        if (prime_flags[i]) primes.push_back(i);
    }
}

vector<int> Erathostenes::get_prime() {
    return primes;
}

Erathostenes::~Erathostenes() {
}

int main(int argc, char const *argv[]) {
    int x; cin>>x;
    Erathostenes e(114514);
    vector<int> ans(e.get_prime());
    auto itr = lower_bound(ans.begin(), ans.end(), x);
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    A,B = map(int,input().split())
    if A == B:
        return A
    elif A%2 == 0 and B%2 == 0:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^B
        else:
            return 1^B
    elif A%2 == 0 and B%2 == 1:
        tmp = int((B-A+1)/2)
        if tmp%2 == 0:
            return 0
        else:
            return 1
    elif A%2 == 1 and B%2 == 0:
        tmp = int((B-A-1)/2)
        if tmp%2 == 0:
            return 0^B^A
        else:
            return 1^B^A
    elif A%2 == 1 and B%2 == 1:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^A
        else:
            return 1^A

print(main())


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

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

Measured memory_bytes: 3592
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, a;
	set<int> st;
	cin >> n;
	while (n--) {
		cin >> a;
		auto it = st.find(a);
		if (it == st.end()) {
			st.insert(a);
		}
		else {
			st.erase(it);
		}
	}

	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 4992
N = int(input())
S = [0] * N
for i in range(N):
    S[i]= input()

dic = {}
for i in range(N):
    if (S[i] in dic.keys()) == False:
        dic[S[i]] = 1
    else:
        dic[S[i]] = dic[S[i]] + 1

sortdic = sorted(dic.items(), key = lambda x:x[1])

m = sortdic[len(sortdic)-1][1]
ans = []
for i in range(len(sortdic)):
    if sortdic[i][1] == m:
        ans.append(sortdic[i][0])

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 47332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
int main(){
    boost;
    
    int n;
    ll t;
    cin>>n>>t;

    ll sum=0;
    ll cur=-1;
    rep(i,1,n){
        ll x;
        cin>>x;
        if(x>cur){
            sum+=t;
            cur=x+t;
        }
        else if(cur==x){
            sum+=t;
            cur+=t;
        }
        else{
            sum+=t-(cur-x);
            cur=x+t;
        }
    }
        cout<<sum;

    return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	cout << ((x<1200) ? "ABC" : "ARC") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        char[] before = scan.next().toCharArray();
        char[] after = scan.next().toCharArray();

        // search
        int answer = 0;
        for(int i = 0; i < 3; i++){
            if(before[i] == after[i]){
                answer++;
            }
        }

        // answer
        System.out.println(answer);

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  cout << N*N*N << endl;
} 

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

bool is_harshad(int x)
{
    int tmp = x;
    int sum = 0;
    while (tmp > 0)
    {
        sum += tmp % 10;
        tmp /= 10;
    }
    return x % sum == 0;
}

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

    if (is_harshad(N))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import typing
from typing import Deque, Set, Dict

class Island:
    def __init__(self, id: int) -> None:
        self.id: int = id
        self.connection: List['Island'] = []
        self.rank: int = 0
    
    def addConnection(self, other: 'Island') -> None:
        self.connection.append(other)
        other.connection.append(self)

    def setRank(self, other: 'Island') -> None:
        self.rank = other.rank +1

class Islands(Dict[int, Island]):
    def __init__(self, num: int):
        for id in range(1, num+1):
            self[id] = Island(id)

def bfs(root: Island, max_depth: int) -> None:
    reserved: Deque[Island] = Deque([root])
    seen: Set[int] = {root.id}
    while len(reserved) != 0:
        current: Island = reserved.popleft()
        if current.rank > max_depth:
            break
        for connected in current.connection:
            if connected.id in seen:
                continue
            connected.setRank(current)
            seen.add(connected.id)
            reserved.append(connected)

def main() -> None:
    with open(0) as f:
        N, M = map(int, f.readline().split())
        ab = [map(int, line.split()) for line in f.readlines()]
    #諸島生成
    islands: Islands = Islands(N)
    #諸島間定期便生成
    for a, b in ab:
        islands[a].addConnection(islands[b])
    #bfs
    bfs(islands[1], 2)
    #出力
    print('POSSIBLE' if islands[N].rank in (1, 2) else 'IMPOSSIBLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 169144
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  char X, Y;
  cin >> X >> Y;
  if(X < Y) cout << '<' << endl;
  else if(X == Y) cout << '=' << endl;
  else cout << '>' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  cin >> n;
  string strN;
  strN = to_string(n);
  int nL = (int)(strN.length());

  map<char,int> s2i;
  s2i['0'] = 0;
  s2i['1'] = 1;
  s2i['2'] = 2;
  s2i['3'] = 3;
  s2i['4'] = 4;
  s2i['5'] = 5;
  s2i['6'] = 6;
  s2i['7'] = 7;
  s2i['8'] = 8;
  s2i['9'] = 9;

  int f = 0;
  for (int i = 0; i < nL; i++) {
    f += s2i[strN[i]];
  }

  if (n % f == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  cout << endl;

  return 0;
}

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

int main()
{
    using ValueType = std::int32_t;
    using WeightType = std::uint64_t;
    const auto max_n = ValueType(100);
    const auto max_val = ValueType(1000);
    const auto max_len = ValueType(max_val * max_n + 10);
    const WeightType inf = 1e13;

    auto n = std::size_t();
    auto weight = WeightType();

    std::cin >> n >> weight;

    auto w = std::vector<WeightType>(n);
    auto val = std::vector<ValueType>(n);

    for (std::size_t i = 0; i < n; ++i) std::cin >> w[i] >> val[i];

    auto dp = std::vector<WeightType>(max_len, inf);
    dp[0] = 0;

    ValueType val_sum = 0;
    for (std::size_t i = 0; i < n; ++i)
    {
        val_sum += val[i];
 
        for (ValueType v = val_sum - val[i]; 0 <= v; --v)
        {
            if (dp[static_cast<std::size_t>(v + val[i])] >= dp[static_cast<std::size_t>(v)] + w[i])
                dp[static_cast<std::size_t>(v + val[i])] = dp[static_cast<std::size_t>(v)] + w[i];
        }
    }

    ValueType result = 0;
    for (ValueType i = 0; i < max_len; ++i)
    {
        if (dp[static_cast<std::size_t>(i)] <= weight) result = i;
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail)
{
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(max(a * c, b * d), max(a * d, b * c));

  print(ans);
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main() {
    long long int Q,H,S,D,N,ONE,TWO;
    cin >>Q>>H>>S>>D>>N;
    ONE=min(min(Q*4,H*2),S);
    TWO=min(ONE*2,D);
    cout << N/2*TWO + N%2*ONE << endl;
    return 0;
}

Measured memory_bytes: 256
//Created by Young Charlie
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 

int main() {
	ios::sync_with_stdio(0);	cin.tie(0);
	int n; cin>>n;
	string a; cin>>a;
	int res = 1;
	for(int i = 0; i < n - 1; i++){
		if(a[i] != a[i + 1]){
			res++;
		}
	}
	cout<<res<<endl;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<pair<string,int>> ans;
  for(int i=0; i<n; i++){
    string s;
    int b;
    cin >> s >> b;
    ans.push_back(make_pair(s,b));
  }
  string se;
  cin >> se;
  long long sum = 0;
  bool cek = false;
  for(int i=0; i<n; i++){
    if(cek){
    	sum += ans[i].second;	
    }
  	if(ans[i].first == se){
    	cek = true;
    }
    
  }
  
  cout << sum << endl;
  
  return 0;

}

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<pll> AB(N);
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    AB[i] = make_pair(a, b);
  }
  sort(AB.begin(), AB.end());
  ll count = 0, money = 0;
  for (int i = 0; i < N; i++) {
    ll a = AB[i].first, b = AB[i].second;
    if (count + b <= M) {
      money += a * b;
      count += b;
    } else {
      money += (M - count) * a;
      break;
    }
  }
  cout << money << '\n';
  return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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;}


int main() {
  char c;cin>>c;
  //cout<<c-'0';
  cout<<(c-'0'<49?'A':'a');
}

Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class C100To105 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int x;
	    in >> x;

        int dp[100010];
        Fill(dp, 0);
        dp[0] = 1;
        reps(i, 1, 100000){
            if(i >= 100 && dp[i-100]) dp[i] = 1;
            if(i >= 101 && dp[i-101]) dp[i] = 1;
            if(i >= 102 && dp[i-102]) dp[i] = 1;
            if(i >= 103 && dp[i-103]) dp[i] = 1;
            if(i >= 104 && dp[i-104]) dp[i] = 1;
            if(i >= 105 && dp[i-105]) dp[i] = 1;
        }

        out << dp[x] << endl;
	}
};


int main() {
	C100To105 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cost(n+1,0);
    vector<int> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i];
        cost[v[i]] = 1;
    }

    int ans_1 = 0;
    int ans_2 = 0;
    for (int i = 0; i < x; i++) {
        if (cost[i] == 1) {
            ans_1++;
        }
    }
    for (int i = x; i < n+1; i++) {
        if (cost[i] == 1) {
            ans_2++;
        }
    }

    cout << min(ans_1,ans_2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a,b[1013],c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[313][313],bbb,ccc,ddd;
    string spc,in,store;

    cin>>n;
    if(n>=400 && n<=599)
        cout<<"8"<<endl;
    else if(n>=600 && n<=799)
        cout<<"7"<<endl;
    else if(n>=800 && n<=999)
        cout<<"6"<<endl;
    else if(n>=1000 && n<=1199)
        cout<<"5"<<endl;
    else if(n>=1200 && n<=1399)
        cout<<"4"<<endl;
    else if(n>=1400 && n<=1599)
        cout<<"3"<<endl;
    else if(n>=1600 && n<=1799)
        cout<<"2"<<endl;
    else if(n>=1800 && n<=1999)
        cout<<"1"<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 3624