akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
using P   = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const long long mod = 1000000007;

struct Combination {
    int mod;
    vector<int64_t> mfact, rfact;

    Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) {
        mfact[0] = 1;
        for(int i = 1; i < mfact.size(); i++) {
            mfact[i] = mfact[i - 1] * i % mod;
        }
        rfact[sz] = inv(mfact[sz]);
        for(int i = sz - 1; i >= 0; i--) {
            rfact[i] = rfact[i + 1] * (i + 1) % mod;
        }
    }

    int64_t fact(int k) const { return (mfact[k]); }

    int64_t pow(int64_t x, int64_t n) const {
        int64_t ret = 1;
        while(n > 0) {
            if(n & 1) (ret *= x) %= mod;
            (x *= x) %= mod;
            n >>= 1;
        }
        return (ret);
    }

    int64_t inv(int64_t x) const { return (pow(x, mod - 2)); }

    int64_t P(int n, int r) const {
        if(r < 0 || n < r) return (0);
        return (mfact[n] * rfact[n - r] % mod);
    }

    int64_t C(int p, int q) const {
        if(q < 0 || p < q) return (0);
        return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
    }

    int64_t H(int n, int r) const {
        if(n < 0 || r < 0) return (0);
        return (r == 0 ? 1 : C(n + r - 1, r));
    }
};

void solve(long long S) {
    Combination comb(10000, mod);
    if(S < 3) {
        cout << 0 << endl;
        return;
    }
    i64 ans = 1;
    rep(i, 2, S / 3 + 1) {
        i64 res = S - 2 * i;
        ans     = (ans + comb.C(res - 1, i - 1)) % mod;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    long long S;
    scanf("%lld", &S);
    solve(S);
    return 0;
}


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

using namespace std;
unsigned long long n,cat,rest,rez;
int main()
{
    cin>>n;
    cat=n/500;
    rest=n%500;
    rez=(cat*1000)+(rest/5)*5;
    cout<<rez<<'\n';
    return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long ll;
typedef queue<pair<int, int> > que;

int main()
{
	int n, a[1005];
	while (1)
	{
		cin >> n; if (n == 0)return 0;
		REP(i, n)cin >> a[i];
		int cnt = 0;
		REP(i, n - 1)REP(j, n - 1)
		{
			if (a[j] > a[j + 1])
			{
				swap(a[j], a[j + 1]);
				cnt++;
			}
		}
		cout << cnt << endl;

		
	}return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  string S;
  llint N,M;
  cin >> N;

  //SOLVE
  double ans;


  double odd=0,even=0;

  rep(i,1,N+1) {
    if (i%2 == 0) {
      even++;
    } else {
      odd++;
    }
  }

  ans = odd / (odd+even);

  //OUTPUT
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in); 
		
		int N = sc.nextInt();
		String s = sc.next();
		
		int countR = 0;
		int countB = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'R') {
				countR++;
			}else {
				countB++;
			}
		}
		
		if(countR > countB) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

set<ll> st;

void dfs(int n, ll num) {
	if (n == 13) return;
	st.insert(num);
	if (num % 10 != 0) dfs(n + 1, num * 10 + num % 10 - 1);
	if (num % 10 != 9) dfs(n + 1, num * 10 + num % 10 + 1);
	dfs(n + 1, num * 10 + num % 10);
}

