akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N;

    cin >> N;

    if(N%2==1){
        cout << N/2+1 << endl;
    }
    else{
        cout <<  N/2 << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);

  int s, t;
  for(int i = 0; i < M; i++){
    cin >> s >> t;
    s--;
    t--;
    G[s].push_back(t);
  }


  double ans_final = M * 2;

  for(int k = 0; k < N; k++){
    vector<double> ans(N);
    for(int i = 0; i < N; i++){
      ans[i] = double(2*M);
    }

    ans[N-1] = 0.0;

    for(int i = N-2; i >= 0; i--){
      
      if(G[i].size() == 1){
        ans[i] = ans[G[i][0]] + 1.0; 
      }else{
        double sum = 0.0;
        double max_exp = 0.0;
        int size_tmp = G[i].size();
        for(int j = 0; j < G[i].size(); j++){
          sum += ans[G[i][j]] + 1.0;
          chmax(max_exp, ans[G[i][j]] + 1.0);
        }
        if(i == k){
          sum -= max_exp;
          size_tmp -= 1;
        }
        ans[i] = sum / double(size_tmp);
      }
    }
    chmin(ans_final, ans[0]);
  }

  cout << setprecision(10) << ans_final << endl;

  return 0;
}


Measured memory_bytes: 1408
/*
https://tubo28.me/compprog/algorithm/minball/
*/

#include <bits/stdc++.h>
using P = std::complex<double>;
using ld = double;
const ld eps = 0.0000000001;

ld cross(const P &l, const P &r) {
  return l.real() * r.imag() - l.imag() * r.real();
}

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
  const int n = right - left;

  assert(n >= 1);
  if (n == 1) {
    return {*left, ld(0)};
  }

  std::mt19937 mt(seed);
  std::shuffle(left, right, mt);
  // std::random_shuffle(left, right); // simple but deprecated

  iter ps = left;
  using circle = std::pair<P, ld>;

  auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
    ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
       S = cross(b - a, c - a);
    P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) /
          (4 * S * S);
    ld r2 = std::norm(p - a);
    return {p, r2};
  };

  auto make_circle_2 = [](const P &a, const P &b) -> circle {
    P c = (a + b) / (ld)2;
    ld r2 = std::norm(a - c);
    return {c, r2};
  };

  auto in_circle = [](const P &a, const circle &c) -> bool {
    return std::norm(a - c.first) <= c.second + eps;
  };

  circle c = make_circle_2(ps[0], ps[1]);

  // MiniDisc
  for (int i = 2; i < n; ++i) {
    if (!in_circle(ps[i], c)) {
      // MiniDiscWithPoint
      c = make_circle_2(ps[0], ps[i]);
      for (int j = 1; j < i; ++j) {
        if (!in_circle(ps[j], c)) {
          // MiniDiscWith2Points
          c = make_circle_2(ps[i], ps[j]);
          for (int k = 0; k < j; ++k) {
            if (!in_circle(ps[k], c)) {
              c = make_circle_3(ps[i], ps[j], ps[k]);
            }
          }
        }
      }
    }
  }
  return c;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<P> ps(n);
  for (auto &e : ps) {
    int x, y;
    std::cin >> x >> y;
    e.real(x);
    e.imag(y);
  }
  std::cout << std::setprecision(20)
            << std::sqrt(min_ball(ps.begin(), ps.end()).second) << std::endl;
}

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

int main()
{
  int h, w;
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) cout << '#';
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
N=int(input())
A=[[] for i in range(N+1)]
B=[0 for i in range(N+1)]
for i in range(N-1):
    a,b=[int(x) for x in input().split()]
    A[a].append(b)
    A[b].append(a)
    B[a]+=1
    B[b]+=1
C=sorted( [int(x) for x in input().split()] )
D=[-1 for i in range(N+1)]
M=sum(C) - C[-1]
isEnd=[]
for i in range(1,N+1):
    if B[i]==1:
        isEnd.append(i)

for c in C:
    d=isEnd.pop()
    D[d]=c
    B[d]=0
    #M += c
    for k in A[d]:
        A[k].remove(d)
        B[k]-=1
        if B[k]==1:
            isEnd.append(k)
