akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

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



Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
res = 0
for i in range(n):
    if(i%2==0):res+=A[i]
    else:res-=A[i]
print(res)
for i in range(1,n):
    res = 2*A[i-1]-res
    print(res)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
int n;
vector<int> adj[N];
ll dp[N][2];

ll solve(int s, int p, int pc) {
	if (dp[s][pc] != -1) {
		return dp[s][pc];
	}
	ll t = 0, ways = 1;
	if (pc == 0) {
		for (auto it : adj[s]) {
			if (it != p) {
				ways = (ways * solve(it, s, 1)) % mod;
			}
		}
		t += ways;
	}
	ways = 1;
	for (auto it : adj[s]) {
		if(it != p) {
			ways = (ways * solve(it, s, 0)) % mod;
		}
	}
	t = (t + ways) % mod;
	return dp[s][pc] = t;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	int x, y;
	for (int i = 0; i < n - 1; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	memset(dp, -1, sizeof(dp));
	ll ans = solve(1, 0, 0);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 15616
s = list(input())
t = list(input())
change = s[:]
for i in range(len(s)):
    for j in range(len(s)):
        if j+i >= len(s):
            change[i+j-len(s)] = s[j]
        else:
            change[j+i] = s[j]
    if t == change:
        print("Yes")
        quit()
print("No")

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
	int  x , n ;
	
	while(scanf("%d %d",&n ,&x))
	{
		int dev=0;
		
		if(x == 0 && n == 0)
		{
			break;
		}
		for(int i = 1 ; i <= n-2 ;i++)
		{
			for(int j = i+1 ; j <= n-1 ; j++)
			{
				for(int k = j+1 ; k <= n ; k++)
				{
					if(x==i+j+k)
					{
						dev++;
					}
				}
			}
		}
		printf("%d\n",dev);
	}
	return 0;
}



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

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

    if(a > b){
        cout << a + (a - 1) << endl;
    }else if(a < b){
        cout << b + (b - 1) << endl;
    }else{
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Three Variables Game
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int M = 3;

enum { AB, AC, BC };

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int ss[M], cs[MAX_N];
pii ops[MAX_N];

/* subroutines */

inline void pm(int a, int b, int i) {
  cs[i] = a, ss[a]++, ss[b]--;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < M; i++) scanf("%d", ss + i);

  for (int i = 0; i < n; i++) {
    char s[4];
    scanf("%s", s);
    ops[i] = pii(s[0] - 'A', s[1] - 'A');
  }

  for (int i = 0; i < n; i++) {
    int c0 = ops[i].first, c1 = ops[i].second;

    if (ss[c0] == 0 && ss[c1] == 0) {
      puts("No");
      return 0;
    }

    if (ss[c0] < ss[c1]) pm(c0, c1, i);
    else if (ss[c1] < ss[c0]) pm(c1, c0, i);
    else if (i + 1 < n) {
      if (c0 == ops[i + 1].first || c0 == ops[i + 1].second) pm(c0, c1, i);
      else pm(c1, c0, i);
    }
    else pm(c0, c1, i);
  }

  puts("Yes");
  for (int i = 0; i < n; i++) putchar(cs[i] + 'A'), putchar('\n');
  return 0;
}


Measured memory_bytes: 4244
N,M = map(int,input().split())
L = [0 for _ in range(N)]
for i in range(M):
  l,r = map(int,input().split())
  l-=1;r-=1 #0index
  L[l] += 1
  if r+1 < N:
    L[r+1] -= 1
S = [0]
for i in range(N):
  temp = L[i] + S[-1]
  S.append(temp)
#print(S)
ans = 0
for i in range(1,N+1):
  if S[i] == M:
    ans += 1
print(ans)

Measured memory_bytes: 13744
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    rep(i, n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
int A;
int B;


scanf("%d %d",&A,&B);


      if((A>=0 && A<=100) && (B>=2 && B<=1000) && (B%2 == 0)){
         if(A>=13){

          printf("%d\n",B);

         }
         else if(A>=6 && A<=12){

          printf("%d\n",B/2);

         }
         else if(A>=0 && A<=5 ){

          printf("0\n");


         }

      }
      else{

        fprintf(stderr,"error");

      }
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
ll pow5(ll x)
{
    return x * x * x * x * x;
}
int main()
{
    ll X;
    cin >> X;
    for (ll A = 0; A <= 500; A++)
    {
        for (ll B = -500; B <= 500; B++)
        {
            if (pow5(A) - pow5(B) == X)
            {
                cout << A << " " << B;
                return 0;
            }
        }
    }

    return 0;
}

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

#define FIO    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;



int main()
{    
    FIO;
    long long int a[4], m = -10e17, temp;
    for(int i=0;i<4;i++)
    	cin>>a[i];
    for(int i=0;i<2;i++)
    {
    	for(int j=2;j<4;j++)
    	{
    		temp = a[i]*a[j];
    		m = max(temp, m);
    	}
    }
    cout<<m;
}


Measured memory_bytes: 3656
use std::collections::BTreeSet;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let a: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let mut row = BTreeSet::new();
    let mut col = BTreeSet::new();

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                row.insert(i);
                col.insert(j);
            }
        }
    }

    for i in &row {
        for j in &col {
            print!("{}", a[*i][*j]);
        }
        println!();
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

const int INF = 1e9;

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

  vector<vector<int>> a(N, vector<int>(3));
  rep(i, N) {
    rep(j, 3) {
      cin >> a[i][j];
    }
  }

  vector<vector<int>> dp(N, vector<int>(3));
  dp[0] = a[0];

  repi(i, 1, N) {
    rep(j, 3) {
      rep(k, 3) {
        if (j != k) {
          int point = dp[i - 1][j] + a[i][k];
          if (point > dp[i][k]) {
            dp[i][k] = point;
          }
        }
      }
    }
  }

  int ans = 0;
  rep(i, 3) {
    if (dp[N - 1][i] > ans) {
      ans = dp[N - 1][i];
    }
  }

  cout << ans << endl;
}


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


