akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void){

  string s;
  int j[30] = {0};
  bool k = true;

  cin >> s;

  for(int i = 0; i < s.size(); i++){
    if(j[s[i]-'a'] != 0){
      k = false;
      break;
    }
    j[s[i]-'a']++;
  }

  if(k) cout << "yes" << endl;
  else cout << "no" << endl;

  return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  string str;
  cin >> str;
  if (str.find('9') != string::npos) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 256
height_a, length_a, height_b, length_b = map(int, input().split())

rectangle_a = height_a * length_a
rectangle_b = height_b * length_b

if rectangle_a == rectangle_b:
    print(rectangle_a)
elif rectangle_a > rectangle_b:
    print(rectangle_a)
elif rectangle_b > rectangle_a:
    print(rectangle_b)

Measured memory_bytes: 9084
// weighted union findわかりません

package main

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

type Node struct {
	to, cost int
}

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, M := nextInt(), nextInt()
	T := make([][]Node, N+1)
	for i := 0; i <= N; i++ {
		T[i] = []Node{}
	}
	for i := 0; i < M; i++ {
		L, R, D := nextInt(), nextInt(), nextInt()
		T[L] = append(T[L], Node{to: R, cost: D})
		T[R] = append(T[R], Node{to: L, cost: -D})
	}

	passed := make([]bool, N+1)
	dist := make([]int, N+1)

	// nodeを出発して通りがかりのcostをもちつつ全探索
	var dfs func(i, j int) bool
	dfs = func(node, d int) bool {
		if passed[node] {
			if dist[node] != d {
				return false
			} else {
				return true
			}
		}
		// 未踏
		passed[node] = true
		dist[node] = d
		for i, nexNode := range T[node] {
			if !dfs(nexNode.to, d+T[node][i].cost) {
				return false
			}
		}
		return true
	}

	// 1orderにしてるんでね
	for i := 1; i <= N; i++ {
		if passed[i] {
			continue
		}
		if !dfs(i, 0) {
			fmt.Fprintln(out, "No")
			return
		}
	}
	fmt.Fprintln(out, "Yes")
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 66048
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << endl; 
    return 0;
}

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