print (M)
print (' '.join([str(x) for x in D[1:]]) )


Measured memory_bytes: 50392
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    vector<pair<int,int>>vec(N);
    REP(i,N){
        int a,b;cin>>a>>b;
        vec[i]=make_pair(b,a);
    }
    sort(vec.begin(),vec.end());
    int sum=0;
    bool ok=true;
    REP(i,N){
        sum+=vec[i].second;
        if(sum>vec[i].first){
            ok=false;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            int maximum = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];
                    if (sum > maximum) {
                        maximum = sum;
                    }
                }
            }
            System.out.println(maximum);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <unordered_set>

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

    std::unordered_set<int> S;
    for (int i = 0; i < q; i++) {
        int op, x;
        std::cin >> op >> x;

        if (op == 0) {
            S.insert(x);
            std::cout << S.size() << std::endl;
        } else if (op == 1) {
            std::cout << S.count(x) << std::endl;
        } else if (op == 2) {
            S.erase(x);
        }
    }
}



Measured memory_bytes: 11028
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define got(container,num) get<num-1>(container)
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m

using namespace std;
const int INF=LLONG_MAX-1e10;
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
deque<char>h;
main()
{
    IOS
    string k;
    cin>>k;
    fa(i,k)h.pb(i);
    cin>>n;
    fun(i)
    {
        int o;
        cin>>o;
        if(o==2)
        {
            int type;
            char nn;
            cin>>type>>nn;
            if((ans+type)%2)h.pf(nn);
            else h.pb(nn);
        }else ans++;
    }
    string tt="";
    fa(i,h)tt+=i;
    string t=tt;
    reverse(all(t));
    out(ans%2?t:tt)
    return 0;
}

Measured memory_bytes: 1748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int S = 1988 ;
using namespace std ;

int H, W, h, w ; 

int main() {
	scanf("%d%d%d%d", &H, &W, &h, &w) ;
	if (!(H % h) && !(W % w)) {
		printf("No\n") ;
		return 0 ;
	}
	printf("Yes\n") ;
	if (H % h) {
		rep(i, 1, H) {
			rep(j, 1, W) if (i % h) printf("%d ", S) ; 
				else printf("%d ", - S * (h - 1) - 1) ;
			printf("\n") ;
		}
	} else {
		rep(i, 1, H) {
			rep(j, 1, W) if (j % w) printf("%d ", S) ; 
				else printf("%d ", - S * (w - 1) - 1) ;
			printf("\n") ;
		}
	}
	return 0 ; 
}

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

int main() {
  int N; cin >> N;
  int maxCount = 0, res = 1;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int j = i;
    while (j % 2 == 0) {
      j /= 2;
      count += 1;
    }
    if (count > maxCount) {
      maxCount = count;
      res = i;
    }
  }
  cout << res << endl;
}

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

