akhauriyash/Code-Regression huggingface dataset:
from itertools import product
import heapq

N = int(input())

list_N = list(range(1, int((N + 1)**0.5)))

list_xyz = list(product(list_N, repeat=3))

ans_list = [x**2 + y**2 + z ** 2 + x*y + y*z + x * z for x, y ,z in list_xyz]
heapq.heapify(ans_list)
for n in range(1, N+1):
    ans = 0
    while True:
        if len(ans_list) < 1:
            break
        tmp = heapq.heappop(ans_list)
        if tmp == n:
            ans += 1
        elif tmp > n:
            heapq.heappush(ans_list, tmp)
            break
        
    print(ans)

Measured memory_bytes: 117072
#include <bits/stdc++.h>
#define pvar(x) clog << "[" << #x << ":" << x << "]\n"
using namespace std;
using ll = long long int;
void solve() {
  int h, w, m, h1, w1;
  cin >> h >> w >> m;
  int mr = 0, mc = 0;
  map<int, int> r, c;
  set<pair<int, int>> s;
  for (int i = 0; i < m; i++) {
    cin >> h1 >> w1;
    r[h1]++, c[w1]++;
    mr = max(mr,r[h1]);
    mc = max(mc,c[w1]);
    s.insert({h1, w1});
  }
  set<int> row,col;
  for (auto i : r) {
    if (mr == i.second) {
      row.insert(i.first);
    }
  }
  for (auto i : c) {
    if (mc == i.second) {
      col.insert(i.first);
    }
  }
  
  for(auto i : row){
  	for(auto j : col){
  		if(s.find({i,j}) == s.end()){
  			cout<<mr+mc<<endl;
  			return;
  		}
  	}
  }

cout<<mr+mc-1<<endl; 
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}


Measured memory_bytes: 73928
#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 = 1001001001;

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

    int ans = N * (N-1) / 2 + M * (M-1) / 2;

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


Measured memory_bytes: 256
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
	int num;
	// 入力numを受け取る
	scanf("%d", &num);

	// num % 10で1の位を取得する
	// switch文で1の位の値に応じてnum本の本の読み方を出力する
	switch(num % 10){
		case 2: case 4: case 5: case 7: case 9:
			printf("hon");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon");
			break;
		default:
			printf("bon");
	}

	return 0;
}


