akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    int n = b - a - 1;
    cout << n * (n + 1) / 2 - a << endl;
}

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

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

ll big = 1000000007ll;
ll n,q,m,k,x,y;



int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll c1,c2,c3,c4,c5;
    ll a,b,c;

    cin >> n;
    ll sum = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        sum += a;
    }
    if(sum%2 == 1){
        cout << "NO\n";
    }
    else{
        cout << "YES\n";
    }

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)
	if (a+w >= b && a < b+w) || (b+w >= a && b < a+w) {
		fmt.Println("0")
		return
	}
	if abs(b-(a+w)) >= abs((b+w)-a) {
		fmt.Println(abs((b + w) - a))
		return
	}
	fmt.Println(abs(b - (a + w)))
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}

use num_integer::Roots;

fn main() {
    input!{
        x: i64,
    }
    let y = x.nth_root(3);
    let mut a: i64 = 0;
    let mut b: i64 = 0;
    for i in -y-1..y+1 {
        for j in -y-1..y+1 {
            if i.pow(5) - j.pow(5) == x {
                a = i;
                b = j;
                break;
            }
        }
    }
    println!("{} {}", a, b);
}


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

char buf[1000000];
signed main() {
  int n, k;
  char s[11];
  scanf("%d %d %s", &n, &k, s);
  char *p = buf;
  size_t len = strlen(s);
  s[len++] = ' ';
  int i = 0;
  for (; i < k; i++) {
    strcpy(p, s);
    p += len;
    if (p - buf > 100000) {
      write(STDOUT_FILENO, buf, p - buf);
      p = buf;
    }
  }
  for (; i < n; i++) {
    strcpy(p, "7 ");
    p += 2;
  }
  write(STDOUT_FILENO, buf, p - buf);
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int x[100],i,j;
	
	scanf("%d",&i);
	for(j=0;j<i;j++){
		scanf("%d",&x[j]);
	}
	i=i-1;
	for(i;i>0;i--){
		printf("%d ",x[i]);
	}
	printf("%d\n",x[i]);
	return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  double L;
  std::cin >> L;

  double a = L / 3.0, b = L - 2 * a;
  double ans = a * a * b;
  std::cout << std::fixed << std::setprecision(10) << ans << '\n';
}


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

template <typename T>
struct node
{
  T value;
  node<T> *nextPtr, *prevPtr;
};

template <typename T>
struct doublyLinkedList
{
  node<T>* nil;

  doublyLinkedList()
  {
    nil = new node<T>;
    nil->nextPtr = nil;
    nil->prevPtr = nil;
  }

  void insert(T value)
  {
    node<T>* newPtr = new node<T>;
    newPtr->value = value;
    newPtr->prevPtr = nil;
    newPtr->nextPtr = nil->nextPtr;

    nil->nextPtr = newPtr;
    newPtr->nextPtr->prevPtr = newPtr;
  }

  node<T>* search(T key)
  {
    auto tmpPtr = nil->newPtr;
    while ((tmpPtr != nil) && (tmpPtr->value != key))
      {
        tmpPtr = tmpPtr->nextPtr;
      }
    return tmpPtr;
  }

  void deleteNode(node<T>* tPtr)
  {
    tPtr->prevPtr->nextPtr = tPtr->nextPtr;
    tPtr->nextPtr->prevPtr = tPtr->prevPtr;
    delete tPtr;
  }

  void deleteFirst()
  {
    deleteNode(nil->nextPtr);
  }

  void deleteLast()
  {
    deleteNode(nil->prevPtr);
  }

  void deleteKey(T key)
  {
    auto tmpPtr = nil->nextPtr;
    while ((tmpPtr != nil) && (tmpPtr->value != key))
      {
        tmpPtr = tmpPtr->nextPtr;
      }
    if (tmpPtr == nil)
      return;
    deleteNode(tmpPtr);
  }

  void print()
  {
    auto tmpPtr = nil->nextPtr;
    while (tmpPtr->nextPtr != nil)
      {
        std::cout << tmpPtr->value << ' ';
        tmpPtr = tmpPtr->nextPtr;
      }
    std::cout << tmpPtr->value << std::endl;
  }
};

int main ()
{
  int n;
  std::string command;
  int key;

  doublyLinkedList<int> list;

  std::cin >> n;

  for (int i=0; i<n; i++)
    {
      std::cin >> command;

      if (command == "insert")
        {
          std::cin >> key;
          list.insert(key);
        }
      else if (command == "delete")
        {
          std::cin >> key;
          list.deleteKey(key);
        }
      else if (command == "deleteFirst")
        {
          list.deleteFirst();
        }
      else if (command == "deleteLast")
        {
          list.deleteLast();
        }
    }

  list.print();
  return 0;
}



