akhauriyash/Code-Regression huggingface dataset:
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void div(ll arr[], ll n, ll s1) 
{ 
    ll max_ele = arr[0],s2=0; 
    //arr[0] = -1; 
  
    for (ll i = 1; i < n; ++i) { 
        if (max_ele >= arr[i])
            arr[i] = max_ele;  
        else if (max_ele < arr[i]) 
			max_ele=arr[i];  
    }  
    for(ll i=0;i<n;i++)
    	s2+=arr[i];
    	
    cout<<s2-s1;
} 

void solve(){
	//code
	ll n,s=0;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i],s+=a[i];
		
	div(a,n,s);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


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

using namespace std;
using ll=long long;

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  int cnt=0;
  rep(i,s.size()){
    s[i]=='+'? cnt++ : cnt--;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <atcoder/modint>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

#define MOD 998244353



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

	int n, q;
	cin >> n >> q;

	vector<long long> sumpow(n + 1);
	long long p = 1;
	sumpow[n] = 1;

	for (int i = n; i >= 1; i--) {
		sumpow[i] = p;
		p *= 10;
		p %= MOD;
	}
	for (int i = 1; i <= n; i++) {
		sumpow[i] = (sumpow[i] + sumpow[i - 1] ) % MOD;
	}


	long long ans = sumpow[n];
	map<int, pair<int, int>> seg;
	seg.emplace(0, make_pair(n, 1));

	rep(_, q) {
		int L, R, d;
		cin >> L >> R >> d;
		L--;


		auto it = seg.upper_bound(L);
		if (it != seg.begin()) --it;

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

		for (; it != seg.end(); ) {
			if (R <= it->first)break;
			ans -= (sumpow[it->second.first] - sumpow[it->first]) * it->second.second;
			ans %= MOD;

			if (it->first < L) {
				v.emplace_back(it->first, make_pair(L, it->second.second));
			}
			if (R < it->second.first) {
				v.emplace_back(R, make_pair(it->second.first, it->second.second));
			}

			it = seg.erase(it);
		}
		for (auto p : v) {
			ans += (sumpow[p.second.first] - sumpow[p.first]) * p.second.second;
			seg.insert(p);
		}

		ans += (sumpow[R] - sumpow[L]) * d;
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
		seg.emplace(L, make_pair(R, d));
		cout << ans << endl;
	}




	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int y, m, c;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> y >> m >> c;
		int sum = 0;
		for (int j = 1; j <y; j++) {
			if (j % 3 == 0) {
				sum = sum + 200;
			}
			else {
				sum = sum + 195;
			}
		}
		for (int k = 1; k <m; k++) {
			if (y % 3 == 0) {
				sum = sum +( m -1)* 20;
				break;
			}
			else {
				if (k % 2 == 1) {
					sum = sum + 20;
				}
				else {
					sum = sum + 19;
				}
			}
		}
		cout << 196471 - sum - c << endl;
	}
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S, T;
    cin >> S >> T;
    ll size = S.size();
    bool flag = true;
    REP(i, size)
    {
        if (S[i] != T[i])
        {
            flag = false;
            break;
        }
    }
    string ans = flag ? "Yes" : "No";

    cout << ans << endl;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
//#define int long long