Measured memory_bytes: 1720
#include "bits/stdc++.h"
using namespace std;

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

    if (A % 2 == 0 || B % 2 == 0) {
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }

}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, yin;
  cin >> n >> yin;
  yin /= 1000;
  if (n > yin)
  {
    cout << "-1 -1 -1";
    return;
  }

  // 10x + 5y + z = Y
  // x + y + z = n
  for(int x = 0; x <= yin/10 + 1; ++x)
  {
    for(int y = 0; y <= yin/5 + 1; ++y)
    {
      int z = n - x - y;
      if (z < 0) continue;
      if (10 * x + 5 * y + z == yin)
      {
        cout << x << " " << y << " " << z;
        return;
      }
    }
  }
  cout << "-1 -1 -1";

  /*
  set<ll> hash;
  queue<tuple<ll, ll, ll>> que;
  if (n <= y / 10) que.emplace(y / 10, 0, y - (y / 10) * 10);
  else if (n <= y / 5) que.emplace(0, y / 5, y - ((y / 5) * 5));
  else que.emplace(0, 0, y);

  while(!que.empty())
  {
    ll x, y, z;
    tie(x, y, z) = que.front();
    que.pop();

    ll hv = (x << 40LL) + (y << 20LL) + z;
    if (hash.find(hv) != hash.end()) continue;
    hash.insert(hv);

    if (x + y + z < n) continue;
    if (x + y + z == n)
    {
      cout << x << " " << y << " " << z;
      return;
    }
    if (z >= 5)
    {
      que.emplace(x, y + 1, z - 5);
    }
    if (z >= 10)
    {
      que.emplace(x + 1, y, z - 10);
    }
    if (y >= 2)
    {
      que.emplace(x + 1, y - 2, z);
    }
  }
  cout << "-1 -1 -1";
  */
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
import java.util.*;

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

        int m = sc.nextInt();
        int d = sc.nextInt();

        int cnt = 0;

        for (int i=1; i<=m; i++){
            for (int j=22; j<=d; j++){
                int d10 = j/10;
                int d1 = j%10;
                if ((i == d10 * d1) && (d1 >= 2)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int A, P; cin >> A >> P;
        cout << (A *3 + P) / 2 << endl;
        return 0;
    }
};

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


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

int main() {
	vector<int> l, r;
	int n, m, i, upper, lower;

	cin >> n >> m;
	l.assign(m, 0);
	r.assign(m, 0);
	for (i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
	}
	upper = *min_element(r.begin(), r.end());
	lower = *max_element(l.begin(), l.end());

	cout << max((min(upper, n) - lower)+1,0) << endl;
}

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


int main()
{
    long long int n, v = 0, ans = 0;
    cin >> n;
    vector<tuple<long long int,long long int,long long int>> a(n);
    for(long long int i = 0;i < n;i++){
        cin >> get<1>(a[i]);
    } 
    for(long long int i = 0;i < n;i++){
        cin >> get<2>(a[i]);
        get<0>(a[i]) = get<1>(a[i]) - get<2>(a[i]);
        get<0>(a[i]) *= -1;
    }

    sort(a.begin(),a.end());
    for(long long int i = 0;i < n;i++){
        get<0>(a[i]) *= -1;
        if(get<1>(a[i]) < get<2>(a[i])){
            v += get<2>(a[i]) - get<1>(a[i]);
            ans++;
        }
    }
    for(long long int i = 0;i < n;i++){
        if(v <= 0){
            break;
        }

        if(get<0>(a[i]) > 0){
            v -= get<0>(a[i]);
            ans++;
        }
    }

    if(v > 0){
        cout << -1;
    }
    else{
        cout << ans;
    }

    return 0;
}

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

int main() {
  int n;
  scanf("%d",&n);
  if(n<10){
      printf("%d",n);
  }else if(n<100){
      printf("9");
  }else if (n<1000){
      printf("%d",n-90);
  }else if(n<10000){
      printf("909");
  }else if(n<100000){
      printf("%d", n-9090);
  }else{
      printf("90909");
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main() {
	ll n, m;
	string s, t;
	cin >> n;
	if (n == 1)
	{
		cout << "Hello World\n";
	}
	else {
		cin >> n >> m;
		cout << n + m << endl;
	}
	return 0;
}


Measured memory_bytes: 256
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
    s: chars,
    ik: usize,
    }
    let n = s.len();
    let s = s.iter().map(|x| x.to_digit(10).unwrap() as usize).collect::<Vec<usize>>();
    let mut dp = vec![vec![vec![0;2];4]; 105];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..4 {
            for k in 0..2 {
                let nd = s[i];
                for d in 0..10 {
                    let (ni,mut nj, mut nk) = (i + 1, j, k);
                    if d != 0 {nj+=1}
                    if nj > ik {continue}
                    if k == 0 {
                        if d > nd {continue}
                        if d < nd {nk = 1};
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    let ans = dp[n][ik][0] + dp[n][ik][1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

 
int main()
{
   string t;
   cin>>t;
  ll  sum=0;
   ll  h=0,h1=0;
   for(int i=0;i<t.size();)
   {

    if(t[i]=='<')
    {  h=0;
     while(t[i]=='<')
     {
        h=h+1;
        i++;
        if(i==t.size())
            break;
     }
    
    if(i==t.size())
 sum=sum+((h+1)*(h))/2;        
        else

     sum=sum+((h-1)*(h))/2;
     
    }

    if(t[i]=='>')
    {   h1=0;
       while(t[i]=='>')
     { 
        h1++;  
        i++;
        if(i==t.size())
            break;
     }
        
     sum=sum+((h1-1)*(h1))/2+max(h,h1);
        
    }

   }

   cout<<sum<<"\n";
   
}

Measured memory_bytes: 900
def F(A,B):
  A=str(A)
  B=str(B)
  return max(len(A),len(B))

N=int(input())
M=int(N**0.5)
v=100000
for i in range(1,M+1):
  if N%i==0:
    j=int(N/i)
    if v>F(i,j):
      v=F(i,j)
    

if v==100000:
  v=len(str(N))
print(v)

Measured memory_bytes: 3060
import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc=new Scanner (System.in);
int n=sc.nextInt();
int a[]=new int[n];
int b[]=new int[n];
int c[]=new int[n-1];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
for(int i=0;i<n;i++)
b[i]=sc.nextInt();
for(int i=0;i<n-1;i++)
c[i]=sc.nextInt();
long ans=0;
for(int i=0;i<n;i++)
{
if(i==0)
ans+=b[a[i]-1];
else
{
if(a[i]==a[i-1]+1)
{
ans+=b[a[i]-1]+c[a[i-1]-1];
//System.out.println(ans);
}
else {
ans+=b[a[i]-1];
//System.out.println(ans+" 2");
}
}
}
System.out.println(ans);
}
}


Measured memory_bytes: 23124
import math

A, B , H , M = list(map(int,input().split()))

hun = 60* H + M 
kaku= min (360-(5.5)*hun , 5.5*hun)

a= math.cos(math.radians(kaku))
L = A**2 + B**2 - 2*A*B*a
print(math.sqrt(L))

Measured memory_bytes: 62512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

char get(ll x) {
  if (x == 0) return '3';
  if (x == 1) return '5';
  if (x == 2) return '7';
  return '0';
}

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

  ll N;
  std::cin >> N;

  ll ans = 0LL;
  std::map<ll, bool> mused;
  for (ll S = 0; S < std::pow(4, 9); S++) {
    std::string str;
    ll status = S;
    for (ll i = 0; i < 9; i++) {
      ll x = status % 4;
      status /= 4;
      str += get(x);
    }
    ll num = atoi(str.c_str());
    if (num > N) continue;
    if (mused[num]) continue;
    if (str.find("3") == std::string::npos) continue;
    if (str.find("5") == std::string::npos) continue;
    if (str.find("7") == std::string::npos) continue;
    if (std::to_string(num).find("0") != std::string::npos) continue;
    mused[num] = true;
    ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m;
    cin >> n >> m;
    int time = 1900*m + 100*(n-m);
    cout << time*pow(2,m) << endl;
    return 0;
}

Measured memory_bytes: 256
let change n m d =
  let t = Array.make (n + 1) max_int in
  let rec doit = function
    | (i, _) when i = m -> t.(n)
    | (i, x) when x + d.(i) > n -> doit (i + 1, 0)
    | (i, x) ->
      t.(x + d.(i)) <- min t.(x + d.(i)) (t.(x) + 1);
      doit (i, x + 1) in
  t.(0) <- 0;
  doit (0, 0)

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> (n, m)) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  Printf.printf "%d\n" (change n m d)

Measured memory_bytes: 2744
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int dp[31];
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 3; i <= 30; i++){
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
	}

	int n;
	while(cin>>n,n){
		cout << (dp[n] + 3649) / 3650 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <cassert>
#include <cstddef>
#include <tuple>
#include <utility>
#include <vector>

template <class Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using size_type = std::size_t;
  using container_type =
      std::vector<std::tuple<size_type, value_type, size_type>>;

protected:
  container_type c;

private:
  size_type &par(const size_type i) { return std::get<0>(c[i]); }
  size_type par(const size_type i) const { return std::get<0>(c[i]);
                                         assert(false);}
  value_type &val(const size_type i) { return std::get<1>(c[i]); }
  const value_type &val(const size_type i) const { return std::get<1>(c[i]); }
  size_type &siz(const size_type i) { return std::get<2>(c[i]); }
  size_type siz(const size_type i) const { return std::get<2>(c[i]); }
  value_type potential(size_type x) {
    value_type ret = {};
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      ret = ret + val(x);
      x = par(x) = par(par(x));
    }
    return std::move(ret);
  }

public:
  PotentializedUnionFind() : c() {}
  explicit PotentializedUnionFind(const size_type size)
      : c(size, std::forward_as_tuple(static_cast<size_type>(0), value_type(),
                                      static_cast<size_type>(1))) {
    for (size_type i = 0; i < size; ++i)
      par(i) = i;
  }

  size_type size() const { return c.size(); }
  bool empty() const { return c.empty(); }

  size_type find(size_type x) {
    assert(x < size());
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      x = par(x) = par(par(x));
    }
    return x;
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    assert(same(x, y));
    return potential(y) + (-potential(x));
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return siz(find(x));
  }

  bool unite(size_type x, size_type y, value_type d) {
    assert(x < size());
    assert(y < size());
    d = d + potential(x) + (-potential(y));
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (siz(x) < siz(y))
      std::swap(x, y), d = -d;
    siz(x) += siz(y);
    par(y) = x;
    val(y) = std::move(d);
    return true;
  }
};

#include<iostream>

int main() {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 2560
// AGC008_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll x, y;
    cin >> x >> y;
    
    // calculation
    ll tmp_x, tmp_y, tmp_res, res = (ll)pow(10, 10);
    for (ll i = 0; i < 2; ++i) {
        for (ll j = 0; j < 2; ++j) {
            tmp_x = x;
            tmp_y = y;
            tmp_res = 0;
            if (i == 1) {
                // 初めに反転
                tmp_x *= -1;
                tmp_res++;
            }
            if (j == 1) {
                // 最後に反転
                tmp_y *= -1;
                tmp_res++;
            }
            
            if (tmp_x <= tmp_y) {
                res = min(res, tmp_res + (tmp_y - tmp_x));
            }
        }
    }
    
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
p = [0] * (N + 1)
for i in range(Q):
  a = int(input())
  p[a] += 1
for i in range(1, N + 1):
  p[i] += K - Q
  if p[i] > 0:
    print("Yes")
  else: print("No")

Measured memory_bytes: 50904
# -*- coding: utf-8 -*-
from collections import defaultdict
from operator import itemgetter

def solve(): 
    N, M =  map(int, input().split())
    D = defaultdict(int)
    for a in map(int, input().split()):
        D[a] += 1
    for _ in range(M):
        B, C = map(int, input().split())
        D[C] += B
    res = 0
    count = 0
    for v, k in sorted(D.items(), key=itemgetter(0), reverse=True):
        if count+k <= N:
            res += v*k
            count += k
        else:
            res += v*(N-count)
            break

    return str(res)

if __name__ == '__main__':
    print(solve())



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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	vector<int> a(n+1);
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}

	vector<int> b(n);

	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans += min(b[i], a[i]);
		b[i] -= min(b[i], a[i]);

		ans += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);

	}

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

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        int[] sharp = new int[n];
        int[] dot = new int[n];

        if (s[0] == '#') sharp[0] = 1;
        else sharp[0] = 0;
        for (int i = 1; i < n; i++)
        {
            if (s[i] == '#') sharp[i] = sharp[i - 1] + 1;
            else sharp[i] = sharp[i - 1];
        }
        dot[n - 1] = 0;
        for (int i = n - 2; 0 <= i; i--)
        {
            if (s[i + 1] == '.') dot[i] = dot[i + 1] + 1;
            else dot[i] = dot[i + 1];
        }

        int ans = int.MaxValue;
        for (int i = 0; i < n; i++)
        {
            ans = Math.Min(ans, sharp[i] + dot[i]);
        }

        if (s[0] == '.') ans = Math.Min(ans, dot[0] + 1);
        else ans = Math.Min(ans, dot[0]);
        Console.WriteLine(ans);
    }
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n, m; cin >> n >> m;
  ll l = -INF, r = INF;
  REP(i, m){
    ll li, ri; cin >> li >> ri;
    chmax(l, li);
    chmin(r, ri);
  }
  cout << (max(0ll, r - l + 1)) << endl;
}


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





