akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    ll a, b; in(a); in(b);
    inn(c); inn(d);

    ll e = (ll) c * d / std::__gcd(c, d);
    auto _c = b/c - (a - 1)/c; err(_c);
    auto _d = b/d - (a - 1)/d; err(_d);
    auto _e = b/e - (a - 1)/e; err(_e);

    out(b - a + 1 - _c - _d + _e);
}

int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 256
S = gets
m1 = (1..12).include?(S.slice(0, 2).to_i)
m2 = (1..12).include?(S.slice(2, 2).to_i )
if m1 && m2
  puts 'AMBIGUOUS'
elsif m1
  puts 'MMYY'
elsif m2
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
n, m = list(map(int, input().split()))
# = list(map(int, input().split()))
# x = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# n, m = list(map(int, input().split()))
l = []
r = []
for i in range(m):
    a, b = list(map(int, input().split()))
    l.append(a-1)
    r.append(b-1)

end = n-1
start = 0
for i in range(m):
    if start <= l[i] and r[i] <= end:
        start = l[i]
        end = r[i]
    elif l[i] < start and r[i] <= end:
        end = r[i]
    elif start <= l[i] and end < r[i]:
        start = l[i]

    if end-start+1 < 0:
        print(0)
        exit()
print(end-start+1)


