akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N,M;
vi hoge;
int fuga[214514];
int main(){
	cin>>N;
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;a--;
		hoge.pb(a);
	}
	for(int i=0;i<N;i++){
		fuga[hoge[i]]=i;
	}
	int cnt=1;
	int ma=1;
	for(int i=1;i<N;i++){
		if(fuga[i]>fuga[i-1]){
			cnt++;
		}else{
			cnt=1;
		}
		ma=max(ma,cnt);
	}
	ma=max(ma,cnt);
	cout<<N-ma<<endl;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int x=0,y=0,ans=0;
int main()
{
    cin>>a;
    for (int i=0;i<sizeof(a);i++)
     if (x==y){x++; if(a[i]=='p') ans--;}     
     else{y++; if(a[i]=='g') ans++;}         
    printf("%d\n",ans);                      
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      return 1LL;
    }
    else{
      ++it;
    }
  }
  return 0LL;
}
bool comp(const string& a,const string& b){
  return a.size() < b.size();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
    sort(all(s[i]));
  }
  sort(all(s),comp);
  string ans ;
  rep(i,s[0].size()){
    char c = s[0][i];
    int k = 1;
    REP(j,1,n){
      k += FindErase(s[j],c);
    }
    if(k == n){
      ans += c;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

typedef struct complex {
  int r,i;
} complex;

complex z1, z2;

/* add your algorithm here */

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  int x3,y3,x4,y4;
  int x, y;

  x = c - a, y = d - b;

  x3 = c - y;
  y3 = d + x;
  x4 = a - y;
  y4 = b + x;

  printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String args[]) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String parts[] = br.readLine().split(" ");
		
		int H = Integer.parseInt(parts[0]);
		int A = Integer.parseInt(parts[1]);
		
		int a = H%A;
		
		if(a==0) {
			System.out.println(H/A);
		}else {
			System.out.println(H/A+1);
		}
		
	}

}


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

