akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    se = N+1 if N % 2 == 0 else N
    return list(filter(lambda x: x[0]+x[1]!=se, combinations(range(1, N+1), 2)))


def main():
    N = read_int()
    E = slv(N)
    print(len(E))
    for e in E:
        print('%d %d' % e)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5980
n=int(input())
w=list(map(int,input().split()))
total,ans=sum(w),sum(w)
point=0

for i in range(1,n):
	if sum(w[0:i+1])>=total//2:
		ans=sum(w[0:i+1])-sum(w[i+1:])
		point=i
		break
if sum(w[point:])-sum(w[0:point])<ans:
	ans=sum(w[point:])-sum(w[0:point])
print(ans)

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


bool solve(){
    string s, t;
    cin>>s>>t;
    if(t.size() != s.size() + 1) return false;
    s += t[t.size() - 1];
    return s == t;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        cout<<(solve() ? "Yes" : "No");
    }

    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
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)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
template <class T> struct FenwickTree {
 
   vector<T> node;
   FenwickTree (int n) : node(n,0) {}
 
   void add(int idx, T val) {
      for (int i = idx; i < node.size(); i |= i + 1) {
         node[i] += val;
      }
   }
 
   T sum(int idx) {
      T ret = 0;
      for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
         ret += node[i];
      }
      return ret;
   }
 
};
 
int N,M;
vector< pair<int,int> > add;
vector<int> l,r;
FenwickTree<int> inst(100010);
 
int main() {
 
  cin >> N >> M;
  l.resize(N);
  r.resize(N);
 
  REP(i,N) {
    int lt,rt; cin >> lt >> rt;
    l[i] = lt;
    r[i] = rt;
    add.push_back(make_pair(rt - lt + 1, i));
  }
  
  sort(add.begin(),add.end());
 
  int j = 0;
  for(int i=1; i<=M; i++) {
    while(j < add.size()) {
      if(add[j].first >= i) break;
      int idx = add[j].second;
      inst.add(l[idx],1);
      inst.add(r[idx]+1,-1);
      j++;
    }
 
    int ans = N - j;
    for(int k=i; k<=M; k+=i) ans += inst.sum(k+1);
    cout << ans << endl;
  }
 
  return 0;
}

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

