akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

int N;
vector<int> A;

int main () {
  cin >> N;
  A.resize(N);
  vector<int> B(N);
  rep(i,N) {
    cin >> A[i];
    B[i] = A[i];
  }

  sort(B.begin(), B.end());
  rep(i,N) {
    if(A[i] == B[N-1]) {
      cout << B[N-2] << endl;
    } else {
      cout << B[N-1] << endl;
    }
  }

  return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  
  
  int ans =0;
  int flg = 0;
  for(int i=0;i<n-1;i++){
    int a=0;
    if(A[i]<A[i+1]) a = 1;
    else if(A[i]>A[i+1]) a = 2;
    else continue;

    if(flg==0) flg = a;
    if(a == flg) continue;
    flg = 0;
    ans++;
  }
  cout<<ans+1<<endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	int s, a, cnt = 0;
	cin >> s;
	rep(i, n - 1) {
		cin >> a;
		if (a == s) {
			s = a + 10001 + cnt;
			cnt++;
		}
		else s = a;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m[4];
    m[0]=a*c;
    m[1]=a*d;
    m[2]=b*c;
    m[3]=b*d;
    sort(m,m+4);
    cout<<m[3];
    return 0;
}

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

#define ll long long 

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  
  ll ans = 0;
  
  ans += (N / (A+B)) * A;
  
  if (N % (A+B) <= A) {
    ans += N % (A+B);
  } else {
    ans += A;
  }
  
  cout << ans << endl;
}

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



class Program
{
 
    public static void Main( )
    {
        var employers = new int[ int.Parse( Console.ReadLine( ))+1 ];
        Console.ReadLine( ).Split( ).Select( int.Parse ).ToList( ).ForEach( x => employers[ x ]++ );
        employers.Skip(1).ToList( ).ForEach( x => Console.WriteLine(x) );

    }
}




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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
int main(){
 int a,b,c;
 cin >> a >> b >> c;
 set<int> S;
 S.insert(a);
 S.insert(b);
 S.insert(c);

 cout << S.size() << endl;
  

}

Measured memory_bytes: 256
S = input()
N = int(input())
Q = tuple([_ for _ in input().split()] for _ in range(N))
C = 0
F = ""
R = ""
for q in Q:
    if q[0] == "1":
        C = (C+1)%2
    else:
        if (int(q[1])+C)%2 != 0:
            F = q[2] + F
        else:
            R = R + q[2]
S = F + S + R
if C != 0:
    S = S[::-1]
print(S)

Measured memory_bytes: 28068
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#define tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO

using ll =long long;





int main(void) {
	int n; cin >> n;
	ll tmp = 0;
	ll ans = 0;
	map<ll, ll> mp;
	mp[0] = 1;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		tmp += x;
		ans += mp[tmp];
		mp[tmp] += 1;
	}

	cout << ans << endl;








}

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

int main() {
  int YABAI, WAYO, MRKT = 0;
  string TKSS, EKSA, LAPLAND;
  cin >> YABAI >> WAYO;
  
  vector<int> OOTJNY(WAYO * 2);
  vector<int> ZUN(50);
    for(int YUNI = 0; YUNI < WAYO * 2;){
      cin >> OOTJNY.at(YUNI);
      YUNI ++;
    }
    
  for(int YUNI = 0; YUNI < WAYO * 2;){
    ZUN.at(OOTJNY.at(YUNI) - 1) ++;
    YUNI ++;
  }
  for(int YUNI = 0; YUNI < YABAI;){
    cout << ZUN.at(YUNI) << endl;
    YUNI ++;
  }
}


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

int main(){

  int x,y;
  int size = 51;
  char ch[size];
  
  cin >> x >> y;
  
  for(int i=1;i<=x;i++)cin >> ch[i];
  
  for(int i=1;i<=x;i++){
  	if(i==y)cout << char(ch[i]-'A'+'a');
    else cout << ch[i];
    
  }
  
  return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  string S[H];
  int counter[H][W];
  for(int i=0;i<H;i++){
    cin >>S[i];
  	for(int j=0;j<W;j++){
   		counter[i][j]=0;
  	}
  }
  
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
  		if(S[i].at(j)=='#'){
        	if(!(j-1<0))counter[i][j-1]++;
            if(!(j+1>=W))counter[i][j+1]++;
          	if(!(i-1<0)){
            	counter[i-1][j]++;
              if(!(j-1<0))counter[i-1][j-1]++;
              if(!(j+1>=W))counter[i-1][j+1]++;
            }	
          if(!(i+1>=H)){
            	counter[i+1][j]++;
              if(!(j-1<0))counter[i+1][j-1]++;
              if(!(j+1>=W))counter[i+1][j+1]++;
            }	
        }  
    }
  }
  
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
  		if(S[i].at(j)=='#'){
        cout<<"#";
        }
     	else{
        cout <<counter[i][j] ;
        }
    }
  
  cout<<endl;
  }
}

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