Measured memory_bytes: 11056
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
int main(){
    string s;cin>>s;
    int n=s.size();
    long long dp[n][4];
    fill(dp[0],dp[0]+n*4,0LL);
    if(s[0]=='?')dp[0][0]=3,dp[0][1]=1;
    else if(s[0]=='A')dp[0][0]=dp[0][1]=1;
    else dp[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<4;j++){
            if(!j){
                if(s[i]=='?')dp[i][j]=dp[i-1][j]*3;
                else dp[i][j]=dp[i-1][j];
            }
            else{
                if(s[i]=='?')dp[i][j]=dp[i-1][j]*3+dp[i-1][j-1];
                else if(s[i]=='A'+j-1)dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
                else dp[i][j]=dp[i-1][j];
            }
            dp[i][j]%=mod;
        }
    }
    printf("%lld\n",dp[n-1][3]);
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w,n,r,c;
  string s,t;
  cin >> h >> w >> n >> r >> c >> s >> t;
  int ii=r,jj=c;
  for(int i=0;i<n;i++){//UR
    if(s[i]=='U'){
      ii--;
      if(ii==0){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(s[i]=='R'){
      jj++;
      if(jj>w){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(t[i]=='D' and ii<h){
      ii++;
    }
    if(t[i]=='L' and jj>1){
      jj--;
    }
  }
  ii=r,jj=c;
  for(int i=0;i<n;i++){//UL
    if(s[i]=='U'){
      ii--;
      if(ii==0){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(s[i]=='L'){
      jj--;
      if(jj==0){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(t[i]=='D' and ii<h){
      ii++;
    }
    if(t[i]=='R' and jj<w){
      jj++;
    }
  }
  ii=r,jj=c;
  for(int i=0;i<n;i++){//DR
    if(s[i]=='D'){
      ii++;
      if(ii>h){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(s[i]=='R'){
      jj++;
      if(jj>w){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(t[i]=='U' and ii>1){
      ii--;
    }
    if(t[i]=='L' and jj>1){
      jj--;
    }
  }
  ii=r,jj=c;
  for(int i=0;i<n;i++){//DL
     if(s[i]=='D'){
      ii++;
      if(ii>h){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(s[i]=='L'){
      jj--;
      if(jj==0){
        cout << "NO" << endl;
        return 0;
      }
    }
    if(t[i]=='U' and ii>1){
      ii--;
    }
    if(t[i]=='R' and jj<w){
      jj++;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <iostream>
using namespace std;
int main(void) {
	string s;
	int k;
	cin >> s >> k;
	string ans = "";
	for (int i = 0; i < s.size(); ++i) {
		if (i != s.size() - 1) {
			if (s[i] == 'a') ans += 'a';
			else if (123 - s[i] <= k) {
				k -= 123 - s[i];
				ans += 'a';
			}
			else {
				ans += s[i];
			}
		}
		else {
			int num = (s[i] - 97 + k) % 26 + 97;
			ans += char(num);
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

int main()
{
	string a, b, c;
	char turn = 'a';
	
	cin >> a >> b >> c;
	
	while (turn != 'd') {
		if (turn == 'a') {
			if (a.empty() == 1) {
				cout << "A" << endl;
				turn = 'd';
			}
			else {
				turn = a[0];
				a.erase(0, 1);
			}
		}
		if (turn == 'b') {
			if (b.empty() == 1) {
				cout << "B" << endl;
				turn = 'd';
			}
			else {
				turn = b[0];
				b.erase(0, 1);
			}
		}
		if (turn == 'c') {
			if (c.empty() == 1) {
				cout << "C" << endl;
				turn = 'd';
			}
			else {
				turn = c[0];
				c.erase(0, 1);
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 256
a,b=map(int,input().split())
import math
c=math.gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(len(set(prime_factorize(c)))+1)

Measured memory_bytes: 62884
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long count = n/11*2;
      if(n%11>6){
        count += 2;
      }else if(n%11>0){
        count++;
      }   
      System.out.println(count);
	}
}

Measured memory_bytes: 21844
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()

  if s[2]==s[3] and s[4]==s[5]:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 5672
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.


Measured memory_bytes: 1364
#include<iostream>
using namespace std;
int a,b,i;
int main(void){
	cin>>a>>b;
	if(b==1){cout<<0;return 0;}
	for(i=1;;i++){
		b-=a;
		if(b<=0)break;
		b++;
	}
	cout<<i;
	return 0;
}

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

using namespace std;

bool color[8];

int main(void) {
    int n;
    int over = 0;

    cin>>n;

    for(int i = 0;i < n;i++)
    {
	int a;

	cin>>a;
	if(1 <= a && a <= 399)
	{
	    color[0] = true;
	} else if(400 <= a && a <= 799){
	    color[1] = true;
	} else if(800 <= a && a <= 1199) {
	    color[2] = true;
	} else if(1200 <= a && a <= 1599) {
	    color[3] = true;
	} else if(1600 <= a && a <= 1999) {
	    color[4] = true;
	} else if(2000 <= a && a <= 2399) {
	    color[5] = true;
	} else if(2400 <= a && a <= 2799) {
	    color[6] = true;
	} else if(2800 <= a && a <= 3199) {
	    color[7] = true;
	} else {
	    over++;
	}
    }

    int x = 0;
    for(int i = 0;i < 8;i++)
	if(color[i])
	    x++;

    int temp = x;
    if(temp == 0)
	temp = 1;
    cout<<temp<<" ";
    int m = x+over;
    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt() , k = fs.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = fs.nextInt();
		}
		
		int rdp[][] = new int[n+1][5001];
		
		rdp[0][0] = 1;
		for(int i=0;i<n;i++) {
			for(int j=0;j<5001;j++) {
				if(rdp[i][j]>0)rdp[i+1][j]=1;
				if(j+a[n-1-i]<5000) {
					if(rdp[i][j]>0)rdp[i+1][j+a[n-1-i]]=1;
				}
			}	
		}
		
		//累積和にする
		for(int i=0;i<n+1;i++) {
			for(int j=5000;j>=1;j--) {
				rdp[i][j-1] += rdp[i][j];
			}
		}
		
		int ans = n;
		boolean dp[][] = new boolean[2][5001];
		dp[0][0] = true;
		for(int i=0;i<n;i++) {
			for(int j=0;j<5001;j++) {
				dp[(i+1)&1][j] |= dp[i&1][j];
				if(j+a[i]>5000) {
					dp[(i+1)&1][5000]|=dp[i&1][j];
				}
				else {
					dp[(i+1)&1][j+a[i]]|=dp[i&1][j];
				}
			}	
			for(int j=0;j<=k;j++) {
				if(dp[i&1][j]) {
					if(rdp[n-i-1][(int)Math.max(0,k-j-a[i])] - rdp[n-i-1][k-j]>0) {
						ans--;
						break;
					}
				}
			}
		}
		
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}




Measured memory_bytes: 166996
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
s = [0] * n
p = [0] * n
for i in range(n):
    s[i], p[i] = input().split()
    p[i] = -(int(p[i]))

for i in sorted(zip(s,p,range(n))):
    print(i[2]+1)


Measured memory_bytes: 3060
from sys import stdin

N = int(stdin.readline().rstrip())
H = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
cnt = 0

for i in range(len(H) - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
        if ans < cnt:
            ans = cnt
    else:
        cnt = 0
        if ans < cnt:
            ans = cnt

print(ans)


Measured memory_bytes: 63984
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
string s; 
char t[200006], d[200006];
int n, q; 
int simul(int x) {
	rep(i, q) {
		if (t[i] == s[x]) {
			if (d[i] == 'L')x--; else x++;
			if (x < 0 || x == n)return x;
		}
	}
	return x;
}

signed main() {
	cin >> n >> q;
	cin >> s;
	rep(i, q)cin >> t[i] >> d[i];

	int lb = -1, ub = n;
	while (ub - lb > 1) {
		int mi = (ub + lb) / 2;
		if (simul(mi) == -1)lb = mi;
		else ub = mi;
	}
	int lb2 = -1, ub2 = n;
	while (ub2 - lb2 > 1) {
		int mi = (ub2 + lb2) / 2;
		if (simul(mi) == n)ub2 = mi;
		else lb2 = mi;
	}
	cout << n - (lb + 1) - (n - ub2) << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <bits/stdc++.h>
using namespace std;

using namespace std;

int main(){
    int n,m;
    std::cin >> n>>m;
    std::cout << n*m/2 << std::endl;
    
}

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

  int counter(int x){
  	if(x==0) return 0;
    return counter(x>>1)+(x&1);
  }

int main() {
	int n;
  	cin>>n;
  	
  	int a[20];
    int x[20][20];
  	int y[20][20];
  

  
  for(int i=1;i<=n;i++){
  	cin>>a[i];
    for(int j=1;j<=a[i];j++){
    	cin>>x[i][j]>>y[i][j];
    }
  }
  
  int ans=0;
  for(int bits = 1; bits<(1 << n);bits++){
  	bool ok = true;
    for(int i=1;i<=n;i++){
    	if(!(bits &(1 <<(i-1))))continue;
      for(int j=1;j<=a[i];j++){
      	if(((bits>>(x[i][j]-1))&1)^y[i][j])ok=false;
      }
    }
    if(ok)ans=max(ans,counter(bits));
  }
  cout<<ans<<endl;
  	
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;cin>>n;
    int minElem=0;
    int minNum=0;
    REP(i,n){
        int a,b;cin>>a>>b;
        if(a>minElem){
            minElem=a;
            minNum=b;
        }
    }
    cout<<minElem+minNum<<"\n";
    return 0;
}


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

int h,w;
char fruits[100][100];

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
void dfs(int y,int x,char f){
	if(y<0||h<=y||x<0||w<=x||fruits[y][x]!=f)return;
	fruits[y][x]=' ';
	for(int i=0;i<4;i++)
		dfs(y+dy[i],x+dx[i],f);
}

int main(){
	while(cin>>h>>w,w|h){
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>fruits[i][j];
		int ans=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(fruits[i][j]!=' '){
				ans++;
				dfs(i,j,fruits[i][j]);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int j = 1;
		int ans = Integer.MAX_VALUE;
		for(int i = 1 ; i < 499500 ; i += j) {
			j++;
			if(a - i == b - (i + j)) {
				ans = Math.min(ans, Math.abs(a - i));
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
import numpy as np
from numba import njit

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())), np.int64)
INF = 10 ** 18


@njit
def f(n, k, h):
    dp = np.full(n, INF, np.int64)
    dp[0] = 0

    for i in range(1, n):
        lb = np.maximum(0, i - k)
        dp[i] = np.min(dp[lb:i] + np.abs(h[lb:i] - h[i]))

    ans = dp[-1]
    return ans


ans = f(n, k, h)
print(ans)


Measured memory_bytes: 120200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string w;
    int a[26],b;
    rep(i, 26)a[i] = 0;
    cin >> w;
    rep(i, w.size()){
        b = w[i] - 'a';
        ++a[b];
    }
    rep(i, 26){
        if (a[i]%2 != 0) {
            No;
            return 0;
        }
    }
    Yes;
    return 0;
}


Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9e18
#define minf -9e18
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    int n;
    cin>>n;

    string s,t;
    cin>>s>>t;

    forn(i,0,n)
    {
    	cout<<s[i]<<t[i];
    }











    return 0;
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        k = 1 << (N.bit_length() - 1)
        while k > 0:
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
            k //= 2
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
B = [memo[a] for a in A]
M = len(memo) + 10

bit = BIT(M)
for b in B:
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


Measured memory_bytes: 71228
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val S = scala.io.StdIn.readLine()

    def isACGT(c: Char): Boolean =
      c match {
        case 'A' | 'C' | 'G' | 'T' => true
        case _ => false
      }

    var count = 0
    var max = 0
    S.foreach { c =>
      if (isACGT(c))
        count += 1
      else {
        max = Math.max(max, count)
        count = 0
      }
    }
    println(Math.max(max, count))
  }

}



Measured memory_bytes: 25528
def main():
    q = int(input())
    s = set()
    
    for _ in range(q):
        op, x = map(int, input().split())

        if op == 0:
            s.add(x)
            print(len(s))
        elif op == 1:
            if x in s:
                print("1")
            else:
                print("0")
main()



Measured memory_bytes: 23300
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
	int n, m, ans = 0;
	scanf("%d %d", &n, &m);
	vector<int> v[m];
	for(int i = 0, a, b ; i < n ; i++){
		scanf("%d %d", &a, &b);
		if(m - a < 0) continue;
		v[m - a].push_back(b);
	}
	priority_queue<int> pq;
	for(int i = m - 1 ; i >= 0 ; i--){
		while(!v[i].empty()){
			pq.push(v[i].back());
			v[i].pop_back();
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5504
S=input()
N=len(S)
if N%2==1:
  S1=S[0:(N//2)]
  S2=S[(N//2+1):]
else:
  S1=S[0:(N//2)]
  S2=S[(N//2):]
  
if S==S[::-1] and S1==S1[::-1] and S2==S2[::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    vector<vector<bool>> seen(h, vector<bool>(w, false));
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }
    vector<vector<int>> d(h, vector<int>(w, INF));
    queue<pair<int, int>> que;
    d[0][0] = 0;
    que.push(make_pair(0, 0));
    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        if (p.first == w - 1 && p.second == h - 1)
        {
            break;
        }
        for (int i = 0; i < 4; i++)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (nx < 0 || nx >= w || ny < 0 || ny >= h || grid[ny][nx] == '#' || d[ny][nx] != INF)
            {
                continue;
            }
            que.push(make_pair(nx, ny));
            d[ny][nx] = d[p.second][p.first] + 1;
        }
    }
    if (d[h - 1][w - 1] == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        int cnt = 0;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (grid[i][j] == '#')
                {
                    cnt++;
                }
            }
        }
        cout << h * w - d[h - 1][w - 1] - 1 - cnt << endl;
    }
}

Measured memory_bytes: 892
package main

import (
	"fmt"
	"math"
)

var V, C []float64

func main() {
	var N int
	fmt.Scan(&N)

	V = make([]float64, N)
	C = make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&V[i])
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&C[i])
	}
	fmt.Println(dfs(0, 0, N-1))
}

func dfs(v float64, c float64, n int) float64 {
	if n < 0 {
		return v - c
	}

	x := dfs(v+V[n], c+C[n], n-1)
	y := dfs(v, c, n-1)

	return math.Max(x, y)
}


Measured memory_bytes: 512
N,A,B,C = map(int,input().split())
ln = [int(input()) for i in range(N)]

def mp(bl, used, i):
  score = 1<<29
  if bl[0] and bl[1] and bl[2]:
    sortedbl = sorted(bl)
    score = used + abs(sortedbl[0]-C) + abs(sortedbl[1]-B) + abs(sortedbl[2]-A)
  if i == N:
    return score
  s0 = mp(bl, used, i+1)
  add = 0
  if bl[0]:
    add = 10
  bl[0]+=ln[i]
  s1 = mp(bl, used+add, i+1)
  bl[0]-=ln[i]
  add = 0
  if bl[1]:
    add = 10
  bl[1]+=ln[i]
  s2 = mp(bl, used+add, i+1)
  bl[1]-=ln[i]
  add = 0
  if bl[2]:
    add = 10
  bl[2]+=ln[i]
  s3 = mp(bl, used+add, i+1)
  bl[2]-=ln[i]
  return min(score, s0, s1, s2, s3)

print(mp([0]*3, 0, 0))

Measured memory_bytes: 3064
#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() {
  ll n, k;
  cin >> n >> k;

  ll x = n / k;

  if (k % 2 == 1) {
    cout << x * x * x << endl;
    return 0;
  }

  ll y = n / (k / 2);
  cout << x * x * x + (y - x) * (y - x) * (y - x) << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  bool ans=false;
  int a,b,c;cin>>a>>b>>c;
  if(a<=c&&c<=b){
    ans=true;
  }else if(b<=c&&c<=a){
    ans=true;
  }
  cout<<yesno(ans)<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int rate;
    cin>>rate;
    int min=400,max=599,kyu=8;
    while(1){
        if(min<=rate&&rate<=max){
            cout<<kyu<<endl;
            return 0;
        }
        min+=200;
        max+=200;
        kyu--;
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n][3];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> a[i][j];
    ll dp[n][3] = {};
    for(int j = 0; j < 3; ++j)
        dp[0][j] = a[0][j];
    for (int i = 1; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 3; ++k)
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 3840
// inputに入力データ全体が入る
function Main(input) {
  var input = input.split('\n');
  var answer;

  var nums = input[0].split(' ');
  nums = nums.map(e => parseInt(e));
  var left = nums[0] + nums[1];
  var right = nums[2] + nums[3];

  if (left > right) {
    answer = 'Left'
  } else if (right > left) {
    answer = 'Right'
  } else {
    answer = 'Balanced'
  }



  // 出力
  console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
/*
1. I'm the Future Red Coder :)
2. Hopefully, I'll be Yellow Soon.
*/
#include<bits/stdc++.h>
#define mod 998244353 //1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
ll power(ll a,ll b,ll m=mod) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
/*struct node {
    int l,r,nq;
};
bool compare(const node& a,const node& b) {
    if (a.r != b.r) return a.r<b.r;
    return a.l<b.l;
}*/
/* ******* DSU START ****** */
/*
const int dsusize = (int)1e5+5;
struct node {
    int data;
    int rk,pn;
}dsu[dsusize];
//ll fans;
void initialize(int n) {
    REP(i,1,n) {
        dsu[i].data = 1;
        dsu[i].rk = 0;
        dsu[i].pn = i;
    }
}
int fnd(int i) {
    if (dsu[i].pn != i) dsu[i].pn = fnd(dsu[i].pn);
    return dsu[i].pn;
}
void unn(int i,int j) {
    i = fnd(i);
    j = fnd(j);
    if (i!=j) {
        //fans -= dsu[i].data*dsu[j].data;
        if (dsu[i].rk>dsu[j].rk) {
            dsu[j].pn = i;
            dsu[i].data += dsu[j].data;
        }
        else {
            dsu[i].pn = j;
            dsu[j].data += dsu[i].data;
            if (dsu[i].rk==dsu[j].rk) {
                dsu[j].rk++;
            }
        }
    }
}
*/
/* ******* DSU END****** */

const int N = (int)2e5+5;
const int Q = 250;
void solve() {
    int r;
    cin>>r;
    cout<<(3*r*r);
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N,K;cin >> N >> K;
    double res = 0.0;
    for(int i = 1;i <= N;i++){
        int n = i;
        double co = 1.0;
        while(n < K)n *= 2,co /= 2.0;
        res += co;
    }
    res /= N;
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
numbers = [int(x) for x in input().split(" ")]
foods = []
for i in range(numbers[0]):
  foods.append([int(x) for x in input().split(" ")])
  foods[i].pop(0)
number = 0
for i in range(numbers[1]+1):
  if all(i in e for e in foods):
    number += 1
print(number)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1000000007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int cnt(string a, string b) {
  int rt = 0;
  for (int i = 0; i < a.length(); i++) {
    rt += (a[i] != b[i]);
  }
  return rt;
}
int main() {
  IOS;
  string s, t;
  cin >> s >> t;
  int mn = 1e9;
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    mn = min(mn, cnt(s.substr(i, t.length()), t));
  }
  cout << mn << endl;
}


Measured memory_bytes: 3588
/*
Dont BLUNDER
*/
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#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 haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}





signed main()
{
	haha
#ifndef ONLINE_JUDGE

	freopen("inp.txt", "r", stdin);

	freopen("out.txt", "w", stdout);
#endif
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";






}

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

#define ll long long

int main(){
    ll n;
    cin >> n;
    ll count = 0, i=1;
    while(n>0){
        i *= 2;
        count += i;
        n = n/2;
    }
    cout << count/2;
    return 0;
}


Measured memory_bytes: 3608
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let ans = match N%10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => panic!("error"),
    };
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


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

	ll count = 0;
	for (ll i = 1; i <= N; i++) {
		
		//iの桁数を求める
		ll temp = i;
		ll keta = 0;
		while (temp > 0) {
			temp = temp / 10;
			keta++;
		}

		if (keta % 2 == 1) count++;
	}

	cout << count << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> cnt(26);
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']--;
		ll ansi = 1;
		for (int j = 0; j < 26; j++) {
			if (s[i] - 'a' != j) {
				ansi = (ansi * (cnt[j] + 1)) % MOD;
			}
		}
		ans = (ans + ansi) % MOD;
	}
	cout << ans;
}


Measured memory_bytes: 512
//$g++ main.cpp - compile
//$./a.out - run
#include <iostream>
#include <string>
#include <cctype>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    string str;
    getline(cin, str);
    for(int i = 0; i < str.length(); i++){
        if(isupper(str[i])) str[i] = tolower(str[i]);
        else if(islower(str[i])) str[i] = toupper(str[i]);
    }
    cout << str << endl;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen, memset
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
#include <fstream>
using namespace std;
int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int k = a % b;
    int t = 0;
    for( int i = 1; i <= b; i++)
    {
        t += k;
        t %= b;
        if( t == c)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class Main {
	
	static int N , W;
	static int[] v , w;
	
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		N = sc.nextInt();
		W = sc.nextInt();
		w = new int[N];
		v = new int[N];
		for(int i = 0; i < N ;i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long ans = funKnapscack(W, N, w, v);
		System.out.println(ans);
	}
	public static long funKnapscack(int w, int n, int[] weights , int []prices ) {
		long table[][] = new long[n+1][w+1];
		
		for(int i = 0; i <= n; i++) {
			for(int j = 0 ; j <= w ; j++ ) {
				if(i == 0 || j == 0) {
					table[i][j] = 0;
					continue;
				}
				long inc = 0;
				if((j-weights[i-1] >= 0)) {
				inc = prices[i-1] + table[i-1][j - weights[i-1]];}
				
				long exc = table[i-1][j];
				table[i][j] = Math.max(inc,exc); 
			}
		}
		
		
		return table[n][w];
	}
	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
}


Measured memory_bytes: 137580
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var i int
	if sc.Scan() {
		i, _ = strconv.Atoi(sc.Text())
	}

	hour := i / 3600
	min := (i % 3600) / 60
	sec := i - hour*3600 - min*60

	fmt.Printf("%d:%d:%d\n", hour, min, sec)
}



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


int sum(const vector<int>& v, int l, int r) {
	int sum = 0;
	for (int i = l; i <= r; ++i) sum += v[i];
	return sum;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a1(n), a2(n); {
		rep(i, n) cin >> a1[i];
		rep(i, n) cin >> a2[i];
	}

	int ans = 0;
	rep(i, n) {
		int tans = sum(a1, 0, i) + sum(a2, i, n - 1);
		ans = max(ans, tans);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
	string s;
	string::iterator it;
	int i, n;

	while (cin>>s) {
		for (it = s.begin(); it != s.end(); it++) {
			if (*it == '@') {
				n = *(++it)++ - '0';
				for (i = 0; i < n; i++)
					cout<<*it;
			} else {
				cout<<*it;
			}
		}
		cout<<endl;
	}

	return 0;
}

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

#define x first
#define y second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define REP(i, a) FOR(i, 0, a)
#define TRACE(x) //cout << #x << " " << x << endl
#define _ << " _ " <<

using namespace std;

#define task "a"

const int MAXN = 1000010;

int a, b;
int sito[MAXN];

int main(){

  //  freopen(task ".in", "r", stdin);
  //  freopen(task ".out", "w", stdout);

  FOR(i, 2, MAXN) {
    if (sito[i] != 0) continue;
    for (int j = i; j < MAXN; j += i) {
      sito[j] = i;
    }
  }

  while(1==1) {
    scanf("%d%d", &a, &b);
    if (a == 0 && b == 0) break;
    int sumA = sito[a];
    int sumB = sito[b];
    while (sito[a] == sumA) a /= sito[a];
    while (sito[b] == sumB) b /= sito[b];

    TRACE(sumA _ sumB);

    while (a != 1) {
      int pom = sito[a];
      sumA -= pom;
      while (sito[a] == pom) a /= sito[a];
      TRACE(pom);
    }
    while (b != 1) {
      int pom = sito[b];
      sumB -= pom;
      while (sito[b] == pom) b /= sito[b];
      TRACE(pom);
    }

    if (sumA > sumB) printf("a\n"); else printf("b\n");
  }
  
  return 0;
}

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

int main(){
	int A,B;
	cin>>A>>B;
	
	int ans=(B-1)/(A-1);
	double ans2=(double)(B-1)/(A-1);
	
	//cout<<ans2<<endl;
	if(ans==ans2)
		cout<<ans<<endl;
	else
		cout<<ans+1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1000000000
int C,N,M,S,D,g1[101][101],s,t,c,d[11][101];
typedef struct P{int p,c,t;}P;
struct Order
{
	bool operator ()(P const& a, P const& b) const
	{
		return a.c>b.c;
	}
};

P tmp,tmp2;
priority_queue<P,vector<P>,Order>Q;
int main()
{
	for(;scanf("%d%d%d%d%d",&C,&N,&M,&S,&D),N;)
	{
		for(int i=0;i<=N;i++)
			for(int j=0;j<=N;j++)
				g1[i][j]=INF;
		for(int i=0;i<=C;i++)
			for(int j=0;j<=N;j++)
				d[i][j]=INF;
		for(int i=0;i<M;i++)
		{
			scanf("%d%d%d",&s,&t,&c);
			if(g1[s][t]>c)
				g1[s][t]=g1[t][s]=c;
		}
		d[C][S]=0;
		tmp.c=0;tmp.p=S;tmp.t=C;
		Q.push(tmp);
		for(;!Q.empty();)
		{
			tmp=Q.top(),Q.pop();
			for(int i=1;i<=N;i++)
			{
				int nc=tmp.c+g1[tmp.p][i];
				if(d[tmp.t][i]>nc)
				{
					tmp2.c=d[tmp.t][i]=nc;
					tmp2.p=i;
					tmp2.t=tmp.t;
					Q.push(tmp2);
				}
				nc=tmp.c+g1[tmp.p][i]/2;
				if(tmp.t>0&&d[tmp.t-1][i]>nc)
				{
					tmp2.c=d[tmp.t-1][i]=min(d[tmp.t][i],nc);
					tmp2.p=i;
					tmp2.t=tmp.t-1;
					Q.push(tmp2);
				}
			}
		}
		printf("%d\n",d[0][D]);
	}
}

Measured memory_bytes: 1176
import sys
from collections import deque
MOD = 10**9+7
input = sys.stdin.readline

N, K = map(int, input().split())
adj = [ [] for _ in range(N+1) ]
for _ in range(N-1):
    u, v = map(int, input().split())
    adj[u].append(v)
    adj[v].append(u)

ans = 1
que = deque( [(1, 0, K)] )

while que:
    u, p, k = que.popleft()
    ans = (ans*k) % MOD

    if p == 0:
        k_next = K-1
    else:
        k_next = K-2

    for v in adj[u]:
        if v == p:
            continue
        que.append( (v, u, k_next) )
        k_next -= 1

print(ans)

Measured memory_bytes: 67248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		
		
		

		Scanner scanner = new Scanner(System.in);
		String[] ar = scanner.nextLine().split(" ");
		
		

		for(int i=0; i<ar.length; i++) {
			if (Integer.parseInt(ar[i]) == 0) {
				System.out.println(i+1);
			}
		}	}

	}

Measured memory_bytes: 35692
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <tuple>

int main() {
  int a;
  scanf("%d", &a);

  char buf[16];
  scanf("%s", buf);
  std::string s = buf;

  if (a >= 3200) {
    puts(s.c_str());
  } else {
    puts("red");
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
  int w[300], h[300];
  int i, j;

  for (i = 0; i < 300; i++) {
    scanf("%d %d", &h[i], &w[i]);
    if (w[i] == 0 && h[i] == 0)
      break;
  }

  for (j = 0; j < i; j++) {
    int k, n;
    for (k = 0; k < h[j]; k++) {
      for (n = 0; n < w[j]; n++) {
	printf("#");
      }
      
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

vector<ll>vec;
void dfs(ll x, int digit = 1){
	if (digit > 10)return;
	vec.push_back(x);
	ll a = x % 10;
	dfs(x * 10 + a, digit + 1);
	if (a != 0) {
		dfs(x * 10 + a - 1, digit + 1);
	}
	if (a != 9) {
		dfs(x * 10 + a + 1, digit + 1);
	}
	return;
}

int main() {
	init();
	
	int K; cin >> K;
	rep(i, 0, 9)dfs((ll)i + 1);
	sort(all(vec));
	cout << vec[K - 1] << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;

void solve() {
	int r;	cin >> r;
	cout << 2*3.14159*r << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3776