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

using namespace std;
vector < pair < ll , ll > > v[60];
ll Edges[60],M,dp[60][(1 << 20) + 5],n;
set < ll > st;

void DFS(ll x , ll p , ll y , ll j , ll idx){

    if(x == y){
        for(auto it : st)  Edges[it]|=(1 << j);
        return;
    }
    for(auto it : v[x]){
        if(it.first != p) {
            st.insert(it.second);
            DFS(it.first , x , y , j , it.second);
        }
    }
    st.erase(idx);
}

ll Rec(int i , ll Mask){

    if(i == n)  return (Mask + 1 == (1 << M));

    if(dp[i][Mask] != -1)  return dp[i][Mask];

    ll Res = 0;
    Res = Rec(i + 1 , Mask|Edges[i]) + Rec(i + 1,Mask);
    return dp[i][Mask] = Res;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin >> n;
    for(ll i = 1;i<n;i++){
        ll x,y;  cin >> x >> y;
        v[x].push_back({y , i});
        v[y].push_back({x , i});
    }
    cin >> M;
    for(ll i = 0;i<M;i++){
        ll x,y;  cin >> x >> y;
        DFS(x , -1 , y , i , -1);
        st.clear();
    }
    cout << Rec(1 , 0);
    return 0;
}


Measured memory_bytes: 491776
def main():
    a, b, h, m = map(int, input().split())

    from math import sin, cos, pi, sqrt

    ar = pi/2 - 2*pi/12*h - 2*pi/60/12*m
    br = pi/2 - 2*pi/60*m

    ax, ay = a * cos(ar), a * sin(ar)
    bx, by = b * cos(br), b * sin(br)

    c = sqrt((ax-bx)**2+(ay-by)**2)

    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62696
