akhauriyash/Code-Regression huggingface dataset:
//
//  alds1_1_d_maximum_profit.cpp
//  aoj
//
//  Created by Sei Kataoka on 2/5/16.
//  Copyright ?? 2016 Sei Kataoka. All rights reserved.
//

#include <iostream>

using namespace std;

static const int MAX = 200000;

int main() {
    int n;
    int r[MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> r[i];

    int maxv = -1000000000;
    int minv = r[0];

    for (int i = 1; i < n; ++i) {
        maxv = max(r[i] - minv, maxv);
        minv = min(r[i], minv);
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 1940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 998244353;

struct R {
    bool operator<(const R& r) const {
        return x < r.x;
    }
    int x, d;
};

struct S {
    int x, dp;
};

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

    int n;
    cin >> n;

    vector<R> r(n);
    for (int i = 0; i < n; i++) {
        int x, d;
        cin >> x >> d;
        r[i] = { x, d };
    }
    sort(r.begin(), r.end());

    vector<S> s;
    int dp = 1;
    s.push_back({ (int)2e+9, dp });

    for (int i = n - 1; i >= 0; i--) {
        int x = r[i].x + r[i].d;
        while (s.back().x < x) s.pop_back();
        dp += s.back().dp; if (dp >= P) dp -= P;
        s.push_back({ r[i].x, dp });
    }

    cout << dp << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int d,t,s;
        cin>>d>>t>>s;
        if(t*s >= d) cout<<"Yes\n";
        else cout<<"No\n";
        
			
        
        
    }



return 0;
}


Measured memory_bytes: 3636
# 総当たりでしたか....

def main():
    n = int(input())
    ans = [0] * (n + 1)
     
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                val = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if val <= n:
                    ans[val] += 1
     
    print(*ans[1:], sep="\n")
main()

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int f(int n) {
  int ret = 0;
  for (int x = 1; x * x <= n; x += 1) {
    for (int y = 1; y * y <= n - x * x; y += 1) {
      for (int z = 1; z * z <= n - x * x - y * y - x * y; z += 1) {
        int a = x * x + y * y + z * z + x * y + y * z + z * x;
        if (a == n) ret += 1;
      }
    }
  }
  return ret;
}

void solve() {
  int n;
  cin >> n;
  reps(i, n) {
    cout << f(i) << '\n';
  }
}


Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    string S; cin >> S;
    ll M = 0;
    ll x = 0;
    for(int i = 0; i < S.length();i++){
        if(S[i] == 'I'){
            x++; M = max(M,x);
        }else{
            x--;
        }
    }
    cout << M << endl;
    return 0;
}


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

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

