akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        Map<String, Integer> m = new HashMap<>();
        int total = 0;
        for (int i = 0; i < N; i++) {
            String s = scanner.next();
            int n = Integer.parseInt(scanner.next());
            total += n;
            m.put(s, total);
        }
        String x = scanner.next();
        System.out.println(total - m.get(x));
    }

}



Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  bool operator>(const mint a) const {
    mint res(*this);
    return res.x > a.x;
  }
  bool operator<(const mint a) const {
    mint res(*this);
    return res.x < a.x;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll n, a, b; std::cin >> n >> a >> b;
  mint all = mint(2).pow(n) - 1;

  mint ma = 1, mb = 1;
  rep(i, a) ma *= (n-i);
  rep(i, b) mb *= (n-i);

  mint na = 1, nb = 1;
  for(int i=1; i<=a; i++) na *= i;
  for(int i=1; i<=b; i++) nb *= i;

  mint aa = ma / na;
  mint bb = mb / nb;

  mint ans = all - aa - bb;
  std::cout << ans.x << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    ll x,k,d; cin >> x >> k >>d;
    ll a;

    if(x < 0) x *= -1;

    a = x/d;

    if(a >= k){

        x -= d*k;
        k -= k;

    }else{
        k -= a;
        x -= d*a;
    }

    while(k > 0 && x > 0){
        k --;
        x -= d;
    }



    if(k == 0) cout << abs(x);
    else if(k%2 == 1) cout << x+d;
    else cout << abs(x);

}

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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

typedef vector<char> vc;
int main(){
	int h,w;
	cin >> h >> w;
	vi al(26);
	rep(i,h){
		string tmp;
		cin >> tmp;
		rep(j,tmp.length())al[tmp[j] - 'a']++;
	}
	int odd = h * w % 2;
	int two = (h %2) * w/2 + (w % 2) * h/2;
	rep(i,26){
		if(al[i] & 2) two--;
		if(al[i] & 1) odd--;
	}
	cout << (odd >= 0 && two >= 0 ? "Yes" : "No") << endl;
	return 0;
}



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

const int MAX_N = 2e5+2;
int N, K, C;
string S;
int dp1[MAX_N], dp2[MAX_N];

void solve()
{
	for(int i=1;i<=N;++i){
		if(S[i-1] == 'x') dp1[i]=dp1[i-1];
		else{
			dp1[i]=dp1[i-1];
			if(i<=C) dp1[i]=max(dp1[i], 1);
			else dp1[i]=max(dp1[i], 1+dp1[i-C-1]);
		}
	}
	for(int i=N;i>=1;--i){
		if(S[i-1]=='x') dp2[i]=dp2[i+1];
		else{
			dp2[i]=dp2[i+1];
			if(i+C>N) dp2[i]=max(dp2[i],1);
			else dp2[i]=max(dp2[i],1+dp2[i+1+C]); 
		}
	}
	for(int i=1;i<=N;++i)if(S[i-1]!='x'){
		if(dp1[i-1]+dp2[i+1] < K) cout << i << '\n';
	}
}

int main()
{
	cin >> N >> K >> C;
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 5300
import math
from collections import deque
from collections import defaultdict

import bisect

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	return ans

q = readInt()
lr = []

maxNumber = 100000

for i in range(q):
	lr.append(readInts())


pri = get_sieve_of_eratosthenes(maxNumber)
simi = []

for i in range(1,len(pri)):
	if pri[bisect.bisect_left(pri,(pri[i]+1)//2)]==(pri[i]+1)//2:
		simi.append(pri[i])

for item in lr:
	print(len(simi[bisect.bisect_left(simi,item[0]):bisect.bisect_right(simi,item[1])]))

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 1e5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
ll dp[N][4];
ll a[4];

void solve(){
    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < 3 ; j ++){
            scanf("%d" , &a[j]);
            if(i){
                for(int k = 0 ; k < 3 ; k ++){
                    if(j != k){
                        dp[i][j] = max(dp[i][j] , dp[i-1][k] + a[j]);
                    }
                }
            }
            else dp[i][j] = a[j];
        }
    }
    printf("%lld\n" , max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2])));

}

main(){
    int t = 1;
    //scanf("%d" , &t);

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

    return 0;
}






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

int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	unsigned long long i,j,n,a,b,c,d,ans,A,B;
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	if(s1[s1.length()-1]==s2[0] and s2[s2.length()-1]==s3[0])cout<<"YES";
	else cout<<"NO";
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, M;
vector<int> ad[100003];
int dp[100004];