int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll i,a,b;
	map<ll,int> m;
	for(i=0;i<3;i++){
		cin>>a>>b;
		m[a]++;
		m[b]++;
		if(m[a]>2 || m[b]>2){
			cout<<"NO";
			return 0;
		}
	}for(i=1;i<5;i++){
		if(m[i]==0){
			cout<<"NO";
			return 0;
		}
	}cout<<"YES";
}

Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
d=[0]*-~n
for i in range(1,n+1):
 for j,k in zip(range(9),(2,5,5,4,5,6,3,7,6)):
  if i-k>=0and(i-k<1or d[i-k])and j+1in a:d[i]=max(d[i],d[i-k]*10+j+1)
print(d[n])

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

int main()
{
int n, k;
int cnt = 0;
cin >> n >> k;

for( int i = 0; i*2+1 <= n; ++i)
{
++cnt;
}

if(cnt >= k)
cout << "YES" << endl;

else
cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int len; cin >> len;
    string a; cin >> a;
    int c = 0;
    for (int i = 2; i < len; i++) {
        if (a[i] == 'C' && a[i-1] == 'B' && a[i-2] == 'A') {
            c++;
            i += 2;
        }
    }
    cout << c;
    return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=1e5+10,M=1e9+7;
int n,m,a,b;
int s,t;
int vis[mxN][4];
vector<int>adj[mxN];

int bfs(){
    queue<pii>fila;
    fila.push({s,0});    
    while(!fila.empty()){
        int u=fila.front().first;
        int d=fila.front().second;
        fila.pop();
        if(vis[u][d%3])continue;
        vis[u][d%3]=true;
        if(u==t && d%3==0)return d/3;
        for(int v:adj[u]){
            fila.push({v,d+1});
        }
    }
    return -1;
}



// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        adj[a].pb(b);
    }
    cin>>s>>t;    
    cout<< bfs();


}

