akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct card
{
  char mark;
  int value;
};

void bubbleSort(vector<card> &c, int n)
{
  for (int i = 0; i < n; ++i)
  {
    for (int j = n - 1; j > i; --j)
    {
      if (c[j].value < c[j - 1].value)
      {
        card tmp = c[j - 1];
        c[j - 1] = c[j];
        c[j] = tmp;
      }
    }
  }
}

void selectionSort(vector<card> &c, int n)
{
  for (int i = 0; i < n; ++i)
  {
    int minj = i;
    for (int j = i; j < n; ++j)
    {
      if (c[j].value < c[minj].value)
        minj = j;
    }
    card tmp = c[minj];
    c[minj] = c[i];
    c[i] = tmp;
  }
}

void print(vector<card> c, int n)
{
  for (int i = 0; i < n; ++i)
    cout << c[i].mark << c[i].value << " \n"[i == n - 1];
}

bool isStable(vector<card> c, vector<card> stable, int n)
{
  for (int i = 0; i < n; ++i)
    if (c[i].mark != stable[i].mark)
      return false;
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<card> c(n);
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    c[i].mark = s[0];
    c[i].value = s[1] - '0';
  }
  vector<card> t = c;

  bubbleSort(c, n);
  selectionSort(t, n);

  print(c, n);
  cout << "Stable" << endl; // バブルソートは安定ソートなので

  print(t, n);

  if (isStable(t, c, n))
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;

  return 0;
}



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


using namespace std;

int main()
{
    vector<int> Result(26,0);

    char a;

    while(cin >> a){
        if(iswalpha(a)){
            int temp = tolower(a) - 'a';
            Result.at(temp) += 1;
        }
    }

    char c = 'a';
    for(auto b: Result){
        cout << c << " : " << b << endl;
        c++;
    }

}

Measured memory_bytes: 3004
<?php
$stdin = trim(fgets(STDIN)); 
$maxTarget = (int)$stdin;
$ans = 0;
for ($target = 1; $target <= $maxTarget; $target++) {
    $mCount = 0;
    if ($target % 2 != 0) {
        for ($m = 1; $m <= $target; $m++) {
            if ($target % $m == 0) {
                $mCount++;
            }
            if ($mCount === 8) {
                $ans++;
                break;
            }
        }
    }
}
printf($ans);

Measured memory_bytes: 4856
import java.util.*;
public class Main{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    if(n%1000==0)
      System.out.print("0");
    else
      System.out.print(1000-(n%1000));
    
  }
}