int rec(int u) {
	if(ad[u].size() == 0)
		return 0;
	if(dp[u]!=-1)
		return dp[u];
	int ans =0;
	for(int i=0;i<ad[u].size();++i) {
		int v = ad[u][i];
		ans = max(ans, 1 +rec(v));
	}
	dp[u]=ans;
	return ans;
}

int main() {
	scanf("%d %d", &N, &M);
	for(int i=0;i<M;++i) {
		int a,b;
		scanf("%d %d", &a, &b);
		ad[a].push_back(b);
	}
	memset(dp, -1, sizeof(dp));
	int ans = -1;
	for(int i=1;i<=N;++i) 
	 if(dp[i]=-1)
	  ans = max(ans, rec(i));
	printf("%d", ans);
}

Measured memory_bytes: 8192
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main(){
  double q,x;
  while(cin>>q,q!=-1){
    x=q/2;
    while(fabs(x*x*x-q)>=0.00001*q) x=x-((x*x*x-q)/(3*x*x));
    cout << fixed << setprecision(7) << x << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a=0,b=0,i;
	char c[20];
	scanf("%d",&a);
	printf("%d",(a-2)*180);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

typedef long long ll;

ll n, Q;
string s;
set<ll> se[29];

int main()
{
    cin>>n>>s>>Q;
    s = ' ' + s;
    for(ll i = 1; i < s.size(); i++)
    {
        se[s[i] - 'a'].insert(i);
    }
    while(Q--)
    {
        ll t1, t2;
        cin>>t1;
        if(t1 == 1)
        {
            char t3;
            cin>>t2>>t3;
            se[s[t2] - 'a'].erase(t2);
            se[t3 - 'a'].insert(t2);
            s[t2] = t3;
        }
        else
        {
            ll t3;
            cin>>t2>>t3;
            ll cnt = 0;
            for(ll i = 0; i < 26; i++)
            {
                auto lt = se[i].lower_bound(t2);
                auto rt = se[i].upper_bound(t3);
                if(lt != rt) cnt++;
            }
            cout<<cnt<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24216
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)

int main()
{
	int n;
	cin >> n;
	int pre = n/1000;
	int post = n<=999?n:n-999;
	char ch = (char)('C'+pre);
	string ext = "";
	if(post/10 == 0)ext = "00";
	else if(post/100 == 0)ext = "0";
	cout << "AB" << ch ;
}
	


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string a[2];
	for(int i=0;i<2;i++)cin>>a[i];
	for(int i=0;i<3;i++)
	{
		if(a[0][i]!=a[1][2-i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  string s,t; cin>>s>>t;
  int ans = INF;
  rep (i, s.size()-t.size()+1){
    int tmp_ans = 0;
    rep(j, t.size()){
      if (t[j] != s[i+j]) tmp_ans++;
    }
    //cout << tmp_ans << endl;
    ans = min(ans, tmp_ans);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (true){
            String numStr = sc.next();
            if (numStr.equals("0"))
                break;
            int sum = 0;
            for (int i = 0; i < numStr.length(); i++){
                 sum += Integer.parseInt(numStr.substring(i, i + 1));
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 26668
#include<iostream>
#include<string>
using namespace std;
int main() {
	//<<<ここにプログラムを書く>>>
	int a, b, x, y, z;
	cin >> a >> b >> x >> y >> z;
	if (x + z <= a && x - z >= 0 && y + z <= b && y - z >= 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
template<class T> using V = vector<T>;

int main(){
  int n;
  while(cin>>n,n){
    V<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int ans = accumulate(a.begin()+1,a.end()-1,0);
    cout << ans/(n-2) << endl;
  }
}



Measured memory_bytes: 3148
from heapq import heapify, heappop, heappush
W,H = map(int,input().split())
R = []
for i in range(W):
  temp = int(input())
  heappush(R,(temp,"x"))
for i in range(H):
  temp = int(input())
  heappush(R,(temp,"y"))
X = 0
Y = 0
ans = 0
#print(W,H)
for i in range(H+W):
  cost,muki = heappop(R)
  #print(cost,muki)
  if muki == "x":
    ans += cost*(H+1-Y)
    #print(cost,H+1-Y,muki)
    X += 1
  else:
    ans += cost*(W+1-X)
    #print(cost,W+1-X,muki)
    Y += 1
print(ans)    


Measured memory_bytes: 29524
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  long N,A,B;in(N,A,B);
  out(N/(A+B)*A+min(N%(A+B),A));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
s = input()
t = input()

result = len(s)
for i in range(len(s) -len(t) + 1):
  result1 = 0
  k = i
  for j in range(len(t)):
    if s[k] != t[j]:
      result1 += 1
    k += 1
  if result > result1:
    result = result1
    
print(result)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
long long n;
void solve()
{
    long long i,j,a,b,a1=0,a2=0,a3=0;
    vector < long long > p(n);
    cin>>a>>b;
    for (i=0;i<n;i++)
        cin>>p[i];
    sort(p.begin(),p.end());
    for (i=0;i<n;i++)
        if (p[i]<=a) a1++;
        else break;
    for (j=i;j<n;j++)
        if (p[j]<=b) a2++;
        else break;
    a3=n-j;
    cout<<min(a1,min(a2,a3))<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 1;
  for (int i = 1; i <4; i++){
    cnt++;
    if(s[0] == s[i]) break;
  }
  if(cnt == 2){
    if(s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if (cnt == 3){
    if(s[1] == s[3] && s[0] != s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if (cnt == 4){
    if(s[1] == s[2] && s[0] != s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


#define MAX_N 100000
int par[MAX_N];
int myrank[MAX_N];
ll siz[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        myrank[i] = 0;
        siz[i] = 1;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;

    if(myrank[x] < myrank[y]){
        par[x] = y;
        siz[y] += siz[x];
    }
    else{
        par[y] = x;
        siz[x] += siz[y];
        if(myrank[x] == myrank[y])  myrank[x]++;
    }
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y){
    return find(x) == find(y);
}

ll ret_size(int x){
    x = find(x);
    return siz[x];
}


int main(){
    ll N, M;
    int a[101000], b[101000];
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int aa, bb;
        cin >> aa >> bb;
        aa--; bb--;
        a[i] = aa;
        b[i] = bb;
    }

    init(N);
    vector<ll> res_list;
    ll res = N*(N-1)/2;
    res_list.push_back(res);
    for(int i = M-1; i > 0; i--){
        if(same(a[i], b[i])){
            res_list.push_back(res);
            continue;
        }
        res -= ret_size(a[i]) * ret_size(b[i]);
        res_list.push_back(res);
        unite(a[i], b[i]);
    }

    for(int i = M-1; i >= 0; i--){
        cout << res_list[i] << endl;
    }


    return 0;
}


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

void solve() {
    ll a;
    string bstr;
    cin >> a >> bstr;

    string b = "";
    rep(i,bstr.size()) {
        if (bstr[i] != '.') {
            b.push_back(bstr[i]);
        }
    }

    ll lb = stol(b);
    cout << (a * lb) / 100 << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int> vec1(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
        vec1[i]=x;
    }
    sort(vec.begin(),vec.end());
    int First=vec[n-1];
    int Second=vec[n-2];
   /// cout<<First<<endl;
    //cout<<Second<<endl;
    for(int i=0;i<n;i++){
        if(vec1[i]==First){
            cout<<Second<<endl;
        }else{
            cout<<First<<endl;
        }
    }
}

Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<ll>f(n + 1), f_inv(n + 1);
	f[0] = 1;
	f_inv[0] = n_pow(f[0], mod - 2);
	for (int i = 1; i < n + 1; i++) {
		f[i] = (i*f[i - 1]) % mod;
		f_inv[i] = n_pow(f[i], mod - 2);
	}
	ll s_max = 0;
	for (int i = k - 1; i < n; i++) {
		ll tmp = (((f[i] * f_inv[i - k + 1]) % mod)*f_inv[k - 1]) % mod;
		s_max += (tmp * a[i]) % mod;
		s_max %= mod;
	}
	ll s_min = 0;
	for (int i = 0; i < n - k + 1; i++) {
		ll tmp = (((f[n - i - 1] * f_inv[n - i - k]) % mod)*f_inv[k - 1]) % mod;
		s_min += (tmp * a[i]) % mod;
		s_min %= mod;
	}
	ll ans = (s_max - s_min) % mod;
	if (ans < 0)ans += mod;
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	long long power = 1;
	for (int i = 1; i <= n; i++) {
		power *= i;
		if (power > 1000000007)
			power = power % 1000000007;
	}
	cout << power << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

int L[2000];
int main(){ 
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }

    sort(L, L + N);
    long long ans = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            auto it = lower_bound(L, L + N, L[i] + L[j]);
            ans += (it - L) - (long long) (j + 1);
        }
    }
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc073/tasks/abc073_d

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;


int main (int argc, char* argv[]) {
	int n, m, r;
	cin >> n >> m >> r;

	vector<int> travel_locations(r);
	for (int i = 0; i < r; i++) {
		cin >> travel_locations[i];
		travel_locations[i]--;
	}

	vector<vector<long long>> costs(n, vector<long long>(n, 1ll << 60));
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		costs[a][b] = c;
		costs[b][a] = c;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
			}
		}
	}

	long long min_cost = numeric_limits<long long>::max();
	sort(travel_locations.begin(), travel_locations.end());
	do {
		long long cost = 0;
		for (int i = 0; i < travel_locations.size() - 1; i++) {
			cost += costs[travel_locations[i]][travel_locations[i + 1]];
		}
		min_cost = min(min_cost, cost);
	} while (next_permutation(travel_locations.begin(), travel_locations.end()));

	cout << min_cost << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  string s;
  cin >> s;
  FOR(i,0,s.size()){
    if(s[i]=='?')s[i] = 'D';
  }
  cout << s << endl;
}


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

int ball[100005];

bool maybe[100005] = { } ;

int n, m;

inline void init()
{
	scanf("%d%d", &n, &m);
	maybe[1] = true;
	for (int i = 1; i <= n ; i++)
	 {
	     ball[i] = 1;
	 }
}

inline void work()
{
	for (int i = 1; i <= m ; i++)
	 {
	 	int x, y;
	 	scanf("%d%d", &x, &y);
	 	if (maybe[x]) maybe[y] = true;
	 	ball[x] --;
	 	ball[y] ++;
	 	if (!ball[x])
	 	 maybe[x] = false;
	 }
	int ans = 0;
	for (int i = 1; i <= n ; i ++) 
	 if (maybe[i]) ans ++;
	printf("%d\n", ans);
    return;
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
#define rep(var,n)  for(int var=0;var<(n);++var)

int main() {
    char buf[200003];
    fgets(buf,200003,stdin);
    int L=0;
    vector<ll> cnt(26, 0);
    rep(i, 200003){
        if (buf[i] < 'a') {
            buf[i] = 0; L = i; break;
        }
        ++cnt[buf[i]-'a'];
    }
    ll ans = 0;
    rep(i,26){
        ans += cnt[i] * (L - cnt[i]);
    }
    ans = ans/2 + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG

#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(){
    int N;
    cin >> N;

    ll memo0 = 2;
    ll memo1 = 1;
    ll memo = 1;
    int count = 0;

    if(N < 2){
        cout << 1 << endl;
        return 0;
    }

    while(true){
        count++;
        if(count == N) break;
        memo = memo0 + memo1;
        memo0 = memo1;
        memo1 = memo;
    }

    cout << memo << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vector<P> p(n);
    rep(i, n) {
        ll t, d;
        cin >> t >> d;
        p[i] = make_pair(d, t);
    }
    sort(rall(p));

    map<ll, ll> mp;
    priority_queue<ll, vector<ll>, greater<ll>> prQ;
    ll ans = 0;
    rep(i, k) {
        ll d = p[i].first;
        ll t = p[i].second;
        ans += d;
        mp[t]++;
        if(mp[t] >= 2) {
            prQ.push(d);
        }
    }
    ll x = mp.size();
    ans += x*x;

    ll now = ans;
    exrep(i, k, n-1) {
        if(prQ.empty()) {
            break;
        }
        ll d = p[i].first;
        ll t = p[i].second;
        if(mp[t] > 0) {
            continue;
        }
        ll z = prQ.top();
        prQ.pop();
        now += d - z;
        now += 2*x + 1;
        mp[t]++;
        x++;
        chmax(ans, now);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 6140
#include<cstdio>
const long long inf = 1e18+7;

int main(){
    long long a[2],b[2];
    for(int i = 0; i < 2; i++) scanf("%lld%lld",&a[i],&b[i]);
    long long ans = -inf;
    long long cur = a[0]*a[1];
    if(ans<cur) ans = cur;
    cur = a[0]*b[1];
    if(ans<cur) ans = cur;
    cur = b[0]*a[1];
    if(ans<cur) ans = cur;
    cur = b[0]*b[1];
    if(ans<cur) ans = cur;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1732
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    print(factorial(int(input())) % mod)
if __name__ == '__main__':
    main()

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

typedef long long ll;

int main() {
    int N, d;
    cin >> N;
    set<int> s;
    rep(i, N) {
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << "\n";
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {
    private static boolean isGreater(int p, int q, int pp, int qq) {
        p *= qq;
        pp *= q;
        return p > pp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();

        int ansX = 100 * A;
        int ansY = 0;
        int maxP = 0;
        int maxQ = 1;

        for (int ai = 0; ai * 100 <= F; ai += A) {
            int a = ai * 100;
            for (int bi = 0; a + 100 * bi <= F; bi += B) {
                int b = bi * 100;
                for (int c = 0; a + b + c <= F; c += C) {
                    for (int d = 0; a + b + c + d <= F; d += D) {
                        if ( (ai + bi) * E < c + d ) {
                            continue;
                        }
                        int water = a + b;
                        int sugar = c + d;
                        if ( isGreater(sugar * 100, water + sugar, maxP, maxQ) ) {
                            maxP = sugar * 100;
                            maxQ = water + sugar;
                            ansX = water + sugar;
                            ansY = sugar;
                        }
                    }
                }
            }
        }

        System.out.println(ansX + " " + ansY);
    }
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, X;
    cin >> n >> X;
    ll x[n];
    rep(i, n){
        ll tmp;
        cin >> tmp;
        x[i] = abs(tmp - X);
    }

    if(n == 1){
        ppp(x[0]);
        return 0;
    }

    sort(x, x+n);

    ll ans = x[0];
    rep(i, n){
        ll a = ans, b = x[i];
        ans = gcd(a, b);
    }

    ppp(ans);



    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, 0, n - 2) {
		string t;
		t = t + s[i] + s[i + 1] + s[i + 2];
//		cout << t << endl;
		if (t == "ABC") ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;

void solve(int A, int B) {
  cout << A * B << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;

  solve(A, B);

  return 0;
}


Measured memory_bytes: 3652
main = do
    str <- getLine :: IO String
    print . maximum $ f str 0

f [] _ = []
f (x:xs) n = if isATCG x then (n+1) : f xs (n+1)
                         else n : f xs 0

isATCG c = case c of
    'A' -> True
    'T' -> True
    'C' -> True
    'G' -> True
    otherwise -> False

Measured memory_bytes: 380
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	int N,W;
	cin>>N>>W;
	vll w,v;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		w.pb(a);
		v.pb(b);
	}
	vll ww[4];
	for(int i=0;i<N;i++){
		ww[w[i]-w[0]].pb(v[i]);
	}
	for(int i=0;i<4;i++){
		sort(ww[i].begin(),ww[i].end(),greater<int>());
	}
	for(int i=0;i<4;i++){
		for(int j=1;j<ww[i].size();j++){
			ww[i][j]+=ww[i][j-1];
		}
	}
	int maxi=0;
	for(int i=0;i<=N;i++){
		if(i>ww[0].size())
			break;
		for(int j=0;j<=N;j++){
			if(j>ww[1].size())
				break;
			for(int k=0;k<=N;k++){
				if(k>ww[2].size())
					break;
				for(int l=0;l<=N;l++){
					if(l>ww[3].size())
						break;

					if(w[0]*i+(w[0]+1)*j+(w[0]+2)*k+(w[0]+3)*l>W)
						continue;

					int comp=0;
					if(i!=0)
						comp+=ww[0][i-1];
					if(j!=0)
						comp+=ww[1][j-1];
					if(k!=0)
						comp+=ww[2][k-1];
					if(l!=0)
						comp+=ww[3][l-1];

					maxi=max(maxi,comp);

				}
			}
		}
	}
	cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	int par[M],rank[M];

	void init(int n){
		for(int i=0;i<n;i++){
			par[i]=i;
			rank[i]=0;
		}
	}

	int root(int x) {
		return par[x]==x?x:par[x]=root(par[x]);
	}

	bool same(int x,int y){
		return root(x)==root(y);
	}

	void unite(int x,int y){
		x=root(x);y=root(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			par[x]=y;
		}else{
			par[y] = x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int n, m; cin >>n>>m;
	int x[M],y[M],z;
	for (int i = 0; i < m; ++i) cin >>x[i]>>y[i]>>z,x[i]--,y[i]--;
	UnionFind uf;
	uf.init(n);
	for (int i = 0; i < m; ++i) uf.unite(x[i], y[i]);
	set<int> se;
	for (int i = 0; i < n; ++i) se.insert(uf.root(i));
	print(se.size());
}



	

Measured memory_bytes: 6400
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

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

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;

const int MAX_N = 100;

int n, m, q = 0;
vector<int> G[MAX_N];
int adj[MAX_N][MAX_N];
vector<pair<int, int> > edge;
bool mark[MAX_N];

void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (adj[u][v] == 1 && mark[u] == false) {
      dfs(u);
    }
  }
}

int main() {
  cin>>n>>m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin>>u>>v;
    u--;
    v--;
    G[u].pb(v);
    G[v].pb(u);
    adj[u][v] = 1;
    adj[v][u] = 1;
    edge.pb(mp(u, v));
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      mark[j] = false;
    }
    adj[edge[i].F][edge[i].S] = 0;
    adj[edge[i].S][edge[i].F] = 0;
    dfs(1);
    for (int j = 0; j < n; j++) {
      if (mark[j] == false) {
        q++;
        break;
      }
    }
    adj[edge[i].F][edge[i].S] = 1;
    adj[edge[i].S][edge[i].F] = 1;
  }
  cout<<q<<endl;
}


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

int main()
{
	long long int n,k,i,cnt=0;
	cin>>n>>k;
	int ara[n];
  
	for(i=0;i<n;i++){
		cin>>ara[i];
	}
  
	sort(ara,ara+n);
  
	for(i=0;i<n-k;i++){
		cnt+=ara[i];
	}
  
	cout<<cnt<<endl;
  
	return 0;
}

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

using namespace std;

#define N 1000000

int main() {
	int dp[N] = {0}, dp_odd[N] = {0};

	for(int i = 1; i < N; i++)
		dp[i] = dp_odd[i] = N;

	for(int i = 1; i < N; i++) {
		int t = i*(i+1)*(i+2)/6;
		if(t > N) break;
		for(int j = t; j < N; j++) dp[j] = min(dp[j], dp[j-t]+1);
		if(t%2 == 1) for(int j = t; j < N; j++) dp_odd[j] = min(dp_odd[j], dp_odd[j-t]+1);
	}

	int n;
	while(cin >> n && n) {
		cout << dp[n] << " " << dp_odd[n] << endl;
	}


	return 0;
}

Measured memory_bytes: 10888
def main():
    A, B, C = map(int, input().split())
    num = sorted([A, B, C])
    ans = 0
    even = 0
    for i in range(3):
        if not num[i]&1:
            even += 1
    if even == 2:
        ans = 1
        for i in range(3):
            if not num[i]&1:
                num[i] += 1
    elif even == 1:
        ans = 1
        for i in range(3):
            if num[i]&1:
                num[i] += 1
    ans += (num[2] * 2 - num[0] - num[1]) // 2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for _ in range(q)]
count=Counter(a)

sum=sum(a)
for i in range(q):
    b=bc[i][0]
    c=bc[i][1]
    diff=c-b
    num=count[b]
    sum+=num*diff
    print(sum)
    count[c]+=count[b]
    count[b]=0

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long repow(long long x, long long y){
    if(y == 0) return 1;
    long long res = 1;
    while(y != 0){
        if(y & 1) res = res*x%MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}
int main(){
    int N;
    cin >> N;
    long long temp = repow(10, N); 
    long long t = repow(9, N);
    long long t2 = repow(8, N);
    cout << ((temp - 2 * t % MOD + MOD) % MOD + t2) % MOD << endl;
}

Measured memory_bytes: 3628
# Binary Search Tree
class Node:
    def __init__(self, v):
        self.value = v
        self.parent = None
        self.left = None
        self.right = None

# 再帰を使わないパターンの方が早い
def insert(node):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if node.value < x.value:
            x = x.left
        else:
            x = x.right
    node.parent = y
    if y is None:
        root = node
    elif node.value < y.value:
        y.left = node
    else:
        y.right = node

def find(num):
    global root
    x = root
    while x is not None:
        if num == x.value:
            return True
        elif num < x.value:
            x = x.left
        else:
            x = x.right
    return False

def preorder_walk(node):
    if node:
        yield node.value
        for x in preorder_walk(node.left):
            yield x
        for x in preorder_walk(node.right):
            yield x

def inorder_walk(node):
    if node:
        for x in inorder_walk(node.left):
            yield x
        yield node.value
        for x in inorder_walk(node.right):
            yield x

root = None
n = int(input())
for i in range(n):
    cmd, *val = input().split()
    if cmd == "insert":
        #root = insert(root, int(val[0]))
        insert(Node(int(val[0])))
    elif cmd == "print":
        print("", *inorder_walk(root))
        print("", *preorder_walk(root))
    elif cmd == "find":
        if find(int(val[0])):
            print("yes")
        else:
            print("no")


Measured memory_bytes: 91244