akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main () {
	ll n, m, a, b;
    string s;
	ll i, j, k;
    ll num = 0;
	ll ret = 0;
	
	cin >> n >> a >> b >> s;
    
    k = 1;
    for ( i = 0; i < n; i++ ) {
        ret = 0;
        if ( s[i] == 'a' ) {
            if ( num < a + b ) {
                num++;
                ret++;
            }
        }
        else if ( s[i] == 'b' ) {
            if ( (num < a + b) && ( k <= b) ) {
                k++;
                num++;
                ret++;
            }
        }
        cout << ((ret == 1) ? "Yes" : "No") << endl;
    }
	
	return 0;
}


Measured memory_bytes: 3724
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      myout(Math.max(one.get(0) * one.get(1), one.get(2) * one.get(3)));
	}
	//Method addition frame start


  
	//Method addition frame end
}


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

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

void solve()
{
    lli n; cin>>n;
    lli arr[n];
    forz(i,n) cin>>arr[i];

    lli dp[n+1];
    forz(i,n+1) dp[i]=0;

    dp[1] = 0;
    dp[2] = abs(arr[1]-arr[0]);

    for(lli i=3; i<=n; i++)
    {
        lli c1 = dp[i-1] + abs(arr[i-1] - arr[i-1-1]);
        lli c2 = dp[i-2] + abs(arr[i-1] - arr[i-1-2]); 

        // deb(i, c1, c2);

        dp[i] = fmin(c1, c2);
    }

    cout<<dp[n]<<endl;
}