using namespace std;
using ll = long long;
int main(){
  ll n;
  cin>>n;
  string ans;
  while(n){
    n--;
    ans+='a'+n%26;
    n/=26;

  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

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

int main() {
  
  int N, K, ans = 1;
  cin >> N >> K;

  for (int i = 0; i < N; i++){
    if (ans <= K){
      ans *= 2;
    }
    else {
      ans += K;
    }
  }
  cout << ans << endl;
}


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

D = int(input())
c = list(map(int, input().split()))

last = [0] * 26

ans = 0
max_M = 0
tmp_t = 0
t = []
mm = []
ll = []

for i in range(D):
    # リストを読む
    s = list(map(int, input().split()))
    # 1日経つ
    last = list(map(lambda x: x + 1, last))
    # マイナスの合計を出す
    minus = 0
    for x in range(26):
        minus = minus + (c[x] * last[x])
    # 一番高い結果の判定
    max_M = 0                                                       
    for y in range(26):
        if max_M < s[y] + (c[y] * last[y]) - minus:
            max_M = s[y] + (c[y] * last[y]) - minus
            tmp_t = y                                                               
    # 判定後
    mm.append(max_M)
    ll.append(last)
    t.append(tmp_t + 1  )
    last[tmp_t] = 0

print(*t, sep='\n')

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

using ll = long long;
using vi = vector<int>;
// Loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

#define ALL(v) v.begin(), v.end()

const int INF = 10000;


int main(void) {
	int x, n;
	int diff = INF;
	int ans  = 100;
	cin >> x >> n;

	int itemp;
	bool q[110];
	rep(i, 110) { q[i] = false; }
	rep(i, n) {
		cin >> itemp;
		q[itemp] = true;
	}
	REP(i, 0, 110) {
		if(q[i]) {
			continue;
		}
		int dtemp = abs(x - i);
		if(diff == dtemp) {
			cout << ans << endl;
			return 0;
		}
		if(diff > dtemp) {
			diff = dtemp;
			ans  = i;
		}
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;

  vpl xy(n);
  REP(i,n)cin>>xy[i].SE>>xy[i].FI;

  sort(ALL(xy));
  vpl y_mx,y_px;
  REP(i,n){
    y_mx.push_back(pll(xy[i].FI-xy[i].SE,i));
    y_px.push_back(pll(xy[i].FI+xy[i].SE,i));
  }
  sort(ALL(y_mx),greater<pll>());
  sort(ALL(y_px),greater<pll>());

  vll idm(n),idp(n);
  REP(i,n){
    idm[i]=y_mx[i].SE;
    idp[i]=y_px[i].SE;
  }

  vll tablem(n,-1);
  vll tablep(n,-1);
  ll nowm=0;
  ll nowp=0;
  REP(i,n){
    if(nowm<idm[i]){
      for(ll j=nowm; j<idm[i]; j++){
        tablem[j]=idm[i];
      }
      nowm=idm[i];
    }
    if(nowp<idp[i]){
      for(ll j=nowp; j<idp[i]; j++){
        tablep[j]=idp[i];
      }
      nowp=idp[i];
    }
  }

  ll ans=0;
  REP(i,n){
    ll dm=-LLINF;
    ll dp=-LLINF;

    if(i!=n-1){
      ll im=tablem[i];
      dm=abs(xy[i].FI-xy[im].FI)+abs(xy[i].SE-xy[im].SE);
    }

    if(i!=n-1){
      ll ip=tablep[i];
      dp=abs(xy[i].FI-xy[ip].FI)+abs(xy[i].SE-xy[ip].SE);
    }

    ans=max(ans,max(dm,dp));
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 18948
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {
    char c;
    cin >> c;
    c++;
    cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define pi 3.141592653589793
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  long double a, b, x, half, h, ans, v;
  cin >> a >> b >> x;
  half = a * a * b / 2;
  if (x >= half) {
    h = 2 * (b - x / (a * a));
    v = atan2(h, a);
    ans = v * 180 / pi;
  }
  else {
    h = 2 * x / (a * b);
    v = atan2(h, b);
    ans = 90 - (v * 180 / pi);
  }

  cout << setprecision(10) << ans << endl;
  



  
  return 0;
}

Measured memory_bytes: 256
def league(n, graph)
  queue = []
  check = ->(i) {
    return if graph[i].empty?
    opponent = graph[i][0]
    return if graph[opponent].empty?
    if graph[opponent][0] == i
      queue << [i, opponent]
    end
  }

  0.upto(n - 1) { |i| check.call(i) }
  ans = 0
  until queue.empty?
    ans += 1
    prev_queue = queue
    queue = []
    until prev_queue.empty?
      pair = prev_queue.shift
      if graph[pair[0]][0] == pair[1] && graph[pair[1]][0] == pair[0]
        graph[pair[0]].shift
        graph[pair[1]].shift
        check.call(pair[0])
        check.call(pair[1])
      end
    end
  end

  ans = -1 if graph.any? { |e| !e.empty? }
  puts ans
end

n = gets.to_i
graph = []
n.times{ graph << gets.split.map{|i| i.to_i - 1 } }
puts league(n, graph)

Measured memory_bytes: 11644
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);

const int N = 1e5 + 5;
int t;

int main()
{
	string a;
	while (cin >>a)
	{
		
		string x = '1' + a;
		int fg = 0;
		string y = x.substr(1, (a.size() - 1) / 2);
		string yy = y; reverse(y.begin(), y.end());
		//debug(y);
		//debug(yy);
		if (yy == y)fg++;
		int k = a.size() - (a.size() + 3) / 2;
		y = x.substr((a.size() + 3) / 2, k+1);
		yy = y;reverse(y.begin(), y.end());
		//debug(y);
		//debug(yy);
		if (yy == y)fg++;
		string b = a;
		reverse(a.begin(), a.end());
		if (a == b)fg++;
		if (fg == 3)puts("Yes");
		else puts("No");
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

const int MOD = 1e9 + 7;

void add(int& x, int y)
{
	x += y;
	if(x >= MOD)
		x -= MOD;
}

void sub(int& x, int y)
{
	x -= y;
	if(x >= MOD)
		x -= MOD;

	if(x < 0)
		x += MOD;
}

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

	int i, j, k, n;
	cin >> n;
	vector<vector<ll>> dp(n, vector<ll>(n, 1e18));
	vector<ll> pre(n);

	for(i=0;i<n;++i)
	{
		int temp;
		cin>>temp;
		dp[i][i] = 0;
		if(!i)
			pre[i] = temp;
		else
			pre[i] = pre[i-1] + temp;
	}

	for(i=n-1;i>=0;--i)
	{
		for(j=0;j<n;++j)
		{
			if(i >= j)
				continue;
			//trace(i, j);
			for(k=i;k<j;++k)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + pre[j] - ((i-1 >= 0) ? pre[i-1] : 0));
		}
	}

	cout << dp[0][n-1] << "\n";

	return 0;
}

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	string s, t;
	cin >> s >> t;
	vector<int> pos[26];
	REP(i, s.size()){
		pos[s[i]-'a'].pb(i);
		pos[s[i]-'a'].pb(i+s.size());
	}
	REP(i, 26) sort(ALL(pos[i]));
	ll ans = 0;
	ll cp = -1;
	REP(i, t.size()){
		int c = t[i]-'a';
		if(pos[c].size()==0){
			cout << -1 << endl;
			return 0;
		}
		int next = upper_bound(ALL(pos[c]), cp) - pos[c].begin();
		ll np = pos[c][next];
		ans += np-cp;
		cp = np%(s.size());
	}
	cout << ans << endl;
	return 0;
} 


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

int main()
{
    string S, T;
    int ans = 0;
    cin >> S >> T;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import copy

H,W,K = input().split()
H = int(H)
W = int(W)
K = int(K)
c = list(input() for i in range(H))
for j in range(H):
    c[j] = list(c[j])
    
def wise(a,masu):#a行の塗りつぶし
    for w in range(W):
        masu[a][w] = 'r'
    return masu
        
def hight(b,ban):#b列の塗りつぶし
    for h in range(H):
        ban[h][b] = 'r'    
    return ban

count = 0
#2**(H+W)は2進数で1 << (H+W)と書ける
for j in range(1<<(H+W)):
    bunsin = copy.deepcopy(c)#コピーを定義しておくことでCの形を戻す
    for k in range((H+W)):
        mask = 1 << k
        if j & mask != 0:
            if k < W:#列の処理
                hight(k, bunsin)
                
            else :#行の処理
                wise(k - W, bunsin)
              
    new_c = []
    for l in range(H):#copyから'#を取り出す'
        for m in range(W):
            new_c.append(bunsin[l][m])
    count_black = new_c.count('#')
    if count_black == K:
        count += 1
print(count)

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

int a[MAXN];

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

    int n,k;
    cin >> n >> k;
    rep(i,1,n) cin >> a[i];
    sort(a+1,a+1+n);
    int res_n = max(0,n-k);
    ll ans = 0;
    rep(i,1,res_n) ans += a[i];
    cout << ans << endl;
}




Measured memory_bytes: 1024
Module Program
  Sub Main
    Dim s = Gets()(0)(0)
    Dim t = Gets()(0)(1)
    Dim u = Gets()(0)(2)
    Dim ans=s+t+u
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 20688
/*
	Templates start.
	Powered by c++11.
	Author : Alex_Wei.
*/

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

// IO templates.

char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#ifdef __WIN64
	#define gc getchar()
#else
	#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#define pc(x) (*O++=x)
#define flush() fwrite(obuf,O-obuf,1,stdout)

inline int read(){
	int x=0,sign=0; char s=getchar();
	while(!isdigit(s))sign|=s=='-',s=getchar();
	while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
	return sign?-x:x;
}
void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

/*
	Templates end.
	Please give me more points.
*/

int x;

int main(){
	cin>>x;
	cout<<(x/500)*1000+(x%500/5)*5;
	
	return 0; 
}

Measured memory_bytes: 256
/*                                                  Alpha_The_Coder
                                                  Created on 20/08/2020                                                     */

#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
void solve();
int main()
{
    iamalpha;
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}
void solve()
{
    vector<int>height;
    int n;cin>>n;
    int h;
    loop(0,n)
    {
        cin>>h;
        height.push_back(h);
    }
    lli minimum_height=0;

    loop(1,n)
    {
        if(height[i]<height[i-1])
            {
                minimum_height+=abs(height[i]-height[i-1]);
                height[i]=height[i-1];
            }
    }
    cout<<minimum_height;

}

// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 4208
#include<stdio.h>
#define N 10000
#define q 500
int linearSearch(int *,int,int);


int main(){
  int a[N],x,y,i,j,count=0,r;

  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&a[i]);
  }
   scanf("%d",&y);
  for(i=0;i<y;i++){
    scanf("%d",&r);
    j=linearSearch(a,x,r);
    if(j==1) count++;
  }

  printf("%d\n",count);
  
  return 0;
}


int linearSearch(int *a,int x,int key){
  int i=0;
  a[x] = key;

  while(key!=a[i]){
    i++;
  }
  if(i==x) return 0;
  return 1;
  
}

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

int main()
{
  int b=0;
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='A'){
      for(int j=i+1;j<a.size();j++){
	if(a[j]=='A') break;
	if(a[j]=='Z'){
	  b++;
	  break;
	}
      }
    }
  }
  for(int i=0;i<b;i++) cout<<"AZ";
  if(b==0) cout<<-1;
  cout<<endl;
}


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