int main(){
    int N;
    cin >>N;
    int A[N];
    bool flag=true;

    for (int i=0; i<N; i++){
        cin >> A[i];
        
    }
    for (int i=0; i<N; i++){
        if(A[i]%2==0&&(A[i]%3==0||A[i]%5==0)){
            continue;
        }
        else if(A[i]%2==1){
            continue;
        }
        else{
            cout << "DENIED";
            flag=false;
            break;
        }
    }
    
    if(flag==true){
        cout << "APPROVED";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("AAA") || s.equals("BBB") ) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
prime_list = []
list = (2..55_555).to_a

is_prime = {}

list.each do |i|
  next if is_prime[i] == true

  prime_list << i

  i.step(55_555, i) do |k|
    is_prime[k] = true
  end
end

$N = gets.chomp.to_i

(1..4).each do |i|
  res = []
  count = 0
  prime_list.each do |p|
    break if $N == count
    next unless p % 5 == i
    res << p
    count += i
    next
  end
  next unless count == $N
  puts res.join(' ')
  exit 0
end

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

int main() {
    int n, x, ans = 0;
    cin >> n >> x;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    rep(i, n) {
        if (a[i] <= x) {
            x -= a[i];
            ans++;
            if (i == n-1 && x > 0) ans--;
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n,m,q = map(int,input().split())
abcd = []
for i in range(q):
  abcd.append(tuple(map(int,input().split())))

def check(l):
  res = 0
  for a,b,c,d in abcd:
    a -= 1
    b -= 1
    if l[b]-l[a] == c:
      res += d
  return res

l = itertools.combinations_with_replacement(range(1,m+1),n)
ans = 0
for li in l:
  ans = max(check(li),ans)
print(ans)


Measured memory_bytes: 67952
import math

def getDivCount( a, b, x ):
    count=0
    if a!=0 :
        count+=b//x-(a-1)//x
    else:
        count+=b//x+1
    return count

a,b,c,d = map(int, input().split())

count = b-a+1
count -= getDivCount(a,b,c)
count -= getDivCount(a,b,d)
count += getDivCount(a,b,c*d//math.gcd(c,d))
print(count)


Measured memory_bytes: 9136
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun func (x)
  (if (>= x 2)
	(1+ (func (ash x -1)))
	0))
(let ((n (read)))
  (princ (expt 2(func n))))


Measured memory_bytes: 7604
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1) / 2 for p in P]

s = sum(E[:K])
ans = s
for i, e in enumerate(E[K:]):
    s = s - E[i] + e
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 25060
def main():
    S=input()
    K=int(input())
    l=len(S)
    chars=[]
    bchar=S[0]
    echar=S[l-1]
    curChar=bchar
    seq=1
    idx=0
    for i in range(1,l-1):
        if S[i]==curChar:
            seq+=1
        else:
            chars.append((idx,seq))
            curChar=S[i]
            idx+=1
            seq=1

    if S[l-1]==curChar:
        chars.append((idx,seq+1))
    else:
        chars.append((idx,seq))
        chars.append((idx+1,1))
    ans=0;
    types=len(chars)
    if types==1:
        ans=(l*K)//2
    elif bchar!=echar:
        for c in chars:
            ans += c[1]//2
        ans*=K
    else:
        tmp=0
        ansb=chars[0][1]//2
        anse=chars[types-1][1]//2
        ansbe=(chars[0][1]+chars[types-1][1])//2
        for i in range(1,types-1):
            tmp+=chars[i][1]//2
        ans=ansb+(tmp*K)+(ansbe*(K-1))+anse
    print(ans)
main()


Measured memory_bytes: 3064
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 3828
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, B, M = map(int, input().split())
    AA = tuple(map(int, input().split()))
    BB = tuple(map(int, input().split()))
    XYC = [tuple(map(int, input().split())) for _ in [0] * M]

    case0 = min(AA) + min(BB)
    case1 = case0
    for x, y, c in XYC:
        case1 = min(case1, AA[x-1] + BB[y-1] - c)
    print(case1)


main()


Measured memory_bytes: 29752
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	Input := ReadLine()
	for _, v := range strings.Split(Input, "") {
		if v == "7" {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 1792
import sys
# input = sys.stdin.readline

N, K = map(int, input().split())

maxcnt = (N - 1) * (N - 2) // 2
if K > maxcnt:
    print(-1)
else:
    print((N - 1) + maxcnt - K)
    for i in range(1, N):
        print(1, i + 1)
    # 
    q = []
    for i in range(1, N - 1):
        for j in range(i + 1, N):
            q.append((i + 1, j + 1))
    while maxcnt > K:
        i, j = q.pop()
        print(i, j)
        maxcnt -= 1

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define REP0(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
const ll INF = 9.22e18;
ll n;
int main() {
    IOS;
    cin >> n;
    REP1(i, 3500) {
        REP1(j, 3500) {
            if (4*i*j%n == 0 && (4*i*j/n - i - j) != 0 && i*j % (4*i*j/n - i - j) == 0 && ((i*j) / (4*i*j/n - i - j)) > 0) {
                cout << i << ' ' << j << ' ' << ((i*j) / (4*i*j/n - i - j)) << endl;
                return 0;
            }
        }
    }
}


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

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

  string ans = "";
  if (a.size() < b.size()) {
    ans = "LESS";
  } else if (a.size() > b.size()) {
    ans = "GREATER";
  } else {
    ans = "EQUAL";
    for (int i=0; i<(int)a.size(); i++) {
      if (a[i] > b[i]) {
        ans = "GREATER";
        break;
      } else if (a[i] < b[i]) {
        ans = "LESS";
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(4100000)


def main():
    K = int(input().rstrip())
    S = input().rstrip()
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll n;
  cin>>n;
  ll ga,sa,ba;
  cin>>ga>>sa>>ba;
  ll gb,sb,bb;
  cin>>gb>>sb>>bb;
  ll nn=n;
  bool fg=false;
  bool fs=false;
  bool fb=false;
  REP(i,n+1)REP(j,n+1) {
    if(i*ga+j*sa > n) break;
    ll d = n-i*ga-j*sa;
    ll k = 0;
    if (bb>ba) {
      k=d/ba;
      d%=ba;
    }
    ll sum = i*gb+j*sb+k*bb+d;
    if (sum > nn) {
      fg = i>0;
      fs = j>0;
      fb = k>0;
      nn = sum;
    }
  }
  ll mx = n;
  if (!fg) {
    if (nn==n) {
      REP(i,n+1)REP(j,n+1) {
        if(i*gb+j*sb > n) break;
        ll d = n-i*gb-j*sb;
        ll k = 0;
        if (ba>bb) {
          k=d/bb;
          d%=bb;
        }
        ll sum = i*ga+j*sa+k*ba+d;
        if (sum > mx) {
          mx = sum;
        }
      }
    } else {
      REP(i,nn+1) {
        if (i*gb > nn) break;
        ll d = nn - i*gb;
        if (!fs) {
          ll j = 0;
          if (sa>sb) {
            j=d/sb;
            d%=sb;
          }
          mx=max(mx,i*ga+j*sa+d);
        } else {
          ll k = 0;
          if (ba>bb) {
            k=d/bb;
            d%=bb;
          }
          mx=max(mx,i*ga+k*ba+d);
        }
      }
    }
  } else {
    REP(j,nn+1) {
      if(j*sb > nn) break;
      ll d = nn - j*sb;
      ll k = 0;
      if (ba>bb) {
        k=d/bb;
        d%=bb;
      }
      mx=max(mx,j*sa+k*ba+d);
    }
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int flag=0;
    for(int i=0;i<n;i++){
    	if(s[i]!=t[i]){
    		flag=1;
    		break;
    	}
    }
    if(flag==0){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
def main():
    k = int(input())
    s = input()
    s2 = ""
    if len(s) <= k:
        print(s)
    else:
        for i in range(k):
            s2 += s[i]
        s2 +=("...")
        print(s2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9176
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
X, Y = map(int, input().split())
#A = int(input())
#B = int(input())

if X%Y == 0 :
  print (-1)
else :
  i = 2
  while (True) :
    if X*i % Y != 0 :
      print (X*i)
      break
    i += 1


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

bool cmp(pair<string, pair<ll, ll> > p1, pair<string, pair<ll, ll> > p2) 
{
    if (p1.first != p2.first) 
        return (p1.first < p2.first);
    return (p1.second.first > p2.second.first);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    vector<pair<string,pair<ll,ll>>>arr;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        string str;
        cin >> str;
        cin >> x;
        arr.push_back({str, {x, i + 1}});
    }
    sort(arr.begin(),arr.end(), cmp);
    for(int i=0;i<n;i++)
    {
        cout<<arr[i].second.second<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define VV(T) vector<vector< T > >
#define brep(i, n) BREP(i, 0, m);
#define BREP(i, x, n) for(int i = x; i < (1<<n); i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define PB push_back
#define MOD 1000000009LL

int a[105];

int main(){
    int N, s; cin >> N;
    rep(i, N) cin >> a[i];
    REP(i, 1, N) if(a[i] == a[i - 1]) s++, i++;
    cout << s << endl;
}

Measured memory_bytes: 764
def main():
    n, a, b = map(int, input().split())
    ans = 0
    sum = 0
    for i in range(1, n+1):
        sum = judgment(i)
        if sum >= a and b >= sum:
            ans += i
    print(ans)

def judgment(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum

main()


Measured memory_bytes: 3064
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans,a;
  set<ll> st;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    st.insert(a);
  }
  ans = st.size();
  if(ans%2==0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 4992
N = int(input())
B = list(map(int, input().split()))
A = [0] * N
for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])
A[0] = B[0]
A[N - 1] = B[N - 2]
print(sum(A))


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

int main(){
	char str[80]={'\0'};
	int i, j,flag=0;
	
	while((fgets(str,sizeof(str),stdin))!=NULL){
	
	while(1){
	for(i=0;i<strlen(str);i++){
		if(str[i]==122)str[i]-=26;
		if(str[i]!=' ' && str[i]!='\n' && str[i]!='.')str[i]++;
	}
		if(strstr(str,"the")!=NULL || strstr(str,"that")!=NULL || strstr(str,"this")!=NULL)break;
	}
	printf("%s",str);
		
		for(i=0;i<strlen(str);i++)str[i]='\0';
	}
return 0;
}

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

void solve()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b)
        swap(a, b);
    cout << max(b - (a + w), 0) << endl;
}

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

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <algorithm>
#define lson root<<1
#define rson root<<1|1
using namespace std;

int n;
int a[200010];
int sum[200010];
int b[200010];

struct node
{
    int l,r,sum;
}tr[1600080];

int push_up(int root)
{
    tr[root].sum=tr[lson].sum+tr[rson].sum;
}

int build(int root,int l,int r)
{
    if(l==r)
    {
        tr[root].sum=0;
        tr[root].l=l;
        tr[root].r=r;
        return 0;
    }
    tr[root].l=l;
    tr[root].r=r;
    int mid=(l+r)>>1;
    build(lson,l,mid);
    build(rson,mid+1,r);
    push_up(root);
}

int update(int root,int pos)
{
    if(pos==tr[root].l&&pos==tr[root].r)
    {
        tr[root].sum++;
        return 0;
    }
    int mid=(tr[root].l+tr[root].r)>>1;
    if(pos<=mid)
    {
        update(lson,pos);
    }
    else
    {
        update(rson,pos);
    }
    push_up(root);
}

int query(int root,int l,int r){
    if(l>r) return 0;
    if(l<=tr[root].l&&tr[root].r<=r) return tr[root].sum;
    int mid=(tr[root].l+tr[root].r)>>1;
    if(r<=mid){
        return query(lson,l,r);
    }else{
        if(l>mid){
            return query(rson,l,r);
        }
        else{
            return query(lson,l,mid)+query(rson,mid+1,r);
        }
    }
}

int check(int x){
    long long ans=0;
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=n;i++){
        sum[i]=sum[i-1]+((a[i]<=x)?1:-1);
    }
   for(int i=0;i<=n;i++){
        sum[i]+=n+1;
    }
    build(1,1,200010);
    for(int i=0;i<=n;i++){
        ans+=query(1,1,sum[i]-1);
        update(1,sum[i]);
    }
    return ans>=1ll*n*(n+1)/4+1;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    int l=1,r=n,ans=0,mid=0;
    while(l<=r){
        mid=(l+r)/2;
        if(check(b[mid])){
            ans=b[mid];
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    printf("%d\n",ans);
}


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

int main() {

  vector<int> list;

  bool sosu[50000] = {false};
  for ( long long int i = 2; i < 50000; i++ ) {
    if ( sosu[i] == false ) {
      list.push_back(i);
      for ( long long int j = i*2; j < 50000; j+=i ) {
	sosu[j] = true;
      }
    }
  }

  int n;

  while(true) {

    cin >> n;
    if ( n == 0 ) break;

    int cnt = 0;

    for ( int i = list.size()-1; i >= 0; i-- ) {

      int k = n - list[i];
      if ( k < 2 ) continue;

      int x = 0;
      int y = i;
      while(true) {

	int z = ( x+y )/2;

	if ( k == list[z] ) {
	  cnt++;
	  break;
	}else if ( k < list[z] ) {
	  if ( y == z ) {
	    if ( x == y ) break;
	    y = x;
	  }else {
	    y = z;
	  }
	}else {
	  if ( x == z ) {
	    if ( x == y ) break;
	    x = y;
	  }else {
	    x = z;
	  }
	}

      }

    }

    cout << cnt << endl;

  }

  return 0;

}

Measured memory_bytes: 1324
S = input().rstrip()

alphabet = list('abcdefghijklmnopqrstuvwxyz')

# elongation
if len(S)<26:
    A = [a for a in alphabet if not a in S]
    print(S + A[0])
    exit()

#
for i in range(24, -1, -1):
    A = [a for a in alphabet if not a in S[:(i+1)]]
    for a in A:
        if S[i]<a:
            print(S[:i] + a)
            exit()

#
print(-1)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        String s = sc.next();
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '+') {
                ans += 1;
            } else {
                ans -= 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int N, A;
	cin >> N >> A;
	cout << N * N - A << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#define X first
#define Y second
using namespace std;
typedef pair<int,pair<int,int> > PP;
int n;
int p[100010];
pair<int,int> x[100010],y[100010];
priority_queue<PP,vector<PP>,greater<PP> >Q;

bool Same(int a,int b){
	int k=a;
	while(true){if(p[k]==k)break;k=p[k];}
	while(true){if(p[a]==a)break;a=p[a],p[a]=k;}
	int l=b;
	while(true){if(p[l]==l)break;l=p[l];}
	while(true){if(p[b]==b)break;b=p[b],p[b]=l;}
	
	if(k==l)return true;
	return false;
}

void Unite(int a,int b){
	int k=a;
	while(true){if(p[k]==k)break;k=p[k];}
	while(true){if(p[a]==a)break;a=p[a],p[a]=k;}
	int l=b;
	while(true){if(p[l]==l)break;l=p[l];}
	while(true){if(p[b]==b)break;b=p[b],p[b]=l;}
	
	p[k]=p[l];
	return;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;a--,b--;
		x[i]=make_pair(a,i);
		y[i]=make_pair(b,i);
	}
	sort(x,x+n);sort(y,y+n);
	for(int i=0;i<n-1;i++){
		Q.push(make_pair(x[i+1].X-x[i].X,make_pair(x[i].Y,x[i+1].Y)));
		Q.push(make_pair(y[i+1].X-y[i].X,make_pair(y[i].Y,y[i+1].Y)));
	}
	for(int i=0;i<n;i++)p[i]=i;
	int ans=0;
	while(!Q.empty()){
		if(!Same(Q.top().Y.X,Q.top().Y.Y)){
			ans+=Q.top().X;
			Unite(Q.top().Y.X,Q.top().Y.Y);
		}
		Q.pop();
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

vector<pii> es[100100];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        es[a].emplace_back(b, i);
        es[b].emplace_back(a, i);
    }

    ll cmax = 0;
    rep(i, n) {
        cmax = max(cmax, (ll)es[i].size());
    }

    vector<bool> used(n, false);
    vi parent(n, -1);
    vi ans(n - 1, -1);
    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        // cout << u << endl;
        used[u] = true;
        int parentc = parent[u];
        int c = 0;
        for (auto p: es[u]) {
            int to = p.first;
            int idx = p.second;
            // cout << u << " " << to << endl;
            if (used[to]) continue;

            if (c == parentc) c++;
            ans[idx] = c;
            parent[to] = c++;
            que.push(to);
        }
    }

    cout << cmax << endl;
    rep(i, n - 1) {
        cout << ans[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 7552
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        // initialize
        let mut v: Vec<usize> = vec![];
        for i in 0..n + 1 {
            v.push(i)
        }
        let mut s: Vec<usize> = vec![1; n + 1];

        UnionFind { parent: v, size: s }
    }

    fn root(&self, x: usize) -> usize {
        if self.parent[x] == x {
            return x;
        } else {
            return self.root(self.parent[x]);
        }
    }

    fn size(&self, a: usize) -> usize {
        let ra = self.root(a);
        self.size[ra]
    }

    fn unite(&mut self, a: usize, b: usize) {
        let mut ra = self.root(a);
        let mut rb = self.root(b);
        if ra == rb {
            return;
        }
        if self.size[ra] < self.size[rb] {
            std::mem::swap(&mut ra, &mut rb)
        };
        self.size[ra] += self.size[rb];
        self.parent[rb] = ra;
    }

    fn same(&self, a: usize, b: usize) -> bool {
        let ra = self.root(a);
        let rb = self.root(b);
        self.parent[a] == self.parent[b]
    }
}

fn main() {
    let mut uf = UnionFind::new(12);
    uf.unite(1, 3);
    uf.unite(1, 5);
    uf.unite(1, 7);
    uf.unite(1, 8);
    uf.unite(1, 10);
    uf.unite(1, 12);

    uf.unite(4, 6);
    uf.unite(4, 9);
    uf.unite(4, 11);
    let x: usize = read();
    let y: usize = read();
    if uf.same(x, y) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
rules = [list(map(int, input().split())) for _ in range(m)]

def get_ans():
    if m == 0:
        return(10**(n-1)*int(bool(1<n)))
        
    for i in range(10**(n-1)*int(bool(1<n)), 10**n):
        for j, rule in enumerate(rules):
            
            if int(str(i)[rule[0]-1]) == rule[1]:
                if j == len(rules)-1:
                    return(i)
                else:
                    continue
            else:
                break
                
    return(-1)


print(get_ans())

Measured memory_bytes: 9208
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;



 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	
	int[][] c = new int[3][3];
	
//	int ans = -1;
	boolean ans = true;
	
	
	
	
	public void input() throws IOException {
		for (int i=0; i<3; i++) {
			for (int j=0; j<3; j++) {
				c[i][j] = in.nextInt();
			}
		}
	}
	
	public void solve() throws IOException {
		for (int i=0; i<2; i++) {
			int dj0 = c[i+1][0]-c[i][0];
			int dj1 = c[i+1][1]-c[i][1];
			int dj2 = c[i+1][2]-c[i][2];
			if (dj0 != dj1 || dj1 != dj2) {
				ans = false;
				return;
			}
		}
		for (int j=0; j<2; j++) {
			int di0 = c[0][j+1]-c[0][j];
			int di1 = c[1][j+1]-c[1][j];
			int di2 = c[2][j+1]-c[2][j];
			if (di0 != di1 || di1 != di2) {
				ans = false;
				return;
			}
		}
	}

	
	public void output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
	}
}

class Point {
	int y;
	int x;
	public Point(int y, int x) {
		this.x=x;
		this.y=y;
	}
	
	public Point move(Point d) {
		Point p = new Point(y, x);
		p.x += d.x;
		p.y += d.y;
		return p;
	}
	
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LLONG_MIN
#define LLMX LLONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000010
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
	ll n, m , k, res = 0;
	cin>>n;
	vl count(MAX, 1);
	for(ll i = 2; i < MAX; i++)
	{
	    for(ll j = i; j < MAX; j += i)
	        count[j]++;
	}
	for(ll i = 1; i < n; i++)
	    res += count[i];
	cout<<res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    map<int, int> cnt;
    for(int i=0;i<n;i++){
        cin >> A[i];
        cnt[A[i]] += 1;
    }

    if (cnt[0] == n){
        cout << "Yes" << endl;
        return 0;
    }
    if (n%3 != 0){
        cout << "No" << endl;
        return 0;
    }
    vector<int> all;
    for(auto& p: cnt){
        for(int i=0;i<p.second/(n/3);i++){
            all.push_back(p.first);
        }
    }
    if(all.size() == 3 && (all[0]^all[1]^all[2]) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4224
s = list(input())

memo = 0
a = [-1 for i in range(10)]

for i in range(len(s)):
    if s[i] == '0':
        a[memo] = 0
        memo += 1
    elif s[i] == '1':
        a[memo] = 1
        memo += 1
    elif s[i] == 'B' and memo >0:
        memo -= 1
    
for i in range(memo):
    if a[i] != -1:
        print(a[i],end ="")



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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vector<pair<int,int>> ab(n);
    rep(i,n) cin >> ab[i].second >> ab[i].first; //first:締切　second:作業時間

    bool can = true;
    int time = 0;
    sort(all(ab));
    rep(i,n) {
        time += ab[i].second;
        if(ab[i].first < time) can = false;
    }
    cout << (can ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back
#define endl '\n'
#define x first
#define y second

int main(){
	int n,m,s,c;
	int a[4]={-1,-1,-1,-1};
	cin>>n>>m;
	bool f=0;
	while(m--){
		cin>>s>>c;
		s--;
		if(a[s]!=-1){
			if(a[s]!=c)f=1;
		}
		a[s]=c;
	}
	if(f){
		cout<<-1<<endl;
		return 0;
	}
	if(n!=1 &&a[0]==0){
		cout<<-1<<endl;
		return 0;
	}
	if(a[0]==-1){
		if(n==1){
			a[0]=0;
		}else{
			a[0]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==-1){
			a[i]=0;
		}
		cout<<a[i];
	}
	cout<<endl;
}

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

int main(void) {
  int K;
  int A, B;

  int check = 1;

  scanf("%d",&K);
  scanf("%d%d", &A, &B);


  for (int i = A; i<=B; i++){
    if (i%K==0){
      check = 0;
      break;
    }
  }


  if (check == 0) printf("OK\n");
  else printf("NG\n");

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int IINF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"

struct UnionFind {
    vector<int> data;

    explicit UnionFind(int data_size) {
        data.assign(static_cast<unsigned long>(data_size), -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int a) {
        if (data[a] < 0) return (a);
        else return (data[a] = find(data[a]));
    }

    int size(int a) {
        return (-data[find(a)]);
    }
};

// AtCoder Beginner Contest 120
int N, M, A[100000], B[100000];

signed main() {
    cin >> N >> M;
    UnionFind data(N);

    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
    }

    int ret = 0;
    vector<int> ans(M);

    for (int i = M - 1; i >= 0; --i) {
        ans[i] = N * (N - 1) / 2 - ret;
        if (data.find(A[i]) != data.find(B[i])) {
            ret += data.size(A[i]) * data.size(B[i]);
            data.unite(A[i], B[i]);
        }
    }
    for (auto &i: ans) cout << i << endl;
}

Measured memory_bytes: 4480
/**
 *    author:  math2do
 *    created: 27.04.2020 22:10:20 IST
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int a, b, c, d, x = 0, y = 0, r = 0;
	int w = 0;//横
	int h = 0;//縦
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	a = x + r;
	b = x - r;
	c = y + r;
	d = y - r;
	if(0 <= b && a <= w){
		if(0 <= d && c <= h){
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b,c,d; cin >> a >> b >> c >> d;
	if (a+b < c+d)
	{
		cout << "Right" << endl;
	}else if(a+b == c+d){
		cout << "Balanced" << endl;
	}else{
		cout << "Left" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a,b,c,ans;
int main(){
	a=read(),b=read(),c=read(),n=read();
	for(int i=0;i*a<=n;++i){
		for(int j=0;i*a+j*b<=n;++j){
			if((n-i*a-j*b)%c==0)++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}




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

vector<double> dp(auto A, auto B, auto L) {
  set<int> S;
  for(auto i=1; i*A<=L; ++i) S.emplace(i*A);
  S.emplace(B);
  for(auto i=1; i*B<=L; ++i) {
    auto dup=S;
    for(auto c: dup) if(c+i*B<=L) S.emplace(c+i*B);
  }
  return vector<double>(begin(S), end(S));
}

int main() {
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  double g=100*A, s=0, c=0;
  auto water = dp(100*A,100*B,F);
  auto sugar = dp(C,D,F);
  sugar.emplace_back(9999);
  auto i=0;
  for(auto w: water) {
    while(i+1<sugar.size() && sugar[i+1]<=E*w/100.0 && sugar[i+1]+w<=F) ++i;
    if(F < w+sugar[i]) continue;
    if(E*w/100 < sugar[i]) continue;
    if(100*sugar[i]/(w+sugar[i]) < c) continue;
    g = w+sugar[i];
    s = sugar[i];
    c = 100*s/g;
  }
  cout<<g<<" "<<s<<endl;
}


Measured memory_bytes: 512