akhauriyash/Code-Regression huggingface dataset:
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e2+2 ;
const long mxNN =1e6+2 ;
void solve(){
    ll n , k ;
    cin >> n >> k ;
    if(n%k==0){
        pf(0) ;
        return ;
    }
    ll rem= n%k ;
    ll rem1 = k-n%k ;
    cout << min(rem1,rem) <<  endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

bool chk(ll N, ll A, ll B, const vector<ll> &h, ll T) {
  ll check = 0;
  REP(i, N) {
    if (h[i] - B * T <= 0)
      continue;
    check += (h[i] - B * T + A - B - 1) / (A - B);
  }
  // cout << T << " " << check << endl;
  return check <= T;
}

void solve(long long N, long long A, long long B, vector<long long> h) {
  ll b = 1L << 31;
  ll ans = (b << 1) - 1;

  for (; b; b >>= 1) {
    ll t = ans - b;
    if (chk(N, A, B, h, t))
      ans = t;
    // cout << ans << endl;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long A;
  long long N;
  long long B;
  cin >> N;
  vector<long long> h(N - 1 + 1);
  cin >> A;
  cin >> B;
  for (int i = 0; i <= N - 1; i++) {
    cin >> h[i];
  }
  solve(N, A, B, h);
  return 0;
}


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

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

typedef long long int64;

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

  vector<int> a(n), a2;
  rep(i, n){ 
    cin >> a[i];
  }
  copy(a.begin(), a.end(), back_inserter(a2));
  sort(a2.begin(), a2.end(), greater<int>());

  rep(i, n) {
    if(a[i] == a2[0]) cout << a2[1] << endl;
    else cout << a2[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 3316
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    string s, t;

    cin >> s >> t;

    if(s == t){
        cout << "Yes" << endl;
        return 0;
    }

    bool fin = false;
    for(int i = 0; i < s.size() + 1; i++){
        char tmp = s.back();
        s.pop_back();
        s.insert(s.begin(), tmp);
        bool ok = true;
        if(s == t){
            fin = true;
            break;
        }
    }

    if(fin){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  map<char,ll> m;
  rep(i,s.size()){
    m[s[i]]++;
  }
  
  if(s.size()==1){
    cout<<"YES"<<endl;
    return 0;
  }else if(s.size()==2 && s[0]!=s[1]){
    cout<<"YES"<<endl;
    return 0;
  }else if(m.size()<3){
    cout<<"NO"<<endl;
    return 0;
  }
  
  ll mi=INF;
  for(auto e: m){
    chmin(mi,e.second);
  }
  
  for(auto e: m){
    if(e.second-mi>1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int dp[100010];
    dp[0] = 0;
    for (int i = 1; i <= 100000; i++) {
        dp[i] = INF;
        int power = 1;
        while (power <= i) {
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 6;
        }
    }
    for (int i = 1; i <= 100000; i++) {
        int power = 1;
        while (power <= i) {
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }
    cout << dp[n];
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> l(n), r(n);
  l[0] = -1;
  for (int i = 1; i < n; i++) {
    l[i] = max(a[i - 1], l[i - 1]);
  }
  r[n - 1] = -1;
  for (int i = n - 2; i >= 0; i--) {
    r[i] = max(r[i + 1], a[i + 1]);
  }
  rep(i, n) cout << max(l[i], r[i]) << endl;
  return 0;
}

Measured memory_bytes: 3968
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 100005;
int n,arr[MaxN],dp[MaxN];
int main(){
	IOS
	while(cin>>n){
		for(int i=0 ; i<n ; i++){
			cin>>arr[i];
		}
		dp[0]=0;
		dp[1]=abs(arr[0]-arr[1]);
		for(int i=2 ; i<n ; i++){
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[n-1]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 4372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    if(s == "Sunny")cout << "Cloudy" << endl;
    if(s == "Cloudy")cout << "Rainy" << endl;
    if(s == "Rainy")cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
# 累積和(2次元)
N, M, Q = map(int, input().split())

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

for i in range(N):
    for j in range(N + 1):
        t[i + 1][j] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(t[q][q] + t[p - 1][p - 1] - t[p - 1][q] - t[q][p - 1])
#print('\n'.join(str(v) for v in result))
print(*result, sep='\n')


Measured memory_bytes: 24300
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100100];
int b[100100];
int bas[200200],tot;
int get(int x){return lower_bound(bas+1,bas+tot+1,x)-bas;}
int cnt[100100];

int ans;
bool ob[100100];
struct UFS{
	int fa[100100];
	int siz[100100];
	void init(){for(int i=1;i<=tot;++i)fa[i]=i,siz[i]=1;}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	void merge(int x,int y)
	{
		int fx=find(x),fy=find(y);
		if(fx==fy)return;
		fa[fy]=fx;
		siz[fx]+=siz[fy];
		ob[fx]=ob[fy]=1;
		siz[fy]=0;
	}
}ufs;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]),bas[++tot]=a[i];
		a[n+1]^=a[i];
	}
	bas[++tot]=a[n+1];
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&b[i]),bas[++tot]=b[i];
		b[n+1]^=b[i];
	}
	bas[++tot]=b[n+1];
	sort(bas+1,bas+tot+1);
	tot=unique(bas+1,bas+tot+1)-bas-1;
	for(int i=1;i<=n+1;++i)
	{
		a[i]=get(a[i]);
		cnt[a[i]]++;
		b[i]=get(b[i]);
	}
	for(int i=1;i<=n+1;++i)
	{
		cnt[b[i]]--;
		if(cnt[b[i]]<0)
		{
			puts("-1");
			return 0;
		}
	}

	ufs.init();
	for(int i=1;i<=n+1;++i)
		if(a[i]!=b[i]) 
		{
			ufs.merge(a[i],b[i]);
			if(i<=n)ans++;
		}
	if(!ans){puts("0");return 0;}
	ob[a[n+1]]=ob[b[n+1]]=1;
	for(int i=1;i<=tot;++i)
		if(ufs.siz[i]&&ob[i]) ans++;
	ans--;
	printf("%d\n",ans);
	return 0;
}


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

// 桁数
int GetDigit(long long a) {
  return log10(a) + 1;
}

int main() {
  long long n;
  cin >> n;
  
  long long i, ans;
  for(i = sqrt(n); i > 0; i--){
    if(n % i == 0){
      ans = GetDigit(n / i);
      break;
    }
  }
  
  cout << ans << endl;
}

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

use std::cmp;

fn main() {
    let (h, w) = get!(usize, usize);
    if h%3 == 0 || w%3 == 0 {
        println!("{}", 0);
        return;
    }

    let mut res = cmp::min(h, w);
    for i in 1..h {
        let a = i * w;
        let b = (h-i) * (w/2);
        let c = (h-i) * ((w+1)/2);
        res = cmp::min(res, cmp::max(a, cmp::max(b, c)) - cmp::min(a, cmp::min(b, c)));
    }
    for i in 1..w {
        let a = i * h;
        let b = (w-i) * (h/2);
        let c = (w-i) * ((h+1)/2);
        res = cmp::min(res, cmp::max(a, cmp::max(b, c)) - cmp::min(a, cmp::min(b, c)));
    }

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

string sa,sb,sc;
signed main(){
    cin >> sa >> sb >> sc; 
    int na = sa.size(),nb = sb.size(),nc = sc.size();
    int anow = 0,bnow = 0,cnow = 0;
    char now = 'a';
    while(true){
        if(anow == na && now == 'a'){
            cout << "A\n";
            return 0;
        }
        if(bnow == nb && now == 'b'){
            cout << "B\n";
            return 0;
        }
        if(cnow == nc && now == 'c'){
            cout << "C\n";
            return 0;
        }
        if(now == 'a'){
            if(sa[anow] == 'b') now = 'b';
            else if(sa[anow] == 'c') now = 'c';
            if(anow != na)anow++;
        }
        else if(now == 'b'){
            if(sb[bnow] == 'a') now = 'a';
            else if(sb[bnow] == 'c') now = 'c';
            if(bnow != nb)bnow++;
        }
        else{
            if(sc[cnow] == 'a') now = 'a';
            else if(sc[cnow] == 'b') now = 'b';
            if(cnow != nc)cnow++;
        }
    }    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main(void){
    int H,W;
    for(;;){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int j = 0;j<H;j++) {
            for(int k = 0; k<W;k++){
                if(k==0||k==W-1)cout<<"#";
                else if(j==0||j==H-1){
                    cout<<"#";
                }
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
import bisect
N = int(input())
a = list(map(int, input().split()))
a.sort()
s = [0]*(10**5+1)

ans = 0
for i in range(10**5+1-2):
    ans = max(ans, bisect.bisect_right(a, i+2) - bisect.bisect_left(a, i))
print(ans)


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

struct UnionFind{
  vector<int> r;
  
  UnionFind(int N){
    r=vector<int>(N,-1);
  }
  
  int root(int x){
    if(r[x]<0){
      return x;
    }
    return r[x]=root(r[x]);
  }
  
  bool unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y){
      return false;
    }
    if(r[x]>r[y]){
      swap(x,y);
    }
    r[x]+=r[y];
    r[y]=x;
    return true;
  }
  
  int size(int x){
    return -r[root(x)];
  }  
};

int main(){
  int a,b;
  cin >>a>>b;
  
  UnionFind UF(a);
  
  for(int i=0;i<b;i++){
    int c,d;
    cin >>c>>d;
    c--;
    d--;
    UF.unite(c,d);
  }
  
  int ans=0;
  for(int i=0;i<a;i++){
    ans=max(ans,UF.size(i));
  }
  
  cout << ans <<endl;
}
  
  
  

Measured memory_bytes: 4064
N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

a = sum(p[:K])
s = sum(p[:K])
for i in range(K, N):
    s += p[i] - p[i - K]
    a = max(a, s)

ans = (a + K) / 2
print(ans)

Measured memory_bytes: 31988
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  int r = N % 10;
  switch(r){
    case 2: case 4: case 5: case 7: case 9:
      printf("hon\n");
      break;
    case 0: case 1: case 6: case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default: break;
  }
  return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int N,num;
	cin >> N;
	num = N / 15;
	cout << N * 800 - num * 200 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }

constexpr int MOD = 1000000007;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    cin >> S >> T;

    if (N > M)
    {
        swap(N, M);
        swap(S, T);
    }

    vector<unsigned int> dp1(M + 1, 1);
    for (int i = 0; i < N; i++)
    {
        for (int j = M - 1; j >= 0; j--)
        {
            if (S[i] != T[j]) dp1[j + 1] += MOD - dp1[j];
        }
        for (int j = 0; j < M; j++)
        {
            (dp1[j + 1] += dp1[j]) %= MOD;
        }
    }

    cout << dp1[M] << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,ans=0;
	string s,t;
	cin >> n;
	cin >> s;
	cin >> t;
	for(i=0; i<n; ++i){
		for(j=i; j<n; ++j){
			if(s[j] != t[j-i]){
				break;
			}
		}
		ans = max(ans,j-i);
	}
	cout << (2*n-ans) << endl;
	return 0;
}


Measured memory_bytes: 256
def Bellman_Ford(G, start, goal):
    V = len(G)
    INF = float('inf')
    negative = [False] * V
    dist = [INF] * V
    dist[start] = 0
    for i in range(V-1):
        UnUpdate = True
        for v, e in enumerate(G):
            for t, cost in e:
                if dist[v] != INF and dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    UnUpdate = False
        if UnUpdate:
            break

    if not UnUpdate:
        for i in range(V):
            UnUpdate = True
            for v, e in enumerate(G):
                for t, cost in e:
                    if dist[v] != INF and dist[v] + cost < dist[t]:
                        dist[t] = dist[v] + cost
                        negative[t] = True
                        for tt, cct in G[t]:
                            negative[tt] = True
                        UnUpdate = False

            if UnUpdate or negative[goal]:
                break
    if negative[goal]:
        return "inf"
    else:
        return 0-dist[goal]


V, E = map(int, input().split())
G = [[] for i in range(V)]
for i in range(E):
    a, b, c = map(int, input().split())
    G[a-1].append((b-1, 0-c))
ans = Bellman_Ford(G,0,V-1)
print(ans)

Measured memory_bytes: 47960
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL num = 1, ans = 0;
	rep(i, N)
	{
		if (A[i] == num)
		{
			++num;
		}
		else ++ans;
	}

	out << (num >= 2 ? ans : -1) << std::endl;
}


Measured memory_bytes: 1792
def main():
    D, G, *pc = map(int, open(0).read().split())
    p = pc[::2]
    c = pc[1::2]
    # コンプリート
    comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)]

    def dfs(G, i):
        # G 総合スコア
        # i 問題 1-based indexing
        if i <= 0:
            # 目標の 総合スコア に到達しなかった
            return 1e9 + 7
        score = 0
        num = min(G // (100 * i), p[i - 1])
        if num == p[i - 1]:
            # コンプリートする
            score = comp[i - 1]
        else:
            # コンプリートしない
            score = 100 * i * num
        if score < G:
            num += dfs(G - score, i - 1)
        return min(num, dfs(G, i - 1))
    print(dfs(G, D))


main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
string t,tt;
VI num,nn;
char s[N];
int n,ret,cnt;
int main() {
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,n) if (s[i]=='x') {
		cnt++;
	} else {
		num.pb(cnt);
		t.pb(s[i]);
		cnt=0;
	}
	num.pb(cnt);
	tt=t;
	reverse(all(t));
	if (t!=tt) {
		puts("-1");
		return 0;
	}
	nn=num;
	reverse(all(nn));
	rep(i,0,SZ(nn)) ret=ret+abs(nn[i]-num[i]);
	printf("%d\n",ret/2);
}


Measured memory_bytes: 1400
s = input()
K = int(input())
ans = ''
alphas = {'a':0,'b':25,'c':24,'d':23,'e':22,'f':21,'g':20,'h':19,'i':18,'j':17,'k':16,'l':15,'m':14,'n':13,'o':12,'p':11,'q':10,'r':9,'s':8,'t':7,'u':6,'v':5,'w':4,'x':3,'y':2,'z':1}
a = 'abcdefghijklmnopqrstuvwxyz'
dict1 = {}
dict2 = {}
i = 1
while i <= 26:
  dict1[i%26] = a[i-1]
  dict2[a[i-1]] = i
  i += 1
for chara in s:
  if alphas[chara] <= K:
    ans = ans + 'a'
    K = K - alphas[chara]
  else:
    ans = ans + chara
K = K%26
if len(ans)>=2:
  ans = ans[:-1]+dict1[(dict2[ans[-1]]+K)%26]
else:
  ans = dict1[(dict2[ans]+K)%26]
print(ans)

Measured memory_bytes: 3572
def main():
    G = [[int(x) for x in input().split()] for _ in range(3)]

    def is_ok(rs, cs):
        for r, ri in enumerate(rs, start=1):
            for c, ci in enumerate(cs):
                if G[r][c] != ri + ci:
                    return False
        return True

    for r0 in range(G[0][0] + 1):
        c0 = G[0][0] - r0
        c1 = G[0][1] - r0
        c2 = G[0][2] - r0

        r1 = G[1][0] - c0
        r2 = G[2][0] - c0

        rs = (r1, r2)
        cs = (c0, c1, c2)
        if is_ok(rs, cs):
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()


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

int main() {
    int X;
    cin >> X;
    string ans;
    if (X == 7 || X == 5 || X == 3){
        ans = "YES";
    }
    else {
        ans = "NO";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
int a[maxn];
int b[maxn], c[maxn];
int n, m;
void solve() {
    cin >> n >> m;
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x]++;
        b[x % m]++;
    }
    for (int i = 1; i <= 1e5; i++) {
        c[i % m] += a[i] / 2;
    }
    ll res = 0;
    res += b[0] / 2;
    for (int i = 1; i <= m / 2; i++) {
        if(i == m - i) {
            res += b[i] / 2;
        } else {
            int mi = min(b[i], b[m - i]);
            int t = m - i;
            if(mi != b[i]) t = i;
            res += mi;
            int left = b[t] - mi;
            res += min(left / 2, c[t]);
        }
    }
    cout << res << endl;
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

// ただの辺
struct edge {
    int to;
    long long cost;
    // 引数一つの時は距離1
    edge(int t, long long c = 1) : to(t), cost(c) {}
};

int n;
vector<int> a;
vector<vector<edge>> g;
vector<vector<int>> dp;
vector<int> ans;

int lis() {
    int ok = n, no = -1;
    while (abs(ok - no) > 1) {
        int m = (ok + no) / 2;
        if (dp[m].back() == INT_MAX) {
            ok = m;
        } else {
            no = m;
        }
    }
    return ok;
}

int insert_index(int x) {
    int ok = n - 1, no = -1;
    while (abs(ok - no) > 1) {
        int m = (ok + no) / 2;
        if (dp[m].back() >= x) {
            ok = m;
        } else {
            no = m;
        }
    }
    return ok;
}

void dfs(int now, int from) {
    int target = insert_index(a[now]);
    dp[target].push_back(a[now]);
    ans[now] = lis();
    for (auto e : g[now]) {
        if (e.to == from) {
            continue;
        }
        dfs(e.to, now);
    }
    dp[target].pop_back();
}

int main() {
    cin >> n;
    a.resize(n);
    g.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    // dp[i].back:長さi+1の最長部分列の最小
    dp.resize(n, vector<int>(1, INT_MAX));
    ans.resize(n);
    dfs(0, -1);
    for (auto e : ans) {
        cout << e << endl;
    }
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int A, B;
	cin >> A >> B;

	if( A == 1 ) { A += 13; }
	if( B == 1 ) { B += 13; }

	cout << (A > B ? "Alice" : (A < B ? "Bob" : "Draw")) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
inf = 10**15
n,m = map(int, input().split())
edge = []
for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edge.append((a,b,c))

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a,b,c = edge[i]
        if d[a]<inf:
            if d[b]<inf:
                if d[b]<d[a]+c:
                    d[b] = d[a]+c
                    update = True
            else:
                update = True
                d[b] = d[a] + c
    if not update:
        break

ans = d[n-1]
updated = [False for _ in range(n)]
for _ in range(n):
    update = False
    for i in range(m):
        a,b,c = edge[i]
        if d[a]<inf:
            if d[a]+c>d[b]:
                d[b] = d[a] + c
                if not updated[b]:
                    update = True
                    updated[b] = True
        if updated[a] and not updated[b]:
            update = True
            updated[b] = True
    if not update:
        break

if updated[n-1]:
    print("inf")
else:
    print(ans)


Measured memory_bytes: 3316
n, k = map(int, input().split())
sunuke = list(range(1, n+1))
d = []

for i in range(k):
    d.append(int(input()))
    a_temp = (list(map(int, input().split())))
    for t in a_temp:
        if t in sunuke:
            sunuke.remove(t)

print(len(sunuke))


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>t;
      sort(all(s));
      sort(all(t));
      reverse(all(t));
     Yes(s<t);
     

       
return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <vector>
    #include <math.h>
    using namespace std;
     
    int main() {
        int N,M,X,Y;
        cin>>N>>M>>X>>Y;
        int P[N];
        int maxp=-100;
        for(int i=0;i<N;i++){
            cin>>P[i];
            if(P[i]>maxp){
                maxp=P[i];
            }
        }
        int Q[M];
        int minq=100;
        for(int j=0;j<M;j++){
            cin>>Q[j];
            if(Q[j]<minq){
                minq=Q[j];
            }
        }
        if(X<Y){
            if(maxp<minq){
                if(maxp>=X & minq<=Y){
                    cout<<"No War"<<endl;
                    return 0;
                }
                else{
                    cout<<"War"<<endl;
                    return 0;
                }
            }
            else{
                cout<<"War"<<endl;
                return 0;
            }
        }
        else{
            cout<<"War"<<endl;
            return 0;
        }
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static bool[] check = new bool[105000];
        static void Main(string[] args)
        {
            int end = (int)Math.Sqrt(105000) + 1;
            for (int i = 2; i < end; i++)
            {
                if (check[i]) continue;
                for (int j = 2; i * j < 105000; j++)
                {
                    check[i * j] = true;
                }
            }
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                if (line == "0") break;
                var n = int.Parse(line);
                if (n <= 3)
                {
                    Console.WriteLine(0);
                    continue;
                }
                int count = 0;
                for(int i = 2; i < n / 2 + 1; i++)
                {
                    if (!check[i] && n - i >= 2 && !check[n - i]) count++;
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    string s;cin>>s;
    int al[27]={0};
    for(int i=0;i<s.size();i++){
        al[s.at(i)-'a']++;
    }
    int end=1;
    for(int i=0;i<26;i++){
        if(al[i]){
            continue;
        }else{
            char word=i+'a';
            cout<<word<<endl;
            end=0;
            break;
        }
    }
    if(end) cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int x,sum = 0;
	scanf("%d",&x);

	FOR(i,1,1000000000){
		sum += i;
		if(x <= sum){
			sum = i;
			break;
		}
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int x, a, b;
    cin >> x >> a >> b;
    YESNO(abs(x - a) < abs(x - b), "A", "B");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;
#define SEG (1<<19)

deque<int> D[26];
int seg[SEG];

int RSQ(int s, int t, int k = 1, int l = 0, int r = SEG / 2 - 1) {
	if (t < l || r < s) {
		return 0;
	}
	if (s <= l && r <= t) {
		return seg[k];
	}
	int lv = RSQ(s, t, k * 2, l, (l + r) / 2);
	int rv = RSQ(s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return lv + rv;
}

void upd(int x) {
	x += SEG / 2;
	seg[x] = 1;
	while (x > 1) {
		x /= 2;
		seg[x] = seg[x * 2] + seg[x * 2 + 1];
	}
	return;
}

int main() {
	int N;
	string S;
	cin >> S;
	N = S.size();
	for (int i = 0;i < N;i++) {
		D[S[i] - 97].push_back(i + 1);
	}
	int a, b, c1, c2, mc, d;
	bool emp;
	ll ans = 0;
	while (1) {
		emp = 1;mc = N;
		for (int i = 0;i < 26;i++) {
			if (D[i].size() < 2) {
				continue;
			}
			emp = 0;
			a = D[i].front();
			b = D[i].back();

			c1 = a - RSQ(0, a - 1);
			c2 = (N - 1 - b) - RSQ(b + 1, N);

			if (mc > c1 + c2) {
				mc = c1 + c2;
				d = i;
			}
		}

		if (emp)break;
		ans += (ll)mc;
		a = D[d].front();D[d].pop_front();
		b = D[d].back();D[d].pop_back();

		upd(a);
		upd(b);
	}
	a = 0;
	for (int i = 0;i < 26;i++) a += D[i].size();
	if (a > 1) { cout << -1 << endl;return 0; }

	cout << ans << endl;
}

Measured memory_bytes: 2948
N, M = map(int, input().split())
P = list(map(int, input().split()))

root = [i for i in range(N + 1)]
comp_size = [1] * (N + 1)

def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if sx >= sy:
    comp_size[rx] += comp_size[ry]
    root[ry] = root[rx]
  else:
    comp_size[ry] += comp_size[rx]
    root[rx] = root[ry]

for _ in range(M):
  a, b = map(int, input().split())
  merge(a, b)
#print(root)

answer = 0
for i in range(N):
  if root_find(P[i]) == root_find(i + 1):
    answer += 1
#print(root)
print(answer)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a[1000],ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1 && a[i]%2==1)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int INF = 1 << 24;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			int [] a = new int[n];
			int [] b = new int[m];
			int asum = 0, bsum = 0;
			for(int i = 0; i < n; i++){
				a[i] = sc.nextInt();
				asum += a[i];
			}
			for(int i = 0; i < m; i++){
				b[i] = sc.nextInt();
				bsum += b[i];
			}
			
			int ansmin = INF, ansA = -1, ansB = -1;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					int anow = asum + b[j] - a[i];
					int bnow = bsum + a[i] - b[j];
					if(anow == bnow){
						if(ansmin > a[i] + b[j]){
							ansmin = a[i] + b[j];
							ansA = a[i];
							ansB = b[j];
						}
					}
				}
			}
			System.out.println(ansmin == INF ? -1 : ansA + " " + ansB);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 21068
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	ll n, d;
	int ans = 0;
	cin >> n >> d;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;

		if (d * d >= x * x + y * y)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int d; cin >> d;
    
    if(d==25) cout << "Christmas" << ln;
    else if(d==24) cout << "Christmas Eve" << ln;
    else if(d==23) cout << "Christmas Eve Eve" << ln;
    else cout << "Christmas Eve Eve Eve" << ln;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
  int cnt;
  int H,W,h,w;
  int total;
  int h1,w1;
  int result;

  cnt = scanf("%d %d", &H,&W);
  cnt = scanf("%d %d", &h,&w);

  total = H*W;
  h1 = h*W;
  w1 = (H-h)*w;
  result = total - h1 - w1;

  printf("%d", result);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int check (vi &arr, int k) {
	mii nums;
	vi comp(len(arr), -1);
	int n = len(arr);

	// calculating for first element 

	forn(0, min(k + 1, n), i) nums[arr[i]] += 1;
	comp[0] = distance(nums.begin(), nums.find(arr[0])) + 1;

	if (n == 1) return 1;

	nums.clear();

	// calculating for second element
	for (int i = max(0LL, 1 - k); i < min(1 + k, n); i += 1) nums[arr[i]] += 1;
	for (int i = 1; i < n; i += 1) {
		cout << i << " " << i - k << " " << i + k << endl;
		if (i + k < len(arr)) {
			nums[arr[i + k]] += 1;
		}
		if (comp[i] == -1) {
			if (nums.find(arr[i]) == nums.end()) cerr << "boo!" << endl;
			comp[i] = (distance(nums.begin(), (nums.find(arr[i])))) + 1;
		}

		if (i - k >= 0) {
			nums[arr[i - k]] -= 1;
			if (nums[arr[i - k]] == 0) nums.erase(nums.find(arr[i - k]));
		}
	}
	int s = 0;
	forn(0, n, i) {
		cerr << comp[i] << " "; 
		s += comp[i];
	}
	cerr << endl;
	return s; 
} 

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;

	int a;
	cin >> a;

	cout << n * n - a;
	
	end_routine;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	ll ans = 0 ;
	for(int i=0;i<s.size();i++) ans += (s.at(i)!=s.at(s.size()-1-i)) ;
	cout << ans/2 << endl ;
}


Measured memory_bytes: 3584
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

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

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	int i, j;
	cin >> n >> m;
	if (n == m)
		cout << "Yes";
	else
		cout << "No";

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long

int main()
{
   char S[100001]={'\0'};
   scanf("%s",S);
     int x0=0;
     int x1=0;
    for (int i = 0;i<strlen(S);i++)
     {
        if (S[i]=='0')
            x0++;
        else x1++;

     }
     int min = 0;
     if (x0>x1)min=x1;
     else min=x0;
     printf("%d",min*2);



    return 0;
}


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

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    
    char dif= 'A'-'a';
   
    printf("%c%c%c\n", s1.at(0) + dif, s2.at(0)+dif, s3.at(0)+dif);
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n, ans = 0; cin >> n;
	Rep(i, n){
		int a; cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

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

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

pair<int, int> i_to_pair(int x)
{
	int sentou = to_string(x)[0] - '0';
	int matubi = to_string(x)[to_string(x).size() - 1] - '0';
	return make_pair(sentou, matubi);
}

int main()
{
	int n;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
	}
	int ans = 0;
	for (auto item : mp) {
		int tmp = item.second;
		if (mp.count(item.first - 1)) tmp += mp[item.first - 1];
		if (mp.count(item.first + 1)) tmp += mp[item.first + 1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3200