using namespace std;

int main()
{
    int X, fiveHundred, five, Sum;
    cin >> X;

    fiveHundred = X / 500;
    Sum = X - (500 * fiveHundred);
    five = Sum / 5;

    cout << (1000 * fiveHundred) + (5 * five);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define got(container,num) get<num-1>(container)
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m

using namespace std;
const int INF=LLONG_MAX-1e10;
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

main()
{
    IOS
    fu(i,1,3)cin>>a[i];
    n=(a[3]+a[2]);
    m=a[1]/n;
    out(m*a[2]+min(a[1]-m*n,a[2]))
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2005,mod=1000000007;
ll pr[N],pi[N];
ll power(ll x,ll y){
	ll re=1;
	while(y>0){
		if(y%2)re=re*x%mod;
		y=y/2;
		x=x*x%mod;
	}
	return re;
}
ll ncr(ll n,ll r){
	return ((pr[n]*pi[r])%mod)*pi[n-r]%mod;
}
int main(){
	ll n,k;cin>>n>>k;
	pr[0]=1;
	pi[0]=1;
	for(ll i=1;i<N;i++){
		pr[i]=i*pr[i-1]%mod;
		pi[i]=power(pr[i],mod-2);
	}
	//for(ll i=1;i<=n;i++)cout<<pr[i]<<" ";cout<<endl;
	//for(ll i=1;i<=n;i++)cout<<pi[i]<<" ";cout<<endl;
	for(ll i=1;i<=k;i++){
		ll ans=0;
		if(n-k+1>=i)
		ans=ncr(n-k+1,i)*ncr(k-1,i-1)%mod;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n, c = 0;
  cin >> n;
  vector<int> v(n), a(n);
  rep(i, 0, n) {
    cin >> v[i];
  }
  rep(i, 0, n) {
    cin >> a[i];
  }
  rep(i, 0, n) {
    if(v[i] > a[i]) {
      c += v[i] - a[i];
    }
  }
  cout << c;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;

int main(){
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vector<int> p(A); for(int i=0;i<A;i++) cin >> p[i];
    vector<int> q(B); for(int i=0;i<B;i++) cin >> q[i];
    vector<int> r(C); for(int i=0;i<C;i++) cin >> r[i];
    
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    
    vector<int> d;
    for(int i=0;i<X;i++) d.push_back(p[i]);
    for(int i=0;i<Y;i++) d.push_back(q[i]);
    for(int i=0;i<C;i++) d.push_back(r[i]);
    
    sort(d.rbegin(),d.rend());
    
    long long sum=0;
    for(int i=0;i<X+Y;i++){
        sum+=d[i];
    }
    cout << sum << endl;
    return 0;
 
}


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

long long int sod[10000001]={0};

void solve()
{   long long int N;
	cin>>N;
	for(int i = 1; i <= N; i++) {
       for(int j = i; j <= N; j += i) {
           sod[j] ++;
       }
   }
	
	long long int sum=0;
	for(int i=1;i<=N;i++)
		sum += (i*sod[i]);
		
	cout<<sum<<endl;

}

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

Measured memory_bytes: 81696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	fast
	ll n;
	cin>>n;
	vec a(n);
	map<ll,ll> wow;
	ll sum=0;
	floop(i,0,n)
	{cin>>a[i]; wow[a[i]]++; sum+=a[i];}
	ll q;
	cin>>q;
	while(q--)
	{
		ll b,c;
		cin>>b>>c;
		wow[c]+=wow[b];
		sum+=wow[b]*(c-b);
		cout<<sum<<"\n";
		wow.erase(b);
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int x, y, b, p;
    for (int i=0; i<N; ++i) {
        cin >> x >> y >> b >> p;
        int res = min(x*b+y*p, (max(b, 5)*x+max(p, 2)*y)*4/5);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '0 1.5 1 1'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


x1,y1,x2,y2 = line[0].split(" ").map(&:to_f)

d =  ((x2-x1)**2 + (y2-y1)**2)**(0.5)

printf("%.10f\n",d)

Measured memory_bytes: 9428
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(f => Int64.Parse(f)).ToArray();
        var x = l[0]; var t = l[1];

        Console.WriteLine((x - t >= 0) ? x - t : 0);
    }
}


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

int main() {
  int n, l, m;
  cin >> n >> l;
  m = l;
  for(int i = 1; i < n; i++){
    if(m < 0)
      m++;
  }
  cout << n * (n - 1) / 2 + n * l - m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    int l=s.length();
    if(s[l-1]=='2' || s[l-1]=='4' || s[l-1]=='5' || s[l-1]=='7' || s[l-1]=='9') cout<<"hon"<<endl;
    if(s[l-1]=='0' || s[l-1]=='1' || s[l-1]=='6' || s[l-1]=='8') cout<<"pon"<<endl;
    if(s[l-1]=='3') cout<<"bon";
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,(1<<4)){
    string now;
    bool f1=(i & (1<<3)),f2=(i & (1<<2)),f3=(i & (1<<1)),f4=(i & (1<<0));
    if(f1) now.push_back('A');
    now+=("KIH");
    if(f2) now.push_back('A');
    now+="B";
    if(f3) now.push_back('A');
    now+="R";
    if(f4) now.push_back('A');
    if(now==s){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	double n, k;
	cin >> n >> k;
	int ans = -(log(n) / log(k));
	cout << 1 - ans << endl;
}


Measured memory_bytes: 256
bingo = []
for i in range(3):
    arr = list(map(int, input().split()))
    bingo.append(arr)
n = int(input())
for i in range(n):
    cursor = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == cursor:
                bingo[j][k] = 0
flag = False
for i in bingo:
    if sum(i) == 0:
        flag = True
for i in range(3):
    if bingo[0][i] + bingo[1][i] + bingo[2][i] == 0:
        flag = True
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[0][2] + bingo[1][1] + bingo[2][0]
if cross1 == 0 or cross2 == 0:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int cnt=0;
    bool flag=true;
    while(flag){
        for(int i=0;i<n;i++){
            if(a[i]%2==0){
                a[i]=a[i]/2;
            }else{
                flag=false;
            }
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int ans[40];
    int i=0;
    do{
        ans[i] = (n%2 <0)? 1:n%2;
        n -= ans[i];
        n /= -2;i++;
    }while(n);
    
    for(i--;i>=0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt()-1;
        int b=sc.nextInt()-1;
        int c=sc.nextInt()-1;
        int d=sc.nextInt()-1;
        String[]s=sc.next().split("",0);
        if(c<d){
            boolean po=true;
            if(c-a>2){
                for(int i=a+1;i<c-1;i++){
                    if((s[i]+s[i+1]).equals("##")){
                        po=false;
                        break;
                    }
                } 
            }
            if(d-b>2){
                for(int i=b+1;i<d-1;i++){
                    if((s[i]+s[i+1]).equals("##")){
                        po=false;
                        break;
                    }
                } 
            }
            System.out.println(po?"Yes":"No");
        }
        else{
            boolean po=true;
            if(c-a>2){
                for(int i=a+1;i<c-1;i++){
                    if((s[i]+s[i+1]).equals("##")){
                        po=false;
                        break;
                    }
                } 
            }
            if(po){
                po=false;
                for(int i=b-1;i<d;i++){
                    //System.out.println(s[i]+s[i+1]+s[i+2]);
                    if((s[i]+s[i+1]+s[i+2]).equals("...")){
                        po=true;
                        break;
                    }
                } 
            }
            System.out.println(po?"Yes":"No");
        }
    }
}


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

int w, h;
vector<vector<int>> d;
vector<vector<vector<vector<int>>>> flg;
int movel(int x, int y){
    if(d[x-1][y]==1) return x;
    return x-1;
}
int mover(int x, int y){
    if(d[x+1][y]==1) return x;
    return x+1;
}
int moveu(int x, int y){
    if(d[x][y-1]==1) return y;
    return y-1;
}
int moved(int x, int y){
    if(d[x][y+1]==1) return y;
    return y+1;
}

int bfs(int tx, int ty, int kx, int ky){
    flg.assign(w+2,vector<vector<vector<int>>>(h+2,vector<vector<int>>(w+2,vector<int>(h+2,0))));
    queue<vector<int>> q;
    q.push({tx, ty, kx, ky, 0});
    flg[tx][ty][kx][ty]=1;

    while(!q.empty()){
        int vtx = q.front()[0];
        int vty = q.front()[1];
        int vkx = q.front()[2];
        int vky = q.front()[3];
        int vcnt = q.front()[4];
        q.pop();

        if(vtx==vkx && vty==vky) return vcnt;
        if(vcnt+1<100){
            if(1!=flg[mover(vtx,vty)][vty][movel(vkx, vky)][vky]){
                q.push({mover(vtx,vty),vty,movel(vkx, vky),vky,vcnt+1});
                flg[mover(vtx,vty)][vty][movel(vkx, vky)][vky]=1;
            }
            if(1!=flg[movel(vtx,vty)][vty][mover(vkx, vky)][vky]){
                q.push({movel(vtx,vty),vty,mover(vkx, vky),vky,vcnt+1});
                flg[movel(vtx,vty)][vty][mover(vkx, vky)][vky]=1;
            }
            if(1!=flg[vtx][moveu(vtx,vty)][vkx][moved(vkx, vky)]){
                q.push({vtx,moveu(vtx,vty),vkx,moved(vkx, vky),vcnt+1});
                flg[vtx][moveu(vtx,vty)][vkx][moved(vkx, vky)]=1;
            }
            if(1!=flg[vtx][moved(vtx,vty)][vkx][moveu(vkx, vky)]){
                q.push({vtx,moved(vtx,vty),vkx,moveu(vkx, vky),vcnt+1});
                flg[vtx][moved(vtx,vty)][vkx][moveu(vkx, vky)]=1;
            }
        }
    }
    return -1;
}

int main(){
    while(1){
        cin >> w >> h;
        if(w==0) break;
        int tx, ty, kx, ky;
        cin >> tx >> ty;
        cin >> kx >> ky;
        d.assign(w+2, vector<int>(h+2,1));
        for(int i=1; i<h+1; i++){
            for(int j=1; j<w+1; j++){
                cin >> d[j][i];
            }
        }
        int ans=bfs(tx, ty, kx, ky);
        if(ans==-1){
            cout << "NA" << endl;
        }else{
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 46692
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, L, *a = map(int, read().split())
knot = -1
for idx, (i, j) in enumerate(zip(a, a[1:])):
    if i + j >= L:
        knot = idx + 1
        print('Possible')
        break
else:
    print('Impossible')
    exit()

answer = list(range(1, knot)) + list(range(knot + 1, N))[::-1] + [knot]
print('\n'.join(map(str, answer)))


Measured memory_bytes: 17868
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split(" ");
const n = +input[0];
let sum = 1;

  for(let i=2;i<=n;i++){
    if(!((i%3==0 && i%5==0) || i%3==0 || i%5==0)){
      sum += i;
    }
  }
console.log(sum);
}

Measured memory_bytes: 35176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] weights = new int[n];
		int[] values = new int[n];
		long[][] dp = new long[n+1][w+1];
		
		for (int i = 0; i < n; i++) {
			weights[i] = sc.nextInt();
			values[i] = sc.nextInt();
		}
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				if (j >= weights[i-1]) {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j - weights[i-1]] + values[i-1]);
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		System.out.println(dp[n][w]);
		
		sc.close();
	}

}


Measured memory_bytes: 126416
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,d=1,n,max=-1,k,ans=0;
    string s,s2;
    cin >> n >> s;
    VI e(26);
    VI f(26);
    for(int i=1;i<n;i++){
        for(char o = 'a'; o<='z';o++){
            bool left =false,right=false;
            for(int j=0;j<i;j++)
				if(s[j]==o)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==o)
					right=true;

            if(left&&right){
                c++;
            }
        }
        if(max < c){
            max = c;
        }
        c=0;
    }
    cout << max <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int k,n,ans;
int num[10];
 
void dfs(int x,int borrow,int cntk){
  if(x==n){
    if(cntk<=k){
      int t=0;
      for(int i=n-1;i>=0;i--)t=t*10+num[i];
      ans=max(ans,t);
    }
  }else{
    int A=a[x]-'0',B=b[x]-'0';
    if(A-borrow>=B){
      num[x]=A-borrow-B;
      dfs(x+1,0,cntk);
    }else{
      num[x]=A-borrow+10-B;
      dfs(x+1,0,cntk+1);
      dfs(x+1,1,cntk);
    }
  }
}
 
int main(){
  cin>>a>>b>>k;
  n=max(a.size(),b.size());
  for(int i=a.size();i<n;i++)a='0'+a;
  for(int i=b.size();i<n;i++)b='0'+b;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  dfs(0,0,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
s = input()
count = 0
a, qa, c, qc = 0, 0, 0, 0
def calc(x, qx, y, qy):
    return ((3*x+qx) * (3*y+qy) * pow3q)
#x*y*pow(3,qx+qy)+qx*y*pow(3,qx+qy-1)+x*qy*pow(3,qx+qy-1)+qx*qy*pow(3,qx+qy-2)
for i in range(len(s)):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        qc += 1
    else:
        continue
pow3q = pow(3, qc-3)
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'C':
        c -= 1
    elif s[i] == 'B':
        count += 3*calc(a, qa, c, qc)
    else:
        qc -= 1
        count += calc(a, qa, c, qc)
        qa += 1
print(int(count) % 1000000007)

Measured memory_bytes: 3188
import java.util.Scanner;
//int[] date=new int[2];
public class Main {
int i,o,sum,h,s,e,u,ty,yu,ui,n,num,qw;
double m,t,r,j,k,f,d,g,w;
static double l;
String b,c,z,x,v,a,q;
Scanner scan =new Scanner(System.in);
//入力
	public void input() {	
	
	}
	//演算
	public void compute() {
	
		}
//出力
	public void output() {
	int[] date=new int[2];
	for(o=0;o<2;o++) {
		date[o]=scan.nextInt();
	}
	if(date[0]<=date[1]) {
		System.out.println("unsafe");
	}else {
		System.out.println("safe");
	}
		}
	public static void main(String [ ] args) {
		Main p = new  Main ();
		p.input();
		p.compute();
		p.output();
		}
	}

Measured memory_bytes: 35700
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

// void __print(int x) {cerr << x;}
// void __print(long x) {cerr << x;}
// void __print(long long x) {cerr << x;}
// void __print(unsigned x) {cerr << x;}
// void __print(unsigned long x) {cerr << x;}
// void __print(unsigned long long x) {cerr << x;}
// void __print(float x) {cerr << x;}
// void __print(double x) {cerr << x;}
// void __print(long double x) {cerr << x;}
// void __print(char x) {cerr << '' << x << '';}
// void __print(const char *x) {cerr << '"' << x << '"';}
// void __print(const string &x) {cerr << '"' << x << '"';}
// void __print(bool x) {cerr << (x ? "true" : "false");}

// template<typename T, typename V>
// void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
// template<typename T>
// void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
// void _print() {cerr << "]\n";}
// template <typename T, typename... V>
// void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
// #ifndef ONLINE_JUDGE
// #define debug(x...) cerr << "[" << #x << /"] = ["; _print(x)
// #else
// #define debug(x...)
// #endif

int main()
{
    //fastio
    ll x;
    sfl(x);
    if(x==0) cout<<1;
    else cout<<0;
    
    return 0;
}

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

long long n, m, h[100005], a, b, cnt;
bool good[100005];

int main(){
	cin>>n>>m;
	for(int i=1; i<=n; i++){
		good[i]=true;
	}
	for(int i=1; i<=n; i++){
		cin>>h[i];
	}
	for(int i=1; i<=m; i++){
		cin>>a>>b;
		if(h[a]>h[b]){
			good[b]=false;
		}
		if(h[b]>h[a]){
			good[a]=false;
		}
		if(h[b]==h[a]){
			good[a]=false;
			good[b]=false;
		}
	}
	for(int i=1; i<=n; i++){
		if(good[i]==true){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 4496
#include<bits/stdc++.h>
using namespace std;
int vis[1000];
int main(){
    int n,m,k,x;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            vis[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(vis[i]==n)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define F(i) for(int i=0;i<n;i++)
int x[100100];
int main(){
	int n,k;
	cin>>n>>k;
	F(i)cin>>x[i];
	LL ans=1e12;
	F(i){
		int e=i+k-1;
		if(e<n){
			ans=min(ans,(LL)min(abs(x[e])+x[e]-x[i],abs(x[i])+x[e]-x[i]));
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int a,b,c;
    cin >> a>>b>>c;
    if((a==b&&b!=c)||(b==c&&b!=a)||(a==c&&b!=c)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
R, S, P = map(int, input().split())
t = input()
ans = 0
hand = []
for i in t:
    if i == "r":
        hand.append("p")
    if i == "s":
        hand.append("r")
    if i == "p":
        hand.append("s")
for i, h in enumerate(t):
    if i >= k:
        if h == "r":
            if hand[i-k] != "p":
                ans += P
            else:
                if i+k <= n-1:
                    if hand[i+k] == "r":
                        hand[i] = "s"
                    else:
                        hand[i] = "r"
                else:
                    hand[i] = "r"
        if h == "s":
            if hand[i-k] != "r":
                ans += R
            else:
                if i+k <= n-1:
                    if hand[i+k] == "s":
                        hand[i] = "p"
                    else:
                        hand[i] = "s"
                else:
                    hand[i] = "s"
        if h == "p":
            if hand[i-k] != "s":
                ans += S
            else:
                if i+k <= n-1:
                    if hand[i+k] == "p":
                        hand[i] = "r"
                    else:
                        hand[i] = "p"
                else:
                    hand[i] = "p"
    else:
        if h == "r":
            ans += P
        if h == "s":
            ans += R
        if h == "p":
            ans += S
print(ans)

Measured memory_bytes: 46704