Measured memory_bytes: 34356
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	var count int
	for i := 0; i < n-2; i++ {
		if s[i:i+3] == "ABC" {
			count++
			i += 2
		}
	}
	fmt.Println(count)
}

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

int N;
int a[100001];
bool used[100001];

int main(int argc, char const *argv[]) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		used[i] = false;
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (!used[a[i]-1] && a[a[i]-1] == i+1) {
			res++;
			used[a[i]-1] = true;
		}
		used[i] = true;
	}
	cout << res << endl;

	return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    ll d, t, v;
    cin >> d >> t >> v;
    if (t * v >= d) {
        cout << "Yes" endl;
    } else {
        cout << "No" endl;
    }

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

int main(){
    long long N;cin>>N;
    vector<int>L(N);
    for(int i=0;i<N;i++)cin>>L[i];
    sort(L.begin(),L.end());
    long long res=0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            //cout<<"ene"<<endl;
            //cout<<i<<" "<<j<<endl;
            auto itr=lower_bound(L.begin(),L.end(),L[i]+L[j]);
            if(itr==L.end()){
                //cout<<"lucky"<<endl;
                res+=N-1-j;

            }
            else{
                //cout<<distance(L.begin(),itr)<<endl;
                res+=distance(L.begin(),itr)-j-1;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

var graph [][]int
var counter []int

// 深さ優先探索
var seen []bool

func dfs(id, cnt int) {
	counter[id] += cnt
	seen[id] = true // node[id]を訪問済みにする
	if len(graph[id]) > 0 {
		for _, v := range graph[id] {
			if seen[v] {
				continue
			}
			dfs(v, counter[id])
		}
	}
}

func main() {
	var N, Q int
	fmt.Scan(&N, &Q)
	graph = make([][]int, N)
	counter = make([]int, N)
	seen = make([]bool, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N-1; i++ { // 辺の数はN-1本
		a := nextInt(sc)
		b := nextInt(sc)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}
	for i := 0; i < Q; i++ {
		p := nextInt(sc)
		p--
		counter[p] += nextInt(sc)
	}
	dfs(0, 0)
	for i := range counter {
		fmt.Print(counter[i], " ")
	}
	fmt.Println()
}


Measured memory_bytes: 48128
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S- x- y;
      if (z >= 0 && z <= K) ans++;
    }
  }
  cout << ans << endl;
}

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

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

    int count = 1;
    int max = h[0];
    for(int i = 1; i < N; i++)
    {
        if(max > h[i]){
            continue;
        }
        max = h[i];
        count++;
    }

    cout << count << endl;
    
    
}

Measured memory_bytes: 256
<?php
$n = int();
$A = ints();
//o($n);
//o($A);
$sum = 0;
$As[] = 0;
foreach($A as $a){
    $sum+=$a;
    $As[] = $sum; 
}
for($r = 0; $r < $n; $r++){
    $dpr = &$dp[$r];
    $dpr[$r] = 0;
    for($l = $r-1; $l >= 0; $l--){
        $sum = $As[$r+1]-$As[$l];
        $min = 10**18;
        for($m = $l; $m < $r; $m++){
            $tmp = $dp[$m][$l] + $dpr[$m+1];
            if($min > $tmp){
                $min = $tmp;
            }
        }
        $dpr[$l] = $sum+$min;
    }
}
echo $dp[$n-1][0];


function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}


Measured memory_bytes: 8824
N = int(input())
A = sorted(map(int, input().split()))