Measured memory_bytes: 7296
a,b,x = map(int,input().split())

import math

d = x/(a**2)

c = b-d
e = c*2
if e<=b:
    f = (e**2+a**2)**(1/2)
    g = (f**2+a**2-e**2)/(2*f*a)
    print(math.degrees(math.acos(g)))
else:
    e = 2*x/(a*b)
    #print(e)
    a = b
    f = (e**2+a**2)**(1/2)
    g = (f**2+a**2-e**2)/(2*f*a)
    print(90-(math.degrees(math.acos(g))))

Measured memory_bytes: 3064
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>
#define PI 2*acos(0.0)

int main()
{
    io;
    double a, b, c,d;
    cin>>a >>b >>c >>d;
    int t = ceil(a/d), h = ceil(c/b);
    if(t >= h)
        cout << "Yes";
    else
        cout <<"No";
    return 0;
}

Measured memory_bytes: 3736
import java.util.Scanner;

//Dragon Fantasy
public class Main{

	int n, hx, hy, dx, dy;
	int[][] p;
	double[] r;
	double EPS = 1e-8;
	
	boolean dfs(int k, int S, double t){
		if(S==(1<<n)-1)return true;
		int x = k==-1?hx:p[k][0], y = k==-1?hy:p[k][1];
		for(int i=0;i<n;i++){
			if(((S>>i)&1)>0)continue;
			if(r[i]<t+Math.hypot(x-p[i][0], y-p[i][1])+EPS)return false;
		}
		for(int i=0;i<n;i++){
			if(((S>>i)&1)>0)continue;
			if(r[i]>t+Math.hypot(x-p[i][0], y-p[i][1])){
				if(dfs(i, S+(1<<i), t+Math.hypot(x-p[i][0], y-p[i][1])))return true;
			}
		}
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt(); hx = sc.nextInt(); hy = sc.nextInt(); dx = sc.nextInt(); dy = sc.nextInt();
			if((n|hx|hy|dx|dy)==0)break;
			p = new int[n][2];
			for(int i=0;i<n;i++)for(int j=0;j<2;j++)p[i][j]=sc.nextInt();
			r = new double[n];
			for(int i=0;i<n;i++)r[i]=Math.hypot(p[i][0]-dx, p[i][1]-dy);
			System.out.println(dfs(-1, 0, 0)?"YES":"NO");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  ll ans = 0;
  rep(i,v.size()-1){
    if (v[i] > v[i+1]){
      ans += (v[i] - v[i+1]);
      v[i+1] = v[i];
    } 
  }
  cout << ans << endl;

  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end


void solve(){
   int n; cin>>n;
   vector<int> a(n),l(n),r(n);
   vector<vector<int>> lb(n),rb(n);
   ll res=0;
   rep(i,0,n){
      cin>>a[i]>>l[i]>>r[i]; a[i]--;
      res+=min(l[i],r[i]);
      if(l[i]<r[i]){if(a[i]+1<n)rb[a[i]+1].push_back(r[i]-l[i]);}
      else lb[a[i]].push_back(l[i]-r[i]);
   }
   
   priority_queue<int> pq;
   for(int i=n-1;i>=0;i--){
      for(int x:lb[i])pq.push(x);
      if(!pq.empty()){
         res+=pq.top(); pq.pop();
      }
   }
   while(pq.size())pq.pop();
   for(int i=0;i<n;i++){
      for(int x:rb[i])pq.push(x);
      if(!pq.empty()){
         res+=pq.top(); pq.pop();
      }
   }
   cout<<res<<endl;
}

int main(){
   int t; cin>>t;
   while(t--)solve();
   return 0;
}

Measured memory_bytes: 19488
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 2000000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	int K;
	cin >> K;

	string S;
	cin >> S;

	ll dp[100][100] = {};

	int N = K + S.size();
	int M = S.size();


	ll kotae = 0;
	for (int i = K; i >= 0; i--) {
		ll tmp = modpow(25, i);
		tmp = tmp * modpow(26, K - i) % mod;

		tmp = tmp * f.comb(M + i - 1, i) % mod;
		kotae += tmp;
	}


	co(kotae % mod);







	Would you please return 0;
}

Measured memory_bytes: 27676
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))

