akhauriyash/Code-Regression huggingface dataset:
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<ll> S(N+1,0);
  map<ll,ll> mp;
  mp[0]++;
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + A[i];
    mp[S[i+1]]++;
  }
  ll ans = 0;
  for(auto m: mp){
    ans += (m.second*(m.second-1))/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15104
from collections import Counter

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
S = []
for _ in range(N):
    string = sorted(input())
    string = "".join(string)
    S.append(string)

S_counter = Counter(S)

ans = 0
for i in S_counter.values():
    if i != 1:
        number = cmb(i, 2)
        ans = ans + number

print(ans)

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

ll dp[110][2][4] = {0LL};

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

  string s;
  cin >> s;
  ll K;
  cin >> K;

  dp[0][0][0] = 1LL;

  rep(i, s.length()){

    ll num = ll(s[i] - '0');

    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 2; k++){

        for(int d = 0; d < 10; d++){

          int ni = i+1, nj = j, nk = k;
          if(d != 0) nj++;
          if(nj > K) continue;
          if(k == 0){
            if(d > num) continue;
            if(d < num) nk = 1;
          }
          dp[ni][nk][nj] += dp[i][k][j];
        }
      }
    }
  }

  cout << dp[s.length()][0][K] + dp[s.length()][1][K] << endl;

  return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, d, *xy = map(int, string.split())
    return str(sum([1 if x**2 + y**2 <= d**2 else 0 for x, y in zip(*[iter(xy)] * 2)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 57164
str = gets.split
N,m = str[0].to_i, str[1].to_i

a = Array.new(N)
str = gets.split
i = 0
while i < N
    a[i] = str[i].to_i
    i += 1
end
a.sort!

b = Array.new(0)
c = 1
d = 0
i = 0
while i < N
    if a[i] <= c
        d += 1
        i += 1
    else
        b.push(d)
        d = 0
        c *= 2
    end
end
b.push(d)
d = 0

while d <= m
    for i in 1..d do
        a[-i] /= 2
    end
    m -= d
    if b.empty?
       puts 0
       exit 
    else
        d += b.pop
    end
end
a.sort!

for i in 1..m do
    a[-i] /= 2
end

answer = 0
i = 0
while i < N
    answer += a[i]
    i += 1
end
puts answer

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

string s;

int main(){
    ll m = 100;
    ll x;
    cin >> x;
    for(int i=0;;i++){
        m = m*1.01;
        if(m>=x) {cout << i+1 << endl; return 0;}
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}


int main(){
	int a;scanf("%d",&a);
	vector<pair<int,int> > ans;
	if(a%2==0){
		for(int i=1;i<=a;i++){
			for(int j=i+1;j<=a;j++){
				if(i+j==a+1)continue;
				ans.push_back(make_pair(i,j));
			}
		}
	}else{
		for(int i=1;i<=a-1;i++){
			for(int j=i+1;j<=a-1;j++){
				if(i+j==a)continue;
				ans.push_back(make_pair(i,j));
			}
		}
		for(int i=1;i<=a-1;i++){
			ans.push_back(make_pair(i,a));
		}
	}
	printf("%d\n",(int)ans.size());
	for(int i=0;i<ans.size();i++){
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
#define N 100000
#define modn 1000000007
inline ll rit(){
    ll f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
ll ans[50], k, addnm, rm;
int main(void){
	RI(k);
	addnm = k/50;
	for(int i=0;i<50;++i) ans[i] = i + addnm;
	printf("50\n");
	rm = k - (k/50)*50 ;
	for(int i=0;i<50;++i){
		printf("%lld%c",ans[i] + (i>=rm?-rm:50-rm+1)," \n"[i==49]);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,K;
    cin>> N>>K;
    ll h[N];
    rep(i,0,N) cin>>h[i];
    sort(h,h+N);
    ll ans=1000000000;
    rep(i,0,N-K+1){
        if(ans<h[i+K-1]-h[i])ans=ans;
        else ans=h[i+K-1]-h[i];
    }
    cout << ans<<"\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
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; }
int main(){
    ll r,D,x;
    cin>>r>>D>>x;
    for(int i=0;i<10;i++){
        x=r*x-D;
        cout<<x<<endl;
    }
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N);
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  queue<int> que;
  map<int, int> amap;
  int group = 1;
  int state;
  for(int i=0;i<N;++i) {
    if(amap[i]>0) continue;
    que.push(i);
    while(!que.empty()) {
      state = que.front();que.pop();
      if(amap[state]>0) continue;
      amap[state] = group;
      for(int i=0;i<edge[state].size();++i) {
        if(amap[edge[state][i]]>0) continue;
        que.push(edge[state][i]);
      }
    }
    group++;
  }
  map<int, int> bmap;
  for(int i=0;i<N;++i) bmap[amap[i]]++;
  int ans = 0;
  for(int i=0;i<=group;++i) {
    ans = max(ans, bmap[i]);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 26600
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	cin >> n;
	string s;
	cin >> s;
	
	if(sz(s)<=n)
		cout<<s<<endl;
	else
		cout<<s.substr(0,n)<<"..."<<endl;
}

Measured memory_bytes: 3656
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

X = int(input())

ans = 1
for i in range(2, X):
    b = i
    p = 2
    a = b ** p
    while a <= X: 
        ans = max(ans, a)
        p += 1
        a = b ** p
print(ans)

Measured memory_bytes: 9108
#include<stdio.h>
int main(){
	int i, j, k, N, m, row, num;
        m = 3;
	int data[200][3];
	int sum[200] = {0};
	scanf("%d", &N);
	for( i = 0; i < N; i++){
		for( k = 0; k < m; k++){
			scanf("%d", &data[i][k]);
		}
	}
	
	
	for( k = 0; k < m; k++){
		for( j = 0; j < N; j++){
			row = j;
			num = data[row][k];
			for( i = j + 1; i < N; i++){
				if( data[i][k] == num){
					data[i][k] = 0;
					data[j][k] = 0;
				}
			}
		}
	}
	
	
	for( i = 0; i < N; i++){
		for( k = 0; k < m; k++){
			sum[i] = sum[i] + data[i][k];
		}
	}
	
	
	for( i = 0; i < N; i++){
		printf("%d\n", sum[i]);
	}
	return 0;
}

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

char a[8];

int main()
{
	for(int i = 1;i<=4;++i){
		cin>>a[i];
	}
	
	int s1 = (a[1]-'0')*10+a[2]-'0';
	int s2 = (a[3]-'0')*10+a[4]-'0';
	
	int flag1 = 0,flag2 = 0;
	
	if(s1>0 && s1<=12) flag1 = 1;
	if(s2>0 && s2<=12) flag2 = 1;
	
	if(flag1 && flag2) cout<<"AMBIGUOUS";
	else if(flag1) cout<<"MMYY";
	else if(flag2) cout<<"YYMM";
	else cout<<"NA";
	
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


N = int(input())
S = input()
counter = Counter(S)
ans = counter['R'] * counter['G'] * counter['B']

for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)

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

using namespace std;

int main () {


	string t;
	cin >> t;

	int mx = 0;
	int c = 0;

	for (int i = 0; i < t.size(); ++i) {
		if (t[i] == 'R') c++;
		else {
			mx = max(c, mx);
			c = 0;
		}
	
	}
	mx = max(mx, c);

	cout << mx << "\n";

}


Measured memory_bytes: 3592
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0]*(S+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j] = dp[i][j]*2
        if A[i] <= j:
            dp[i+1][j] += dp[i][j-A[i]]
        dp[i+1][j] %= mod
print(dp[N][S])

Measured memory_bytes: 132608
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    n = int(input())
    for _ in range(n):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0

for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
LL n,x,ans,x1,x2;
int main()
{
	scanf("%lld%lld",&n,&x);
	ans=n;
	x1=x,x2=n-x;
	while(1)
	{
		if(x1<x2) swap(x1,x2);
		if(!x2) break;
		if(x1%x2==0) ans-=x2;
		ans+=x2*(x1/x2)*2;
		x1-=x2*(x1/x2);
	}
	printf("%lld\n",ans);
}

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

long long int N, a[4];

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", a + 3);
        ++a[min(2, __builtin_ctzll(a[3]))];
    }
    puts(a[0] + !!a[1] <= a[2] + 1 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n; cin>>n;
    if(n==3){
        cout<<61<<endl;
        return 0;
    }
    ll dp[4][4][4][101]={};
    dp[0][0][0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                for(int l=0; l<4; l++){
                    dp[k][l][0][i+1]+=dp[j][k][l][i];
                    dp[k][l][0][i+1]%=MOD;
                    dp[k][l][1][i+1]+=dp[j][k][l][i];
                    dp[k][l][1][i+1]%=MOD;
                    if(!(l==3 && k==1)){
                        dp[k][l][2][i+1]+=dp[j][k][l][i];
                        dp[k][l][2][i+1]%=MOD;
                    }
                    if(!(k==1 && l==2) && !(k==2 && l==1) && !(j==1 && l==2) && !(j==1 && k==2)){
                        dp[k][l][3][i+1]+=dp[j][k][l][i];
                        dp[k][l][3][i+1]%=MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int j=0; j<4; j++){
        for(int k=0; k<4; k++){
            for(int l=0; l<4; l++){
                ans+=dp[j][k][l][n];
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	char c;
	bool check=false;
	rep(i,n){
		cin>>c;
		if(c=='Y')check=true;
	}
	cout<<((check)?"Four":"Three")<<endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    X = int(input())
    ans = 360 // gcd(X, 360)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61924
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int ans = MAX;
		int num = 0;
		for(int i = 0;i < s.length - 2;i++){
			num = Integer.parseInt(s[i] + s[i+1] + s[i+2]);
			ans = Math.min(ans, Math.abs(num-753));
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<string.h>
 
int main(){
    int s[200],p[100],r[200];
 
    scanf("%s",s);
    scanf("%s",p);
    strcpy(r,s);
    strcat(r,s);
 
    if(strstr(r,p)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
 
    return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

string s;

signed main()
{
	init();
	solve();
}

ll N, M;

void init()
{
	cin >> N >> M;
}

void solve()
{
	ll res;
	if (N * 2 >= M) {
		cout << M / 2 << endl;
		return;
	}
	res = N;
	M -= 2 * N;
	res += M / 4;
	cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[1 << n];
		for (int i = 0; i < 1 << n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 1; i < 1 << n; i *= 2) {
			for (int j = 0; j < 1 << n; j += i * 2) {
				if (a[j] != a[j + i]) {
					a[j] = Math.abs(a[j] - a[j + i]);
				}
			}
		}
		System.out.println(a[0]);
	}
}

Measured memory_bytes: 90668
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	vector<int> k(m);
	vector<vector<int>>s(m,vector<int>(n,0));
	for(int i = 0; i < m; i++) {
		cin>>k[i];
		for(int j = 0; j < k[i]; j++) {
			int x;cin>>x;
			s[i][x - 1] = 1;
		}
	}
	vector<int> p(m);
	for(int i = 0; i < m; i++) {
		cin>>p[i];
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		bool flag = true;
		for(int j = 0; j < m; j++) {
			int tmp = 0;
			for(int l = 0; l < n; l++) {
				if (((i >> l) & 1) && s[j][l] == 1){
					tmp++;
				}
			}
			if (tmp % 2 != p[j]){
				flag = false;
			}
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
array1 = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
array2 = [True for _ in range(8)]
result1 = 0
plus = 0

for i in range(N):

    if a[i] >= 3200:
        plus += 1
        continue

    for j in range(8):
        if a[i] < array1[j]:
            if array2[j]:
                result1 += 1
                array2[j] = False
            break

result2 = result1 + plus

print(max(result1, 1), result2)


Measured memory_bytes: 3064
h, w = map(int, input().split())
s = [[j for j in input()] for i in range(h)]
dij = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        cnt = 0
        for di, dj in dij:
            ni, nj = i + di, j + dj
            if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == '#':
                cnt += 1
        s[i][j] = cnt
for i in range(h):
    print(*s[i], sep='') 

Measured memory_bytes: 3444
n = int(input().rstrip())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

ans = 0
resid = 0
for i in range(n):
    prev_beat = min(resid, aa[i])
    cur_beat = min(aa[i] - prev_beat, bb[i])
    ans += prev_beat
    ans += cur_beat
    resid = bb[i] - cur_beat
ans += min(resid, aa[n])

print(ans)

Measured memory_bytes: 97572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    if(s[0]==s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3604
while True:
    H,W=map(int,input().split())
    if (H,W)==(0,0):
        break
    for i in range(H):
        for j in range(W):
            if j<W-1:
                if (i+j)%2==0:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if (i+j)%2==0:
                    print("#")
                else:
                    print(".")
    print("")


Measured memory_bytes: 7040
while (ln = gets)
  a, op, b = ln.split
  case op.to_s
  when '+'
    ans = a.to_i + b.to_i
  when '-'
    ans = a.to_i - b.to_i
  when '*'
    ans = a.to_i * b.to_i
  when '/'
    ans = a.to_i / b.to_i
  else
    break
  end
  puts ans
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e15+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
 
//ll x[100001]={0};
ll a[200005]={0};
//ll b[200005]={0};
//bool c[1000001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<pair<pair<ll,ll>,ll> > edge;
//vector<ll> adj[200001];
//vector<ll> opp[200001];
//vpii edges;
//bool visited[200001];
////bool color[200001]={0};
//ll dist[100001]={0};
 
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}
 
void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}
 
ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}
 
double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}
 
/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr);
        }
    }
}*/
 
/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    //if(grid[x][y]!=color)return;
    if(visited[x][y] || Map[x][y]=='#'){
        //f=true;
        return;
    }
    visited[x][y]=true;
    Map[x][y]='#';
    //if(px!=(x+1) || py!=y)
        dfs(x+1,y);
    //if(px!=(x-1) || py!=y)
        dfs(x-1,y);
    //if(px!=(x) || py!=y+1)
        dfs(x,y+1);
    //if(px!=(x) || py!=y-1)
        dfs(x,y-1);
}*/
 
/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s){
    if(visited[s])return;
        visited[s]=true;
    for(auto u:adj[s]){
        dfs(u);
    }
}*/

//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

ll dp[402][402]={0};
ll sum(ll l,ll r){
    ll s=0;
    for(ll i=l;i<=r;i++){
        s+=a[i];
    }
    return s;
}
void solve(){
    ll n;
    cin>>n;
    input(a,n);

    for(ll i=n-1;i>=0;i--){
        for(ll j=i+1;j<n;j++){
            dp[i][j]=INF;
            for(ll k=i;k<j;k++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum(i,j));
            }
        }
    }
    cout<<dp[0][n-1];
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //sieve(1000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(2*c>=b-a+1)
        for(int i=a;i<=b;i++)
        printf("%d\n",i);
    else {
        for(int i=a,p=0;p<c;p++,i++)
            printf("%d\n",i);
        for(int i=b-c+1,p=0;p<c;p++,i++)
            printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        if s in a:
            a[s] -= c

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

N = int(input())
P = list(map(int, input().split()))

cnt = 0
for i in range(N-1):
    if i+1 == P[i]:
        p = P[i]
        P[i] = P[i+1]
        P[i+1] = p
        cnt += 1

if P[N-1] == N:
    cnt += 1

print(cnt)



Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[]) {
        int n;
        vector<string> s;
        cin >> n;
        s = vector<string>(n);
        for (auto i = 0; i < s.size(); ++i) {
                cin >> s[i];
        }
        for (int i = 1; i < s.size(); ++i) {
                if (s[i].size() < s[0].size()) {
                        swap(s[i], s[0]);
                }
        }
        sort(s[0].begin(), s[0].end());
        string ans;
        for (int i = 0; i < s[0].size(); i++) {
                bool flag {true};
                for (int j = 1; j < s.size(); j++) {
                        auto it = find(s[j].begin(), s[j].end(), s[0][i]);
                        if (it != s[j].end()) {
                                s[j].erase(it);
                        }
                        else {
                                flag = false;
                                j = s.size();
                        }
                }
                if (flag) {
                        ans.push_back(s[0][i]);
                }
        }
        cout << ans << endl;
}

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

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll x,a;
        cin>>x>>a;
        if(x<a) cout<<0;
        else cout<<10;
    }
    end_routine();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	ll x, y; cin >> x >> y;
	if(x >= 0 && y >= 0 && x <= y){
		printf("%lld\n", y - x);
	}else if(x >= 0 && y < 0 && x >= abs(y)){
		printf("%lld\n", x - abs(y) + 1);
	}else if(x >= 0 && y < 0 && x < abs(y)){
		printf("%lld\n", abs(y) - x + 1);
	}else if(x < 0 && y >= 0 && abs(x) >= y){
		printf("%lld\n", min(abs(x) - y + 1, y - x));
	}else if(x < 0 && y >= 0 && abs(x) < y){
		printf("%lld\n", min(y - abs(x) + 1, y - x));
	}else if(x < 0 && y < 0 && x <= y){
		printf("%lld\n", y - x);
	}else if(x < 0 && y < 0 && x > y){
		printf("%lld\n", x - y + 2);
	}else if(x >= 0 && y >= 0 && x > y){
		printf("%lld\n", min(y + x + 1, 2 + x - y));
	}else{
		int p;
		rep(i, 1000000000000000){
			p++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,sum[200000];
str s;
bool valid (int k){
    int l = 1;
    int r = n;
    int m = n - k;
    l += m; r-= m;
    if(l>=r)return true;
    else{
        int temp = sum[r] - sum[l-1];
        int rng = r-l+1;
        if(temp%rng==0){return true;}
        else return false;
    }
}
int bins (){
    int res = 1;
    int l = 1;
    int r = n;
    while(l<=r){
        int mid = (l+r)/2;
        if(valid(mid)){
            res = mid;
            l = mid+1;
        }
        else{
            r = mid-1;
        }
    }
    return res;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    n = s.size();
    s = " "+s;
    for(int i=1;i<=n;i++){
        sum[i] = sum[i-1] + numerize(s[i]);
    }
    cout<<bins()<<newl;

}


Measured memory_bytes: 876
def test():
    n, a, b, c, d = map(int, input().split())
    s = list(input())

    s.insert(0, '.')

    # A-C B-D までに岩が2個あるか
    r = s[a:c+1]
    sr = "".join(r)
    if '##' in sr:
        print("No")
        return
    t = s[b:d+1]
    st = "".join(t)
    if '##' in st:
        print("No")
        return
    # A B が入れ替わるかどうか
    if (c > d):
        # 入れ替わるスペースがあるか
        u = s[b-1:d+2]
        su = "".join(u)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

Measured memory_bytes: 7412
using System;
using System.Linq;

class F2
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var n2 = n / 2;
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		if (n % 2 == 0)
		{
			long M = a.Where((x, i) => i % 2 == 1).Sum(x => (long)x), t = M;
			for (int i = 0; i < n2; i++)
				M = Math.Max(M, t += a[2 * i] - a[2 * i + 1]);
			Console.WriteLine(M);
		}
		else
		{
			var dp = CreateArray(n2 + 1, 3, -1L << 60);
			dp[0][0] = dp[0][1] = dp[0][2] = 0;

			for (int i = 0; i < n2; i++)
				for (int j = 0; j < 3; j++)
					for (int k = j; k < 3; k++)
						dp[i + 1][k] = Math.Max(dp[i + 1][k], dp[i][j] + a[2 * i + k]);
			Console.WriteLine(Enumerable.Range(0, 3).Max(j => dp[n2][j]));
		}
	}

	static T[] CreateArray<T>(int l, T v)
	{
		var a = new T[l];
		if (!Equals(v, default(T)))
			for (int i = 0; i < l; ++i) a[i] = v;
		return a;
	}

	static T[][] CreateArray<T>(int l, T[] v)
	{
		var a = new T[l][];
		for (int i = 0; i < l; ++i) a[i] = (T[])v.Clone();
		return a;
	}

	static T[][] CreateArray<T>(int l1, int l2, T v) => CreateArray(l1, CreateArray(l2, v));
}


Measured memory_bytes: 54912
def DP(A,N,S,M):
    dp = [[0 for _ in range(S+1)] for _ in range(N+1)]
    dp[0][0] = 1
    #dp[i][j]:要素数i個以下,i番目までで和がjである部分集合の個数
    for i in range(1,N+1):
        for j in range(S+1):
            dp[i][j] = 2 * dp[i-1][j]
            dp[i][j] %= M
            if j - A[i-1] >= 0:
                dp[i][j] += dp[i-1][j-A[i-1]]
                dp[i][j] %= M

    return dp[N][S]

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))
    M = 998244353

    ans = DP(A,N,S,M)
    print(ans)

if __name__ == "__main__":
    main()


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

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

int n,c,ans;

int main() {
  string s;
  cin >> n >> s;
  c = 0;
  for (int i=1; i<n; i++) {
    if (s[i] == 'E') c++;
  }
  ans = c;
  for (int i=1; i<n; i++) {
    if (s[i] == 'E') c--;
    if (s[i-1] == 'W') c++;
    ans = min(ans, c);
  }
  cout << ans;
}


Measured memory_bytes: 900
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();
        int set = (N / X);
        if(N % X >= 1) set++;
      System.out.println(set * T);
    } 
}

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

int main(){
  while(true){
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 1; i <= H; i++){
      for(int j = 1; j <= W; j++){
        if(i % 2 == 1 && j % 2 == 1) cout << '#';
        else if( i % 2 == 0 && j % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n, a;
   cin >> n >> a;
   cout << n*n -a << endl;

   return 0;
}


Measured memory_bytes: 256
## reference: https://qiita.com/shinhiro/items/c652e042828ce26074e4

from heapq import heappush, heappop

X, Y, Z, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

solver = []
hq = []
heappush(hq, (-(A[0]+B[0]+C[0]), 0, 0, 0))
for i in range(K):
  val, idx_a, idx_b, idx_c = heappop(hq)
  solver.append(-val)
  if idx_a + 1 < X:
    new_tuple_a = (-(A[idx_a+1]+B[idx_b]+C[idx_c]),idx_a+1,idx_b,idx_c)
    if new_tuple_a not in hq:
      heappush(hq, new_tuple_a)
  if idx_b + 1 < Y:
    new_tuple_b = (-(A[idx_a]+B[idx_b+1]+C[idx_c]),idx_a,idx_b+1,idx_c)
    if new_tuple_b not in hq:
      heappush(hq, new_tuple_b)
  if idx_c + 1 < Z:
    new_tuple_c = (-(A[idx_a]+B[idx_b]+C[idx_c+1]),idx_a,idx_b,idx_c+1)
    if new_tuple_c not in hq:
      heappush(hq, new_tuple_c)

for i in range(K):
  print(solver[i])
  



Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll k;
    cin >> k;

    ll num = 0;
    queue<ll> que;
    FOR(i, 1, 10) que.push(i);
    while(que.size()) {
        ll a = que.front(); que.pop();
        num++;
        if(num == k) {
            cout << a << endl;
            break;
        }
        for(ll i=max(0LL, a%10-1); i<=min(9LL, a%10+1); ++i) {
            que.push(a*10+i);
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main(){
  string S,T;
  cin >>S>>T;
  int c=0;
  REP(i,S.size()){
   if(S.at(i) != T.at(i)){
    c++; 
   }
    else continue;
  }
  cout <<c<<endl;
}  

Measured memory_bytes: 3924
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
//#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
void solve()
{
  string a,b;
  cin>>a>>b;
  int ans=0;
  frr(i,a.size())
  {
  	if(a[i]!=b[i])
  		ans++;
  }
  cout<<ans<<endl;

}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator

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

int main(void) {
  string S;
	cin >> S;

  REP(i,S.size()) {
    if (S[i] == ',') cout << " ";
    else cout << S[i];
  }
  cout << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using LL = long long int;
using namespace std;

int main (void) {
  string s;
  cin >> s;
  int a = 0;
  REP(i, s.size()) {
    if(a == 0 && s[i] == 'C')a++;
    else if(a == 1 && s[i] == 'F')a++;
  }
  if(a == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    mod = 10**9+7

    fact = [1]

    for i in range(1, n+1):
        fact.append(fact[-1]*i % mod)

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9+7): return inv_n(fact[n-r]
                                             * fact[r] % mod, mod)*fact[n] % mod

    ans = 0

    for i in range(n-k+1):
        ans = (ans+nCr(n-i-1, k-1)*(a[n-i-1]-a[i])) % mod
    print(ans)


main()


Measured memory_bytes: 63912