int n,m,k;
int p[100005];
int r[100005];
int s[100005];
int in[100005];
vector<int> bl[100005];
int ans[100005];

void init(int n) {
  for(int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
    s[i] = 1;
  }
  return;
}

int f(int x) {
  return x == p[x] ? x : p[x] = f(p[x]);
}

bool u(int x, int y) {
  x = f(x);
  y = f(y);


  if(x == y) return true;

  if(r[x] > r[y]) {
    p[y] = x;
    s[x] += s[y];
  }
  else {
    if(r[x] == r[y]) r[x]++;
    p[x] = y;
    s[y] += s[x];
  }

  return false;
}

bool ma(int x, int y) {
  return f(x) == f(y);
}

int siz(int x) {
  return s[f(x)];
}

  

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

  init(n);

  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    in[a]++;
    in[b]++;
    u(a,b);
  }


  for(int i = 0; i < k; i++) {
    int c,d;
    cin >> c >> d;
    c--;d--;
    bl[c].push_back(d);
    bl[d].push_back(c);
  }

  // for(int i = 0; i < n; i++) cout <<p[i]<<"  "<< siz(i) << endl;
   

   for(int i = 0; i < n; i++) {
    int tmp = 0;
    for(int j = 0; j < bl[i].size(); j++) {
      if(ma(bl[i][j],i)) tmp++;
    }
    cout << siz(i) - in[i] - tmp - 1 << endl;
   }
}

    

    


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

const ll INF = TEN(18);

int n;
V<ll> a;
VV<int> g;

