akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
constexpr int IINF = INT_MAX;

int n;
vector<vector<P> > g;
vector<int> d;

void dfs(int now){
    for(auto e : g[now]){
        int nxt = e.first, t = e.second;
        if(d[nxt] > d[now] + t){
            d[nxt] = d[now] + t;
            dfs(nxt);
        }
    }
}

int main(){
    while(cin >> n, n){
        g.clear();
        g.resize(n);
        d.resize(n);
        int ans = 0;
        for(int i=0;i<n-1;i++){
            int a, b, t;
            cin >> a >> b >> t;
            a--; b--;
            g[a].push_back(P(b,t));
            g[b].push_back(P(a,t));
            ans += t*2;
        }
        fill(d.begin(),d.end(), IINF);
        d[0] = 0;
        dfs(0);
        int dmax = 0;
        for(int i=1;i<n;i++){
            if(g[i].size() > 1){
                dmax = max(dmax, d[i]);
            }
            else {
                ans -= g[i][0].second*2;
            }
        }
        ans -= dmax;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll a,b,c; cin >> a >> b >> c;

	ll d = c-(a+b);

	string res;
	if(d < 0){
		res = "No";
	}
	else{
		if(4*a*b < d*d) res = "Yes";
		else res = "No";
	}

	cout << res << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#define MAX 100000
#define NIL -1


using namespace std;

struct Node{int parent,left,right;};
Node T[MAX];
int n;

void initialize(){
  for(int i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
}

int getdepth(int x){
  int depth=0;
  while(T[x].parent!=NIL){
    x=T[x].parent;
    depth++;
  }
  return depth;
}

string getstate(int x){
  if(T[x].parent==NIL) return "root";
  else if(T[x].left==NIL) return "leaf";
  else return "internal node";
}

void display(){
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",
    i,T[i].parent,getdepth(i),getstate(i).c_str());
    if(T[i].left!=NIL){
      printf("%d",T[i].left);
      int x=T[T[i].left].right;
      while(x!=NIL){
        printf(", %d",x);
        x=T[x].right;
      }
    }
    printf("%s\n","]");
  }
}

int main(){
  scanf("%d",&n);
  initialize();
  for(int i=0;i<n;i++){
    int idx,nc;
    scanf("%d %d",&idx,&nc);
    if(nc>0){
      int c[nc];
      scanf("%d",&c[0]);
      T[idx].left=c[0];
      T[c[0]].parent=idx;
      for(int i=1;i<nc;i++){
        scanf("%d",&c[i]);
        T[c[i-1]].right=c[i];
        T[c[i]].parent=idx;
      }
    }
  }
  display();
}

Measured memory_bytes: 4704
n,m = map(int,input().split())
MOD=1000000007

dp=[0]*(n+1)
dp[0]=1

for _ in range(m):
    dp[int(input())]=-1

for i in range(n+1):
    if dp[i]==-1:
        continue

    if i+1<=n and dp[i+1]!=-1:
        dp[i+1]=(dp[i+1]+dp[i])%MOD
    if i+2<=n and dp[i+2]!=-1:
        dp[i+2]=(dp[i+2]+dp[i])%MOD

print(dp[-1])


Measured memory_bytes: 12816
n = int(input())
p = list(map(int, input().split()))

ans = []

def judge(l):
    if l[0]<l[1]<l[2]:
        return True
    elif l[0]>l[1]>l[2]:
        return True
    else:
        return False

for i in range(n-2):
    ans.append(judge(p[i:i+3]))

print(sum(ans))

Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


w, h, x, y = LI()
if w/2 == x and h/2 == y:
    print(h*w/2, 1)
else:
    print(h*w/2, 0)

Measured memory_bytes: 41328
#include <iostream>

using namespace std;

int main(void)
{
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    int a[3], b[3];
    for (int i = 0; i <= 101; i++) {
        if (i == 101) {
            cout << "No" << endl;
            break;
        }
        if (c[0][0] - i >= 0 && c[1][0] - i >= 0 && c[2][0] - i >= 0) {
            a[0] = i; b[0] = c[0][0] - i; b[1] = c[1][0] - i; b[2] = c[2][0] - i;
            a[1] = c[0][1] - b[0];
            if (a[1] + b[1] == c[1][1] && a[1] + b[2] == c[2][1]) {
                a[2] = c[0][2] - b[0];
                if (a[2] + b[1] == c[1][2] && a[2] + b[2] == c[2][2]) {
                    cout << "Yes" << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

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

const int INF = 1e9;

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

	vector<int> dp(n+1, INF);
	dp[0] = 0;
	for (int i=0;i<m;i++) {
		for (int j=0;j+c[i]<=n;j++) {
			dp[j+c[i]] = min(dp[j+c[i]], dp[j]+1);
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 3208
using System;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var array = input.Split(' ');
            var n = int.Parse(array[0]);
            var a = int.Parse(array[1]);
            var b = int.Parse(array[2]);
            var result = 0;
            
            for (var i = 1; i <= n; i++)
            {
                var sum = GetSum(i);

                if (a <= sum && sum <= b)
                {
                    result += i;
                }
            }
            
            Console.WriteLine(result);
        }

        static int GetSum(int x)
        {
            var n = x;
            var sum = 0;
            while (0 < n)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}

Measured memory_bytes: 27524
#include<bits/stdc++.h>
using namespace std;
int su[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&su[i]);
	}
	sort(su, su+n);
	if(su[0] == su[n-1]){
		if((su[0] == (n-1)) || su[0] <= n/2){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else if(su[n-1] - su[0] == 1){
		int gae = 0;
		for(int i=0;i<n;i++){
			if(su[i] != su[0]){
				gae = i;
				break;
			}
		}
		if(gae == n-1){
			printf("No\n");
		}else{
			if((((n-gae)/2) + gae < su[0]+1) || (gae > su[0]) ){
				printf("No\n");
			}else{
				printf("Yes\n");
			}
		}
	}else{
		printf("No\n");
	}
}

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  vector<vector<int64_t>> dp(110, vector<int64_t>(100100, 0));
  for (int k = 1; k <= N; k++) {
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      if (sum_w >= w.at(k - 1)) {
        dp.at(k).at(sum_w) = max(dp.at(k - 1).at(sum_w), v.at(k - 1) + dp.at(k - 1).at(sum_w - w.at(k - 1)));
      }
      else {
        dp.at(k).at(sum_w) = dp.at(k - 1).at(sum_w);
      }
    }
  }
  // for (int i = 0; i < 10; i++) {
  //   for (int j = 0; j < 20; j++) {
  //     cout << dp.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
  cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 87296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  

  
  string S;
  cin >> S;
  
  map<string, int> week;  // 名前→成績
  week["SUN"] = 0;
  week["MON"] = 1;
  week["TUE"] = 2;
  week["WED"] = 3;
  week["THU"] = 4;
  week["FRI"] = 5;
  week["SAT"] = 6;
  
  
  cout << 7-week.at(S) << endl;
  
  
}

Measured memory_bytes: 256
n,k=map(int,input().split())
lists=list(map(int,input().split()))

import math
import fractions
flag=True
#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fractions.gcd(num,lists[i])
        return num
if k%union_gcd(lists)==0 and k<=max(lists):
    flag=True
else:
    flag=False
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 82196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const ll INF = 1LL<<60;
int main(){
	int N;
	cin >> N;
	vector<int> X(N);
	rep(i,N){
		cin >> X[i];
	}
	ll ans = INF;
	
	REP(i,100){
		//座標iで開催するとする。
		ll tairyoku = 0;
		rep(j,N){
			tairyoku += (X[j]-i)*(X[j]-i);
		}
		ans = min(ans,tairyoku);
	}
	
	cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int x,int y){
		int r = 1;
		while(1){
			if(y&1)r=mul(r,x);
			if(y>>=1)x=mul(x,x);else
				break;
		}
		return r;
	}
};
/*####*/

modular_arithmetic ma;

int n;bool ff;
vector<int> e[5005];
int sz[5005];

int m,a[5005];
void dfs(int x,int fat){
	sz[x] = 1;
	int mx = 0;
	for(vector<int>::iterator it = e[x].begin(); it != e[x].end(); it++){
		int y = *it;
		if(y == fat)continue;
		dfs(y, x);
		sz[x] += sz[y];
		if(sz[y] + sz[y] == n){
			ff = true;
		}
		mx = max(mx, sz[y]);
	}
	mx = max(mx, n - sz[x]);
	if(mx + mx < n){
		a[m++] = n-sz[x];
		for(vector<int>::iterator it = e[x].begin(); it != e[x].end(); it++){
			int y = *it;
			if(y == fat)continue;
			a[m++] = sz[y];
		}
	}
}

int fac[5005],ifac[5005];
void init(){
	fac[0] = 1;
	for(int i=1; i<=n; i++)
		fac[i] = ma.mul(fac[i-1],i);
	ifac[n] = ma.pw(fac[n],ma.mod-2);
	for(int i=n; i>=1; i--)
		ifac[i-1] = ma.mul(ifac[i], i);
}

int d[5005],d2[5005];
int solve(){
	memset(d,0,sizeof(d));
	d[0] = 1;
	int N = 0;
	for(int i=0; i<m; i++){
		memset(d2,0,sizeof(d2));
		for(int j=0; j<=N; j++)if(d[j])
			for(int k=0; k<=a[i]; k++){
				int W = ma.mul(fac[a[i]], ifac[a[i]-k]);
				W = ma.mul(W, W);
				W = ma.mul(W, ifac[k]);
				d2[j+k] = ma.add(d2[j+k], ma.mul(d[j], W));
			}
		memcpy(d,d2,sizeof(d2));
		N += a[i];
	}

	int res = 0;
	for(int i=0; i<=N; i++){
		int cur = ma.mul(d[i], fac[N-i]);
		if(i%2)res = ma.sub(res, cur);else
			res = ma.add(res, cur);
	}
	return res;
}


int solve_1(){
	init();
	int ret = solve();
	a[m++] = 1;
	return ma.add(ret, solve());
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	ff = false;
	dfs(1,1);
	if(ff){
		int res = 1;
		for(int i=1; i+i<=n; i++)
			res = ma.mul(res, i);
		res = ma.mul(res, res);
		printf("%d\n",res);
	}else{
		printf("%d\n",solve_1());
	}
	return 0;
}


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

#define int long long

using namespace std;

const int maxn = 110, maxl = 1e5 + 10;
int w[maxn], v[maxn], dp[maxn][maxl], n, W;

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> W;

    memset(dp, 63, sizeof dp);
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < v[i]; j++)
            dp[i][j] = dp[i - 1][j];
        for (int j = v[i]; j < maxl; j++)
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
    }

    for (int i = maxl; ~i; i--)
        if (dp[n - 1][i] <= W)
            return cout << i, 0;

    return 0;
}


Measured memory_bytes: 86272
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N,M;
    cin >> N >> M;
    int Sx[N],Sy[N],Cx[M],Cy[M];
    int ans[N]={};
    int dis[N];
    rep(i,N) dis[i]=INF;
    rep(i,N) cin >> Sx[i] >> Sy[i];
    rep(i,M) cin >> Cx[i] >> Cy[i];
    rep(i,N){
        rep(j,M){
            int dis2=abs(Sx[i]-Cx[j])+abs(Sy[i]-Cy[j]);
            if(dis[i]>dis2) dis[i]=dis2,ans[i]=j+1;
        }
    }
    rep(i,N) cout << ans[i] << endl;
}

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