n = int(input())
s = input()
ans = s.count("R")*s.count("G")*s.count("B")
for i in range(1,n//2+10):
  j = 0
  while j+2*i <= n-1:
    if s[j] != s[j+i] and s[j] != s[j+2*i] and s[j+i] != s[j+2*i]:
      ans -= 1
    j += 1
print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    string s,t;
    cin>>s>>t;
    
    vector<int> S(s.length());
    vector<int> T(t.length());
    
    REP(i,s.length()){
        S[i-1]=s[i-1];
        //cout<<S[i]<<" ";
    }
    REP(i,t.length()){
        T[i-1]=t[i-1];
        //cout<<T[i]<<" ";
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(),[](auto& a, auto& b) {return a > b;});
    
    bool f=true;
    REP(i,min(s.length(),t.length())){
        //sl(S[i-1],T[i-1]);
        if(S[i-1]<T[i-1]){
            cout<<"Yes";
            return 0;
        }else if(S[i-1]>T[i-1])f=false;
        //cout<<T[i]<<" ";
    }
    if(f&&s.length()<t.length()){
            cout<<"Yes";
            return 0;
    }
    cout<<"No";
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, n) for(int i = 0; i <= n; i++)
#define MREP(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
	int input;
	int tmp = 1, n = 9;
	bool fact[10];
	int trueCount = 0;
	
	PREP(i, n){
		tmp *= (!i) ? 1 : 2;
		fact[i] = false;
	}

	while(cin >> input){
		MREP(i, n){
			if(tmp <= input){
				input -= tmp;
				fact[i] = true;
				trueCount++;
			}
			if(input == 0) break;
			tmp /= 2;
		}
		tmp = 1;
		PREP(i, n){
			tmp *= (!i) ? 1 : 2;
			if(fact[i] == true){
				fact[i] = false;
				trueCount--;
				cout << tmp;
				if(trueCount) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1>> x2 >> y2;
  cout << x2-y2+y1<< " " << y2+x2-x1 << " " << x1-y2+y1<< " " << y1+x2-x1 << endl;
}


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

int main()
{
    int n;
    int max = 99;
    int sum = 0;
    
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        int p;
        std::cin >> p;
        sum += p;
        max = std::max(max, p);
    }

    sum -= max / 2;

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    ps = [int(i) for i in input().split()]
    sps = [i for i, j in zip(ps, sorted(ps)) if i != j]
    print("YES" if len(sps) <= 2 else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
R, G, B, N = map(int, input().split())

score = 0
for i in range(N // R + 1):
    for j in range((N-i * R) // G + 1):
        if N - i * R - j * G >= 0 and (N - i * R - j * G) % B == 0:
            score += 1

print(score)

Measured memory_bytes: 40560
s = input()
if (s[0]=="R" and s[1] == "S" and s[2]=="R") or (s[0]=="S" and s[1] == "R" and s[2]=="S") or (s[0]=="R" and s[1] == "S" and s[2]=="S") or (s[0]=="S" and s[1] == "S" and s[2]=="R") :
    print(1)
elif s[0]=="R"and s[1]=="R"and s[2]=="R":
    print(3)
elif (s[0]== "S" and s[1]=="R"and s[2]=="R") or (s[0]=="R" and s[1]=="R"and s[2]=="S"):
    print(2)
else:
    print(0)

Measured memory_bytes: 61744
#include<iostream>
using namespace std;
int main(){
string n;
cin>>n;
int sum=0;
for(int i=0;i<n.length();i++)
sum=sum+(n[i]-48);
if(sum%9==0)
    cout<<"Yes";
else
    cout<<"No";
//cout<<sum;


return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	int D, N;

	cin >> D >> N;

	if (!(N == 100)){

		if (D == 0){
			std::cout << N << std::endl;
		}
		else if (D == 1){
			std::cout << N * 100 << std::endl;
		}
		else if (D == 2){
			std::cout << N * 10000 << std::endl;
		}

	}
	else{
		if (D == 0){
			std::cout << N + 1 << std::endl;
		}
		else if (D == 1){
			std::cout << N * 100 + 100 << std::endl;
		}
		else if (D == 2){
			std::cout << N * 10000 + 10000 << std::endl;
		}
	}

	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

bool ok_left(int cur, int n, int q, string s, vector<char>& t, vector<char>& d) {
    for(int i = 0; i < q; ++i) {
        if(s[cur-1] == t[i]) {
            if(d[i] == 'L') cur--;
            else cur++;
        }
        if(cur == 0) return true;
        if(cur == n+1) return false;
    }
    return false;
}

int find_left(int n, int q, string s, vector<char>& t, vector<char>& d) {
    int l = 0, r = n+1;
    while(r-l > 1) {
        int mid = (l+r)/2;
        if(ok_left(mid, n, q, s, t, d)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    return l;
}

bool ok_right(int cur, int n, int q, string s, vector<char>& t, vector<char>& d) {
    if(cur == n+1) return true;
    for(int i = 0; i < q; ++i) {
        if(s[cur-1] == t[i]) {
            if(d[i] == 'L') cur--;
            else cur++;
        }
        if(cur == 0) return false;
        if(cur == n+1) return true;
    }
    return false;
}

int find_right(int n, int q, string s, vector<char>& t, vector<char>& d) {
    int l = 0, r = n+1;
    while(r-l > 1) {
        int mid = (l+r)/2;
        if(ok_right(mid, n, q, s, t, d)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return n+1-r;
}

int32_t main() {

    int n, q; cin >> n >> q;
    string s; cin >> s;

    vector<char> t(q), d(q);
    for(int i = 0; i < q; ++i) cin >> t[i] >> d[i];

    int off_left = find_left(n, q, s, t, d);
    int off_right = find_right(n, q, s, t, d);

    int ans = n-off_left-off_right;

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


Measured memory_bytes: 1156
object Main extends App {

  val sc = new java.util.Scanner(System.in) 
  val n, k, q = sc.nextInt()
  val a = Array.fill(q)(sc.nextInt()).groupBy(identity).mapValues(_.size)
   (1 to n).foreach(i => if (k + a.get(i).getOrElse(0) - q > 0) println("Yes") else println("No"))
}

Measured memory_bytes: 74588
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
#define lowbit(x) ((x)&(-x))
#define hh putchar('\n')
#define kg putchar(' ')
using namespace std;
const int maxn=10005,mod=20101009;
int x,yueshu[maxn],num;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
signed main()
{
	x=read();
	for(int a=1;a<=1000;++a)
		for(int b=-1000;b<=1000;++b)
			if(a*a*a*a*a-b*b*b*b*b==x)
			{
				cout<<a<<' '<<b;
				return 0;
			}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
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;
}

int main()
{
    string match = "ATCG";
    string S;
    cin >> S;

    int ans = 0, tmp = 0;
    bool flag;
    rep(i, S.size())
    {
        flag = false;
        rep(j, match.size())
        {
            if (S[i] == match[j])
            {
                tmp++;
                flag = true;
                break;
            }
        }
        if (!flag)
        {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);

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


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

int N, M, X;
int d[110];
	
int main() {
	
	cin>>N>>M>>X;
	for(int i = 0; i < M; i++){
		int t;
		cin>>t;
		d[t] = 1;
	}
	
	int a = 0, b = 0;
	for(int i = 0; i < X; i++){
		a += d[i];
		//cout<<"a: "<<a<<endl;
	}
	for(int i = N; i > X; i--){
		b += d[i];
		//cout<<"b: "<<b<<endl;
	}
	
	cout<<min(a, b)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
X,Y=open(0).read().split()

X=int(X)

Y=int(Y)


for i in range(110000):
    if (2**i) >= 1000000000000000000:
        #print(i)
        break



list1=[2**i*X for i in range(61) if 2**i*X <= Y]

print(len(list1))


Measured memory_bytes: 9072
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      double[] v = new double[n];
      for(int i = 0;i < n;i++){
      	v[i] = (double)sc.nextInt();
      }
      Arrays.sort(v);
      for(int i = 1;i < n;i++){
      	v[i] = (v[i]+v[i-1])/2;
      }
      System.out.println(v[n-1]);
    }
}


Measured memory_bytes: 21972
let max_m = 2000

let to_int_list str =
  Str.split (Str.regexp_string " ") str |> List.map int_of_string

let make_dp a n =
  let dp = Array.make_matrix (n + 1) (max_m + 1) false in
  let rec duduwa i j =
    if j > max_m then doit (i + 1)
    else begin
      if dp.(i - 1).(j) then dp.(i).(j) <- true
      else if j > a.(i - 1) && dp.(i - 1).(j - a.(i - 1)) then dp.(i).(j) <- true;
      duduwa i (j + 1)
    end
  and doit i =
    if i > n then dp
    else (dp.(i).(a.(i - 1)) <- true; duduwa i 1)
  in
  doit 1

let () =
  let n = read_int () in
  let a = Array.of_list (to_int_list (read_line ())) in
  let _ = read_int () in
  let dp = make_dp a n in
  let m = to_int_list (read_line ()) in
  List.iter (fun e -> Printf.printf "%s\n" (if dp.(n).(e) then "yes" else "no")) m

Measured memory_bytes: 2492
#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>;

const double pi = 3.14159265359;

int main(){
    int r;
    cin >> r;
    double ans =  2 * r * pi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    REP(i, 9) {
        int x = i + 1;
        REP(j, 9) {
            int y = j + 1;
            cout << x << "x" << y << "=" << x * y << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct UF{
  std::vector<int> par, dep, sz;
  UF(int n){
    par.resize(n+1), dep.resize(n+1), sz.resize(n+1);
    init(n);
  }
  void init(int nu) {
    for(int iu=0;iu<=nu;iu++){
      par[iu] = iu;
      dep[iu] = 0;
      sz[iu] = 1;
    }
  }
  int find(int xu){
    if(par[xu] == xu) return xu;
    return par[xu] = find(par[xu]);
  }
  void unite(int xu, int yu){
    xu=find(xu);
    yu=find(yu);
    if(xu == yu) return;
    if(dep[xu] < dep[yu]){
      sz[yu] += sz[xu];
      par[xu] = yu;
    }else{
      par[yu] = xu;
      sz[xu] += sz[yu];
      if(dep[xu] == dep[yu]) dep[xu]++;
    }
  }
  bool same(int xu, int yu){
    return find(xu) == find(yu);
  }
};
int main(int argc, char const *argv[]) {
  ll a, b, c, n, q;std::cin >> n >> q;
  UF uf(n+1);
  re(i, q){
    scanf("%lld %lld %lld", &a, &b, &c);
    if(a==0) uf.unite(b, c);
    else std::cout << (uf.same(b, c)?1:0) << '\n';
  }
}


Measured memory_bytes: 5512
def main():
  x, y = map(int, input().split())
  if (y-2*x)%2 == 0 and y-2*x >= 0 and (4*x-y)%2 == 0 and 4*x-y >= 0:
    print("Yes")
  else:
    print("No")
if __name__  == "__main__":
  main()

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  for(int i=0; i<50; i++){
    if(A%2 == 1 || B%2 == 1 || C%2 == 1){
      cout << i << endl;
      return 0;
    }
    else{
      int a=(B/2)+(C/2),b=(A/2)+(C/2),c=(B/2)+(A/2);
      A=a;
      b=b;
      C=c;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll cons = 1e10;

int main(){
  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a + 2);
  vector<ll> t(b + 2);
  vector<ll> x(q);
  ll i, j;
  
  s[0] = -2 * cons;
  for(i = 1; i < a + 1; i++){
    cin >> s[i];
  }
  s[a + 1] = 2 * cons;
  
  t[0] = -2 * cons;
  for(i = 1; i < b + 1; i++){
    cin >> t[i];
  }
  t[b + 1] = 2 * cons;
  
  for(i = 0; i < q; i++){
    cin >> x[i];
  }  
  /*cout << "a[0]" << s[0] << "a[1]" << s[1] << "a[2]" << s[2] << "a[3]" << s[3] <<
    "b[0]" << t[0] << "b[1]" << t[1] << "x[1]" << x[1] << endl; */
  
  vector<ll>::iterator s_bound, t_bound;
  ll s_left, s_right, t_left, t_right;
  vector<ll> result(6);
  for(i = 0; i < q; i++){
    
    
    s_bound = upper_bound(s.begin(), s.end(), x[i]);
    t_bound = upper_bound(t.begin(), t.end(), x[i]);
    s_left = *(s_bound - 1);
    s_right = *(s_bound);
    t_left = *(t_bound - 1);
    t_right = *(t_bound);
    //cout << s_left << " " << s_right << " " << t_left << " " << t_right << endl;
    
    /*for(j = 0, s_left = -2 * cons, s_right = s[0]; s[j] < x[i]; j++){
      s_left = s[j];
      s_right = s[j + 1];
    }
    
    for(j = 0, t_left = -2 * cons, t_right = t[0]; t[j] < x[i]; j++){
      t_left = t[j];
      t_right = t[j + 1];
    }
    */
    
    result[0] = x[i] - min(t_left, s_left);
    result[1] = x[i] - s_left + (t_right - s_left);
    result[2] = x[i] - t_left + (s_right - t_left);
    result[3] = s_right - x[i] + (s_right - t_left);
    result[4] = t_right - x[i] + (t_right - s_left);
    result[5] = max(s_right, t_right) - x[i];
    cout << *min_element(result.begin(), result.end()) << endl;
  }

  return 0;
}

Measured memory_bytes: 3712
import sys

N = int(input())

k = 0
S = []
while 1:
    if N % 2 == 0:
        S.append(0)
    else:
        N -= (-1) ** k
        S.append(1)
    N /= 2
    k += 1
    if N == 0:
        break

for i in S[::-1]:
    sys.stdout.write(str(i))
sys.stdout.write('\n')


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		String[] card =
			{
				"S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
				"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
				"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
				"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13",
			};
		
		String[] have_card = new String[52];
		
		scanner.nextLine();
		//Scanner scanner1 = new Scanner(System.in);
		for(int i=0; i<n; i++)
		{
			have_card[i] = scanner.nextLine();
		}
		
		boolean have = false;
		for(int i=0; i<card.length; i++)
		{
			have = false;
			for(int j=0; j<n; j++)
			{
				if(have_card[j].equals(card[i]))
				{
					have = true;
					break;
				}
			}
			if(!have)
			{
				System.out.println(card[i]);
			}
		}
	}
}

Measured memory_bytes: 25980
#解説方針#解法1
#https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
from heapq import heappop, heappush
#標準入力
N = int(input())
MOD = 10 ** 9 + 7
L = [[] for i in range(N + 1)] #dfs用
for i in range(N - 1):
  a, b = map(int, input().split())
  L[a].append(b)
  L[b].append(a)

#木の探索
parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in L[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)
#print(order, parent)

half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)#2 ** N の逆元の集合
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):#iが1から
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]
#print(size)
# 辺iがSに含まれるための必要十分条件による辺の個数の期待値 
# (1 - (1/2) ** i)(1 - (1/2) ** (N - i))を展開して計算
# 根である1の頂点以外は、ある頂点とその親を結ぶ辺を考えた際
# i と N - i個の頂点に別れるので,size[2:]でOK
ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) %
          MOD for i in size[2:])  
#ans = sum((1 - (1/2) ** i- (1/2) ** (N - i) + (1/2) ** N) for i in size[2:])  
#print(ans)
ans += 1  # 木の頂点の個数は辺の個数+1
# -「すべての辺が含まれない、つまり空グラフの場合の誤加算」-N/2
ans -= power_inv[N] + N * power_inv[1]  
#ans -= N * power_inv[1]  
ans %= MOD

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {
    int ret1 = dp[i - 1] + abs(h[i - 1] - h[i]);
    int ret2 = dp[i - 2] + abs(h[i - 2] - h[i]);
    dp[i]    = min(ret1, ret2);
  }
  cout << dp[n - 1] << endl;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){

    double x;
    cin  >> x;
    for(double i=x;i<=1000000;i++){
        if(IsPrime(i)){
            cout << i <<endl;
            break;
        }
    }

}



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

using namespace std;

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]);
        else if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])ret += 2;
        else ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<time.h>
#include<algorithm>
using namespace std;

int main()
{
	vector <int>N(3);
	int M = 0;
	for (int i = 0; i < 3; i++)cin >> N[i];
	sort(N.begin(), N.end());
	cout << N[2] * 10 + N[1] + N[0];
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = b[a[0]-1]
p = a[0]-1
for i in a[1:]:
    index = i-1
    sum += b[index]
    if p != n-1 and index == p+1:
        sum += c[p]
    p = index

print(sum)


Measured memory_bytes: 3064
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

    g = fractions.gcd(A[0], A[1])

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (a - K) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


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

int n, k, temp, a[200005];
long long ans;
deque< pair<int, int> > item;
typedef pair<int, int> P;

bool cmp(P x, P y) {
    return x.first > y.first;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> temp;
        a[temp]++;
    }

    for(int i=1; i<=200000; i++) {
        if(a[i]) item.push_back(make_pair(a[i], i));
    }
    sort(item.begin(), item.end(), cmp);

    while(k--) {
        if(!item.empty()) item.pop_front();
    }
    for(int i=0; i<item.size(); i++)
        ans += item[i].first;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
// B - Multiplication 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n; cin>>n;
	vector<ll> A(n);
	long double count_log = 0.0;
	for(int i=0; i<n; ++i){
		cin>>A[i];
		if(A[i] == 0){ puts("0"); return 0; }
		count_log += log10l(A[i]);
	}
	if(count_log > 18){ puts("-1"); return 0; }
	ll inf = 1e18;
	ll ans = 1;
	for(ll a:A){
		ans *= a;
		if(ans > inf){ ans = -1; break; }
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 4112
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
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
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b=input().split()
a=int(a)

if "." in list(b):
    bi,bf=b.split(".")
    
    ans1=a*int(bi)*100
    
    if len(list(bf))>0:
        cnt=1
        for i in list(bf):
            if cnt==1:
                p=a*int(i)*10
                ans1+=p
                cnt+=1
            elif cnt==2:
                p=a*int(i)
                ans1+=p
    print(ans1//100)
else:
    print(a*int(b))

Measured memory_bytes: 10612
#!/usr/bin/ruby
n,m=gets.split.map &:to_i
v={1=>1}
r=[1]
h=Hash.new{|h,k|h[k]=[]}
m.times{
	a,b=gets.split.map &:to_i
	h[a]<<b
	h[b]<<a
}
f=->x{
	loop{
		break if h[x].none?{|e|
			!v[e]&&(v[e]=1;r<<e;x=e)
		}
	}
}
f[1]
r.reverse!
f[1]
p r.size
puts r*' '

Measured memory_bytes: 23548
K, A, B = map(lambda x : int(x), input().split())

if B - A <= 2:
  print(str(K+1))
elif K <= A-1:
  print(str(K+1))
else:
  num = 1
  K -= A-1
  num += A-1

  num += int(K/2) * (B-A)
  num += (K%2)

  print(str(num))


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int K;
  in >> K;
  vector<int> cost(K, numeric_limits<int>::max());
  cost[1] = 1;
  deque<int> Q;
  Q.push_back(1);
  while (!Q.empty()) {
    int n = Q.front();
    Q.pop_front();
    if (cost[n] < cost[10 * n % K]) {
      cost[10 * n % K] = cost[n];
      Q.push_front(10 * n % K);
    }
    if (cost[n] + 1 < cost[(n + 1) % K]) {
      cost[(n + 1) % K] = cost[n] + 1;
      Q.push_back((n + 1) % K);
    }
  }
  out << cost[0] << '\n';
}

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

#define NUM 2000000

vector<pair<int, int>> v;
int N;

int main(void){
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        int p;
        scanf("%d", &p);
        v.push_back(make_pair(p, i));
    }

    sort(v.begin(), v.end());

    /*
    for(int i = 0; i < N; i++){
        printf("%d %d\n", v[i].first, v[i].second);
    }
    */

    int count_max = 1;
    int cnt = 1;

    for(int i = 1; i < N; i++){
        if(v[i - 1].second < v[i].second){
            cnt += 1;
        }else{
            count_max = max(cnt, count_max);
            cnt = 1;
        }
    }
    count_max = max(cnt, count_max);

    printf("%d\n", N - count_max);

}


Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
using namespace std;
int main() {

	long long a, b;
	cin >> a >> b;

	if ((a - b) % 2 != 0)	cout << "IMPOSSIBLE" << endl;
	else   cout << (max(a, b) - min(a, b)) / 2 + min(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            int max = Math.Max(n[0], Math.Max(n[1], n[2]));
            int min = Math.Min(n[0], Math.Min(n[1], n[2]));

            if (3 * max % 2 == (n[0] + n[1] + n[2]) % 2) ans = (3 * max - n[0] - n[1] - n[2]) / 2;
            else ans = (3 * (max + 1) - n[0] - n[1] - n[2]) / 2;

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2 << " ";
    if (W == 2 * x && H == 2 * y) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)



int main() {
	li x, y;
	cin >> x >> y;
	if (x % y == 0) {
		puts("-1");
		return 0;
	}
	cout << x*(y - 1) << endl;

	return 0;
}


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

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    int s_h, s_w, g_h, g_w;
    cin >> s_h >> s_w >> g_h >> g_w;
    s_h--; s_w--; g_h--; g_w--;
    vector<string> E(h);
    for (auto &e: E)
        cin >> e;

    vector<vector<int>> D(h, vector<int>(w, -1));

    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> Q;
    Q.push({0, s_h, s_w});
    vector<int> dh = {1, -1, 0, 0}, dw = {0, 0, 1, -1};

    while(!Q.empty()){
        auto [cost, ch, cw] = Q.top();
        Q.pop();
        if (D[ch][cw] != -1)
            continue;
        D[ch][cw] = cost;
        if (ch == g_h and cw == g_w)
            break;
        for (int i = 0; i < 4; i++){
            auto nh = ch + dh[i];
            auto nw = cw + dw[i];
            if (nh < 0 or h <= nh or nw < 0 or w <= nw)
                continue;
            if (E[nh][nw] == '#')
                continue;
            Q.push({cost, nh, nw});
        }

        for (int i = -2; i <= 2; i++){
            for (int j = -2; j <= 2; j++){
                auto nh = ch + i;
                auto nw = cw + j;
                if (nh < 0 or h <= nh or nw < 0 or w <= nw)
                    continue;
                if (E[nh][nw] == '#')
                    continue;
                Q.push({cost + 1, nh, nw});
            }
        }
    }

    cout << D[g_h][g_w] << endl;
}

Measured memory_bytes: 12280
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int n,h,w;
  cin >> n >> h >> w;
  cout << (max(0,n-h)+1) * max(1,n-w+1) << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

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

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

struct poe{
  int src,dst;
  string lab;
public:
  poe(int src,int dst,string lab):src(src),dst(dst),lab(lab) {}
  poe():src(0),dst(0),lab("") {}
};

int main(){
  while(true){
    int n,a,s,g;
    cin>>n>>a>>s>>g;
    if(n==0)break;
    assert(n<=40);
    assert(a<=400);
    poe poes[a];
    REP(i,a){
      int x,y;
      string lab;
      cin>>x>>y>>lab;
      // reverse
      poes[i] = poe(y,x,lab);
    }
    // bellman-ford
    string youngest[n];
    REP(i,n) youngest[i] = "~";
    youngest[g] = "";

    bool update = false;
    REP(i,n*10){
      update = false;
      REP(e,a){
        poe poi = poes[e];
        int src = poi.src;
        int dst = poi.dst;
        if(youngest[src][0]=='~')continue;
        string nxt = poi.lab + youngest[src];
        if(youngest[dst] > nxt){
          youngest[dst] = nxt;
          update = true;
          if(i>=n && dst==s){
            update = false;
            youngest[s]="~";
            break;
          }
        }
      }
      if(!update)break;
    }
    if(youngest[s][0]=='~'){
      cout << "NO" << endl;
    }else{
      cout << youngest[s] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;
  bool ok = true;
  for(ll i = 0; i < n; i++){
    ll a;
    cin >> a;

    if(a % 2 == 0){
      if(a % 3 == 0 || a % 5 == 0) continue;
      else ok = false;
    }
  }
  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner



object Main {

  def read(): (Int, Int, IndexedSeq[IndexedSeq[Int]]) = {
    val sc = new Scanner(System.in)
    val n, d = sc.nextInt()
    val x: IndexedSeq[IndexedSeq[Int]] = IndexedSeq.fill(n, d)(sc.nextInt())
    (n, d, x)
  }

  def dist(y: IndexedSeq[Int], z: IndexedSeq[Int]): Double = {
    Math.sqrt((y,z).zipped.map((yi, zi) => Math.pow(yi - zi, 2)).sum)
  }

  def solve(n: Int, x: IndexedSeq[IndexedSeq[Int]]): Int = {
    (for {
      i <- 0 until n - 1
      j <- i + 1 until n
    } yield {
      val y = x(i)
      val z = x(j)
      val d = dist(y, z)
      d % 1 == 0
    }).count(identity)
  }

  def main(args: Array[String]) = {
    val (n, d, x) = read()
    println(solve(n, x))
  }

}

Measured memory_bytes: 27336
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

const string st[3] = {"-1","0","1"} ;


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vector<ll> num ;
  queue<string> Q ;
  
  for(int i=1;i<=9;i++){
    Q.push(to_string(i)) ;
    
    while(!Q.empty()){
      string s = Q.front() ;
      Q.pop() ;
      num.PB(stol(s)) ;
      int ss = SZ(s) ;
      
      if(ss<=10){
        int ends = s[ss-1] - '0' ;
        
        REP(k,3){
          int j = stoi(st[k]) ;
          
          if(ends+j>=0 && ends+j<=9){
            string t = s + to_string(ends+j) ;
            Q.push(t) ;
          }
          
        }
        
      }
      
    }
    
  }
  
  sort(ALL(num)) ;
  
  cout << num[n-1] <<endl;  
  
  
  return 0 ;
}

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

int main(void){

    ll a,b,c;

    cin >> a >> b >> c;

    if(c <= b + 1){
        cout << c + b;
    }else{
        cout << min(c,a+b+1) + b;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [int(i) for i in input().split()]

counter = min(h)
h = list(map(lambda x, y=min(h): x-y, h))
# print(min(h[1:3]))
while sum(h) > 0:
    start = False
    # print(h)
    for i in range(len(h)):
        if not start and h[i] > 0:
            start = True
            start_index = i
            continue
        elif start and h[i] == 0:
            start = False
            water = min(h[start_index:i])
            counter += water
            h = h[:start_index] + \
                list(map(lambda x, y=water: x - y, h[start_index:i])) + h[i:]
    if start:
        water = min(h[start_index:])
        counter += water
        h = h[:start_index] + \
            list(map(lambda x, y=water: x - y, h[start_index:]))
print(counter)


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    string s;
    cin >>s ;
    int a[3] = {};
    for(auto x:s){
        a[x-'a']++;
    }
    sort(a,a+3);
    if(a[2]-a[0] <= 1){
        cout << "YES" << endl;
    }else{
        cout <<"NO" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> G[100010];
int deg[100010];
bool used[100010];
int dp[100010];

int calc(int now){
    if(dp[now] != -1) return dp[now];
    int res = 0;
    rep(i, 0, G[now].size()){
        res = max(res, calc(G[now][i]) + 1);
    }
    return dp[now] = res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[b].push_back(a);
        deg[a]++;
    }
    int ans = 0;
    rep(i, 0, n) dp[i] = -1;
    rep(i, 0, n){
        if(deg[i] == 0){
            ans = max(ans, calc(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12032
#include <iostream>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int sum = 0;
		for ( int i = 0; i < n/4; i++ )
		{
			int score;
			cin >> score;
			sum += score;
		}
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

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


    if (B > A * C) {
        cout << C << endl;
    } else {
        cout << B/ A << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)



ll powmod(ll a, ll p, ll MOD) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

ll combmod(ll n, ll r, ll MOD){
  if(n < r) return 0LL;
  if (n < 0 || r < 0) return 0LL;
  vector<ll> ff(n+1), vff(n+1);
  // 1! ~ n!
  ff[0] = 1;
  for(ll i = 1; i < n + 1; i++) {
    ff[i] = ff[i - 1] * i % MOD;
  }
  // n!^(MOD-2) (= n!^(-1))
  ll inv = powmod(ff[n], MOD - 2, MOD);

  // n!^(-1) ~ 1!^(-1)
  vff[n] = inv;
  for(ll i = n - 1; i >= 0; i--) {
    vff[i] = vff[i + 1] * (i + 1) % MOD;
  }

  // n combination r
  ll comb = (((ff[n] * vff[r]) % MOD) * vff[n - r]) % MOD;

  return comb;
}

int main() {
    const ll MOD = 1e9+7;
    ll X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    } 
    ll k = (X + Y) / 3;

    cout << combmod(k, X - k, MOD) << endl;



    return 0;
}

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

int main() {
  long n,q;
  string s;
  cin >> n >> s >> q;
  vector<set<long>> a(26,set<long>());
  vector<long> ans;
  for(long i=0;i<n;i++) a[s[i]-'a'].insert(i+1);
  for(long i=0;i<q;i++) {
    long q1,q2,q3_2;
    char q3_1;
    cin >> q1 >> q2;
    if(q1==1) {
      cin >> q3_1;
      a[s[q2-1]-'a'].erase(q2);
      s[q2-1]=q3_1;
      a[q3_1-'a'].insert(q2);
    } else {
      cin >> q3_2;
      ans.push_back(0);
      for(long i=0;i<26;i++) {
        auto itr=a[i].lower_bound(q2);
        if(itr!=a[i].end()) if(*itr<=q3_2) ans.back()++;
      }
    }
  }
  for(long i=0;i<ans.size();i++) cout << ans[i] << endl;
}

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

#define ll long long
#define endl "\n"

const int mx = 25;

int h, w;
char grid[mx][mx];
bool visited[mx][mx];
int dist[mx][mx];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

bool valid(int row, int col){
    return (row >= 0 and row < h and col >= 0 and col < w and visited[row][col] == false and grid[row][col] == '.');
}

void bfs(int r, int c){
    queue <pair <int, int> > cells;
    cells.push(make_pair(r, c));
    visited[r][c] = true;
    dist[r][c] = 0;

    while (!cells.empty()){
        auto now = cells.front();
        cells.pop();

        for (int dir = 0; dir < 4; dir++){
            int row = dx[dir] + now.first;
            int col = dy[dir] + now.second;

            if (valid(row, col)){
                dist[row][col] = dist[now.first][now.second] + 1;
                visited[row][col] = true;
                cells.push(make_pair(row, col));
            } 
        }
    }
}

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    cin >> h >> w;
    //pair <int, int> start, end;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> grid[i][j];
        }
    }
    int ans = 0;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (grid[i][j] == '#') continue;
            memset(visited, false, sizeof(visited));
            memset(dist, 0, sizeof(dist));
            bfs(i, j);
            for (int i=0; i<h; i++){
                for (int j=0; j<w; j++){
                    ans = max(ans, dist[i][j]);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;

}


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

const long long MOD = (long long)1e9 + 7;

template <typename T>
T modPow(T base, T e, T mod) {
  if(e==0) return 1;
  if(e==1) return base%mod;
  if(e%(T)2==1) return (base * modPow(base, e-(T)1, mod)) %mod;
  
  T tmp = modPow(base, e/(T)2, mod);
  return (tmp * tmp) % mod;
}

int main(){
  long long N;
  cin >> N;
  
  long long A[N];
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  long long ans = 0;
  for (long long bit = 0; bit < 60; bit++) {
    long long bitCount = 0;
    for (int i = 0; i < (int)N; i++) {
      if((A[i]>>bit) & 1) bitCount++;
    }
    long long tmp = bitCount*(N-bitCount)%MOD;
    tmp *= modPow(2LL,bit,MOD);
    ans += tmp%MOD;
    ans %= MOD;
  }
  
  cout << ans % MOD << endl;

  return 0;
}

Measured memory_bytes: 2560