int main() {
    int n;
    cin >> n;

    // pair<vector<vector<int>>, vector<vector<int>>> xy;
    int a[n];
    vector<vector<int>> x(n);
    vector<vector<bool>> y(n);

    for(int i = 0; i < n; i++) {
        cin >> a[i];
        for(int j = 0; j < a[i]; j++) {
            int X;  bool Y;
            cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }

    int ans = 0;
    vector<bool> isHonest(n);
    for(int bit = 0; bit < (1 << n); bit++) {
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) isHonest[i] = true;
            else isHonest[i] = false;
        }

        int cnt = 0;
        bool No_Contradict = true;
        for(int i = 0; i < n; i++) {
            if(!isHonest[i]) continue;
            for(int j = 0; j < a[i]; j++) {
                if(isHonest[x[i][j]] != y[i][j]) {
                    No_Contradict = false;
                    break;
                } 
            }
            if(!No_Contradict) break;
        }
        if(No_Contradict) {
            int temp = accumulate(isHonest.begin(), isHonest.end(), 0);
            ans = max(ans, temp);
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

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

#define int ll


main(){
	int n;
	char c[200001];
	cin >> n >> c;

	int ans = 0;
	int l=0,r=n-1;
	while(l<r){
		if(c[l]=='W' && c[r]=='R'){
			swap(c[l],c[r]);
			ans++;
		}
		if(c[l]=='R')l++;
		if(c[r]=='W')r--;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }

    std::vector<int> num_matches = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

    std::vector<int> dp_num(n + 1, 0);

    for (int i = 0; i < n; i++) {
        for (auto num : a) {
            if (i + num_matches[num] > n) {
                continue;
            }

            dp_num[i + num_matches[num]] = std::max(dp_num[i + num_matches[num]], dp_num[i] + 1);
        }
    }

    std::vector<std::string> dp(n + 1, "");

    for (auto num : a) {
        if (num_matches[num] > n) {
            continue;
        }

        dp[num_matches[num]] = std::max(dp[num_matches[num]], std::to_string(num));
    }

    for (int i = 0; i < n; i++) {
        if (dp[i] == "") {
            continue;
        }

        for (auto num : a) {
            if (i + num_matches[num] > n) {
                continue;
            }
            if (dp[i + num_matches[num]].length() <= dp[i].length()) {
                dp[i + num_matches[num]] = dp[i] + std::to_string(num);
            } else if (dp[i + num_matches[num]].length() == dp[i].length() + 1) {
                dp[i + num_matches[num]] = std::max(dp[i + num_matches[num]], dp[i] + std::to_string(num));
            }
        }
    }

    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 33024
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: usize = sc.read();
    let b: usize = sc.read(); 
    if (b - a) % 2 == 0 {
        println!("{}", "Alice");
    } else {
        println!("{}", "Borys")
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        mut l: [usize; n],
    }

    l.sort();
    let mut count = 0;

    for i in 0..n-2 {
        let t1 = l[i];
        for j in i+1..n-1 {
            let t2 = l[j];
            for k in j+1..n {
                if t1 + t2 > l[k] {
                    count+=1;
                } else {
                    break;
                }
            }

        }
    }

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



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  int N ;
  cin >> N ;
  vector<pair<int,int>>vec;
  rep(i,N){
    int h; cin>>h;
    vec.push_back(make_pair(h,i));
  }
  sort(vec.begin(),vec.end());
  rep(i,N){
    cout<<vec[i].second+1<<endl;
  }
}
  



Measured memory_bytes: 1780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//template<typename T>
#define o_set(T) tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//use it like o_set(ll) x;  --> x.order.....
//-->for pair<ll,ll> : second element as index and for search use INT_MAX...
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


#define fast ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(25)
#define pb push_back
#define I insert
#define F first
#define S second
#define digit(x) floor(log10(x))+1
const long long M1=1000000007;
const long long  M2=998244353;
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
template<typename T>
void showArr(T a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
bool isValid(ll x,ll y,ll n,ll m){
    return (x>=0 and y>=0 and x<n and y<m);
}
ll power(ll a,ll n,ll m){
    ll ans=1;
    while(n>0){
        if(n&1){
            ans=(ans%m * a%m)%m;
        }
        n=n>>1;
        a=(a%m*a%m)%m;
    }
    return ans;
}
ll MMI(ll a,ll m){
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1){
        ll q=a/m,t=m;
        m=a%m,a=t,t=y,y=x-q*y,x=t;
    }
    if(x<0) x+=m0;
    return x;
}

ll dx[]={-1,1,0,0},dy[]={0,0,-1,1};
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ll t;
    cin>>t;
    if(t>=30){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    int ans = 0;
    int temp = arr[0];
    for(int i = 0; i < n; ++i){
        if(arr[i] <= temp){
            ans++;
            temp = min(temp, arr[i]);
        }
    }
    cout << ans ;
}

Measured memory_bytes: 4752
n = gets.to_i
works = []
n.times do
  works << gets.split.map(&:to_i)
end
works = works.sort { |a, b| b[1] <=> a[1] }.reverse
first = 0
second = 0
res = "Yes"

works.each do |work|
  first += work[0]
  second = work[1]
  res = "No" if first > second
end

puts res

Measured memory_bytes: 19420
import java.util.*;

public class Main {
    static int[] a;
    static int[] b;
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) throws InterruptedException {
        while (true) {
            int n = scan.nextInt();
            int m = scan.nextInt();
            if(n == 0 && m == 0) break;
            solve(n, m);
        }
    }

    static void solve(int n, int m) {
        a = new int[n+1];
        b = new int[(n+1)*(n+1)];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                b[i* (n + 1) + j] = a[i] + a[j];
            }
        }
        Arrays.sort(b);
        int max = -1;
        for (int i = 0; i < b.length; i++) {
            if ( b[i] > m) break;
            int index = binarySEarch(b, m - b[i]);
            max =Math.max(max, b[i] + b[index]);
        }
        System.out.println(max);
    }

    static int binarySEarch(int[] a, int b) {
        int ok = 0;
        int ng = a.length;
        int mid = 0;

        while(ng - ok > 1) {
            mid = (ng + ok) / 2;
            if(a[mid] <= b) {
                ok = mid;
            }
            else {
                ng = mid;
            }
        }
        return ok;
    }
}