template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

int solve(int N, int K){
    const int MAX = 510000;
    auto func = [&](int a, int b) { return max(a, b); };
    SegTree<int> seg(MAX, func, 0);
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        int left = max(0, a - K);
        int right = min(MAX, a + K + 1);
        int val = seg.get(left, right);
        seg.update(a, val + 1);
    }
    return seg.get(0, MAX);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    cout << solve(n, k) << endl;
}

Measured memory_bytes: 7404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);for(int i=0;i<N;i++)cin>>A[i];
  deque<int>cols(1,-1);
  for(int i=0;i<N;i++){
    auto itr=lower_bound(cols.begin(),cols.end(),A[i]);
    if(itr==cols.begin())cols.push_front(A[i]);
    else {itr--;*itr=A[i];}
  }
  cout<<cols.size();
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

int main(){

	int t;
	cin>>t;
	while(1){
		if(t==0)
			break;
		t--;
		int gx,gy;
		cin>>gx>>gy;
		int p;
		cin>>p;
		long long dp[2][16][16];
		int field[16][16];
		bool mttb[16][16][16][16];
		memset(mttb,0,sizeof(mttb));
		const int INF=-1;
		memset(field,0,sizeof(field));
		memset(dp,0,sizeof(dp));
		for(int i = 0; i < 2; i++)
			for(int j = 0; j < 16; j++)
				for(int k = 0; k < 16; k++)
					dp[i][j][k]=0;
		for(int i = 0; i < p; i++){
			int minx,miny,maxx,maxy;
			cin>>minx>>miny>>maxx>>maxy;
			if(minx>maxx){
				swap(minx,maxx);
				swap(miny,maxy);
			}
			if(miny>maxy){
				swap(miny,maxy);
				swap(minx,maxx);
			}
			mttb[miny][minx][maxy][maxx]=true;
			mttb[maxy][maxx][miny][minx]=true;
			//for(int j = minx; j <= maxx; j++)
			//	for(int k = miny; k <= maxy; k++)
			//		field[k][j]=1;
		}
		dp[0][0][0]=1;
		int v=0;
		bool f=false;
		while(1){
			f=false;
			for(int i = 0; i <= gy; i++){
				for(int j = 0; j <= gx; j++){
					if(i-1>=0&&dp[v][i-1][j]&&!mttb[i-1][j][i][j]){
						f=true;
						dp[v^1][i][j]+=dp[v][i-1][j];
					}
					if(j-1>=0&&dp[v][i][j-1]&&!mttb[i][j-1][i][j]){
						f=true;
						dp[v^1][i][j]+=dp[v][i][j-1];
					}
				}
			}
			if(dp[v^1][gy][gx]>=1){
				v^=1;
				break;
			}
			if(!f)
				break;
			for(int i = 0; i <= gy; i++){
				for(int j = 0; j <= gx; j++){
					dp[v][i][j]=0;
				}
			}
			v^=1;
		}
		if(!f)
			cout<<"Miserable Hokusai!"<<endl;
		else
			cout<<dp[v][gy][gx]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
def make_divisors(n):
    '''
    nの約数リストを返す
    '''
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 and i % 2 == 1:
            divisors.append(i)
            if i != n // i and n//i % 2 == 1:
                divisors.append(n//i)
    # divisors.sort()
    return divisors


N = int(input())
ans = 0
for i in range(1, N+1):
    divisors = make_divisors(i)
    if len(divisors) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3060
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    min_costs = [0 for i in range(N)]
    min_costs[1] = abs(h[1] - h[0])


    for i in range(2, N):
        min_cost = 1000000000
        for j in range(1, K+1):
            if i-j < 0: break
            cost = abs(h[i] - h[i-j]) + min_costs[i-j]
            if cost < min_cost:
                min_cost = cost
        min_costs[i] = min_cost

    
    print(min_costs[N-1])



if __name__ == '__main__':
    main()



Measured memory_bytes: 56544
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

#define LOCAL  1
#define UPLOAD 2

#define ll long long
const long long INF = 1LL << 60;

template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

const long long mod=1e9+7;
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  ll W = input();
  std::vector<std::pair<ll,ll>> values;
  for(int i=0;i<N;i++){
    values.push_back({input(),input()});
  }

  vector<vector<ll>> dp(N+1, vector<ll>(W+1));

  for(ll i=0;i<N;i++){
    for(ll w=0;w<=W;w++){
      if(values[i].first <= w){
        chmax(dp[i+1][w], dp[i][w-values[i].first] + values[i].second);
      }
      chmax(dp[i+1][w], dp[i][w]); 
    }  
  }

  output(dp[N][W]);

  return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define For(i, j, k) for(register int i = (j); i <= (k); ++i)
#define Forr(i, j, k) for(register int i = (j); i >= (k); --i)
using namespace std;

template <typename T>
inline void read(T &x){
	T p = 1, c = getchar();
	x = 0;
	while(!isdigit(c)){
		if(c == '-') p = -1;
		c = getchar();
	}
	while(isdigit(c)){
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= p;
}

template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

inline void File(){
#ifndef ONLINE_JUDGE
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif
}

typedef long long ll;
int n;
ll sum = LONG_MAX, flag, x, y, ans;

int main(){
	read(n);
	For(i, 1, n){
		read(x), read(y);
		if(x != y) flag = 1;
		ans += x;
		if(x > y) chkmin(sum, y);
	}
	if(!flag) printf("0\n");
	else printf("%lld\n", ans - sum);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void)
{
    int i,n,cnt = 0;
    scanf("%d",&n);
    int a[n];
    for(i = 0; i < n; i++)
        scanf("%d",&a[i]);
    
    qsort(a,n,sizeof(int),compare_int);
    
    for(i = 0; i < n - 1; i++)
    {
        if(a[i] == a[i + 1])
        {
            cnt++;
            break;
        }
        
    }
    if(cnt == 1)
        printf("NO");
    else
        printf("YES");
        
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
 // int a; cin>>a;
  string s; cin>>s;
  
  cout<< s.substr(0,3) <<endl;
  
}


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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int N, D;
  cin >> N >> D;
  vector<int> X(N);
  vector<int> Y(N);
  rep(i, N) {
    cin >> X[i];
    cin >> Y[i];
  }

  int cnt = 0;
  rep(i, N) {
    double distance = sqrt(pow(X[i], 2) + pow(Y[i], 2));
    if (distance <= D) {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
  string s,t;
  cin>>s>>t;
  while(s.size()>t.size())t='0'+t;
  while(t.size()>s.size())s='0'+s;
  if(s==t)cout<<"EQUAL"<<endl;
  else if(s>t)cout<<"GREATER"<<endl;
  else cout<<"LESS"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define root2 1.4142135623
#define mod 998244353
#define ll long long
using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;
    
    long long a;
    cin>>a;
    cout<<a + a*a + a*a*a;
    
    return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL;   
typedef unsigned long long uLL;

const int maxn=30+7,B=19;

int n,len,k,cur_len,s[maxn],a[maxn];
bool mark;

LL cur,ans;

int main()
{
    scanf("%d",&n);
    while (n)
    {
        a[++len]=n%10;
        n/=10;
    }

    ans=0;
    for (int S=0;S<(1<<B);++S)
    {
        memset(s,0,sizeof(s));
        dep(j,B,1) if (S&(1<<(j-1))) s[j]=a[j]-10,++s[j+1]; else s[j]=a[j];

        k=B;
        while (s[k]==0) --k;

        rep(cur_len,k,30)
        {
            mark=1,cur=1;

            if ((cur_len&1)&&(s[(cur_len>>1)+1]!=0)) continue;
            if (cur_len&1) cur=10;

            // printf("%d\n",S);
            // rep(j,1,cur_len) printf("%d ",s[j]);
            // printf("\n");

            rep(j,1,(cur_len>>1))
                if ((s[j]!=(-s[cur_len-j+1]))||(abs(s[j])==10)) {mark=0;break;} else cur=cur*(LL)((j==1)?(9-abs(s[j])):(10-abs(s[j])));

            if (mark) ans+=cur;
        }
    }

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

    // system("pause");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define FOR(i, a, b) for(int i = (a);i <= (b); i++)
#define ROF(i, a, b) for(int i = (a);i >= (b); i--)
const int N = 2e5 + 11;
int n;
int cnt[N], a[N];
LL ans;
LL cal(LL x){
    return x * (x - 1) / 2;
}
int main(){
    cin>>n;
    FOR(i, 1, n){
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    FOR(i, 1, n)ans += cal(cnt[i]);
    FOR(i, 1, n){
        ans -= cnt[a[i]] - 1;
        printf("%lld\n", ans);
        ans += cnt[a[i]] - 1;
    }
    return 0;
}




Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vi a(n);
	Foz(i, n) cin >> a[i];
	int ans = 0;
	Foz(i, n) ans += a[i] - 1;
	cout << ans << '\n';
}



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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

int A[MAXN + 2];

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> A[i];
	sort(A, A + N);
	int vmax = 0, smax = 0;
	for(int i = 1; i < N; i++) {
		if(A[i] == A[i - 1]) {
			if(A[i] >= vmax) {
				smax = vmax;
				vmax = A[i];
			} else if(A[i] > smax) {
				smax = A[i];
			}
			i++;
		}
	}
	cout << ((ll)vmax * smax) << endl;
}


Measured memory_bytes: 640
l, r = map(int, input().split())
mod1 = []
mod2 = []
cccc=0
for i in range(l,r+1):
  b=i%2019
  mod1.append(b)
  if b==0:
    cccc=1
    break
#print(mod1)
if cccc==1:
  print(0)
else:
  for i in range(len(mod1)-1):
    for j in range(i+1,len(mod1)):
      mod2.append((mod1[i]*mod1[j])%2019)
	#print(mod2)
  print(min(mod2))



Measured memory_bytes: 75436
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int n; cin >> n;
        string s; cin >> s;
        bool ret[n+1] = {0};
        for(auto k : {0,1}){
            for(auto j : {0,1}){
                ret[0] = k, ret[1] = j;
                rep(i,1,n){
                    if(s[i] == 'o') ret[i+1] = ret[i-1];
                    else ret[i+1] = !ret[i-1];
                    if(!ret[i]) ret[i+1] = !ret[i+1];
                }
                bool ans0;
                if(s[0] == 'o') ans0 = ret[1];
                else ans0 = !ret[1];
                if(!ret[0]) ans0 = !ans0;
                if(ans0 != ret[n-1] || ret[0] != ret[n]) continue;
                rep(i,0,n){
                    if(ret[i]) cout << "S";
                    else cout << "W";
                }
                return 0;
            }
        }
        cout << "-1" << endl;

    }
}

Measured memory_bytes: 720
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main() {
	long n;
	char ret[40];
	long index = 0;
	long sho, amari;
	scanf("%ld", &n);
	if (n == 0) {
		printf("0\n");
		return 0;
	}
	sho = n;
	//計算
	while( ( sho!= 0) ){
		amari = sho % (-2);
		if ( amari !=0 ) {
			sho=sho-1;
		}
		ret[index] = amari*amari;
		sho = sho / (-2);
		index++;
	}
	index--;
	//結果表示
	for (; index >= 0; index--) {
		printf("%d", ret[index]);
	}
	printf("\n");
	return 0;
}




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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1), cnt(n+1), c(n+1);
    ll sum = 0;
    for(int i=1; i<=n; ++i){
        int A;
        cin >> A;
        a[i] = A;
        cnt[A]++;
    }
    for(int i=1; i<=n; ++i){
        c[i] = cnt[i]*(cnt[i]-1)/2;
        sum += c[i];
    }
    for(int i=1; i<=n; ++i){
        ll ans = sum - (cnt[a[i]] - 1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MAX_N = 1e5;

int par[MAX_N + 1];
int rank0[MAX_N + 1];
int num[MAX_N + 1];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rank0[i] = 0;
        num[i] = 1;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank0[x] < rank0[y]) {
        par[x] = y; num[y] += num[x];
    } else {
        par[y] = x; num[x] += num[y];
        if (rank0[x] == rank0[y]) rank0[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    init(n);
    int a[m], b[m];
    int fri[n] = {}, bro[n] = {};
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        unite(a[i] - 1, b[i] - 1);
        fri[a[i] - 1]++; fri[b[i] - 1]++;
    }
    int c[k], d[k];
    for (int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
        if (same(c[i] - 1, d[i] - 1)) {
            bro[c[i] - 1]++; bro[d[i] - 1]++;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << num[find(i)] - 1 - fri[i] - bro[i] << endl;
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
  while(1){
    int H, W, i, j, kabe;
    scanf("%d%d", &W, &H);
    if(H == 0 && W == 0){
      return 0;
    }
    vector<vector<int>> D(H, vector<int>(W, inf));
    vector<vector<vector<int>>> can_go(H, vector<vector<int>>(W, vector<int>(4, 0)));
    for(i = 0; i < 2 * H - 1; i++){
      if(i % 2 == 0){
        for(j = 0; j < W - 1; j++){
          scanf("%d", &kabe);
          if(kabe == 0){
    //        printf("(%d, %d, %d)\n", i / 2, j, 1);
    //        printf("(%d, %d, %d)\n", i / 2, j + 1, 3);
            can_go[i / 2][j][1] = 1;
            can_go[i / 2][j + 1][3] = 1;
          }
        }
      }
      else{
        for(j = 0; j < W; j++){
          scanf("%d", &kabe);
          if(kabe == 0){
    //        printf("(%d, %d, %d)\n", i / 2, j, 2);
    //        printf("(%d, %d, %d)\n", i / 2 + 1, j, 0);
            can_go[i / 2][j][2] = 1;
            can_go[i / 2 + 1][j][0] = 1;
          }
        }
      }
    }
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    queue<pair<pair<int, int>, int>> q;
    q.push(pair<pair<int, int>, int>(pair<int, int>(0, 0), 1));
    while(q.size() > 0){
      int x = q.front().first.first;
      int y = q.front().first.second;
      int v = q.front().second;
  //    printf("(x, y, v) = (%d, %d, %d)\n", x, y, v);
      q.pop();
      if(x < 0 || H < x || y < 0 || W < y || D[x][y] <= v){
        continue;
      }
      D[x][y] = v;
      for(int d = 0; d < 4; d++){
        if(can_go[x][y][d] == 1){
  //        printf("go(%d)\n", d);
          q.push(pair<pair<int, int>, int>(pair<int, int>(x + dx[d], y + dy[d]), v + 1));
        }
      }
    }
  /*  for(i = 0; i < H; i++){
      for(j = 0; j < W; j++){
        printf("%d ", D[i][j]);
      }
      printf("\n");
    }
*/    if(D[H - 1][W - 1] >= inf){
      printf("0\n");
    }
    else{
      printf("%d\n", D[H - 1][W - 1]);
    }
  }
}



Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

const lli mod = 1000000007;

lli pw(lli x, lli n) {
    if (n < 0) {
        return 0;
    } else if (n == 0) {
        return 1;
    } else if (n % 2) {
        return (pw(x, n - 1) * x) % mod;
    } else {
        lli t = pw(x, n / 2);
        return (t * t) % mod;
    }
}

int main() {
    string S;
    cin >> S;
    int Q = 0;
    REP(i, 0, S.size()) {
        Q += (S[i] == '?');
    }
    auto A = make_v(S.size(), 0LL);
    auto Qa = make_v(S.size(), 0LL);
    auto C = make_v(S.size(), 0LL);
    auto Qc = make_v(S.size(), 0LL);
    REP(i, 0, S.size() - 1) {
        if (S[i] == 'A') {
            A[i + 1]++;
        }
        if (S[i] == '?') {
            Qa[i + 1]++;
        }
        A[i + 1] += A[i];
        Qa[i + 1] += Qa[i];
    }
    for (int i = S.size() - 1; i > 0; i--) {
        if (S[i] == 'C') {
            C[i - 1]++;
        }
        if (S[i] == '?') {
            Qc[i - 1]++;
        }
        C[i - 1] += C[i];
        Qc[i - 1] += Qc[i];
    }
    lli ans = 0;
    REP(i, 0, S.size()) {
        if (S[i] == 'B') {
            ans = (ans + ((((A[i] * C[i]) % mod) % mod) * pw(3, Q))) % mod;
            ans = (ans + ((((Qa[i] * C[i]) % mod) % mod) * pw(3, Q - 1))) % mod;
            ans = (ans + ((((A[i] * Qc[i]) % mod) % mod) * pw(3, Q - 1))) % mod;
            ans = (ans + ((((Qa[i] * Qc[i]) % mod) % mod) * pw(3, Q - 2))) %
                  mod;
        } else if (S[i] == '?') {
            ans = (ans + ((((A[i] * C[i]) % mod) % mod) * pw(3, Q - 1))) % mod;
            ans = (ans + ((((Qa[i] * C[i]) % mod) % mod) * pw(3, Q - 2))) % mod;
            ans = (ans + ((((A[i] * Qc[i]) % mod) % mod) * pw(3, Q - 2))) % mod;
            ans = (ans + ((((Qa[i] * Qc[i]) % mod) % mod) * pw(3, Q - 3))) % mod;
        }
    }
    cout << ans << endl;

    /*
    int Q = 0;
    REP(i, 0, S.size()) {
        Q += (S[i] == '?');
    }
    lli ans = 0;
    REP(i, 0, S.size()) {
        if (S[i] == 'B' || S[i] == 'C') continue;
        REP(j, i + 1, S.size()) {
            if (S[j] == 'A' || S[j] == 'C') continue;
            REP(k, j + 1, S.size()) {
                if (S[k] == 'A' || S[k] == 'B') continue;
                int q = ((S[i] == '?') + (S[j] == '?') + (S[k] == '?'));
                ans = (ans + pw(3, Q - q)) % mod;
            }
        }
    }
    cout << ans << endl;
    //*/

    return 0;
}


Measured memory_bytes: 3584
N=int(input())
A=[int(i)-1 for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
ans=B[A[0]]
for i in range(N-1):
    ans+=B[A[i+1]]
    if A[i+1]-A[i]==1:
        ans+=C[A[i]]
print(ans)


Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int MAXN = 105;

int T[MAXN];

int main() {

  int n, m, p, x, sum = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &T[i]), sum += T[i];
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &p, &x);
    printf("%d\n", sum - T[p] + x);
  }
}


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

#pragma warning(disable:4996)
using namespace std;


int main() {
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;++i)cin>>v[i];
	int answer=v[0];
	int sum=v[0];
	for (int i = 1; i < N; ++i) {
		sum+=v[i];
		answer=min(answer,sum/(i+1));
	}
	cout<<answer<<endl;
	return 0;
}



Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    private BufferedReader in;
    private StringTokenizer tok;
    private PrintWriter out;

    //------------------------------------------------------------------------------
    public static void main(String[] args) {
        new Main().run();
    }

    private void solve() throws IOException {
        // TODO
        int a = readInt();
        int b = readInt();
        int x = readInt();
        if (a <= x && x <= a + b) {
            out.println("YES");
        } else {
            out.println("NO");
        }
    }

    private void run() {
        try {
            initIO();
            solve();
            in.close();
            out.close();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

    private void initIO() throws IOException {
        try {
            in = new BufferedReader(new FileReader(new File("input.txt")));
            out = new PrintWriter(new File("output.txt"));
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    private String readString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int w, a[2]; cin >> w;
    REPI(i, 2) cin >> a[i];
    sort(a, a + 2);

    int ans =  a[1] - w - a[0];
    if(ans > 0) cout << ans;
    else cout << 0;
}


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

using namespace std;

int main(void){

    int n, k;
    cin >> n >> k;
    int count = 1;
    int rui = k;

    while(1){
        if(n < rui) break;
        count++;
        rui *= k;
    }

    cout << count << endl;

    return 0;
}

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

int n;
int s[100];

int main () {
  int res = 0;
  cin >> n;
  rep(i,n) {
    cin >> s[i];
    res += s[i];
  }

  sort(s, s + n);
  for(int i = 0; i < n && res % 10 == 0; i++) {
    if(s[i] % 10 != 0) {
      res -= s[i];
    }
  }
  if(res % 10 == 0) res = 0;
  
  cout << res << endl;
  return 0;
}


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

int main()
{
	int i,j,k,c;
	string T,P;
	
	
	cin >> T;
	cin >> P;
	if(T.size()>=P.size())
	{
	for(i=0;i<=T.size()-P.size();i++)
	{
		j=i;
		k=0;
		c=0;
		while(j<=T.size()-1 && T[j]==P[k])
		{
			c++;
			k++;
			j++;
		}
		if(c==P.size()) cout << i << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 3200
n = int(input())
a = list(map(int,input().split()))

d = {}
ans = 0

for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

for k,v in d.items():
    if k <= v:
        ans += v-k
    else:
        ans += v

print(ans)


Measured memory_bytes: 17780
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
int main() {
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];

	for(int i=k+1;i<=n;i++) {
		if(a[i]>a[i-k])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 4408
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	int res = 0;
	for (int p = 2; p <= sqrt(n) + 1; p++)
	{
		if (n % p != 0)
			continue;
		int count = 0;
		while (n % p == 0)
		{
			n /= p;
			count++;
		}
		int i = 0;
		int sum = 0;
		while (sum <= count)
			sum += ++i;
		res += i - 1;
		if (n == 1)
			break;
	}
	if (n != 1)
		res += 1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<queue>
using namespace std;
long B,l,r;
int Q;
main()
{
	cin>>Q;
	priority_queue<int>L,R;
	for(;Q--;)
	{
		int id;cin>>id;
		if(id==1)
		{
			int a,b;cin>>a>>b;
			B+=b;
			if(!R.empty()&&-R.top()<=a)
			{
				R.push(-a);
				r+=a;
				if(L.size()<R.size())
				{
					int w=-R.top();
					r-=w;
					l+=w;
					R.pop();
					L.push(w);
				}
			}
			else
			{
				L.push(a);
				l+=a;
				if(L.size()>R.size()+1)
				{
					int w=L.top();
					l-=w;
					r+=w;
					L.pop();
					R.push(-w);
				}
			}
		}
		else
		{
			long w=L.top();
			cout<<w<<" "<<B+r-l+w*((int)L.size()-(int)R.size())<<endl;
		}
	}
}

Measured memory_bytes: 3452
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    string s = "abcdefghijklmnopqrstuvwxyz";
    string t;
    cin>>t;
    if(t[0]=='z'){cout<<'a'; return 0;}
    for(int i=0;i<32;i++){
        if(t[0]==s[i]){cout<<s[i+1]; return 0;}
    }
    return 0;
}


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

long long int weight[110], value[110], dp[100100];

int main(){
    int n, w;   cin >> n >> w;
    for(int i=1;n>=i;i++){
        cin >> weight[i] >> value[i];
    }
    for(int i=1;n>=i;i++){
        for(int j=w;j>=0 and weight[i]<=j;j--){
            dp[j]=max(dp[j-weight[i]]+value[i], dp[j]);
        }
    }
    long long int ans=0;
    for(int i=1;w>=i;i++){
        ans=max(ans, dp[i]);
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=1e9+7;

ll a[MX], probability[MX];

ll bigmod(ll a, ll b)
{
    if(!b) return 1;
    if(b&1) return (a*bigmod(a, b-1))%mod;
    else
    {
        ll r=bigmod(a, b/2);
        return (r*r)%mod;
    }
}

int main()
{
    FasterIO;

    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];

    ll fact=1;

    for(int i=1; i<n; i++)
    {
        probability[i]=(probability[i-1]+ bigmod(i, mod-2) )%mod;

        fact=(fact*(ll)i)%mod;
    }

    ll expectedvalue=0;
    for(int i=1; i<n; i++)
    {
        expectedvalue=(expectedvalue + ( (a[i+1]-a[i])*probability[i] ) %mod )%mod;
    }
    cout<<setprecision(10)<<fixed<<(expectedvalue*fact)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	string s;
	cin >> s;
	int ans = 0, n = s.length();
	loop(i, n){
		int r = i;
		while(r < n && s[r] == 'R'){
			r++;
		}
		ans = max(ans, r - i);
		i = r;
	}
	cout << ans;
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e3;

int n, m, x[N], y[N], c[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", x + i, y + i);
		c[(x[i] + y[i]) & 1]++;
	}
	if (c[0] && c[1]) return puts("-1"), 0;
	printf(c[0] ? "32\n1 " : "31\n");
	for (int i = 30; i >= 0; i--) printf("%d%c", 1 << i, " \n"[!i]);
	for (int i = 1; i <= n; i++) {
		if (c[0]) putchar('R'), x[i]--;
		for (int j = 30; j >= 0; j--)
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0)
					x[i] -= 1 << j, putchar('R');
				else
					x[i] += 1 << j, putchar('L');
			} else {
				if (y[i] > 0)
					y[i] -= 1 << j, putchar('U');
				else
					y[i] += 1 << j, putchar('D');
			}
		if (x[i] || y[i]) printf("[%d %d] WTF\n", x[i], y[i]);
		puts("");
	}
}

Measured memory_bytes: 256