int main()
{
    kira; 

    lli t=1; //cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}




















Measured memory_bytes: 1792
a,b = map(int,input().split())

def gcd(i,j):
  if i > j:
    i,j = j,i
  j %= i
  if j == 0:
    return i
  else:
    return gcd(j,i)

g = gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if g == 1:
  print(1)
else:
  print(len(factorization(g))+1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int c[15],d[15][15];
int main(){
    scanf("%d%d%d",&n,&m,&t);
    rep(i,1,n){
        scanf("%d",&c[i]);
        rep(j,1,m) scanf("%d",&d[i][j]);
    }
    int a[15];
    int cm=(1<<n)-1;
    int sum=inf;
    rep(i,0,cm){
        memset(a,0,sizeof a);
        int s=0;
        rep(j,0,n-1) if(i&(1<<j)) {
            s+=c[j+1];
            rep(k,1,m) a[k]+=d[j+1][k];
        }
        bool f=1;
        rep(i,1,m) if(a[i]<t) f=0;
        if(f) sum=min(sum,s);
    }
    if(sum==inf) puts("-1");
    else printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3792
def main():
    import sys
    input=sys.stdin.readline
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    a=sorted(a)
    k=[[int(i) for i in input().split()] for i in range(m)]
    k=sorted(k,key=lambda x:-x[1])
    
    now=0
    flag=True
    for x,y in k:
        if flag:
            for i in range(x):
                if i+now>=n:
                    print(sum(a))
                    exit()
                if flag:
                    if y>a[i+now]:
                        a[i+now]=y
                    else:
                        flag=False
        now+=x
    print(sum(a))
if __name__=="__main__":
    main()

Measured memory_bytes: 31000
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
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;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll a, b, c;
    cin >> a >> b >> c;
    bool flag = false;
    for(int i=1; i<=b; i++){
        if(a*i % b == c) flag = true;
    }
    if(flag) YES();
    else NO();
}

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


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


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	int a, b, c, n;
	int ans = 0;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				a = GCD(i, j);
				//printf("%d %d = %d\n", i, j,a);
				b = GCD(a,k);
				//printf("%d %d\n",a,b);
				ans += b;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,l;
    cin>>n>>m>>l;
    long long NM[100][100]={{}};
    for(int s=0;s<n;s++)
    {
        for(int t=0;t<m;t++)
        {
            cin>>NM[s][t];
        }
    }//NM行列を格納した
    long long ML[100][100]={{}};
    for(int s=0;s<m;s++)
    {
        for(int t=0;t<l;t++)
        {
            cin>>ML[s][t];
        }
    }//ML行列を格納した
    for(int a=0;a<n;a++)
    {
        for(int b=0;b<l;b++)
        {
            long long S={};
            for(int c=0;c<m;c++)
            {
                S+=NM[a][c]*ML[c][b];
            }
            
            if(b==l-1)cout<<S<<endl;
            else cout<<S<<" ";
        }
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3260
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

int n;
vector<bool> visit(n);
vvec G(n);
void dfs(int now){
    visit[now]=true;
    for(int next:G[now]){
        if(visit[next]) continue;
        dfs(next);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int m;
    cin>>n>>m;
    visit.resize(n,false);
    G.resize(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        G[x].pb(y);
        G[y].pb(x);
    }
    
    ll ans=0;
    rep(i,n){
        if(!visit[i]){
            ans++;
            dfs(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
int s[110];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>s[i];
    }

    sort(s, s+N);

    int t = s[0];
    int ans = 1;
    REP(i,1,N){
        if(t < s[i]){
            t = s[i];
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> p(N);
  for (int i=0; i<N; i++){
    cin >> p[i];
  }
  vector<double> q(N, 0.0);
  rep(i, 0, N) {
    q[i] = (p[i]+1)/2.0;
  }
  vector<double> c(N+1, 0.0);
  double ans = 0.0;
  rep(i, 0, N) {
    c[i+1] = c[i]+q[i];
    if (i >= K-1) ans = max(ans, c[i+1]-c[i+1-K]);
  }
  printf("%.10lf\n", ans);

  return 0;
}


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

int main(){
    string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;

    int ans;
    for(int i = 0; i < 7; i++){
        if(s == week[i]) ans = 7 - i;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;

int main(){
    double N,K;
    cin >> N >> K;
    vector<int> A(N);
    double i_min;
    rep(i,N){
        cin >> A[i];
        if(A[i]==1) i_min=i+1;
    }

    int r;
    int ans=INF;
    rep(l,K){
        r=K-1-l;
        ans=min(ans,1+max(0,(int)ceil((i_min-1-l)/(K-1)))+max(0,(int)ceil((N-i_min-r)/(K-1))));
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
N, M = map(int, input().split())
K = [0] * N
L = [[] for _ in range(N + M)]
R = [i for i in range(N + M)]
def find(i):
  if R[i] == i:
    return i
  r = find(R[i])
  R[i] = r
  return r
def union(i, j):
  ri = find(i)
  rj = find(j)
  if ri > rj:
    R[ri] = rj
  else:
    R[rj] = ri
for i in range(N):
  _L = [int(x) + N - 1  for x in input().split()]
  for l in _L[1:]:
    union(i, l)
for i in range(N):
  find(i)
  if R[i]:
    print('NO')
    break
else:
  print('YES')

Measured memory_bytes: 26032
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
i = 2
cnt = 1
check = 0

# for i in range(2, n + 1):
#     m = n
#     while m % i == 0:
#         m //= i
#     m %= i
#     if m == 1:
#         print(i)
#         cnt += 1
# print(cnt)
# print()
# print()

out = [n]
while i < n: #割ってひく
    m = n
    if i - m / i > 2:
        break
    while m % i == 0:
        check = 1
        m //= i

    if (m % i == 1 and check):
        out.append(i)
        cnt += 1
    i += 1

i = 2
while i * i <= n: #割ってひく
    m = n
    while m % i == 0:
        m //= i
    if m == 1:
        out.append(i)
    i += 1

out += make_divisors(n - 1)
print(len(set(out)) - 1)

Measured memory_bytes: 40428
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
check=[0]*n
for i in range(m):
  a[i],b[i]=map(int,input().split())
  check[a[i]-1]+=1
  check[b[i]-1]+=1
  
for i in range(n):
  print(check[i])

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main() {
    int n;
    long long a[200010];
    scanf("%d", &n);
    long long sum_all = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        sum_all += a[i];
    }
    long long sum = 0;
    long long min_ = 1000000000000000;
    for (int i = 0; i < n - 1; i++) {
        sum += a[i];
        min_ = min(abs(sum - (sum_all - sum)), min_);
    }
    printf("%lld", min_);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll mod = 1e9+7;
vector<ll> fact;
ll add(ll a, ll b) {
    return (a + b) % mod;
}
ll mul(ll a, ll b) {
    return a * b % mod;
}
ll power(ll x, ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i <<= 1) {
        if (i & n) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}
ll inv(ll n) {
    return power(n, mod-2);
}
ll divi(ll a, ll b) {
    return mul(a, inv(b));
}
ll comb(ll n, ll r) {
    if (r < 0 || n < 0 || r > n) return 0;
    return divi(fact[n], mul(fact[r], fact[n-r]));
}
ll solve(ll n, ll m) {
    // cout << n+m << " " << m << endl;
    // cout << comb(n+m, m) << " " << comb(n+m, m-1) << " " << comb(n+m, m) - comb(n+m, m-1)<< endl;
    return (comb(n+m, m) - comb(n+m, m-1) + mod)%mod;
}
void init_fact() {
    fact.assign(1e6+10, 1);
    FOR(i, 1, fact.size()) fact[i] = mul(i, fact[i-1]);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int W, H, K; cin >> W >> H >> K;
    init_fact();
    ll ans = 0;
    REP(left, K+1) {
        ll down = K - left;
        ll right = W + left;
        ll up = H + down;
        // cout << up << " " << down << " " << left << " " << right << " " << solve(up, down) << endl;
        ans = add(ans, mul(comb(up+down+left+right, up+down), mul(solve(up, down), solve(right, left))));
    }
    cout << ans << endl;
}

Measured memory_bytes: 10744
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

ll N, W;
ll w[105], v[105];
ll dp[105][100005];

int main() {

    cin >> N >> W;
    rep(i, N) { cin >> w[i] >> v[i]; }

    rep(i, N) rep(j, 100005) dp[i][j] = INF;

    dp[0][0] = 0;

    rep(i, N) {
        rep(j, 100005) {
            if(j >= v[i]) {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    // rep(i, 10) {
    //     if(dp[N][i] <= W) {
    //         if(i)
    //             cout << " ";
    //         cout << dp[N][i];
    //     }
    // }

    int res = 0;
    rep(i, 100005) {
        if(dp[N][i] <= W) {
            res = i;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>
#include<stack>
#include <unordered_map>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define Quick ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)
#define PII pair<int,int>
#define PLL pair<long, long>
#define lowbit(x) (x&-x)

const int maxn = 50;
#define ERR 1e-6
#define fabs(a) (a < 0 ? -(a) : a)
#define square(a) ((a) * (a))
const int N = 2e3 +10;
int n;
int ans[N];
int d[N][N];
void floyd()
{
    for (int k = 1; k <= n; k ++ )
        for (int i = 1; i <= n; i ++ )
            for (int j = 1; j <= n; j ++ )
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main()
{
    //STDIN
    int x,y; cin >> n>> x >> y;
    for (int i = 1; i < n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            int dist = min(min(abs(j-i), abs(x-i) + 1 + abs(y-j)), abs(y-i) + 1 + abs(x-j));
            ans[dist]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        printf("%d\n", ans[i]);
    }
    return 0;

}

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

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 17;
ll const inf = 1000000000000000000;
int v[5 + nmax];
ll dp[1 + nmax][1 + nmax][1 + (1 << nmax)];
int seen[1 + nmax][1 + nmax][1 + (1 << nmax)];
std::pair<int,int> coef[1 + (1 << nmax)];

ll solve(int x, int y, int state) {
  if(y < x)
    return 0;
  else if(x == y)
    return 1LL * v[x] * (coef[state].first + coef[state].second);
  else if(0 < seen[x][y][state])
    return dp[x][y][state];
  else {
    seen[x][y][state] = 1;
    dp[x][y][state] = inf;
    for(int i = x; i <= y; i++) {
      ll result = 1LL * (coef[state].first + coef[state].second) * v[i] + 
                        solve(x, i - 1, state * 2) + solve(i + 1, y, state * 2 + 1);
      dp[x][y][state] = std::min(dp[x][y][state], result);
    }
    return dp[x][y][state];
  }
}

int main() {
  int n;
  std::cin >> n;
  coef[1] = {1, 1};
  for(int i = 2;i < (1 << nmax); i++) {
    if(i % 2 == 0)
      coef[i] = {coef[i / 2].first, coef[i / 2].first + coef[i / 2].second};
    else
      coef[i] = {coef[i / 2].first + coef[i / 2].second, coef[i / 2].second};
  }
  for(int i = 0;i < n; i++)
    std::cin >> v[i];
  std::cout << solve(1, n - 2, 1) + v[0] + v[n - 1];
  return 0;
}


Measured memory_bytes: 13976
n = int(input())

t = [0 for i in range(n)]
a = [0 for i in range(n)]

for i in range(n):
    t[i],a[i] = map(int,input().split())

t_num = t[0]
a_num = a[0]

for i in range(1,n):
    k = max(-(-t_num//t[i]),-(-a_num//a[i]))
    #その比に票を合わせる
    t_num,a_num = k*t[i],k*a[i]

print(t_num + a_num)


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


#define rep(i, N) for(ll i=0; i<(N); ++i)

template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } else { return 0; }}
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } else { return 0; }}


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

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

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

ll repeatSquaring(ll n, ll p, ll mod) {
  if(p == 0) return 1;
  if(p % 2 == 0) {
    ll t = repeatSquaring(n, p / 2, mod);
    return t * t % mod;
  } else {
    return (n * repeatSquaring(n, p - 1, mod)) % mod;
  }
}

ll comb(ll n, ll k, ll mod) {
  //分子
  ll res = 1;
  rep(i, k) res = res * (n - i) % mod;
  
  //分母（逆数にする前）
  ll bunbo = 1;
  rep(i, k) bunbo = bunbo * (k - i) % mod;
  
  res = (res * repeatSquaring(bunbo, mod - 2, mod)) % mod;
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  rep(i, N) cin >> d[i];
  
  sort(d.begin(), d.end());
  
  cout << (d[d.size() / 2] - d[d.size() / 2 - 1]) << endl;
}

//1 4 4 6 7 9
/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
int main(){
    iosetup;
    int N; cin >>N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];

    sort(ALL(A));
    UNIQUE(A);
    int ans = A.size();
    if(ans % 2 == 0) ans--;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    ll cnt = 0;
    char ans;

    rep(i,s.size()){
        if(s[i] == '1'){
            cnt++;
        }
        if(s[i] != '1'){
            ans = s[i];
            break;
        }
    }

    if(cnt >= k){
        cout << 1 << endl;
    }

    else cout << ans  << endl;
}

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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = 0;
	ans = max(0, (min(B, D) - max(A, C)));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int n,q;
ll book[maxn];
vector<int>G[maxn];
void dfs(int now,int fa)
{
	for(int i=0;i<G[now].size();i++)
	{
		if(G[now][i]==fa) continue;
		book[G[now][i]]+=book[now];
		dfs(G[now][i],now);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>q;
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<q;i++)
	{
		int a,b;
		cin>>a>>b;
		book[a]+=b;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) cout<<book[i]<<(i==n?'\n':' ');
	return 0;
}

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

int main()
{
    char X, Y;

    cin >> X >> Y;
    if(X>Y){
        cout << ">" << endl;
    }
    else if(X<Y){
        cout << "<" << endl;
    }
    else
    {
        cout << "=" << endl;
    }
    
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int n;
    cin>>n;

    vi v(n+1);
    int cnt=0;

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

        if(i%2!=0 && v[i]%2!=0){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3580
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static int R;
    public static int G;
    public static int B;
    public static int N;

    public static int upper_bound(long x, long[] RG) {
        int ok = RG.length;
        int ng = -1;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (RG[mid] <= x) {
                ng = mid;
            } else {
                ok = mid;
            }
        }
        return ok;
    }

    public static int lower_bound(long x, long[] RG) {
        int ok = -1;
        int ng = RG.length;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (RG[mid] < x) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return ok;

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        R = scanner.nextInt();
        G = scanner.nextInt();
        B = scanner.nextInt();
        N = scanner.nextInt();
        long[] RG = new long[((N + R - 1) / R + 1) * ((N + G - 1) / G + 1)];
        int idx = 0;
        for (int r = 0; r <= (N + R - 1) / R; r++) {
            for (int g = 0; g <= (N + G - 1) / G; g++) {
                RG[idx++] = R * r + G * g;
            }
        }
        Arrays.sort(RG);
        long cnt = 0;
        for (int b = 0; b <= (N + B - 1) / B; b++) {
            cnt += upper_bound(N - B * b, RG) - lower_bound(N - B * b, RG) - 1;
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 96664
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	if (a % 2 + b % 2 != 2) {
		std::cout << "Even" << std::endl;
	} else {
		std::cout << "Odd" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
(let ((o (read-line))
    (e (read-line)))
    (loop for i below (length e) do
        (progn
            (format t "~(~A~)" (char o i))
            (format t "~(~A~)" (char e i))
        )
    )
    
    (if (not (= (length o) (length e)))
        (format t "~(~A~)" (char o (- (length o) 1)))
    )
)

Measured memory_bytes: 24400
#include <iostream>
#include<stdio.h>
using namespace std;

int main(){
    char a;
    cin >> a;
    if((int)a>=97){
        cout << 'a' << endl;
    }else{
        cout <<'A' << endl;
    }
    //cout <<(int)a;
    

    return 0;
}

Measured memory_bytes: 3496
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(len(p) - 2):
    q = [p[i], p[i + 1], p[i + 2]]
    if not q[1] == max(q) and not q[1] == min(q):
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&(k^'-'))k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
void file()
{
	#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	#endif
}
const int MAXN=200010;
int n,ans;
int sum[MAXN];
int dp[1<<26];
char a[MAXN];
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	int i,j;
	sum[1]^=1<<(a[1]-'a');
	memset(dp,0x3f,sizeof dp);
	dp[0]=0;
	For(i,1,n)
	{
		sum[i]=sum[i-1]^(1<<(a[i]-'a'));
		For(j,0,25)if(dp[sum[i]^(1<<j)]+1<dp[sum[i]])
			dp[sum[i]]=dp[sum[i]^(1<<j)]+1;
	}
	printf("%d\n",max(dp[sum[n]],1));
	return 0;
}



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

typedef long long int ll;
const int K_MAX = 5002;
int d[K_MAX];
int k, q;

int main(){
    cin >> k >> q;
    for(int i = 0; i < k; i++){
        cin >> d[i];
    }

    vector<ll> ANS;
    for(int j  = 0; j < q; j++){
        ll n, x, m;
        cin >> n >> x >> m;
        x %= m;
        ll zero = 0;
        ll total = x;
        ll cyct = 0;
        ll cycz = 0;
        ll p = (n-2) / k;
        ll q = (n-2) % k;
        for(int i = 0; i < k; i++){
            int dm = d[i] % m;
            if (dm == 0){
                cycz++;
                if (i <= q)zero++;
            }
            cyct += dm;
            if (i <= q)total += dm;
        }
        zero += cycz * p;
        total += cyct * p;
        ll newans = n-1;
        newans -= zero;
        newans -= (total / m);
        ANS.push_back(newans);
    } 
    for(int j = 0; j < q; j++){
        cout << ANS[j] << endl;
    }
    return 0;
}

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

class Main {

	void solve() {

		char[] a = incharar();
		for (int i=0; i<a.length; i++) {
			if (a[i] == '1') a[i] = '9';
			else if (a[i] == '9') a[i] = '1';
		}
		out.println(String.valueOf(a));
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}
	
}

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

int main() {
   int K,S;
  cin >> K >> S;
  int ans =0;
 for(int a =0 ;a<=K;a++) {
for(int b =0;b<=K;b++){
	int c = S - a - b;
  if(0 <= c && c <= K){
	ans++;
  }
}
 }
   
    cout <<ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m,gomi;
	cin>>m>>n>>gomi;
	int p;
	cin>>p;
	vp in(p);
	rep(i,p)cin>>in[i].second>>in[i].first>>gomi;
	vvi G(n,vi(m));
	rep(i,n)rep(j,m)cin>>G[i][j];
	int out=0;
	rep(i,p)if(G[in[i].first][in[i].second])out++;
	cout<<out<<endl;
}

Measured memory_bytes: 1224
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}
std::vector<long long> a;
std::vector<long long> b;
std::vector<long long> c;
std::vector<long long> d;
long long N;  
long long M;
long long Q;

ll f(int dep, vector<ll> &v) {
  ll ret = 0;
  if(N==dep+1) {
    rep(i, Q) {
      if(v[b[i]-1]-v[a[i]-1] == c[i]) {
	ret += d[i];
      }
    }
  } else {
    for(int i=v[dep]; i<=M; i++) {
      v[dep+1] = i;
      ret = max(ret, f(dep+1, v));
    }
  }
  return ret;
}

int main(){

  scanf("%lld",&N);

  scanf("%lld",&M);

  scanf("%lld",&Q);
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
    scanf("%lld",&c[i]);
    scanf("%lld",&d[i]);
  }
  vector<ll> v(N);
  ll ans = 0;
  rep(i,M) {
    v[0] = i+1;
    ans = max(ans, f(0, v));
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3672
let AV: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let BW: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let T: Int = Int(readLine()!)!

let distFirst: Int = abs(AV[0] - BW[0])
let dvw: Int = AV[1] - BW[1]
if dvw*T >= distFirst {
    print("YES")
} else {
    print("NO")
}

Measured memory_bytes: 8236
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CCleaning {
public:

    vector<ll> a;
    vector<int> graph[100005];
    vector<bool> used;
    bool flag = true;

    void dfs(int p) {
      if (!flag) return; // fast fail
      used[p] = true;
      ll ma = 0;
      int cnt = 0;
      ll sum = 0;
      for(auto e: graph[p]) {
        if (used[e]) continue;
        dfs(e);
        chmax(ma, a[e]);
        sum += a[e];
        cnt++;
      }
      // p == 0
      if (p == 0) {
        if (cnt==1 && a[p]==sum) {
          return;
        }
        // cnt>1
        if (sum%2 != 0 || a[p] != sum/2) {
          flag = false;
          return;
        }
        if (ma > sum/2) {
          flag = false;
          return;
        }
        return;
      }

      // p != 0
      if (cnt==0 || a[p] == sum) {
        return;
      }
      if (a[p] > sum) {
        flag = false;
        return;
      }

      if (a[p] < sum) {
        auto k = sum - a[p];
        auto r = min(sum - ma, sum/2);
        if (k > r) {
          flag = false;
        }
        a[p] -= k;
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      a.resize(n);
      used.resize(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
      }
      dfs(0);
      if (flag) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
};

signed main() {
  CCleaning solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<int> zalgo(string S){
    int n = S.size();
    vector<int> Z(n, 0);
    int left = 0;
    for(int i = 1; i < n; i++){
        int l = i - left;
        if(i + Z[l] < left + Z[left]){//すでに求めたpreffixに再利用したものが完全に収まるか判定
            Z[i] = Z[l];//収まっていたらすでに求めたものを再利用できる
        }
        else{
            int j = max(0, Z[left] + left - i);//収まっていなかったら収まっている部分は必ず一致するので再利用(重ならない場合に注意)
            while(i + j < n && S[i + j] == S[j]) j++;//一致しなくなるまで探索
            Z[i] = j;
            left = i;//探索した場合はそれが必ず最もみぎに終端を持つ部分文字列になる
        }
    }
    Z[0] = n;
    return Z;
}
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < N; i++){
        string s = S.substr(i);
        vector<int> z = zalgo(s);
        int n = z.size();
        for(int j = 0; j < n; j++){
            if(z[j] > j) ans = max(ans, j);
            else ans = max(ans, z[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712