int main(){
	int N;
	int K;

	cin >> N >> K;

	long long ans = 1;
	for(int i = 1; i < N; i++){
		ans *= (K - 1);
	}
	ans = ans * K;
	cout << ans << endl;
	
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

bool cmp(const ii &u, const ii &v) {
	return (u.se < v.se) || (u.se == v.se && u.fi < v.fi);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vii a(n); fore(i, 0, n) cin >> a[i].fi >> a[i].se;
	sort(a.begin(), a.end(), cmp);
	LL t = 0;
	fore(i, 0, n) {
		t += a[i].fi;
		if (t > a[i].se) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
    return 0;
}
                                                        		

Measured memory_bytes: 3328
#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>;

int main(){
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector <ll> t;
    
    ll k3=0;
    int m;
    rep(i,n){
        //cout << "i" << i << endl;
        if(k3==0){
            if(s[i]=='0'){
                k3=1;
                m=1;
                t.push_back(0);
                
            }
            else{
                k3=-1;
                m=-1;
                
            }
        }
        else if(k3>0){
            if(s[i]=='0'){
                ++k3;
            }
            else{
                t.push_back(k3);
                k3=-1;
            }
        }
        else{
            if(s[i]=='1'){
                --k3;
            }
            else{
                t.push_back(k3*(-1));
                k3=1;
        }
    }
    }

    if(k3>0){
        t.push_back(k3);
    }
    else{
        t.push_back(k3*(-1));
    }

    ll l,l2=0;

    l=t.size();
    //cout << l << endl;
    if(l%2==0){
        t.push_back(0);
        ++l;
    }
    
    
    vector <ll> r(l);
    ll k2;
    ll ans=0,ans2;

    if(2*k+1>l){
        cout << n << endl;
    }
    else{
        rep(i,2*k+1){
            ans+=t[i];
            //cout << i << i << endl;
            //cout << t[i] << endl;
        }
        ans2=ans;
        k2=(l-2*k-1)/2+1;
        rep(i,k2-1){
            ans+=t[2*k+1+i*2]+t[2*k+2+i*2];
            ans-=t[i*2]+t[i*2+1];
            if(ans>ans2){
                ans2=ans;
            }
        }
        cout << ans2 << endl;
    }

    
    
    

    return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 5;
int dp[(1 << 13) + 5][maxn], inf = 1e9;
struct Key{
	int cost, status;
};
Key key[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, cnt, box;
	cin >> n >> m;
	int bound = (1 << n);
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j < bound; ++j)
			dp[j][i] = inf;
	for (int i = 1; i <= m; ++i) {
		cin >> key[i].cost >> cnt;
		for (int j = 0; j < cnt; ++j) {
			cin >> box;
			key[i].status |= (1 << (box - 1));
		}
	}
	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j <= bound; ++j)
			if (dp[j][i - 1] != inf) {
				dp[j][i] = min(dp[j][i], dp[j][i - 1]);
				dp[j | key[i].status][i] = min(dp[j | key[i].status][i],  dp[j][i - 1] + key[i].cost);
			}
		dp[key[i].status][i] = min(dp[key[i].status][i], key[i].cost);
	}
	if (dp[(1 << n) - 1][m] == inf)
		cout << "-1\n";
	else
		cout << dp[bound - 1][m] << '\n';
	return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

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

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

const int maxn = 310;
double N;

vector<md> dp(maxn, md(maxn, vd(maxn, -1)));

double go(int a, int b, int c){
  if(a<0||b<0||c<0) return 0;
  if(dp[a][b][c] >= 0) return dp[a][b][c];
  dp[a][b][c] = 1+(N-a-b-c+go(a-1,b,c)*a+go(a+1,b-1,c)*b+go(a,b+1,c-1)*c) / (a+b+c);
  return dp[a][b][c];
}

int main(){
  IO; cin >> N;
  int t; vi num(3);
  REP(i, N){
    cin >> t;
    num[t-1]++;
  }
  dp[0][0][0] = 0;
  cout << setprecision(15) << go(num[0], num[1], num[2]) << endl;
}


Measured memory_bytes: 237696
<?php
list($n, $t) = ints();
$a = ints();
$min = $a[0];
$maxd = 0;
for ($i = 1; $i < $n; ++$i) {
    $min = min($min, $a[$i - 1]);
    $d = $a[$i] - $min;
    if (isset($cnt[$d])) ++$cnt[$d];
    else $cnt[$d] = 1;
}
ksort($cnt);
echo array_pop($cnt);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 29700
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    SORT(x)     sort(x.begin(),x.end())
#define    fill(x,y)   memset(x, y, sizeof(x))

using namespace std;

int main(){
	//freopen("in.txt","r", stdin);
	//freopen("out.txt","w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s1,s2; cin >> s1 >> s2;
	int a,b; cin >> a >> b;
	string s; cin >> s;
	if(s==s1) a--;
	else b--;
	cout << a << " " << b << endl;	
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+7,MOD=1234567;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2,vis[M]={false};
string s,p,q,ok,ch;
vector<ll>v,v_1,v_2;
map<ll,ll>mp,mp_2;
set<ll>st;
ll parent[M],Rank[M],arr[200][200];
ll cnt=0,cost=0;
deque<ll>Q;
//vector< pair<string,ll >v,v_1;
struct node
{
    ll pa,ran,visit;

};
node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    ll a,b,c=0,n,t,sum=0,mx=MOD,l,x,y,i=0,j=0,r,d=0,e,chk,largest,smallest=999999,k;
    cin>>t>>a;
   for(i=1;i<=t;i++)
   {
       for(j=1;j<=a;j++)
       {
           cin>>arr[i][j];
       }
   }
   for(i=1;i<=t;i++)
   {
       for(j=i+1;j<=t;j++)
       {
               double dd=0.0;
               for(k=1;k<=a;k++)
               {
                   dd+=((arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k])*1.0);
               }
               dd=sqrt(dd);
               //cout<<dd<<endl;
               int cc=dd;
               if(cc==dd)
                sum++;
           }
       }
   cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j = i*i; j<1000000; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int ans = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){ans++;}
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2140
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