int main()
{
	int N, Q;
	char s[200000];
	cin >> N >> Q >> s;

	char t[200000], d[200000];
	for (int i = 0;i < Q;i++)
		cin >> t[i] >> d[i];

	int l = 0, r = N - 1;
	for (int i = Q - 1;i >= 0;i--)
	{
		if (t[i] == s[l] && d[i] == 'L')
			l++;
		else if (t[i] == s[r] && d[i] == 'R')
			r--;

		if (t[i] == s[l - 1] && d[i] == 'R')
			l = max(l - 1, 0);
		else if (t[i] == s[r + 1] && d[i] == 'L')
			r = min(r + 1, N - 1);

		if (l > r)
			break;
	}

	cout << r - l + 1;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

Measured memory_bytes: 768
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int int64_t
const int infinity = 1e18;
using namespace std;

int dp[101][100001];

signed main(){
	
	int n,W;
	cin>>n>>W;
	int wt[n];
	int val[n];
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
		
	}
	for(int i = 100;i>=0;i--){
		for(int j = 100000;j>=0;j--){
			dp[i][j] = infinity;
		}
	}
	
	//exit(0);//
	
	 //dp[i][j] is weight at this condition.
	dp[0][0] = 0;
	dp[0][val[0]] = wt[0];
	for(int i=1;i<n;i++){
		dp[i][0] = 0;
		for(int j=1;j<=100000;j++){
			
			if(j >= val[i]){
				dp[i][j] = min(dp[i-1][j],wt[i] + dp[i-1][j-val[i]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
				
			
			
		}
	}
	
	
	for(int i = 100000;i>=0;i--){
		
		if(dp[n-1][i] <= W){
			cout<<i<<"\n";
			break;	
		}
		
	}
	

}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int open = 0; // 開き括弧
  int close = 0; // 閉じ括弧
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') {
      open++;
    } else {
      close++;
      if (open > 0) {
        open--;
        close--;
      }
    }
  }
  for (int i = 0; i < close; i++) cout << '(';
  cout << S;
  for (int i = 0; i < open; i++) cout << ')';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
fun main() {
    fun gcd(c:Long, d:Long):Long{
        if (d>c){return gcd(d,c)}
        if (c%d==0L){return d}
        return gcd(d, c%d)
    }
    val (a,b,c,d)= readLine()!!.split(" ").map { it.toLong() }
    val c_div=b/c-(a-1)/c
    val d_div=b/d-(a-1)/d
    val lcm=c*d/gcd(c,d)
    val lcm_div=b/lcm-(a-1)/lcm


//    println(c_div)
//    println(d_div)
//    println(lcm_div)
    println(b-a+lcm_div-c_div-d_div+1)
}

Measured memory_bytes: 36420
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else {
		cout <<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	double N;
	cin >> N;
	vector<double>vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	double sum = 0, a = 0;
	for (int i = 0; i < N; i++) {
		a = 1 / vec[i];
		sum += a;
	}
	a = 1 / sum;
	cout << a << endl;
}

Measured memory_bytes: 256
N, M = input().split()
N, M = int(N), int(M)

if N == 1 and M == 0:  # 1桁の数字指定なし
    ans = 0
elif N == 1:  # 1桁で数字指定有り:最初のcと同じものがずっと来ればans=c
    s, c = input().split()
    c = int(c)
    ans = c
    for m in range(M-1):
        temp_s, temp_c = input().split()
        if not int(temp_c) == c:
            ans = -1
            break

elif M == 0:  # 2桁以上で数字指定無し:10or100
    ans = 10**(N-1)
else:  # 2桁以上かつ数字指定有り:指定された数字から答えを出す
    # ただし、1桁目についての指定で追加処理
    ans_exist = True  # 矛盾なく答えが存在するか
    guess = []
    for n in range(N):
        guess.append(-1)
        # guess=[-1,-1,-1]
    for m in range(M):
        s, c = input().split()
        s, c = int(s), int(c)

        # すでに別の数字が指定されている時
        if not guess[s-1] == -1 and not guess[s-1] == c:
            ans_exist = False
            break
        # 1桁目に0が指定された時
        elif s == 1 and c == 0:
            ans_exist = False
            break
        else:
            guess[s-1] = c

    # 矛盾なく解が存在するなら指定がある桁を加算
    if ans_exist:
        # 1桁目に指定が無いなら1桁目は1
        ans = 10**(N-1) if guess[0] == -1 else 0
        for n in range(N):
            if not guess[n] == -1:
                ans += guess[n]*(10**(N-1-n))
    else:
        ans = -1

print(ans)


Measured memory_bytes: 3064
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


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


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


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
import numpy as np

def main():
	x=II()
	for i in range(-300,300):
		for j in range(-300,300):
			if i**5==x+j**5:
				print(i,j)
				exit()






if __name__=="__main__":
	main()


Measured memory_bytes: 27000
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    deque<ll> b;
    ll cnt = 0;

    rep(i, n) {
        if (cnt % 2 == 0) {
            b.push_back(a[i]);
            cnt++;
        } else {
            b.push_front(a[i]);
            cnt++;
        }
    }

    if (cnt % 2 != 0) reverse(all(b));
    for (auto c: b) cout << c << " ";
    cout << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 2e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf;
}


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

using namespace std;

char s[6][7], t[6][7];

