akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=300010;
vector<vector<pll> >G(51);
vector<ll>dp(51,-1);

bool dfs(ll i,ll sup){
    if(dp[i]>=0)return dp[i];
    bool res=0;
    for(auto e:G[i]){
        ll w=e.se;
        ll to=e.fi;
        if((w&sup)==w){
            res|=dfs(to,sup);
        }
    }
    dp[i]=res;
    return res;
}

signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,51){
        REP(j,1,51){
            if(i%j==i)continue;
            G[i].pb(mp(i%j,1LL<<j));
        }
    }
    ll ans=0;
    ll j=52;
    while(j>0){
        ll l=-1,r=j;
        while(r-l>1){
            ll mid=(r+l)/2;
            ll sup=ans+(1LL<<mid);
            bool f=1;
            rep(i,n){
                rep(k,51){
                    dp[k]=-1;
                }
                dp[b[i]]=1;
                f&=dfs(a[i],sup-1);
            }
            if(f)r=mid;
            else l=mid;
        }
        if(r==0)break;
        if(r==52){
            cout<<-1<<endl;
            return 0;
        }
        ans+=(1LL<<(r-1));
        j=r-1;
    }
    ans-=ans%2;
    cout<<ans<<endl;
}

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

int main()
{
  int N;
  int b[110];
  int a[110];
  int res=0;
  cin >> N;

  for(int i=0;i<N-1;i++) cin >> b[i];

  a[0] = b[0];
  for(int i=1;i<N;i++){
    if(b[i-1] > b[i]) a[i] = b[i];
    else a[i] = b[i-1];
  }
  a[N-1] = b[N-2];


  for (int i=0;i<N;i++) res += a[i];
  
  cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s, t;
  cin >> s >> t;
  
  int ans = 0;
  rep(i, s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

main(){

int i,m,f,r,sum;

for(i=0;i<50;i++){
scanf("%d %d %d",&m,&f,&r);

sum = m + f;

if(m == -1 && f == -1 && r == -1){
break;
}

else if(m == -1 || f == -1 || sum < 30){
printf("F\n");
}

else if(sum >= 80 ){
printf("A\n");
}

else if(sum >= 65 && sum < 80){
printf("B\n");
}

else if(sum >= 50 && sum < 65){
printf("C\n");
}

else if(sum >= 30 && sum < 50){
 if(r >= 50){
 printf("C\n");
 }
 else{
 printf("D\n");
 }
}

}

return 0;
}


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if((a[2]+a[2]-a[1]-a[0])%2==0){
        cout << (a[2]+a[2]-a[1]-a[0])/2 << endl;
    }else{
        cout << ((a[2]+a[2]-a[1]-a[0])/2)+2 << endl;
    }
    return 0;
}

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

int main() {
  int64_t H = 0, W = 0;
  cin >> H >> W;
  
  if(H == 1 || W == 1){
    cout << 1 << endl;
  }
  else if(H % 2 == 1 && W % 2 == 1){
    cout << H * W / 2 + 1 << endl;
  }
  else{
    cout << H * W / 2  << endl;
  }
}


Measured memory_bytes: 256
def check(vec):
    if len(vec) == 0:
        return True
    h = 0
    for v in sorted(vec, reverse=True):
        if h + v[0] < 0:
            return False
        h += v[1]
    return True


def parse(brackets):
    m = 0
    f = 0
    for c in brackets:
        if c == "(":
            f += 1
        else:
            f -= 1
        if m > f:
            m = f
    return m, f


def main():
    N = int(input())
    ls = []
    rs = []
    tot = 0
    for _ in range(N):
        m, f = parse(input().strip())
        tot += f
        if f >= 0:
            ls.append([m, f])
        else:
            rs.append([m-f, -f])
    return tot == 0 and check(ls) and check(rs)


if __name__ == "__main__":
    print("Yes" if main() else "No")


Measured memory_bytes: 100048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int a,b;
  cin >> a>>b;
 
  vector<string> p(a);
  vector<string> q(b);
  
  rep(i,a){
    cin>>p[i];
  }
  
  rep(i,b){
    cin>>q[i];
  }
  
  rep(i,a-b+1){
    rep(j,a-b+1){
      bool memo = true;
      for(int k=i;k<=i+b-1;k++) {
        if(p[k].substr(j,b)!=q[k-i]) {
          memo=false;
        }
      }
      if(memo) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
}


Measured memory_bytes: 256
#define w vector
#define z double
#define q int
#define ar begin()
#define ae end()
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>
using namespace std;z inf=numeric_limits<z>::infinity();q main(){q n,m,r;cin>>n>>m>>r;w<w<z>>d=w<w<z>>(n,w<z>(n,inf));w<q>v;for(q i=0;i<r;i++){q l;cin>>l;v.push_back(l-1);}
sort(v.ar,v.ae);for(q i=0;i<m;i++){q a,b,c;cin>>a>>b>>c;d[a-1][b-1]=c;d[b-1][a-1]=c;}
for(q k=0;k<n;k++)for(q i=0;i<n;i++)for(q j=0;j<n;j++){d[i][j]=min(d[i][j],d[i][k]+d[k][j]);}
q aa=1e9;do{q bb=0;for(q i=0;i<v.size()-1;i++){bb+=d[v[i]][v[i+1]];}aa=min(aa,bb);}while(next_permutation(v.ar,v.ae));cout<<aa<<endl;}


Measured memory_bytes: 512
n = int(input())
a_array = [int(x) for x in input().split()]
d = dict()
ans_d = dict()
for a in a_array:
    d.setdefault(a, 0)
    d[a] += 1
for key, value in d.items():
    ans_d[key] = value*(value-1)//2

sum_count = sum(ans_d.values())
ans = []
for a in a_array:
    tmp = d[a] - 1
    tmp_count = sum_count -ans_d[a]
    ans.append(tmp_count + tmp*(tmp-1)//2)

for a in ans:
    print(a)



Measured memory_bytes: 37176
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   string s, t;
   cin >> s >> t;
   rep(i, 0, n) { cout << s[i] << t[i]; }
   cout << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
string s;
int k, ans, sz, t;
int main(){
	cin >> s >> k;
	sz = s.size();
	for(; k; k--){
		for(; s[t] == '0'; t++, sz--);
		if(sz < k) break;
		if(k == 3) ans += (sz - 1) * (sz - 2) * (sz - 3) / 6 * 9 * 9 * 9 + (s[t] - '1') * (sz - 1) * (sz - 2) / 2 * 9 * 9;
		else if(k == 2) ans += (sz - 1) * (sz - 2) / 2 * 9 * 9 + (s[t] - '1') * (sz - 1) * 9;
		else ans += (sz - 1) * 9 + (s[t] - '0');
		t++; sz--;
	}
	printf("%d\n",ans);
}

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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007








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

    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];

   

    if(arr[1]==arr[2] && arr[1]==arr[0]) puts("Yes");
    else puts("No");
    
    
    return 0;
}




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

#define endl "\n"

int main(){
    int n; cin>>n;
    vector<int> v(n);
    for(auto &i: v) cin>>i;
    int min1 = v[0], count = 1;
    for(int i = 1; i<n; i++){
        if(v[i] <= min1){
            count++;
        }
        min1 = min(min1, v[i]);
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
#define all(x) (x).begin(),(x).end()
using namespace std;
int x[10000];
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a*b/gcd(a,b);
}
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	f(i,a){
		cin>>x[i];
	}
	f(i,a){
		int y=0,z=0;
		f(j,a){
			if(i==j)continue;
			if(i<j&&x[i]>x[j]){
				z++;
			}
			else if(i>j&&x[i]>x[j]) y++;
		}
		if(b%2) ans+=y*b%mod*((b-1)/2)+z*((b+1)/2)%mod*b;
		else ans+=y*b/2%mod*(b-1)+z*(b+1)%mod*b/2;
		ans%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
dic = {}
for i in range(N):
    S = input().rstrip('\n')
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

# print(dic)
D = sorted(dic.items(), key=lambda x: (-x[1], x[0]))
# print(D)

nn = D[0][1]

for k, v in D:
    if v == nn:
        print(k)
    else:
        break


Measured memory_bytes: 61944
def popcount(x):
    return bin(x).count("1")
def solve(n):
    if n == 0:
        return 0
    return 1+solve(n % popcount(n))

N = int(input())
X = input()
num_x = int(X, 2)
p_cnt = X.count('1')
if p_cnt == 1:
    for i in range(N):
        if X[i] == '1':
            print(0)
        elif i == N-1:
            print(2)
        else:
            print(1)
    exit()
r0_p = num_x % (p_cnt+1)
r0_m = num_x % (p_cnt-1)
for i in range(N):
    if X[i] == '0':
        c_p_cnt = p_cnt+1
        r = (r0_p + pow(2, (N - 1 - i), c_p_cnt)) % c_p_cnt
    else:
        c_p_cnt = p_cnt-1
        if c_p_cnt == 0:
            print(0)
            continue
        r = (r0_m- pow(2, (N - 1 - i), c_p_cnt)) % c_p_cnt
    print(1 + solve(r % c_p_cnt))



Measured memory_bytes: 80816
import java.util.*;
import java.util.Arrays; 
public class Main{
	
	void cal()
	{
		Scanner sc=new Scanner(System.in);
		int N,K;
		N=sc.nextInt();
		K=sc.nextInt();
		
		
		int Health[]=new int[N];
		
		
		for(int i=0;i<N;i++)
		{
			Health[i]=sc.nextInt();				
		}
		
		Arrays.sort(Health);
	     
	    	long  mov=0;
	    	 N=N-K;
	    	 for(int i=0;i<N;i++)
	 		{
	 			mov+=Health[i];
	 				
	 		}
	    	 System.out.println(mov);
	    	 
	     	
		sc.close();
		
	}

public static void main (String args[])
{
	Main obj= new Main();
	obj.cal();

}
}





Measured memory_bytes: 66740
H, W, M = map(int, input().split())

bombs = set()
for _ in range(M):
	y, x = map(int, input().split())
	bombs.add((x - 1, y - 1))

counts_v = [0] * W
counts_h = [0] * H
for x, y in bombs:
	counts_v[x] += 1
	counts_h[y] += 1

max_h = max(counts_h)
max_v = max(counts_v)

max_x_list = []
max_y_list = []

for x in range(W):
	if max_v == counts_v[x]:
		max_x_list.append(x)

for y in range(H):
	if max_h == counts_h[y]:
		max_y_list.append(y)

def check():
	for x in max_x_list:
		for y in max_y_list:
			if (x, y) not in bombs:
				return True
	return False

total = max_h + max_v
if not check():
	total -= 1

print(total)


Measured memory_bytes: 167012
#include<stdio.h>


int main(){

  long long n, i, j, a[200000], b[200000];

  scanf("%lld", &n);
  if(n%2==1){
    for(i=0;i<n;i++){
      scanf("%lld", &a[i]);
      if(i%2==0) b[(n-1)/2-i/2]=a[i];
      else b[(n-1)/2+i/2+1]=a[i];
    }
  }else{
    for(i=0;i<n;i++){
      scanf("%lld", &a[i]);
      if(i%2==0) b[n/2+i/2]=a[i];
      else b[n/2-i/2-1]=a[i];
    }
  }

  for(i=0;i<n;i++){
    if(i==n-1) printf("%lld\n", b[i]);
    else printf("%lld ", b[i]);
  }

  return 0;
}


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

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

    int A[N+1];
    for(int i = 1; i <= N; i++) cin >> A[i];

    int res = 0;

    for(int i = 1; i < N; i++)
    {
        if(A[i] == A[i+1])
        {
            A[i+1] = -1;
            res++;
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
flag=0
for a in A:
    if flag==0 and a%2==0:
        if a%3==0 or a%5==0:
            flag=0
        else:
            flag=1

if flag==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1000000007;


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

   int n;
   cin >> n;
   vector<int> a(4);
   
   rep(i, 0, n){
      string s;
      cin >> s;
      if(s == "AC")a[0]++;
      if (s == "WA") a[1]++;
      if (s == "TLE") a[2]++;
      if (s == "RE") a[3]++;
   }
   printf("AC x %d\n", a[0]);
   printf("WA x %d\n", a[1]);
   printf("TLE x %d\n", a[2]);
   printf("RE x %d\n", a[3]);
   return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    string s;
    cin>>s;
    long long sum = 0;
    for(int i = 0; i < s.size(); i++){
        sum += s[i] - '0';
    }
    if(sum%9){
        cout<<"No";
    }else
    {
        cout<<"Yes";
    }
    
    return 0;
}

Measured memory_bytes: 3728
# import math
# import statistics
# a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(i)
e1,e2,e3 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))

ba1=e1//(e2+e3)
ba2=e1-ba1*(e2+e3)
if ba2<=e2:
    print(ba2+ba1*e2)
elif ba2>e2:
    print(e2+ba1*e2)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=10001;
ll a[N],b[N],n,as=0,bs=0,c,ca;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n+1){
		cin>>a[i];
		as+=a[i];
	}
	FOR(i,1,n+1){
		cin>>b[i];
		bs+=b[i];
	}
	c=bs-as;
	ca=c*2;
	if(as>bs){
		cout<<"No"<<endl;
		return 0;
	}


	
	FOR(i,1,n+1){
		ll k;
		if(b[i]%2!=a[i]%2){
			b[i]++;
			c--;
			if(c<0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		k=b[i]-a[i];
		if(k>0){
			a[i]+=k;
			ca-=k;
			if(ca<0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(k<0){
			k*=-1;
			b[i]+=k;
			c-=k;
			if(c<0){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	if(c==ca)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(int argc, char* argv){
  int a, b;
  
  scanf("%d %d",&a,&b);
  
  if(a % 2 == 1 && b % 2 == 1)
    printf("Odd\n");
  else
    printf("Even\n");

  return 0;

}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
set<ll>se;

void solve(ll N,ll n){
	auto v=divisor(N);
	for(ll k:v){
		if(k==1)continue;
		ll d=n;
		while(d>=k){
			if(d%k==0)d/=k;
			else break;
		}
		d%=k;
		if(d==1){
			se.insert(k);
		}
	}
}

int main(){
	ll n;cin>>n;
	solve(n,n);
	solve(n-1,n);
	cout<<se.size()<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	string S;
	cin >> S;

	vbool alpha(26);
	for (int i = 0; i < 26; i++) {
		alpha[i] = false;
	}

	for (int i = 0; i < S.length(); i++) {
		alpha[int(S[i]) - 97] = true;
	}

	if (S.length() != 26) {
		char plus;
		for (int i = 0; i < 26; i++) {
			if (alpha[i] == false) {
				plus = char(i + 97);
				break;
			}
		}
		cout << S << plus;
	}
	else {

		int replace = -1;
		for (int i = S.length() - 1; i > 0; i--) {
			if (int(S[i - 1]) < int(S[i])) {
				replace = i - 1;
				break;
			}
		}

		if (replace == -1) {
			cout << -1;
			return 0;
		}

		for (int i = 0; i < replace; i++) {
			cout << S[i];
		}
		for (int i = 0; i < 26; i++) {
			alpha[i] = false;
		}
		for (int i = replace + 1; i < S.length(); i++) {
			alpha[int(S[i]) - 97] = true;
		}

		for (int i = int(S[replace]-97)+1; i < 26; i++) {
			if (alpha[i] == true) {
				cout << char(i + 97);
				return 0;
			}
		}
	}
}


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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#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
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
 

 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b and b==c){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
    
    
    return 0;
}


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

int main(void)
{
  int N; cin >> N;
  vector<int> A(N);
  vector<int> sorted(N);
  
  for (auto i = 0; i < N; i++)
    cin >> A[i];
  
  copy(A.begin(), A.end(), sorted.begin());
  sort(sorted.begin(), sorted.end());

  for (auto i = 0; i < N; i++) {
    if (A[i] == sorted[N-1]) cout << sorted[N-2] << endl;
    else cout << sorted[N-1] << endl;
  }
}

Measured memory_bytes: 3200
//Triangle
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
	long long S, x1 = 1000000000, x2 = 1, y1, y2, z1 = 0, z2 = 0, q, r;
	cin >> S;
	if (S == pow(10, 18)) {
		y2 = pow(10, 9);
		y1 = 0;
	}
	else {
		r = S % x1;
		q = S / x1;
		y2 = q + 1;
		y1 = x1 - r;
	}
	cout << x1 << " " << x2 << " " <<  y1 << " " << y2 << " " << z1 << " " << z2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
#define int long long
inline int read(){
	int a=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')b=-1;c=getchar();}
	while(isdigit(c)){a=a*10+c-'0';c=getchar();}
	return a*b;
}
int a,b;
signed main(){
	a=read();b=read();
	a*=b;
	printf("%lld\n",a);
	return 0;
}

Measured memory_bytes: 3748
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("Yes\n")
#define NO() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int H,W,h,w,field[500][500];
	cin >> H >> W >> h >> w;
	if(H % h == 0 && W % w == 0){
		NO();
		return 0;
	}
	YES();
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			if(i % h == h - 1 && j % w == w - 1) field[i][j] = -(h * w - 1) * 1000 - 1;
			else field[i][j] = 1000;
		}
	}
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			if(j) cout << " " << field[i][j];
			else cout << field[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> p;

    for (int i = 0; i < N; i++)
    {
        int p_tmp;
        std::cin >> p_tmp;

        p.push_back(p_tmp);
    }

    int total = std::accumulate(p.begin(), p.end(), 0);
    int max_price = *std::max_element(p.begin(), p.end());

    int ans = total - max_price / 2;

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

    return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> v(26);
    for(int i = 0; i < n; ++i)
        v[s[i] - 'a'].insert(i);
    for(int i = 0; i < q; ++i){
        int type;
        cin >> type;
        if(type == 1){
            int idx;
            char c;
            cin >> idx >> c;
            --idx;
            v[s[idx] - 'a'].erase(idx);
            v[c - 'a'].insert(idx);
            s[idx] = c;
        }
        else{
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            for(int j = 0; j < 26; ++j)
                ans += (v[j].lower_bound(l) != v[j].lower_bound(r));
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	set<int> p;
	for( int k = 2; k <= 100100; ++k ) p.insert(k);
	int x; cin >> x;
	for( int n = 2; n <= 100100; ++n ){
		int k = 2;
		while( n*k < 100100+1000 ){
			p.erase(n*k);
			++k;
		}
	}
	vector<int> candy;
	for( auto k : p ){
		candy.push_back(k);
	}
	cout << (*lower_bound(candy.begin(), candy.end(), x)) << endl;
}

Measured memory_bytes: 4992
#include<cstdio>
int main() {
    int a, b;
    int sum;
    int c;
    while(scanf("%d %d", &a, &b) != EOF) {
        sum = a + b;
        c = 0;
        while (sum > 0) {
            sum /= 10;
            c++;
        }
        printf("%d\n", c);
    }
    return 0;
}



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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  string s;
  cin >> s;
  int m = stoi(&(s[5]), nullptr);

  if(m > 4) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, k , d;
    cin >> x >> k >> d;
    x = abs(x);
    int z = x / d;
    if(z >= k){
        int ans = x % d + d * (z - k);
        cout << ans << '\n';
        return 0;
    }
    else{
        k = k - z;
        x = x % d;
        int xx = d - x;
        if(k % 2== 0)
            cout << x;
        else 
            cout << xx;
    }
    return 0;
}
 

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

int main(void)
{
    ll n;
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
    } else if (n == 2) {
        cout << 1 << endl;
    } else {
        ll sum = 0;
        for (ll i = 1; i < n; i++) {
            sum += i;
        }
        cout << sum << endl;
    }
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
  V<int> a(5);
  for(int i=0;i<5;i++)cin>>a[i];
  for(int i=0;i<5;i++)if(a[i]==0){cout<<i+1<<"\n";break;}
}

Measured memory_bytes: 3660
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int a, b, c, i;

	scanf("%d %d %d", &a, &b, &c);

	for (i = 0; a <= b; a++)
	{
		if (c % a == 0) {
			i++;
		}
	}

	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int x;
	cin>>x;
	if(x<600)cout<<"8"<<endl;
	else if(x<800)cout<<"7"<<endl;
	else if(x<1000)cout<<"6"<<endl;
	else if(x<1200)cout<<"5"<<endl;
	else if(x<1400)cout<<"4"<<endl;
	else if(x<1600)cout<<"3"<<endl;
	else if(x<1800)cout<<"2"<<endl;
	else if(x<2000)cout<<"1"<<endl;
	
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

lint digsum(lint n) {
  lint res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  string s;
  cin>>s;
  lint sum=0;

  int n=s.size();
  rep(i,n){
    char c=s[i];
    sum+=c-'0';
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;

  }
  else {
    cout<<"No"<<endl;
  }
}

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

int main() {
  long W, H, x, y;
  cin >> W >> H >> x >> y;

  double A = W * H / 2.0;
  bool answer = (x == W / 2.0) && (y == H / 2.0);
  printf("%lf %d\n", A, answer);
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
const int maxn = 300 + 10;
int cnt[maxn];
int a[maxn][maxn], pos[maxn][maxn], n, m;
set<pii> s[maxn];
bool isv(int mid){
	for(int i=0; i<n; i++){
		s[i].clear();
		for(int j=0; j<m; j++)
			s[i].insert({j, a[i][j]});
	}
	for(int it=0; it+1<m; it++){
		bool can = 1;
		memset(cnt, 0, sizeof cnt);
		for(int i=0; i<n; i++){
			auto t = *s[i].begin();
			cnt[t.Y]++;
		}
		int idx = -1;
		for(int i=0; i<maxn; i++)
			if(cnt[i] > mid) can = 0, idx = i;
		if(can) return 1;
		for(int i=0; i<n; i++)
			s[i].erase(make_pair(pos[i][idx], idx));
	}
	return 0;
}
int main(){
	cin >> n >> m;
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++){
			cin >> a[i][j];
			a[i][j]--;
			pos[i][a[i][j]] = j;
		}
	int lo = 0, hi = n;
	while(hi - lo > 1){
		int mid = hi + lo >> 1;
		if(isv(mid))
			hi = mid;
		else
			lo = mid;
	}
	cout << hi << endl;
}


Measured memory_bytes: 5248
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
    string x;
    cin>>x;
    ll ans=0;
    rep(i,0,x.size())
    {
        ans = ans+ x[i]-'0';
        ans= ans%9;
    }
    if(ans==0) cout<<"Yes";
    else cout<<"No";
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 3764
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main()
{
   int n,x1;
   cin>>n>>x1;
   int sum=0;
   int cnt=0;
   for(int i=1;i<=n;i++)
   {
       int x;
       cin>>x;
       sum+=x;
       if(sum>x1)
        break;
       cnt++;
   }
   cout<<cnt+1<<endl;
    return 0;
}


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

#define int long long

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

  vector<int> a(N);
  for ( int i = 0; i < N; i++ ) cin >> a[i];

  int ans = 0;
  int now = 100000;
  bool flag = true;
  while ( flag ) {
    flag = false;
    for ( int i = 1; i < N-1; i++ ) {
      if ( a[i] == a[i-1] && a[i] == a[i+1] ) {
	a[i] = now--;
	flag = true;
	ans++;
      }
    }
  }

  for ( int i = 0; i < N; i++ ) {
    if ( i && a[i] == a[i-1] ) {
      a[i] = now--;
      ans++;
    }
    if ( i < N && a[i] == a[i+1] ) {
      a[i] = now--;
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(getline(cin,s),s!="END OF INPUT"){
    for(int i=0,p=0;i<s.size();i++){
      if(s[i]!=' ')p++;
      if(s[i]==' '||i==s.size()-1){
        cout<<p;
        p=0;
      }
    }
    cout<<endl;
  }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) cout << a-1 << ' ' << b << endl;
    else cout << a << ' ' << b-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


// s = r + 2*(1-r)*r + 3*(1-r)^2*r + ...
// (1-r)s = (1-r)*r + ...
// rs = r + (1-r)r + ...
//    = r/r = 1;
// s = 1/r = rp

int main(){
  int N,M; cin>>N>>M;
  ll t = 1900*M+100*(N-M);
  ll rp = pow(2,M);
  cout << t*rp;
}

Measured memory_bytes: 256
/*
 *  Created on: 24-October-2019
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
#define INF 1000000005
 
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
 
using namespace std;

lli dp[105][100005];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n; cin>>n;
    int W; cin>>W;
    lli w[n+1], v[n+1];
    fi(i,1,n+1) cin>>w[i]>>v[i];
    lli ans = 0;
    fi(i,0,105) fi(j,0,100005) dp[i][j] = INF;
    fi(i,0,n+1)
    {
    	flli(j,0,100001)
    	{
    		// if(i==0) continue;
    		if(j==0) dp[i][j] = 0;
    		if(i==0) continue;
    		if(j - v[i] >= 0) dp[i][j] = min(dp[i-1][j], w[i] + dp[i-1][j-v[i]]);
    		else dp[i][j] = dp[i-1][j];

    		if(dp[i][j] <= W) ans = max(ans, j);
    	}
    }
    // debug1(dp[2][100000]);
    cout<<ans;
    return 0;
}

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

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

  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << H*W-(H*w+h*W-h*w) << endl;

  return 0;
}

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

using namespace std;

int main()
{
	int a = 0, b = 0, c = 0;
	string S;

	cin >> S;

	for (int i = 0; i < 3; i++) {
		if (S[i] == 'a')a = 1;
		if (S[i] == 'b')b = 1;
		if (S[i] == 'c')c = 1;
	}

	if (a == 1 && b == 1 && c == 1)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

D, G = gets.split.map(&:to_i)
P = (1 .. D).map do |w|
  c,b = gets.split.map(&:to_i)
  [w,c,b]
end

ans = (1 << D).times.inject(1000_000) do |min_solve, complete|
  unused, used = D.times.partition{|i| complete[i].zero? }
  
  solved_offset, point = used.inject([0, 0]) do |s, i|
    w,c,b = P[i]
    [s[0] + c, s[1] + 100 * w * c + b]
  end
  
  next min(min_solve, solved_offset) if point >= G
  
  rest = unused.reverse_each.inject([0, G - point]) do |s, i|
    solved_count, rest = s
    w,c,b = P[i]
    r = min((rest + 100 * w - 1) / (100 * w), c - 1)
    [solved_count + r, max(0, rest - 100 * w * r)]
  end
  
  if rest[1].zero?
    min(min_solve, solved_offset + rest[0]) 
  else
    min_solve
  end
  
end

puts ans



Measured memory_bytes: 1916
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long

string S;

int main() {
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
		cout << "Bad" << endl;
	else cout << "Good" << endl;


	return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
ll W, weight[110], value[110];

ll dp[110][100100] = {0};

int main(void){
	cin>>n>>W;
	for (int i = 0; i < n; i++) cin>>weight[i]>>value[i];

	for (int i = 0; i < n; i++) {
		for (int sum_w = 0; sum_w <= W; sum_w++) {
			if (sum_w - weight[i] >= 0) {
				dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			} else {
				dp[i + 1][sum_w] = dp[i][sum_w];
			}
		}
	}

	printf("%lld\n", dp[n][W]);
	
	return 0;
}

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

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Pair>[] edges;
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int H = sc.nextInt();
		int W = sc.nextInt();
		String S[] = new String[H];
		for(int i=0;i<H;i++)S[i]=sc.next();
		
		
		int a[][]= new int[2000][2000];
		for(int i=0;i<H;i++) {
			int cnt = 0;
			for(int j=0;j<W;j++) {
				if(S[i].charAt(j)=='.' && j!=W-1)cnt++;
				else {
					if(j==W-1&&S[i].charAt(j)=='.') {
						cnt++;
						j++;
					}
					for(int k=1;k<=cnt;k++) {
						a[i][j-k]+=cnt;
					}
					cnt=0;
				}
			}
		}
 
		for(int i=0;i<W;i++) {
			int cnt = 0;
			for(int j=0;j<H;j++) {
				if(S[j].charAt(i)=='.' && j!=H-1)cnt++;
				else {
					if(j==H-1&&S[j].charAt(i)=='.') {
						cnt++;
						j++;
					}
					for(int k=1;k<=cnt;k++) {
						a[j-k][i]+=cnt;
					}
					cnt=0;
				}		
			}
		}
		
		int ans=0;
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				ans = Math.max(a[i][j],ans);
			}
		}
		out.println(ans-1);
        out.close();
		
	}
	
	 static void sort(long[] A) {
         PriorityQueue<Long> pq = new PriorityQueue<>();
         int i = 0;
         for (i = 0; i < A.length; i++)
             pq.add(A[i]);
         for (i = 0; i < A.length; i++)
             A[i] = pq.poll();
     }

	static class Pair{
		int b;
		int c;
		Pair(int b,int c){
			this.b = b;
			this.c = c;
		}
	}
}


Measured memory_bytes: 55892
#include<bits/stdc++.h>
#define int long long

using namespace std;

#define forn(i, a, b) for(int i = a; i <= b; i++)

const double EPS = 1e-9;
const double pi = acos( -1. );
const int mod = 1e9 + 7;
int MAX = -1e18;
int MIN = 1e18;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))

int mul_mod(int a, int b, int mod)
{
    int res = 0;
    while( b )
    {
        if( b & 1 )
            res = (res + a) % mod;
        a = (a + a) % mod;
        b >>= 1;
    }
    return res;
}

int binpow(int a, int b, int mod)
{
    if(b==0) return 1;
    if(b%2==1) return mul_mod(a,binpow(a,b-1,mod),mod);
    else
    {
        int d=binpow(a, b/2, mod)%mod;
        return 1ll * mul_mod(d, d, mod) % mod;
    }
}

inline int GCD_E ( int a, int b, int & x, int & y )
{
    if ( !a )
    {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = GCD_E ( b % a, a, x1, y1 );
    x = y1 - ( b / a ) * x1;
    y = x1;
    return d;
}


inline int divMOD ( int a, int b, int m = mod)
{
    int x, y;
    int g = GCD_E ( b, m, x, y );
    x = ( x % m + m ) % m;
    return ( a * x ) % m;
}

bool is_prime( int n )
{
    int d = n - 1;
    int s = 0;
    while(d % 2 == 0)
    {
        s++;
        d >>= 1;
    }
    int a[9] = { 2, 3, 5, 7, 11, 13, 17, 19, 23};
    forn ( i, 0, 8 )
    {
        bool comp = ( binpow(a[i], d, n) != 1);
        if( comp )
            forn( j, 0, s-1 )
        {
            int fp = binpow(a[i], (1ll << j) * d, n);
            if(fp == n-1)
            {
                comp = false;
                break;
            }
        }
        if( comp ) return false;
    }
    return true;
}

bool isprime(int n)
{
    if(n<2) return false;
    for(int i=2; i*i*i<=n; ++i) if(n%i==0) return false;
    for(int it=0; it<1e5; ++it)
    {
        int i = rand()%(n-1)+1;
        if(__gcd(i,n)!=1) return false;
        if(binpow(i,n-1,n)!=1) return false;
    }
    return true;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int phi(int n)
{
    int result = n;

    for (int p = 2; p * p <= n; ++p)
    {
        if (n % p == 0)
        {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }

    if (n > 1)
        result -= result / n;
    return result;
}
main()
{
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n --){
    int x, y;
    cin >> x >> y;
    double d = sqrt(x*x*1.0 + y*y*1.0);
              if(d <= k)
                ans ++;
  }
  cout << ans;
}


Measured memory_bytes: 3676
import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:  # その島が親なら
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] > self.table[s2]:
                self.table[s2] = s1  # 親の番号を更新
                self.table[s1] -= 1
                self.size[s1] += self.size[s2]
                self.size[s2] = 0
            else:
                self.table[s1] = s2
                self.table[s2] -= 1
                self.size[s2] += self.size[s1]
                self.size[s1] = 0  #

        return


n, m = map(int, input().split())
brs = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
ans = [n*(n-1)//2]
for i in range(m-1, 0, -1):
    a, b = brs[i][0], brs[i][1]
    a, b = a-1, b-1  # 0インデックスにするため
    s1, s2 = uf.find(a), uf.find(b)
    if s1 != s2:
        ans.append(ans[-1] - uf.size[s1]*uf.size[s2])  # つながったら不便さが解消される
    else:
        ans.append(ans[-1])  # 親が一緒なら時系列が進んでも不便さは変わらない
    uf.union(s1, s2)

print(*list(reversed(ans)), sep='\n')


Measured memory_bytes: 62628