akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;
using ll = long long;

#define reps(i,s,n) for( int(i) = (s); (i)<(n);(i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    string str,alpha = "abcdefghijklmnopqrstuvwxyz";

    int k;
    cin >> str >> k;
    vector<int> vec(str.length());
    int num;
    rep(i,str.length()){
        num = str[i] - 'a';
        vec[i] = num;
        if(vec[i] == 0) vec[i] = 26;
        //cout << alpha[num]  << "," << num << endl;
    }
    rep(l,str.length()){
        //if(vec[l]==0)vec[l]=26;
        //cout << k << "," << 26-vec[l] << endl;
        if(k >= 26-vec[l]){
            k -= (26-vec[l]);
            vec[l] = 0;
        }
    }
    
    vec[str.length()-1] = (vec[str.length()-1] + k) % 26;
    
    rep(i,str.length()) cout << alpha[vec[i]];
    cout << endl;

    return 0;
}



Measured memory_bytes: 1024
def solve():
    S = input()
    T = input()
    ans = len(T)
    if (len(S) == len(T)):
        tmp = 0
        for j in range(len(T)):
            if S[j] != T[j]:
                tmp += 1
        ans = tmp
    else:
        for i in range(len(S) - len(T)):
            tmp = 0
            for j in range(len(T)):
                if S[j + i] != T[j]:
                    tmp += 1
            ans = min(ans, tmp)
    print(ans)
        

if __name__ == "__main__":
    solve()

Measured memory_bytes: 67568
#include<iostream>
using namespace std;
int a, b;
int main(){
  cin >> a >> b;
  if((a + b) % 2 == 0){
    cout << (a + b) / 2 << endl;
    }else{
     cout << (a + b) / 2 + 1 << endl;
    }
  return 0;
  }


Measured memory_bytes: 256
N = int(input())
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
x = factorize(N)
counter = 0
for item in x:
  if item[1]==1:
    counter += 1
  else:
    temp = item[1]
    i = 1
    while temp > 0:
      temp -= i
      i += 1
      if temp >= 0:
        counter += 1
print(counter)

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

int main(){
    int n, k;
    cin >> n >> k;
    //ｎこをｋ人にわける
    vector<int> pe(k);
    int flag = 0;
    while(true){
        for(int i=0; i<k; i++){
            pe.at(i) += 1;
            n--;
            if(n==0){
                flag = 1;
                break;
            }
        }

        if(flag == 1) break;
    }

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

    cout << pe.at(k-1) - pe.at(0) << endl;
}

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

int n,tep,ax,ay;
int a[10];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&tep);
		if(1<=tep&&tep<=399)a[1]++;
		if(400<=tep&&tep<=799)a[2]++;
		if(800<=tep&&tep<=1199)a[3]++;
		if(1200<=tep&&tep<=1599)a[4]++;
		if(1600<=tep&&tep<=1999)a[5]++;
		if(2000<=tep&&tep<=2399)a[6]++;
		if(2400<=tep&&tep<=2799)a[7]++;
		if(2800<=tep&&tep<=3199)a[8]++;
		if(tep>=3200)a[9]++;
	}
	for(int i=1;i<=8;i++)
	{
		if(a[i]!=0)ax++;
	}
	ay=ax+a[9];
	if(ax==0 && a[9]!=0)
	{
		ax=1;
		ay=a[9];
	}
	printf("%d %d",ax,ay);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    vector<pair<long, long> > a(n), b(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(a[i].first), &(a[i].second) );
    }
    sort(a.begin(), a.end());

    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(b[i].first), &(b[i].second) );
    }
    sort(b.begin(), b.end());

    long count=0;
    vector<long> aflag(n,0);
    long j;
    for(i=0; i<n; i++) {
        long ymax=-10000;
        long jsave=-1;
        for(j=0; j<n; j++) {
            if(!aflag[j] && a[j].first<b[i].first && a[j].second<b[i].second) {
                if(a[j].second > ymax) {
                    ymax=a[j].second;
                    jsave=j;
                }
            }
        }
        if(jsave>=0) {
            aflag[jsave] = 1;
            count++;
        }
    }
    printf("%ld\n", count);

    return 0;
}

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