int main() {
  int h, w, k; cin >> h >> w >> k;
  for(int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  int ans = 0;
  for(int mi = 0; mi < (1 << h); ++mi) {
    for(int mj = 0; mj < (1 << w); ++mj) {
      for(int i = 0; i < h; ++i) {
        strcpy(t[i], s[i]);
      }
      int cnt = 0;
      for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
          if(((mi >> i) & 1) || ((mj >> j) & 1)) {
            t[i][j] = 'R';
          }
          cnt += t[i][j] == '#';
        }
      }
      ans += cnt == k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>

using namespace std;

typedef long long ll;

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

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

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

    int a = (int) ((N * 100.0 + 108 - 1) / 108.0);
    // cout << a << endl;

    double c = ( a * 108.0 / 100.0);
    // printf("%f\n", N * 100.0 / 108.0);
    // printf("%f\n", c);

    int b = (int) c;

    if (N == b) {
        cout << a << endl;
    } else {
        cout << ":(" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int A, N, sum, calc;
    scanf("%d", &N);
    scanf("%d", &A);
    calc = N / 500;
    sum = N - 500 * calc;
    if(sum <= A){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int  a, b, c;
    cin >> a >> b >> c;
    cout << c/a * b;
    
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, W, w[110], v[110];
long long dp[100010];
int main() {
	scanf("%d%d", &n, &W);
	for(int i=1; i<=n; i++) {
		scanf("%d%d", w+i, v+i);
		for(int j=W; j>=0; j--)
			if(j >= w[i]) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
	}
	printf("%lld", dp[W]);
	return 0;
}

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

int N,M;
pair<int,int> PD[10010];

int main()
{
    while(cin >> N >> M && N)
    {
        int d,p;
        for(int i=0;i<N;i++)
        {
            cin >> d >>p;
            PD[i]=make_pair(p,d);
        }
        sort(PD,PD+N);
        int S=0;
        for(int i=0;i<N;i++)
           S+=PD[i].first*PD[i].second;
        for(int i=N-1;i>=0;i--)
        {
            if(M<=0)   break;
            int guard=min(M,PD[i].second);
            S-=PD[i].first*guard;
            M-=guard;
        }
        cout << S <<endl;
    }
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector< pair<int, int> > e(M);
    vector<int> v(N);
    int inp0, inp1;
    for(int i = 0; i < M; i++){
        cin >> inp0 >> inp1;
        inp0--;
        inp1--;
        v[inp0]++;
        v[inp1]++;
        e[i].first = inp0;
        e[i].second = inp1;
    }
    
    int num = 0;
    bool fin = false;
    while(true){
        int vvv;
        for(vvv=0; vvv < N; vvv++){
            if(v[vvv] == 1){
                v[vvv]--;
                num++;
                break;
            }
            if(vvv == N-1)
                fin = true;
        }

        if(fin) break;

        for(int i=0; i < M; i++){
            if(e[i].first == vvv)
                v[e[i].second]--;
            else if(e[i].second == vvv)
                v[e[i].first]--;
        }
    }

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
fun isPrime(x: Int): Boolean = when {
  x == 2 -> true
  x < 2 || x % 2 == 0 -> false
  else -> {
    var i = 3
    var ok = true
    while (i*i <= x) {
      if (x % i == 0) {
        ok = false; break
      }
      i += 2
    }
    ok
  }
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  var ans = 0
  for (i in 1..n) {
    val x = readLine()!!.toInt()
    if (isPrime(x)) ++ans
  }
  println(ans)
}



Measured memory_bytes: 32504
// AOJ 2104: Country Road
// 2017.9.30

#include <stdio.h>
#include <stdlib.h>

int d[100002];

char buf[800000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int t, n, k, i, x, x0, ans;

	fgets(p=buf, 10, stdin), t = getint();
	while (t--) {
		fgets(p=buf, 20, stdin), n = getint(), p++, k = getint();
		fgets(p=buf, sizeof(buf), stdin);
		if (k >= n) { puts("0"); continue; }
		for (n--, x0 = getint(), i = 0; i < n; i++, x0 = x) {
			p++, x = getint();
			d[i] = x - x0;
		}
		qsort(d, n, sizeof(int), cmp);
		for (ans = 0, i = 0; i <= n-k; i++) ans += d[i];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int n,m,c,g,a[10000];
int main(){
	while(true){
		cin>>n>>m;c=1;g=0;if(n==0 && m==0)break;
		for(int i=1;i<=n;i++)cin>>a[i];
		for(int i=1;i<=m;i++){
			int p;cin>>p;c+=p;
			c+=a[c];
			if(c>=n && g==0){g=i;}
		}
		cout<<g<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
   int X,Y;
   cin>>X>>Y;
   bool a=false;
   for(int i=0; i<X+1; i++){
    if(i*2+(X-i)*4==Y){
        a=true;
        break;
    }
   }
   if(a==true){
       cout<<"Yes"<<endl;
   }
   else
   cout<<"No"<<endl;
}

Measured memory_bytes: 3624
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int hide = A - B * 2;
		if (hide < 0) {
			hide = 0;
		}
		System.out.println(hide);
	}

}

class MyComparator implements Comparator {
	@Override
	public int compare(Object arg0, Object arg1) {
		long x = (long) arg0;
		long y = (long) arg1;

		if (x < y) {
			return 1;
		} else if (x > y) {
			return -1;
		} else {
			return 0;
		}
	}
}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 21076
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		List<Integer> heights = new ArrayList<>();
		
		for(int i=0; i<n; i++) {
			heights.add(sc.nextInt());
		}
		
		List<Double> avt = heights.stream().map(heigh -> Math.abs((t-heigh.intValue()*0.006) 
				- a)).collect(Collectors.toList());
		
		OptionalDouble min = avt.stream().mapToDouble(num -> num.doubleValue()).min();
		
		for(int i=0; i<n; i++) {
			
			if(avt.get(i) == min.getAsDouble()) {
				System.out.println(i+1);
			}
		}
		
		sc.close();
	}
}


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

const int INF = 1e9;

int main() {
    int n, q;
    cin>>n>>q;

    tuple<int, int, int> events[2*n];
    for (int i=0; i<n; i++) {
        int s, t, x;
        cin>>s>>t>>x;
        events[2*i] = make_tuple(s-x, 1, x);
        events[2*i+1] = make_tuple(t-x, -1, x);
    }
    sort(events, events+2*n);

    set<int> s;
    int idx_d = 0;
    for (int i=0; i<q; i++) {
      int d;
      cin>>d;
      if (idx_d == 2*n) {
        cout<<-1<<endl;
        continue;
      }
      while (get<0>(events[idx_d]) <= d) {
        if (get<1>(events[idx_d]) == 1) {
          s.insert(get<2>(events[idx_d]));
        } else {
          s.erase(get<2>(events[idx_d]));
        }
        ++idx_d;
        if (idx_d == 2*n) {
          break;
        }
      }
      if (s.size() == 0) {
        cout<<-1<<endl;
      } else {
        cout<<*s.begin()<<endl;
      }
    }
}

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

using namespace std;

const int maxn=100005;

int n,m;

vector<int>adj[maxn];

vector<bool>visited;

vector<int>ans;

void dfs(int v)
{
    visited[v]=true;
    for(auto u:adj[v])
    {
        if(!visited[u])
            dfs(u);
    }
    ans.push_back(v);
}

void topological_sort()
{
    visited.assign(maxn,false);
    ans.clear();
    for(int v=1;v<=n;v++)
    {
        if(!visited[v])
            dfs(v);
    }
reverse(ans.begin(),ans.end());
}

vector<int>DAG(maxn);

int main()
{

    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
    }

    topological_sort();

    int first=ans[0];
    DAG[first]=0;

    for(int i=0;i<ans.size();i++)
    {
        int v=ans[i];
        for(auto u:adj[v])
        {
            DAG[u]=max(DAG[u],DAG[v]+1);
        }
    }
    cout<<*max_element(DAG.begin(),DAG.end())<<endl;
return 0;
}


Measured memory_bytes: 8828
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MaxN = 103;
char s[MaxN],t[MaxN];

inline bool check(const char* s) {
	register char ch=s[0];
	while (*s!=0) {
		if (ch!=*s) return false;
		s++;
	}
	return true;
}

int main() {
	scanf("%s",s);
	int L=strlen(s);
	int ans=L-1;
	for (char ch='a';ch<='z';ch++) {
		strcpy(t,s);int l=L;
		int step=0;
		while (!check(t) && l>0) {
			for (int i=0;i<l-1;++i) if (t[i]!=ch) t[i]=t[i+1];
			t[l-1]=0;
			step++,l--;
		}
		ans=min(ans,step);
	}
	printf("%d\n",ans);
	return 0;
} 

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

int main(){
  int a,b,x;
  int t;
  cin >> x >> a >> b;		// 4 3 6
  string ok = "delicious",
    safe = "safe",
    ou = "dangerous";

  t = -a+b;
  
  if (t <= 0) cout << ok << endl;
  if (t >0 && t <= x) cout << safe << endl;
  if (x < t) cout << ou << endl;
  
  return 0;
}


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

from collections import deque

n, q = [int(i) for i in raw_input().split()]
d = deque()
for i in range(n):
    name, time = raw_input().split()
    time = int(time)
    d.append([name, time])

total = 0
while len(d) > 0:
    p = d.popleft()
    if p[1] <= q: # 終わり
        total += p[1]
        print "{} {}".format(p[0], total)
    else:
        total += q
        p[1] -= q
        d.append(p)


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n),res(n*n,-1);
   rep(i,0,n){
      scanf("%d",&a[i]);
      a[i]--; res[a[i]]=i;
   }
   vector<int> ord(n); iota(ALL(ord),0);
   sort(ALL(ord),[&](int i,int j){return a[i]<a[j];});
   int lb=0,rb=n*n-1;
   for(int i:ord){
      int cnt=i;
      while(cnt){
         if(res[lb]==-1)res[lb]=i,cnt--;
         else if(lb==a[i]){puts("No"); return 0;}
         lb++;
      }
   }
   sort(ALL(ord),[&](int i,int j){return a[i]>a[j];});
   for(int i:ord){
      int cnt=n-1-i;
      while(cnt){
         if(res[rb]==-1)res[rb]=i,cnt--;
         else if(rb==a[i]){puts("No"); return 0;}
         rb--;
      }
   }
   puts("Yes");
   rep(i,0,n*n)printf("%d ",res[i]+1); puts("");
   return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
 
    string a;
    cin >> a;
    
    unsigned long b;
    b = a.size()-1;
    
    cout << a[0] << a.size()-2 << a[b];
    
    
    

    return 0;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;

int solve(int R, int G, int B, int N) {
  int count = 0;
  int rmax = (N / R) + 1;
  int gmax = (N / G) + 1;
  int bmax = (N / B) + 1;

  vector<int> bvec;
  for(int b = bmax-1; b >= 0; b-- ){
    bvec.push_back(N - b * B);
  }

  for(int r = 0; r < rmax; r++){
    if( r * R > N ){ break; }
    for(int g = 0; g < gmax; g++){
      if( r * R + g * G > N ){ break; }

      if(binary_search(bvec.begin(), bvec.end(), r * R + g * G )){
        count++;
      }
    }
  }

  return count;
}

int main(int argc, char const *argv[]) {
  int R, G, B, N;

  cin >> R;
  cin >> G;
  cin >> B;
  cin >> N;

  cout << solve(R, G, B, N);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
#define N 262144
int n,m,num[MN],f[MN],t[N*2+5],a[MN];
vector<int> v[MN];
inline void rw(int x,int v){for(x+=N+1;t[x]=min(t[x],v),x>>=1;);}
inline int query(int l,int r){
	int res=1e9;
	for(l+=N,r+=N+2;l^r^1;l>>=1,r>>=1){
		if(~l&1) res=min(res,t[l+1]);
		if( r&1) res=min(res,t[r-1]);
	}
	return res;
}
int main(){
	n=read();register int i,j;
	for(i=1;i<=n;++i) num[i]=num[i-1]+1-(a[i]=read()),f[i]=1e9;
	m=read();memset(t,63,sizeof t);int l;
	for(i=1;i<=m;++i) l=read(),v[l-1].push_back(read());
	for(i=0;i<n;++i){
		f[i+1]=min(f[i+1],f[i]+a[i+1]);
		for(j=0;j<v[i].size();++j){
			int w=min(f[i]+num[v[i][j]]-num[i],query(i,v[i][j])+num[v[i][j]]);
			f[v[i][j]]=min(f[v[i][j]],w);
			rw(v[i][j],w-num[v[i][j]]); 
		}
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=500005,mod=1e9+7;
int f[N]={1};
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int c(int n,int m)
{
	return f[n]*qp(f[m],mod-2)%mod*qp(f[n-m],mod-2)%mod;
}
signed main()
{
	for(int i=1;i<=500000;i++)
		f[i]=f[i-1]*i%mod;
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		int zh=1;
		zh=zh*c(m,i)%mod*c(n,i)%mod*f[i]%mod;
		zh=zh*c(m-i,n-i)%mod*c(m-i,n-i)%mod*f[n-i]%mod*f[n-i]%mod;
		if(i%2)
			ans=(ans+mod-zh)%mod;
		else
			ans=(ans+zh)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7536
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 1007;
const LD EPS = 1e-7;

const int MAXM = 5007;

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	LL a, b, c;
	cin >> a >> b >> c;
	if ((a & 1) && (b & 1) && (c & 1))
	{
		LL ans = min(a * b, b * c);
		ans = min(ans, c * a);
		cout << ans;
	}
	else
		cout << 0;
	//cout << endl; system("pause");
	return 0;
}

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

map<string, int> cnt;

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		string s;
		cin>>s;
		cnt[s] ++;
	}
	cout<<"AC x "<<cnt["AC"]<<endl;
	cout<<"WA x "<<cnt["WA"]<<endl;
	cout<<"TLE x "<<cnt["TLE"]<<endl;
	cout<<"RE x "<<cnt["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Size(x) ((int)((x).size()))
#define rep(i, l, r) for(int (i) = (l); (i) <= (r); ++(i))
#define per(i, r, l) for(int (i) = (r); (i) >= (l); --(i))
#define chkmax(x, y) (x) = max((x), (y))
#define chkmin(x, y) (x) = min((x), (y))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
inline char gc() {
	static char now[1 << 16], *S, *T;
	if (S == T) {T = (S = now) + fread(now, 1, 1 << 16, stdin); if (S == T) return EOF;}
	return *S ++;
}
#define gc getchar
inline int read() {
	int x = 0, f = 1; char c = gc();
	while (c < '0' || c > '9') {(c == '-') ? (f = 0) : 0; c = gc();}
	while (c >= '0' && c <= '9') {x = (x << 3) + (x << 1) + (c ^ 48); c = gc();}
	return f ? x : ((~ x) + 1);
}
const int mod = 1e9 + 7;
inline int add(const int &x, const int &y) {
	return (x + y >= mod) ? (x +  y - mod) : (x + y);
}
inline void Add(int &x, const int &y) {
	x += y; (x >= mod) ? (x -= mod) : 0;
}
inline int sub(const int &x, const int &y) {
	return (x < y) ? (x - y + mod) : (x - y);
}
inline void Sub(int &x, const int &y) {
	x -= y; (x < 0) ? (x += mod) : 0;
}
inline int qpow(int a, int b) {
	if (!a) return 0;
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) res = 1ll * res * a % mod;
	return res;
}

int n, K;
int f[2][50000][2], suf[2][50000];
int main() {
	n = read(); K = read();
	if (n <= 50000) {
		f[0][1][0] = 1;
		rep(i, 1, K) {
			int now = i & 1, pre = now ^ 1;
			rep(j, 1, n) Add(f[pre][j][0], f[pre][j - 1][0]);
			rep(j, 1, n) {
				f[now][j][0] = f[pre][n / j][0];
			}
		}
		int ans = 0;
		rep(i, 1, n) Add(ans, f[K & 1][i][0]);
		printf("%d\n", ans);
		return 0;
	}
	int sqr = (int) sqrt(n);
	f[0][1][0] = 1;
	rep(ii, 1, K) {
		int now = ii & 1, pre = now ^ 1;
		per(j, sqr, 1) suf[pre][j] = (suf[pre][j + 1] + f[pre][j][1]) % mod;
		rep(j, 1, sqr) (f[pre][j][0] += f[pre][j - 1][0]) %= mod;
		rep(j, 1, sqr) {
			f[now][j][0] = f[pre][min(n / j, sqr)][0];
			if (n / j > sqr) {
				f[now][j][0] = add(f[now][j][0], suf[pre][j]);
			}
		}
		for (int i = sqr + 1, j; i <= n; i = j + 1) {
			j = n / (n / i); int len = j - i + 1;
			f[now][n / i][1] = 1ll * len * f[pre][n / i][0] % mod;
		}
	}
	int ans = 0;
	rep(i, 1, sqr + 2) Add(ans, f[K & 1][i][0]), Add(ans, f[K & 1][i][1]);
	printf("%d\n", ans);
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define mp make_pair

#define int long long
const int N = 1e6 + 10, Mod = 1e18 + 7, Sq = 20;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b; cin >> a >> b;
    if(a >= 13)
        return cout << b, 0;
    if(a >= 6)
        return cout << b/2, 0;
    return cout << 0, 0;
}


Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let s = read string
    Seq.sumBy (fun c -> if c = '1' then 1 else 0) s |> printfn "%d"
    0


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

int main(){
  int n, a;
  int b[3] = {};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a % 4 == 0) b[2]++;
    else if(a % 2 == 0) b[1]++;
    else b[0]++;
  }
  if(b[1] == 0){
    if(b[0] <= b[2] + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else{
    if(b[0] <= b[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

public class Main {

    //Fast Reader
        private static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new InputStreamReader(System.in));
            }

            public String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            public void resetST() {
                st = null;
            }

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

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

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

            public float nextFloat() {
                return Float.parseFloat(next());
            }

            public String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                st = null;
                return str;
            }

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

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

            public double[] nextDoubleArray(int size) {
                double[] arr = new double[size];
                for (int i = 0; i < size; i++) {
                    arr[i] = nextDouble();
                }
                return arr;
            }
        }
    public static void main(String[] args)
    {
        FastReader sc =new FastReader();
        PrintWriter pr =new PrintWriter(System.out);
        int n=sc.nextInt();
        int ac=0;
        int wa=0;
        int re=0;
        int tle=0;
        for (int i=0;i<n;i++)
        {
            String s=sc.nextLine();
            if(s.equals("AC"))
                ac+=1;
            else if(s.equals("WA"))
                wa+=1;
            else if(s.equals("TLE"))
                tle++;
            else if(s.equals("RE"))
                re++;
        }
        pr.println("AC x "+ac);
        pr.println("WA x "+wa);
        pr.println("TLE x "+tle);
        pr.println("RE x "+re);
        pr.close();
	// write your code here
    }
}


Measured memory_bytes: 43184
#include<stdio.h>
#include<string.h>

int main(){

    char S[15], T[15], U[15];
    int A, B;

    scanf("%s %s %d %d %s", S, T, &A, &B, U);

    int pull = 0;

    if(strcmp(S,U) == 0){
        pull = 1;
    }

    printf("%d %d\n", A - pull, B - 1 + pull);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
struct node {
    int to,next;
}E[MAXN * 2];
int sumE,sg[MAXN],head[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u,int fa) {
    sg[u] = 0;
    for(int i = head[u]; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    dfs(v,u);
	    sg[u] ^= (sg[v] + 1);
	}
    }
}
void Solve() {
    read(N);
    int x,y;
    for(int i = 1 ; i < N ; ++i) {
	read(x);read(y);
	add(x,y);add(y,x);
    }
    dfs(1,0);
    if(sg[1]) puts("Alice");
    else puts("Bob");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
using namespace std;

int len = 1E9 + 7;
const int ms = 1E8 + 4;
int sp[ms];
int b[ms];
int n, m;
int ans;
void bina(int obj)
{
	int lt=0, rt=n;
	int mid;
	while (lt < rt-1)
	{
		mid = (lt + rt) / 2;
		if (sp[mid] > obj)
			rt = mid;
		else if (sp[mid] < obj)
			lt = mid;
		else
			return;
	}
	ans += min(abs(obj - sp[lt]), abs(obj - sp[rt]));
}


int main(void)
{
	
	while (cin >> len)
	{
		if (len == 0)
			break;
		cin >> n >> m;
		sp[0] = 0;
		sp[n] = len;
		ans = 0;
		for (int i =1; i < n; i++)
		{
			cin >> sp[i];
		}
		sort(sp, sp + n + 1);
		for (int k = 0; k < m; k++)
		{
			cin >> b[k];
			bina(b[k]);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3516
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    print(N / 2 * (N / 2 + N % 2));
    
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int k;
    cin >> k;

    ll a[k];
    for (int i = 1; i <= k; i++) {
        cin >> a[k - i];
    }

    ll mn = 2;
    ll mx = 3;
    if (a[0] != 2LL) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i < k; i++) {
        if (mx / a[i] == mn / a[i] && mn % a[i] != 0LL && mx % a[i] != 0LL) {
            cout << -1 << endl;
            return 0;
        }

        if (mn % a[i] != 0LL) {
            mn = (mn / a[i] + 1) * a[i];
        }

        mx = mx / a[i] * a[i] + a[i] - 1;
    }
    
    cout << mn << " " << mx << "\n";
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) = p3_abc122b()

fun p3_abc122b() {
    val s = readLine()!!

    val actg = listOf('A', 'C', 'T', 'G')

    var answer = 0
    var streak = 0

    for (c in s) {
        if (c in actg) streak++ else streak = 0
        answer = Math.max(answer, streak)
    }

    println(answer)
}


Measured memory_bytes: 34164