Measured memory_bytes: 57452
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int h; cin>>h;
        if(h == 0) return 0;

        vector<vector<int>> num(h+10, vector<int>(5, 0));
        for(int i=0; i<h; i++){
            for(int j=0; j<5; j++){
                cin>>num[i][j];
            }
        }

        int ans=0;
        while(1){
            int sum=0;
            for(int i=h-1; i>=0; i--){
                if(num[i][0] == num[i][1] && num[i][1] == num[i][2] && num[i][2] == num[i][3] && num[i][3] == num[i][4]){
                    sum += num[i][0] * 5;
                    num[i][0] = num[i][1] = num[i][2] = num[i][3] = num[i][4] = 0;
                }
                else if(num[i][0] == num[i][1] && num[i][1] == num[i][2] && num[i][2] == num[i][3]){
                    sum += num[i][0] * 4;
                    num[i][0] = num[i][1] = num[i][2] = num[i][3] = 0;
                }
                else if(num[i][1] == num[i][2] && num[i][2] == num[i][3] && num[i][3] == num[i][4]){
                    sum += num[i][1] * 4;
                    num[i][1] = num[i][2] = num[i][3] = num[i][4] = 0;
                }
                else if(num[i][0] == num[i][1] && num[i][1] == num[i][2]){
                    sum += num[i][0] * 3;
                    num[i][0] = num[i][1] = num[i][2] = 0;
                }
                else if(num[i][1] == num[i][2] && num[i][2] == num[i][3]){
                    sum += num[i][1] * 3;
                    num[i][1] = num[i][2] = num[i][3] = 0;
                }
                else if(num[i][2] == num[i][3] && num[i][3] == num[i][4]){
                    sum += num[i][2] * 3;
                    num[i][2] = num[i][3] = num[i][4] = 0;
                }
            }

            if(sum == 0) break;

            ans += sum;

            for(int i=0; i<5; i++){
                int height = h - 1;
                for(int j=h-1; j>=0; j--){
                    if(num[j][i] != 0){
                        num[height][i] = num[j][i];
                        if(height != j) num[j][i] = 0;
                        height--;
                    }
                }
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
int H,A;
cin>>H>>A;
if(H%A==0){
cout<<H/A<<endl;
}else{
  cout<<H/A+1<<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;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;

int main() {
    
    ll X,K,D;
    cin >> X >> K >> D;

    ll jo = abs(X)/D;
    ll amari = abs(X)%D;
    ll min = INF;

    if(K <= jo){
        min = abs(X)-(K*D);
    }
    else{
        if((K-jo)%2 == 1){
            min = abs(amari-D);
        }
        else{
            min = abs(amari);
        }
    }
    

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k) ans += p[i];
  cout << ans << endl;
  return 0;
}

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

using namespace std;


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

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


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


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

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

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

int main(){

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

    int x, y;
    cin >> x >> y;

    cout << x+y/2 << endl;



    return 0;
}


Measured memory_bytes: 256
"use strict"
function main(arg) {
    arg = arg.trim().split("\n")
    arg.shift()
    var data = arg
    data = data.map(e => {
        var row = e.split(" ").map(Number)
        return [row[0]-row[1], row[1]+row[0]]
    }).sort((a, b) => {
        return a[1] - b[1]
    })
    var sum = 0
    var P = -900000000000;
    var N = data.length
    for (var i=0; i<data.length; i++) {
        if (P <= data[i][0]) {
            sum++
            P = data[i][1]
        }
    }
    console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i, n) cin >> s[i] >> t[i];
  string x;
  cin >> x;

  int ans = 0;
  bool slp = false;
  rep(i, n) {
    if (slp) ans += t[i];
    if (s[i] == x) slp = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

vector<vector<Int> > bfs(vector<string> &s,Int dir){
  Int h=s.size(),w=s.front().size();
  vector<vector<Int> > dp(h,vector<Int>(w,-1));
  using P = pair<Int, Int>;
  queue<P> q;

  for(Int i=0;i<h;i++){    
    for(Int j=0;j<w;j++){
      if(s[i][j]=='#'){
        dp[i][j]=0;
        q.emplace(i,j);
      }
    }
  }
  
  Int dy[]={1,-1,0,0,1,1,-1,-1};
  Int dx[]={0,0,1,-1,1,-1,1,-1};
  auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};
  
  while(!q.empty()){
    Int y,x;
    tie(y,x)=q.front();q.pop();
    for(Int k=0;k<dir;k++){
      Int ny=y+dy[k],nx=x+dx[k];
      if(!in(ny,nx)) continue;
      if(~dp[ny][nx]) continue;
      dp[ny][nx]=dp[y][x]+1;
      q.emplace(ny,nx);
    }
  }
  
  return dp;
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];
  auto dp=bfs(st,4);
  Int ans=0;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      chmax(ans,dp[i][j]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 25524
// AOJ 2014: Surrounding Area
// 2017.10.1

#include <stdio.h>
#include <string.h>

typedef struct { int r, c; } Q;
Q q[2700]; int top;

char map[52][52]; int w, h;
char visited[50][52];

int mv[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };

void calc(int *sb, int *sw)
{
	int i, f, r, c, r1, c1, r2, c2, sum;

	*sb = *sw = 0;
	memset(visited, 0, sizeof(visited));
	for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
		if (map[r][c] != '.' || visited[r][c]) continue;

		f = 0, sum = 1, visited[r][c] = 1;
		q[0].r = r, q[0].c = c, top = 1;
		while (top > 0) {
			r1 = q[--top].r, c1 = q[top].c;
			for (i = 0; i < 4; i++) {
				r2 = r1 + mv[i][0], c2 = c1 + mv[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || visited[r2][c2]) continue;
				if      (map[r2][c2] == 'B') f |= 1;
				else if (map[r2][c2] == 'W') f |= 2;
				else {
					visited[r2][c2] = 1; sum++;
					q[top].r = r2, q[top++].c = c2;
				}
			}
		}
		if      (f == 1) *sb += sum;
		else if (f == 2) *sw += sum;
	}
}

int main()
{
	int r, c, sb, sw;

	while (scanf("%d%d", &w, &h) && w > 0) {
		for (sb = sw = 0, r = 0; r < h; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == 'B') sb++;
				else if (map[r][c] == 'W') sw++;
			}
		}
		if (!sb && !sw) puts("0 0");
		else if (!sb) printf("0 %d\n", w*h - sw);
		else if (!sw) printf("%d 0\n", w*h - sb);
		else { calc(&sb, &sw); printf("%d %d\n", sb, sw); }
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	if (n % 10 == 9) {
		cout << "Yes" << endl;
	}
	else if (n % 100 / 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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


int main(){
    ll n, l;
    cin >> n >> l;
    ll a[n];
    rep(i, n)   cin >> a[i];

    bool can = false;
    ll left = -1;
    rep(i, n-1){
        if(l <= a[i]+a[i+1]){
            can = true;
            left = i;
        }
    }
    cout << ((can)? "Possible":"Impossible") << endl;
    if(can){
        rep(i, left){
            cout << i+1 << endl;
        }
        for(ll i = n-2; left < i; i--){
            cout << i+1 << endl;
        }
        cout << left+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1536
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	min := math.MaxInt64
	for i := 0; i <= 100000; i++ {
		var acnt, bcnt, ccnt int
		ccnt = 2 * i
		if i < x {
			acnt = x - i
		}
		if i < y {
			bcnt = y - i
		}
		p := c*ccnt + a*acnt + b*bcnt
		if p < min {
			min = p
		}
	}

	fmt.Println(min)
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

bool is_prime(ll x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a;
    ll m=n;
    while(n!=1){
        if(is_prime(n)){
            a.push_back(n);
            break;
        }
        ll now,now2;
        for(ll i=2;i<n;i++){
            if(n%i==0){
                now=i;
                //cout << now << endl;
                break;
            }
        }
        now2=now;
        while(n%now==0){
            a.push_back(now2);
            now2*=now;
            n/=now;
        }
    }
    
    sort(a.begin(),a.end());
    
    for(ll i=0;i<a.size();i++){
        if(m%a[i]==0){
            ans++;
            m/=a[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}











Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, a[3][MAXN], c[MAXN];
bool b[MAXN], r[2], s[2];

inline void Ast(bool x)
{
	if (!x)
		puts("No"), exit(0);
}

inline void Modify(int x)
{
	for (; x <= n; x += x & -x)
		b[x] ^= 1;
}

inline bool Query(int x)
{
	bool r = 0;
	for (; x; x -= x & -x)
		r ^= b[x];
	return r;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 0; i < 3; i ++)
		for (int j = 1; j <= n; j ++)
			a[i][j] = Read();
	for (int i = 1; i <= n; i ++)
		if (a[0][i] > a[1][i])
		{
			Ast(a[2][i] % 3 == 1);
			Ast(a[1][i] == a[2][i] + 1);
			Ast(a[0][i] == a[1][i] + 1);
			c[i] = a[2][i] / 3;
			Ast((c[i] ^ i) & 1);
			c[i] ++;
			r[i & 1] ^= 1;
		}
		else
		{	
			Ast(a[0][i] % 3 == 1);
			Ast(a[1][i] == a[0][i] + 1);
			Ast(a[2][i] == a[1][i] + 1);
			c[i] = a[0][i] / 3;
			Ast((c[i] ^ i) & 1);
			c[i] ++;
		}
	for (int i = n - 1 + (n & 1); i > 0; i -= 2)
		s[1] ^= Query(c[i]), Modify(c[i]);
	mset(b, 0);
	for (int i = n - (n & 1); i > 0; i -= 2)
		s[0] ^= Query(c[i]), Modify(c[i]);
	Ast(s[0] == r[1] && s[1] == r[0]);
	return puts("Yes"), 0;
}


Measured memory_bytes: 1920
n, c, k = map(int, input().split())
arrivals = {}
for _ in range(n):
    t = int(input())
    if t in arrivals:
        arrivals[t] += 1
    else:
        arrivals[t] = 1
data = sorted(arrivals.keys())
ans = 0
current_bus_seats = c
bus_wait_from = data[0]
for time in data:
    ppl = arrivals[time]
    if current_bus_seats != c:
        if time - bus_wait_from > k:
            ans += 1
        else:
            if ppl <= current_bus_seats:
                current_bus_seats -= ppl
                continue
            else:
                ppl -= current_bus_seats
                ans += 1
    current_bus_seats = c
    bus_wait_from = time
    d, m = divmod(ppl, c)
    ans += d
    current_bus_seats -= m
if current_bus_seats < c:
    ans += 1
print(ans)



Measured memory_bytes: 15196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2 < k )
    {
        cout<<-1<<endl;
    }else
    {
        vector<pair<int,int>> ans;
        int now = (n-1)*(n-2)/2;
        for(int i=1;i<n;++i)
        {
            for(int j=i+1;j<n;++j)
            {
                if(now > k)
                {
                    now--;
                    ans.push_back({i,j});
                }else
                {
                    goto L;
                }
            }
        }
        L:
        cout<<ans.size() + n-1<<endl;
        for(int i=1;i<n;++i)
        {
            cout<<i<<" "<<n<<endl;
        }
        for(auto p:ans)
        {
            cout<<p.first<<" "<<p.second<<endl;
        }

    }
}

Measured memory_bytes: 384
N = int(input())
S = input()

maxlen = 0

for i in range(N):
	a = S[0:i+1]
	b = S[i+1:N]
	aset = set(a)
	bset = set(b)

	ans = aset & bset

	if len(ans) >= maxlen:
		maxlen = len(ans)

print(maxlen)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    string s, w;
    cin >> w;
    rep(i, w.size()) w[i] = tolower(w[i]);
    int cnt = 0;
    while( cin >> s ){
        if( s == "END_OF_TEXT" ) break;
        rep(i, s.size()) s[i] = tolower(s[i]);
        if( s == w ) cnt++;
    }
    cout << cnt << endl;
}

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " "); 
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    int sum = N * (L + (L + N - 1)) / 2;

    if (L * (L + N - 1) > 0) {
        if (abs(L) < abs(L+N-1)) {
            sum -= L;
        } else {
            sum -= (L+N-1);
        }
    }

    cout << sum << endl;

    return 0;
}


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

int main()
{
    unsigned long i, n;
    unsigned long long int sum = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
            //cout << i << "\n";
            sum = sum + i;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int,int> >a;
    rep(i,n){
        int tmp;
        cin >> tmp;
        pair<int,int>p=make_pair(tmp,i);
        a.push_back(p);
    }

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

    rep(i,n)
        cout << a[i].second+1 << " ";
    cout << "\n";
}

Measured memory_bytes: 1780
import sys

sys.setrecursionlimit(10 ** 5 + 5)


def omit(n, links, parents):
    q = [0]
    visited_f = [False] * n
    while q:
        v = q.pop()
        if visited_f[v]:
            continue
        visited_f[v] = True
        q.extend(u for u in links[v] if not visited_f[u])

    q = [n - 1]
    visited_b = [False] * n
    while q:
        v = q.pop()
        if visited_b[v]:
            continue
        visited_b[v] = True
        q.extend(u for u in parents[v] if not visited_b[u])

    remains = [i for i, (f, b) in enumerate(zip(visited_f, visited_b)) if f and b]
    sr = set(remains)
    for v in remains:
        links[v] &= sr

    return remains


n, m, p = list(map(int, input().split()))
INF = 10 ** 12
costs = [[INF] * n for _ in range(n)]
links = [set() for _ in range(n)]
parents = [set() for _ in range(n)]
for line in sys.stdin:
    a, b, c = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    parents[b].add(a)
    costs[a][b] = min(costs[a][b], p - c)
remains = omit(n, links, parents)

dist = [INF] * n
dist[0] = 0
for _ in range(n + 1):
    updated = False
    for v in remains:
        d = dist[v]
        if d == INF:
            continue
        cv = costs[v]
        for u in links[v]:
            if dist[u] > d + cv[u]:
                dist[u] = d + cv[u]
                updated = True
    # print(dist, updated)
    if not updated:
        break
else:
    print(-1)
    exit()

print(max(0, -dist[n - 1]))


Measured memory_bytes: 102108
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x1,y1,x2,y2 = LI()
X = y2 - y1
Y = x2 - x1
x3,y3 = x2-X, y2+Y
x4,y4 = x3-Y, y3-X
print(x3,y3,x4,y4)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N;

int C[4444],A[4444];

int pos[2][2222];

int sum[2][4444][2222];

int dp[2222][2222];

signed main(){
    cin>>N;
    rep(i,2*N){
        char c;
        cin>>c>>A[i];
        C[i]=c=='B';
        A[i]--;
        pos[C[i]][A[i]]=i;
        sum[C[i]][i+1][A[i]+1]++;
    }


    rep(k,2){
        rep(i,2*N+1){
            rep(j,N+1){
                sum[k][i+1][j+1]-=sum[k][i][j];
                sum[k][i][j+1]+=sum[k][i][j];
                sum[k][i+1][j]+=sum[k][i][j];
            }
        }
    }

    fill_n(*dp,2222*2222,INF);
    dp[0][0]=0;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(i<N){
                int p=pos[0][i];
                int cost=p-sum[0][p][i]-sum[1][p][j];
                chmin(dp[i+1][j],dp[i][j]+cost);
            }
            if(j<N){
                int p=pos[1][j];
                int cost=p-sum[0][p][i]-sum[1][p][j];
                chmin(dp[i][j+1],dp[i][j]+cost);
            }
        }
    }


    cout<<dp[N][N]<<endl;
    return 0;
}