int main() {
  double a, b;
  int c;
  cin >> a >> b;
  if (double((a+b)/2)==int((a+b)/2)){
    c = int((a+b)/2);
  }else{
    c = int((a+b)/2) + 1;
  }
  cout << c << endl;
}


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


int main(){
  long long mod =	1e9+7;
  long long N, K; cin>>N>>K;
  long long ans=0, big=0, small=0;
  int i,j;

  for(i=0; i<N-K+2; i++){
    ans = ans+(N-K-i+1)*(K+i)+1;
  }

  ans=ans%mod;
  printf("%lld\n",ans);

  return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> b(n);

    rep(i,n)cin >> b[i];

    vector<int> a;

    for(int i=0;i<n;i++){
        if(b[i]<=i+1){
            a.insert(a.begin()+b[i]-1,b[i]);
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i,n){
        cout << a[i] << " ";
    }cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> K(N);
  vector<vector<int>> A(N);
  rep(i, N) {
    cin >> K[i];
    vector<int> A_tmp(K[i]);
    rep(j, K[i]) {
      cin >> A_tmp[j];
    }
    A[i] = A_tmp;
  }

  vector<vector<char>> C(N, vector<char>(M, 0));
  rep(i, N) {
    rep(j, K[i]) {
      C[i][A[i][j]-1] = 1;
    }
  }

  int answer {};
  rep(i, M) {
    char sum {};
    rep(j, N) {
      sum += C[j][i];
    }
    if (sum == N) ++answer;
  }
  cout << answer << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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 (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,a,b,c,d);

  int ca = (a-1)/c;
  int cb = b/c;
  int da = (a-1)/d;
  int db = b/d;
  int gg = d*c/gcd(d,c);
  int ea = (a-1)/gg;
  int eb = b/gg;

  /*
  debug(ca);
  debug(cb);
  debug(da);
  debug(db);
  debug(ea);
  debug(eb);
  */
  OUT(b-a+1-(cb-ca+db-da-(eb-ea)))BR;
  
  
  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 all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; cin >> N;
  vector<int> A(N+1), B(N+1), C(N+1);
  rep(i, N) cin >> A[i+1];
  rep(i, N) cin >> B[i+1];
  rep(i, N-1) cin >> C[i+1];


  int ans = B[A[1]];
  for (int i = 2; i <= N; i++) {
    ans += B[A[i]];
    if (A[i]-A[i-1] == 1) ans += C[A[i-1]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef complex<double> P;
const double PI =acos(-1);
const double eps = 1e-6;
double table[40][40][41];

P convert(double r){
  const P ori(1,0);
  double theta=r<eps?0:2*PI*r;
  P ret(ori.real()*cos(theta)-ori.imag()*sin(theta),
	ori.real()*sin(theta)+ori.imag()*cos(theta));
  return ret;
}

double Polygon_Area(P c,P d,P e){
  P a[3]={c,d,e};
  int n=3;
  double sum=0;
  rep(i,n){
    sum+=(a[i%n].real()-a[(i+1)%n].real())*(a[i%n].imag()+a[(i+1)%n].imag());
  }
  if ( sum<0)sum*=-1;
  return sum/2;
}



double solve(int n,int m,double *r){
  complex<double> in[n];
  rep(i,n)in[i]=convert(r[i]);

  rep(i,n)rep(j,n)rep(k,m+1)table[i][j][k]=0;
  
  rep(i,n){//start point
    table[i][i][1]=0;
    REP(j,i,n){//last point
      REP(k,2,m){
	REP(l,j+1,n){//nextpoint
	  table[i][l][k+1]=max(table[i][l][k+1],
			       table[i][j][k]+Polygon_Area(in[i],in[j],in[l])
			       );
	}
      }
    }
  }
  

  double ans=0;
  rep(i,n){
    rep(j,n)ans = max(table[i][j][m],ans);
  }
  return ans;
}

main(){
  int n,m;
  while(cin>>n>>m && n){
    double r[n];
    rep(i,n)cin>>r[i];
    printf("%.6lf\n",solve(n,m,r));
  }
}

Measured memory_bytes: 1492
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

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

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll n,k;
    sc(n);
    sc(k);

    ll a[n],maxy=-1;
    fo(i,0,n){
        sc(a[i]);
        maxy=max(a[i],maxy);
    }
    
    ll ans = maxy,l=1,r=maxy;
    
    while(l<=r)
    {
        ll mid =(l+r)/2;
        ll temp = 0;
        fo(i,0,n) temp+=(a[i]+mid-1)/mid -1;
        if(temp<=k)
        {
            ans = min(ans,mid);
            r= mid-1;
        }
        else l = mid+1;
        
    }
    
    printf("%lli",ans);
   
}

int main()
{
    ll t=1;
   // sc(t);
    while(t--) solve();
}





Measured memory_bytes: 5352
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pub push_back
#define ll long long
					  
using namespace std;



int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("seating.in", "r", stdin);
	//freopen("seating.out", "w", stdout);
	int l1, l2, r1, r2;
	cin >> l1 >> r1 >> l2 >> r2;
	l1 = max(l1, l2);
	r1 = min(r1, r2);
	cout << max(0, r1 - l1);	
}

Measured memory_bytes: 256
program ABC095A
    implicit none
    integer(8)::i
    integer(8)::add=0
    character(3)::S

    read(5,*)S

    do i=1,3
        if(S(i:i)=='o')then
            add=add+1
        end if
    end do

    print'(i0)',700+100*add
end program ABC095A

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

int main() {
	int x, a, b;
	cin >> x >> a >> b;

	if (a - b >= 0) {
		cout << "delicious" << endl;
	}
	else if (b-a > x) {
		cout << "dangerous" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 256
// package com.patra.cp.atcoder.practice.dp;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static long solve(int[] weights, int[] values, long[][] dp,  int currPos, int capacity) {
//        System.out.println(currPos + " " + capacity);
        if(currPos <= 0) {
            return 0;
        }
        if(capacity <=  0) {
            return 0;
        }
        if(dp[currPos][capacity] != -1) {
            return dp[currPos][capacity];
        }
        long include = 0;
        long exclude = solve(weights, values, dp,currPos-1, capacity);
        if(capacity >= weights[currPos]) {
            include = solve(weights, values, dp,currPos-1, capacity-weights[currPos]) + values[currPos];
        }
        dp[currPos][capacity] = Math.max(include, exclude);
        return dp[currPos][capacity];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] splits = line.split(" ");
        int N = Integer.parseInt(splits[0]);
        int W = Integer.parseInt(splits[1]);
        int[] weights = new int[N+1];
        int[] values = new int[N+1];
        for(int i=1; i<=N; i++) {
            line = sc.nextLine();
            splits = line.split(" ");
            weights[i] = Integer.parseInt(splits[0]);
            values[i] = Integer.parseInt(splits[1]);
        }
        long[][] dp = new long[N+1][W+1];
        for(long[] row : dp) {
            Arrays.fill(row, -1);
        }
        System.out.println(solve(weights, values, dp, N, W));
//        for(int i=0; i<=N; i++) {
//            for(int j=0; j<=W; j++) {
//                System.out.print(dp[i][j] + " ");
//            }
//            System.out.println("");
//        }
    }
}


Measured memory_bytes: 126548
s = input()
n = len(s)

def isKaibun(x):
    if x == x[::-1]:
        return True
    else:
        return False

ans = 'Yes'

if not isKaibun(s):
    ans = 'No'
if not isKaibun(s[:(n-2)//2+1]):
    ans = 'No'
if not isKaibun(s[(n+2)//2:]):
    ans = 'No'

print(ans)

Measured memory_bytes: 38256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9){
        cout<<a*b;
        return 0;
    }
    cout<<"-1";
	exit(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
    ll n, m, i, j, k, l;
    cin>>n>>m>>k;
    vector<ll>a(n+1);
    vector<ll>b(m);
    a[0]=0;
    for(i=1; i<n+1; i++)
    {
        int x;
        cin>>x;
        a[i]=a[i-1]+x;
    }
    for(i=0; i<m; i++)
    {
        int y;
        cin>>y;
        if(i==0)
            b[i]=y;
        else
            b[i]=b[i-1]+y;
    }
    int ans=0;
    for(int s=0; s<n+1; s++)
    {
        if(a[s]>k)
            break;
        int tmp=k-a[s];
        int left=0;
        int right=m-1;
        while(left<=right)
        {
            int mid=(left+right)/2;
            if(tmp<b[mid])
                right=mid-1;
            else
                left=mid+1;
        }
        ans=max(ans, s+left);
    }
    cout<<ans<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6356
#include <stdio.h>
#define N 8
#define NOT_FREE 1
#define FREE 0
 
int pQ(int);
int  b[N][N] = {};
int r[N] = {}, c[N] = {}, dpos[2*N-1] = {}, dneg[2*N-1] = {};
int main()
{
  int i, j;
  int k, r1, c1;
   
  scanf("%d", &k); 
  for(i = 0; i < k; i++)
    {
      scanf("%d %d", &r1, &c1); 
      b[r1][c1] = r[r1] = c[c1] = dpos[r1+c1] = dneg[r1-c1+N-1] = NOT_FREE;
    }
   
  pQ(0);
  return 0;
}
int pQ(int i)
{
  int j, k, l;
  if(i == N)
    {
      for(k = 0; k < N; k++)
    {
      for(l = 0; l < N; l++)
        {
          if(b[k][l] == FREE) printf(".");
          else printf("Q");
        }
      printf("\n");
    }
      return;
    }
  if(r[i] == NOT_FREE) pQ(i+1);
  else
    {
      for(j = 0; j < N; j++)
    {
      if(c[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
      c[j] = dpos[i+j] = dneg[i-j+N-1] = b[i][j] = NOT_FREE;
      pQ(i+1);
      c[j] = dpos[i+j] = dneg[i-j+N-1] = b[i][j] = FREE;
    }
    }
}

Measured memory_bytes: 572
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n+1)]

dp[0][0] = 1
for i in range(1, n+1):
    cum = [0] * (k+2)
    for j in range(k+1):
        cum[j+1] = (cum[j] + dp[i-1][j]) % mod
        dp[i][j] += cum[j+1] - cum[max(0, j-a[i-1])]
        dp[i][j] %= mod

print(dp[n][k])

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

using namespace std;

int n, k;
int a[100010];
bitset<100010> al;
vector<int> adj[100010];
int ans = 0;
int dist[100010];

void dfs(int u){
    al[u] = true;
    dist[u] = 1;

    for(auto v : adj[u]){
        if(!al[v]){
            dfs(v);
            dist[u] = max(dist[u], dist[v] + 1);
        }
    }

    if(u != 1 && dist[u] == k && a[u] != 1) dist[u] = 0, ans++;
}

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

    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        if(i != 1) adj[a[i]].emplace_back(i);
    }

    if(a[1] != 1) ans++;

    dfs(1);

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

Measured memory_bytes: 12800
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    input_init();
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    vector<vector<ll>> b(22, vector<ll>(n));
    rep(i,n) {
        int idx = 0;
        ll m = a[i];
        while (m>0) {
            b[idx++][i] = m%2;
            m/=2;
        }
    }

    vector<vector<ll>> c(b);
    rep(i,22) {
        for (int j = 1; j < n; ++j) {
            b[i][j] += b[i][j-1];
        }
    }

    ll ans = 0;
    rep(j,n) {
        ll cnt = INF;
        rep(i,22) {
            int see = 2;
            if (c[i][j]) see--; 
            auto itr = lower_bound(b[i].begin()+j, b[i].end(), b[i][j]+see);
            ll tmp = (itr-b[i].begin())-j;
            chmin(cnt, tmp);
        }
        ans += cnt;
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
pii poyo[252521];
int v[252521];
int l[252521], r[252521];

ll dp[252521];

int main(){
  scanf("%d",&n);
  REP(i,n){
    int xx,vv;
    scanf("%d%d",&xx,&vv);
    poyo[i] = pii(xx,vv);
  }
  // zaatu
  sort(poyo,poyo+n);
  REP(i,n)poyo[i] = pii(poyo[i].second,i);
  sort(poyo,poyo+n);
  REP(i,n)v[poyo[i].second] = i+1;
  // left
  l[0] = v[0];
  FOR(i,1,n)l[i] = max(l[i-1],v[i]);
  // right
  r[n-1] = v[n-1];
  FORR(i,0,n-1)r[i] = min(r[i+1],v[i]);
  // dp[r[i]] += sum(dp[l[i]-1]~dp[r[i]])
  dp[0] = 1;
  ll sum = 1;
  int lw = 0, hi = 0;
  REP(i,n){
    while(hi < l[i])(sum += dp[++hi])%=MOD;
    while(lw < r[i]-1)(sum += MOD-dp[lw++])%=MOD;
    (dp[l[i]] += sum)%=MOD;
    (sum += sum)%=MOD;
  }
  printf("%lld\n",dp[n]);
  return 0;
}


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

const int DIM = 1e2 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    int sum = 0;
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        sum += arr[i];
    }
    
    int m;
    cin >> m;
    
    for( int i = 1; i <= m; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        cout << sum + (y - arr[x]) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import collections
n=int(input())
s=[input() for i in range(n)]

c = collections.Counter(s)
arr=c.most_common()
num=arr[0][1]
tmp=[]
for i in arr:
  if i[1]==num:
    tmp+=[i[0]]

tmp=sorted(tmp)
for i in tmp:
  print(i)

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

using namespace std;

vector<long long>tree;

long long find(int v, int seg_start, int seg_end, int query_left, int query_right) {
  if (query_left > query_right) return 0;
  if (query_left == seg_start && query_right == seg_end) {
    return tree[v];
  }
  int seg_mid = (seg_start + seg_end) / 2;
  return max(find(v*2, seg_start, seg_mid, query_left, min(seg_mid, query_right)),
            find(v*2 + 1, seg_mid + 1, seg_end, max(seg_mid + 1, query_left), query_right));
}

void log(int v) {
  cout << v << " " << tree[v*2] << " " << tree[v*2 + 1] << "\n";
}

void update(int v, int seg_start, int seg_end, int pos, long long val) {
  if (seg_start == pos && seg_end == pos) {
    tree[v] = val;
    return;
  }
  int seg_mid = (seg_start + seg_end) / 2;
  if (pos <= seg_mid) {
    update(v*2, seg_start, seg_mid, pos, val);
  } else {
    update(v*2+1, seg_mid + 1, seg_end, pos, val);
  }
  //log(v);
  tree[v] = max(tree[v*2], tree[v*2+1]);
}

int main() {
  int n;
  cin >> n;
  vector<int>h(n, 0), a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  tree.clear();
  tree.resize(4 * n, 0);
  // Normal implementation: dp[i] = max beauty of increasing subseq ending at element i.
  // vector<long long>dp(n, 0);
  // dp[0] = a[0];
  // long long ans = dp[0];
  // for (int i = 1; i < n; i++) {
  //   dp[i] = a[i];
  //   for (int j = 0; j < i; j++) {
  //     if (h[j] <= h[i]) {
  //       dp[i] = max(dp[j] + a[i], dp[i]);
  //     }
  //   }
  //   ans = max(ans, dp[i]);
  // }
  
  // dp[i] = max beauty of increasing subsequnce ending at height i.
  // requirement h_i < n (problem stmt)
  long long ans = 0;
  vector<long long>dp(n + 1, 0);
  for (int i = 0; i < n; i++) {
    long long best_before_hi = find(1, 0, n, 0, h[i]);
    dp[h[i]] = best_before_hi + a[i];
    update(1, 0, n, h[i], dp[h[i]]);
    // dp[h[i]] = a[i];
    // for (int j = 0; j < h[i]; j++) {
    //   dp[h[i]] = max(dp[h[i]], dp[j] + a[i]);
    // }
    ans = max(ans, dp[h[i]]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9728
#include<stdio.h>
int main(){
  int i ,n ,y[31]={0};
  for ( i = 1 ; i <= 28 ; i++ ){
    scanf ( "%d" ,&n ); 
    y[n] = 1;
  }

  for ( i = 1 ; i <= 30 ; i++){
    if ( y[i] == 0 ){
      printf ( "%d\n" ,i);
    }
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;

  if (K % 2 == 0)
    cout << A - B << endl;
  else
    cout << B - A << endl;

  return 0;
}

Measured memory_bytes: 256
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
l = []
for i in range(N):
    l += IL()[1:]

cnt = 0
for i in range(1,M+1):
    if l.count(i) == N:
        cnt += 1
print(cnt)

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

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long, long>pll;

signed main() {
	int l,a[200100]={0};
    cin>>l;
    REP(i,l){
        cin>>a[i];
    }
	/*
    int odd[200100]={0},eve[200100]={0};
    FOR(i,1,l){
        odd[i]=odd[i-1];
        eve[i]=eve[i-1];
        if(a[i]%2==0){
            eve[i]++;
        }
        else{
            odd[i]++;
        }
    }
    int s=0,t=l-1;
    int ans=0;
    REP(i,l){
        if(a[i]%2==0){
            ans++;
        }
    }
*/
    int dp[5][200100]={0};
    REP(i,l){
        dp[0][i+1]=dp[0][i]+a[i];
        dp[1][i+1]=min(dp[0][i],dp[1][i])+a[i]%2;
        if(a[i]==0){
            dp[1][i+1]+=2;
        }
        dp[2][i+1]=min(dp[0][i],min(dp[1][i],dp[2][i]))+(a[i]+1)%2;
        dp[3][i+1]=min(dp[0][i],min(dp[3][i],min(dp[2][i],dp[1][i])))+a[i]%2;
        if(a[i]==0){
            dp[3][i+1]+=2;
        }
        dp[4][i+1]=min(dp[4][i],min(dp[0][i],min(dp[1][i],min(dp[3][i],dp[2][i]))))+a[i];
    }

    int ans=dp[0][l];
    REP(i,5){
        ans=min(ans,dp[i][l]);
    }
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

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

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b;
    rep(i,n) cin>>a[i];
    rep(i,n) ans=gcd(ans,a[i]);
    for(ll j=1;j<=sqrt(ans);j++){
        if(ans%j==0 && j!=ans/j){
            b.pb(j);
            b.pb(ans/j);
        }
        if(ans%j==0 && j==ans/j){
            b.pb(j);
        }
    }
    sort(ALL(b));
    rep(i,b.size()) cout<<b[i]<<endl;
    return 0;
}


Measured memory_bytes: 3176
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n,x,y;cin>>n>>x>>y;
	x--;y--;
	vector<int> v(n);
	vector<int> ans(n,0);
	vector<vector<int>> d(n,vector<int>(n,0));
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			d[i][j]=abs(i-j);
			int temp=0;
			temp+=min(abs(x-i),abs(y-i));
			temp+=min(abs(x-j),abs(y-j));
			temp++;
			d[i][j]=min(d[i][j],temp);
			ans[d[i][j]]++;
		}
	}
	for(int i=1;i<n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


vector<long long> primes(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n+1);rep(i,n)cin>>a[i+1];
  vector<int> b(n+1,0);

  vector<int> ans;
  for(int i = n;i > 0;--i){
    if(b[i]%2 == a[i])continue;
    auto p = primes(i);
    ans.pb(i);
    for(auto&& one: p){
      b[one]++;
    }
  }


  print(ans.size());
  for(auto&& one: ans){
    cout<<one<<" ";
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 5292
#include<bits/stdc++.h>
#define FOR(i,n) for(int i = 0; i < n; i++)
#define lli long long int
#define INF 1e10

lli N, W, *value, *weight, dp[101][100001];
using namespace std;

lli found(lli v, int i) {
	if(v == 0) return 0;
	if(v < 0 || i >= N) return INF;
	if(dp[i][v] > 0) return dp[i][v];
	dp[i][v] = min(found(v, i + 1), weight[i] + found(v - value[i], i + 1));
	return dp[i][v];
}

lli execute() {
	lli max_val = 0;
	FOR(i, N) max_val += value[i];
	for(;max_val > 0; max_val--)
		if(found(max_val, 0) <= W) return max_val;
	return 0;
}

int main() {
	cin>>N>>W;
	value = new lli[N];
	weight = new lli[N];
	FOR(i, N) cin>>weight[i]>>value[i];
	FOR(i, N) fill(dp[i], dp[i] + 100001, -1);
	lli result = execute();
	cout<<result;
}


Measured memory_bytes: 78464
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    x,y=map(int,input().split())
    ans=10**20
    if -x<=-y:
        ans=min(ans,2+-y-(-x))
    if -x<=y:
        ans=min(ans,1+y-(-x))
    if x<=-y:
        ans=min(ans,1+(-y)-x)
    if x<=y:
        ans=min(ans,y-x)
    print(ans)

resolve()

Measured memory_bytes: 38256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto cs = new int[][](3, 3);
    foreach (i; 0..3) foreach (j, c; readln.split.to!(int[])) cs[i][j] = c;
    writeln(
        cs[1][0] - cs[0][0] == cs[1][1] - cs[0][1] &&
        cs[1][1] - cs[0][1] == cs[1][2] - cs[0][2] &&
        cs[2][0] - cs[0][0] == cs[2][1] - cs[0][1] &&
        cs[2][1] - cs[0][1] == cs[2][2] - cs[0][2] ?
        "Yes" : "No"
    );
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int c = 0;
        int count = 0;
        while (c < n) {
            c += 2 * d + 1;
            count++;
        }

        System.out.println(count);
    }

}


Measured memory_bytes: 22612
import sys

input = sys.stdin.readline

P = 10 ** 9 + 7


def main():
    N, M = map(int, input().split())
    A = [0] * M
    for i in range(M):
        A[i] = int(input())

    for i in range(M - 1):
        if A[i] + 1 == A[i + 1]:
            print(0)
            exit()

    broken = [False] * (N + 1)
    for a in A:
        broken[a] = True

    dp = [0] * (N + 1)
    dp[0] = 1
    dp[1] = 1 if not broken[1] else 0

    for i in range(2, N + 1):
        if broken[i]:
            dp[i] = 0
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % P
    
    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int dtoi(double a){
	
	int a1 = a;
	int a2 = a1 + 1;
	
	if(a -a1 < a2 - a) return a1;
	else return a2;
}

int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n; cin >> n;
	
	double sum = 0;
	
	vector<int> a(n); 
	rep(i,n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(all(a));
	
//	cout << sum/n << endl;
	
	
	int mean = dtoi(sum/n);
	
//	cout << mean << endl;
	
	
	int cost = 0;
	
	rep(i, n) cost += (mean - a[i]) * (mean - a[i]);
	
	cout << cost << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 200005
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int A[N];
int main()
{
	int i,n,ID;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	for(i=1;i<=n;i++)A[i]-=i;
	sort(A+1,A+n+1);
	ID=(n+1)/2;
	long long Sum=0;
	for(i=1;i<=n;i++)Sum+=abs(A[i]-A[ID]);
	printf("%lld\n",Sum);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long i,j,k,n,m,x,y,z;
int main()
{
	cin>>x>>y>>z;
	if(x%2==0||y%2==0||z%2==0)
	{
		printf("0\n");
		return 0;
	}
	m=min(x*y,min(y*z,x*z));
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n / i; j++) {
			if (i * j < n) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define modulo 2019ll
ll powmod(ll a, ll n)
{
    if(n==0)
    return 1;
    if(n%2==0)
    {
        return (powmod(a,n/2)*powmod(a,n/2))%modulo;
    }
    else
    {
        return (((powmod(a,n/2)*powmod(a,n/2))%modulo)*a)%modulo;
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    int n=str.size();
    vector<int> dp(n,0);
    int res=0;
    for(int i=n-1;i>=0;--i)
    {
        res=(res+powmod(10,n-i-1)*(str[i]-'0'))%modulo;
        dp[i]=res;
    }
    map<int,int> ma;
    for(int i=0;i<n;++i)
    {
        ma[dp[i]]++;
        //cout<<dp[i]<<" ";
    }
    ll ans=0;
    //cout<<"\n";
    for(auto it=ma.begin();it!=ma.end();++it)
    {
        int temp1=it->first;
        int temp=it->second;
        //cout<<temp1<<" ";
        
        ans+=(temp*(temp-1))/2;
        if(temp1==0)
        ans+=temp;
    }
    cout<<ans<<"\n";
}


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

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

void prop(int y,int x,char s){

  map[y][x] = 'x';
  if(y+1<h && map[y+1][x] == s)prop(y+1,x,s);
  if(x+1<w && map[y][x+1] == s)prop(y,x+1,s);
  if(y-1>=0 && map[y-1][x] == s)prop(y-1,x,s);
  if(x-1>=0 && map[y][x-1] == s)prop(y,x-1,s);

}

int main(){
  int i,j;
  int ans;
  char tmp;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf(" %c ",&map[i][j]);
      }
    }

    ans = 0;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	tmp = map[i][j];
	if(tmp!='x'){
	  prop(i,j,tmp);
	  ans++;
	}
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int best_pizza(int topp_arr_size, int base_price, int topp_price, int base_cal, int *topp_cal_arr);
int pop_max(int *arr, int *arr_size);
void swap(int *a, int *b);
int main(int argc, char **argv) {
  int topp_arr_size;
  scanf("%d", &topp_arr_size);
  int base_price, topp_price;
  scanf("%d %d", &base_price, &topp_price);
  int base_cal;
  scanf("%d", &base_cal);
  int topp_cal_arr[topp_arr_size];
  int i;
  for (i = 0; i < topp_arr_size; i++) {
    scanf("%d", topp_cal_arr+i);
  }
  printf("%d\n", best_pizza(topp_arr_size, base_price, topp_price, base_cal, topp_cal_arr));
  return 0;
}

int best_pizza(int topp_arr_size, int base_price, int topp_price, int base_cal, int *topp_cal_arr) {
  int cal_sum = base_cal;
  int price_sum = base_price;
  while (topp_arr_size > 0) {
    int new_cal_sum = cal_sum + pop_max(topp_cal_arr, &topp_arr_size);
    int new_price_sum = price_sum + topp_price;
    if (new_cal_sum/new_price_sum < cal_sum/price_sum) {
      break;
    }
    cal_sum = new_cal_sum;
    price_sum = new_price_sum;
  }
  return cal_sum/price_sum;
}

int pop_max(int *arr, int *arr_size) {
  int last = *arr_size - 1;
  int i;
  for (i = last - 1; i >= 0; i--) {
    if (arr[last] < arr[i]) {
      swap(arr+i, arr+last);
    }
  }
  *arr_size = *arr_size - 1;
  return arr[last];
}

void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

struct UnionFind {
#define MAX 200001
    int root[MAX];
    void Init() {rep(i,MAX) root[i] = -1;}
    void unite(int a ,int b) {
        int a_root = find(a),b_root = find(b);
        if (a_root != b_root) {
            if (root[a_root] > root[b_root]) {
                root[a_root] += root[b_root];
                root[b_root] = a_root;
            } else {
                root[b_root] += root[a_root];
                root[a_root] = b_root;
            }
        }
    }
    int find(int a) {
        if (root[a] < 0) return a;
        else {
            root[a] = find(root[a]);
            return root[a];
        }
    }
    int size(int a) {
        int a_root = find(a);
        return -root[a_root];
    }
    /*
     * root : rootの番号
     * unite : 併合
     * find : aのrootを返す
     * size : aのグループの要素数
     * */
};


int n,m;
UnionFind UF;
set<int> st;


signed main() {
    UF.Init();
    cin >> n >> m;
    rep(i,n) {
        int k;
        cin >> k;
        rep(j,k) {
            int l;
            cin >> l;
            UF.unite(i,n+l);
        }
    }
    rep(i,n) st.insert(UF.find(i));
    if (st.size() == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}




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

int main()
{
    string s,s2;
    int flag=1;
    cin >> s;
    int T;
    cin >> T;
    while(T--)
    {
        int x,f;
        char c;
        cin >> x ;
        if(x==1)
        {
            flag=!flag;
        }
        else
        {
            cin >> f >> c;
            f--;
            if(flag^f)s2.push_back(c);
            else s.push_back(c);
        }
    }
    if(flag)
    {
        reverse(s2.begin(),s2.end());
        cout << s2 << s << endl;
    }
    else
    {
        reverse(s.begin(),s.end());
        cout << s << s2 << endl;
    }
    return 0;
}

Measured memory_bytes: 960