Measured memory_bytes: 35648
function Main(input){
  var sum = '';
  for(i = 0;i < input.length;i++){
    if(input[i] == '1'){
      sum += '9';
    }
    else if(input[i] == '9'){
      sum += '1';
    }
  }
  console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

  vector<int> m(N);
  rep(i, N) cin >> m[i];

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

  int ans = 0;
  rep(i, N) {
    X -= m[i];
    ans++;
  }

  while (X - m[0] >= 0) {
    X -= m[0];
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if N-R*r-G*g >= 0 and (N-R*r-G*g) % B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 40556
x,n=map(int,input().split())
List=set(list(map(int,input().split())))
if(n==0):
  print(x)
else:
  i=j=x
  ans=x
  while True:
    if(i not in List):
      ans=i
      break
    if(j not in List):
      ans=j
      break
    else:
      i-=1
      j+=1

      
  print(ans)
      


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 4;

pint get(ll n){
    string s = to_string(n);
    pint p {s.front() - '0', s.back() - '0'};
    return p;
}

void solve() {
    ll n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        pint p = get(i);
        if(p.second==0) continue;
        if(p.first == p.second)++ans;

        for(int j = 1; j <= 6; ++j){
            ll base = pow(10, j) * p.second + p.first;
            ll range = pow(10, j-1);
            ll M = (range-1)* 10 + base;
            //cout << i << ' ' << base << endl;
            if(base > n) break;
            if(M <= n) ans += range;
            else{ // base <= n < M
                //cout << i << ' ' << base <<  ' '<<(n-base)/10 << endl;
                ans += (n - base)/10 + 1;
            }
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <list>

int current_time = 0;

class Task {
public:
    Task() {}
    std::string name;
    int time_remaining;
};

#ifdef DEBUG
void show_data(std::list<Task>& data)
{
    for(auto iter = data.begin(); iter != data.end(); iter++) {
        printf("%s : %d\n", iter->name.c_str(), iter->time_remaining);
    }
    puts("");
}
#endif

void show_result(Task& task)
{
    printf("%s %d\n", task.name.c_str(), current_time);
}

void solve(std::list<Task>& data, int time_limit)
{
    Task current_task;
    while(!data.empty()) {
        current_task.name = data.front().name;
        current_task.time_remaining = data.front().time_remaining;
        data.pop_front();

        if(current_task.time_remaining <= time_limit) {
            current_time += current_task.time_remaining;
            show_result(current_task);
        } else {
            current_time += time_limit;
            current_task.time_remaining -= time_limit;
            data.push_back(current_task); // XXX: may disappear
        }
    }
}

int main()
{
    int input_size, time_limit;
    std::cin >> input_size >> time_limit;
    std::list<Task> data(input_size);
    for(auto iter = data.begin(); iter != data.end(); iter++) {
        std::cin >> iter->name >> iter->time_remaining;
    }
#ifdef DEBUG
    show_data(data);
#endif

    solve(data, time_limit);
    return 0;
}

Measured memory_bytes: 7944
// Mon May 11 18:21:13 IST 2020          
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f_                 first 
#define s_                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const double pi = 3.141592653589793238;
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
// const int N = 2e5; 
const int INF = INT_MAX;  
int tests(){
    string s1,s2 ;
    cin >> s1 >> s2 ; 
    s2.pop_back();
    cout << ( s1 == s2 ? "Yes" : "No" ) << '\n';
    return 0; 
}
int32_t main(){
    I__O ;    
    int cases = 1 ;  
    // cin >> cases ; 
    while(cases--){    
        tests(); 
    }
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3552
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

#define diff(x, y) ((x > y) ? x - y : y - x)

int a, b, c, d;

int main(){
  bool f = false;
  cin >> a >> b >> c >> d;
  if (diff(a, c) <= d){
    f = true;
  }
  if (diff(a, b) <= d && diff(b, c) <= d){
    f = true;
  }

  if (f == true) cout << "Yes" << endl;
  if (f == false) cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func allAtoi(num []string) []int {
	conv := make([]int, len(num))
	for i, item := range num {
		conv[i], _ = strconv.Atoi(item)
	}
	return conv
}

func main() {
	nm := allAtoi(strings.Split(nextLine(), " "))
	coins := allAtoi(strings.Split(nextLine(), " "))
	ans := solve(nm[0], nm[1], coins)
	fmt.Println(ans)
}

func solve(n, m int, coins []int) int {
	dp := make([]int, n+1, n+1)
	for j := 0; j < m; j++ {
		coin := coins[j]
		for i := 0; i < n; i++ {
			sum := coin + i
			if sum <= n {
				if dp[i]+1 < dp[sum] || dp[sum] == 0 {
					dp[sum] = dp[i] + 1
				}
			}
		}
	}
	return dp[n]
}



Measured memory_bytes: 1508
#include <iostream>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)


int main() {
    int h,w;
    while(cin>>h>>w && h) {
        rep(i,h) {
            rep(j,w) {
                if(i==0 or i==h-1) {
                    putchar('#');
                    continue;
                }
                if(j==0 or j==w-1)
                    putchar('#');
                else
                    putchar('.');
            }
            puts("");
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL X, K, D, ans;
int main(){
	cin >> X >> K >> D;
	
	LL t = abs(X) / D;
	if (K <= t) {
		if (X < 0) ans = X + D * K;
		else ans = X - D * K;
		cout << abs(ans) << endl;
		return 0;
	}
	if ((K - t) % 2) t++;
	if (X < 0) ans = X + D * t;
	else ans = X - D * t;
	cout << abs(ans) << endl;
  return 0;
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(b + c <= a) {
				System.out.println(0);
		}else if(b + c > a) {
			c =  b + c - a;
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll N;
ll A, B;
ll h[100001];

bool enough(ll T){
    ll cnt = 0;
    for(ll i = 0; i < N; ++i){
        if(h[i] > B * T){
            cnt += (h[i] - B * T) / (A - B);
            if((h[i] - B * T) % (A - B) != 0) cnt++;
        }
    }
    return cnt <= T;
}

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

    cin >> N;
    cin >> A >> B;
    for(ll i = 0; i < N; ++i){
        cin >> h[i];
    }
    
    ll l = 0;
    ll r = 1000000001;
    while(l < r){
        ll mid = (r + l) / 2;
        if(enough(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


int N;
int P[9];
int Q[9];
int cnt = 0;
int ret_p;
int ret_q;
int A[9];

void func(int depth)
{
	if (depth == N)
	{
		bool match_p = true;
		bool match_q = true;
		for (int i = 0; i < N; i++)
		{
			if (P[i] != A[i])
			{
				match_p = false;
			}
			if (Q[i] != A[i])
			{
				match_q = false;
			}
		}

		cnt++;
		if (match_p)
		{
			ret_p = cnt;
		}
		if (match_q)
		{
			ret_q = cnt;
		}

		return;
	}

	for (int i = 1; i <= N; i++)
	{
		bool has = false;
		for (int j = 0; j < depth; j++)
		{
			if (A[j] == i)
			{
				has = true;
				break;
			}
		}
		if (has)
		{
			continue;
		}
		A[depth] = i;
		func(depth + 1);
	}
}

signed main()
{
	cin >> N;
	REP(i, N) cin >> P[i];
	REP(i, N) cin >> Q[i];

	func(0);

	cout << abs(ret_p - ret_q) << endl;
}




Measured memory_bytes: 504
import java.util.HashMap;
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();

                int[] A = new int[N];
                HashMap<Integer, Integer> aHash = new HashMap<Integer, Integer>();
                HashMap<Integer, Integer> aKaburiHash = new HashMap<Integer, Integer>();

                for (int i = 0; i < N; i++) {
                	int temp = scan.nextInt();
                	A[i] = temp;

                	if (!aHash.containsKey(temp)) {
                		aHash.put(temp, 1);
                	} else {
                		aKaburiHash.put(temp, 1);
                	}

                }

                scan.close();

                int count = 0;

                aRoop: for (int a = 0; a < N; a++) {
                	
                	int tempA = A[a];

                	if (aKaburiHash.containsKey(tempA)) {
                		continue aRoop;
                	}
                	
                	aHash.remove(tempA);

	                int rootA = (int)Math.sqrt(tempA);

	                for (int i = 1; i <= rootA; i++) {


	                	if (tempA%i == 0) {

	                		if (aHash.containsKey(i)) {
	                			continue aRoop;
	                		}

	                		if (i != tempA/i && aHash.containsKey(tempA/i)) {
	                			continue aRoop;
	                		}
	                		
	                	}

	                }
	                
	                count++;
	                
	                aHash.put(tempA, 1);

                }

                System.out.println(count);

        }
}

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

int main()
{
    string s; cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
bool B(ll x,int i){return (x>>i)&1;}
int main(){
	int N,X;
	cin>>N>>X;
	V<ll> a(N);
	rep(i,N) cin>>a[i];
	V<ll> s(N+1);
	rep(i,N) s[i+1] = s[i] + a[i];

	V<ll> xs;
	rep(r,N+1) rep(l,r){
		ll x = s[r]-s[l];
		xs.pb(x);
	}
	ll res = 0;
	for(int i=50;i>=0;i--){
		int cnt = 0;
		for(ll x:xs) if(B(x,i)) cnt++;
		if(cnt>=X){
			V<ll> nxs;
			for(ll x:xs) if(B(x,i)) nxs.pb(x);
			xs = nxs;
			res = res*2+1;
		}else{
			res = res*2;
		}
	}
	cout<<res<<endl;
}

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




int main(){

  long long N, r = 0, g = 0, b = 0;
  string S;
  cin >> N >> S;

  for(int i = 0; i < N; i++){
    if(S[i] == 'R') r++;
    else if(S[i] == 'G') g++;
    else if(S[i] == 'B') b++;
  }

  long long sum = 0;
  for(int j = 0; j < N - 2; j++){
    for(int k = 1; k <= (N - j - 1) / 2; k++){
      if(S[j] != S[j + k] && S[j + k] != S[j + k * 2] && S[j + k * 2] != S[j]) sum++;
    }
  }

  long long a = r * g * b - sum;
  cout << a << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
	int n,a,b,c,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a+b*b==c*c){
			printf("YES\n");
			continue;
		}
		if(b*b+c*c==a*a){
			printf("YES\n");
			continue;
		}
		if(c*c+a*a==b*b){
			printf("YES\n");
			continue;
		}
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
const ll mod=1e9+7;
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
} 
int countDivisors(int n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) {             
            if (n / i == i) 
                cnt++;   
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll ans=1;
	for(ll i=2;i<n;i++)
	{
		ans+=countDivisors(i);
	}	
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 3692
import java.util.*;
public class Main {
	static String input = new String();
	static char[] hyou = {'I','V','X','L','C','D','M'};
	static int[] hyou2 = {1,5,10,50,100,500,1000};
	static int search(char a){
		for(int i=0;i<7;i++)if(a==hyou[i])return hyou2[i];
		return 0;
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			input = in.next();
			int result = 0;
			for(int s=0;s<input.length()-1;s++){
				int next=search(input.charAt(s+1));
				int now=search(input.charAt(s));
				if(next>now)result-=now;
				else result+=now;
			}
			result+=search(input.charAt(input.length()-1));
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 17296
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL n;
    LL k;
    vector<LL> a;
    LL tmp_a;
    cin >> n >> k;
    vector<LL> p_cnt(n, 0);
    vector<LL> p_prev(n, 0);
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        tmp_a--;
        a.push_back(tmp_a);
    }
    LL start=0;
    LL next;
    LL tele_cnt=0;
    while(true){
        p_cnt[start]++;
        next=a[start];
        if(p_cnt[start]==2){
            break;
        }
        if(tele_cnt==k){
            break;
        }
        p_prev[start]=tele_cnt;
        tele_cnt++;
        start=next;
    }

    //cout << start+1 << " " << tele_cnt << endl;

    if(tele_cnt==k){
        cout << start+1 << endl;
    }else{
        LL resi=(k-tele_cnt)%(tele_cnt-p_prev[start]);
        //cout << resi << endl;
        for(int i=0; i<resi; i++){
            next=a[start];
            start=next;
        }
        cout << start+1 << endl;
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N,M;
ll i, j,a;
vector<ll> rv[101010];
vector<ll> r4;
int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,M){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        rv[a].push_back(b);
        rv[b].push_back(a);
    }
    a = 1;
    fornum(i,0,N){
        if(rv[i+1].size()%2){
            a = 0;
            break;
        }
        if(rv[i+1].size()==4){
            r4.push_back(i + 1);
        }
        if(rv[i+1].size()>=6){
            a = 2;
        }
    }
    if(a==2||(a==1&&r4.size()>=3)){
        printf("Yes");
    }else if(a==0||r4.size()<2){
        printf("No");
    }else if(r4.size()==2){
        ll a = r4[0];
        ll b = r4[1];
        fornum(i,0,rv[a].size()){
            ll ib = a;
            ll ii = rv[a][i];
            while(ii!=a&&ii!=b){
                fornum(j,0,2){
                    if(rv[ii][j]!=ib)
                        break;
                }
                ib = ii;
                ii = rv[ii][j];
            }
            if(ii==a){
                printf("Yes");
                return 0;
            }
        }
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
    return a*a + b*b;
}
struct pt {
    double x, y;
};

bool cmp(pt a, pt b) {
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

bool cw(pt a, pt b, pt c) {
    return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) < 0;
}

bool ccw(pt a, pt b, pt c) {
    return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) > 0;
}

vector<pt> convex_hull(vector<pt>& a) {

    sort(a.begin(), a.end(), &cmp);
    pt p1 = a[0], p2 = a.back();
    vector<pt> up, down;
    up.push_back(p1);
    down.push_back(p1);
    for (int i = 1; i < (int)a.size(); i++) {
        if (i == a.size() - 1 || cw(p1, a[i], p2)) {
            while (up.size() >= 2 && !cw(up[up.size()-2], up[up.size()-1], a[i]))
                up.pop_back();
            up.push_back(a[i]);
        }
        if (i == a.size() - 1 || ccw(p1, a[i], p2)) {
            while(down.size() >= 2 && !ccw(down[down.size()-2], down[down.size()-1], a[i]))
                down.pop_back();
            down.push_back(a[i]);
        }
    }

    a.clear();
    for (int i = 0; i < (int)up.size(); i++)
        a.push_back(up[i]);
    for (int i = down.size() - 2; i > 0; i--)
        a.push_back(down[i]);
    return a;
}
int main() {
    scanf("%d", &n);
    vector<pt> a;
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf", &x[i], &y[i]);
        a.pb({x[i],y[i]});
    }
    convex_hull(a);
    n=sz(a);
    for (int i = 0; i < n; ++i){
        X += a[i].x; Y += a[i].y;
    }
    X /= n; Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - a[0].x, Y - a[0].y);
        for (int j = 1; j < sz(a); j++) {
            e = dist(X - a[j].x, Y - a[j].y);
            if (d < e) { d = e; f = j; }
        }
        ii old=ii(X,Y);
        X += (a[f].x - X)*P;
        Y += (a[f].y - Y)*P;
        //debugs(X,Y);
        if(abs(X-old.fi)<EPS && abs(Y-old.se)<EPS) {cout<<sqrt(d);return 0;}
        P *= 0.999;
    }
    cout<<fixed<<setprecision(10)<<sqrt(d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
//lln n,m;

int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1);


}






Measured memory_bytes: 3592
use std::io::stdin;

fn main() {
    let n = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace().next().unwrap().parse::<i64>().unwrap()
    };
    let a : Vec<i64> = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace().filter_map(|x| x.parse().ok()).collect()
    };

    let all_xor = a.iter().fold(0 as i64, |l,r| return l ^ *r);
    for x in a {
        println!("{}", all_xor ^ x);
    }
}


Measured memory_bytes: 5808
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<long>> data(M, vector<long>(3));
  vector<long> count(N);
  vector<pair<long, long>> sub(M);
  for(int i = 0; i < M; i++){
    cin >> sub.at(i).first >> sub.at(i).second;
    data.at(i).at(0) = sub.at(i).second;
    data.at(i).at(1) = sub.at(i).first;
    data.at(i).at(2) = i;
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < M; i++){
    count.at(data.at(i).at(1) - 1)++;
    sub.at(data.at(i).at(2)).second = count.at(data.at(i).at(1) - 1);
  }
  for(int i = 0; i < M; i++){
    cout << setfill('0') << right << setw(6) << sub.at(i).first;
    cout << setfill('0') << right << setw(6) << sub.at(i).second << endl;
  }
  return 0;
}

Measured memory_bytes: 9344
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(100*(10-n) + r)


Measured memory_bytes: 2940
s = input()

indexA = 0
indexZ = len(s)

for i in range(indexZ):
	if s[i] == "A":
		indexA = i
		break

s = s[::-1]

for i in range(len(s)):
	if s[i] == "Z":
		indexZ = len(s)-i
		break

print(indexZ - indexA)

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100];
vector<bool> visited(1000, false);
vector<int> tin(10000), low(10000);
int t = 0;
int bridge = 0;
void dfs(int source, int parent = -1)
{
    low[source] = tin[source] = ++t;
    visited[source]=  true;
    for(auto child:adj[source])
    {
        if(child == parent)
        continue;
        if(visited[child])
        {
            low[source] = min(low[source], tin[child]);
        }
        else
        {
            dfs(child, source);
            low[source] = min(low[source], low[child]);
            if(tin[source] < low[child])
            {
                bridge++;
            }
        }
    }
}
int main()
{
    
    ios_base::sync_with_stdio(false);
    
    int n;cin >> n;
    int m;
    cin >> m;
    for(int i= 0;i<m;++i)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 1;i<=n;i++)
    {
        if(!visited[i])
        dfs(i);
    }
    cout << bridge;
    return 0;
    
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, k, x, y;
    int ans = 0;
    cin >> n >> k >> x >> y;
    for (int i = 1; i <= n; i++) {
        if (i <= k) {
            ans += x;
        }
        else {
            ans += y;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n,k,r,s,p; string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans=0;
    rep(i,k){
        if(t[i]=='r')ans+=p;
        if(t[i]=='s')ans+=r;
        if(t[i]=='p')ans+=s;
    }
    for(int i=k; i<n; ++i){
        if(t[i]==t[i-k]){
            t[i]='x';
            continue;
        }
        if(t[i]=='r')ans+=p;
        if(t[i]=='s')ans+=r;
        if(t[i]=='p')ans+=s;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
from collections import deque
h,w = list(map(int,input().split()))
s = [[x for x in input()] for _ in range(h)]

gh = h-1
gw = w-1
def bfs():
  que = deque([])
  ch = 0
  cw = 0
  d[ch][cw] = 0

  dh = [1,0,-1,0]
  dw = [0,1,0,-1]
  
  que.append([ch,cw])
  while que:
    p = que.popleft()
    if p[0] == gh and p[1] == gw:
      return
    for i in range(4):
      nh = p[0] + dh[i]
      nw = p[1] + dw[i]
      
      if nh >= 0 and nh < h and nw >=0 and nw < w and \
          d[nh][nw] == float('inf') and s[nh][nw] != '#':
        d[nh][nw] = d[p[0]][p[1]] + 1
        que.append([nh, nw])

d = [[float('inf') for _ in range(w)] for _ in range(h)]
bfs()
if d[gh][gw] == float('inf'):
  print(-1)
  exit()

white = 0
root = d[gh][gw]

for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      white += 1
print(white-root-1)

Measured memory_bytes: 3436
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
MOD = 10 ** 9 + 7
length = int(A.max()).bit_length()
answer = 0
for i in range(length):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    x *= 2 ** i % MOD
    answer += x

print(answer % MOD)


Measured memory_bytes: 51136
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

int n, h, cnt;
#define pii pair<int,int>
pii wp[(int)1e5 + 10];

void check()
{
	if(h<=0){
		printf("%d\n", cnt);
		exit(0);
	}
} 

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	cin>>n>>h;
	for(int i = 1; i <= n; i++)
		cin>>wp[i].second>>wp[i].first;
	sort(wp+1, wp+n+1);
//	for(int i = 1; i <= n; i++)
//		swap(wp[i].second, wp[i].first);
	int mx=0, mxwho;
	for(int i = 1; i <= n; i++)
		if(wp[i].second > mx)
			mx = wp[i].second, mxwho = i;
	cnt = 0;
	for(int i = n; i >= 1; i--)
	{
		if(i==mxwho || wp[i].first <= wp[mxwho].second)	continue;
		cnt++;
		h -= wp[i].first;
		check();
	}
	if(wp[mxwho].first > wp[mxwho].second)
		cnt++, h-=wp[mxwho].first, check();
	int d = h/wp[mxwho].second;
	cnt += d;
	h -= d*wp[mxwho].second;
	if(h)
		cnt++, h=0;
	check();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
        int n;
        cin >> n;
        int tans = 0, hans = 0;
        rep(i, n){
            string t, h;
            cin >> t >> h;
            if(t > h) tans += 3;
            else if(t < h ) hans += 3;
            else{
                tans++;
                hans++;
            }
        }
        cout << tans << " " << hans << endl;
}


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

struct Tree{
 struct Node{ int l=-1,r=-1,p=-1; int v; int w; };
 vector<Node> V;
 int R=-1;

 int& parentchild(int v){
  if(v==R) return R;
  if(V[V[v].p].l==v) return V[V[v].p].l;
  else return V[V[v].p].r;
 }
 void swapidx(int a,int b){
  swap(parentchild(a), parentchild(b));
  swap(V[a], V[b]);
  if (V[a].l != -1) V[V[a].l].p = a;
  if (V[a].r != -1) V[V[a].r].p = a;
  if (V[b].l != -1) V[V[b].l].p = b;
  if (V[b].r != -1) V[V[b].r].p = b;
 }
 void rotL(int v){
  int w=V[v].r;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].r=V[w].l; if(V[v].r!=-1) V[V[v].r].p=v;
  V[v].p=w; V[w].l=v;
 }
 void rotR(int v){
  int w=V[v].l;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].l=V[w].r; if(V[v].l!=-1) V[V[v].l].p=v;
  V[v].p=w; V[w].r=v;
 }

 void fix(int v){
  while(true){
   int p=V[v].p;
   if(p==-1) return;
   if(V[p].w>=V[v].w) return;
   if(V[p].l==v) rotR(p); else rotL(p);
  }
 }

 void insert(int v, int w){
  int p=-1; int* pp=&R;
  while(*pp!=-1){
   p=*pp;
   if(v<V[p].v) pp=&V[p].l;
   else if(v>V[p].v) pp=&V[p].r;
   else return;
  }
  *pp=V.size();
  V.push_back({-1,-1,p,v,w});
  fix(V.size()-1);
 }
 int find(int v){
  int p=R;
  while(p!=-1){
   if(v==V[p].v) return p;
   if(v<V[p].v) p=V[p].l; else p=V[p].r;
  }
  return -1;
 }
 void erase(int v){
  if(v==-1) return;
  while(true){
   if(V[v].l!=-1 && V[v].r!=-1){
    if(V[V[v].l].w<V[V[v].r].w) rotL(v);
    else rotR(v);
   }
   else if(V[v].l!=-1) rotR(v);
   else if(V[v].r!=-1) rotL(v);
   else break;
  }
  swapidx(v,V.size()-1);
  parentchild(V.size()-1)=-1;
  V.pop_back();
 }

 void printPreorder(int p=-2){
  if(p==-2) p=R;
  if(p==-1) return;
  printf(" %d",V[p].v);
  printPreorder(V[p].l);
  printPreorder(V[p].r);
 }
 void printInorder(int p=-2){
  if(p==-2) p=R;
  if(p==-1) return;
  printInorder(V[p].l);
  printf(" %d",V[p].v);
  printInorder(V[p].r);
 }
};

Tree T;
int Q;

int main() {
 scanf("%d",&Q);
 rep(i,Q){
  string c;
  { char buf[10]; scanf("%s",buf); c=buf; }
  if(c=="insert"){
   int v,w; scanf("%d%d",&v,&w);
   T.insert(v,w);
  }
  else if(c=="find"){
   int v; scanf("%d",&v);
   if(T.find(v)==-1) printf("no\n"); else printf("yes\n"); fflush(stdout);
  }
  else if(c=="delete"){
   int v; scanf("%d",&v);
   T.erase(T.find(v));
  }
  else if(c=="print"){
   T.printInorder(); printf("\n");
   T.printPreorder(); printf("\n"); fflush(stdout);
  }
 }
}




Measured memory_bytes: 8252
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cassert>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;

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


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve()
{
    
    int n;
    cin>>n;
    int m;
    cin>>m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    pvec x(m);
    sort(all(a));
    rep(i,m) cin>>x[i],swap(x[i].fs,x[i].sc);
    sort(rall(x));
    vec b(n);
    int cnt=0;
    rep(i,m){
        rep(j,x[i].second){
            b[cnt]=x[i].fs;
            cnt++;
            if(cnt==n) break;
        }
        if(cnt==n) break;
    }
    int ans=0;
    rep(i,n) ans+=max(a[i],b[i]);
    cout<<ans<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve();
}

Measured memory_bytes: 8064
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int W, H, O, P;

void cut(int x, int y, int a){
  if(a==1 && O < x ){
    O = x;
  } else if(a==2 && W > x){
    W = x;
  } else if(a==3 && P < y){
    P = y;
  } else if(a==4 && H > y){
    H = y;
  }
}

int main(){
  O = 0;
  P = 0;
  int N, x, y, a;
  cin >> W >> H >> N;
  for(int i=0; i<N; i++){
    cin >> x >> y >> a;
    cut(x,y,a);
  }

  if(W-O<0 || H-P<0) cout << 0 << endl;
  else cout << (W-O) * (H-P) << endl;

}

Measured memory_bytes: 256
import itertools
N,M,Q = map(int,input().split())
list_a = []
for i in range(Q):
  a = list(map(int,input().split()))
  list_a.append(a)
list_num =[]
max_num = 0
for i in range(1,M+1):
  list_num.append(i)
num = list(itertools.combinations_with_replacement(list_num, N))
for i in num:
  count=0
  for j in list_a:
    if i[j[1]-1]-i[j[0]-1]==j[2]:
      count+=j[3]
  max_num = max(count,max_num)
print(max_num)
    
  
  
    
    

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

int count_map(vector<vector<char>> map) {
    int res = 0;
    
    for(vector<char> row : map) {
        for(char cell : row) {
            if(cell == '#') {
                res++;
            }
            // cout << cell;
        }
        // cout << endl;
    }
    // cout << "res=" << res << endl;
    return res;
}

vector<vector<char>> fill(vector<vector<char>> map, vector<int> rows,
                          vector<int> cols) {

    for(int row : rows) {
        for(int i = 0; i < map.at(row).size(); i++) {
            map.at(row).at(i) = '0';
        }
    }
    for(vector<char> &r : map) {
        for(int col : cols) {
            r.at(col) = '0';
        }
    }
    return map;
}

vector<int> num2comb(int mx, int i) {
    vector<int> res;
    for(int s = 0; s < mx; s++) {
        if(((i >> s) & 1) == 1) {
            res.push_back(s);
        }
    }
    return res;
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> map(H, vector<char>(W));
    for(int h = 0; h < H; h++) {
        for(int w = 0; w < W; w++) {
            cin >> map.at(h).at(w);
        }
    }

    int ans = 0;
    int rmx = pow(2, H);
    int cmx = pow(2, W);

    for(int ri = 0; ri < rmx; ri++) {
        for(int ci = 0; ci < cmx; ci++) {
            if(count_map(fill(map, num2comb(H, ri), num2comb(W, ci))) == K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4088
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    System.err.println("コインの数");
    int A, B, C, X;
    do{
      do {
        System.err.print("500円玉：");
        A = stdIn.nextInt();
      } while (A < 0 || A > 50);
      do {
        System.err.print("100円玉：");
        B = stdIn.nextInt();
      } while (B < 0 || B > 50);
      do {
        System.err.print(" 50円玉：");
        C = stdIn.nextInt();
      } while (C < 0 || C > 50);
    } while (A + B + C == 0);

    do {
      System.err.print("X円にする：");
      X = stdIn.nextInt();
    } while (X < 50 || X > 20000);

    int count = 0; int sum = 0;
    for (int i = 0; i <= A ; i++) {
      int a = 500 * i;
      sum = a;
      if (sum > X) {
        break;
      } else if (sum == X) {
        count++;
        break;
      }

      for (int j = 0; j <= B ; j++) {
        int b = 100 * j;
        sum = a + b;
        if (sum > X) {
          break;
        } else if (sum == X) {
          count++;
          break;
        }

        for (int k = 0; k <= C ; k++) {
          int c = 50 * k;
          sum = a + b + c;
          if (sum > X) {
            break;
          } else if (sum == X) {
            count++;
            break;
          }
        }
      }
    }

  System.out.println(count);
  }
}


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

namespace TYC
{
	const int N = 1e5 + 5, INF = 0x3f3f3f3f;

	int n, sumv, mxv, siz[N], col[N], F[N][3];
	char str[N];
	vector<int> E[N], T[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	bool rebuild(const int u, const int f, int deg)
	{
		bool flag = col[u];
		for (int v : T[u])
			if (v != f && rebuild(v, u, 1))
			{
				E[u].push_back(v);
				deg++;
				flag = true;
			}
		if (!flag)
			n--;
		else
			sumv += (col[u] ^= (deg & 1));
		return flag;
	}

	inline int f(const int p) { return col[p] == 1 ? 1 : -1; }

	void dfs(const int u)
	{
		F[u][0] = F[u][1] = F[u][2] = E[u].size() ? -INF : 0;
		for (int v : E[u])
		{
			dfs(v);
			F[u][2] = max(F[u][2], F[u][0] + f(u) + F[v][1] + 1);
			F[u][2] = max(F[u][2], F[v][0] + f(v) + F[u][1] + 1);
			F[u][0] = max(F[u][0], F[v][0] + f(v) + 1);
			F[u][1] = max(F[u][1], F[v][1] + f(u) + 1);
		}
		mxv = max(mxv, max(F[u][0], max(F[u][1], F[u][2])));
	}

	void work()
	{
		n = read();
		for (int i = 1; i < n; i++)
		{
			int u = read(), v = read();
			T[u].push_back(v);
			T[v].push_back(u);
		}
		scanf("%s", str + 1);
		int rot = 0, cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			col[i] = str[i] == 'W';
			if (!rot && col[i])
				rot = i;
			cnt += col[i];
		}
		if (cnt <= 1)
			return void(printf("%d\n", cnt));
		rebuild(rot, 0, 0);
		dfs(rot);
		printf("%d\n", 2 * n - 2 + sumv - mxv);
	}
}

int main()
{
	TYC::work();
	return 0;
}

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

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

  if ( a == b){
    cout << a + b << endl;
  }

 else{
   cout << (max(a,b))*2-1 <<endl;
 }
}
  




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    //後の大きい数ほど有効
    int N,T;
    cin >> N >> T;
    int result = 0;
    int A[N];
    int max[N];
    int min[N];
    int temp = 0;
    int allMax = 0;
    bool outFlag;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    //初回
    temp = 1000000000;
    for (int i = 0; i < N; ++i)//min
    {
        if(temp > A[i]){
            temp = A[i];
        }
        min[i] = temp;
    }
    temp = 0;
    for (int i = N-1; i >= 0; --i)//max
    {
        if(temp < A[i]){
            temp = A[i];
        }
        max[i] = temp;
    }
    for (int i = 0; i < N; ++i)//差
    {
        if(allMax < max[i]-min[i]){
            allMax = max[i]-min[i];
        }
    }
    for (int i = 0; i < N; ++i)//差
    {
        if(allMax == max[i]-min[i] && A[i]==min[i]){
            A[i]++;
            result++;
        }
    }
    //２週目以降
    for (int count = 0; count < 2; count=0)
    {
        temp = 1000000000;
        for (int i = 0; i < N; ++i)//min
        {
            if(temp > A[i]){
                temp = A[i];
            }
            min[i] = temp;
        }
        temp = 0;
        for (int i = N-1; i >= 0; --i)//max
        {
            if(temp < A[i]){
                temp = A[i];
            }
            max[i] = temp;
        }
        outFlag=true;
        for (int i = 0; i < N; ++i)//差
        {
            if(allMax == max[i]-min[i] && A[i]==min[i]){
                A[i]++;
                result++;
                outFlag=false;
            }
        }
        if(outFlag){
            break;
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int VCount(const vvi& s,int j)
{
	int res=0;
	rep(i,s.size())
		res+=s[i][j];
	return res;
}

int main()
{
	for(int h,w;cin>>h>>w,h|w;){
		vvi s(h,vi(w));
		rep(i,h)
			rep(j,w)
				cin>>s[i][j];
		
		int res=0;
		rep(bit,1<<h){
			vvi temp=s;
			rep(i,h)
				if((1<<i)&bit)
					transform(allof(temp[i]),temp[i].begin(),logical_not<int>());
			int sum=0;
			rep(j,w){
				int vc=VCount(temp,j);
				sum+=max(vc,h-vc);
			}
			res=max(res,sum);
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;



int main()
{
	fastio 
	// SUBL
	string s;
	cin >> s;
	FI(i,1,s.length()-1)
	{
		if(s[i]==s[i-1]) 
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstring>
#include <algorithm>
#define INF 500050
typedef long long ll;
ll a[INF];
using namespace std;
int main()
{
	int n;
	cin>>n;
	double sum = 0.0;
	for(int i=1; i<=n; i++) {
		double x;
		cin>>x;
		sum += 1.0/x;
	}
	cout<<1.0/sum<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256