akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
int a,b,c,n,s;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&n);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			if(n-i*500-j*100>=0)
				s+=(n-i*500-j*100<=c*50);
	printf("%d\n",s);
	return 0;
}

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

int main() {
    
    int N,X,s,sum,ans;


    cin >> N >> X;


    vector<int> m(N);

    for (int i=0;i<=N-1;i++){
        cin >> m.at(i);
    }

    s = m.at(0);

    for (int i=1;i<=N-1;i++){
        if (m.at(i) <s){
            s = m.at(i);
        }
    }
    sum = std::accumulate(m.begin(), m.end(), 0);

    ans = (X - sum) / s + N;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
  int a,b,c;
  cin>>a>>b>>c;
  
  if (a%2 && b%2 && c%2)
  {cout<<min(a*b,min(b*c,c*a))<<endl;}
  else
  {cout<<0<<endl;}
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> m;
    m[a]++;
    m[b]++;
    m[c]++;
    for (auto i : m) {
        if (i.second == 1) {
            cout << i.first << endl;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("-O3", "unroll-loops")
#pragma GCC target ("arch=ivybridge")

const int nmax = 204800, block = 8192, unrl = 8;
int a[nmax], b[nmax];

int main() {

	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (int i = 0; i + unrl <= N; i += unrl) {
		for (int j = 0; j + block <= N; j += block) {
			for (int k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);

			}
		}
	}

	for (int i = 0; i < N / unrl * unrl; i++) {
		for (int j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (int i = N / unrl * unrl; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1792
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

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

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n; cin >> n;
  ll get = (n + 999) / 1000;
  get = get * 1000;
  cout << get - n << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3632
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");

  var n = parseInt(input[0], 10);
  var taro = 0;
  var hanako = 0;

  for (i = 1; i <= n; i++) {
    var card = input[i].split(" ");
    if (card[0] < card[1]) {
      hanako += 3;
    } else if (card[0] == card[1]) {
      taro += 1;
      hanako += 1;
    } else {
      taro += 3;
    } 
  }
  console.log(taro, hanako);
});

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

int main(void)
{
  int N;
  string s;
  cin >> N;
  
  unordered_map<string, int> m;
  m["AC"] = 0;
  m["WA"] = 0;
  m["RE"] = 0;
  m["TLE"] = 0;
  
  while(N--)
  {
    cin >> s;
    m[s]++;
  }
  
  cout << "AC x " << m["AC"] << '\n'
       << "WA x " << m["WA"] << '\n'
       << "TLE x " << m["TLE"] << '\n'
       << "RE x " << m["RE"];
  
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    for (int i = 0; i + 1 < N; i++) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    for (int i = 0; i + 2 < N; i++) {
        if (S[i] == S[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}


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

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

  string s;
  cin >> s;

  int unh = 0;

  char tmp = 'A';
  rep(i, s.size()) {
    if (tmp == 'R' && s[i] == 'L') {
      unh += 2;
      tmp = s[i];
      continue;
    }

    if (i == 0 && s[i] == 'L') {
      unh++;
      tmp = s[i];
      continue;
    }

    if (i == s.size() - 1 && s[i] == 'R') {
      unh++;
      tmp = s[i];
      continue;
    }

    tmp = s[i];
  }

  if (2 * k < unh) {
    unh -= 2 * k;
  } else {
    unh = 1;
  }

  cout << n - unh << endl;
  return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

sA = sum(A) // 2
x1 = sA - sum(A[1::2])
ans = [str(x1 * 2)]

for i in range(1,N):
  x1 = A[i-1] - x1
  ans.append(str(x1 * 2))
  
print(" ".join(ans))

Measured memory_bytes: 17224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include <numeric>
#include<tuple>
#include <functional>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, m, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll p, q, r;
	cin >> p >> q >> r;
	cout << min(p + q, min(q + r, p + r)) << endl;
	return 0;
}

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

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

int main()
{
  string o, e;
  cin >> o >> e;
  REP(i, e.length())
    cout << o[i] << e[i];
  if(o.length() - e.length() == 1) cout << o.back();
  cout << endl;
}


Measured memory_bytes: 256
a = raw_input()
flag = -1
for z in range(0, len(a)) :
    if 'C' == a[z]:
        flag = z
if flag == -1:
    print 'No'
else:
    flag2 = -1
    for z in range(flag+1, len(a)):
        if 'F' == a[z]:
            flag2 = z
    if flag2 == -1:
        print 'No'
    else:
        print 'Yes'


Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NMAX 100000

int len, part, rank[NMAX+1];
int compare_sa(const void *a, const void *b);
void construct_sa(char *string, int n, int *sa);
int main(void)
{
  int i, n, k, l, lo, hi, sa[NMAX+1];
  char s[NMAX+1];
  scanf("%d%*c", &k);
  scanf("%s%*c", s);
  n = strlen(s);
  l = (n + k) / (k + 1);
  lo = 1;
  hi = n;
  construct_sa(s, n, sa);
  if (n % (k + 1) == 0) {
    int res = 0;
    for (i = 0; i < k; i++) {
      if (rank[n/(k+1)*(i+1)] > rank[res]) res = n / (k + 1) * (i + 1);
    }
    s[res+n/(k+1)] = '\0';
    printf("%s\n", s + res);
  } else {
    while (hi >= lo) {
      int mid = (lo + hi) / 2, pos = 0, res = 0;
      while (pos < n) {
        pos += rank[pos] <= mid ? l : l - 1;
        res++;
      }
      if (res <= k + 1) hi = mid - 1;
      else lo = mid + 1;
    }
    s[sa[lo]+l] = '\0';
    printf("%s\n", s + sa[lo]);
  }
}

int compare_sa(const void *a, const void *b)
{
  int i = *(int*)a, j = *(int*)b;
  if (rank[i] != rank[j]) return rank[i] - rank[j];
  else {
    int ri = (i + part <= len ? rank[i+part] : -1), rj = (j + part <= len ? rank[j+part] : -1);
    return ri - rj;
  }
}

void construct_sa(char *string, int n, int *sa)
{
  int i, tmp[NMAX+1];
  len = n;
  for (i = 0; i <= len; i++) {
    sa[i] = i;
    rank[i] = i < n ? string[i] : -1;
  }
  for (part = 1; part <= len / 2; part *= 2) {
    qsort(sa, len + 1, sizeof(int), compare_sa);
    tmp[sa[0]] = 0;
    for (i = 1; i <= len; i++) {
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(&sa[i-1], &sa[i]) ? 1 : 0);
    }
    for (i = 0; i <= len; i++) rank[i] = tmp[i];
  }
}


Measured memory_bytes: 1780
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define pb push_back

using namespace std;
const int N=105;
typedef long long LL;
const int mod=1000000007;
LL x,y,f[N];
int ans,tot;
struct data{LL a,b;};
vector <data> vt[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

LL getLL()
{
	char ch;
	while(!isdigit(ch=getchar()));
	LL x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void dfs(int x,LL a,LL b)
{
	if(x>88) return;
	if(a>=f[x] && b>=f[x+1]) return;
	vt[x].pb((data){a,b});
	dfs(x+1,b,a+b);
	dfs(x+1,b,a+2*b);
}

void solve()
{
	x=getLL(),y=getLL(),ans=tot=0;
	if(x>y) swap(x,y);
	rep(i,1,90) if(f[i]>x || f[i+1]>y) {ans=i-1; break;}
	if(ans<=1)
	{
		if(x==1) tot=y%mod;
		else tot=4;
		printf("%d %d\n",1,tot);
		return;
	}

	int sz=vt[ans].size();
	rep(i,0,sz-1)
	{
		LL a=vt[ans][i].a,b=vt[ans][i].b;
		if(a<=x && b<=y) tot=(tot+(x-a)/b)%mod;
		if(a<=y && b<=x) tot=(tot+(y-a)/b)%mod;
	}
	printf("%d %d\n",ans,tot);
}

int main()
{
	f[0]=f[1]=1;
	rep(i,2,90) f[i]=f[i-1]+f[i-2];
	dfs(1,1,1);
	for(int T=getint(); T--; solve());
	return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

long n;

int main()
{
  fastio;
  cin >> n;
  long res = 1; res += (n != 2);
  for (long i = 2; i * i <= n - 1; i++){
    if ((n - 1) % i == 0){
      res++;
      if ((n - 1) / i != i) res++; 
    }
  }
  for (long i = 2; i * i <= n; i++){
    if (n % i == 0){
      long x = n;   
      while (x % i == 0) x /= i; 
      res += (x % i == 1);
      int j = n / i;
      if (i == j) continue;
      x = n;
      while (x % j == 0) x /= j;
      res += (x % j == 1);
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
   string s;
   string t;
   cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            ans++;
        }
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3912
#include <iostream>
using namespace std;
// Recursive function to return gcd of a and b
class gfg
{
 public :long long int gcd(long long int a, long long int b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }


// Function to return LCM of two numbers
  long long int lcm(long long int a,long long int b)
 {
    return (a*b)/gcd(a, b);
 }
} ;
// Driver program to test above function
int main()
{
    gfg g;
    long long int a,b;
    cin>>a>>b;
    cout<<g.lcm(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	list<ll> l1,l2;
	for(int i=0;i<n;i++){
		l1.push_back(a[i]);
		l2.push_back(a[i]);
	}
	ll res1 = 0,res2 = 0;
	ll sv1 = a[n-1],lv1 = a[n-1];
	ll sv2 = a[0],lv2= a[0];
	l1.pop_back();
	l2.pop_front();
	int mode = 1;
	while(!l1.empty()){
		if(mode==1){
			ll tmp1 = l1.front(),tmp2 = l2.back();
			res1 += abs(sv1-tmp1);
			res2 += abs(sv2-tmp2);
			l1.pop_front();
			l2.pop_back();
			sv1 = tmp1;
			sv2 = tmp2;
			if(!l1.empty()){
				tmp1 = l1.front(),tmp2 = l2.back();
				res1 += abs(lv1-tmp1);
				res2 += abs(lv2-tmp2);
				l1.pop_front();
				l2.pop_back();
				lv1 = tmp1;
				lv2 = tmp2;
			}
		}else{
			ll tmp1 = l1.back(),tmp2 = l2.front();
			res1 += abs(sv1-tmp1);
			res2 += abs(sv2-tmp2);
			l1.pop_back();
			l2.pop_front();
			sv1 = tmp1;
			sv2 = tmp2;
			if(!l1.empty()){
				tmp1 = l1.back(),tmp2 = l2.front();
				res1 += abs(lv1-tmp1);
				res2 += abs(lv2-tmp2);
				l1.pop_back();
				l2.pop_front();
				lv1 = tmp1;
				lv2 = tmp2;
			}

		}
		mode = (mode+1)%2;
	}
	cout<< max(res1,res2 ) <<endl;
	return 0;
}


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

using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    map<ll,int> cnt;
    cnt[0]=1;
    ll sum=0;
    ll res=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        res+=cnt[sum];
        cnt[sum]++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
int main(void){
    char s1, s2;
    
    scanf("%c %c",&s1, &s2);
    
    if(s1 == s2){
        printf("H\n");
    }else if(s1 != s2){
        printf("D\n");
    }
    
}


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

int main(){
    long long N,M;
    cin >> N >> M;
    vector<pair<int,int>> edge;
    int vert[100001];
    for(int i=1;i<=N;i++) vert[i]=0;
    long long nB,nW;
    bool al=false;

    for(int i=0;i<M;i++){
        int A,B;
        cin >> A >> B;
        edge.push_back(make_pair(A,B));
    }

    vert[1]=1;
    nB=1; nW=0;
    bool update=true;
    while(update){
        update=false;
        for(pair<int,int> x:edge){
            if(vert[x.first]!=0 && vert[x.second]!=0){
                if(vert[x.first]==vert[x.second]){
                    al=true;
                    update=false;
                    break;
                }
            }else if(vert[x.first]!=0){
                vert[x.second]=(-vert[x.first]);
                if(vert[x.second]==1) nB++;
                else nW++;
                update=true;
            }else if(vert[x.second]!=0){
                vert[x.first]=(-vert[x.second]);
                if(vert[x.first]==1) nB++;
                else nW++;
                update=true;
            }
        }
    }

    if(al){
        cout << (N*(N-1)/2-M) << endl;
    }else{
        cout << (nB*nW-M) << endl;
    }
    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

constexpr int INF = (1 << 30);

int main() {
	int n, k;
	std::cin >> n >> k;
	std::vector<std::vector<int>> g(n);
	std::vector<std::pair<int, int>> edge;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		std::cin >> a >> b;
		a--; b--;
		edge.emplace_back(a, b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	std::vector<int> dist(n);
	auto bfs = [&] (int str, int par) -> void {
		std::queue<std::pair<int, int>> que;
		que.emplace(str, par);
		dist[str] = 0;
		while (not que.empty()) {
			auto [v, p] = que.front(); que.pop();
			for (int u : g[v]) if (u != p) {
				dist[u] = dist[v] + 1;
				que.emplace(u, v);
			}
		}
	};
	
	int ans = n, h = (k >> 1);
	
	if (k & 1) {
		for (const auto [a, b] : edge) {
			std::fill(dist.begin(), dist.end(), INF);
			bfs(a, b); bfs(b, a);
			int count = 0;
			for (int d : dist) if (d > h) count++;
			ans = std::min(ans, count);
		}
	} else {
		for (int v = 0; v < n; v++) {
			std::fill(dist.begin(), dist.end(), INF);
			bfs(v, -1);
			int count = 0;
			for (int d : dist) if (d > h) count++;
			ans = std::min(ans, count);
		}
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std;
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(a,c)-min(b,d)<0)
  cout<<min(b,d)-max(a,c)<<endl;
  else
  cout<<0<<endl;
  }
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int k = scan.nextInt();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
   ll n,k;
   cin>>n>>k;
//    k%=n;
   ll a[n];
   ll i;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       a[i]--;
   }
   ll st=0;
   ll cyc=0;
   ll vis[n];
   clr(vis); 
   ll cys=-1;
   ll count=0;
   while(true)
   {
       if(vis[st])
       {
           cys=st;
           break;
       }
    //    cout<<st+1<<"\n";
        vis[st]=1;
        st=a[st];
   }
    st=0;
   vll v;
   ll stt=cys;
   while(true)
   {
       v.pb(stt);
       stt=a[stt];
       cyc++;
       if(stt==cys)break;

   }
   st=0;
//    cout<<cys<<"\n";
   while(true)
   {
       if(st==cys)
       {
        //    cout<<k<<"here\n";
           break;
       }
       k--;
       st=a[st];
       if(k==0)break;
   }
   if(k==0)
   {
       cout<<st+1<<"\n";
   }
   else{
    //    cout<<k<<"\n";
       ll ans=k%cyc;
       cout<<v[ans]+1<<"\n";
   }
//    cout<<k%cyc<<"\n";
//    for(auto it:v)
//    {
//        cout<<it+1<<" ";
//    }
    //   cout<<cys<<" "<<cyc<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 8456
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int k;
	cin >> k;
	int a = k / 2;
	int b = (k + 1) / 2;
	cout << a * b << 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;

int main() {
        string S;
        int d =5;
        int c1 = 0, c2 = 0;
        while (1) {
                cin >> S;
                if (cin.eof() == true) break;
                auto S1 = S;
                auto S2 = S;
                int c1 = 0, c2 = 0;
                int p;
                while ((p = S1.find("JOI")) != string::npos) {
                        S1.erase(0, p+1);
                        c1 ++;
//                      cout << "c1 = " << c1  << endl;
                }
                cout << c1 << endl;
                while ((p = S2.find("IOI")) != string::npos) {
                        S2.erase(0, p+1);
                        c2 ++;
                }
                cout << c2 << endl;
                if (d-- == 0) break;
        }
        return 0;
}



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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector < int > deg(n, 0);
  vector < vector < int > > g(n);
	
  m += n - 1;

  while(m--) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    ++deg[v];
  }

  vector < int > qu;
  vector < int > ans(n);

  for(int v = 0; v < n; ++v) {
    if(deg[v] == 0) {
      ans[v] = -1;
      qu.emplace_back(v);
    }
  }

  for(int it = 0; it < n; ++it) {
    int v = qu.back();
    qu.pop_back();

    for(int s : g[v]) {
      ans[s] = v;
      if(--deg[s] == 0) {
        qu.push_back(s);
      }
    }
  }

  for(auto x : ans) cout << ++x << endl;

  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;
ll h[mxn];
vll adj[mxn];

void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    ll n,m;
    cin >> n >> m;
    in_arr1(h,n);
    ll a,b;
    for(i=0;i<m;i++){
        cin >> a >> b;
        adj[a].pb(h[b]);
        adj[b].pb(h[a]);
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        sort(adj[i].begin(), adj[i].end());
        ll sz=adj[i].size();
        if(sz==0 || adj[i][sz-1] < h[i]){
            ans++;
        }
    }
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 10236
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1) / b + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1

    else:
        dic[a] = 1

ans = 0

for a in dic:
    if dic[a] % 2 != 0:
        ans += 1

print(ans)

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int n;
    cin >> n;
    int money = 100;
    for(int i = 0; i < n; i++){
        money = (money * 21 + 19) / 20;
    }
    cout << money * 1000 << endl;
}



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, a;

	cin >> n;

	vector<vector<ll>> v(n, vector<ll>(n - 1, -1));

	REP(i, n) {
		REP(j, n - 1) {
			cin >> a;
			v[i][j] = a;
		}
	}

	vector<ll> cnt(n, 0);

	ll ans = 0;
	bool flag;
	vector<bool> used(n);
	ll sum;
	ll prev = -1;
	bool f;

	while (true) {
		flag = true;
		f = true;

		REP(i, n) {
			if (cnt[i] != n - 1) {
				flag = false;
				break;
			}
		}

		if (flag) {
			break;
		}

		ans++;

		REP(i, n) {
			used[i] = false;
		}

		REP(i, n) {
			if (used[i] || cnt[i] == n - 1) {
				continue;
			}

			ll x = v[i][cnt[i]] - 1;

			used[i] = true;

			if (!used[x] && v[x][cnt[x]] - 1 == i) {
				cnt[i]++;
				cnt[x]++;
				used[x] = true;
				f = false;
			}
		}

		if (f) {
			ans = -1;
			break;
		}

		if (ans > 100000) {
			ans = n * (n - 1) / 2;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 10112
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;

ll ds(ll digit) {
	ll res = 0;
	while (digit != 0) {
		res += digit % 10;
		digit /= 10;
	}
	return res;
}
ll MOD = 1000000007;
int main() {
	ll N;
	cin >> N;
	ll min = 100000000;
	vector<ll>a(110);
	for (ll i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (ll i = -100; i <101; ++i) {

		ll sum = 0;

		for (ll j = 0; j<N; ++j)
		
			sum += (a[j] - i)*(a[j] - i);
			if (sum<min)min = sum;
		
	}
	cout << min << endl;
}





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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string x, y;
    cin >> x >> y;

    if((x.compare(y)) == 0) cout << "=";
    else if((x.compare(y) > 0)) cout << ">";
    else cout << "<";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input.split("\n");
  let tmp = input[1].split(" ");
  let a = parseInt(tmp[0]);
  let b = parseInt(tmp[1]);
  for (a; a <= b; a++) {
    const res = a % parseInt(input[0]);
    if (res === 0) {
      console.log("OK");
      return;
    }
  }
  console.log("NG");
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29600
#include <cstdio>
#include <cmath>

int main(){
    int x;
    scanf("%d",&x);
    if(x < 4){
        printf("1\n");

        return 0;
    }
    int max = 0;
    for(int i = 2; i <= sqrt(x); i++){
        for(int j = 1;; j++){
            if(pow(i,j) <= x && x <= pow(i,j + 1)){
                if(max < pow(i,j)){
                    max = pow(i,j);
                }
            }
            if(pow(i,j) > x){
                break;
            }
        }
    }
    printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

int main()
{
	long K, A, B;
	std::cin >> K >> A >> B;

	if (A >= B-1) {
		std::cout << (K+1) << "\n";
		return 0;
	}
	if (K <= A-1) {
		std::cout << (K+1) << "\n";
		return 0;
	}

	K -= A-1;
	long n = A;
	n += (K/2) * (B-A);
	if (K%2 == 1)
		++n;
	std::cout << n << "\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	
	if(a >= b){
		cout << "delicious" << endl;
	}
	else if(a+x >= b){
		cout << "safe" << endl;
	}
	else{
		cout << "dangerous" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define INT INT_MAX
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int M = 1e5 + 1;
int N, W;
int wt[M], val[M];

/*
Normal knapsack has O(N*W) time. But when W is really huge then we will get TLE.
So we can't use W. The only thing left is val. We will use it.
Prev, dp[i][j] = Max value obtained for 1....i items and sum of weight of items is j
Now, dp[i][j] = Min weight needed to get j value using 1....i items
*/
// O(N * Sum_values) Time & Space
int Bottom_Up() {
    // maximum value we can get by including all items
    int max_val = 0;
    for(int value : val) max_val += value;
    vector<vector<int>> dp(N+1, vector<int>(max_val+1, INT_MAX));
    
    // Base case
    for(int i = 0; i <= N; ++i) dp[i][0]=0;
    // Recurrence
    for(int i = 1; i <= N; ++i) {
        for(int value = 1; value <= max_val; ++value) {
            if(val[i] > value) {
                dp[i][value] = dp[i-1][value];
                continue;
            }
            int incl = dp[i-1][value - val[i]] + wt[i];
            int excl = dp[i-1][value];
            dp[i][value] = min(incl, excl);
        }
    }
    for(int value = max_val; value >= 0; --value) {
        if(dp[N][value] <= W) return value;
    }
    return -1;
}

// O(N * Sum_values) Time | O(Sum_values) space 1 Array
int Bottom_Up1() {
    // maximum value we can get by including all items
    int max_val = 0;
    for(int value : val) max_val += value;
    vector<int> dp(max_val+1, INT_MAX);
    // Base case
    dp[0] = 0; //Initially dp contains 0th row which should be 0, INF, INF....
    // Recurrence
    for(int i = 1; i <= N; ++i) {
        for(int value = max_val; value >= 1; --value) {
            if(val[i] > value) {
                continue;
            }
            int incl = dp[value - val[i]] + wt[i];
            int excl = dp[value];
            dp[value] = min(incl, excl);
        }
    }
    for(int value = max_val; value >= 0; --value) {
        if(dp[value] <= W) return value;
    }
    return -1;
}

int32_t main() {
    IOS;
    cin >> N >> W;
    // vector<vector<int>> dp(N+1, vector<int>(W+1, -1));
    for(int i = 1; i <= N; ++i) {cin >> wt[i]; cin >> val[i];}
    cout << Bottom_Up1() << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
   int w,h;
    char mero[400][400];
    int reached[400][400]={0};
    long long a,b;
    long long search(int x,int y){
        if(x<0||h<=x||y<0||w<=y) return 0;
        if(reached[x][y]==1) return 0;
        reached[x][y]=1;
        if(mero[x][y]=='.'){
            a++;
            if(mero[x+1][y]=='#') search(x+1,y);
            if(mero[x-1][y]=='#') search(x-1,y);
            if(mero[x][y+1]=='#') search(x,y+1);
            if(mero[x][y-1]=='#') search(x,y-1);
        }
        if(mero[x][y]=='#'){
            b++;
            if(mero[x+1][y]=='.') search(x+1,y);
            if(mero[x-1][y]=='.') search(x-1,y);
            if(mero[x][y+1]=='.') search(x,y+1);
            if(mero[x][y-1]=='.') search(x,y-1);
        }
    }
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>mero[i][j];
    }
    long long ans=0;
    a=0,b=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
                ans+=a*b;
                a=0,b=0;
                search(i,j);
        }
    }
    ans+=a*b;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
                ans+=a*b;
                a=0,b=0;
                search(i,j);
        }
    }
    ans+=a*b;
    cout<<ans;
}

Measured memory_bytes: 13568
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue(void);


int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;
  
  while(head != tail){
    
    if(Q[head].t<=q){
      elaps += Q[head].t;
      u=dequeue();
      printf("%s %d\n",u.name,elaps);
   
    }

    else{
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
      dequeue();
    }
  }  

 
  return 0;
  
}

void enqueue(P x){ 
  Q[tail]=x;
  
  if(tail==LEN){
    tail = 1;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P x;
  x = Q[head];

  if(head == LEN){
    head = 1;
  }
  else{
    head++;
  }
  return x; 
}

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

int main(){

    int i, j;
    char moji[4][3];
    char dammy;
    for(j=0;j<3;j++){
        for(i=0;i<3;i++){
            scanf("%c", &moji[i][j]);
        }
        scanf("%c", &dammy);
    }
    
    printf("%c%c%c", moji[0][0], moji[1][1],moji[2][2]);

    return 0;
}

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9')cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	// "sort"
	// "strconv"
	// "strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	var a, b uint32
	fmt.Scanf("%d %d", &a, &b)

	fmt.Printf("%032b\n", a&b)
	fmt.Printf("%032b\n", a|b)
	fmt.Printf("%032b\n", a^b)

}



Measured memory_bytes: 1188
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;


int main(){
  int n,k =0;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) a.at(i) +=1;
  queue<int>q;
  int mx,s = 0;
  double ans = 0;
  rep(i,n){
    s += a.at(i);
    q.push(a.at(i));
    if(q.size() > k){
      s -= q.front();
      q.pop();
    } 
    if(q.size() == k){
      mx = max(mx,s);
    }
  }
  ans = mx;
   ans /= 2;
  printf("%.10f",ans);

}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<std::vector<long long>> A(2, std::vector<long long>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%lld", &A[i][j]);
    }
  }

  ll second = accumulate(all(A[1]), 0LL);

  ll ans = 0;
  ll first = 0;
  rep(i, 0, N) {
    first += A[0][i];
    chmax(ans, first + second);
    second -= A[1][i];
  }

  put(ans);

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

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

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256