int32_t main() {

    string s, t; cin >> s >> t;
    int l = s.length(), m = t.length();

    vector<vector<int>> dp(l+1, vector<int>(m+1, 0));

    for(int i = 1; i <= l; ++i) {
        char si = s[i-1];
        for(int j = 1; j <= m; ++j) {
            char tj = t[j-1];
            int cand = max(dp[i-1][j], dp[i][j-1]);
            if(si == tj && dp[i-1][j-1] >= cand) {
                cand = dp[i-1][j-1]+1;
            }
            dp[i][j] = cand;
        }
    }

    string ans = "";

    int i = l, j = m;
    while(i > 0 && j > 0) {
        if(dp[i-1][j-1]+1 == dp[i][j] &&
           dp[i-1][j-1] >= dp[i-1][j] &&
           dp[i-1][j-1] >= dp[i][j-1]) {
            ans += s[i-1];
            i--;
            j--;
        } else if(dp[i-1][j] > dp[i][j-1]) {
            i--;
        } else {
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  int a,b;
  string s,ans;
  cin >> a >> b >> s;
  
  ans = "No";
  
  if(s.at(a) == '-'){
    int cnt = 0;
    for(int i = 0;i < a+b;i++){
      if(s.at(i) == '-'){
        cnt++;
      }
    }
    if(cnt == 1){
    ans = "Yes";
    }
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io {cin.sync_with_stdio(0); cout.sync_with_stdio(0);}
#define out(x,y) {cout<<x<<y;}
using ll = long long int;
using pa = pair<ll,ll>;

int main(){
	fast_io;
	ll k,n,m;
	cin>>k>>n>>m;
	if(n%k==0 || m%k==0){
		cout<<"OK\n";
	}
	else if(k*(1+(n/k))<=m){
		cout<<"OK\n";
	}
	else cout<<"NG\n";
}

Measured memory_bytes: 3692
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
mod = 10**9+7

dp = [[0]*(M+1) for i in range(N+1)]
dps = [[0]*(M+1) for i in range(N+1)]
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            dp[n+1][m+1] = (dps[n][m]+1)%mod
        dps[n+1][m+1] = (dp[n+1][m+1]+dps[n+1][m]+dps[n][m+1]-dps[n][m])%mod

print(dps[-1][-1]+1)


Measured memory_bytes: 130728
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,leave;
  vector<P> nodes;
  cin >> n >> k;
  leave = ((n-1)*(n-2))/2 - k;
  if(leave<0){
    cout <<"-1\n";
    return 0;
  }
  for(int i=1;i<n;i++){
    nodes.push_back(P(0,i));
  }
  if(leave!=0){
    for(int i=1;i<n;i++){
      for(int j=i+1;j<n;j++){
        nodes.push_back(P(i,j));
        leave--;
        if(leave==0) break;
      }
      if(leave==0) break;
    }
  }
  cout << nodes.size()<<endl;
  for(auto i:nodes){
    cout << i.first+1<<" "<<i.second+1<<endl;
  }
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	ox := strings.Split(s, "")

	firsts := []string{"S", "W"}
	seconds := []string{"S", "W"}
	for _, first := range firsts {
		for _, second := range seconds {
			all := succeed(first, second, ox)
			ok := check(all, ox)
			if ok {
				fmt.Println(strings.Join(all, ""))
				return
			}
		}
	}
	fmt.Println(-1)
}

func succeed(first string, second string, ox []string) []string {
	res := make([]string, len(ox))
	res[0] = first
	res[1] = second
	for i := 2; i < len(res); i++ {
		if ("o" == ox[i-1]) == (res[i-1] == res[i-2])  {
			res[i] = "S"
		} else {
			res[i] = "W"
		}
	}
	return res
}

func check(list, ox []string) bool {
	first := list[0]
	firstAns := ox[0]
	last := list[len(list) - 1]
	lastAns := ox[len(ox) - 1]
	res := true
	if first == "S" {
		if firstAns == "o" {
			res = res && (list[1] == last)
		} else {
			res = res && (list[1] != last)
		}
	} else {
		if firstAns == "o" {
			res = res && (list[1] != last)
		} else {
			res = res && (list[1] == last)
		}
	}
	if last == "S" {
		if lastAns == "o" {
			res = res && (list[len(list) - 2] == first)
		} else {
			res = res && (list[len(list) - 2] != first)
		}
	} else {
		if lastAns == "o" {
			res = res && (list[len(list) - 2] != first)
		} else {
			res = res && (list[len(list) - 2] == first)
		}
	}
	return res
}


Measured memory_bytes: 8704
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int h[100], w[100];
	int count = 0;
	while (true) {
		cin >> h[count];
		cin >> w[count];
		if (h[count] == 0 && w[count] == 0) {
			break;
		}
		count++;
	}
	
	for(int a =0;a<count;a++){

		for (int i = 0; i < h[a]; i++) {
			for (int j = 0; j < w[a]; j++) {
				if (i == 0 || i == h[a]-1) {
					cout << '#';
				}
				else if (j==0 || j==w[a]-1) {
					cout << '#';
				}
				else  {
					cout << '.';
				}	
			}
			cout << endl;
		}
		cout << endl;
	}

	

	return 0;
}



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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    string s; cin >> s;
    string ret;
    for (char i : s) {
        if (i == 'B') {
            if (!ret.empty()) ret.pop_back();
        } else {
            ret.push_back(i);
        }
    }
    cout << ret << '\n';
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector <int> x(10000);
int main() {
    vector <int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    int K;
    cin >> K;
    for(int i = 0; i < K; i++){
        sort(A.begin() , A.end());
        A[2] *= 2;
    }
    cout << A[0] + A[1] + A[2] << endl;
}

Measured memory_bytes: 3644
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let mut ans = 0;

    for i in 1..n+1 {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }

    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 123456;

int a[N];
int b[N];
int ans[N];

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

    string s;

    cin >> s;

    int n = s.length();

    a[0] = 0;
    rep(i , 1 , n - 1) {
        if(s[i] == 'R') {
            a[i] = i;
        }
        else {
            a[i] = a[i - 1];
        }
    }

    b[n - 1] = n - 1;
    per(i , n - 2 , 0) {
        if(s[i] == 'L') {
            b[i] = i;
        }
        else {
            b[i] = b[i + 1];
        }
    }

    rep(i , 0 , n - 1) {
        if(s[i] == 'R') {
            int le = b[i];
            if((le - i) % 2 == 0) {
                ans[le]++;
            }
            else {
                ans[le - 1]++;
            }
        }
        else {
            int ri = a[i];
            if((i - ri) % 2 == 0) {
                ans[ri]++;
            }
            else {
                ans[ri + 1]++;
            }
        }
    }


    rep(i , 0 , n - 1) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1872
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int t = int.Parse(input[1]);
		long[,,] dp = new long[n+1,t+1,2];//dp[見た数、使った時間、短縮済か]:=価値の最大値
    long[,] vertexes = new long[n,2];
    long answer = 0;
    for(int i = 0; i < n; i++)
    {
      long[] numsa = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = numsa[0];
      vertexes[i,1] = numsa[1];
    }

    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= t; j++)
      {
        dp[i,j,0] = dp[i-1,j,0];
        if(j-vertexes[i-1,0] >= 0)
          dp[i,j,0] = Math.Max(dp[i,j,0], dp[i-1, j-vertexes[i-1,0], 0]+vertexes[i-1,1]);

        dp[i,j,1] = dp[i-1,j,1];
        if(j-vertexes[i-1,0] >= 0)
          dp[i,j,1] = Math.Max(dp[i,j,1], dp[i-1, j-vertexes[i-1,0],1]+vertexes[i-1,1]);
        if(j-1 >= 0)
          dp[i,j,1] = Math.Max(dp[i,j,1], dp[i-1,j-1, 0]+vertexes[i-1,1]);
      }
    }

    for(int i = 0; i <= t; i++)
    {
      for(int j = 0; j <= 1; j++)
      {
        answer = Math.Max(answer,dp[n,i,j]);
      }
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 151640
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define MAX 10000001

bool prime[MAX];

int main(){
  rep(i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  loop(i, 2, sqrt(MAX)){
    for(int j = i*2; j < MAX; j += i)
      prime[j] = false;
  }

  int n;
  while(cin >> n, n != 0) {
    for(int j = n; j > 1; j--)
      if(prime[j] == true && prime[j - 2] == true && prime[j - 6] == true && prime[j - 8]) { cout << j << endl; break;}
  }
}
    

Measured memory_bytes: 10924
import sys

input = sys.stdin.buffer.readline
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7
dp = [0] * (pow(2, n))
dp[0] = 1
# dp[i][j] 男i人に対して女の集合Sが合致
bitcnt = [0] * (pow(2, n) + 1)
for s in range(pow(2, n)):
    # otoko = bin(s).count("1")
    bitcnt[s] = bitcnt[s // 2] + s % 2
    i = bitcnt[s]
    for j in range(n):
        if (s >> j) & 1 == 0:
            if A[i][j] == 1:
                ns = s | 1 << j
                dp[ns] += dp[s]
                dp[ns] %= mod
print(dp[pow(2, n) - 1])


Measured memory_bytes: 75228
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	ss := make([]string, n)
	im := make([]IntMap, n)
	var ans [26]int

	for i := 0; i < n; i++ {
		ss[i] = getNextString(scanner)
		l := len(ss[i])
		im[i] = IntMap{}

		for ii := 0; ii < l; ii++ {
			im[i].increment(int(ss[i][ii] - 'a'))
		}
	}

	for i := 0; i < 26; i++ {
		ans[i] = 50
		for ii := 0; ii < n; ii++ {
			if ans[i] > im[ii].get(i) {
				ans[i] = im[ii].get(i)
			}
		}
		for ii := 0; ii < ans[i]; ii++ {
			fmt.Fprintf(writer, "%c", 'a'+i)
		}
	}
	fmt.Fprintln(writer, "")

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		try {
			Pattern pattern = Pattern.compile("([0-9]+) *([0-9]+) *([0-9]+)");
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
			Matcher matcher;
			ArrayList<Integer> l = new ArrayList<Integer>();
			int n=Integer.parseInt(bf.readLine());
			for(int i=0;i<n;i++){
				matcher = pattern.matcher(bf.readLine());
				if(matcher.matches()){
					for(int j=1;j<=3;j++){
						l.add(Integer.parseInt(matcher.group(j))*Integer.parseInt(matcher.group(j)));
					}
					Collections.sort(l);
					if(l.get(0).intValue()+l.get(1).intValue() == l.get(2).intValue()){
						System.out.println("YES");
					}else{
						System.out.println("NO");
					}
					l.clear();
				}
			}
		}catch(Exception e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 10000
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T> using v = vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a,l,r) for(int a = (l); a < (r); a++)
#define pb push_back
#define sz(a) ((int) a.size())
const int inf = 4611686018427387903;//2^62-1
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read() {}     template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){}     template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){put (arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here

void run() {
    int n,k;read(n,k);int a[n];rep(i,0,n)get a[i];
    int ans=1;
    int l=0,r=k;
    while(r<n){
        l=r-1;
        r=l+k;
        ans++;
    }
    put ans;
}
int32_t main() {srand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, res; cin >> N;
    string S; cin >> S;
    res = 0;
    for (int i = 0; i < N; i++)
    {
        res++;
        char now = S[i];
        while(i != N - 1 && now == S[i + 1])
        {
            i++;
        }
    }
    cout << res << endl;
	return 0;
}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, D;
    cin >> N >> D;

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

    return 0;
}

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

N, M = map(int,input().split())
to = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int,input().split())
    A -= 1; B -= 1
    to[A].append(B)
    to[B].append(A)

# 二部グラフ判定(単純グラフ:連結,　自己ループ無, 多重辺無　を想定)
# -1:未訪問, 0:黒, 1:白
visited = [-1] * N

# 0を黒塗りでスタート
def is_bipartite(v=0, color=0):
    flag = True
    visited[v] = color
    for nv in to[v]:
        ncolor = (color + 1) % 2
        if visited[nv] == -1:
            flag &= is_bipartite(nv, ncolor)
        elif visited[nv] != ncolor:
            return False
    return flag

if is_bipartite():
    a = sum(visited)
    b = N - a
    ans = a*b - M
else:
    ans = N*(N-1)//2 - M

print(ans)

Measured memory_bytes: 44488
def recover(purple):
    h = len(purple)
    w = len(purple[0])
    red = []
    blue = []
    for i in xrange(h):
        if (i&1)==0:
            red.append(['#' for j in xrange(w-1)]+['.'])
            blue.append(['.' for j in xrange(w-1)]+['#'])
        else:
            red.append(['#']+['.' for j in xrange(w-1)])
            blue.append(['.']+['#' for j in xrange(w-1)])
        for j in xrange(w):
            if purple[i][j]=='#':
                red[i][j] = '#'
                blue[i][j] = '#'
    return red, blue

def main():
    h, w = [int(i) for i in raw_input().strip().split()]
    purple = []
    for i in xrange(h):
        purple.append(raw_input().strip())
    r, b = recover(purple)
    for line in r:
        print ''.join(line)
    print ''
    for line in b:
        print ''.join(line)

if __name__=='__main__':
    main()


Measured memory_bytes: 7428
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int n,m;cin>>n>>m;
	vector<pair<long long,long long>> d(n);
	for(int i=0;i<n;i++)cin>>d[i].first>>d[i].second;
	sort(d.begin(),d.end());
	
	long long ans=0;
	for(int i=0;i<n;i++){
		if(m<=d[i].second){
			ans+=d[i].first*m;
			break;
		}
		else{
			ans+=d[i].first*d[i].second;
			m -= d[i].second;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s1;

	k=s1.length();

	for(i=0;i<k;i+=2) cout<<s1[i];

	cout<<endl;



}


Measured memory_bytes: 592
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    is_break = False
    seen = set()
    for a in A:
        if a not in seen:
            seen.add(a)
        else:
            is_break = True
            break
    
    if is_break:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  bool x = false;
  for(int i = 0; i<n; i++) cin >> a.at(i) >> b.at(i);
  for(int i = 0; i<(n-2); i++){
    int res = 0;
    if(a.at(i) == b.at(i)) res++;
    if(a.at(i+1) == b.at(i+1)) res++;
    if(a.at(i+2) == b.at(i+2)) res++;
    if(res == 3){
      x = true;
      break;
    }
  }
  if(x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
n = int(input())
b = list(map(int,input().split()))

a = [b[0]]

if len(b) == 2:
    if b[0]<=b[1]:
        print(sum(b)+b[0])
    elif b[0] >b[1]:
        print(sum(b)+b[1])
elif len(b)==1:
    print(b[0]*2)
elif len(b)>=3:
    b.append(0)

    for i in range(n-2):
        if b[i]<=b[i+1]:
            a.append(b[i])

        elif b[i]>b[i+1]:
            a.append(b[i+1])

    a.append(b[-2])
    print(sum(a))

Measured memory_bytes: 3064
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int maxa = 0;
        int maxi = 0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            if(a[i]>maxa){
                maxa = a[i];
                maxi = i;
            }
            b[i] = sc.nextInt();
        }
        System.out.println(maxa + b[maxi]);

    }


}