void gcl(int& x,int& y){
    if(x<y) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}

int main(){
    int N,X;cin>>N>>X;
    vector<int> sub(N);
    rep(i,0,N){
        int x;cin>>x;
        sub[i]=abs(X-x);
    }

    sort(sub.begin(),sub.end());

    rep(i,1,N) gcl(sub[i],sub[i-1]);

    cout<<sub[N-1]<<endl;
}  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

i64 largest_rectangle(vi hist) {
    hist.push_back(0);
    using ii = pair<i64, int>;
    stack<ii> st;
    i64 ret = 0;
    for (int i = 0; i < hist.size(); i++) {
        if (st.empty() || st.top().first < hist[i]) {
            st.push(ii(hist[i], i));
        } else {
            int s;
            while (st.size() && st.top().first >= hist[i]) {
                ret = max(ret, st.top().first * (i - st.top().second));
                s = st.top().second;
                st.pop();
            }
            st.push(ii(hist[i], s));
        }
    }
    
    return ret;
}

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    cout << largest_rectangle(as) << endl;
}


Measured memory_bytes: 6096
#include <iostream>
#include <string>
using namespace std;
struct Dice{
    int s[6];
    void roll(char c){
        int tmp;
        if(c=='N'){
            tmp=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=tmp;
        }
        if(c=='E'){
            tmp=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=tmp;
        }
        if(c=='W'){
            tmp=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=tmp;
        }
        if(c=='S'){
            tmp=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=tmp;
        }
        if(c=='R'){
            tmp=s[1];
            s[1]=s[2];
            s[2]=s[4];
            s[4]=s[3];
            s[3]=tmp;
        }
    }
    int top(){
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};

bool same(Dice a, Dice b){
    for(int i=0; i<6; i++)
        if(a.s[i]!=b.s[i]) return false;
    return true;
}

 
int main(void){
    Dice d[101];
    int n;
    cin>>n;
    
    for(int j=0; j<n; j++)
        for(int i=0; i<6; i++)
            cin>>d[j].s[i];
            
    bool ff=true;
    
    for(int k=0; k<n-1; k++){
        for(int l=k+1; l<n; l++){
            bool f=false;
            for(int i=0; i<4; i++){
                d[l].roll('R');
                for(int j=0; j<4; j++){
                    d[l].roll('N');
                    if(same(d[k],d[l])) f=true;
                }
            }
            d[l].roll('E');
            for(int j=0; j<4; j++){
                d[l].roll('N');
                if(same(d[k],d[l])) f=true;
            }
            d[l].roll('W');
            d[l].roll('W');
            for(int j=0; j<4; j++){
                d[l].roll('N');
                if(same(d[k],d[l])) f=true;
            }
        if(f) ff=false;    
        }
    }
    
    cout<<(ff?"Yes":"No")<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	while(1){
		int n,x;
		in(n,x);
		if(n==0&&x==0)return 0;
		set<vector<int>> table;
		arep(i,1,n+1){
			arep(j,1,n+1){
				if(i==j)continue;
				arep(k,1,n+1){
					if(i==k||j==k)continue;
					if(i+j+k==x){
						vector<int> hoge;
						hoge.pb(i);
						hoge.pb(j);
						hoge.pb(k);
						sort(hoge);
						table.insert(hoge);
					}
				}
			}
		}
		out(table.size());
	}
	return 0;
}



Measured memory_bytes: 3248
#include <stdio.h>

int main ()
{
	int a, b;
	char op;
	
	
	while(scanf("%d %c %d", &a, &op, &b))
	{
		if(op == '?')
		{
			break;
		}
		switch(op)
		{
			case '+':
				printf("%d\n",a+b);
				break;
			case '-':
				printf("%d\n",a-b);
				break;
			case '*':
				printf("%d\n",a*b);
				break;
			case '/':
				printf("%d\n",a/b);
			    break;
		}
	}
	return 0;
}


Measured memory_bytes: 2756
'use strict'

function Main(input){
	const T = input.trim();
	const answer = [''];

	let start,end;
	for(let i=0,l=T.length;i<l;i++){
		//ACGTを探す
		let j;
		start = -1;
		for(j=i;j<l;j++){
			if(T[j]=='A' || T[j]=='C' || T[j]=='G' || T[j]=='T'){
				start=j;
				break;
			}
		}
		if(start === -1) break;
		end = -1;
		for(let k=start+1;k<l;k++){
			if(T[k]!='A' && T[k]!='C' && T[k]!='G' && T[k]!='T'){
				end = k;
				answer.push( T.slice(start,end) );
				i=end;
				//console.log(start,k);
				break;
			}
		}
		if(end===-1){
			answer.push( T.slice(start) );
			break;
		}
	}
	//console.log(answer);
	//console.log( answer.map((v)=>v.length));
	console.log(Math.max( ...answer.map( (v)=>v.length )));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    string str;
    cin >> str;
    for(int i=str.length()/2-1; i>0; i--){
        if(str.substr(0, i) == str.substr(i, i)){
            cout << 2*i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    println(getPrimeList(5555).filter(_ % 5 == 1).take(sc.nextInt).mkString(" "))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def getPrimeList(maxV: Long): List[Long] = {
    getPrimeListRecursive((2L to maxV).toList)
  }

  def getPrimeListRecursive(A: List[Long]): List[Long] = {
    if (A.size == 0) (List[Long]()) else {
      List(A.head) ++ getPrimeListRecursive(A.filter(_ % A.head != 0))
    }
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

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

Measured memory_bytes: 46568
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int a[214514],b[214514];
signed main(){
	int n;
	cin>>n;
	int sum = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i+n] = a[i];
		sum += a[i];
	}
	sum = sum/2;
	// find b[1];
	for(int i=1;i<=n;i++){
		if( i % 2 == 0 ){
			sum -= a[i];
		}
	}
	b[1] = sum;
	cout<<2*b[1]<<" ";
	for(int i=2;i<=n;i++){
		b[i] = a[i-1] - b[i-1];
		cout<<2*b[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

ll mpow(ll a, ll n){
    ll res = 1;
    while (n > 0){
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main(){
    int n, m;
    sc(n) sc(m)
    int x = 1900 * m + 100 * (n - m);
    int y = mpow(2, m);
    cout << x * y << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

def dfs(x):
    if x > N:
        return 0

    san, go, nana = 0, 0, 0
    c = x
    for i in range(len(str(c))):
        if c % 10 == 3:
            san += 1
        elif c % 10 == 5:
            go += 1
        elif c % 10 == 7:
            nana += 1
        c = c // 10
    if san > 0 and go > 0 and nana > 0:
        ret = 1
    else:
        ret = 0

    for i in [3, 5, 7]:
        ret += dfs(10*x + i)

    return ret

print(dfs(0))


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

int main(){
    int n; cin>>n;
    bool flag = false;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
        if(i*j == n) flag = true;
        }
    }

    if(flag ) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=4005,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    if(a<0||b<0) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll dp[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    int A,B;cin>>A>>B;
    
    //s=最初のbが出てきたときの残りのr+1
    //t=個数がs未満になって以降の最初のbが出てきたときの残りのr+1
    //u=個数がt未満になって以降の最初のbが出てきたときの残りのr+1
    
    //u>=2の場合OUT
    
    //1個目のbがx番目とする。(1<=x<=A+1) -> s=A-(x-1)+1
    //A+B-(s-1)個中、x-1個のr,1個のb,A＋B-(s-1)-x個の(r or b)
    //これは簡単な二項係数
    //s-1個でrがA',bがB'という問題に帰着される O(N^2)
    
    //同じことをやる
    //bがy番目とする。tが決まる
    //y-1個のr,1個のb,...
    
    //残りt-1個が、rrrr..bbbbb...ならOK(つまり1通りに定まる)
    
    
    //1個目のbと2個目のbを全探索
    //r確定の範囲がO(1)
    //あー無理だ
    
    
    // rrrrr...../b/??????????/rrrr...../b/?????????/rrrrr..../bbbb...... ->OK
    
    //   x      /1/ B-1 (u+v) /  y      /1/ B-(v+2) */ A-(x+u+y)
    
    // r x+u+y; A-(x+u+y)
    // b 1+v+1; B-(v+2)
    
    //sum x+y+B+1; A-(x+y+1)
    
    //*パートはDPで前計算O(N^2)で可能 累積和でO(1)
    
    dp[0][0]=1;
    
    for(int i=0;i<4000;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j+1]+=dp[i][j];
            
            dp[i+1][j]%=mod;
            dp[i+1][j+1]%=mod;
        }
    }
    
    for(int i=0;i<=4000;i++){
        for(int j=1;j<=4000;j++){
            dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<=A;i++){
        for(int u=0;u<=B-1;u++){
            int v=B-1-u;
            
            ll sum=i+1;
            sum*=comb(B-1,u);
            sum%=mod;
            
            int uu=A-i-u,vv=B-2-v;
            int s=B-(v+2);
            
            if(uu<0||vv<0) continue;
            
            ll p=0;
            
            int l=max(0,s-vv),r=min(uu,s);
            
            if(l==0){
                p=dp[s][r];
            }else{
                p=dp[s][r]-dp[s][l-1]+mod;
                p%=mod;
            }
            
            sum*=p;
            sum%=mod;
            
            ans+=sum;
            ans%=mod;
            
            //cout<<i<<" "<<u<<" "<<ans<<" "<<p<<endl;
        }
    }
    
    ans+=(A+1);
    ans%=mod;
    
    cout<<ans<<endl;
}



Measured memory_bytes: 125568
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
#a = [int(i) for i in readline().split()]

n,m = [int(i) for i in readline().split()]

ac = [0]*n
wa = [0]*n

ac_num = 0
wa_num = 0

for _ in range(m):
    p,s = [i for i in readline().split()]
    p = int(p)-1
    if ac[p] == 1:
        continue
    
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] += 1
        ac_num += 1
        wa_num += wa[p]

print(ac_num,wa_num)        





Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){int A,B,C;
           cin>>A>>B>>C;
  int uu=0;
  int jj=0;
     if(A==5){uu++;}
           if(A==7){jj++;}  
           if(B==5){uu++;}
           if(B==7){jj++;}
               if(C==5){uu++;}
           if(C==7){jj++;}
           
if(uu==2&&jj==1){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}

}

Measured memory_bytes: 256
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var t = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(p => p[0]).Select(p => p[1]).ToArray();
		var yx = Enumerable.Range(0, n).ToArray();
		var xy = Enumerable.Range(0, n).ToArray();
		Array.Sort(t, yx);
		Array.Copy(yx, t, n);
		Array.Sort(t, xy);

		int ss = 64, sc = n / ss + 1;
		var s = new int[sc, sc];
		for (int i = 0; i < n; i++)
			s[i / ss, xy[i] / ss]++;
		for (int i = 0; i < sc; i++)
			for (int j = 1; j < sc; j++)
				s[i, j] += s[i, j - 1];
		for (int j = 0; j < sc; j++)
			for (int i = 1; i < sc; i++)
				s[i, j] += s[i - 1, j];

		var c = MInt(n * MPow(2, n) - n);
		for (int i = 0; i < n; i++)
		{
			var v = xy[i];

			var li = i >= ss && v >= ss ? s[i / ss - 1, v / ss - 1] : 0;
			var ix = i - i % ss;
			for (int i2 = ix; i2 < i; i2++)
				if (xy[i2] < v) li++;
			for (int j2 = v - v % ss; j2 < v; j2++)
				if (yx[j2] < ix) li++;

			c -= MPow(2, i) + MPow(2, n - 1 - i) + MPow(2, v) + MPow(2, n - 1 - v);
			c += MPow(2, li) + MPow(2, i - li) + MPow(2, v - li) + MPow(2, n - 1 + li - i - v);
			c = MInt(c);
		}
		Console.WriteLine(c);
	}

	const int M = 998244353;
	static long MPow(long b, long i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
	static long MInt(long x) => (x %= M) < 0 ? x + M : x;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(n+1), y(m+1);
    cin >> x[n] >> y[m];
    rep(i, n){
        cin >> x[i];
    }
    rep(i, m){
        cin >> y[i];
    }
    SORT(x);
    SORT(y);
    if(x[n] < y[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int a[26];
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    string s;
    cin>>s;

    iter_(i,s.size()){
        a[s[i]-97]++;
    }
    bool f=true;
    iter_(i,26){
        if(a[i]%2!=0){
            f=false;
            break;

        }
    }
    if(f)
        cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }

}



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



int main(){
	string s,s2,s3,s4;
	vector<string> vs;
	
	cin >> s >> s2;
	for(int i=0;i+s2.size()<=s.size();i++){
		s3=s.substr(i,s2.size());
		
		for(int j=0;j<s3.size();j++){
			if(s3[j]!=s2[j] && s3[j]!='?') goto aa;
		}
		
		s4="";
		for(int j=0;j<i;j++){
			if(s[j]=='?') s4+='a';
			else s4+=s[j];
		}
		s4+=s2;
		for(int j=s4.size();j<s.size();j++){
			if(s[j]=='?') s4+='a';
			else s4+=s[j];
		}
		vs.push_back(s4);
		
		
		aa:;
	}
	
	if(vs.size()==0){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	
	sort(vs.begin(),vs.end());
	cout << vs[0] << endl;
	
	return 0;
}

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

int main(void){
    int n = 0;
    int cnt = 0, ans = 0;

    scanf("%d", &n);

    while(cnt * cnt <= n){
        cnt++;
    }
    ans = (cnt-1) * (cnt-1);

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

} 


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main(){
    string s; cin >> s;
    bool ans=true;
    for(int i=0; i<s.size(); ++i){
        if(i%2==0) continue;
        char c=s[i];
        if(!(c=='L' || c=='U' || c=='D')) ans=false;
    }
    for(int i=0; i<s.size(); ++i){
        if(i%2) continue;
        char c=s[i];
        if(!(c=='R' || c=='U' || c=='D')) ans=false;
    }
    if(ans){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        int n = sc.nextInt();
        long cnt = 0;
        for(int i=0;i<n;i++){
            sc.next();
            char c = sc.next().charAt(0);
            if(c=='(') cnt += sc.nextInt();
            else cnt -= sc.nextInt();
            if(cnt==0) System.out.println("Yes");
            else System.out.println("No");
        }
    }
 
}

Measured memory_bytes: 56396
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


/*
 * //構造体バージョン
 * struct UnionFind {
 *          vector<int> par;
 *
 *          UnionFind(int N) : par(N) {
 *          for(int i = 0; i < N; i++) par[i] = i;
 *          }
 * };
 *
 */


class UnionFind{
        public:

                vector<int> par;

                //初期化
                UnionFind(int N) {
                        par = vector<int>(N,-1);
                }

                //親を調べる
                //マイナスになっているのが親
                int root(int x){
                        if(par[x] < 0) return x;
                        return par[x] = root(par[x]);
                }

                //その根の大きさを調べる
                int size(int x){
                        return -par[root(x)];
                }

                //根をつなげる
                bool Union(int x, int y){
                        int px = root(x);
                        int py = root(y);
                        if(px == py) return false;

                        //サイズの大きい方につなげる
                        if(size(px) < size(py)) swap(px, py);

                        //大きい方に小さい方の値を足すことでparに入っている親の大きさがその根の数になる。
                        par[px] += par[py];

                        //pyの親はpxになる。
                        par[py] = px;

                        return true;
                }
};



int main(){
        int N, M;
        cin >> N >> M;
        vector<int> A(M), B(M);
        for(int i = 0; i < M; i++)
        {
                cin >> A[i] >> B[i];
                A[i]--;
                B[i]--;
        }

        vector<ll> ans(M);
        ans[M-1] = (ll)N * (N-1) / 2;

        UnionFind tree(N);

        for(int i = M-1; i >= 1; i--)
        {
                ans[i-1] = ans[i];

                if(tree.root(A[i]) != tree.root(B[i])) {
                        ans[i-1] -= (ll)tree.size(A[i]) * tree.size(B[i]);
                        tree.Union(A[i], B[i]);
                }
        }

        for (int i = 0; i < M; i++)
        {
                cout << ans[i] << endl;
        }
}

























Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int x[n];
  int y[n];
  int h[n];
  int flag=0;
  int cx,cy;
  int xt,yt,ht;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i]!=0 && flag != 1) {
      xt=x[i];
      yt=y[i];
      ht=h[i];
      flag=1;
    }
  }

  int needH;
  for ( cx = 0; cx <= 100; cx++) {
    for ( cy = 0; cy <= 100; cy++) {
      flag=0;
      needH = ht + abs(xt - cx) + abs(yt - cy);
      for (int i = 0; i < n; i++) {
        if (h[i]>0) {
          if (needH - abs(x[i] - cx) - abs(y[i] - cy) != h[i]) {
            flag= -1;
            break;
          }
        }else{
          if (needH - abs(x[i] - cx) - abs(y[i]- cy) > 0) {
            flag = -1;
            break;
          }
        }
      }
        if (flag == 0) {
          cout << cx << " " << cy << " " << needH << endl;
          return 0;
        }
    }
  }

  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int N;
ll W;
vector<ll> weight;
vector<int> value;
int dp[101][101][301];

int dfs(int i, int k, ll w) {
  if (i == N) return 0;
  if (dp[i][k][w] != -1) return dp[i][k][w];
  int ret = 0;
  if (w + (ll)k * weight[0] + weight[i] <= W) ret = max(ret, dfs(i + 1, k + 1, w + weight[i] - weight[0]) + value[i]);
  ret = max(ret, dfs(i + 1, k, w));
  return dp[i][k][w] = ret;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  memset(dp, -1, sizeof(dp));
  cin >> N >> W;
  weight.resize(N); value.resize(N);
  REP(i, N) cin >> weight[i] >> value[i];

  cout << dfs(0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 12288
import java.util.Scanner;

public class Main {
	static final char CHECKED = 'C';
	static final char BLACK = '.';
	static final char START = '@';
	void run(){
		Scanner s = new Scanner(System.in);
		while(true){
			int w = s.nextInt();
			int h = s.nextInt();
			if(w == 0 && h == w)break;
			int x = 0;
			int y = 0;
			char tile[][] = new char[h][w];
			for(int i = 0;i < h;i++){
				String row = s.next();
				for(int j = 0;j < w;j++){
					tile[i][j] = row.charAt(j);
					if(tile[i][j] == START){
						y = i;
						x = j;
						tile[i][j] = BLACK;
					}
				}
			}
			System.out.println(cntTile(tile,y,x));
		}
	}

	int cntTile(char[][] panel,int y,int x){
		//??????????????´??????????????\????????¢?´¢???????????????0????????´?????????
		if(y >= panel.length)return 0;
		if(y < 0)return 0;
		if(x >= panel[0].length)return 0;
		if(x < 0)return 0;
		int cnt = 0;
		if(panel[y][x] == BLACK){
			panel[y][x] = CHECKED;
			cnt++;
			//??±???????????¢?´¢????????????????????¢?´¢??????????????°?????????
			cnt += cntTile(panel,y + 1,x);
			cnt += cntTile(panel,y - 1,x);
			cnt += cntTile(panel,y,x + 1);
			cnt += cntTile(panel,y,x - 1);
			return cnt;
		}else{
			return 0;
		}
	}

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

Measured memory_bytes: 38908
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto inp = readln.chomp.split.to!(long[]);
  long num;
  if (inp[0] % inp[2]) {
    inp[0] += inp[2] - (inp[0] % inp[2]);
  }
  if (inp[1] % inp[2]) {
    inp[1] -= inp[1] % inp[2];
  }

  if (inp[0] <= inp[1]) {
    num = (inp[1] - inp[0]) / inp[2] + 1;
  }

  num.writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
      int a,b,c;
      
      scanf("%d",&a);
      scanf("%d",&b);
      scanf("%d",&c);
    
    if(a<b&&b<c)
    printf("Yes\n");
    else
    printf("No\n");
    
    return(0);
    
    
    
}


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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int maxn = 1e5 + 5;

int N;
int A[maxn];

inline void solve ()
{
	sort (A + 1, A + N + 1, greater <int> ());
	
	for (int i = 1; i <= N; ++i) if (i + 1 > A[i + 1])
	{
		int d1 = A[i] - i, d2 = 0;
		for (int j = i + 1; j <= N; ++j) if (A[j] == i) ++d2;

		d1 += 2; d2 += 2;
		if ((d1 & 1) || (d2 & 1)) printf ("First");
		else printf ("Second");

		break;
	}
}

inline void input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main ()
{


	input ();
    solve ();

    return 0;
}


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

char A[20][20];
bool V[20][20];
int count,H,W;
void check(int x,int y){
    if(0<=x-1){
        if(A[x-1][y]=='.'&&!V[x-1][y]){
            count++;
            V[x-1][y]=true;
            check(x-1,y);
        }
    }
    if(x+1<H){
        if(A[x+1][y]=='.'&&!V[x+1][y]){
            count++;
            V[x+1][y]=true;
            check(x+1,y);
        }
    }
   if(0<=y-1){
        if(A[x][y-1]=='.'&&!V[x][y-1]){
            count++;
            V[x][y-1]=true;
            check(x,y-1);
        }
    }   
    if(y+1<W){
        if(A[x][y+1]=='.'&&!V[x][y+1]){
            count++;
            V[x][y+1]=true;
            check(x,y+1);
        }
    }
    return;
    }
int main(){
    int x,y;
    count=1;
    while(true){
        cin>>W>>H;
        if(W==0&&H==0){
            break;
        }else{
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    cin>>A[i][j];
                    if(A[i][j]=='@'){
                        x=i;
                        y=j;
                    }
                }
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    V[i][j]=false;
                    }
                }
            }
        check(x,y);
        cout<<count<<endl;
        count=1;
    }
    return 0;
}

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	/* --------------------------------------------------------------------
	   main
	 * -------------------------------------------------------------------- */
	static final int[] A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	public static void main(String args[]) throws Exception {

		// ----- input -----
		int K = 0;
		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))){
			K = Integer.parseInt(input.readLine());
		}

		System.out.println(A[K-1]);
	}
}


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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    string s;cin>>s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



    return 0;
}

Measured memory_bytes: 3620
n,m = map(int, input().split())		# 5 7 2

A = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(降順(逆順)ソート付き)

ans="Yes"
if A[m-1]*4*m < sum(A): ans="No"

print(ans)


Measured memory_bytes: 2940
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines);

  let n = 1;
  let cnt = 0;

  while (n < B) {
    n = n + A - 1;
    cnt++;
  }

  return cnt.toString();
};

const parseLines = (lines: string[]) => {
  const [A, B] = lines[0].split(' ').map(v => +v);
  const obj = { A, B };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


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

using namespace std;
typedef long long ll;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = min(a, k);
  k -= a;
  if (k > 0) {
    k -= b;
  }
  if (k > 0) {
    ans -= k;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> A(N,0);

    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    sort(A.begin(),A.end());
    int v=0;
    for(int j=0;j<N;j++){
        if(j==(N-1)){
            v+=(A[j]/2);
        }else{
        v+=A[j];
        }
    }
    cout<<v<<endl;

    return 0;
}

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

int main(){
	
	int y[5];
	rep(i,5){
		cin>>y[i];
	}
	rep(i,5){
		if(y[i]==0)cout<<i+1<<endl;
	}

}


Measured memory_bytes: 3636