using P = pair<ll, ll>;
V<P> dfs(int p, int b) {
    V<P> dp = {{0, INF}};
    for (int d: g[p]) {
        if (d == b) continue;
        auto ndp = dfs(d, p);
        int k = int(ndp.size());
        ndp.push_back({INF, INF});
        for (int i = k - 1; i >= 0; i--) {
            if (ndp[i].first < INF / 2 || ndp[i].second < 0) ndp[i + 1].first = min(ndp[i + 1].first, 0LL);
        }
        int m = int(dp.size()) - 1;
        V<P> udp(m + k + 1, {INF, INF});
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= k; j++) {
                udp[i+j].first = min(udp[i+j].first, dp[i].first + ndp[j].first);
                udp[i+j].second = min(udp[i+j].second, dp[i].first + ndp[j].second);
                udp[i+j].second = min(udp[i+j].second, dp[i].second + ndp[j].first);
                udp[i+j].second = min(udp[i+j].second, dp[i].second + ndp[j].second);
            }
        }
        dp = udp;
    }
    int m = int(dp.size()) - 1;
    V<P> udp(m + 1);
    for (int i = 0; i <= m; i++) {
        if (a[p] > 0) {
            udp[i].first = dp[i].first + a[p];
            udp[i].second = dp[i].second + a[p];
        } else {
            udp[i].first = INF;
            udp[i].second = min(dp[i].first, dp[i].second) + a[p];
        }
    }

    return udp;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20) << fixed;

    cin >> n;
    a = V<ll>(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    g = VV<int>(n);
    for (int j = 0; j < n - 1; ++j) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    auto dp = dfs(0, -1);

    for (int i = 0; i < n; i++) {
        if (dp[i].first < INF / 2 || dp[i].second < 0) {
            cout << i << endl;
            return 0;
        }
    }
    assert(false);
    return 0;
}


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();

    int n, l;   cin >> n >> l;
    string arr[n];
    for(int i = 0;i < n;i++)    cin >> arr[i];
    sort(arr, arr + n);

    for(int i = 0;i < n;i++)
        cout << arr[i];
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int a, b, c, d, n = 0;
    int ans = 0;
     
    while(scanf("%d", &n) != EOF){
        ans = 0;
        if(n <= 36){
            for(a = 0; a <= 9; a++){
                for(b = 0; b <= 9; b++){
                    for(c = 0; c <= 9; c++){
                        for(d = 0; d <= 9; d++){
                            if(a + b + c + d ==n){
                                ans++;
                            }
                        }
                    }
                }
            }
            printf("%d\n", ans);
        }else{
            printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  ll H1, M1, H2, M2, K, ans = 0;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ans = -H1 * 60 - M1 + H2 * 60 + M2 - K;
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n);
	int sgn=0;
	for (int i=0; i<n; i++) {
		cin>>a[i];
		if(a[i]<0)
			sgn=(sgn+1)%2;
		a[i]=abs(a[i]);
	}
	ll ret=0;
	for (int i=0; i<n; i++)
		ret+=a[i];
	sort(a.begin(),a.end());
	if(sgn)
		ret-=2*a[0];
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,k;
    cin >>n >>k;
    vector<long long>h(n);
    for(long long i=0;i<n;i++){
        cin >>h[i];
    }
    sort(h.begin(),h.end());
    
    long long ans=0;
    for(long long i=0;i<n-k;i++){
        ans+=h[i];
    }
    
    cout<<ans;
}


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


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

  int n; cin >> n;
  vector<int> x(n), y(n), h(n);
  for(int i = 0; i < n; i++) {
  	cin >> x[i] >> y[i] >> h[i];
  	if(h[i] > 0) {
  		swap(x[0], x[i]);
  		swap(y[0], y[i]);
  		swap(h[0], h[i]);
  	}
  }
  for(int i = 0; i <= 100; i++) {
  	for(int j = 0; j <= 100; j++) {
  		int height = h[0] + abs(i - x[0]) + abs(j - y[0]);
  		bool valid = true;
  		for(int k = 0; k < n; k++) {
  			int tmp = max(height - abs(i - x[k]) - abs(j - y[k]), 0);
  			if(tmp != h[k]) {
  				valid = false;
  				break;
  			}
  		}
  		if(valid) {
  			cout << i << " " << j << " " << height << endl;
  			return 0;
  		}
  	}
  }
  return 0;
}	


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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 200010