Measured memory_bytes: 180608
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    long a, b, c, k;

    cin >> a >> b >> c >> k;
    long s = 0;
    vector<long> v(6, 0);
    v.at(0) = a;
    v.at(1) = 1;
    v.at(2) = b;
    v.at(3) = 0;
    v.at(4) = c;
    v.at(5) = -1;
    for (int i = 0; i < 6; i += 2)
    {
        if (k <= 0)
        {
            break;
        }
        if (v.at(i) <= k)
        {
            s += (v.at(i) * v.at(i + 1));
            k -= v.at(i);
        }
        else
        {
            s += (k * v.at(i + 1));
            k -= v.at(i);
        }
    }

    cout << s << endl;
    return 0;
}


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

bool calcEnd = false;
string acc = "";

void search7(string &s, string &ops, int target){
    if(calcEnd){
        return;
    }
    else{
        if(ops.size() == 3){
            int result = s[0] - '0';
            for(int i=0;i<3;i++){
                if(ops[i] == '+'){
                    result += (s[i+1] - '0');
                }
                else{
                    result -= (s[i+1] - '0');
                }
            }
            if(result == target){
                for(int i=0;i<3;i++){
                    acc += s[i];
                    acc += ops[i];
                }
                acc += s[3];
                acc += "=7";
                calcEnd = true;
            }
            return;
        }
        else{
            string plus = ops + '+';
            string minus = ops + '-';
            search7(s, plus, target);
            search7(s, minus, target);
        }
    }
    return;
}