int main(){
  int a[4];
  int t[4];
  int a_ans = 0;
  int t_ans = 0;
  int ans = 0;

  for(int i = 0; i < 4; i++){
    cin >> a[i];
    a_ans+=a[i];
  }

  for(int i = 0; i < 4; i++){
    cin >> t[i];
    t_ans+=t[i];
  }

  ans = max(t_ans,a_ans);
  cout << ans << endl;

}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;

template<typename T>
T gcd(T a, T b) {
  if(a > b)return gcd(b, a);
  if(a == 0)return b;
  return gcd(b % a, a);
}


int main(int argc, char const* argv[])
{
  ll a, b; cin >> a >> b;
  ll res = a * (b / gcd<ll>(a, b));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;

    if(a < 1200) puts("ABC");
    else if(a < 2800) puts("ARC");
    else puts("AGC");
    
}

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

using namespace std;

bool parse(const string& s, int& idx){
	if(idx >= s.size()) return true;
	if(s[idx++]!='m') return false;
	if(idx >= s.size()) return false;
	if(s[idx]=='e'){
		++idx;
	} else {
		if(!parse(s, idx)) return false;
		if(idx >= s.size() || s[idx++] != 'e') return false;
	}
	if(idx >= s.size()) return false;
	if(s[idx]=='w'){
		++idx;
	} else {
		if(!parse(s, idx)) return false;
		if(idx >= s.size() || s[idx++] != 'w') return false;
	}
	return true;
}

int main(){
	string s;
	while(cin >> s){
		int idx = 0;
		bool ok = parse(s, idx);
		cout << (ok && idx == s.size() ? "Cat" : "Rabbit") << endl;
	}
}

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