int main() {
    ll k,n,a[N],b[N],ans=0;cin>>k>>n;
    for(int i=0; i<n; i++)cin>>a[i];
    for(int i=0; i<n-1; i++) b[i] = (a[i+1]-a[i]);
    b[n-1] = a[0]+k-a[n-1];
    sort(b, b+n);
    for(int i=0; i<n-1; i++) ans += b[i];
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 6744
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using P=pair<int,int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

P f(int x){
    int a=x%10;
    int b=0;
    while(x){
        b=x;
        x/=10;
    }
    return P(a,b);

}
int main(){
    int n;
    cin>>n;
    map<P,int>freq;
    for(int i=1;i<=n;++i){
        P p=f(i);
        freq[p]++;
    }
    ll ans=0;
    for(int i=1;i<=n;++i){
        P p=f(i);
        P q(p.second,p.first);
        ans+=freq[q];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
S = input()
A = S[:2]
B = S[2:]

# print(A, B)

month = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']

A_month = True
try:
  month.index(A)
except ValueError:
  A_month = False
  
# print(A_month)

B_month = True
try:
  month.index(B)
except ValueError:
  B_month = False
  
# print(B_month)

if A_month and B_month:
  print('AMBIGUOUS')
elif A_month and not B_month:
  print('MMYY')
elif not A_month and B_month:
  print('YYMM')
else:
  print('NA')

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

using namespace std;

int main()
{
  int i,j,n;
  map <string,int> mp;
  
  cin >> n;
  
  for(i=1;i<=n;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  
  auto m = max_element(mp.begin(),mp.end(),[](const pair <string,int>& a,const pair <string,int>& b){return a.second < b.second;});
  j = m->second;
  
  for(auto it=mp.begin();it!=mp.end();it++){
    if(it->second == j) cout << it->first << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n,d; cin >> n >> d;
	int ans = (n+(2*d+1)-1)/(2*d+1);
	out(ans);
}




Measured memory_bytes: 256
n,k = map(int,input().split())
d = list(map(int,input().split()))
for i in range(n,100001):
    s = list(str(i))
    sw = 0
    for t in s:
        for j in range(k):
            if int(t) == d[j]:
                sw = 1
                break
        if sw == 1:
            break
    if sw == 0:
        print(i)
        break

Measured memory_bytes: 9096
// atcoder/agc034/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s;
  while (cin >> s) {
    reverse(s.begin(), s.end());
    stack<pair<char, int>> t;
    each (c, s) t.push({c, 1});
    lli x = 0;
    while (3 <= t.size()) {
      pair<char, int> p = t.top(); t.pop();
      pair<char, int> q = t.top(); t.pop();
      if (p.first == 'A' && q.first == 'A') {
        t.push({'A', p.second + q.second});
        continue;
      }
      pair<char, int> r = t.top(); t.pop();
      if (p.first == 'A' && q.first == 'B' && r.first == 'C') {
        x += p.second;
        t.push(p);
        continue;
      }

      t.push(r);
      t.push(q);
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 5284
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_variables)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::mem::swap;
use std::io::prelude::*; // input()

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
fn main() {
    let n = input::<usize>();
    let mut v = (0..n-1)
        .map(|_| input::<usize>())
        .collect::<Vec<_>>();
    let mut s = vec![0; n];
    s[0] = v[0];
    for i in 1..n-1 {
        s[i] = min(v[i-1], v[i]);
    }
    s[n-1] = v[n-2];
    let mut cnt = 0;
    for i in s {
        cnt += i;
    }
    println!("{}", cnt);
}


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

int main(){
  string s,t;
  cin >> s;

  int ans=110;
  for(char x='a';x<'z'+1;x++){
    int count=0;
    int temp=0;
    t=s+x;  
    //cout<<t<<" "<<t.length()<<endl;
    for(int i=0;i<t.length();i++){
      //cout<<count<<" "<<temp<<endl;
      if(t.at(i)==x){
        count=max(count,temp);
        temp=0;
      }
      else{
        temp++;
      }
    }
    //cout<<x<<" "<<count<<endl;
    ans=min(ans,count);
  }
  cout<<ans<<endl;
  return 0;
}

    

Measured memory_bytes: 256
S = input()

cnt = 0
a = []
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
        cnt += 1
        if i == len(S) - 1:
            a.append(cnt)
    else:
        lenflag = False
        a.append(cnt)
        cnt = 0
print(max(a))

Measured memory_bytes: 3060
/* Dijkstra's Algorithm */

#include<cmath>
#include<queue>
#include<vector>
#include<iostream>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	vector<int>			vi;
typedef	pair<double,int>	pdi;

const int inf=1000000000;
int n,id[1000],x[1000],y[1000];
double adj[1000][1000];

bool Dijkstra(int s,int g,int *path)
{
	double d[1000];
	bool visited[1000];
	for(int i=0;i<n;i++)	d[i]=inf,visited[i]=false;
	d[s]=0;
	priority_queue<pdi> pq;	pq.push(mp(0,s));
	while(!pq.empty()){
		pdi a=pq.top();	pq.pop();
		double dis=-a.first;
		int u=a.second;
		if(visited[u])	continue;
		if(u==g)	return true;
		visited[u]=true;
		for(int v=0;v<n;v++){
			if(visited[v])	continue;
			if(dis+adj[u][v]<d[v]){
				d[v]=dis+adj[u][v];
				pq.push(mp(-d[v],v));
				path[v]=u;
			}
		}
	}
	return false;
}

void showPath(int s,int now,int *path,int *id)
{
	if(now==s){ cout<<id[s]; return; }
	showPath(s,path[now],path,id);
	cout<<' '<<id[now];
}

int main()
{
	for(;cin>>n,n;){
		for(int i=0;i<n;i++)	cin>>id[i]>>x[i]>>y[i];

		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	adj[i][j]=(i==j?0:inf);
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			int xx=x[i]-x[j],yy=y[i]-y[j];
			if(xx*xx+yy*yy<=50*50)	adj[i][j]=sqrt(xx*xx+yy*yy);
		}

		int m;	cin>>m;
		while(m--){
			int sid,gid;	cin>>sid>>gid;
			int s,g;
			for(int i=0;i<n;i++){
				if(id[i]==sid)	s=i;
				if(id[i]==gid)	g=i;
			}

			int path[1000];
			if(Dijkstra(s,g,path)){
				showPath(s,g,path,id);
				cout<<endl;
			}
			else	cout<<"NA"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
ans = "No"
zoro = 0

for i in range(n):
    d1,d2 = input().split()
    
    if d1 == d2:
        zoro += 1
    else:
        zoro = 0
        
    if 2 < zoro:
        ans = "Yes"
        
print(ans)

Measured memory_bytes: 9196
import java.lang.Exception

fun main(args:Array<String>?): Unit {
    while(true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val step = readLine()!!.trim().split(' ').map {
            when (it) {
                "lu" -> Step.LU
                "ru" -> Step.RU
                "ld" -> Step.LD
                "rd" -> Step.RD
                else -> throw Exception()
            }
        }
        println(countGrossStep(step))
    }

}
fun countGrossStep(steps: List<Step>): Int {
    var result = 0
    var current = State.OnFloor() as State
    for (step in steps){
        val next = current.step(step)
        if (current.changeState(next)) ++result
        current = next
    }
    return result
}

sealed class State {
    abstract fun step(step: Step): State
    fun changeState(that: State): Boolean {
        return (this is OnBoard && that is OnFloor) || (this is OnFloor && that is OnBoard)
    }
    data class OnBoard(val left: Boolean, val right: Boolean): State() {
        constructor():this(true, true)
        override fun step(step: Step): State {
            return when(step){
                Step.LU -> OnBoard(true, right)
                Step.RU -> OnBoard(left, true)
                Step.LD -> if (right) OnBoard(false, true) else OnFloor()
                Step.RD -> if (left) OnBoard(true, false) else OnFloor()
            }
        }
    }
    data class OnFloor(val left: Boolean, val right: Boolean): State() {
        constructor():this(true, true)
        override fun step(step: Step): State {
            return when(step){
                Step.LU -> if (right) OnFloor(false, true) else OnBoard()
                Step.RU -> if (left) OnFloor(true, false) else OnBoard()
                Step.LD -> OnFloor(true, right)
                Step.RD -> OnFloor(left, true)
            }
        }
    }
}
enum class Step {
    LU, RU, LD, RD
}


Measured memory_bytes: 37528
#include <stdio.h>
#include <math.h>

int main() {
    int A, B, X;
    scanf("%d %d %d", &A, &B, &X);
    double a = (double)A;
    double b = (double)B;
    double x = (double)X;
    double c;
    double Tan;
    if(a * a * b / 2.0 > x) {
        c = 2 * x / (a * b);
        Tan = b / c;
    }
    else {
        c = 2 * b - 2 * x / (a * a);
        Tan = c / a;
    }
    printf("%f\n", atan(Tan) * 180 / 3.141592);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>

const int N=1000005;

int n,dp[N];
std::vector<int>G[N];

void dfs(int u,int fa)
{
	bool ff=0;
	for(int &v:G[u])if(v^fa)
	{
		dfs(v,u);
		dp[u]+=dp[v];
		if(!dp[v])
		{
			if(ff)
				dp[u]++;
			else
				ff=1;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1,x,y; i<=n-1; i++)
	{
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int root;
	for(root=0; root<n; root++)
	{
		if(G[root].size()>2)
	    	break;
	}
	if(root>=n)return puts("1")*0;
	dfs(root,1e9);
	printf("%d",dp[root]);
	return 0;
}

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

using namespace std;

int N , K;

inline int abs(int a){
    return (a < 0) ? -1 * a : a;
}

int dp(int i, int* h, int* memo) {
    if(i == N - 1) return 0;
    if(memo[i] != -1) return memo[i];
    int mini = INT_MAX;
    for(int j = 1; (j + i) < N && j <= K; j++) {
        mini = min(mini, abs(h[i] - h[j + i]) + dp(i + j, h , memo));
    }
    return  memo[i] = mini;
}

int main() {
    cin >> N >> K;
    int memo[N];
    memset(memo, -1, sizeof memo);
    int h[N];
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    cout << dp(0, h, memo) << endl; 
    return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1e18;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y);
long long dp[20][20];
using P = pair<int,int>;

vector<ll> calc(vector<P>& a) {
	int n = a.size();
	sort(a.begin(), a.end());
	rep(i, n + 1)rep(j, n + 1) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(l, n) {
		for (int r = l + 1; r <= n; ++r) {
			{
				ll now = INF;
				for (int k = l; k < r; ++k) {
					ll s = 0;
					for (int i = l; i < r; ++i) {
						s += abs(a[i].first - a[k].first)*ll(a[i].second);
					}
					chmin(now, s);
				}
				rep(j, n) chmin(dp[r][j + 1], dp[l][j] + now);
			}
			{
				ll now = 0;
				for (int i = l; i < r; ++i) {
					now += abs(a[i].first)*ll(a[i].second);
				}
				rep(j, n + 1) chmin(dp[r][j], dp[l][j] + now);
			}
		}
	}
	vector<ll> res(n + 1, INF);
	rep(j, n + 1) res[j] = dp[n][j];
	return res;
}

int main() {
	int N;
	cin >> N;
	vector<int>X(N), Y(N), P(N);
	vector<long long >Ans(N + 1, INF);
	for (int n = 0;n<N; ++n) {
		cin >> X[n] >> Y[n] >> P[n];
	}
	for (int n = 0;n<(1<<N);++n) {
		vector<pair<int, int>>Ax,Ay;
		for (int m = 0;m<N;++m) {
			if (n>>m&1) {
				Ax.emplace_back(X[m],P[m]);
			}
			else {
				Ay.emplace_back(Y[m], P[m]);
			}
		}
		vector<long long> dx = calc(Ax); 
		vector<long long> dy = calc(Ay);
		for (int p = 0;p<dx.size();++p) {
			for (int q = 0;q<dy.size();++q) {
				Ans[p + q] = min(Ans[p + q], dx[p] + dy[q]);
			}
		}
	}
	for (int i = 0; i < N+1; ++i) {
		cout << Ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
import sys
import numpy as np
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B, H, M = map(int, readline().split())
    long = 30*(H%12+M/60)
    short = 6*M
    ans = np.sqrt(A**2 + B**2 - 2*A*B*np.cos(np.deg2rad(long-short)))
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 27192
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int res;
void judge(int i, int j) {
	if (i == j&&i == res)puts("U");
	else if (i == res)puts("L");
	else if (j == res)puts("M");
	else puts("I");
}
int C(int a, int b, char c) {
	if (c == '+')return a + b;
	return a*b;
}
int calc(string s) {
	int res = s[0] - '0';
	char c;
	for (int i = 1; i < s.size(); i++) {
		if ('0' <= s[i] && s[i] <= '9')res = C(res, s[i] - '0', c);
		else c = s[i];
	}
	return res;
}
int main() {
	string s, t, k; cin >> s >> res; t = s;
	int d = 0;
	for (char c : s) {
		if (c == '+') {
			d += calc(k); k = "";
		}
		else k += c;
	}
	d += calc(k);
	judge(calc(s), d);
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,dp[30][3010],ans,ansz=-1,anss;
int main(){
	int t=scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	dp[0][0]=1;
	for(int i=1;i<=f/100;i++){
		for(int j=0;j<=min(f-i*100,i*e);j++){
			//cout<<"dp["<<i<<"]["<<j<<"]";
			if(a<=i) dp[i][j]|=dp[i-a][j];
			if(b<=i) dp[i][j]|=dp[i-b][j];
			if(c<=j) dp[i][j]|=dp[i][j-c];
			if(d<=j) dp[i][j]|=dp[i][j-d];
			//cout<<"="<<dp[i][j]<<"\n";
			//if(dp[i][j])cout<<"="<<(j*100)*1.0/(i*100+j)<<"%,and ";
			//if(dp[i][j])cout<<"mx="<<anss*100.0/ansz<<"\n";
			if(dp[i][j]&&(j*100)*1.0/(i*100+j)>anss*100.0/ansz){
				//cout<<"gx\n";
				ansz=i*100+j;
				anss=j;
			}
		}
	}
	if(ansz==-1) printf("%d 0",a*100);
	else printf("%d %d",ansz,anss);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){ 
	const int MAX_V=999999;
	int prime[MAX_V+1];
	int i,k,v,n,sum[MAX_V+1];
	prime[0]=0;
	prime[1]=0;
	for(i=2;i<=MAX_V;i++){
		prime[i]=1;
	}
	for(i=2;i*i<=MAX_V;i++){
		if(prime[i]){
			for(k=2*i;k<=MAX_V;k+=i){ 
				prime[k]=0;
			}
		}
	}
	sum[0]=0;
	for(i=0;i<=MAX_V;i++){ 
		sum[i+1]=sum[i]+prime[i]; 
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",sum[n+1]);
	}
	return 0; 
}


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

#define ll long long

int main() {
  int h, w;

  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i ++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || j == 0 || i == h - 1 || j == w - 1) cout << "#";
        else cout << ".";
      }
      cout << "\n";
    }
    cout << "\n";
  }
  cout << flush;
    
  return 0;
}
  

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c;
  if(a > b){
    d = a;
    a = b;
    b = d;
  }
  if(b > c){
    d = b;
    b = c;
    c = d;
  }
  if(a > b){
    d = a;
    a = b;
    b = d;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}


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

int main(){
  string S;
  long ch[26]={};
  cin >> S;
  for(long i=0; i<S.size(); i++){
    ch[S[i]-'a']++;
  }
  int idx=-1;
  for(int i=0; i<26; i++){
    if(ch[i]==0){
      idx = i;
      break;
    }
  }
  if(idx==-1){
    cout << "None" << endl;
    return 0;
  }
  cout << (char)('a'+idx) << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:https://abc087.contest.atcoder.jp/tasks/abc087_b>
問題文============================================================
 あなたは、500 円玉を A 枚、100 円玉を B 枚、50 円玉を C 枚持っています。
 これらの硬貨の中から何枚かを選び、合計金額をちょうど X 円にする方法は何通りありますか。
 
 同じ種類の硬貨どうしは区別できません。
 2 通りの硬貨の選び方は、ある種類の硬貨についてその硬貨を選ぶ枚数が異なるとき区別されます。
=================================================================

解説=============================================================
全探索
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll A,B,C,X; cin >> A >> B >> C >> X;
    
 //   ll cntA = X/A, cntB = X/B, cntC = X/C;
    
    ll ans = 0;
    for(int i = 0; i <= A;i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k  <= C;k++){
                if(500*i + 100*j + 50*k == X){
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll x = in(), a = in(), b = in();
	cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
int n, x, m;
multiset<int> S;
int main(){
    //IN;
    SC(n);
    FF(i, 1, n){
        SC(x);
        S.insert(x);
    }
    SC(m);
    FF(i, 1, m){
        SC(x);
        multiset<int>::iterator it = S.find(x);
        if(it == S.end()){
            puts("NO");
            return 0;
        }
        S.erase(it);
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
int main()
{
  double w,l;
  int num;
  string str;
  vector<int> v;
  while(cin >> str){
    double bmi;
    sscanf(str.c_str(),"%d%*c%lf%*c%lf",&num,&w,&l);
    bmi=w/l/l;
    if(bmi>=25.0){
      v.push_back(num);
    }
  }
  for(int buf:v){
    cout << buf << endl;;
  }
}

Measured memory_bytes: 1288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    int n, k;
    cin >> n >> k;
    if (n%k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


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


int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);

  rep(i,n)cin>>a[i];
  multiset<ll> st;
  st.insert(INF);
  rep(i,n){
    if (*st.begin()>=a[i]){
      st.insert(a[i]);
    }
    else{
      auto it=st.lower_bound(a[i]);
      it--;
      st.erase(it);
        st.insert(a[i]);
    }
  }
cout<<st.size()-1;
}


Measured memory_bytes: 8644
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, k; cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    ans += min(abs(x), abs(x - k)) * 2;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll n = 0;
    REP(i, N) {
        cin >> A[i];
        n = max(A[i], n);
    }
    sort(A, A + N);

    ll r = A[0];
    REP(i, N) {
        if (abs((n + 1) / 2 - r) > abs((n + 1) / 2 - A[i]))
            r = A[i];
    }
    cout << n << " " << r << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;

namespace _126A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int K = int.Parse(NM[1]);
            string S = Console.ReadLine();
            Console.WriteLine("{0}{1}{2}", S.Substring(0, K - 1), S.Substring(K - 1, 1).ToLower(), S.Substring(K, N - K));
        }
    }
}


Measured memory_bytes: 13140
import heapq

Q = int(input())
m = L = R = 0
l, r = [], []
n = 0
b = 0

for i in range(Q):
  query = list(map(int, input().split()))
  if len(query) == 3: # 更新クエリ
    b += query[2]
    new = query[1]
    if  n == 0:
      m = new
    elif n == 1:
      if new <= m:
        heapq.heappush(l, -new)
        heapq.heappush(r, m)
        L, R = new, m
        m = new
      else:
        heapq.heappush(l, -m)
        heapq.heappush(r, new)
        L, R = m, new
    elif n == 2:
      if new < m:
        m = -heapq.heappop(l)
        heapq.heappush(l, -new)
        L = new
      else:
        _r = heapq.heappop(r)
        if new < _r:
          m = new
          heapq.heappush(r, _r)
        else:
          m = _r
          heapq.heappush(r, new)
          R = new
    else:
      _l = - l[0]
      _r = r[0]
      if n%2:
        if new <= _l:
          _ = heapq.heappop(l)
          heapq.heappush(l, -new)
          heapq.heappush(r, m)
          m, L, R = _l, L+new, R+m
        elif new <= m:
          heapq.heappush(r, m)
          m, L, R = new, L+new, R+m
        else:
          heapq.heappush(r, new)
          L, R = L+m, R+new
      else:
        if new <= m:
          heapq.heappush(l, -new)
          L += new - m
        elif new <= _r:
          heapq.heappush(l, -m)
          m = new
        else:
          _ = heapq.heappop(r)
          heapq.heappush(l, -m)
          heapq.heappush(r, new)
          m, R = _r, R+new-_r
    n += 1
  else: # 求値クエリ
    print(m, R-L+b)

Measured memory_bytes: 11152
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
flg = None #正
cur = a_ls[0]
cnt = 1
for a in a_ls[1:]:
    if a > cur:
        if flg is None:
            flg = True
        if not flg:
            flg = None
            cnt += 1
    if a < cur:
        if flg is None:
            flg = False
        if flg:
            cnt += 1
            flg = None
    cur = a
print(cnt)

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

bool best[25];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 1){
        int d;
        cin >> d;
        cout << d << endl;
        return 0;
    }
    map<int, int> D;
    D[0]++;
    for(int i = 1; i <= n; i++){
        int d;
        cin >> d;
        D[d]++;
    }
    bool left = true;
    for(auto p : D){
        if(p.second > 2 || (p.first%12 == 0 && p.second == 2)){
            cout << 0 << endl;
            return 0;
        }
        if(p.second == 2){
            best[p.first] = true;
            best[24-p.first] = true;
        }
        else{
            if(left){
                best[p.first] = true;
                left = false;
            }
            else{
                best[24-p.first] = true;
                left = true;
            }
        }
    }
    best[24] = true;
    int ans = 24, bef = 0;
    for(int i = 1; i <= 24; i++){
        if(best[i]){
            ans = min(ans, i-bef);
            bef = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
lr_array = [[int(x) for x in input().split()] for y in range(m)]
pq_array = [[int(x) for x in input().split()] for y in range(q)]


def solve1():
    table = [[0 for x in range(n + 1)] for y in range(n + 1)]
    for l, r in lr_array:
        table[l][r] += 1
    # for row in table:
    #     print(row)
    # print("---------")
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            table[i][j] = table[i][j - 1] + table[i][j]
    # for row in table:
    #     print(row)
    for p, q in pq_array:
        res = 0
        for i in range(p, q + 1):
            # print(i)
            res += table[i][q]
        print(res)

    return 0


# 横軸：スタート
# 縦軸：ゴール
# 2次元累積和で解く
def solve2():
    table = [[0 for x in range(n + 1)] for y in range(n + 1)]
    for l, r in lr_array:
        table[l][r] += 1
    # for row in table:
    #     print(row)
    # print("---------")

    # 横方向の累積和
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            table[i][j] = table[i][j - 1] + table[i][j]

    # 縦方向の累積和
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            table[i][j] = table[i - 1][j] + table[i][j]

    # for row in table:
    #     print(row)

    # p=1, q=8の場合、
    # 「スタートが8でゴールが8の場合のすべての本数」から「スタートが1の場合の
    for p, q in pq_array:
        print(table[q][q] + table[p-1][p-1] - table[q][p-1] - table[p-1][q])


if __name__ == '__main__':
    # solve1()
    solve2()


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

void Main()
{
    int64_t N;
    cin >> N;
    string S = to_string(N);
    for(int64_t i = 0; i < 3; ++i)
    {
        if(S.at(i) == '7')
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 3696