int main(void) {
	int k;
	cin >> k;
	
	rrep (i, 9) dfs(0, i);
	int cnt = 0;
	for (auto it = st.begin(); it != st.end(); it++) {
		cnt++;
		if (cnt == k) {
			cout << *it << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 231552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;

typedef pair<int,int> Point;
typedef vector<Point> VP;
#define X first
#define Y second

bool compy(const Point &a, const Point &b) {
    return a.Y < b.Y;
}

Point p[50],pp[50];

int main(void){
    int N,K;
    scanf("%d %d",&N,&K);
    rep(i,N){
        scanf("%d %d",&p[i].X,&p[i].Y);
    }
    sort(p,p+N);
    ll res = LLONG_MAX;
    rep(r,N)rep(l,r){
        ll w = p[r].X-p[l].X;
        if(r-l+1<K)continue;
        int idx=0;
        for(int i=l;i<=r;i++){
            pp[idx++]=p[i];
        }
        int n = idx;
        sort(pp,pp+n,compy);
        rep(i,n-K+1){
            ll h = pp[i+K-1].Y-pp[i].Y;
            res = min(res,w*h);
        }
    }
    printf("%lld\n",res );
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ll a;
    while(~scanf("%lld",&a))
    {
        ll mod=11;
        ll s=a/mod*2;
        a%=mod;
        if(a>=1&&a<=6)s++;
        if(a>=7&&a<=10)s+=2;
        printf("%lld\n",s);
    }
}


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

using namespace std;

using P = pair<int,int>;

vector<P> func(vector<int> array){
  map<int,int> m;
  for(auto&i:array){
    ++m[i];
  }
  vector<P> res;
  for(auto&i:m){
    res.emplace_back(i.second,i.first);
  }
  sort(res.begin(),res.end(),greater<P>());
  res.emplace_back(0,0);
  return res;
}

int main(){
  int n;
  cin >> n;
  vector<int> array;
  vector<int> array1;
  vector<int> array2;
  for(int i=0;i<n;++i){
    int d;
    cin >> d;
    array.emplace_back(d);
    if(i&1){
      array1.emplace_back(d);
    }else{
      array2.emplace_back(d);
    }
  }
  vector<P> ans1 = func(array1);
  vector<P> ans2 = func(array2);
  int ans = n;
  for(int i=0;i<2;++i){
    for(int j=0;j<2;++j){
      if(ans1[i].second==ans2[j].second)continue;
      ans = min(ans,n-ans1[i].first-ans2[j].first);
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

    while (n > 0) {
        n -= 1;
        s = char('a' + n % 26) + s;
        n /= 26;
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
 
int main(void){
    // Your code here!
    int N,flag;
    int A[100000],cnt[100000];
    int ans=1;
    
    scanf("%d",&N);
    
    if(N % 2 == 0){
        flag = 0;
    }
    else{
        flag = 1;
    }
    
    for(int i = 0; i < N; i++){
        int num;
        if(flag == 0 && i % 2 == 1){
            cnt[i] = 2;
        }
        else if(flag == 1 && i % 2 == 0){
            if(i == 0){
                cnt[i] = 1;
            }
            else{
                cnt[i] = 2;
            }
        }
        else{
            cnt[i] = -1;
        }
    }
    
    for(int i = 0; i < N; i++){
        scanf("%d",&A[i]);
        if(cnt[A[i]] > 0){
            cnt[A[i]]--;
        }
        else{
            printf("0\n");
            return 0;
        }
    }
    
    for(int i = 0;i<N/2;i++){
        ans = (ans * 2) % 1000000007;
    }
    
    
    printf("%d\n",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
inline int Get(){
	static char c; c = getchar();
	while (c != '0' && c != '1') c = getchar();
	return c - '0';
}

const int N = 205;

struct Ba{
	LL B[61];
	inline bool Ins(LL x){
		int i,j;
		for (i = 60; i >= 0; --i) if (x>>i&1){
			if (B[i]){ x ^= B[i]; continue; }
			for (j = 0; j < i; ++j) if (x>>j&1) x ^= B[j];
			B[i] = x;
			for (j = i+1; j <= 60; ++j) if (B[j]>>i&1) B[j] ^= x;
			return 1;
		}
		return 0;
	}
	inline bool check(LL x){
		int i;
		for (i = 60; i >= 0; --i) if (x>>i&1){
			if (B[i]){ x ^= B[i]; continue; }
			return 0;
		}
		return 1;
	}
	inline void init(){
		memset(B,0,sizeof(B)); 
	}
	inline bool Empty(){
		for (int i = 0; i <= 60; ++i) if (B[i]) return 0;
		return 1;
	}
}B[N],now,now0; int type[N],cnt;

bool ok[61];
int n; LL a[N],p[N];
inline void solve(){
	int i,j;
	read(n);
	for (i = 1; i <= n; ++i) read(a[i]);
	for (i = 1; i <= n; ++i) p[i] = Get();
	/*
	if (p[n] == 1){ cout << 1 << '\n'; return; }
	cnt = 0;
	for (i = 1; i <= n; ++i){
		if (!cnt){
			++cnt; type[1] = p[i]; B[1].init(),B[1].Ins(a[i]);
			continue;
		}
		if (type[cnt] == p[i]){
			B[cnt].Ins(a[i]);
			continue; 
		}
		++cnt; type[cnt] = p[i]; B[cnt].init(); B[cnt].Ins(a[i]);
	}
	for (i = 0; i <= 60; ++i){
		for (j = n; j >= 1; --j) if (a[j] >> i & 1){
			if (p[j] == 1){ cout << 1 << '\n'; return; }
			break;
		}
	}
	*/
	now.init(); now0.init();
	/*
	for (i = 1; i <= n; ++i){
		if (p[i] == 0){
			now0.Ins(a[i]);
			for (j = 0; j <= 60; ++j) if (now.B[j] && now0.check(now.B[j])) now.B[j] = 0;
			continue;
		}
		now.Ins(a[i]);
		for (j = 0; j <= 60; ++j) if (now0.B[j] && now.check(now0.B[j])) now0.B[j] = 0;
		continue;
	}
	*/
	for (i = n; i; --i){
		if (p[i] == 0) now0.Ins(a[i]); else now.Ins(a[i]);
		for (j = 0; j <= 60; ++j) if (!now0.check(now.B[j])) { cout << 1 << '\n'; return; }
	}
//	if (now.Empty()) cout << 0 << '\n'; else cout << 1 << '\n';
	cout << 0 << '\n';
}

int main(){
	int T; read(T); while (T--) solve();
	return 0;
}

Measured memory_bytes: 3576
# AOJ 2809: Graduation Ceremony
# Python3 2018.7.11 bal4u

MAX = 2002
dx = (0,1,0,-1)   # URDL
dy = (-1,0,1,0)
tr = {'U':0, 'R':1, 'D':2, 'L': 3}

S = list(input())
K = int(input())
u, d, l, r = [0]*MAX, [0]*MAX, [0]*MAX, [0]*MAX
for s in S:
	dir = tr[s]
	j2 = j = K
	while j > 0:
		j -= 1
		u[j2] = min(-d[j], u[j2])+dy[dir]
		r[j2] = max(-l[j], r[j2])+dx[dir]
		d[j2] = max(-u[j], d[j2])+dy[dir]
		l[j2] = min(-r[j], l[j2])+dx[dir]
		j2 -= 1
	r[0] = l[0] = l[0]+dx[dir]
	u[0] = d[0] = d[0]+dy[dir]
ans = 0;
for i in range(K+1):
	j  = max(-l[i], r[i])
	j2 = max(-u[K-i], d[K-i])
	j += j2;
	if j > ans: ans = j
print(ans)


Measured memory_bytes: 5724
#include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<algorithm>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;


int main(){
	int P, Q, R;
	int Ans;
	cin >> P >> Q >> R;
	Ans = min({ P + Q, Q + R, R + P });
	cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(1){
    C-=B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A-=D;
    if(A<=0){
      cout << "No" << endl;
      break;
    }    
  }
  
}

Measured memory_bytes: 3632
N=int(input())
S=list(input())
T=list(input())
#print(S,T)
cnt=0
for i in range(N):
    if S==T:
        print(len(S)+cnt*2)
        exit()
    else:
        del S[0]
        del T[len(T)-1]
        #print(S,T)
        cnt+=1
print(cnt*2)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = unsigned long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return b / gcd(a, b)*a;}

int main(){
    int n;
    cin >> n;
    ll t[n];
    REP(i,n)cin >> t[i];
    ll answer = 1;
    
    FOR(i,0,n){
        answer = lcm(answer,t[i]);
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;

int main(void){
	set<int> st;

	int n, k;

	cin >> n >> k;

	vector<int> mp(n + 1, 0);

	int t;
	for (int i = 0; i < n; i++){
		cin >> t;
		st.insert(t);
		mp[t]++;
	}

	priority_queue<int> q;

	for (int i = 1; i <= n; i++){
		if (mp[i] != 0)
			q.push(-mp[i]);
	}

	int num = 0;
	if (st.size() > k){
		for (int i = 0; i < st.size() - k; i++){
			num += -q.top();
			q.pop();
		}
	}

	cout << num << endl;

	return 0;
}

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

int main()
{
	int N = 0, K = 0;
	std::cin >> N >> K;

	int *h;
	int a;
	h = new int[N];
	int i = 0;
	while (std::cin >> a){
		h[i] = a;
		i++;
		if (i == N) break;
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (h[i] >= K) ans++;
	}

	std::cout << ans << std::endl;

	delete[] h;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    cout << R / d - (L - 1) / d << endl;
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);

        long c = 1;
        while (true) {
            n /= k;
            if (n == 0) break;
            c++;
        }
        return c;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll uint64_t
using namespace std;

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    while(l <= r){
        if(l % d == 0) ans++;
        l++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3616
s = str(input())

n = len(s)
# temp = 'R'
ans = [0]*len(s)

er_= 0
or_ =0

for i in range(n):
  if s[i] == 'L' and s[i-1] == 'R':
    if i%2 == 0:
      ans[i] += er_
      ans[i-1] += or_
      er_= 0
      or_ =0
    else:
      ans[i] += or_
      ans[i-1] += er_
      er_= 0
      or_ =0
  elif s[i] == 'R':
    if i%2 == 0:
      er_ += 1
    else:
      or_ += 1
  else:
    continue

el_= 0
ol_ = 0
      
for i in reversed(range(n)):
  if s[i] == 'R' and s[i+1] == 'L':
    if i%2 == 0:
      ans[i] += el_
      ans[i+1] += ol_
      el_= 0
      ol_ = 0
    else:
      ans[i] += ol_
      ans[i+1] += el_
      el_= 0
      ol_ = 0
  elif s[i] == 'L':
    if i%2 == 0:
      el_ += 1
    else:
      ol_ += 1
  else:
    continue

print(' '.join(map(str, ans)))


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {
  string s; cin >> s;
  int n = s.size();
  cout << ((n % 2) ^ (s[0] == s.back()) ? "First\n" : "Second\n");
  return 0;
}

Measured memory_bytes: 512
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(" ");

const A = parseInt(input[0], 10);
const B = parseInt(input[1], 10);
const C = parseInt(input[2], 10);

console.log(B / A < C ? Math.floor(B / A) : C);


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> adj[100005];
bool vis[100005];
void dfs(int node,int dp[]){
    vis[node]=true;
    for(int child:adj[node]){
        if(!vis[child]){
            dfs(child,dp);
        }
        dp[node]=max(dp[node],dp[child]+1);
    }
}
int32_t main() {
    int n,m;
    cin>>n>>m;
    int dp[n+1]={0};
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i])
            dfs(i,dp);
    }
    int mx=0;
    for(int i=1;i<=n;i++){
        mx=max(mx,dp[i]);
    }
    cout<<mx<<endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	ll X, N;
	cin >> X >> N;
		
	set<ll> s;
	for(int i = 0; i < N; i++){
		ll temp;
		cin >> temp;
		s.insert(temp);
	}
	for(ll i = 0; ; i++){
		if(s.find(X-i) == s.end()){
			cout << X-i << endl;
			return;
		}
		if(s.find(X+i) == s.end()){
			cout << X+i << endl;
			return;
		}
	}
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


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

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

using namespace std;
using ll=long long;

const int INF = 100000000;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    int N = s.size();
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            if (s[i] == '0') s[i] = '1';
            else s[i] = '0';
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == '0') cnt++;
    }
    cout << min(cnt, N - cnt) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, P>IP;
int H, W, N;
char com[1000010];
char dir[1000010];
char mp[1010][1010];
int sx, sy, gx, gy;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};
int nxtT[4][1000010];
int flg[1010][1010];
int main(){

    while(cin>>H>>W>>N, H){
        for(int y=0;y<1010;y++){
            for(int x=0;x<1010;x++){
                mp[y][x] = '#';
                flg[y][x] = 1234567;
            }
        }
        for(int i=0;i<N;i++)cin>>com[i];
        for(int y=1;y<=H;y++){
            for(int x=1;x<=W;x++){
                cin>>mp[y][x];
                if(mp[y][x]=='S'){
                    sx = x;
                    sy = y;
                }
                if(mp[y][x]=='G'){
                    gx = x;
                    gy = y;
                }
            }
        }
        dir[0]=0;
        for(int i=0;i<N;i++){
            dir[i+1] = (4 + dir[i] + (com[i]=='R'?1:-1))%4;
        }
        for(int i=0;i<4;i++){
            nxtT[i][N+1] = 1234567;
            for(int j = N; j >= 0; j--){
                if(dir[j]==i)nxtT[i][j] = j;
                else nxtT[i][j] = nxtT[i][j+1];
            }
        }
        priority_queue<IP, vector<IP>, greater<IP> > Q;
        Q.push(IP(0, P(sx, sy)));
        while(!Q.empty()){
            int t = Q.top().first;
            int x = Q.top().second.first;
            int y = Q.top().second.second;
            Q.pop();
            if(t>N)break;
            if(flg[y][x] < 1234567)continue;
            flg[y][x] = t;
            for(int i=0;i<4;i++){
                if(mp[y+dy[i]][x+dx[i]]=='#')continue;
                if(flg[y+dy[i]][x+dx[i]]<1234567)continue;
                Q.push(IP(nxtT[i][t], P(x+dx[i], y+dy[i])));
            }
        }
        if(flg[gy][gx]<1234567)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 8836
from collections import Counter

n,m=[int(i) for i in input().split()]
a=[]
for i in range(m):
  s,e=[int(i) for i in input().split()]
  a.append(s)
  a.append(e)

c=Counter(a)
for i,j in c.most_common():
  if j % 2 !=0:
    print('NO')
    break
else:
  print('YES')

Measured memory_bytes: 21628
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main(){
	char s;
	cin >> s;
	if(s >= 'A' && s <= 'Z') cout << "A" << endl;
	else cout << 'a' << endl;
	return 0;
}





Measured memory_bytes: 3580
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	   
	   int A = sc.nextInt();
	   int B = sc.nextInt();
	   int C = sc.nextInt();
	  
	  if(C>=A && C<=B ) {
	   System.out.print("Yes");
   }
   else {
	   System.out.print("No");
   }
	   
		}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int money = int.Parse(Console.ReadLine());
            int happys = money / 500;
            happys = happys * 1000;
            int happyf = money % 500;
            happyf = happyf / 5;
            happyf = happyf * 5;
            Console.WriteLine(happyf + happys );
            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#define MAX(a,b)((a)>=(b)?(a):(b))
int main() {
	int a,b,c,d,L;
	scanf("%d %d %d %d %d",&L,&a,&b,&c,&d);
	printf("%d\n",L-MAX((a+c-1)/c,(b+d-1)/d));
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String result = "A";
        char ch = str.charAt(0);
        if(ch>='a' && ch<='z'){
            result = "a";
        }
        System.out.println(result);
    }
}


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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int n, l; cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(all(s));
    string ans;
    for(int i = 0; i < n; i++){
        ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type sw struct {
	vals []int
	cond int
}

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	sws := make([]sw, m)

	for i := 0; i < m; i++ {
		var n int
		fmt.Scan(&n)

		for j := 0; j < n; j++ {
			var v int
			fmt.Scan(&v)
			sws[i].vals = append(sws[i].vals, v-1)
		}
	}

	for i := 0; i < m; i++ {
		var n int
		fmt.Scan(&n)

		sws[i].cond = n
	}

	pattern := int(math.Pow(2, float64(n)))
	on_off := map[int]int{}
	re := 0

	for index := 0; index < pattern; index++ {
		for j := 0; j < n; j++ {
			on_off[j] = int(uint16(index) >> uint16(j) & 1)
		}

		ok := true
		for _, item := range sws {
			sum := 0
			for _, v := range item.vals {
				sum += on_off[v]
			}
			if item.cond != sum%2 {
				ok = false
				break
			}
		}
		if ok {
			re++
		}
	}

	fmt.Printf("%#v\n", re)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(rall(l));
  int ans = 0;
  rep(i,k){
    ans += l[i];
  }
  cout << ans << endl;
}


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

class Node{
public:
  Node* prev;
  Node* next;
  int data;
  Node(){
    prev=0;
    next=0;
    data=0;
  }
};

class List{
private:
  Node head;
public:
  List(){
    head.next=&head;
    head.prev=&head;
  }
  int insert(int a){
    Node* p = new Node();

    if(p==0){
      return -1;
    }

    Node* q = &head;
    Node* r = head.next;

    p->prev = q;
    p->next = r;
    p->data = a;

    q->next = p;
    r->prev = p;

    return 0;
  }

  int del(int a){
    Node* p;

    for(p=head.next;p!=&head;p=p->next){
      if(p->data==a){
        break;
      }
    }

    if(p==&head){
      return -2;
    }

    Node* q = p->prev;
    Node* r = p->next;

    q->next = r;
    r->prev = q;

    delete p;

    return 0;
  }

  int deleteFirst(){
    Node* p = head.next;

    if(p==&head){
      return -2;
    }

    Node* q = p->prev;
    Node* r = p->next;

    q->next = r;
    r->prev = q;

    delete p;

    return 0;
  }

  int deleteLast(){
    Node* p = head.prev;

    if(p==&head){
      return -2;
    }

    Node* q = p->prev;
    Node* r = p->next;

    q->next = r;
    r->prev = q;

    delete p;

    return 0;
  }

  void print(){
    for(Node* p=head.next;p!=&head;p=p->next){
      cout << p->data;

      if(p->next!=&head){
        cout << ' ';
      }else{
        cout << endl;
      }
    }
  }
};

int main(){
  List L;

  int n;
  cin >> n;

  for(int i=0;i<n;i++){
    char com[20];
    cin >> com;;

    if(com[0]=='i'){
      int x;
      cin >> x;

      L.insert(x);
    }else if(com[6]=='F'){
      L.deleteFirst();
    }else if(com[6]=='L'){
      L.deleteLast();
    }else{
      int x;
      cin >> x;

      L.del(x);
    }
  }

  L.print();

  return 0;
}



Measured memory_bytes: 34240
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int dp[101][10010] = {};
int v[101];
int w[101];

/*----------------------------------------------------------------*/
signed main(){

    int N,W;
	cin >> N >> W;
	rep(i,N)cin >> v[i] >> w[i];

	rep(i,N){
		rep(j,W+1){
			if(j-w[i] >= 0){
				dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
			}else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	cout << dp[N][W] << endl;
	

    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc088.contest.atcoder.jp/tasks/abc088_d


Measured memory_bytes: 10912
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)
else:
    print("ERROR")


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

int main()
{
    int n,count=0;
    cin>>n;
    vector<vector<int>> rolls(n,vector<int> (2));
    for(int i=0;i<n;i++){
     cin>>rolls[i][0]>>rolls[i][1];
    }
    for(int i=0;i<n;i++){
     
     if(rolls[i][0]==rolls[i][1]){
         ++count;
         if(count==3){
             cout<<"Yes";
             break;
         }
         
     }else
         count=0;
    }
    
    if(count<3)
     cout<<"No";
     return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string t;
    cin>>t;
    int n=t.length();
    for(auto&c:t){
        if(c=='?') cout<<'D';
        else cout<<c;
    }
    cout<<'\n';
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  list<char> s;
  string t; cin >> t;
  rep(i,t.size()){
    s.push_back(t[i]);
  }
  
  int q; cin >> q;
  bool flag = true;
  int cnt=0;
  rep(i,q){
    int t; cin >> t;
    if(t==1){
       flag = !flag;
       cnt++;
       //continue;
     }else{
      int f;
      char c;
      cin >> f >> c;
      if(f==1){
        if(flag) s.push_front(c);
        else s.push_back(c);
      }else{
        if(flag) s.push_back(c);
        else s.push_front(c);
      }
    }
    /*for(list<char>::iterator it = s.begin(); it!=s.end();it++){
      cout << *it;
    }
    cout << endl;*/
  }

  if(cnt%2==1) s.reverse();

  for(char x: s){
    cout << x;
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 10064
#include <iostream>
#include <queue>


using namespace std;

int main(int argc, const char * argv[]) {
    
    int n;
    cin>>n;
    
    priority_queue<int,vector<int>,less<int> > pq[n];
    
    int q;
    cin>>q;
    
    for(int i=0;i!=q;++i){
        int query;
        cin>>query;
        
        int t;
        cin>>t;
        
        switch (query) {
            case 0:
                int x;
                cin>>x;
                pq[t].push(x);
                break;
            case 1:
                if(pq[t].empty()) break;
                cout<<pq[t].top()<<endl;
                break;
            case 2:
                if(pq[t].empty()) break;
                pq[t].pop();
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 4080
n=int(input())
arr=list(map(int,input().split()))
dp=[float('inf')]*n

if n==0:
    print(0)
else:
    dp[0]=0
    dp[1]=abs(arr[1]-arr[0])
    for x in range(2,n):
        dp[x]=min(dp[x],dp[x-1]+abs(arr[x-1]-arr[x]))
        dp[x]=min(dp[x],dp[x-2]+abs(arr[x-2]-arr[x]))



    print(dp[n-1])


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

int main(void) {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<int> ans(N, 0);
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      ans[min(
          {j - i, abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1})]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import heapq
INF = float('inf')


def dijkstra(s, n, edges, d):
    d = [INF] * n
    d[s] = 0
    pq = [(0, s)]
    while len(pq):
        c, v = heapq.heappop(pq)
        if d[v] < c:
            continue
        for v2nvcost, nv in edges[v]:
            if c + v2nvcost < d[nv]:
                d[nv] = c + v2nvcost
                heapq.heappush(pq, (d[nv], nv))
    return d


n, m, s, t = map(int, input().split())
s -= 1
t -= 1
edges_yen = [[] for _ in range(n)]
edges_snuuk = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    edges_yen[u].append((a, v))
    edges_yen[v].append((a, u))
    edges_snuuk[u].append((b, v))
    edges_snuuk[v].append((b, u))
d = [INF] * n
d_yen = dijkstra(s, n, edges_yen, d)
d = [INF] * n
d_snuuk = dijkstra(t, n, edges_snuuk, d)
temp = [0] * n  # 場所iで両替した時の最終スヌーク
for i in range(n):
    temp[i] = 10**15 - (d_yen[i] + d_snuuk[i])

ans = [INF] * n
ans[-1] = temp[-1]
for i in range(n - 2, -1, -1):
    ans[i] = max(ans[i + 1], temp[i])
# print(d_yen)
# print(d_snuuk)
for i in range(n):
    print(ans[i])


Measured memory_bytes: 126872
def main():
    n = int(input())
    comp = list(map(int, input().split()))
    comp.sort(reverse=True)
    
    fin = n - 2
    p = comp[0]
    for i in range(1, n):
        if fin == 1:
            p += comp[i]
            break
        elif fin == 0:
            break

        p += comp[i]*2
        fin -= 2

    print(p)

if __name__ == '__main__':
    main()

Measured memory_bytes: 94216
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int N, W, dp[101][10001];
pair<int, int> mono[101];//mono[a] = (weight,price)

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

	for (int a = 1; a <= N; a++)
	{
		cin >> mono[a].second >> mono[a].first;
	}

	sort(mono, mono + N);

	for (int a = 1; a <= N; a++)
	{
		for (int b = 1; b <= W; b++)
		{
			if (b - mono[a].first >= 0)
			{
				dp[a][b] = max(dp[a - 1][b], dp[a][b - mono[a].first] + mono[a].second);
			}
			else
			{
				dp[a][b] = dp[a - 1][b];
			}
		}
	}

	sort(dp[N] + 1, dp[N] + W + 1, greater<int>());

	cout << dp[N][1] << endl;

	return 0;
}

Measured memory_bytes: 5072
#include <stdio.h>
#include <math.h>

double Px(int x[],int y[],int n,int p);
double inf(int x[],int y[],int n);

int main(void){
    int n,x[100],y[100];
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
     for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
    for(i=1;i<=3;i++) printf("%lf\n",Px(x,y,n,i));
    printf("%lf\n",inf(x,y,n));
    return 0;
}

double Px(int x[],int y[],int n,int p){
    double sum=0.0;
    for(int i=0;i<n;i++){
        sum+=pow((double)abs(x[i]-y[i]),(double)p);
    }
    return pow(sum,1.0/(double)p);
}

double inf(int x[],int y[],int n){
    int max=0,i;
    for(i=0;i<n;i++){
        if(abs(x[i]-y[i])>max) max=abs(x[i]-y[i]);
    }
    
    return (double)max;
}



Measured memory_bytes: 2104
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = int(input())
MOD = 10 ** 9 + 7

if s <= 2:
    print(0)
    sys.exit(0)

cache = {}
# dfs(0)=1が6 <= n <= 9のまとめて取る分をフォローしている
cache[0] = 1
cache[1] = cache[2] = 0
cache[3] = cache[4] = cache[5] = 1
def dfs(n):
    if n in cache:
        return cache[n]
    else:
        ans = 0
        for i in range(3, n + 1):
            ans += dfs(n - i) % MOD
        cache[n] = ans
        return cache[n]

print(dfs(s) % MOD)


Measured memory_bytes: 68556
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int N;

void dfs(string S,char mx){
  if(S.size() == N){
    cout << S << endl;
  }else{
    for(char c='a'; c<=mx; c++){
      dfs(S+c,(c==mx ? char(mx+1) : mx));
    }
  }
}
int main(){
  cin >> N;
  dfs("",'a');
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define f first
#define s second

#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vpi;


const int M = 1e9+7;


int main(){

	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt[26]={0};
	ll pow2[100005];
	for(int i=0;i<n;++i)
		++cnt[s[i]-97];

	// pow2[0]=1;
	// for(int i=1;i<100005;++i){
	// 	pow2[i] = (pow2[i-1]<<1)%M;
	// }
	ll ans=1;
	for(int i=0;i<26;++i){
		ans = (ans*(cnt[i]+1))%M;
	}

	cout<<ans-1;












	return 0;

}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	int m,f,b;
	cin>>m>>f>>b;
	if(m+f<b){
		cout<<"NA"<<endl;
	}
	else if(m>=b){
		cout<<"0"<<endl;
	}
	else{
		cout<<abs(b-m)<<endl;
	}
	return 0;
}


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

int main(){
  int X=0, sum=0, i=0, X_origin=0;
  string flag="No";
  cin >> X;
  X_origin = X;
  
  while(X/10 != 0){
    sum += X%10;
    X /= 10;
  }
  if(X_origin%(sum + X) == 0){
    flag = "Yes";
  }
  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		int r = in.nextInt();
		System.out.println(3 * r * r);
		in.close();
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < b) puts("0");
    else puts("10");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  ll n;
  cin >> n;
  ll ans=0;
  vector<ll> v=divisor(n);
  rep(i,v.size()){
    if(v[i]>1 && n/(v[i]-1)==n%(v[i]-1))ans+=v[i]-1;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 384
import math

k = int(input())
two = []
total = 0
for x in range(1, k + 1):
	for y in range(1, k + 1):
		two.append(math.gcd(x, y))

for z in range(1, k + 1):
	for i in two:
		total += math.gcd(z, i)
print(total)


Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a,b;
    cin >> a >> b;
    if( a < 10 and b < 10) cout << a * b << endl;
    else cout << - 1 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;


long long int divide(long long int h,long long w){
	if(h %2 == 0){
		return (h/2)*w;
	}
	if(w %2 == 0){
		return (w/2)*h;
	}
	
	long long int mi = min(h,w);
	long long int ma = max(h,w);
	return (ma/2)*mi;
	
}

long long int calcRes(long long int rect1,long long int rect2,long long int rect3){
	long long int ma = max(rect1,max(rect2,rect3));
	long long int mi = min(rect1,min(rect2,rect3));
	
	return ma - mi;
}

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


Measured memory_bytes: 256
h, n = gets.split.map(&:to_i)
a = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(h + 1, (1 << 31) - 1)
dp[0] = 0
h.next.times do |i|
  a.each do |x, y|
    if i + x < h && dp[i + x] > dp[i] + y
      dp[i + x] = dp[i] + y
    elsif i + x >= h && dp[h] > dp[i] + y
      dp[h] = dp[i] + y
    end
  end
end
puts dp[h]

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

int
main
(
  int argc,
  char ** argv
)
{
  std::size_t rating;

  std::cin >> rating;

  if (rating < 1200) 
  {
    std::cout << "ABC" << std::endl;
  }
  else if (rating < 2800)
  {
    std::cout << "ARC" << std::endl;
  }
  else
  {
    std::cout << "AGC" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256