#最大公約数
import fractions
temp = a[0]
for i in a[1::]:
    temp = fractions.gcd(temp,i)
    if temp==1:
        break
print(temp)

Measured memory_bytes: 14252
function calc(input) {
  var array = input.split(' ');
  var A = parseInt(array[0]);
  var B = parseInt(array[1]);
  var C = parseInt(array[2]);

  var ascArray = [A, B, C].sort(function(a, b) {
    return a - b;
  });

  var min = ascArray[0];
  var mid = ascArray[1];
  var max = ascArray[2];

  var diffFromMidToMax = max - mid;
  var diffFromMinToMid = mid - min;
  var isMod0 = diffFromMinToMid % 2 === 0;

  if(min === mid === max){
    return 0;
  }

  if (mid === min) {
    return max - min;
  }

  if (mid === max) {
    return Math.floor(diffFromMinToMid / 2) + (isMod0 ? 0 : 2);
  }

  return diffFromMidToMax + Math.floor(diffFromMinToMid / 2) + (isMod0 ? 0 : 2);
}

function main(input) {
  console.log(calc(input));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>
#define N 1000000


void insertionSort(int [],int,int);
void shellSort(int[],int);

int cnt=0;

int main(){
  int n,i,j,A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  shellSort(A,n);
  printf("%d\n",cnt);


  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}

void insertionSort(int A[],int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;

    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j = j -g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[],int n){
  int i,m=0;
  int G[n];
  G[0]=0;
  for(i=0;i<n;i++){
    G[i+1] = 3*G[i]+1;
    m++;
    if(G[i+1]>N){
      break;
    }
  }
  while(G[m] > n){
    m--;
  }
  printf("%d\n",m);

  for(i=m;i>1;i--){
    printf("%d ",G[i]);
  }
  printf("%d\n",G[1]);
  for(i=m;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

Measured memory_bytes: 4508
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll tt) {
    ll n;
    cin>>n;
    ll a[n];
    repf(i,0,n) cin>>a[i];
    sort(a,a+n);
    ll c=2,id=n-2,ans=a[n-1];  
    while(c<n) {
        ans+=a[id];
        c++;
        if(c<n) {
            ans+=a[id];
            c++;
            id--;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
long long int a[200005];
long long int pre, ans;
const int mod = 7 + 1e9;
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < n - 1; i++) {
    pre = (pre + a[i]) % mod;
    ans = (ans + pre * a[i + 1]) % mod;
  }
  cout << ans % mod << endl;
  system("pause");
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


int med(vector<int> a) {
        sort(all(a));
        return a[sz(a) / 2];
}



void _main() {
        int a, b; cin >> a >> b;
        cout << max({a + b, a - b, a * b});
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3620
package main

import "fmt"

func main() {
	// 入力を読み込む
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	// 累積和の計算
	sum := make([]int, N+1)
	for i := 0; i < N; i++ {
		sum[i+1] = sum[i] + A[i]
	}
	// 累積和が同じ数になる項目の数をmapに保存
	m := make(map[int]int, 0)
	for _, v := range sum {
		m[v]++
	}
	var ans int
	for _, v := range m {
		if v >= 2 { // 2個以上ある場合、少なくとも1個i<jかつsum[i]-sum[j] == 0となるi<jが存在する
			ans += (v * (v - 1)) / 2 // nC2のcombinationを計算してansに足しこむ
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14976
#include <stdio.h>
int main(){
    int n;
    scanf("%d", &n);
    if (n % 1000 == 0){
        printf("%d", 0);
    }
    else if(n % 1000 != 0){
        printf("%d", 1000 - n % 1000);
    }
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;

struct point{
	int x,y;
	point() { x = y = 0; }
	point(int xx, int yy) { x = xx; y = yy; }
	void resize(int n) { x = (x+n)%n; y = (y+n)%n;}
};

int main()
{
	vector< vector<int> > map;
	point p;
	int n, i, j=0;

	while (cin>>n) {
		if (n == 0) break;
		map.clear();
		map.resize( n, vector<int>(n) );
		p = point(n/2, n/2+1);
		map[p.x][p.y] = 1;
		for (i = 2; i <= n*n; i++) {
			p.x++;
			p.y++;
			p.resize(n);
			while ( map[p.x][p.y] != 0 ) {
				p.x--;
				p.y++;
				p.resize(n);
			}
			map[p.x][p.y] = i;
		}
		for (p.y = 0; p.y < n; p.y++) {
			for (p.x = 0; p.x < n; p.x++) {
				cout<<setw(4)<<right<<map[p.x][p.y];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c;
  d=a*100+b*10+c;
  	if(d%4==0)
     cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
      
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[a[i]] == i) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	int diff_max = -999999999;
	int tmp = a[0];
	for(int i = 1; i < n; i++){
			//tmp = a[i];
			diff_max = max(diff_max, a[i]-tmp);
			tmp = min(tmp, a[i]);
	}
	

	cout << diff_max << endl;
}


			


Measured memory_bytes: 3872
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
const int M = 2e4 + 10;
int64 dp[N][M];
struct Node {
  int w, s, v;
  bool operator <(const Node& rhs) const {
    return s + w < rhs.s + rhs.w;
  }
};
Node a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &a[i].w, &a[i].s, &a[i].v);
  }
  sort(a, a + n);
  for (int j = 0; j < M; ++j) dp[0][j] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < M; ++j) {
      dp[i + 1][j] = dp[i][j];
      if (a[i].w <= j) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][min(a[i].s, j - a[i].w)] + a[i].v);
      }
    }
  }
  printf("%lld\n", dp[n][M - 1]);
  return 0;
}


Measured memory_bytes: 157952
#include<iostream>
#include<string>
using namespace std;
int main(){
	char dp[8][8];
	char a='X';
	while(cin>>dp[0][0]){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			if(i!=0||j!=0)
			    cin>>dp[i][j];
		}
	}
	for(int i=0;i<8-1;i++){
		for(int j=0;j<8-1;j++){
			if(dp[i][j]=='1'&&dp[i][j+1]=='1'&&dp[i+1][j]=='1'&&dp[i+1][j+1]=='1')
				a='A';
		}
	}
	for(int i=0;i<8-3;i++){
		for(int j=0;j<8;j++){
			if(dp[i][j]=='1'&&dp[i+1][j]=='1'&&dp[i+2][j]=='1'&&dp[i+3][j]=='1')
				a='B';
		}
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8-3;j++){
			if(dp[i][j]=='1'&&dp[i][j+1]=='1'&&dp[i][j+2]=='1'&&dp[i][j+3]=='1')
				a='C';
		}
	}
	for(int i=0;i<8-2;i++){
		for(int j=0;j<8-1;j++){
			if(dp[i][j+1]=='1'&&dp[i+1][j]=='1'&&dp[i+1][j+1]=='1'&&dp[i+2][j]=='1')
				a='D';
		}
	}
	for(int i=0;i<8-1;i++){
		for(int j=0;j<8-2;j++){
			if(dp[i][j]=='1'&&dp[i][j+1]=='1'&&dp[i+1][j+1]=='1'&&dp[i+1][j+2]=='1')
				a='E';
		}
	}
	for(int i=0;i<8-2;i++){
		for(int j=0;j<8-1;j++){
			if(dp[i][j]=='1'&&dp[i+1][j]=='1'&&dp[i+1][j+1]=='1'&&dp[i+2][j+1]=='1')
				a='F';
		}
	}
	for(int i=0;i<8-1;i++){
		for(int j=0;j<8-2;j++){
			if(dp[i][j+1]=='1'&&dp[i][j+2]=='1'&&dp[i+1][j]=='1'&&dp[i+1][j+1]=='1')
				a='G';
		}
	}
	cout<<a<<endl;
	}
	return 0;
}

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