int main(){
    string s;
    cin >> s;
    int target = 7;
    string ops = "";
    search7(s, ops, target);
    cout << acc << endl;
    return 0;
}

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

map<int,int> m;
vector<int> v;
int n,ans,x;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>x;
        if(m[x]==0) v.push_back(x);
        m[x]++;
    }
    for(int i=0;i<v.size();i++) 
	{
		if(m[v[i]]>=v[i]) 
			ans+=m[v[i]]-v[i]; 
		else 
			ans+=m[v[i]];
	}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
n = int(input())

taro_point = 0
hana_point = 0

for j in range(n):
    t, h = input().split()

    if t > h:
        taro_point += 3

    elif t < h:
        hana_point += 3

    else:
        taro_point += 1
        hana_point += 1

print(taro_point, hana_point)


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int L, R;
    cin >> L >> R;

    int m = 2019;
    for(int i=L; i<=R && i <= L+2019; i++){
        for(int j=i+1; j<=R && j <= L+2019; j++ ){
            int a1 = i % 2019;
            int a2 = j % 2019;
            int a3 = (a1 * a2) % 2019;
            m = min(m, a3);
        }
    }

    cout << m;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) scanf("%lld", a + i);

  ll total = N * (N + 1) / 2;
  ll sum = 0;
  for (int i = 0; i < N; i++) sum += a[i];

  string ans = "NO";
  if (sum % total == 0) {
    ll k = sum / total; // 操作を行う回数
    ll d[N];
    d[0] = (a[0] - a[N-1]) - k;
    for (int i = 1; i < N; i++) {
      d[i] = (a[i] - a[i-1]) - k;
    }

    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (d[i] <= 0 && d[i] % N == 0) continue;

      flag = false;
      break;
    }
    if (flag) ans = "YES";
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    int n, m, a, b, tot=0;
    cin >> n >> m;
    int h[n+1];
    int res[n+1];
    for(int i=1; i<=n; i++) res[i] = 0;
    for(int i=1; i<=n; i++) cin >> h[i];
    while(m--){
        cin >> a >> b;
        if(h[a]>h[b] && res[a]>=0) res[a]++;
        else res[a] = -1;
        if(h[a]<h[b] && res[b]>=0) res[b]++;
        else res[b] = -1;
    }
    for(int i=1; i<n+1; i++){
        if(res[i]>=0) tot++;
    }
    cout << tot << "\n";
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}



Measured memory_bytes: 5156
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N=110;
const int MAX_V=1010;
const int MAX_W=1e9+10;
const int inf = 1<<30;
int N, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N][MAX_N*MAX_V+1];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> N >> W;
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  fill(dp[0], dp[0]+MAX_N*MAX_V+1, inf);
  dp[0][0] = 0;

  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= MAX_N*MAX_V; j++) {
      if(j < v[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
    }
  }

  int res = 0;
  for(int i = 0; i <= MAX_N*MAX_V; i++) if(dp[N][i] <= W) res = i;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 45312