akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<bool>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j,k;
  int h,w;
  cin>>h>>w;
  int a[h][w];
  int b[h][w];
  int c[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>b[i][j];
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      c[i][j]=b[i][j]-a[i][j];
      //cout<<c[i][j];
    }
    //cout<<endl;
  }

  int r=80*162;
  VVVI v(h,VVI(w,VI(2*r,0)));
  v[0][0][r+c[0][0]]=1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(i>=1){
        for(k=0;k<2*r;k++){
          if(k-c[i][j]>=0&&k-c[i][j]<2*r&&v[i-1][j][k-c[i][j]]==1){
            v[i][j][k]=1;
          }
        }
        for(k=0;k<2*r;k++){
          if(k+c[i][j]>=0&&k+c[i][j]<2*r&&v[i-1][j][k+c[i][j]]==1){
            v[i][j][k]=1;
          }
        }
      }
      if(j>=1){
        for(k=0;k<2*r;k++){
          if(k-c[i][j]>=0&&k-c[i][j]<2*r&&v[i][j-1][k-c[i][j]]==1){
            v[i][j][k]=1;
          }
        }
        for(k=0;k<2*r;k++){
          if(k+c[i][j]>=0&&k+c[i][j]<2*r&&v[i][j-1][k+c[i][j]]==1){
            v[i][j][k]=1;
          }
        }
      }
    }
  }
  int ans=inf;
  for(i=0;i<2*r;i++){
    if(v[h-1][w-1][i]==1) ans=min(ans,abs(i-r));
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 23168
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
  string n;
  cin >> n;
  reverse(n.begin(),n.end());
  int N=n.at(0)-'0';
  if(N==3){
    cout << "bon" << endl;
  }else if(N==0||N==1||N==6||N==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

bool b[9][9];
int wid, hei;
bool getBoard()
{
	memset(b, 0, sizeof(b));
	string s;
	cin >> s;
	if (s == "#")return false;
	int bx = 0, by = 0;
	for (char c : s)
	{
		switch (c)
		{
		case 'b':
			b[bx][by] = true;
			by++;
			break;
		case '/':
			bx++; wid = by; by = 0;
			break;
		default:
		{
			int i = c - '0';
			by += i;
			break;
		}
		}
	}
	hei = bx + 1;
	return true;
}
void setBoard()
{
	string s;
	for (int i = 0; i < hei; ++i)
	{
		for (int j = 0; j < wid; ++j)
		{
			if (b[i][j])s.push_back('b');
			else s.push_back('1');
		}
		s.push_back('/');
	}
	s.pop_back();
	for (int loop = 0; loop < 100; ++loop)
	{
		for (int i = 1; i < s.size(); ++i)
		{
			if ('1' <= s[i] && s[i] <= '9' && '0' <= s[i - 1] && s[i - 1] <= '9')
			{
				s[i]--;
				s[i - 1]++;
			}
		}
	}
	string t;
	for (char c : s)if (c != '0')t.push_back(c);
	cout << t << endl;
}

int main(void)
{
	while (getBoard())
	{
		int p, q, r, s;
		cin >> p >> q >> r >> s;
		b[p - 1][q - 1] = false;
		b[r - 1][s - 1] = true;
		setBoard();
	}
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
int main(){
    using namespace std;
    int n,i,x;
    cin >> n;
    for(i=3;i<=n;i++){
        x = i;
        if(x%3==0){
            cout << " " << i;
        }else{
            while(x){
                if(x%10==3){
                    cout << " " << i;
                    x = 0;
                }else{
                    x = x/10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


int main(){
	ll n,k;
	cin >> n >> k;
	cout<<min(n%k,k-n%k)<<endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100001
int n;
int prime[MAX];
int cnt[MAX]={};
void eratos() {
	for (int i=0;i<MAX;i++) {
	//全部primeと設定する
	prime[i] = 1;
	}
	prime[0] = prime[1] = 0;

	for (int i=2;i<MAX;i++) {
	if (prime[i]) {
	for (int j=i+i;j<MAX;j+=i) {
	prime[j] = 0;
	}
	}	
	}
}

void like() {
	for (int i=3;i<MAX;i++) 
	{
	if (i%2==1) {	
	if (prime[i] && prime[(i+1)/2]) {
	++cnt[i];
	}
	}
	cnt[i]+=cnt[i-1];
	}
}



int main() {
	int q;
	int l,r;
	cin >> q;
	eratos();
	like();
	for (int i=0;i<q;i++) {
	scanf("%d %d", &l, &r);
	printf("%d\n", cnt[r]-cnt[l-1]);
	}

/*	for (int i=0;i<=11;i++) {
	cout << "p "<<prime[i] << endl;
	cout << "c "<<cnt[i] << endl;
	}
*/
	return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
#include<cstring>
using namespace std;
int main() {
	int n,k;
	int num[100001] = {0};
	while(scanf("%d%d",&n,&k),(n|k)){
		memset(num,0,sizeof(num));
		for(int i = 0; i < n; i++){
			scanf("%d",&num[i]);
		}
		int sum = 0;
		for(int i = 0; i < k; i++){
			sum += num[i];
		}
		int tmp = sum;
		for(int i = k; i < n; i++){
			tmp += num[i];
			tmp -= num[i-k];
			sum = max(sum,tmp);
		}
		printf("%d\n",sum);
	}
    return 0;
}

Measured memory_bytes: 1588
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int x=sc.nextInt();
  int t=sc.nextInt();
  int count=n/x;
  if(n%x!=0)count++;
  System.out.println(count*t);
}
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long K, std::vector<long long> h){

    SORT(h);

    lli ans = INF;
    REP(i,0,N-K+1){
        chmin(ans,abs(h[i] -h[i+K-1]));
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    func(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
 
  int a = N * A;
  int b = B;
  
  if( a >= b ){
    cout << b << endl;
  } else {
    cout << a << endl;
  }
}

Measured memory_bytes: 256
s = input()
a = 0
b = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      a = a+1
    else:
      b = b+1
  else:
    if s[i] == "0":
      b = b+1
    else:
      a = a+1
if a < b:
  print(a)
else:
  print(b)

Measured memory_bytes: 9208
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll n,a;

int check(ll k,ll num) {
    ll tmp=1;
    for (int i=0;i<k+1;i++) {
        tmp*=num;
        if (tmp>n) return 1;
        else if (tmp==n) return 0;
    }
    return -1;
}

int main() {
    scanf("%lld%lld",&n,&a);
    ll ans=n;
    for (int k=1;k<=40;k++) {
        ll lo=1,hi=1000000;
        while (lo<=hi) {
            ll mid=(lo+hi)>>1;
            int x=check(k,mid);
            if (x<0) {
                lo=mid+1;
            } else if (x>0) {
                hi=mid-1;
            } else {
                hi=mid;
                break;
            }
        }
        //printf("%d %lld\n",k,hi);
        ll tmp=1;
        for (int i=0;i<k+1;i++) tmp*=hi;
        int i=0;
        while (tmp<n) {
            tmp=tmp/hi*(hi+1);
            i++;
        }//printf("i:%d\n",i);
        ans=min(ans,a*k+hi*(k+1)+i);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<utility>
#include<map>
#include<stdio.h>
using namespace std;
int main()
{
	int a, b, c;
	cin >>a >> b >> c;
	if (a*c <= b)
	{
		cout << c << endl;
	}
	else
	{
		cout << (b / (a)) << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	ll M, D; cin >> M >> D;
	ll cnt = 0;
	FOR(m, 1, M+1) {
		FOR(d, 1, D+1) {
			ll d1 = d % 10;
			ll d2 = (d / 10) % 10;

			if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) {
				cnt ++;
			}
		}
	}

	cout << cnt << endl;
	return 0;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 5 ;
int n ;
ll k , a[maxn] , b[maxn] ;
int main()
{
	scanf("%d%lld" , &n , &k) ;
	for(int i = 1 ; i <= n ; i ++)  scanf("%lld" , &a[i]) ; 
	sort(a + 1 , a + n + 1) ;
	ll x = 0 , y = 0 , z = 0 ;
	for(int i = 1 ; i <= n ; i ++)
	  if(a[i] < 0)  x ++ ;
	  else if(a[i] > 0)  y ++ ;
	  else  z ++ ;
    if(x * y >= k)
    {
    	ll l = -1e18 , r = -1 , ans = -1 ;
    	while(l <= r)
    	{
    		ll mid = (l + r) / 2 ;
    		int p = n - y + 1 ;
			ll sum = 0 ;
			for(int i = 1 ; i <= x ; i ++)
    		{
    			while(a[i] * a[p] > mid && p <= n)  p ++ ; 
    			if(p <= n && a[i] * a[p] <= mid) 
				  sum += n - p + 1 ;
			}
			if(sum >= k)   r = mid - 1 , ans = mid ;
			else  l = mid + 1 ;
		}
    	printf("%lld\n" , ans) ;
	}
	else if(x * y + x * z + y * z + z * (z - 1) / 2 >= k)   printf("0\n") ;
	else
	{
	    k -= x * y + x * z + y * z + z * (z - 1) / 2 ;
		ll l = 1 , r = 1e18 , ans = 1e18 ;
		while(l <= r)
    	{
    		ll mid = (l + r) / 2 ;
    		int nxt = x ;
			ll sum = 0 ;
			for(int i = 1 ; i <= x ; i ++)
			  b[i] = -a[x - i + 1] ;
			for(int i = 1 ; i <= x ; i ++)
			{
				if(b[i] * b[i] <= mid)  sum -- ;
				while(nxt >= 1 && b[nxt] * b[i] > mid)  nxt -- ;
				if(nxt >= 1 && b[nxt] * b[i] <= mid)  sum += nxt ;
			}
			nxt = y ;
			for(int i = 1 ; i <= y ; i ++)
			  b[i] = a[n - y + i] ;
			for(int i = 1 ; i <= y ; i ++)
			{
				if(b[i] * b[i] <= mid)  sum -- ;
				while(nxt >= 1 && b[nxt] * b[i] > mid)  nxt -- ;
				if(nxt >= 1 && b[nxt] * b[i] <= mid)  sum += nxt ;
			}
			assert(sum % 2 == 0) ;
			if(sum / 2 >= k)   r = mid - 1 , ans = mid ;
			else  l = mid + 1 ;
		} 
		printf("%lld\n" , ans) ;
	}
	return 0 ;
}

Measured memory_bytes: 3072
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
//#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

char S[200005];
int dp[3000][2];
signed main(){
    scanf("%s",S);
    int N=strlen(S);
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<2019;j++){
            dp[j][i%2]=0;
        }
        int t=S[i]-'0';
        dp[t][i%2]+=1;
        if(i==0)continue;
        
        for(int j=0;j<2019;j++){
            dp[(j*10+t)%2019][i%2]+=dp[j][(i-1)%2];
        }
        ans+=dp[0][i%2];
        //printf("%d\n",dp[0][i%2]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1900
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


long pow3(long x) { return x * x * x; }


int main()
{
    long N, K;
    cin >> N >> K;

    size_t out = 0;
    if (K <= N)
        out += pow3(N / K);
    if (K % 2 == 0)
        out += pow3((N + K / 2) / K);

    cout << out << endl;
}


Measured memory_bytes: 256
S = input()
ans = 0
ansmax = 0
if S[0] == "R":
    ans += 1
if S[1] == "R":
    ans += 1
else:
    ansmax = ans
    ans = 0
if S[2] == "R":
    ans += 1

ansmax=max(ans,ansmax)
print(ansmax)

    




Measured memory_bytes: 61612
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int n, m;
int k;

char s[1024];

int main() {
    vector <vector <int>> a;
    vector <vector <int>> dist;
    int n, m, k;
    k = max(n, m);
    scanf("%d %d", &n, &m);
    a.resize(n);

    pair <int, int> st, ed;

    scanf("%d %d", &st.first, &st.second);
    scanf("%d %d", &ed.first, &ed.second);
    -- st.first, -- st.second;
    -- ed.first, -- ed.second;

    for (int i = 0 ; i < n ; ++ i) {
        scanf("%s", s);
        for (int j = 0 ; j < m ; ++ j) {
            a[i].push_back(s[j] == '#' ? 0 : 1);
        }
    }

    dist.resize(n);
    for (int i = 0 ; i < n ; ++ i) {
        dist[i].resize(m, 0);
    }




    const int inf = 1e9;
    for (int i = 0 ; i < n; ++ i)
    for (int j = 0 ; j < m; ++ j) {
        dist[i][j] = inf;
    }

    dist[st.first][st.second] = 0;
    deque <pair <int, int>> q;

    q.push_back(st);
    while (!q.empty()) {
        auto [x, y] = q.front();
        q.pop_front();
        int cur_dist = dist[x][y];
        #define mp make_pair
        for (auto [i, j] : {mp(1, 0), mp(-1, 0), mp(0, 1), mp(0, -1)}){
            int new_x = x + i, new_y = y + j;
            if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && cur_dist < dist[new_x][new_y] && a[new_x][new_y]) {
                q.emplace_front(new_x, new_y);
                dist[new_x][new_y] = cur_dist;
            }
        }

        for (int i = -2 ; i <= 2 ; ++ i)
        for (int j = -2 ; j <= 2 ; ++ j) {
            int new_x = x + i, new_y = y + j;
            if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && cur_dist + 1 < dist[new_x][new_y] && a[new_x][new_y]) {
                dist[new_x][new_y] = cur_dist + 1;
                q.emplace_back(new_x, new_y);
            }
        }

    }

    printf("%d\n", dist[ed.first][ed.second] == inf ? -1 : dist[ed.first][ed.second]);
}


Measured memory_bytes: 11724
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,m,ans,seg[1<<19],la[1<<19];
P c[200005];
void lazy(int l,int r,int k){
    seg[k]+=la[k];
    if(l!=r){
        la[k*2+1]+=la[k];
        la[k*2+2]+=la[k];
    }
    la[k]=0;
}
void up(int a,int b,int l,int r,int k,int x){
    lazy(l,r,k);
    if(r<a||b<l)return;
    if(a<=l&&r<=b){
        la[k]+=x;
        lazy(l,r,k);
        return;
    }
    up(a,b,l,(l+r-1)/2,k*2+1,x);
    up(a,b,(l+r+1)/2,r,k*2+2,x);
    seg[k]=max(seg[k*2+1],seg[k*2+2]);
}
int que(int a,int b,int l,int r,int k){
    lazy(l,r,k);
    if(r<a||b<l)return 0;
    if(a<=l&&r<=b)return seg[k];
    return max(que(a,b,l,(l+r-1)/2,k*2+1),que(a,b,(l+r+1)/2,r,k*2+2));
}
int main(void){
    cin>>n>>m;
    ans=max(ans,n-m);
    for(int i=0;i<n;i++)scanf("%d%d",&c[i].F,&c[i].S);
    sort(c,c+n);
    for(int i=1;i<=m;i++)up(i,i,0,(1<<18)-1,0,-(m-i+1));
    for(int i=0;i<n;i++){
        up(1,c[i].S,0,(1<<18)-1,0,1);
        ans=max(ans,que(c[i].F+1,m+1,0,(1<<18)-1,0)-c[i].F);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 5504
#include <iostream>
using namespace std;
int main(){
  int N,A;cin>>N>>A;
  int L=A;int R=A+N-1;
  int eat;
  if (R<=0)eat=R;
  else if (L>=0)eat=L;
  else eat=0;
  int ans =(L+R)*(R-L+1)/2-eat;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php
list($n) = ints();
$ans = '';
while (true) {
    --$n;
    $ans .= chr(97 + $n % 26);
    $n = intdiv($n, 26);
    if ($n === 0) break;
}
echo strrev($ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16180
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}


ll N,a[100010];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	
	int i;
	for (i=1; i<=N; i++)
		cin >> a[i];
		
	ll t=0;
	for (i=1; i<=N; i++){
		ll x;
		cin >> x;
		a[i]-=x;
		t-=a[i];
	}
	
	if (t<0){
		cout << "No";
		return 0;
	}
	
	ll nec=0;
	for (i=1; i<=N; i++){
		if (a[i]<0)
			nec+=(-a[i]+1)/2;
	}
	
	cout << (nec<=t ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	
	public static int compute_maxprofit(int n, int[] R) {
		int max_profit = -999999999;
		int min = R[0];
		for(int i = 1; i < n; i++) {
			if(R[i] - min > max_profit) {
				max_profit = R[i] - min;
			}
			if(R[i] < min) {
				min = R[i];
			}
		}
		
		return max_profit;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] R = new int[n];
		for(int i = 0; i < n; i++) {
			R[i] = in.nextInt();
		}
		in.close();
		System.out.println(compute_maxprofit(n, R));
	}

}


Measured memory_bytes: 100704
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    long N;
    private void Scan()
    {
        var cin = new Scanner(Console.OpenStandardInput());
        N = cin.NextLong();
    }

    public void Solve()
    {
        Scan();
        int loop = (int)Math.Sqrt(N);
        for(int i = loop; i >= 1; i--)
        {
            if (N % i == 0)
            {
                Console.WriteLine((N / i).ToString().Length);
                return;
            }
        }
    }


}

Measured memory_bytes: 13140
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val A = sc.nextInt()
    val B = sc.nextInt()
    val K = sc.nextInt()
    val list = mutableListOf<Int>()
    for (i in Math.max(A,B) downTo 1) {
        if (A%i != 0) continue
        if (B%i != 0) continue
        list.add(i)
    }
    println(list[K-1])
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> d(n);
    rep(i,n){
        cin >> d[i].first >> d[i].second;
    }
    for(int i=0;i<n-2;i++){
        if(d[i].first!=d[i].second) continue;
        if(d[i+1].first!=d[i+1].second) continue;
        if(d[i+2].first!=d[i+2].second) continue;
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

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

int main(){
  string s;
  cin >> s;
  vector<int> v(26);
  int flag = 1;

  for(int i = 0; i < s.length(); i++){
    v.at(s.at(i) - 'a')++;
    if(v.at(s.at(i) - 'a') >= 2){
      flag = 0;
      break;
    }
  }

  if(flag){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

int main() {
	string line;
	cin >> line;
	int i = 0;
	int len = line.length();
	for (i = 0; i < len; i++) {
		if (line[i] == 'C') break;
	}
	if (i == len) {
		cout << "No" << endl;
		return 0;
	}
	for (; i < len; i++) {
		if (line[i] == 'F') break;
	}
	if (i == len) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mem(x, y) memset(x, y, sizeof(x))
#define pii pair<int, int>
#define pli pair<LL, int>
#define mkp make_pair
const int N = 200005;
int n, K, tot, bit[N];
LL a[N], sum[N], b[N];

void lsh() {
    sort(b, b + n + 1);
    tot = unique(b, b + n + 1) - b;
}

int idx(LL val) {
    return lower_bound(b, b + tot, val) - b + 1;
}

void upd(int u) {
    for(int i = u; i <= n + 1; i += i & (-i)) bit[i]++;
}

int query(int u) {
    int ret = 0;
    for(int i = u; i; i -= i & (-i)) ret += bit[i];
    return ret;
}

int main()
{
    scanf("%d%d", &n, &K);
    for(int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        a[i] -= K;
        sum[i] = sum[i - 1] + a[i];
        b[i - 1] = sum[i];
    }
    b[n] = 0;
    lsh();
    LL ans = 0;
    upd(idx(0));
    for(int i = 1; i <= n; i++) {
        ans += query(idx(sum[i]));
        upd(idx(sum[i]));
    }
    printf("%lld\n", ans);
    return 0;
}



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



int main() {

    vector<int> line(3);
    cin >> line[0] >> line[1] >> line[2];
    
    sort(line.begin(),line.end());
    
    int K; cin >> K;
    for(int i=0 ; i<K ; i++){
        line[2] *= 2;
    }
    
    cout << line[0]+line[1]+line[2] << endl;
    
}

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

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int[][] a=new int[n][2];
        for(int i=0;i<n;i++){
            a[i][0]=in.nextInt();
            a[i][1]=i+1;
        }
        Arrays.sort(a, (b, c) -> Integer.compare(b[0], c[0]));
        for(int i=0;i<n;i++){
            System.out.print(a[i][1]+" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 66692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    
    s[k-1] =  s[k-1] - 'A' +'a';
    
    cout << s << endl;
    
    return 0;
}



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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    int[] ans;
    List<int>[] to;

    void calc()
    {
        var N = cin.nextInt();
        var Q = cin.nextInt();
        to = new List<int>[N];
        for(var i = 0;i < N; i++)
        {
            to[i] = new List<int>();
        }
        
        for(var i = 0;i < N - 1; i++)
        {
            var a = cin.nextInt() - 1;
            var b = cin.nextInt() - 1;
                to[a].Add(b);
                to[b].Add(a);
            
        }
        ans = new int[N];
        for(var i = 0;i < Q; i++)
        {
            var p = cin.nextInt() - 1;
            var x = cin.nextInt();
            ans[p] += x;
        }

        dfs(0, -1);
        Console.WriteLine(string.Join(" ", ans));
    }

    void dfs(int v, int prev)
    {
        foreach(var i in to[v])
        {
            if(i == prev)
            {
                continue;
            }
            ans[i] += ans[v];
            dfs(i, v);
        }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 72216
fun main() {
    var C = mutableListOf(0, 0, 0, 0)
    val n = readLine()!!.toInt()
    for (i in 0 until n) {
        when (readLine()!!) {
            "AC"  -> C[0] += 1
            "WA"  -> C[1] += 1
            "TLE" -> C[2] += 1
            "RE"  -> C[3] += 1
        }
    }
    println("AC x ${C[0]}\nWA x ${C[1]}\nTLE x ${C[2]}\nRE x ${C[3]}\n")
}


Measured memory_bytes: 58752
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;

    if (y % 2 == 0 && 2 * x <= y && y <= 4 * x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#define MN 40002
#define MM 5000001
#define ll long long
#define ld long double
#define inf 0x7fffffff
#define clz 1000000007
#define ers(arr,val) memset(arr,val,sizeof(arr));
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,b,a) for(int i=(b);i>=(a);i--)
#define repe(i,u) for(int i=h[u];i;i=e[i].nx)
using namespace std;
int n,a[100001];
ll ans1=0,ans2=0;
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	if(n==1) return 0*puts("0");
	if(n==2) return 0*printf("%d",abs(a[1]-a[2]));
	sort(a+1,a+n+1);
	int L=a[n],R=a[n-1],l=2,r=n-2,op=0; ans1+=1ll*abs(a[n]-a[1])+1ll*abs(a[n-1]-a[1]);
	while(r-l+1>=2){
		//printf("%d %d\n",L,R);
		if(op&1) ans1+=1ll*abs(L-a[r])+1ll*abs(R-a[r-1]);
		else ans1+=1ll*abs(L-a[l])+1ll*abs(R-a[l+1]);
		if(op&1) L=a[r],R=a[r-1],r-=2;
		else L=a[l],R=a[l+1],l+=2;
		op++;
	}
	//printf("%d %d\n",L,R);
	if(r-l+1==1) ans1+=1ll*max(abs(a[r]-L),abs(a[r]-R));
	L=a[1],R=a[2],l=3,r=n-1,op=1; ans2+=1ll*abs(a[1]-a[n])+1ll*abs(a[2]-a[n]);
	while(r-l+1>=2){
		//printf("%d %d\n",L,R);
		if(op&1) ans2+=1ll*abs(L-a[r])+1ll*abs(R-a[r-1]);
		else ans2+=1ll*abs(L-a[l])+1ll*abs(R-a[l+1]);
		if(op&1) L=a[r],R=a[r-1],r-=2;
		else L=a[l],R=a[l+1],l+=2;
		op++;
	}
	//printf("%d %d\n",L,R);
	if(r-l+1==1) ans2+=1ll*max(abs(a[r]-L),abs(a[r]-R));
	printf("%lld",max(ans1,ans2));
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int a;
	cin >> a;
	int h, m, s;
	h = (a / 3600); a %= 3600;
	m = (a / 60); a %= 60;
	s = a;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}



Measured memory_bytes: 3112
from networkx import*
(N,M,S,T,*r),*t=[map(int,t.split())for t in open(0)]
G=Graph()
for u,v,a,b in t:G.add_edge(u,v,y=a,s=b)
b=m=10**15
y,s=map(eval(dir()[763]),(G,G),(S,T),(m,m),'ys')
while N:b=min(b,y[N]+s[N]);r+=m-b,;N-=1
print(*r[::-1])

Measured memory_bytes: 208460
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) ((a < 0) ? -a : a)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

int main() {
	int n = ri();
	char s[32];
	snprintf(s, 32, "%d", n);
	
	int res = 0;
	for (char* ptr = s; *ptr; ptr++) {
		res += (*ptr - '0');
	}
	
	if (res == 1) res = 10;
	
	printf("%d", res);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N;
  cin>>N;
  vector<ll> A(N), B(N), C(N);
  vector<vector<ll>> Q(N, vector<ll>(3, 0));
  rep(i, N){
    cin>>A[i]>>B[i]>>C[i];
    Q[i][0]=A[i];Q[i][1]=B[i];Q[i][2]=C[i];
      }
  vector<vector<ll>> dp(N, vector<ll>(3, 0));
  dp[0][0]=A[0];
  dp[0][1]=B[0];
  dp[0][2]=C[0];
  rep(i, N-1){
    rep(j, 3){
      rep(k, 3){
        if(j!=k)dp[i+1][j]=max(dp[i+1][j], dp[i][k]+Q[i+1][j]);
      }
    }
  }
  ll Ans=max(dp[N-1][0], dp[N-1][1]);
  Ans=max(Ans, dp[N-1][2]);
  cout<<Ans<<endl;
  /*rep(i,N){
    rep(j, 3){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
} 

Measured memory_bytes: 16444
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;
const int maxn=1e5+8;
int a[maxn]={0};
int main()
{
    int n,i,b,k=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>b;
        if(b<=n)
            a[b]++;
        else
            k++;
    }
    for(i=0;i<=n;i++)
    {
        if(a[i]==0) continue;
        if(a[i]<i)
            k+=a[i];
        if(a[i]>i)
            k+=(a[i]-i);
    }
    cout<<k<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
namespace mp=boost::multiprecision;
typedef long long ll;
typedef unsigned long long ull;
using bint=mp::cpp_int;

int main(){
  int n,m;
  cin>>n>>m;
  if(n<=m) co("unsafe");
  else co("safe");
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);


template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,T,S; cin >> N >> T >> S;
	V<ll> A(N+1,0),B(N+1,0);
	FOR(i,1,N+1) cin >> A[i] >> B[i];
	V<V<ll>> dp(N+1,V<ll>(T+1,0));
	for(int i = 1; i <= N; ++i){
		for(int j = 0; j <= T; ++j){
			chmax(dp[i][j],dp[i-1][j]);
			if(j+B[i]>T) continue;
			if(j<S&&S<j+B[i]) continue;
			chmax(dp[i][j+B[i]],dp[i-1][j]+A[i]);
		}
	}
	ll ans = 0;
	for(int j = 0; j <= T; ++j) chmax(ans,dp[N][j]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 73284
x,y=map(int,input().split())
if x==1 or x==3 or x==5 or x== 7 or x==8 or x==12 or x==10:
    if y==1 or y==3 or y==5 or y==7 or y==8 or y==10 or y==12:
        print('Yes')
    else:
        print('No')
elif x==4 or x==6 or x==9 or x==11:
    if y==4 or y==6 or y==9 or y==11:
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)

int memo[202020];

int f(int x) {
  if (x == 0) return 0;
  if (memo[x] >= 0) return memo[x];
  int p = __builtin_popcount(x);
  return memo[x] = f(x % p) + 1;
}

int modpow(int b, int e, int p) {
  if (e == 0) return 1;
  return modpow(b * b % p, e / 2, p) * (e % 2 ? b : 1) % p;
}

signed main() {
  fill(memo, memo + 202020, -1);

  int n;
  cin >> n;
  string x;
  cin >> x;

  int p = 0;
  for (auto c : x)
    if (c == '1') p++;

  reverse(x.begin(), x.end());

  int one = 0, zero = 0, b_one = 1, b_zero = 1;
  for (auto c : x) {
    if (c == '1') {
      one += b_one;
      if (p > 1) one %= p - 1;
      zero += b_zero;
      zero %= p + 1;
    }
    b_one *= 2;
    if (p > 1) b_one %= p - 1;
    b_zero *= 2;
    b_zero %= p + 1;
  }

  reverse(x.begin(), x.end());

  rep(i, 0, n) {
    if (x[i] == '1') {
      if (p == 1)
        cout << 0 << endl;
      else {
        int t = (one - modpow(2, n - 1 - i, p - 1) + p - 1) % (p - 1);
        cout << f(t) + 1 << endl;
      }
    } else {
      int t = (zero + modpow(2, n - 1 - i, p + 1)) % (p + 1);
      cout << f(t) + 1 << endl;
    }
  }

  return 0;
}

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

int main(){

  int n;
  cin>>n;
  vector<long long int> l(n+1);
  l.at(0)=2;
  l.at(1)=1;

  for(int i=2;i<n+1;i++){

    l.at(i)=l.at(i-1)+l.at(i-2);


  }

  cout<<l.at(n)<<endl;






  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 3030;
char a[N],b[N];
int f[N][N];
char ans[N];
int n,m;
int main()
{
	cin >> a >> b;
	int m = strlen(a);
	int n = strlen(b); 
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			f[i][j] = max(f[i-1][j],f[i][j-1]);
			if(a[i-1]==b[j-1]) f[i][j] = max(f[i-1][j-1]+1,f[i][j]);
		}
	}
	int i = m, j = n;
	while(f[i][j])
	{
		if(a[i-1] == b[j-1])
		{
			ans[f[i][j]] = a[i-1];
			i--;
			j--;
		}else{
			if(f[i][j] == f[i-1][j]) i--;
			else j--;
		}
	}
	cout << ans + 1 << endl;
} 


Measured memory_bytes: 35712
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	switch A, B := nextInt(), nextInt(); {
	case A >= 13:
		fmt.Println(B)
	case A >= 6 && A <= 12:
		fmt.Println(B / 2)
	default:
		fmt.Println(0)
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int m, n;
    cin >> m >> n;
    int a[n];
    rep(i,n)cin >> a[i];

    int ans = 0;
    if(m == 2){
        int tmp1 = 0, tmp2 = 0;
        rep(i,n){
            if((i + a[i]) % 2 == 0){
                tmp1++;
            }else{
                tmp2++;
            }
        }
        ans = min(tmp1, tmp2);
        cout << ans << endl;
        return 0;
    }

    int dp[n][2];

    rep(i,n){
        if(i == 0){
            dp[i][0] = 0;
            dp[i][1] = 1;
        }else{
            dp[i][0] = dp[i-1][1];
            if(a[i] != a[i-1])dp[i][0] = min(dp[i][0], dp[i-1][0]);
            dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
        }
    }

    ans = min(dp[n-1][0], dp[n-1][1]);

    cout << ans << endl;
    return 0;
}
 
 



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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<int, Pii> iPii;
int N;
int M;
int T[200010];
multiset<int> D;
int main(int argc, char **argv, char **envp) {
  cin >> N;
  REP(i,N) {
    int d;
    scanf("%d", &d);
    D.insert(d);
  }
  cin >> M;
  REP(i,M) {
    int t;
    scanf("%d", &t);
    if (D.count(t)==0) goto FAILURE;
    D.erase(D.find(t));
  }

  printf("YES\n");
  return 0;
  FAILURE:
  printf("NO\n");
  return 0;
}


Measured memory_bytes: 11264
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const ll MAX = (ll)1e12+10;

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

    ll N;
    cin >> N;

    ll ans = MAX;
    REP(i, sqrt(N)+100) {
        if (i == 0 or i == 1) continue;
        if (N % i == 0) {
            ans = min(ans, (ll)i+(N/i)-2);
        }
    }
    if (ans == MAX) ans = N-1;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2040
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = CInt(NextString())
        Dim flg As Boolean

        For c As Integer = 0 To N \ 4
            For d As Integer = 0 To N \ 7
                If c * 4 + d * 7 = N Then flg = True
            Next
        Next

        WriteLine(New String() {"No", "Yes"}(B2I(flg)))
    End Sub


    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 21968