int main()
{
	int n, i;
	string s;
	map<string, int> m, m2;
	map<string, int>::iterator it;
	for (i = 0; i < 8; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	m.clear();
	for (i = 8; i < 16; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	m.clear();
	for (i = 16; i < 24; i++) {
		cin>>n>>s;
		m[s] = n;
		m2[s] = n;
	}
	it = m.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	m2.erase(m2.find((*it).first));
	it = m2.begin();
	cout<<(*it).second<<" "<<(*it).first<<endl;
	it++;
	cout<<(*it).second<<" "<<(*it).first<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string>S(n);
    for(int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int ABC[26][50];
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < 50; j++) {
            ABC[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < S[i].size(); j++) {
            ABC[(int)(S[i][j]-'a')][i]++;
        }
    }
    string ans = "";
    for(int i = 0; i < 26; i++) {
        int X = 2500;
        for(int j = 0; j < n; j++) {
            X = min(X,ABC[i][j]);
        }
        for(int j = 0; j < X; j++) {
            ans+=(char)(i+'a');
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
s,t=input(),input()
ls=len(s)
lt=len(t)
ans=''
for i in range(ls-lt+1)[::-1]:
  c=0
  for j in range(lt):
    if s[i+j]==t[j] or s[i+j]=='?':
      c+=1
  if c==lt:
    ans=s[:i]+t+s[i+lt:]
    print(ans.replace('?','a'))
    break
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll int a,b,c,count=0,k,z=0,n=0,i=0;
  	vector<ll int> arr;
  	cin >> n >> k;
  	for(i=0;i<n;i++){
    	cin >> z;
      	arr.push_back(z);
      	if(i>=k){
        	if(arr[i]>arr[i-k]){cout << "Yes"<<endl;}
          	else{cout << "No"<<endl;}
        }
    }
}

Measured memory_bytes: 5352
import java.util.Arrays;
import java.util.Scanner;

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

        int INF = (int) (1e9 + 5);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] stones = new int[N];
        for (int i = 0; i < N; i++) {
            stones[i] = sc.nextInt();
        }
        int[] cost = new int[N];
        Arrays.fill(cost, INF);
        cost[0] = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j <= i + K; ++j) {
                if (j < N) {
                    cost[j] = Math.min(cost[j], cost[i] + Math.abs(stones[i] - stones[j]));
                }
            }
        }
        System.out.println(cost[N-1]);
    }
}


Measured memory_bytes: 51052
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    ll it = n/(a+b); n %=(a+b);
    cout << it*a+min(n,a) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[10];
int main()
{
    int i,j,k;
    scanf("%s",a);
    k=strlen(a);
    for(i=0;i<k-1;i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128