Measured memory_bytes: 89420
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first2 1
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll n ;
	cin>> n ;
	n--;
	ll ans = arr[n];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, x, y, z, money;
  int ax = -1;
  int ay = -1;
  int az = -1;
  
  cin >> N >> M;
    
  for(int x = 0;x <= N; x++){
    for(int y = 0;x + y <= N; y++){
      z = N - x - y;
      money = x*10000 + y*5000 + z*1000;
      if(money == M){
      ax = x;
      ay = y;
      az = z;
      }   
    }
  }
  cout << ax << " " << ay << " " << az << endl;  
}

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

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

  int N; cin >> N;
  int *A = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 == 0) {
      if (A[i] % 3 != 0 && A[i] % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line := scanner.Text()
	abc := strings.Fields(line)

	var sum int
	for _, s := range abc {
		x, _ := strconv.Atoi(s)
		sum += x
	}

	if sum <= 21 {
		fmt.Println("win")
	} else {
		fmt.Print("bust")
	}
}


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

string S;

int main() {
    cin >> S;

    int max = 0;
    int tmp = 0;
    string target = "ACGT";

    // cout << target.find(S[1]) << endl;
    for (int i = 0; i < S.size(); i++) {
        if (target.find(S[i]) != string::npos) {
            tmp++;
        } else {
            tmp = 0;
        }

        if (tmp > max) {
            max = tmp;
        }
    }

    cout << max << endl;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===



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

	int N, W;
	cin >> N >> W;

	vector<Vi> value(4);
	int w1, v1;
	cin >> w1 >> v1;
	value[0].push_back(v1);

	for (int i = 1; i < N; ++i) {
		int wi, vi;
		cin >> wi >> vi;
		value[wi - w1].push_back(vi);
	}
	
	for (int i = 0; i < 4; ++i) {
		sort(value[i].begin(), value[i].end(), greater<int>());
	}

	vector<Vi> csum(4);
	for (int i = 0; i < 4; ++i) {
		int ni = (int)value[i].size();
		csum[i].resize(ni + 1);
		for (int j = 0; j < ni; ++j) {
			csum[i][j + 1] = csum[i][j] + value[i][j];
		}
	}

	int ans = -I_INF;

	for (int i = 0; i < (int)csum[0].size(); ++i) {
		for (int j = 0; j < (int)csum[1].size(); ++j) {
			for (int k = 0; k < (int)csum[2].size(); ++k) {
				for (int l = 0; l < (int)csum[3].size(); ++l) {
					ll wsum = (ll)i * w1 + (ll)j * (w1 + 1) + (ll)k * (w1 + 2) + (ll)l * (w1 + 3);
					if (wsum <= W) {
						int vsum = csum[0][i] + csum[1][j] + csum[2][k] + csum[3][l];
						ans = max(ans, vsum);
					}
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

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

import math

def main():
    k = int(input())

    ans = 0

    for i in range(1, k+1):
        for j in range(1, k+1):
            for l in range(1, k+1):
                ans += math.gcd(math.gcd(i,j),l)

    print(ans)


if __name__ == '__main__':
    main()


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

n,m,k = map(int,input().split())

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

num = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)
    num[a-1] += 1
    num[b-1] += 1

edge = [[] for i in range(n)]

for i in range(k):
    c,d = map(int,input().split())
    edge[c-1].append(d-1)
    edge[d-1].append(c-1)


for i in range(n):
    cnt = size(i) - num[i] - 1
    for e in edge[i]:
        if same(e,i):
            cnt -= 1
    print(cnt,end=' ')

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

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

using namespace std;
using lint = long long;

int main(void)
{
    
    int N, M;
    cin >> N >> M;
    vector<int> A(N);

    double sum  = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    int cnt = 0;
 
    for(int i = 0; i < N; i++){
        if(sum / (4*M) <= A[i]) cnt++;
    }

    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,l,r,t1,t2,t3,t4,mx,mi,mii=4000000000000000000,a[200010],s[200010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	l=2;
	r=4;
	t1=a[1];
	t2=a[2];
	t3=a[3];
	t4=s[n]-s[3];
	for(int i=3;i<=n;i++)
	{
		while(l<i&&abs(t1-t2)>abs(t1-t2+a[l]*2ll))
		{
            t1+=a[l];
			t2-=a[l];
			l++;
        }
        while(r<=n&&abs(t4-t3)>abs(t3-t4+a[r]*2ll))
		{
            t3+=a[r];
			t4-=a[r];
			r++;
        }
        mi=4000000000000000000;
		mx=-4000000000000000000;
		mi=min(mi,t1);
		mi=min(mi,t2);
		mi=min(mi,t3);
		mi=min(mi,t4);
		mx=max(mx,t1);
		mx=max(mx,t2);
		mx=max(mx,t3);
		mx=max(mx,t4);
        mii=min(mii,mx-mi); 
		t2+=a[i]; 
		t3-=a[i];
	} 
	cout<<mii;
	return 0;
} 

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

using namespace std;

int n, m, k;
queue <pair <int, int> > q;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char a[801][801];
int d[801][801];
int sti, stj;

bool check (int x, int y) {
	if (x < 1 || x > n) return 0;
	if (y < 1 || y > m) return 0;
	if (a[x][y] != '.') return 0;
	return 1;
}

int get (int x) {         
	int y = x / k + 1;
	if (x % k == 0) y --;
	return y;
}

int main () {
	cin >> n >> m >> k;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			cin >> a[i][j];
			d[i][j] = 1e9 + 7;
			if (a[i][j] == 'S') {
				sti = i;
				stj = j;
			}	
		}
	}
	d[sti][stj] = 0;
	q.push (make_pair (sti, stj));
	while (q.size ()) {
		int x = q.front ().first;
		int y = q.front ().second;
		q.pop ();
		for (int i = 0;i < 4;i ++) {
			int tox = x + dx[i];
			int toy = y + dy[i];
			if (!check (tox, toy)) continue;
			if (d[x][y] + 1 < d[tox][toy]) {
				q.push (make_pair (tox, toy));
				d[tox][toy] = d[x][y] + 1;
			}
		}
	}
	int ans = 1e9 + 7;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
		//	cout << d[i][j] << ' ';
			if (d[i][j] > k) continue;
			int cur = min ({m - j, j - 1, n - i, i - 1});
			if (cur == 0) {
				cout << 1;
				return 0;
			}
			ans = min (ans, get (cur));
		}
		//cout << endl;
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 3456
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	for (int i = M; i < N; i++) {
		if (v[i] > v[i - M])cout << "Yes\n";
		else cout << "No\n";
	}

}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		/*String a = s.next();
		String b = s.next();
		*/
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int x = s.nextInt();
		int count = 0;
		int amount = 0;

		for (int i = 0; i < a + 1; i++) {
			for (int j = 0; j < b + 1; j++) {
				for (int k = 0; k < c + 1; k++) {
					amount = 500 * i + 100 * j + 50 * k;
					if (x == amount) {
						count++;
					}
				}
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    vector<int> v(5);
    cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];

    for (int i =0; i<5; ++i) {
        if (v[i] == 0) {
            cout << i+1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    cin>>n;
    cout<<powl(n,3LL);
    return 0;
}
/*
5
4
3
2
3
4
4
3
3
4
2
3
*/


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

bool isPrime(long long n){
    
    for (long long i = 2; i*i<= n; i++){
        if (n % i == 0) return false;
    }
    return true;
}

int main(){
    
    long long n;
    cin >> n;
    
    if (isPrime(n)){
        cout << n-1 << endl;
        return 0;
    }
    
    
    long long ans = 2*pow(10,12);
    for (long long i = 1; i*i <= n; i++){
        if (n % i != 0) continue;
        
        long long tate = n / i;
        
        long long move = (i-1) + (n/i -1);
        
        ans = min(ans, move);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
// Oh, this is a fake solution!
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<int> P;

int bitcount(int a) {
    int c = 0;
    while (a) c++, a&=a-1;
    return c;
}

inline double cross(const P& a, const P& b) { return imag(conj(a)*b); }

inline bool intersectSS(const P& s0, const P& s1, const P& t0, const P& t1) {
    if (max(real(s0), real(s1)) < min(real(t0), real(t1))) return false;
    if (max(real(t0), real(t1)) < min(real(s0), real(s1))) return false;
    if (max(imag(s0), imag(s1)) < min(imag(t0), imag(t1))) return false;
    if (max(imag(t0), imag(t1)) < min(imag(s0), imag(s1))) return false;
    return cross(s1-s0, t0-s0) * cross(s1-s0, t1-s0) <= 0
        && cross(t1-t0, s0-t0) * cross(t1-t0, s1-t0) <= 0;
}

int n, g[32], m[32];
P ps[32][32];

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) {
            int x, y;
            scanf("%d", m+i);
            rep (j, m[i]) {
                scanf("%d%d", &x, &y);
                ps[i][j] = P(x, y);
            }
        }
        memset(g, 0, sizeof(g));
        rep (i, n) g[i] |= 1<<i;
        rep (i, n) rep (j, m[i]-1) rep (x, i) rep (y, m[x]-1) {
            if (intersectSS(ps[i][j], ps[i][j+1], ps[x][y], ps[x][y+1])) {
                g[i] |= 1<<x, g[x] |= 1<<i;
            }
        }
        const int nn = 1<<n;
        int ans = 0;
        rep (b, nn) {
            bool f = true;
            rep (i, n) if ((b&(1<<i)) && (g[i]&b)!=b) {
                f = false;
                break;
            }
            if (f) ans = max(ans, bitcount(b));
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    ll N;
    string S;
    cin >> N >> S;
    ll count=1;
    rep(i,N-1){
        if (S[i]!=S[i+1]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    //ios::sync_with_stdio(false);
    string S;
    cin  >> S;
    for(int i = 0;i < S.size();i+= 2){
        cout << S.at(i);
    }
    cout << endl;
}

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

int main(){
  int n;
  string w[110];
  bool f=0;
  cin>>n;
  fr(i,n) cin>>w[i];
  fr(i,n) fr(j,n) if(i!=j) if(w[i]==w[j]) f=1;
  fr(i,n-1) if(w[i+1][0]!=w[i][w[i].length()-1]) f=1;
  cout<<(f?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<N;i++){
        if(s.substr(i,N-i)==t.substr(0,N-i)){
            cout<<2*N-(N-i)<<endl;
            return 0;
        }
    }
    cout<<2*N<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import bisect
n=int(input())
s=[]
for i in range(3,10):
  for p in itertools.product(['3','5','7'],repeat=i):
    if '3' in p and '5' in p and '7' in p:
      s.append(int(''.join(p)))
x=bisect.bisect_right(s,n)
print(x)

Measured memory_bytes: 44976
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

static const int N = 100100;

using namespace std;

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

    int a, b, c;
    // array<int, N> a, b;
    // vector<int> a, b;

    cin >> a >> b >> c;

    string str;

    bool can = false;
    if ((c >= a && c <= b) || (c >= b && c <= a))
        can = true;

    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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 facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}




int main() {
    int n,m;
    cin>>n>>m;
    int ret=0;
    if(n<=3){
        ret+=(4-n)*100000;
    }
    if(m<=3){
        ret+=(4-m)*100000;
    }
    if(n==1 && m==1){
        ret+=400000;
    }
    cout<<ret<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN], tab[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << "\n";
}


Measured memory_bytes: 24832