int main(void){
    ll m,ans;
    int n,i;
    while(1){
        cin >> n >> m;
        if(n==0) return 0;
        vector< pair<int,int> > PD(n);
        for(i=0;i<n;i++){
            cin >> PD[i].second >> PD[i].first;
        }
        sort(PD.begin(), PD.end());
        ans=0;
        i=n-1;
        while(1){
            if(i<0) break;
            if(m>=PD[i].second){
                m-=PD[i].second;
                i--;
            }else{
                ans+=(PD[i].second-m)*PD[i].first;
                i--;
                break;
            }
        }
        while(i>=0){
            ans+=PD[i].second*PD[i].first;
            i--;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3152
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			String op = sc.next();
			char[] s1 = sc.next().toCharArray();
			char[] s2 = sc.next().toCharArray();

			s = "";
			int p1 = 0, p2 = 0;
			int l1 = s1.length, l2 = s2.length;
			while(p1 < l1 && p2 < l2){
				if(s1[p1] == s2[p2]){
					s += s1[p1];
					p1++;
					p2++;
				}
				else if(s1[p1] == '('){
					p1 = read(s1,p1,(op.equals("u") ? true : false));
				}
				else{
					p2 = read(s2,p2,(op.equals("u") ? true : false));
				}
			}

			if(op.equals("u")){
				while(p1 < l1) s += s1[p1++];
				while(p2 < l2) s += s2[p2++];
			}

			System.out.println(s);
		}
	}

	private static String s;

	private static int read(char[] t,int p,boolean flg){
		int level = 0;
		do{
			if(flg) s += t[p];
			if(t[p] == '(') level++;
			else if(t[p] == ')') level--;
			p++;
		}while(level != 0);
		return p;
	}
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int c_ans = 0;
 
  for(int i=1; i<N+1; i++){
    int ans = 0;
    int j = 1;
    int t = 1;
   while(t > 0){
    t = i / j;
     if(t <= 0){
       break;
     }
    ans = ans + t %10;
    j = j * 10;
   }
   if(ans >= A && ans <= B){
    c_ans = c_ans + i;
   }
  }
  cout << c_ans << endl;
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int M, N;
  cin >> M >> N;
  int a[M][N];
  rep(i, M) rep(j, N) {
    cin >> a[i][j];
    if(i) a[i][j] = !a[i][j];
  }
  int ans = 0;
  rep(i, M) {
    int mx = 0;
    rep(j, N) {
      int b[N]; rep(j, N) b[j] = a[i][j];
      int cnt = 0;
      rep(k, j) {
	if(b[k]) cnt++;
	b[k+1] = !b[k+1];
      }
      for(int k = N-1; k > j; k--) {
	if(b[k]) cnt++;
	b[k-1] = !b[k-1];
      }
      if(b[j]) cnt++;
      mx = max(mx, cnt);
    }
    ans += mx;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
    ll N,D;
    cin >> N >> D;
    ll cnt = 0;
    rep(i,N){
        ll x,y;
        cin >> x >> y;
        if(D*D>= (x*x)+(y*y)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <iostream>

const long long INF = 1e9 + 7;
int main(){
    long long n, m;
    std::cin >> n >> m;

    long long nFact = 1, i = nFact;
    while(i <= n){
        nFact *= i++;
        nFact %= INF;
    }

    long long mFact = 1, j = mFact;
    while(j <= m){
        mFact *= j++;
        mFact %= INF;
    }

    long long ans = 0;
    switch(std::abs(n - m)){
        case 0:
            ans = nFact * mFact * 2 % INF;
            break;
        case 1:
            ans = nFact * mFact % INF;
            break;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main(){
	int A;
	int B;
	cin >> A;
	cin >> B;
	
	int sum;
	int pro;
	int dif;
	
	sum = A+B;
	pro = A*B;
	dif = A-B;
	
	int ans;
	ans = max({sum, pro, dif});
	cout << ans << endl;
	
	return 0;
}	

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  ll cnt = 0;
  n -= 1;
  while( n > 0 ){
    n -= k-1;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n;
  cin >> n;
  vector<set<string>> ans(10);
  ans[0].insert("a");
  rep(i,n-1){
    for(auto value: ans[i]){
      string s = value;
      rep(j,s.size()){
        string p = s;
        string q = s;
        char x = s[j] + 1;
        p.push_back(s[j]);
        q.push_back(x);
        ans[i+1].insert(p);
        ans[i+1].insert(q);
      }
      //cout << s << endl;
      //ans[i+1].push_back(s);
    }
  }
  
  
  while(!ans[n-1].empty()){
    cout << *begin(ans[n-1]) << endl;
    ans[n-1].erase(*begin(ans[n-1]));
  }
  
}




Measured memory_bytes: 16384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	int N; cin >> N;
	vector<pair<int, int>>ups;
	vector<pair<int, int>>downs;
	for (int i = 0; i < N; ++i) {
		string st; cin >> st;
		int left = 0;
		int right = 0;
		for (int i = 0; i < st.size(); ++i) {
			if (st[i] == '(') {
				right++;
			}
			else {
				right--;
				left = min(left, right);
			}
		}
		left = -left;
		if (right >= 0) {
			ups.push_back(make_pair(left, right));
		}
		else {
			downs.push_back(make_pair(left, right));
		}
	}
	sort(ups.begin(), ups.end());
	int num = 0;
	bool ok = true;
	auto it = ups.begin();
	while (it != ups.end()) {
		if (num >= it->first) {
			num += it->second;
		}
		else {
			ok = false;
			break;
		}
		it++;
	}
	sort(downs.begin(), downs.end(), [](const pair<int, int>&l, const pair<int, int>&r) {
		return l.first + l.second > r.first + r.second;
	});
	auto jt = downs.begin();
	while (jt != downs.end()) {
		if (num >= jt->first) {
			num += jt->second;
		}
		else {
			ok = false;
			break;
		}
		jt++;
	}
	if (num != 0)ok = false;
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3200
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K,N = map(int, readline().split())
    A = [int(i) for i in readline().split()]

    d = 0
    for i in range(N-1):
        tmp = A[i+1] - A[i]
        d = max(d, tmp)

    d = max(d, K - A[-1] + A[0])

    print(K - d)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24908
N = int(input())
count = 0
item = [3, 5, 7]

def dfs(s):
    global count
    if s > N:
        return
    string = str(s)
    if '3' in string and '5' in string and '7' in string:
        count += 1
    dfs(10*s + 3)
    dfs(10*s + 5)
    dfs(10*s + 7)

dfs(0)
print(count)

Measured memory_bytes: 3060
#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;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
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:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll dp[55][55][50*50+1];
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,A; cin >>N >> A;
    vector<ll> x(N);
    for(auto& in:x) cin >> in;
    dp[0][0][0] = 1;
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= i; j++){
            for(int k = 0; k <= N*50; k++){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N;i++){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 53504
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue>
#include<cmath>
#include<utility>
#include<set>
#include<cmath>
#define MOD 998244353
using namespace std;
long long PGCD(long long a, long long b)
{
    if(a%b==0)
        return b;
    return PGCD(b, a%b);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a, b;
    cin >> a >> b;
    if(a < b)
        swap(a, b);
    cout << (a*b)/PGCD(a, b);
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = [0] * N
ans = 0 
from collections import deque        
ansL = deque()
for i in range(N):
    m = N - i 
    count = 0
    for k in range(1,N//m+1):
        count += b[m*k-1]
    if count % 2 != a[m-1]:
        b[m-1] = 1
        ans += 1
        ansL.appendleft(m)    
print(ans)
print(*ansL) 
    

    

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



//メイン関数
int main()
{
	ll N, W;
	cin >> N >> W;
	vector<pair<ll, ll>> wv(N);
	REP(i, N)
	{
		ll a, b;
		cin >> a >> b;
		wv[i] = {a,b};
	}

	const int siz = 1100 * N;
	vector<vector<ll>> dp(N, vector<ll>(siz, INFL));
	dp[0][0] = 0;
	dp[0][wv[0].second] = wv[0].first;
	FOR(i, 1, N)REP(j, siz)
	{
		dp[i][j] = dp[i - 1][j];

		ll w = wv[i].first;
		ll v = wv[i].second;
		if(j - v >= 0)dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w);
	}
	ll res = 0;
	REP(i, siz)if(dp.back()[i] <= W)res = i;
	cout << res << endl;
	cin >> N;

	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int a, b;
  std::cin >> a >> b;
  a = (a == 1 ? 14 : a);
  b = (b == 1 ? 14 : b);
  if (a > b)
    std::cout << "Alice" << std::endl;
  else if (a < b)
    std::cout << "Bob" << std::endl;
  else
    std::cout << "Draw" << std::endl;
}


Measured memory_bytes: 256
N = int(input())
p_infos = []

for i in range(N):
    p_info = [int(s) for s in input().split()]
    if p_info[2] == 0:
        p_infos.append(p_info)
    else:
        p_infos.insert(0, p_info)

is_finished = False
for c_x in range(101):
    if is_finished: break
    for c_y in range(101):
        if is_finished: break
        c_h = -1 # impossible value
        for p in p_infos:
            x, y, h = p[0], p[1], p[2] 
            x_d, y_d = abs(x - c_x), abs(y - c_y)
            if h > 0:
                if c_h == -1:
                    c_h = h + x_d + y_d
                elif c_h != h + x_d + y_d:  
                    break
            elif c_h - x_d - y_d > 0:
                break

            if p == p_infos[-1]:
                print(c_x, c_y, c_h)
                is_finished = True


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
const int INFTY = 1001001001;

void bfs(vector<vector<int>> &edges, vector<P> &dist, int node)
{
    queue<int> Q;
    Q.push(node);
    dist[node].first = 0;
    while (!Q.empty())
    {
        node = Q.front();
        Q.pop();
        for (int e : edges[node])
        {
            if (dist[e].first == INFTY)
            {
                dist[e].first = dist[node].first + 1;
                Q.push(e);
            }
        }
    }
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> edges(N);
    vector<P> dist(N), e(N-1);
    vector<int> cost(N);

    int a, b;
    for (int i = 0; i < N - 1; ++i)
    {
        cin >> a >> b;
        edges[--a].push_back(--b);
        edges[b].push_back(a);
        e[i] = P(a, b);
    }

    int max_index, max_v = -1;
    for (int i = 0; i < N; ++i)
    {
        cin >> cost[i];
        dist[i].second = i;
        dist[i].first = INFTY;
        if ((int)edges[i].size() > max_v)
        {
            max_v = edges[i].size();
            max_index = i;
        }
    }

    bfs(edges, dist, max_index);
    sort(dist.begin(), dist.end(), less<P>());
    sort(cost.begin(), cost.end(), greater<int>());

    vector<int> nodes(N);
    for (int i = 0; i < N; ++i)
    {
        nodes[dist[i].second] = cost[i];
    }

    int ans = 0;
    for(P p : e){
        //cout << p.first << " " << p.second << " " << nodes[p.first] << " " << nodes[p.second] << endl;
        ans += min(nodes[p.first], nodes[p.second]);
    }

    cout << ans << endl;
    for (int i = 0; i < N; ++i)
    {
        if (i)
            cout << " ";
        cout << nodes[i];
    }
    cout << endl;
}


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

using namespace std;


int main()
{
	int n,q,num,cnt = 0;
	vector<int> s;

	cin >> n;
	for (int i = 0; i != n; ++i)
	{
		cin >> num;
		s.push_back(num);
	} 

	s.erase(unique(s.begin(), s.end()), s.end());

	cin >> q;
	for (int i = 0; i != q; ++i)
	{
		cin >> num;
		if (find(s.begin(), s.end(), num) != s.end())
		{
			++cnt;
		}
	}

	cout << cnt << endl;

	return 0;

}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll a,b,k;

int main(){
  cin >> a >> b >> k;
  if(a>k){
    cout << a-k << " " << b;
    return 0;
  }
  cout << 0 << " " << max(b+a-k,0ll);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n, m, X;
    cin >> n >> m >> X;
    vector<int> cost(n);
    vector<vector<int>> arr(n, vector<int>(m));
    for(int i = 0; i < n; ++i){
        cin >> cost[i];
        for(int j = 0; j < m; ++j){
            cin >> arr[i][j];
        }
    }

    int best = 1 << 30;
    for(int i = 0; i < (1 << n); ++i){
        vector<int> skill(m);
        int cur_cost = 0;
        for(int j = 0; j < n; ++j){
            if(i & (1 << j)){
                cur_cost += cost[j];
                for(int k = 0; k < m; ++k){
                    skill[k] += arr[j][k];
                }
            }
        }
        bool good = true;
        for(int j = 0; j < m; ++j){
            if(skill[j] < X){
                good = false;
                break;
            }
        }
        if(good){
            best = min(best, cur_cost);
        }
    }
    if(best == (1<<30))
        cout << -1 << endl;
    else
        cout << best << endl;
}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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


int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int ans = 0;
    for(int j = 1; j*j < i; j++) {
      for(int k = j; j*j+k*k < i; k++) {
        for(int m = k; j*j+k*k+m*m < i; m++) {
          int num = j*j+k*k+m*m+j*k+k*m+m*j;
          if(num==i&&j!=k&&k!=m) ans += 6;
          else if(num==i&&j==k&&k==m) ans++;
          else if(num==i&&j==k) ans += 3;
          else if(num==i&&k==m) ans += 3;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let str=readLine()!
var flag=0

var i=0
for j in str{
  if i%2==1&&(j == "R"){flag-=1
                      break}
  if i%2==0&&(j == "L"){flag-=1
                      break}
  i+=1
}
if flag == -1 {print("No")}else{print("Yes")}

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


using namespace std;

int main(){
	string s1, s2, s3;
	
	cin >> s1 >> s2 >> s3;
	 
	s1[0] = char(s1[0] - 'a' + 'A');
	s2[0] = char(s2[0] - 'a' + 'A');
	s3[0] = char(s3[0] - 'a' + 'A');
	cout << s1[0] << s2[0] << s3[0 ]<< endl;
	return 0;
} 

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

#define NUM_MAX	100

typedef struct _numAryList numAryList;
typedef struct _numAryList {
	numAryList	*front;
	numAryList	*back;
	int			num;
} numAryList;

int main(void)
{
	numAryList numAry[NUM_MAX];
	numAryList head;
	numAryList *next;
	numAryList *first;
	numAryList *second;
	int num;
	int ret;
	int i;
	int alice = 0;
	int bob = 0;

	/* 変数初期化 */
	memset(&numAry, 0, sizeof(numAry));
	head.front = &head;
	head.back = &head;
	head.num = 0;

	ret = scanf("%d", &num);
	for(i=0; i<num; i++)
	{
		ret = scanf("%d", &numAry[i].num);

		/* 双方向リストの初期化 */
		numAry[i].front = &head;
		numAry[i].back = head.back;
		head.back = &numAry[i];
		numAry[i].back->front = &numAry[i];
	}

	next = &numAry[0];
	first = &head;
	second = &head;

	/* リストから全ての要素を抜いた場合、whileを抜ける */
	while(head.front != &head)
	{
		/* アリスがカードを取るか判定 */
		if(first->num < next->num)
		{
			/* アリスが捨てたカードをボブに渡す */
			second = first;
			first = next;
		}
		else
		{
			/* アリスが取らなかったカードを、ボブが取るか判定 */
			if(second->num < next->num)
			{
				second = next;
			}
		}

		/* リストを一周検索したか判定 */
		if(next == &head)
		{
			/* リストを1周した場合、手持ちのカードの点数を立つ */
			alice += first->num;
			bob += second->num;

			/* アリスが取ったカードをリストから抜く */
			first->back->front = first->front;
			first->front->back = first->back;

			/* ボブが取ったカードをリストから抜く */
			second->back->front = second->front;
			second->front->back = second->back;

			first = &head;
			second = &head;
		}
		next = next->front;
	}
	printf("%d", alice - bob);

	return(0);
}


Measured memory_bytes: 128
n = int(input())
lst = list(map(int,input().split()))

count = 0
for i in range(n):
    minj = i
    for j in range(i+1,n):
        if lst[j] < lst[minj]:
            minj = j
    if minj != i:
        lst[i], lst[minj] = lst[minj], lst[i]
        count += 1
print(*lst)
print(count)




Measured memory_bytes: 5604
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            double a = sc.nextDouble();
            double b = sc.nextDouble();
            double c = sc.nextDouble();
            double d = sc.nextDouble();
            double e = sc.nextDouble();
            double f = sc.nextDouble();
            double x;
            double y;
            double ae;
            double bd;
            double o;
            double af;
            double dc;
            double p;
            double bf;
            double ec;
            double q;

            ae = a * e;
            bd = b * d;
            o = bd - ae;

            af = a * f;
            dc = d * c;
            p = dc - af;

            y = p / o;

            bf = b * f;
            ec = e * c;
            q = (bf - ec);

            x = q / o;
            if (Math.abs(x) < 0.0001) {
                x = 0;
            }
            if (Math.abs(y) < 0.0001) {
                y = 0;
            }
            System.out.printf("%.3f %.3f\n", x, y);
        }
    }
}



Measured memory_bytes: 28264
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define INF 1000000000

int main()
{
	ll k,a,b,ans=0;
	cin >> k >> a >> b;

	if(b<=a)ans=1+k;
	else{
		ll c = k;
		if(c>=a+1){
			c -= a+1;
			ans += b + c/2*(b-a);
			if(c%2)ans+=1;
		}
		if(ans<1+k)ans=1+k;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
#define INF 2000000000

int main() {
	ll a, b, c, d, x, y;
	cin >> a >> b >> c >> d;
	if (c % b == 0)x = c / b;
	else x = c / b + 1;
	if (a % d == 0)y = a / d;
	else y = a/d + 1;
	if (x <= y)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
N = int(input())
*W, = map(int, input().split())
s1, s2 = 0, sum(W)
ans = sum(W)
for i in range(N):
	s1 += W[i]
	s2 -= W[i]
	ans = min(ans, abs(s1 - s2))
print(ans)

Measured memory_bytes: 3060
#pragma region template

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#pragma region random

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}

#pragma endregion

#pragma region debug
string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#pragma endregion

#pragma endregion

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    int flag = 0,n = s.size();
    for(int i=0;i<n;i++)
    {
        if(i&1)
        {
            if(s[i]=='R')
            flag = 1;
        }
        else
        {
            if(s[i]=='L')
            flag = 1;
        }
    }
    if(flag)
    cout<<"No";
    else
    cout<<"Yes";

    return 0;

}

Measured memory_bytes: 256
def solve(n, k, a):
    ori_k = k

    mapper = {}
    for i in range(n):
        idx = i+1
        to = a[i]
        mapper[idx] = to

    path = [1]
    cur_town = 1
    visited = set()
    visited.add(1)

    before_cycle = None
    while k > 0:
        k -= 1
        cur_town = mapper[cur_town]
        if k == 0:
            return cur_town
        if cur_town in visited:
            before_cycle = path.index(cur_town)
            path = path[path.index(cur_town):]
            break
        
        path.append(cur_town)
        visited.add(cur_town)

    # print(path, len(path))
    # print(before_cycle)
    # print((ori_k-before_cycle) % len(path))
    result = path[(ori_k-before_cycle) % len(path)]
    return result



n, k = map(int, input().split())
a = list(map(int, input().split()))
result = solve(n,k, a)
print(result)


     



Measured memory_bytes: 49340
#include<iostream>
using namespace std;
int main(){
    long long n,d,x,y,s=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>x>>y;
    	if(x*x+y*y<=d*d)s++;
    }
	cout<<s;
	return 0;
}

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

const int MAXN = 303;
double memo[MAXN][MAXN][MAXN];
int n;

double dp(int i, int j, int k) {
    if(i < 0 || j < 0 || k < 0)
        return 0.0;
    if(memo[i][j][k] != 0.0)
        return memo[i][j][k];
    if(i == 0 && j == 0 && k == 0)
        return 0.0;
    double ex = (double)(n - i - j - k)/((double)(i + j + k));
    double p = 0.0;
    if(i > 0)
        p += ((double)i)*(dp(i - 1, j + 1, k) + 1.0);
    if(j > 0)
        p += ((double)j)*(dp(i, j - 1, k + 1) + 1.0);
    if(k > 0)
        p += ((double)k)*(dp(i, j, k - 1) + 1.0);
    p /= (double)(i + j + k);
    return memo[i][j][k] = ex + p;
}

int main() {
    cin >> n;
    int ct1 = 0, ct2 = 0, ct3 = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x == 1)
            ct1++;
        if(x == 2)
            ct2++;
        if(x == 3)
            ct3++;
    }
    cout << fixed << setprecision(15) << dp(ct3, ct2, ct1) << endl;
}

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

int main(void) {
    char S[255];
    int ans=0;
    int i;
    
    scanf("%s\n",S);
    for (i=0; i<=3; i++) {
        if (S[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
L1 =[int(i) for i in input().split()]
L2=sorted(L1)
if L2[0]==0:
    print(0)
elif L2[-1]*L2[-2]>10**18:
    print(-1)
else:
    ans=1
    for i in range(N):
        ans*=L2[i]
    if ans<=10**18:
        print(ans)
    else:
        print(-1)

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

int main(){
  int n;
  cin >> n;
  int a[n+1]={};
  for(int i=1; i<n; i++){
    int b;
    cin >> b;
    b--;
    a[b]++;
  }
  for(int i=0; i<n; i++){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4408
import sys
from collections import Counter
from math import gcd


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def profile(fish):
    x, y = fish
    GCD = gcd(abs(x), abs(y))

    return (abs(x // GCD), abs(y // GCD), int((x >= 0) ^ (y >= 0)))


N = int(input())
F = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]
modFacts, invs = prepare(N)

C0 = Counter()
C1 = Counter()
zero = 0
for f in F:
    if f == (0, 0):
        zero += 1
    else:
        x, y, flag = profile(f)
        if x == 0:
            C0[(0, 1, 0)] += 1
            C1[(0, 1, 0)] += 1
        elif y == 0:
            C0[(0, 1, 0)] += 1
            C1[(1, 0, 1)] += 1
        else:
            C1[(x, y, flag)] += 1
            if flag:
                x, y = y, x
                flag = 0
            C0[(x, y, flag)] += 1

ans = 1
for x, y, flag in C0.keys():
    b = C1[(y, x, flag ^ 1)]
    a = C0[(x, y, flag)] - b
    cnt = (pow(2, a, MOD) - 1) + (pow(2, b, MOD) - 1) + 1
    ans *= cnt
    ans %= MOD
ans -= 1
ans += zero
print(ans % MOD)


Measured memory_bytes: 195984
def rsp(t):
  t=t.replace('r','P')
  t=t.replace('p','S')
  t=t.replace('s','R')
  return t
 
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
T_rev=list(rsp(T))
 
if N<K:
  print(T_rev.count('R')*R+T_rev.count('S')*S+T_rev.count('P')*P)
else:
  for i in range(K,N):
    if T_rev[i]==T_rev[i-K]:
      T_rev[i]='x'
  print(T_rev.count('R')*R+T_rev.count('S')*S+T_rev.count('P')*P)

Measured memory_bytes: 4212
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 998244353;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 100005
// vector < vector < int >  > v(MAXN);
// int visit[MAXN];
// int d[MAXN];
// int deg[MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
void pre(){
}

void solve(){
  int n,m;
  cin>>n>>m;
  // v.clear();

  vector < vector < int >  > v(n+5);
  int visit[n+5] = {0};
  int d[n+5] = {0};
  int deg[n+5]= {0};

  for(int i = 0;i<m;i++){
    int x,y;
    cin>>x>>y;
    v[x].push_back(y);
    deg[y]++;
  }
  queue < int > q;
  for(int i = 1;i<=n;i++){
    if(deg[i] == 0){
      q.push(i);
    }
  }

  while(!q.empty()){
    int vertex = q.front();
    q.pop();
    for(int i = 0;i<v[vertex].size();i++){
      int node = v[vertex][i];
      if(visit[node] == 1) continue;
      else{
        deg[node]--;
        d[node] = max(d[node],d[vertex] + 1);
        if(deg[node] == 0){
          visit[node] = 1;
          q.push(node);
        }
      }
    }
  }

  int ans = 0;
  for(int i = 1;i<=n;i++) ans = max(ans,d[i]);
    cout<<ans;
}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 9548
/**
 *      ABC 88 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 03:39:21
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int c1, c2, c3, c4, c5, c6, c7, c8, c9;
    cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6 >> c7 >> c8 >> c9;

    vector<int> d;
    d.push_back(c1+c5-c2-c4); d.push_back(c4+c8-c5-c7); d.push_back(c1+c8-c2-c7);
    d.push_back(c2+c6-c3-c5); d.push_back(c5+c9-c6-c8); d.push_back(c2+c9-c3-c8);
    d.push_back(c1+c6-c3-c4); d.push_back(c4+c9-c6-c7); d.push_back(c1+c9-c3-c7);

    if (*max_element(d.begin(), d.end()) == 0 && *min_element(d.begin(), d.end()) == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;

}



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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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

int main(void) {
	
	while (1) {
		int n, a, b, c, x;
		int pos = 1;
		int time = -1;
		int y[101] = {};

		cin >> n >> a >> b >> c >> x;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> y[i];
		}
			if (x == y[pos]) {
				pos++;
			}
		if (pos == n + 1) {
			time = 0;
		}
		FOR(i, 1, 10000) {
			if (time == 0) {
				break;
			}
			x = (a*x + b) % c;
			if (x == y[pos]) {
				pos++;
				if (pos == n + 1) {
					time = i;
					break;
				}
			}
			if (time != -1) {
				break;
			}
		}
		cout << time << endl;
	}
	
}


Measured memory_bytes: 3080
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

print ("Yes" if x in g1 and y in g1 or 
       x in g2 and y in g2 or x in g3 and y in g3 else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};



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

	vector<ll> a(N + 1);

	repn(i, N) cin >> a[i];

	repn(i, N) a[i] -= K;

	vector<ll> sum(N + 2);
	sum[1] = 0;
	repn(i, N) sum[i+1] = sum[i] + a[i];

	vector<pair<ll, ll>> p(N + 2);
	repn(i, N + 1) p[i] = { sum[i],i };

	sort(++p.begin(), p.end());

	vector<ll> z(N + 2);
	repn(i, N + 1) z[p[i].second] = i;

	//repn(i, N + 1) cout << sum[i];
	//repn(i, N+1) cout << z[i];

	Segment_Tree<ll> sg(N + 1, [](ll a, ll b) {return a + b; }, 0);

	ll ans = 0;
	for (ll i = N + 1; i >= 1; i--) {
		ans += sg.query(z[i], N + 2);
		sg.update(z[i], 1);
	}

	cout << ans;
	

	system("PAUSE");

}





Measured memory_bytes: 12408
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

string a,b;

int main(){
    while(cin>>a>>b){
        if(a.size()<b.size()){ printf("LESS\n"); continue;}
        if(a.size()>b.size()){ printf("GREATER\n"); continue;}
        bool flag=false;
        for(int i=0;i<a.size();i++){
            if(a[i]==b[i]) continue;
            if(a[i]>b[i]){ flag=true;printf("GREATER\n");break;}
            if(a[i]<b[i]){ flag=true;printf("LESS\n");break;}
        }
        if(!flag) printf("EQUAL\n");
    }
    return 0;
}


Measured memory_bytes: 256