akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(2*n);
    for(int i=0; i<2*n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        ans += a[2*i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    if(s.size() != t.size()){
        cout << "No\n";
        return 0;
    }
    int n = s.size();
    for(int i = 0; i < n; i++){
        bool flag = true;
        for(int j = 0; j < n; j++){
            if(s[(i+j) % n] != t[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<ll>A;
int check[100005];

int main() {

	int N;

	scanf("%d",&N);

	int i, j;

	for (i = 0; i < N; i++) {
		ll a;
		scanf(" %lld",&a);
		A.push_back(a);
	}

	sort(A.begin(),A.end());

	int now = 0;

	ll slime_size = A[0];

	while (1) {

		if (now > N - 1) { break; }

		for (i = now + 1; i < A.size(); i++) {
			if (A[i] > slime_size * 2ll) { break; }
			slime_size += A[i];
		}
		if (i < A.size()) {
			for (j = now; j <= i - 1; j++) {
				check[j] = 1;
			}
			now = i;
			slime_size += A[i];
		}
		else {
			break;
		}
	}
	int ans = 0;
	for (i = 0; i < N; i++) {
		if (check[i] == 0) { ans++; }
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int change=0;
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]) continue;
		change++;
	}
	cout<<change<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define fb(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)
#define pb push_back

typedef long long ll;
using namespace std;
typedef vector <int> vi;

int N, M;
string s[10];
int c[20];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    ff(i, 0, N - 1) cin >> s[i];
    ff(i, 0, N - 1) ff(j, 0, M - 1) if (s[i][j] == '#') ++c[i+j];
    ff(i, 0, N + M - 2) if (c[i] != 1) return cout << "Impossible" << endl, 0;
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,c,j,cant=0,flg,flg2,m;
	char a[11],b[101][11],bb[101][21];
	scanf("%s",a);
	scanf("%d",&c);
	for(i=0;i<c;i++){
		scanf("%s",b[i]);
	}
	for(i=0;i<c;i++){
		strcpy(bb[i],b[i]);
		strcat(bb[i],b[i]);
	}
	for(i=0;i<c;i++){
		flg2=0;
		for(j=0;j<strlen(bb[i]);j++){
			flg=1;
			if(bb[i][j]==a[0]){
				for(m=0;m<strlen(a);m++){
					if(j+m+1>20){
						flg=0;
						break;
					}
					if(bb[i][j+m]!=a[m]){
						flg=0;
						break;
					}

				}
				if(flg==1){
					flg2=1;
					break;
				}
			}
			
		}
		if(flg2==1){
			cant++;
		}
	}
	printf("%d\n",cant);
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int MAX_N = 100100;

ll A[MAX_N*3];
int main(){
    int N;
    cin >> N;
    REP(i,3*N){
        ll a;
        cin >> a;
        A[i] = a;
    }
    priority_queue<ll, vector<ll>, greater<ll> > qx;
    priority_queue<ll, vector<ll> > qy;

    ll xsum = 0;
    ll ysum = 0;
    for(int i = 0; i < N; i++){
        ll x = A[i];
        qx.push(x);
        xsum += x;
    }

    for(int i = 0; i < N; i++){
        ll y = A[i+2*N];
        qy.push(y);
        ysum += y;
    }

    ll XSUM[MAX_N];
    XSUM[0] = xsum;
    for(int i = N; i < 2*N; i++){
        ll z = A[i];
        ll x_min = qx.top();
        if(z > x_min){
            qx.pop();
            qx.push(z);
            xsum -= x_min;
            xsum += z;
        }
        XSUM[i-N+1] = xsum;
    }

    ll YSUM[MAX_N];
    YSUM[N] = ysum;
    for(int i = 2*N - 1; i >= N; i--){
        ll z = A[i];
        ll y_max = qy.top();
        if(z < y_max){
            qy.pop();
            qy.push(z);
            ysum -= y_max;
            ysum += z;
        }
        YSUM[i-N] = ysum;
    }

    ll ans = LLONG_MIN;
    REP(i,N+1){
        ll diff = XSUM[i] - YSUM[i];
        //printf("xsum:%lld\tysum:%lld\tdiff:%lld\n", XSUM[i], YSUM[i], diff);
        ans = max(ans, diff);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,p;
	cin>>n>>p;
	if(n>=40){
		cout<<1<<endl;
		return 0;
	}
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	vector<long long> v;
	if(p%2==0){
		v.push_back(2);
	}
	for(long long i=3;i*i<=p;i+=2){
		bool f=true;
		for(long long j=3;j*j<=i;j+=2){
			if(i%j==0){
				f=false;
				break;
			}
		}
		if(f){
			v.push_back(i);
		}
	}
	sort(v.begin(),v.end());
	long long ans=1;
	for(int i=0;i<v.size();i++){
		int cnt=0;
		while(p!=0&&p%v[i]==0){
			p/=v[i];
			cnt++;
		}
		for(int j=0;j<cnt/n;j++){
			ans*=v[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
  double a, b, c, d, e, f;

  while((scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)) != -1) {
    double x, y;
    double denom = a * e - b *d;
    double nomer_x = c*e - b*f;
    double nomer_y = -c*d + a*f;
    x = nomer_x / denom;
    y = nomer_y / denom;

    if(x == 0) { x = 0;  }
    if(y == 0) { y = 0;  }

    printf("%.3lf %.3lf\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int n;
long long p[101],q[101],r[101],b[101];
long long memo[101];
long long dp(int a){
  if(memo[a] != -1) return memo[a];
  if(r[a] == 0 && b[a] == 0) return memo[a] = p[a] + q[a];
  long long red,blue;
  if(r[a] == 0){
    red = q[a];
    blue = dp(b[a]);
  } else if(b[a] == 0){
    blue = p[a];
    red = dp(r[a]);
  } else {
    red = dp(r[a]);
    blue = dp(b[a]);
  }
  red *= (q[a] / __gcd(red,q[a]));
  blue *= (p[a] / __gcd(blue,p[a]));
  long long m = (blue/p[a])*(red/q[a])/__gcd(blue/p[a],red/q[a]);
  return memo[a] = m*(p[a]+q[a]);
}
int main(){
  while(scanf("%d",&n),n!=0){
    fill(memo,memo+101,-1);
    for(int i=1;i<=n;i++){
      scanf("%lld %lld %lld %lld",&p[i],&q[i],&r[i],&b[i]);
      long long m = __gcd(p[i],q[i]);
      p[i] /= m;
      q[i] /= m;
    }
    long long ans = 0;
    for(int i=1;i<=n;i++){
      ans = max(ans,dp(i));
    }
    printf("%lld\n",ans);
  }
  return (0);
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
int main(){
  int N; cin >> N;
  long long s[N+1];
  s[0] = 0;
  
  long long a;
  REP(i,N){
    cin >> a;
    s[i+1] = s[i]+a;
  }

  sort(s,s+N+1);
  long long r = 0;
  long long c = s[0];
  long long cumu = 1;
  for(int i=1;i<N+1;i++){
    if(c==s[i]){
      cumu++;
    }
    else{
      if(cumu>1){ r += cumu*(cumu-1)/2; }
      cumu = 1;
      c = s[i];
    }
  }
  if(cumu>1){ r+= cumu*(cumu-1)/2;}
  
  cout << r << "\n";
}

Measured memory_bytes: 1792
v = 0
i = 0
a = []
b = []
while v == 0:
    x = input().split()
    if 0 == int(x[0]):
        if 0 == int(x[1]):
            v = 1
        else:
            a.append(int(x[0]))
            b.append(int(x[1]))
            i = int(i) + 1
        
    else:
        a.append(int(x[0]))
        b.append(int(x[1]))
        i = int(i) + 1
for j in range(int(i)):
    if a[j] < b[j]:
        pass
    else:
        c = a[j]
        a[j] = b[j]
        b[j] = c

for j in range(int(i)):
    print('%d %d' % (int(a[j]),int(b[j])))


Measured memory_bytes: 5904
#include<bits/stdc++.h>
#define N 200005
#define LL long long
using namespace std;
const int mo=1e9+7;
vector<int> G[N],E[N]; int d[N],w[N],lw,cnt,z[N],lz;
int n,f[N],F[N],vis[N],ans=1,sum,res,now,cir[N],X,Y,fc[N],xf[N],pr[N],sz[N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
void Tell(int t,int fa)
{
	int i; vis[t]=cnt,now+=2,z[++lz]=t;
	for(i=0;i<G[t].size();i++)
		if(vis[G[t][i]]!=cnt) Tell(G[t][i],t);
		else if(G[t][i]!=fa) X=t,Y=G[t][i];
	now-=G[t].size();
}
void dfs(int t,int fa)
{
	int i; vis[t]=cnt,f[t]=fa;
	for(i=0;i<G[t].size();i++)
		if(vis[G[t][i]]!=cnt) dfs(G[t][i],t);
}
void DFS(int t,int fa)
{
	int i;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa&&!cir[G[t][i]]){
			pr[G[t][i]]=t,DFS(G[t][i],t);
			if(G[t][i]<pr[t])
				E[t].push_back(G[t][i]),d[G[t][i]]++;
		  }
}
void dp(int t)
{
	int i; sz[t]=0,F[t]=1;
	for(i=0;i<E[t].size();i++){
		dp(E[t][i]),sz[t]+=sz[E[t][i]];
		F[t]=1LL*F[t]*F[E[t][i]]%mo*xf[sz[E[t][i]]]%mo;
	  }
	F[t]=1LL*F[t]*fc[sz[t]]%mo,sz[t]++;
}
void solve(int t)
{
	int i;
	now=sum=lw=lz=0,++cnt;
	Tell(t,0);
	if(now){ ans=0; return ;}
	++cnt,dfs(X,0);
	for(i=Y;i;i=f[i]) cir[i]=1,w[++lw]=i;
	for(i=1;i<=lz;i++) E[z[i]].clear(),d[z[i]]=0;
	res=1,now=0;
	for(i=1;i<=lw;i++){
		pr[w[i]]=w[i%lw+1];
		if(w[i%lw+1]>w[(i+lw-2)%lw+1])
			E[w[i]].push_back(w[(i+lw-2)%lw+1]),d[w[(i+lw-2)%lw+1]]++;
	  }
	for(i=1;i<=lw;i++) DFS(w[i],0);
	for(i=1;i<=lz;i++)
		if(!d[z[i]]){
			dp(z[i]);
			res=1LL*res*xf[sz[z[i]]]%mo*F[z[i]]%mo;
		  }
	sum=(sum+res)%mo;
	for(i=1;i<=lz;i++) E[z[i]].clear(),d[z[i]]=0;
	res=1,now=0;
	for(i=1;i<=lw;i++){
		pr[w[i]]=w[(i+lw-2)%lw+1];
		if(w[i%lw+1]<w[(i+lw-2)%lw+1])
			E[w[i]].push_back(w[i%lw+1]),d[w[i%lw+1]]++;
	  }
	for(i=1;i<=lw;i++) DFS(w[i],0);
	for(i=1;i<=lz;i++)
		if(!d[z[i]]){
			dp(z[i]);
			res=1LL*res*xf[sz[z[i]]]%mo*F[z[i]]%mo;
		  }
	sum=(sum+res)%mo;
	ans=1LL*ans*sum%mo;
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	fc[0]=xf[0]=1;
	for(i=1;i<N;i++){
		fc[i]=1LL*fc[i-1]*i%mo;
		xf[i]=fpm(fc[i],mo-2);
	  }
	for(i=1;i<=2*n;i++){
		scanf("%d %d",&x,&y);
		G[x].push_back(y+n);
		G[y+n].push_back(x);
	  }
	for(i=1;i<=2*n;i++)
		if(!vis[i])
			solve(i);
	ans=1LL*ans*fc[2*n]%mo;
	cout<<ans;
	return 0;
}


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

using namespace std;


int main() {

	int N,Y ;
	cin >> N >>Y ;

	int s =Y/1000;

	int x, y, z;
	x = -1;
	y = -1;
	z = -1;

	for (int i = 0; i <= s / 10; i++) {
		for (int j = 0; j <= s / 5; j++) {
			int remain = s - 10 * i - 5 * j;

			if (0 <= remain && remain == N - i - j) {
				x = i;
				y = j;
				z = N - i - j;
			}
		}
	}

	cout << x << " " << y << " " << z << endl;




	return 0;
}




Measured memory_bytes: 256
S = input()
ans = 0
N = len(S)
for i in range(1,N):
    tmp = S[0:N-i]
    M = len(tmp)
    if M % 2 != 0:
        continue
    flg = False
    for k in range(M//2):
        if tmp[k] != tmp[M//2+k]:
            flg = False
            break
        flg = True
    if flg:
        print(M)
        exit()

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

//aをb回繰り返した数を返す
int gen_num(int a, int b) {
	int i;
	double S = 0;
	for (i = 0; i < b; i++) {
		S += a * pow(10, i);
	}
	return (int)S;
}

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

	int A, B;
	A = gen_num(a, b);
	B = gen_num(b, a);

	if (a < b) printf("%d\n", A);
	else printf("%d\n", B);

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  //sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) a[i] -= i;
  sort(a.begin(), a.end());
  ll x = a[a.size() / 2];
  ll result = 0;
  for (int i = 0; i < n; ++i) result += abs(a[i] - x);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env ruby

next_month = false
trade = Hash.new(0)

t = Array.new
n = Array.new
while line = gets
  if line.chomp! == ''
    next_month = true
    next
  end
  c, d = line.split(?,).map(&:to_i)
  trade[c] += 1

  (next_month) ? n << c : t << c
end

(t & n).sort.each do |company|
  puts "#{company} #{trade[company]}"
end

Measured memory_bytes: 8568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		sc.close();

		int mod = 2019;
		int ml = l % mod;
		int mr = r % mod;
		if (ml == 0 || mr == 0 || l / mod < r / mod) {
			System.out.println(0);
		} else {
			int ans = mod;
			for (int i = ml; i < mr; i++) {
				for (int j = i + 1; j <= mr; j++) {
					int val = i * j % mod;
					ans = Math.min(ans, val);
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 25300
#include <stdio.h>
#include <math.h>
int main(void) {
    float wood,range;
    scanf("%f",&wood);
    scanf("%f",&range);
    range=range*2+1;/*観測範囲*/
    int ans=ceil(wood/range);/*本数<範囲*人数*/
    printf("%d\n",ans);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    if(N % 2) {
        cout << N * 2 << endl;
    } else {
        cout << N << endl;
    }
}   

Measured memory_bytes: 256
n = gets.to_s.to_i
x,y = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }.transpose

dist = 0
cnt = 0
(0 ... n).to_a.permutation do |per|
  
  cnt += 1
  per.each_cons(2) do |i,j|
    
    dist += ( ( x[i] - x[j] ) ** 2 + ( y[i] - y[j] ) ** 2 ) ** 0.5
    
  end
end

puts dist / cnt

Measured memory_bytes: 14724
#include<bits/stdc++.h>
using namespace std;
//define
#define int unsigned long long
#define vint vector<int>
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string

//dp
template<class T>inline bool chmin(T& a,T b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class T>inline bool chmax(T& a,T b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
const long long INF=1LL<<60;
long long dp[100010];

//main
signed main(){
  int N,M,O,Q,count=0,count2=0,count3=0;
  for(int i=0;i<100010;i++)dp[i]=INF;
  dp[0]=0;
  double D=0;
  int c='A'-'a';
  char C;
  str S,T;
  cin>>N>>M;
  if(N>9||M>9)cout<<-1<<endl;
  else cout<<N*M<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
int n,m;
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
bool vis[MAXN];int f1,f2;
int dep[MAXN],cal[MAXN],up[MAXN];
void dfs(int x)
{
	vis[x]=1;
	if(dep[x]&1)cal[x]=-1;else cal[x]=1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(!vis[y])dep[y]=dep[x]+1,up[y]=x,dfs(y),cal[x]+=cal[y];
		else if(dep[y]!=dep[x]-1&&!f1)f1=y,f2=x;
	}
}
int sta[MAXN],tp;
int main()
{
//	freopen("a.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}
	dfs(1);
	if(!f1)
	{
		if(cal[1])return pr2(-1),0;
		LL ans=0;for(int i=1;i<=n;i++)ans+=abs(cal[i]);
		return pr2(ans),0;
	}
	else if(!((dep[f2]-dep[f1])&1))
	{
		if(abs(cal[1])&1)return pr2(-1),0;
		int u=cal[1];LL ans=abs(cal[1])/2;
		for(int i=f2;i;i=up[i])cal[i]+=(-u)/2;
		for(int i=f1;i;i=up[i])cal[i]+=(-u)/2;
		for(int i=1;i<=n;i++)ans+=abs(cal[i]);
		return pr2(ans),0;
	}
	else
	{
		if(cal[1])return pr2(-1),0;
		memset(vis,0,sizeof(vis));sta[++tp]=0;
		for(int i=f2;i!=f1;i=up[i])
		{
			vis[i]=1;
			sta[++tp]=cal[i];
		}LL ans=0;
		for(int i=1;i<=n;i++)if(!vis[i])ans+=abs(cal[i]);
		sort(sta+1,sta+1+tp);int mid=(tp+1)/2;
		for(int i=1;i<=tp;i++)ans+=abs(sta[i]-sta[mid]);
		pr2(ans);
	}
	return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<vector<int>> t;

  int n;
  cin >> n;

  t.push_back(vector<int>{0, 0, 0});

  for (int i = 0; i < n; i++) {
    int time;
    cin >> time;
    int x, y;
    cin >> x;
    cin >> y;
    t.push_back(vector<int>{time, x, y});
  }

  for (int i = 1; i < t.size(); i++) {
    int prevtime = t[i - 1][0];
    int prevx = t[i - 1][1];
    int prevy = t[i - 1][2];

    int time = t[i][0];
    int x = t[i][1];
    int y = t[i][2];

    int timediff = time - prevtime;
    int dist = abs(x - prevx) + abs(y - prevy);

    if (timediff < dist) {
      cout << "No" << endl;
      return 0;
    } else {			// time is enough
      int rem = timediff - dist;
      if (rem % 2) {
	cout << "No" << endl;
	return 0;
      }
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin >> N;
    long long ans =0;
    for(int i=0;i<N;i++){
        int a; cin >> a; ans+=a-1;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD=1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Long> a = new ArrayList<>();
        HashMap<Long,Long> energy = new HashMap<>();
        for(int i=0;i<n;i++){
            long tempA = sc.nextInt();
            long tempB = sc.nextInt();
            if(energy.containsKey(tempA)){
                energy.put(tempA,energy.get(tempA)+tempB);
            }else{
                energy.put(tempA,tempB);
                a.add(tempA);
            }
        }

        Collections.sort(a);

        long ans = 0;
        for(Long value:a){
            long count = energy.get(value);
            //System.out.println(value+" "+count);
            for(long i=0;i<count;i++){
                m--;
                ans+=value;
                if(m==0){
                    System.out.println(ans);
                    return;
                }
            }
        }

    }
}


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

using namespace std;

typedef long long ll;
const ll MOD=1e9+7;

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

  ll n,m;cin>>n>>m;
  std::vector<ll> x(n+1),y(m+1);
  ll xtmp,ytmp;
  x[0]=0;y[0]=0;
  cin>>xtmp;
  ll sum=0;
  ll xdp[n+1]={};
  for(ll i=1;i<n;i++){
      cin>>x[i];
      x[i]-=xtmp;
      xdp[i]=(xdp[i-1]+i*x[i]-sum)%MOD;
      sum=(sum+x[i])%MOD;
  }
  cin>>ytmp;
  ll ydp[m+1]={};
  sum=0;
  for(ll i=1;i<m;i++){
      cin>>y[i];
      y[i]-=ytmp;
      ydp[i]=(ydp[i-1]+i*y[i]-sum)%MOD;
      sum=(sum+y[i])%MOD;
  }
  ll res=(xdp[n-1]*ydp[m-1])%MOD;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3456
// 模板
// #include "bits/stdc++.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <queue>
#include <map>
#include <deque>
#include <stack>
#include <cmath>
using namespace std;
#define mm(a,n) memset(a, n, sizeof(a))
#define gcd(a,b) __gcd(a,b) 
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)
typedef long long ll;
typedef unsigned long long ull;
 
void Main();
 
int main() {
    //应清除注释
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w", stdout);
    Main();
    // fclose(stdin);
    // fclose(stdout);
    // system("pause");  //应注释
    return 0;
}
 
void Main() {
    int n;
    ll m;
    cin >> n >> m;
    m *= m;
    int ans = 0;
    int x, y;
    while(n--) {
        cin >> x >> y;
        ll s = (ll)x*x + (ll)y*y;
        if(s <= m) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, a, b, c, d);
	while(true) {
		c -= b;
		if(c <= 0) { OUT("Yes"); break; }
		a -= d;
		if(a <= 0) { OUT("No"); break; }
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back
#define f first
#define s second

#define read1(a) int a; scanf("%d", &a)
#define read2(a, b) int a, b; scanf("%d %d", &a, &b)
#define read3(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c)

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) FOR(i, 0, a)

const int MAX = 2005;

vi v; vi v2;
map<int, int> mpx;
int main() {
    int n; scanf("%d", &n);
    F0R(i, n) {
        read1(k); v.pb(k); v2.pb(k);
    }
    sort(v.begin(), v.end());
    F0R(i, v.size()) { mpx[v[i]] = i; }
    F0R(i, v2.size()) { v2[i] = mpx[v2[i]]; }
    int ct = 0;
    F0R(i, v2.size()) { if (v2[i]%2 != i%2) { ct++; } }
    cout << ct/2 << endl;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
/*----------------------------------------------*/
bool uni[1000000000];

signed main(){
  int n;
  cin>>n;
  rep(i,n){
    int a;cin>>a;
    if(uni[a]){
      cout<<"NO"<<endl;
      return 0;
    }
    uni[a]=true;
  }
  cout<<"YES"<<endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    
    vector<int> d(N);
    
    for(int i = 0; i < N; i++){
        cin >> d.at(i);
    }

    int maxValue = 0;
    int maxIndex = 0;
    for(int i = 0; i< N; i++){
        maxValue = d.at(i);
        maxIndex = i;
        for(int j = i + 1; j < N; j++){
            if(d.at(j) > maxValue){
                maxValue = d.at(j);
                maxIndex = j;
                d.at(j) = d.at(i);
                d.at(i) = maxValue;
            }
        }
    }
    
    int count = 1;
    int temp = d.at(0);
    for(int i = 1; i < N; i++){
        if(d.at(i) != temp){
            count++;
        }
        temp = d.at(i);
    }
    cout << count << endl;
/*
    for(auto e: d){
        cout << e << endl;
    }
*/
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
ll a[2020], b[2020];
ll x;

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

    cin>>N>>x;

    ll s=0;
    for(int i=0;i<N;i++) cin>>a[i], b[i]=a[i], s+=a[i];

    ll res = 1e18;
    for(int k=0;k<N;k++) {
      res = min(res, s + k*x);
      s=0;
      for (int i=0;i<N;i++) {
        b[i] = min(b[i], a[(i+k+1)%N]);
        s += b[i];
      }
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A,green=0,white=0,yellow=0,pink=0;
  string color,G="G",W="W",Y="Y",P="P";
  int judge;
  cin >> N;
 
  // ここにプログラムを追記
  for(int i=0;i<N;i++){
    cin >> color;
    if(color == G){
      green = 1;
    }
    else if(color == W){
      white = 1;
    }
    else if(color == Y){
      yellow = 1;
    }
    else if(color == P){
      pink =1;
    }
    else {
      cout << "error" << endl;
      break;
    }
  }
  judge = green +white + yellow + pink;
  if(judge == 3){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
n= int(input())
a= input()
b= input()
c= input()
ct = 0
for i in range(n):
 tmp1 = a[i]
 tmp2 = b[i]
 tmp3 = c[i]
 if tmp1 == tmp2 and tmp2 ==tmp3:
  ct += 0
 elif tmp1 == tmp2 or tmp1 == tmp3 or tmp2 == tmp3:
  ct += 1
 else:
  ct += 2
print(ct)

Measured memory_bytes: 3064
while True:
    h,w = [int(x) for x in input().split()]
    width = []

    if h == 0 and w == 0:
       break
    else:
        for i in range(w):
            if i == 0 or i==w-1:
                width.append("#")
            else:
                width.append(".")
        print("".join(["#" for j in range(w)]))
        for j in range(h-2):
            print("".join(width))
        print("".join(["#" for j in range(w)]))
        print()


Measured memory_bytes: 5620
/***************************************************************************
                                AUTHOR: SPARSH SINHA
            **************************************************************************/


#include <bits/stdc++.h>
using namespace std;
#define si(N) scanf("%d",&N);
#define sll(N) scanf("%lld",&N);
#define ss(s) scanf("%s",s);
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a; i<=b;i++)
#define fori(i,n) for(int i = 0 ; i < n; i++)
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define debug(x)       cerr<< #x <<" : "<<x<<endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
const int INF = 1e9 + 7;

int N = 2019;
int check(int rl , int rr){
     int min_rem = INT_MAX;
     for( int i = rl ; i<= rr; i++){
           for( int j = i + 1 ; j<=rr; j++){
                min_rem = min((i*j)%N , min_rem);
           }
     }
     return min_rem%N;
}
int main()
{
     ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
      int L , R;
      cin>>L>>R;
      int rl = L%N , rr = R%N;
      int ql = L/N , qr = R/N;
      if(rl == 0 || rr == 0) cout<<0<<endl;
      else{
               if(rr <= rl) cout<<0<<endl;
               else{
                     //here rr > rl
                     if( ql < qr) cout<<0<<endl;
                     else{
                          //if ql = qr
                          //we need to check only for numbers from rl to rr 
                          cout<<check(rl ,rr)<<endl;
                     }
               }
      }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, a[312345];
ll ma[312345], mi[312345];

int main() {
	cin >> n;
	REP(i, 3 * n) scanf("%d", a + i);
	
	priority_queue<int> pq;
	ll sum = 0;
		
	REP(i, 2 * n) {
		pq.push(-a[i]);
		sum += a[i];
		
		if (pq.size() > n) sum += pq.top(), pq.pop();
		if (i >= n - 1) ma[i] = sum;
	}
	
	while (!pq.empty()) pq.pop();
	sum = 0;
	
	for (int i = 3 * n - 1; i >= n; i--) {
		pq.push(a[i]);
		sum += a[i];
		
		if (pq.size() > n) sum -= pq.top(), pq.pop();
		if (i <= 2 * n) mi[i] = sum;
	}
	
	
	ll ans = LLONG_MIN;
	
	FOR(i, n - 1, 2 * n) chmax(ans, ma[i] - mi[i + 1]);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4728
program takahashi_calendar
  implicit none
  integer :: m, d, d1, d10, i, j, ans = 0
  read(*,*) m, d
  do i = 1, m
    do j = 22, d
      d1 = mod(j,10)
      if (d1 < 2) cycle
      d10 = j/10
      if (i == d1*d10) ans = ans+1
    end do
  end do
  write(*,'(i0)') ans
end program takahashi_calendar

Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if ((x+r <= w) && ((x-r) >= 0) && (y+r <= h) && (y-r >= 0)) {
        printf("Yes\n");
    } else { 
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 2e5+5;
const int MOD = 1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}
 
int N;
pair<int,int> A[MAXN];
int ans[MAXN];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i].fi;
        A[i].se = i;
    }

    sort(A, A+N);
    for (int i = 0; i < N-1; i++) ans[A[i].se] = A[N-1].fi;
    ans[A[N-1].se] = A[N-2].fi;

    for (int i = 0; i < N; i++) cout << ans[i] << '\n';
    return 0;
}


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


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

    string ans;
    while (n) {
        n--;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]

from collections import Counter

c = Counter(a)
d = Counter(b)

max = 0

for key, value in c.items():
    if value - d[key] > max:
        max = value - d[key]

print(max)

Measured memory_bytes: 3316
import collections

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnitDict(dict):

    def __init__(self, iterable=None, wrapper=lambda x: x):
        super().__init__(self)
        self.wrapper = wrapper
        if iterable is not None:
            self.update(iterable)

    def __missing__(self, key):
        self[key] = self.wrapper(key)
        return self[key]


class UnionFind(object):

    def __init__(self, nodes=None):
        self.par = UnitDict(wrapper=lambda x: x)
        self.rank = collections.defaultdict(int)
        self.groups = UnitDict(wrapper=lambda x: {x})
        if nodes is not None:
            for node in nodes:
                _, _, _ = self.par[node], self.rank[node], self.groups[node]

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def are_same(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def elements(self, node):
        return self.groups[self.root(node)]

    def size(self, node):
        return len(self.elements(node))

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.groups[x].update(self.groups[y])
            self.groups[y].clear()
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


islands = UnionFind(range(N))
ans_list = []
last = int(N * (N-1) / 2)
ans_list.append(last)
for i in range(1, M):
    if islands.are_same(AB[-i][0], AB[-i][1]):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1]-islands.size(AB[-i][0])*islands.size(AB[-i][1]))
    islands.unite(AB[-i][0], AB[-i][1])


for i in range(1, len(ans_list)+1):
    print(ans_list[-i])

Measured memory_bytes: 148088
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int count = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] != arr[i - 1]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 25940
using System;

public class Program
{
    public static int ANum = 0;
    public static int BNum = 0;
    public static int CNum = 0;

    public static int AValue = 500;
    public static int BValue = 100;
    public static int CValue = 50;

    public static void Main()
	{
        ANum = int.Parse(Console.ReadLine());
        BNum = int.Parse(Console.ReadLine());
        CNum = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());

        Console.WriteLine(Coin(X, AValue));
    }

    static int Coin(int X, int value)
    {
        var count = 0;
        if (value == AValue)
        {
            for (var i = 0; i <= ANum; i++)
            {
                if (i * AValue > X)
                {
                    break;
                }

                count += Coin(X - i * AValue, BValue);
            }
            return count;
        }
        else if (value == BValue)
        {
            for (var i=0; i<=BNum; i++)
            {
                if (i * BValue > X)
                {
                    break;
                }

                count += Coin(X - i * BValue, CValue);
            }
            return count;
        }
        else if (value == CValue)
        {
            return (X / CValue <= CNum) ? 1 : 0;
        }
        else
        {
            return 0;
        }
    }
}


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

string toLower(string str) {
    for(int i=0; i<str.length(); i++) {
	if(isupper(str[i])) str[i] = tolower(str[i]);
    }
    return str;
}

int main() {
    string str;
    cin >> str;
    int sum = 0;
    string temp;

    while(true) {
	cin >> temp;
	if(temp == "END_OF_TEXT") break;
	temp = toLower(temp);
	if(temp == str) ++sum;
    }

    cout << sum << endl;
}

Measured memory_bytes: 1200
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

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

    int total = 0;
    for (int i = 0; i <= n; i++){
        int t = i;
        int sum = 0; 
        while(t > 0){
            sum += t % 10;
            t /= 10;
        }
        if (sum >= a && sum <= b){
            total += i;
        }
    }
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

ll fact(int n){
    ll ret = 1LL;
    rep(i, 1, n + 1){
        ret = MUL(ret, i, mod);
    }
    return ret;
}

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

    ll n, m; cin >> n >> m;
    if(abs(n - m) >= 2){
        cout << 0 << endl;
        return 0;
    }

    ll res = MUL(fact(n), fact(m), mod);
    if(n == m) res = MUL(res, 2LL, mod);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
  }
  sort(A.begin(), A.end());
  
  auto Can = [&](int idx) {
    ll s = 0;
    for (int i = 0; i <= idx; ++i) {
      s += A[i];
    }
    
    for (int i = idx + 1; i < N; ++i) {
      if (2 * s < A[i]) {
        return false;
      }
      
      s += A[i];
    }
    
    return true;
  };
  
  int lo = 0, hi = N;
  while (lo < hi) {
    int med = (lo + hi) / 2;
    if (Can(med)) {
      hi = med;
    } else {
      lo = med + 1;
    }
  }
  
  cout << N - lo << '\n';
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    string s;
    cin >> n >> a;
    if(n % 500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    long long n,k,c=0;
    cin >> n >> k;
    long long arr[n];
    for (int i = 0 ; i<n ; i++) {
        cin >> arr[i];
    }
    sort(arr , arr+n);
    for (long long i = n-1 ; i>=0 ; i--) {
        if (k>0) {
            arr[i] = 0;
            k--;
        }
    }
    for (long long i = 0 ; i<n ; i++) {
        if (arr[i] > 0) {
            c+=arr[i];
            arr[i] = 0;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
string s;

cin >>s;
if(s=="a"||s=="i"||s=="u" || s=="e"||s=="o")
cout <<"vowel"<<endl;
else cout<<"consonant"<<endl;
}


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int A, B;
  cin >> A >> B;
  int N = ((B - A) * (B - A + 1)) / 2;
  cout << N - B << endl;
}
  

Measured memory_bytes: 3608
## coding: UTF-8
#最後の方のテストケースでREになってしまう。時間切れ。
#from decimal import *
#from itertools import permutations, combinations,combinations_with_replacement,product

#N = int(input())

s = input().split()
p = [int(w) for w in s]

#print(p)

I = p[0]
O = p[1]
#T = p[2] #使わない
J = p[3]
L = p[4] 
#S = p[5] #使わない
#Z = p[6] #使わない

answer = 0

answer += O #O型は最初に全部使います。


if(I % 2 == J % 2 and I % 2 == L % 2):
    #[odd,odd,odd] or [even,even,even]
    #[0,0,0],[0,0,even],[0,even,even]
    answer += I+J+L
elif( (I + J + L) % 2 == 1):
    #[even,even,odd]
    #[0,0,odd],[0,even,odd]
    answer += I+J+L-1
elif( (I == 0 and J % 2 == 1 and L % 2 == 1)  or (J == 0 and I % 2 == 1 and L % 2 == 1)  or  (L == 0 and J % 2 == 1 and I % 2 == 1)  ):
    answer += I+J+L-2
else:
    #[even,odd,odd]
    #if(min(I,J,L) % 2 == 0):
        #answer += I+J+L - 2
    #else:
        #answer += I+J+L - 1
    answer += I+J+L-1

print(answer)


Measured memory_bytes: 3064
n, m, c = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = 0
n.times do
  as = gets.split.map(&:to_i)
  sum = [as, bs].transpose.inject(0) do |r, (a, b)|
    r + a * b
  end

  ans += 1 if sum + c > 0
end

puts ans


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

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

using namespace std;

using ll = long long;

int main(void)
{
    constexpr int SHIFT_MAX = 40;

    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    
    ll f = 0;
    ll g = 0;

    REP(shift, SHIFT_MAX) {
        ll mask = 1ll << shift;
        ll count_ones = 0;
        REP(i, N) {
            if (A[i] & mask) {
                count_ones++;
            }
        }
        ll count_zeros = N - count_ones;
        ll x0 = count_zeros * mask;
        ll x1 = count_ones * mask;
        if (K & mask) {
            f = max(x0 + f, x1 + g);
        } else {
            f = x1 + f;
        }
        g += max(x0, x1);
    }
    cout << f << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	std::string s, t;
	std::cin >> s >> t;
	std::size_t count = 0;
	for (auto i : boost::irange(s.size()))
	{
		count += s[i] != t[i];
	}
	std::cout << count << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3804