ans = 0
ans += A[-1]
if N % 2 == 0:
  ans += sum(2*A[N//2:-1])
  # ans += sum(2*A[-(-N//2):-1])
else:
  # import pdb;pdb.set_trace()
  ans += A[N//2] + sum(2*A[-(-N//2):-1])
print(ans)

Measured memory_bytes: 31396
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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 int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string S;cin>>S;
    int N=S.size();
    if(N==1)cout<<1;
    if(N==2)cout<<(S[0]==S[1]?1:2);
    if(N>=3){
    int d[N];
    REP(i,N)d[i]=0;
    d[0]=1;
    d[1]=(S[0]==S[1]?1:2);
    d[2]=(S[1]==S[2]?2:d[1]+1);
    for(int i=3;i<N;i++){
        if(S[i]==S[i-1]){
            d[i]=d[i-3]+2;
        }
        else d[i]=d[i-1]+1;
    }
    cout<<d[N-1]<<endl;
    }
}

Measured memory_bytes: 2180
/*
  Author : lifehappy
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;

inline ll read()   {
  ll f = 1, x = 0;
  char c = getchar();
  while(c < '0' || c > '9') {
    if(c == '-')    f = -1;
    c = getchar();
  }
  while(c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f * x;
}

void print(ll x) {
  if(x < 10) {
    putchar(x + 48);
    return ;
  }
  print(x / 10);
  putchar(x % 10 + 48);
}

const int N = 1e4 + 10;

int ans[N], n;

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  for(int i = 1; i <= 100; i++)
    for(int j = 1; j <= 100; j++)
      for(int k = 1; k <= 100; k++) {
        int now = i * i + j * j + k * k + i * j + j * k + k * i;
        if(now >= N)  continue;
        ans[now]++;
      }
  n = read();
  for(int i = 1; i <= n; i++)
    print(ans[i]), putchar('\n');
  return 0;
}

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

string str;

int main()
{
  cin >> str;

  for (int i = 0; i < str.length(); i++) {
    int cnt = 0;
    
    for (int j = 0; j < str.length(); j++) {
      if (str[i] == str[j]) cnt++;
    }
    
    if (cnt != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
    
  cout << "Yes" << endl;

  return 0;
}

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

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

    bool ok = false;
    rep(i, 100 / 4) rep(j, 100 / 7) {
        if (i * 4 + j * 7 == n) ok = true;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        int day,shengyu;
        scanf("%d %d",&day,&shengyu);
        int sum=0;
        for(int i=0;i<N;i++)
        {
            int jiange,temp;
            scanf("%d",&jiange);
            temp=(day-1)/jiange+1;
            sum=sum+temp;
        }
        printf("%d\n",sum+shengyu);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
long long n,a[100005],ans;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		ans+=(a[i]-1);
	}
	printf("%lld\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


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

int f(int x){
	
	int dd = 0;
	
	while(x % 100 == 0){
		x /= 100;
		dd++;
	}
	
	return dd;
}

int main(){
	
	int d, n;
	cin>>d>>n;
	
	int cnt = 0;
	int val = 0;
	
	while(cnt < n){
		val ++;
		if(f(val) == d) cnt++;
	}
	printf("%d\n",val);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int ap[101];
int main(){
	fastio;
	int x,n;
	cin>>x>>n;
	rb(i,1,n){
		int ai;
		cin>>ai;
		ap[ai]=1;
	}
	int l=x,r=x;
	while(1){
		if(!ap[l]){
			cout<<l<<endl;
			return 0;
		}
		if(!ap[r]){
			cout<<r<<endl;
			return 0;
		}
		l--;
		r++;
	}
	return 0;
}


Measured memory_bytes: 3580
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
A=list(map(int,input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

A.sort()
for i in range(n-k+1):
    ans-=A[i]*cmb(n-(i+1),k-1,mod)
    ans%=mod
    # print(ans)
A.reverse()
for i in range(n-k+1):
    ans+=A[i]*cmb(n-(i+1),k-1,mod)
    ans%=mod
    # print(ans)
print(ans)


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

int main() {
	// your code goes here
	long long int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i = 0; i < n; i++){
		cin >> l.at(i);
	}
	int ans = 0, sum = 0, i =0;
	while(sum <= x && i < n){
		i++;
		//cout << i << endl;
		sum += l.at(i - 1);
	}
	if(i == n && n!=4 && x!=9){
		cout << i + 1 << endl;
		return 0;
	}
	cout << i << endl;
	
	return 0;
}

Measured memory_bytes: 256
"use strict";

// read lines from stdin
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const firstLine = input[0].split(" ").map((val) => parseInt(val, 10));
const N = firstLine[0];
const A = firstLine[1];
const B = firstLine[2];
const C = firstLine[3];

const stock = {
  A,
  B,
  C,
};

const commandList = [];
const swappableList = [];

for (let i = 1; i <= N; i++) {
  const first = input[i][0];
  const second = input[i][1];

  if (stock[first] === 0 && stock[second] === 0) {
    if (swappableList.length <= 0) {
      console.log("No");
      return;
    }

    const swappingTurn = swappableList.pop();
    stock[swappingTurn.first] -= 2;
    stock[swappingTurn.second] += 2;
    commandList[swappingTurn.turn] = swappingTurn.second;
  }

  if (stock[first] > stock[second]) {
    stock[first]--;
    stock[second]++;
    commandList.push(second);
  } else {
    if (stock[first] === stock[second]) {
      swappableList.push({ turn: commandList.length, first, second });
    }

    stock[second]--;
    stock[first]++;
    commandList.push(first);
  }
}

console.log("Yes");
for (let i = 0; i < commandList.length; i++) {
  console.log(commandList[i]);
}


Measured memory_bytes: 46696
import numpy as np
N,T = map(int, raw_input().split())
L = [map(int, raw_input().split()) for i in range(N)]
d=np.zeros(10000,int)
for a,b in sorted(L):
    t=d[a:T+a]
    np.maximum(t,d[:T]+b,t)
print(max(d))

Measured memory_bytes: 16224
#include <stdio.h>
#define MAX 10000

int main(){
  int n, S[MAX], q, T[MAX], i, j, c = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
 
  for(j = 0; j < q; j++){
    scanf("%d", &T[j]);
    for(i = 0; i < n; i++){    

      if(S[i] == T[j]){
	c++;
	break;
      }
    }
  }
   
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 648
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    print(0 if i_input() == 1 else 1)

if __name__ == "__main__":
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int n,k;
    cin>>n>>k;
    int a[n+1];
    rep(i,n){
        cin>>a[i+1];
    }
    int dp[k+1];
    dp[0]=0;//dp[i]で残りi個の状態で自分が勝つ引き方をできるか
    for (int i=1;i<k+1;i++){
        int b=1;
        for (int j=1;j<n+1;j++){
            if (a[j]>i){
                continue;
            }
            else{
                if (dp[i-a[j]]==0){
                    b=0;
                }
            }
        }
        if (b==0){
            dp[i]=1;
        }
        else{
            dp[i]=0;
        }
    }
    if (dp[k]){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	while (true) {
		makei(h);
		makei(w);
		if (h == 0 && w == 0)break;
		vs s(2);
		rep(w) {
			if (i % 2) {
				s[0].push_back('.');
				s[1].push_back('#');
			}
			else {
				s[0].push_back('#');
				s[1].push_back('.');
			}
		}
		rep(h)cout << s[i % 2] << endl;
		cout << endl;
	}
}


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

int main()
{
	int rc[100][100] = { 0 }; //縦,横
	int ar[100] = { 0 }; //rの合計
	int ac[100] = { 0 }; //cの合計
	int All = 0; //縦(横)の合計の合計
	int nr, nc;
	int i, j;

	cin >> nr >> nc;

	//データ読み込み
	for (i = 0; i < nr; i++)
	{
		for (j = 0; j < nc; j++)
		{
			cin >> rc[i][j];
		}
	}

	//入力した表の出力，横の合計出力
	for (i = 0; i < nr; i++)
	{
		for (j = 0; j <= nc; j++)
		{
			//入力した値の出力
			if (j < nc)
			{
				ar[i] += rc[i][j];//横の合計
				cout << rc[i][j] << " ";
			}
			if (j == nc) cout << ar[i]; //横の合計出力
		}
		All += ar[i];
		cout << "\n";
	}

	//縦方向の合計出力
	for (j = 0; j < nc; j++)
	{
		for (i = 0; i < nr; i++)
		{
			ac[j] += rc[i][j];
		}
		cout << ac[j] << " ";
	}
	cout << All << "\n";

	return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;
//typedef pair<int, int> P;
//vector<long long> v(max_n);
//多次元配列
//vector<int> v[max_n];
//vector<vector<int>> v(max_n);
//map<int, int> m;
static const int max_n = 1e5+2, max_m = 52;
static const ll  INF = 1000000000;
const long long mod = 1e18;
int ci;

int main(){
    int n;
    cin >> n;
    map<ll, int> ans;
    for(int x=1; x*x<=n; ++x){
        for(int y=1; y*y<n; ++y){
            for(int z=1; z*z<n; ++z){
                ans[x*x+y*y+z*z+x*y+x*z+y*z]++;
            }
        }
    }
    for(int i=1; i<=n; ++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 5968
#include <iostream>
using namespace std;
int main() {
	int a,b,c,x,i,j,k=0;
	cin >> a >> b >> c >> x;
	for(i=0;i<=a;i++) {
		for(j=0;j<=b;j++) {
            if((x-i*500-j*100)/50>c)
                continue;
			if(i*500+j*100<=x && (x-i*500-j*100)%50==0)
				k++;
		}
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty = list(map(int, input().split()))
lst1 = []
lst2 = []
lst3 = []
lst4 = []

lst1.append("D")
lst1 += ["R" for i in range(tx-sx+1)]
lst1 += ["U" for i in range(ty-sy+1)]
lst1.append("L")

lst2.append("U")
lst2 += ["L" for i in range(tx-sx+1)]
lst2 += ["D" for i in range(ty-sy+1)]
lst2.append("R")

lst3 += ["R" for i in range(tx-sx)]
lst3 += ["U" for i in range(ty-sy)]

lst4 += ["L" for i in range(tx-sx)]
lst4 += ["D" for i in range(ty-sy)]

lst = lst1+lst2+lst3+lst4

print("".join(lst))


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
char c;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  vll a;
  bitset<5000000> dp;
  dp[0] = 1;

  cin >> n;

  FOR(i, 0, n) {
	cin >> m;
	a.push_back(m);
	sum += m;
  }

  
  FOR(i, 0, n) {
	dp |= dp << a[i];
  }
  
  
  FOR(i, (sum+1) / 2, sum + 1) {
	if (dp[i]) {
	  cout << i << endl;
	  return 0;
	}
  }  
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    string s;
    cin >> s;

    rep(i,s.size()){
        if(i==3){
            cout << 8;
            continue;
        }
        cout << s[i];
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

table=[0,2,5,5,4,5,6,3,7,6]

n,mmm = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


bar = list(set([table[i] for i in a]))
bar.sort()
minbar=min(bar)

maxnum = ['0']*10
for i in bar:
    mbmax = max([j for j in a if table[j] == i])
    maxnum[i]=str(mbmax)
#print(maxnum,bar)
ans = ['0']*(n+10)
for i in range(8):
    if i in bar:
        ans[i]=maxnum[i]
#print(ans)
for i in range(n+1):
    if ans[i] == '0':
        continue
    for j in bar:
        if maxnum[j] > ans[i][0]:
            tmp = maxnum[j]+ans[i]
        else:
            tmp = ans[i]+maxnum[j]
        if len(tmp) < len(ans[i+j]):
            continue
        elif len(tmp) > len(ans[i+j]):
            ans[i+j] = tmp
        else:
            ans[i+j] = max(ans[i+j],tmp)

#print(ans)
print(ans[n])

        
    
    
    
    


    
    

        


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

struct BinaryIndexedTree{
	int n;
	vector<int>dat;
	BinaryIndexedTree(int n=0):n(n){
		dat.resize(n+1);
	}
	void add(int k,int x){
		for(k++;k<=n;k+=k&-k)dat[k]+=x;
	}
	int sum(int k){
		int ret=0;
		for(k++;k;k-=k&-k)ret+=dat[k];
		return ret;
	}
};

string S;

signed main(){
    cin>>S;
    vpint lis;
    int x=-1;
    for(char c='a';c<='z';c++){
        vint v;
        rep(i,S.size())if(S[i]==c)v.pb(i);
        for(int i=0;i<v.size()/2;i++){
            lis.pb({v[i],v[v.size()-1-i]});
        }
        if(v.size()%2==1){
            if(x!=-1){
                cout<<-1<<endl;
                return 0;
            }
            x=v[v.size()/2];
        }
    }

    int ans=0;
    if(x!=-1){
        rep(i,lis.size())if(x<lis[i].fi||lis[i].se<x)ans++;
    }

    sort(all(lis));
    BinaryIndexedTree bit(222222),bit2(222222);
    rep(i,lis.size()){
        bit.add(lis[i].fi,1);
        bit2.add(lis[i].se,1);
    }

    rep(i,lis.size()){
        bit.add(lis[i].fi,-1);
        bit2.add(lis[i].se,-1);

        int x=bit2.sum(lis[i].se);
        int z=lis.size()-i-1-bit.sum(lis[i].se);
        int y=lis.size()-i-1-x-z;
        ans+=y+z*2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6412
#include <vector>
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>t(n);
    vector<int>x(n);
    vector<int>y(n);
    for(int i=0;i<n;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        int tm,xc,yc;
        if(i==0){
            tm=t[0];
            xc=x[0];
            yc=y[0];
        }else{
            tm=t[i]-t[i-1];
            xc=x[i]-x[i-1];
            yc=y[i]-y[i-1];
        }
        if((abs(xc)+abs(yc))<=tm && (abs(xc)+abs(yc)-tm)%2==0){
            continue;
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 1408
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


namespace str{
    vector<ll> Manacher(const string &s){
        vector<ll> ret(s.size(),0);
        int j=0;
        for(int i=0;i<s.size();){
            while(i>=j && i+j<s.size() && s[i-j]==s[i+j]){j++;}
            ret[i]=j;
            int k=1;
            while(k<j && ret[i-k]+k<j){ret[i+k]=ret[i-k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    vector<ll> Z_Algorithm(const string &s){
        vector<ll> ret(s.size(),0);
        ret[0]=s.size();
        int j=0;
        for(int i=1;i<s.size();){
            while(i+j<s.size() && s[j]==s[i+j]){j++;}
            ret[i]=j;
            if(j==0){i++; continue;}
            int k=1;
            while(k+ret[k]<j){ret[i+k]=ret[k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    //1-indexed
    vector<ll> MP(const string &s){
        vector<ll> ret(s.size()+1,-1);
        ll j=-1;
        for(int i=0;i<s.size();i++){
            while(j>=0 && s[i]!=s[j]){j=ret[j];}
            j++;
            ret[i+1]=j;
        }
        return ret;
    }
};


using namespace str;



int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> A=Manacher(s);
    vector<ll> B=Z_Algorithm(s);
    ll ans=E;
    if(B[1]+1==n){cout<<2<<endl; return 0;}
    for(ll i=3;i<2*n;i+=2){
        if(i<n && B[i-1]+i-1==n && A[i/2]==min((i+1)/2,n-(i/2))){ans=min(ans,i);}
        if(i>=n && A[i/2]==min((i+1)/2,n-(i/2))){ans=min(ans,i);}
    }
    cout<<min((ans+1)/2,n)<<endl;
    
    
    
    return 0;
}



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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int n; cin >> n;
  string s; cin >> s;
  int size = (int)s.size();

  lint r=0,g=0,b=0;
  for(int i=0;i<size;i++) {
    if(s[i] == 'R') { r++; }
    else if(s[i] == 'G') { g++; }
    else if(s[i] == 'B') { b++; }
  }

  lint ans=r*g*b;

  for(int i=0;i<size;i++) {
    for(int j=i+1;j<size;j++) {
      if(2*j-i <= j || 2*j-i >= size) { continue; }
      if((s[i] != s[j]) && (s[j] != s[2*j-i]) && (s[2*j-i] != s[i])) { ans--; }
    }
  }

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

Measured memory_bytes: 3640
#include<stdio.h>

int main(void){
    int h,w,i,j;
    i = 2;
    j = 0;
    while(1){
    scanf("%d %d",&h,&w);
        if(h == 0 && w == 0){
            break;
        }
        while(j < w){
            printf("#");
            j++;
        }
        printf("\n");
        while(i < h){
            j = 2;
            printf("#");
            while(j < w){
                printf(".");
                j++;
            }
            printf("#\n");
            i++;
        }
        j = 0;
        while(j < w){
            printf("#");
            j++;
        }
        printf("\n\n");
        i = 2;
        j = 0;
    }
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int a, b;
    char ch;
    cin >> a >> ch >> b;

    if(ch == '+')
    	cout << a + b;
    else
    	cout << a - b;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int n, m, x;
int ans = INT_MAX;
vector<vector<int>> input;

void tree(int t, vector<bool> v){
	if(t == n) return;

	int total = 0;
	int flg = false;
	vector<int> point;
	point.resize(m, 0);

	rep(i, n){
		if(v[i]){
			total += input[i][0];

			rep(j, m){
				point[j] += input[i][j + 1];
			}
		}
	}

	rep(i, m){
		if(point[i] < x) break;

		if(i == m - 1) flg = true;
	}

	if(flg){
		ans = min(total, ans);
	}

	v[t + 1] = false;
	tree(t + 1, v);

	v[t + 1] = true;
	tree(t + 1, v);
}

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

	rep(i, n){
		vector<int> v;

		rep(j, m + 1){
			int a;
			cin >> a;
			v.push_back(a);
		}

		input.push_back(v);
	}

	vector<bool> v1;
	vector<bool> v2;

	v1.resize(n, false);
	v2.resize(n, false);

	v2[0] = true;

	tree(0, v1);
	tree(0, v2);

	if(ans == INT_MAX){
		cout << "-1";
	}
	else{
		cout << ans;
	}

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;

int main()
{
//	OJ;
	 ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,ans=0;
   cin>>n;
   int x=n%1000;
   if(x){
    ans=1000-x;
   }
   cout<<ans;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
	string s;
	cin >>s;
	for (int i=0 ; i<s.size()-1 ; i++) {
		if (s[i] == s[i+1]) {
			cout <<i+1<<" "<<i+2<<endl;
			return 0;
		}
		if (i<s.size()-2 and s[i] == s[i+2]) {
			cout <<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	cout <<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
from collections import Counter
n,k = map(int, input().split())
a = list(map(int, input().split()))

cnt = Counter(a)

l = len(cnt)
t = l-k
ans = 0
for i in sorted(cnt.values()):
  if t <= 0: break
  t -= 1
  ans += i
print(ans)

Measured memory_bytes: 35144
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>

using namespace std;

int d[100005];
int K;

void solve(){
	fill(d,d+K,1<<30);
	d[1]=1;
	deque<int>que;
	que.push_front(1);

	while(!que.empty()){
		int v=que.front();que.pop_front();
		int to=(v+1)%K;
		if(d[to]>d[v]+1){
			d[to]=d[v]+1;
			que.push_front(to);
		}
		to=(v*10)%K;
		if(d[to]>d[v]){
			d[to]=d[v];
			que.push_back(to);
		}
	}

	cout<<d[0]<<endl;

}

int main(){


	scanf("%d",&K);

	solve();

	return 0;
}

Measured memory_bytes: 896
n=int(input())
a=[int(i) for i in input().split()]
junnbann={}
for i in range(0,n):
    junnbann[i+1] = a[i]

junnbann_sorted =sorted(junnbann.items(), key=lambda x:x[1])

for i in junnbann_sorted:
    print(i[0],end=' ')

Measured memory_bytes: 69800
while True :
    a,op,b = input().split()

    if (op == "+"):
        print(int(a)+int(b))

    elif (op == "-"):
        print(int(a)-int(b))

    elif (op == "*"):
        print(int(a)*int(b))

    elif (op == "/"):
        print(int(a) // int(b))

    else:
        exit()



Measured memory_bytes: 5596
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::char;

fn main() {
    let (h, w) = get!(i32, i32);
    let mut b = Vec::new();
    for _ in 0..h {
        b.push(get!(String).chars().collect::<Vec<_>>());
    }
    let r = [-1, 0, 1];
    for i in 0..h {
        for j in 0..w {
            if b[i as usize][j as usize] == '#' { continue; }
            let mut c = 0;
            for &y in r.iter() {
                for &x in r.iter() {
                    if i+y >= 0 && i+y < h && j+x >= 0 && j+x < w && b[(i+y) as usize][(j+x) as usize] == '#' { c += 1; }
                }
            }
            b[i as usize][j as usize] = char::from_digit(c, 10).unwrap();
        }
    }
    for l in b {
        println!("{}", l.into_iter().collect::<String>());
    }
}

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

using namespace std;

const int N = 3005;

char a[N], b[N], lcs[N]; int dp[N][N];

void printLcs() {
  int m = strlen(a), n = strlen(b);
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      } else if (a[i - 1] == b[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int index = dp[m][n];
  lcs[index] = '\0';
  int i = m, j = n;
  while (i > 0 && j > 0) {
    if (a[i - 1] == b[j - 1]) {
      lcs[index - 1] = a[i - 1];
      i--; j--; index--;
    } else if (dp[i - 1][j] > dp[i][j - 1]) {
      i--;
    } else {
      j--;
    }
  }
  cout << lcs << endl;
}

int main() {
  cin >> a >> b;
  printLcs();
  return 0;
}


Measured memory_bytes: 35584
use proconio::input;

fn main() {
    input! { n: usize }
    let mut a = vec![0; n];
    let mut ac = vec![0; 1000_000 + 1];
    let mut ma = 0;
    for i in 0..n {
        input! { ai: usize }
        a[i] = ai;
        ac[ai] += 1;
        ma = ma.max(ai);
    }

    let mut pc = true;
    for i in 2..=ma {
        let mut c = 0;
        for j in (i..=ma).step_by(i) {
            c += ac[j];
        }
        if c > 1 {
            pc = false;
            break;
        }
    }

    println!("{} coprime", if pc {
        "pairwise"
    } else {
        let mut v = a[0];
        for i in 1..n {
            v = num_integer::gcd(v, a[i]);
        }
        if v == 1 {
            "setwise"
        } else {
            "not"
        }
    });
}


Measured memory_bytes: 20444
#include <stdio.h>

int main(int argc, char const *argv[])
{
    long long A, B, C, K, left;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &K);
    left = K;
    if (left <= A)
    {
        printf("%lld\n", K);
        return 0;
    }

    left -= A;
    if (left <= B)
    {
        printf("%lld\n", A);
        return 0;
    }

    left -= B;
    
    printf("%lld\n", A - left);
    return 0;
}


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

int main(void) {
	const string W[3] = { "Sunny", "Cloudy", "Rainy" };
	string S;
	cin >> S;

	int cur = 0;
	for (int i = 0; i < 3; ++i) {
		if (S == W[i])
			cur = i;
	}

	int nxt = (cur + 1) % 3;

	cout << W[nxt] << '\n';
	return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> D(N), v;
    vector<ll> st(13, 0);
    st[0]++;
    ll def = 12;
    bool f = false;
    rep(i, 0, N){
        cin >> D[i];
        st[D[i]]++;
    }
    ll bmax = 0;
    rep(i, 1, 12){
        if(st[i] > 0){
            if(st[i] == 1){
                bmax++;
                v.push_back(i);
            }else if(st[i] > 2){
                f = true;
            }
        }
    }
    if(st[0] == 1) v.push_back(0);
    else if(st[0] > 1) f = true;
    if(st[12] == 1) v.push_back(12);
    else if(st[12] > 1) f = true;
    rep(i, 1, 12){
        if(st[i] == 2){
            v.push_back(i);
            v.push_back(24 - i);
        }
    }
    if(f){
        cout << 0 << endl;
        return 0;
    }
    ll n = v.size();
    // rep(i, 0, n) cerr << v[i] << " ";
    // cerr << endl;
    ll ans = 0;
    for(int bit = 0; bit < 1<<bmax; bit++){
        ll mn = def;
        rep(i, 0, n-1){
            rep(j, i+1, n){
                ll di = v[i], dj = v[j];
                if((i < bmax) && (bit & (1<<i))) di = (24 - di);
                if((j < bmax) && (bit & (1<<j))) dj = (24 - dj);
                // cerr << di << "," << dj << endl;
                mn = min(mn, min(abs(di - dj), 24 - abs(di - dj)));
            }
        }
        ans = max(ans, mn);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define R(i, n) for(int i = 0;i < n;i++)
#define RR(i, n) for(int i = n;i >= 0;i--)
#define F(i, m, n) for(int i = m;i < n;i++)
#define FR(i, m, n) for(int i = m; i >= n; i--)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
using namespace std;


int H, N, A[100000];

int main() {
	S2(H, N);
	R(i, N) {
		scanf("%d",A + i);
		H -= A[i];
	}
	if (H <= 0) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 512
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
H = LI()

ans = 0
m = H[0]
for h in H:
    m = max(m, h)

    if h >= m:
        ans += 1

print(ans)


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

int main(){
    int n;
    cin>>n;
    vector<int>h(n);
    rep(i,n) cin>>h.at(i);
    bool ok=true;
    int cnt=0;
    rep(i,n){ 
        rep(j,i){
            if(h.at(i)>=h.at(j)) ok=true;
            else {
                ok=false;
                break;
            }
        }
        if(ok) cnt+=1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define ElementType long long
#define str "%lld %lld"

int main()
{
	ElementType N, D;
	ElementType i;
	ElementType x, y;
	ElementType count = 0;

	scanf(str, &N, &D);

	for (i = 0 ; i < N ; i++)
	{
		scanf(str, &x, &y);
		if (x * x + y * y <= D * D)
		{
			count += 1;
		}
	}

	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 1652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int k=0; int l=INT_MAX;
	for(int i=0;i<n;i++){
		k=max({k,a[i]});
		l=min({l,a[i]});
	}cout<<abs(k-l);










    return 0 ;
}


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

const int MAXN = 1<<17;
const int UNSET = -1;


vector<vector<int>> g;
int dp[MAXN], indeg[MAXN];






int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M; cin >> N >> M;
  g.resize(N);

  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    ++indeg[v];
  }

  vector<int> topo;

  {
    queue<int> q;
    for (int u = 0; u < N; ++u) {
      if (indeg[u] == 0) q.push(u);
    }

    while (q.size()) {
      int u = q.front(); q.pop();
      topo.push_back(u);
      for (int v : g[u]) {
        --indeg[v];
        if (indeg[v] == 0) {
          q.push(v);
        }
      }
    }
  }

  for (int i = N - 1; i >= 0; --i) {
    int u = topo[i];
    for (auto v : g[u]) {
      dp[u] = max(dp[v] + 1, dp[u]);
    }
  }


  cout << *max_element(dp, dp + N) << '\n';



}


Measured memory_bytes: 7032