akhauriyash/Code-Regression huggingface dataset:
/* compatible with http://kk.kake.info.waseda.ac.jp/~kakehi/lp12/wl/ */
#include <stdio.h>
enum{M=5000};
bigint_init(int a[], int x){
	int z;
	z=0;
	while(z<=M){a[z]=0;z=z+1;}
	a[M]=0;
	while(x/10){a[a[M]]=x%10;a[M]=a[M]+1;x=x/10;}
	a[a[M]]=x%10;
	a[M]=a[M]+1;
}
bigint_print(int a[]){
	int i;
	i=a[M]-1;
	while(i>-1){fputc(a[i]+'0',stdout);i=i-1;}
}
bigint_add(int a[], int x[]){
	int i,c;
	i=0;
	c=0;
	while(i<M){
		a[i]=a[i]+x[i]+c;
		c=a[i]/10;
		a[i]=a[i]%10;
		if(a[i])a[M]=i+1;
		i=i+1;
	}
}
bigint_mul(int _a[], int x[]){
	int i=_a[M]-1,j,c=0;
	int a[M];
	while(c<M){a[c]=0;c=c+1;}
	c=0;
	while(i>-1){
		j=0;
		while(j<x[M]){
			a[i+j]+=_a[i]*x[j];
			j=j+1;
		}
		i=i-1;
	}
    for(i=0;i<M;i++){
      a[i]+=c;
      c=a[i]/10,a[i]%=10;
      if(a[i])_a[M]=i+1;
    }
    memcpy(_a,a,sizeof(a));
}

int main(){
	int f1[M+1],f2[M+1],f3[M+1];
	bigint_init(f1,1);
	int i=2,n;
	while(i<1501){
		bigint_init(f2,i);
		bigint_mul(f1,f2);
		i=i+1;
	}
	bigint_init(f2,2);
	bigint_add(f1,f2);
	bigint_print(f1);
	fputc('\n',stdout);
	i=0;
	scanf("%d",&n);
	while(i<n){
		bigint_init(f1,i+2);
		bigint_print(f1);
		fputc('\n',stdout);
		i=i+1;
	}
	return 0;
}

/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = input()
    
    w_acc, b_acc = [0], [0]
    for i in range(N):
        w_acc.append(w_acc[-1] + (S[i] == '.'))
        b_acc.append(b_acc[-1] + (S[i] == '#'))
    
    ans = w_acc[-1]
    for i in range(1, N + 1):
        ans = min(ans, b_acc[i] + w_acc[-1] - w_acc[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 67680
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,h,w,i,sx,sy;
char a[nmax],b[nmax];
bool ok(char c,char c1)
{
	int d,x=0,i;
	if(c=='L')d=sy;
	if(c=='R')d=w-sy+1;
	if(c=='U')d=sx;
	if(c=='D')d=h-sx+1;
	for(i=1;i<=n;i++)
	{
		if(a[i]==c)x++;
		if(x==d)return 1;
		if(b[i]==c1)
		{
			if(c=='L' && sy-(x-1)<=w)x--;
			if(c=='R' && sy+(x-1)>=1)x--;
			if(c=='U' && sx-(x-1)<=h)x--;
			if(c=='D' && sx+(x-1)>=1)x--;
		}
	}
	return 0;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>h>>w>>n>>sx>>sy;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>b[i];
	if(ok('L','R')|ok('R','L')|ok('U','D')|ok('D','U'))cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	int n, m;
 	cin >> n >> m;
 	vector<int> card(n);
 	vector<pair<int, int> > change(m);
 	for (int i = 0; i < n; i++){
 		cin >> card[i];
 	}
 	for (int i = 0; i < m; i++){
 		cin >> change[i].second >> change[i].first;
 	}
 	sort(change.begin(), change.end(), greater<pair<int, int> >());

 	int i = 0, coun = 0;
 	while (coun < n){
 		for (int j = 0; j < change[i].second; j++){
 			card.push_back(change[i].first);
 		}
 		coun += change[i].second; 
 		i++;
 		if (i == m) break;
 	}
 	sort(card.begin(), card.end(), greater<int>());

 	ll ans = 0;
 	for (i = 0; i < n; i++){
 		ans += card[i];
 	}
 	cout << ans << endl;
 	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int A=S.size();
  bool a=false;
  while(!a){
    A-=2;
    S=S.substr(0,A);
    string T=S.substr(0,A/2),U=S.substr(A/2,A/2);
    if(T==U){
      cout << A << endl;
      a=true;
    }
  }
}
    

Measured memory_bytes: 3628
def makep(n, l, mask):
    a = l[0] & mask
    b = l[-1] & mask
    ll = len(l)
    diff = a ^ b
    for i in range(n):
        if(((diff >> i) & 1) != 0):
            diff = 1 << i
            break

#    print("a = {}, b = {}, mask = {}, ll = {}, diff = {}".format(a, b, mask, ll, diff))

    for i, elem in enumerate(l[1:-1], 1):
        if(i < ll // 2):
            l[i] = (l[i] & ~diff) | (a & diff)
        else:
            l[i] = (l[i] & ~diff) | (b & diff)

#    print("l = {}".format(l))

    nextbit = mask & ~diff
    if(0 != nextbit):
        for i in range(n):
            if(((nextbit >> i) & 1) != 0):
                nextbit = 1 << i
                break
        l[ll // 2 - 1] = (l[ll // 2 - 1] | (a & ~diff)) ^ nextbit
        l[ll // 2 - 0] = (l[ll // 2 - 0] | (a & ~diff)) ^ nextbit

#        print("nextbit = {}, ll//2 = {}, l = {}".format(nextbit, ll//2, l))

    if(ll > 2):
        l[:ll // 2] = makep(n, l[:ll // 2], mask & ~diff)
        l[ll // 2:] = makep(n, l[ll // 2:], mask & ~diff)
    return(l)

N, A, B = map(int, input().split())

A1num = "{:b}".format(A).count("1")
B1num = "{:b}".format(B).count("1")

if((A1num % 2) == (B1num % 2)):
    print("NO")
    exit()

print("YES")

p = [0] * (2 ** N)
p[0] = A
p[-1] = B
p = makep(N, p, 2 ** N - 1)

#for i in p:
#    print("{:08b}".format(i))

print(" ".join(map(str, p)))


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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



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

const int N = 200005;


void solve()
{
	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return;

}

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



	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main() {
	char A[150][150];
	char B[50][50];
	bool can = false;
	int M, N;

	for (int i = 0; i < 150; i++)
	{
		for (int j = 0; j < 150; j++)
		{
			A[i][j] = 'a';
		}
	}


	cin >> M >> N;
	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < M; j++)
		{
			bool flg = true;
			for (int x = 0; x < N; x++)
			{
				for (int y = 0; y < N; y++)
				{
					if (A[i + x][j + y] != B[x][y]) {
						flg = false;
					}
				}
			}
			if (flg) {
				can = true;
			}
		}
	}
	if (can) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B");
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

template<typename T, typename F> const T bsearch(T l, T h, const T& err, const F& f) {
  while(h - l > err) {
    auto m = (l + h) / 2;
    if(f(m)) h = m;
    else     l = m;
  }
  return h;
}

using LL = long long;

int main() {
  LL N, K;
  cin >> N >> K;
  vector<LL> A(N), F(N);
  for(auto* v: {&A, &F}) for(auto& i: *v) cin >> i;

  sort(begin(A), end(A));
  sort(begin(F), end(F));
  reverse(begin(F), end(F));

  LL L=-1, H=1e18+1, R=1e6+1, E=1;
  cout << bsearch(L,H,E,[&](auto x){
    LL n = 0;
    for(auto i=0; i<N; ++i) n += bsearch(L,R,E,[&a=A[i],&f=F[i],&x](auto k){return (a-k)*f<=x;});
    return n <= K;
  }) << endl;
}


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

using namespace std;


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

    int n , m;
    cin >> n >> m;

    priority_queue<int> pq;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        pq.push(x);
    }

    while (m--) {
        int t = pq.top();
        pq.pop();
        pq.push(t / 2);
    }

    long long ans = 0;
    while (pq.size()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<string> s;
    vector<int> t;
    for(int i = 0; i < n; i ++)
    {
        string temp;
        int ti;
        cin >> temp >> ti;
        s.push_back(temp);
        t.push_back(ti);
    }
    string k;
    cin >> k;
    int res = 0;
    int j = 0;
    for(;j < n; j ++)
    {
        if(s[j] == k)
        break;
    }
    j ++;
    for(;j < n; j ++)
    {
        res += t[j];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int memo[50][50];

int main(){
	int H, W, map[50][50];
	std::cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char c;
			std::cin >> c;
			map[i][j] = c - '0';
		}
	}

	for(int i=1;i<H;i++)memo[i][0] = memo[i-1][0] + map[i][0];
	for(int j=1;j<W;j++)memo[0][j] = memo[0][j-1] + map[0][j];
	for(int i=1;i<H;i++){
		for(int j=1;j<W;j++){
			memo[i][j] = std::min(memo[i-1][j] + map[i][j], memo[i][j-1] + map[i][j]);
		}
	}

	std::cout << memo[H-1][W-1] << std::endl;
}

Measured memory_bytes: 1176
#include <stdio.h>
#define MAX 101
int main(){
  int n,i,a,b,j,c,data[MAX][MAX];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++) {
      data[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d%d",&a,&b);
    for(j=1;j<=b;j++){
      scanf("%d",&c);
      data[i][c]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",data[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>

using namespace std;

int main(){
	string a,b,c;

	cin>>a>>b>>c;

	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

long long n,f[100005];

long long did(long long b)
{
	long long s=0,t=0;
	for(long long i=1;i<=n;i++)
	{
		b*=-1;
		s+=f[i];
		if(b==-1&&s>=0)
		{
			t+=(s+1);
			s=-1;
		}
		else if(b==1&&s<=0)
		{
			t+=(1-s);
			s=1;
		}
	}
	
	return t;
}

int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++) scanf("%lld",&f[i]);
	cout<<min(did(1),did(-1))<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    string s;
    cin >> s;
    REP(i,s.length()){
        if(s[i] == '1'){
            s[i] = '9';
        }else{
            s[i ]= '1';
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<string>
using namespace std;
string str1;
int l,r,m;
int a,c,b;
int n;
int defdef(string str){
	if (str=="Male") return 0;
	if (str=="Female") return 1;
	if (str=="Vacant") return -1;

}


int main(){
	cin>>n;
	l=0;
	cout<<l<<endl;
	cout.flush();
	cin>>str1;
	r=l+n;
	a=defdef(str1);
	c=a;
	if (c==-1)return 0;
	while (true){
		m=(l+r)/2;
		cout<<m<<endl;
		cout.flush();
		cin>>str1;
		b=defdef(str1);
		if (b==-1)return 0;
		if ((a+b+l+m)%2==1){r=m;c=b;} else {l=m;a=b;}
	}
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n,temp;
	cin >> n >> m;
	if(m > n){
		temp = m;;
		m = n;
		n = temp;
	}
	for(int i = 0;i < n;++i){
		cout << m;
	} 
	return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> a(N);
    REP(i,N){
        cin >> a[i];
    }

    sort(ALL(a));

    int ng = -1;
    int ok = N-1;
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(2*a[mid] > a[N-1]){//ここに条件をかく
            ok = mid;
        }else{
            ng = mid;
        }
    }

    int ok_d = abs(a[N-1]-a[ok]*2);
    int ng_d = abs(a[N-1]-a[ng]*2);

    if(ok_d<ng_d) cout << a[N-1] << " " << a[ok] << endl;
    else cout << a[N-1] << " " << a[ng] << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <vector>
using namespace std;
int M,K,len;
vector<int> v;
int visit[1<<20];
int main(){
	scanf("%d %d",&M,&K);
	len=(1<<M)-1;
	if(K!=0){
		if(M==1||K>len){
			printf("-1");
			return 0;
		}
		int num=K;
		for(int i=0;num;i++){
			if(num%2){
				v.push_back(1<<i);
				visit[1<<i]=1;
			}
			num/=2;
		}
		if(true){
			for(int i=0;i<v.size()/2;i++) printf("%d ",v[i]);
			
			for(int i=0;i<=len;i++) if(visit[i]==0) printf("%d ",i);
			
			for(int i=v.size()/2-1;i>=0;i--) printf("%d ",v[i]);
			
			for(int i=v.size()/2;i<v.size();i++) printf("%d ",v[i]);
			
			for(int i=len;i>=0;i--) if(visit[i]==0) printf("%d ",i);
			for(int i=v.size()-1;i>=(int)v.size()/2;i--) printf("%d ",v[i]);
		}
	}
	else{
		for(int i=0;i<=len;i++) printf("%d %d ",i,i);
	}
}
//0101

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

// #define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
typedef long double ld;

ld calcds(ld l1,ld a1,ld b1,ld l2, ld a2, ld b2){
  return (l1-l2)*(l1-l2)+(a1-a2)*(a1-a2)+(b1-b2)*(b1-b2);
}
int main(){
  ld ans = 0.0;
  int m,n;
  cin >> n >> m;
  vector<long double>l,a,b;
  REP(i,n){
    long double ll,aa,bb;
    cin >> ll >> aa >> bb;
    l.pb(ll); a.pb(aa); b.pb(bb);
  }
  int tmp[1000];
  int cnt = 0;
  REP(i,n) tmp[i] = 1;
  REP(i,n-m) tmp[i] = 0;
  do {
    cnt++;
    ld sum = 0.0;
    REP(i,n){
      FOR(j,i,n){
        if(tmp[i]==1&&tmp[j]==1){
          sum += calcds(l[i],a[i],b[i],l[j],a[j],b[j]);
        }
      }
    }
    ans = max(ans,sum);
  } while ( next_permutation (tmp,tmp+n));
  cout << fixed << setprecision(25) << ans << endl;
  return 0;
}

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

using namespace std;

const int INF = 1e9 + 7;
const int N = (int)2e5 + 3;

typedef long long ll;
typedef long double ld;

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

int n, a[N], k;
int main(){
  scanf ("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i){
    scanf ("%d", a + i);
  }
  int ans = INF;
  for (int i = 1; i + k - 1 <= n; ++i){
    ans = min(ans, abs(a[i]) + abs(a[i + k - 1] - a[i]));
    ans = min (ans, abs(a[i + k - 1]) + abs(a[i + k - 1] - a[i]));
  }
  printf ("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#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--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, 3 * N) cin >> A[i];
	sort(A, A + 3 * N);
	ll res = 0;
	rep(i, 0, N) {
		res += A[N + i * 2];
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n, m;
    cin >> n >> m;
    if(abs(n - m) >= 2){
        cout << 0;
        exit(0);
    }
    int x = 1;
    int y = 1;
    for(int i = 2; i <= n; i++){
        x = x * i % (int)(pow(10, 9) + 7);
    }
    for(int i = 2; i <= m; i++){
        y = y * i % (int)(pow(10, 9) + 7);
    }
    if(n == m){
        cout << (x % (int)(pow(10, 9) + 7)) * (y % (int)(pow(10, 9) + 7)) * 2 % (int)(pow(10, 9) + 7);
    }else{
        cout << (x % (int)(pow(10, 9) + 7)) * (y % (int)(pow(10, 9) + 7)) % (int)(pow(10, 9) + 7);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,p,sum,q;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(b<c||d<a)
    {
        sum=0;
    }
    else
    {
       if(b>d)
        p=d;
        else
        p=b;
        if(a>c)
            q=a;
        else
            q=c;

        sum=p-q;

    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        int sum = 0;
        for(int i = 0; i<m; i++){
            sum+=in.nextInt();
        }
        out.println(sum>=n?"Yes":"No");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 42724
#include <stdio.h>
 
 
int main() {
    int i, n;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) printf(" %d", i);
        else {
            while (x) {
                if (x % 10 == 3) {
                    printf(" %d", i);
                        break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
  return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 25 )
int main(){
  int W, N, v[1000], w[1000], dp[1001], cnt = 0;
  char op;
  while(cin >> W >> N , W){
    fill_n(dp,1001,0);
    for(int i = 0 ; i < N ; i++ ) cin >> v[i] >> op >>  w[i];
    for(int i = 0 ; i < N ; i++ ){
      for(int j = W ; j >= w[i] ; j-- ){
        dp[j] = max( dp[j], dp[j - w[i]] + v[i]);
      }
    }
    int ret = 0;
    for(int i = 0 ; i <= W ; i++ ){
      if(dp[i] > dp[ret]) ret = i;
    }
    cout << "Case " << ++cnt << ":" << endl << dp[ret] << endl << ret << endl;
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const int MAX_N = 1<<19;

/*    BIT  sum:O(logN)   add:O(logN)  */

//[1,n]
class BIT{
public:
  int bit[MAX_N+1],n;
  BIT(){memset(bit,0,sizeof(bit));}
  BIT(int n){this->n=n,memset(bit,0,sizeof(bit));}

  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
};


ll n,p,Q;
PP C[MAX_N];

int main(){
  cin>>n>>p>>Q;
  BIT B(n);

  for(int i=0;i<n;i++){
    cin>>C[i].s.f;
    C[i].s.s=i+1;
    C[i].f=-(n-i-1)*p+C[i].s.f;
  }
  sort(C,C+n,greater<PP>());

  ll sum=n*(2*Q*p+(n-1)*p)/2,ans=sum;
  for(int i=0;i<n;i++){
    ll idx=C[i].s.s,cost=C[i].s.f;
    ll l=B.sum(idx),r=i-l;
    sum+=-(Q+(idx-1)-l*2)*p-(n-idx-r)*p*2+cost;
    B.add(idx,1);
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 17428
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] number = line.split(" ");
        int n = Integer.parseInt(number[0]);
        int m = Integer.parseInt(number[1]);
        if(n + m < 10){
            System.out.println(n + m);
        } else {
            System.out.println("error");
        }
    }
}

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

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

long long lcm(long long a, long long b){
    return a*b/gcd(a,b);
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    long long a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    return 0;
}

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

#define M_PI 3.14159265358979323846264338327950288
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

int main() {
#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
#endif
    LL Q, H, S, D, N, P;
    LL res = 0;
    cin >> Q >> H >> S >> D >> N;
    P = min(4*Q, min(2*H, S));
    if (2 * P <= D) {
        res = N * P;
    } else {
        res = (N / 2) * D + (N % 2) * P;
    }
    cout << res << endl;
    return 0;
}


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

void print(vector<int> &a){
cout<<a[0];
for(int i=1;i<a.size();i++)cout<<' '<<a[i];
cout<<endl;
return ;
}
void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
	return ;
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];

	for(int i=0;i<n;i++){
		int v= a[i];
		int j=i-1;
		while(j>=0&&a[j]>v){
		a[j+1]=a[j];
		a[j]=v;
		j--;
		}
	print(a);
	}


	return 0;
}



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

// long long int answer[10002];
long long int ans(int in, long long int answer[]){
	if (in == 1){
		answer[in] = 2;
		return answer[1];
	}
	answer[in] = ans(in - 1, answer) + in;
	return answer[in];
}

int main(){
	int in,result;

	// ans(10000, answer);
	while (cin >> in, !cin.eof()){
		result = 1;
		for (int i = 0; i < in; i++){
			// +1, +2, +3,..
			result += (i+1);
		}
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>

using namespace std;

class c_bubble
{
private:
    int n;
    long x[100];
    
public:
    void f_bubble();

};

void c_bubble::f_bubble()
{
    int i, j;
    int temp1;
    int c;
    
    cin >> n;
    for ( i = 0; i < n; ++i){
        cin >> x[i];        
    }
    
    c = 0;
    
    for ( i = 0; i < n; ++i){
        for ( j = n-1; j >= i+1; --j){
            if (x[j] < x[j-1]){
                temp1 = x[j];
                x[j] = x[j-1];
                x[j-1] = temp1;
                c += 1;
            }
        }
    }
    
    for ( i = 0; i < n; ++i){
        cout << x[i];
        if( i == n-1){
            cout << endl;
        }else{
            cout << " ";
        }        
    }
    cout << c << endl;
}

int main(){
    c_bubble bubble01;
    
    bubble01.f_bubble();
    
    return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<ctype.h>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int a[17][17],b[17][17],cnt;
int main(){
	int n=read(),k=read();
	----n;
	int ans=n/11*5;
	n%=11;
	for(int i=1;i<=13;++i)
		for(int j=1;j<=7;++j)
			b[i][j]=++cnt;
	for(int i=1;i<=11;++i)
		for(int j=1;j<=5;++j)
			for(int k=0;k<=2;++k)
				for(int l=0;l<=2;++l)
					a[i][j]=(a[i][j]+b[i+k][j+l])%11;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=5;++j)
			ans+=a[i][j]==k;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define inf 1000000000000000000


int main()
{    

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
cin>>n;
ll a[100000]={-1};
a[0]=0;
ll w,m;
cin>>w; 
pll b[n+1];
for(ll i=1;i<=n;i++)
{
	cin>>b[i].ff>>b[i].ss;
}

for(ll i=1;i<=n;i++)
{	
	for(ll j=100000;j>=0;j--)
	{		

		if(a[j]!=-1)
		{	
			if(b[i].ff+j<100001)
			{
				m = max(b[i].ss+a[j],a[j+b[i].ff]);
				a[j+b[i].ff] = m;
			}
		}
	}
}

	cout<<a[w]<<endl;



}

Measured memory_bytes: 1024
N = int(input())
D1= [0] * N
D2 = [0] * N
for i in range(N):
    D1[i],D2[i] = map(int,input().split())

zorome = 0
for i in range(N):
    if D1[i] == D2[i]:
        zorome += 1
        if zorome == 3:
            print("Yes")
            exit()
    else:
        zorome = 0

print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>

#define INF 100000000
#define MOD 1000000007

#define ll long long

using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << '0' << endl;
		return 0;
	}
	ll factn = 1;
	ll factm = 1;
	for (ll i = 1; i <= n; ++i) {
		factn *= i;
		factn %= MOD;
	}
	for (ll i = 1; i <= m; ++i) {
		factm *= i;
		factm %= MOD;
	}
	if (abs(n - m) == 0) {
		cout << (factn * factm) % MOD * 2 % MOD << endl;
	}
	else {
		cout << (factn * factm) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,i;
    int x = 0;
    cin >> a >> b >> c;
    
    for(i = a; i <= b; i++){
        if(c % i == 0){
            x++;
        }
    }
    cout << x;
    cout << endl;
}


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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

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

	int n = 0;
	cin >> n;

	vector<int> v(n);
	vector<int> res(n, 0);

	for (auto &x : v) 
		cin >> x;

	for (int i = 1; i < n; i++) {
		if (v[i - 1] >= v[i])
			res[i] = res[i - 1] + 1;
		else
			res[i] = 0;
	}

	cout << *max_element(ALL(res)) << '\n';

	return 0;
}

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

int main()
{
    int h, w;
    int i, j, judge = 1;
    char save;
    
    cin >> h >> w;
    
    int s[h+2][w+2];
    
    for(i = 0; i <= h+1; i++) {
        for(j = 0; j <= w+1; j++) {
            s[i][j] = 0;
        }
    }
    
    for(i = 1; i <= h; i++) {
        for(j = 1; j <= w; j++) {
            cin >> save;
            if(save == '#') { s[i][j] = 1; }
        }
    }
    
    for(i = 1; i <= h; i++) {
        for(j = 1; j <= w; j++) {
            
            if((s[i][j] == 1) && (s[i-1][j] == 0) && (s[i][j-1] == 0) && (s[i+1][j] == 0) &&(s[i][j+1] == 0)) {
                judge = 0;
            }
            
        }
    }
    
    if(judge == 1) { cout << "Yes\n"; }
    else { cout << "No\n"; }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 505

int main(){

    ll n;
    cin >> n;
    ll F[n][10];
    ll P[n][10];
    
    REP(i,n){
        REP(j,10){
            cin >> F[i][j];
        }
    }
    REP(i,n){
        REP(j,11){
            cin >> P[i][j];
        }
    }

    ll ans = LLONG_MIN;
    for(ll i = 1;i < (1LL<<10LL);i++){

        //ビットの部分
       
        ll tmp = 0;//利益
        for(ll j = 0;j < n;j++){
            //n個のお店について
            ll cnt = 0;//空いている時間が何個あるか
            for(ll k = 0;k < 10;k++){

                if((i>>k) & 1 && F[j][k]){
                    //bitが立っている:開けたい && F[j][k]が1:kの時間帯は店nは営業中
                    cnt++;
                }                
            }
            tmp += P[j][cnt];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using Pii = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _GLIBCXX_DEBUG
 
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
 
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


// 各操作を行う関数を実装する
 
// AとBに共通して含まれる要素からなる集合を返す
int main(){
  int N,A,B;
  cin >>N>>A>>B;
  int sum_a = 0;
  for (int i =1;i <= N;i++){
    int c =0;
    int t =i;
    for( int j =0; j<5 ; j++){
      c += t % 10;
      t /= 10;
    }
     if(A <= c && c <= B ){
       sum_a += i;
     }
    
  }
  cout << sum_a;
}

Measured memory_bytes: 3564
fun main(args: Array<String>) {
  val input1 = readLine()!!.split(" ").map(String::toInt)
  val days = input1[0]
  val count = input1[1]
  var homeWorkDays = 0
  val work = readLine()!!.split(" ").map(String::toInt)
  homeWorkDays = work.sum()
  val result = if (days < homeWorkDays) -1 else days - homeWorkDays
  println(result)
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;
int a[N];

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (i >= k) {
      if (a[i] > a[i-k]) puts("Yes");
      else puts("No");
    }
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int qAns = 0;
  int pAns = 0;
  int cnt = 0;
  cin >> n;
  vector<int> vec(n);
  vector<int> p(n);
  vector<int> q(n);
  for(int i = 0; i < n; i++){
    vec.at(i) = i+1;
  }
  for(int i = 0; i < n; i++){
    int buf;
    cin >> buf;
    p.at(i) = buf;
  }
  for(int i = 0; i < n; i++){
    int buf;
    cin >> buf;
    q.at(i) = buf;
  }
  do{
    if(vec == p) pAns = cnt;
    if(vec == q) qAns = cnt;
    cnt++;
  }while(next_permutation(vec.begin(),vec.end()));
  cout << abs(pAns - qAns) << endl;
}

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

#define pb push_back
#define loop(i,l,r) for(int i = (l); i < (r); i++)
#define rloop(i,r,l) for(int i = (r-1); i >= (l); i--)
#define refloop(x, v) for(auto& x : (v))
#define exists(m,e) if((m).find(e) != (m).end())
#define nexists(m,e) if((m).find(e) == (m).end())
#define sortaka(v) sort((v).begin(), (v).end())
#define rsort(v) sort((v).rbegin(), (v).rend())
#define lower_bound_index(v, x) (lower_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] >= x
#define upper_bound_index(v, x) (upper_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] > x
#define scanint(x) scanf("%d", &(x))
#define scanfloat(x) scanf("%f", &(x))
#define scanll(x) scanf("%lld", &(x))
#define scanchar(x) scanf("%c", &(x))
#define scanstring(x) scanf("%s", &(x))
#define printint(x) printf("%d", x)
#define printfloat(x) printf("%.9f", x)
#define printll(x) printf("%lld", x)
#define printchar(x) printf("%c", x)
#define printstring(x) printf("%s", x)
#define printintnewline(x) printf("%d\n", x)
#define printfloatnewline(x) printf("%.9f\n", x)
#define printllnewline(x) printf("%lld\n", x)
#define printcharnewline(x) printf("%c\n", x)
#define printstringnewline(x) printf("%s\n", x)
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))

typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<string> vs;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<vector<pair<long long, long long>>> vvpll;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);

    int n; cin >> n;
    vi f(n), s(n);
    loop(i, 0, n){
        cin>>f[i]>>s[i];
    }

    bool pos = false;
    loop(i, 0, n-2){
        if(f[i] == s[i] && f[i+1] == s[i+1] && f[i+2] == s[i+2]){
            pos = true;
            break;
        }
    }

    if(pos){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		int dataNum;
		int aNum = 0, bNum = 0;
		int aPoint = 0, bPoint = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str = br.readLine();

			dataNum = Integer.parseInt(str);
			if (dataNum == 0) {
				break;
			}

			aPoint = 0;
			bPoint = 0;
			aNum = 0;
			bNum = 0;
			for (int i = 0; i < dataNum; i++) {
				StringBuffer sb = new StringBuffer(new String(br.readLine()));
				aNum = Character.getNumericValue(sb.charAt(0));
				bNum = Character.getNumericValue(sb.charAt(2));

				if (aNum > bNum) {
					aPoint += aNum + bNum;
				} else if (bNum > aNum) {
					bPoint += aNum + bNum;
				} else {
					aPoint += aNum;
					bPoint += bNum;
				}
			}

			System.out.println(aPoint + " " + bPoint);
		}
	}
}


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

int main(){
  int N;cin>>N;
  int h[N+100];
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  int dp[N+100];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1];  
}

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

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

  k = a - b + 1;

  if (a * b <= 0)
    cout << "Zero" << endl;
  else if (a > 0)
    cout << "Positive" << endl;
  else {
    if (k % 2 == 0)
      cout << "Positive" << endl;
    else
      cout << "Negative" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }
const ll MOD = 1000 * 1000 *1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a - b + MOD) % MOD;}
inline ll sub(const ll a, const ll b){ return (a - b + MOD) % MOD; }
inline void chmul(ll &a, const ll b) { a = (a * b) %  MOD;}
inline ll mul(const ll a, const ll b){ return (a * b) %  MOD;}

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

const int SIZE = 100000 + 10;
ll dp[SIZE][13];

int main() {
  vector<int> nxt(13);
  REP(i,13) {
    nxt[i] = (i * 10) %	13;
  }
  string S; cin>>S;
  dp[0][0] = 1;
  REP(i,S.size()) {
    if(S[i] == '?') {
      REP(v,10) {
      REP(k,13) {
        const int kk = nxt[k];
        chadd(dp[i+1][(kk+v)%13], dp[i][k]);
      }}
    } else {
      int v = S[i] - '0';
      REP(k,13) {
        const int kk = nxt[k];
        chadd(dp[i+1][(kk+v)%13], dp[i][k]);
      }
    }
    //    REP(k,13) cout << dp[i+1][k] << " " ; cout << endl;                               
  }
  cout << dp[S.size()][5] << endl;

  return 0;
}




Measured memory_bytes: 10688
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())
BC = []
for i in range(Q):
    BC.append(list(map(int, input().split())))
dic = Counter(A)
ans = 0
for k, v in dic.items():
    ans += int(k)*v
for i in BC:
    B, C = i[0], i[1]
    ans += - B*dic[B] + C*dic[B]
    dic[C] += dic[B]
    del dic[B]
    print(ans)

Measured memory_bytes: 105032
#define ll long long
    #define pub push_back
    #define pob pop_back
    #define puf push_front
    #define pof pop_front
    #define mp make_pair
    #define fo(i , n) for(ll i = 0 ; i < n ; i++)
    //#include<bits/stdc++.h>
    #include<iomanip>
    #include<cmath>
    #include<cstdio>
    #include<utility>
    #include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    ll pi = acos(-1) ;
    ll z =  998244353 ;
    ll inf = 100000000000000000 ;
    ll p1 = 37 ;
    ll p2 = 53 ;
    ll mod1 =  202976689 ;
    ll mod2 =  203034253 ;
    ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
    ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
    ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
    ll max(ll a , ll b){if(a > b) return a ; return b ;}
    ll min(ll a , ll b){if(a < b) return a ; return b ;}
    ll left(ll i){return ((2*i)) ;}
    ll right(ll i){return ((2*i) + 1) ;}
    void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
    //ios_base::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    using namespace std ;
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    // ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
    // s.find_by_order(i)  itertor to ith element (0 indexed)

    void solve()
    {
        ll n ;
        cin >> n ;
        ll m = n-1 ;
        vector<ll> fact_1 , fact_2 ;
        for(ll i = 1 ; i*i <= n ; i++)
        {
            if(n % i == 0)
            {
                if(i != 1)
                    fact_1.pub(i) ;
                if(i*i != n)
                    fact_1.pub(n/i) ;
            }
        }
        for(ll i = 1 ; i*i <= m ; i++)
        {
            if(m % i == 0)
            {
                if(i != 1)
                    fact_2.pub(i) ;
                if(i*i != m && (m/i != 1))
                    fact_2.pub(m/i) ;
            }
        }
        ll ans = fact_2.size() ;
        fo(i , fact_1.size())
        {
            ll a = n ;
            ll f  = fact_1[i] ;
            while(a%f == 0)
                a /= f ;
            if((a-1)%f == 0)
                ans++ ;
        }
        cout << ans << endl ;
    }

    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
        /*#ifndef ONLINE_JUDGE
        freopen("inputf.txt" , "r" , stdin) ;
        freopen("outputf.txt" , "w" , stdout) ;
        freopen("error.txt" , "w" , stderr) ;
        #endif*/
        
        ll t ;
        //cin >> t ;
        t = 1 ;
        while(t--)
        {
            solve() ;
        }
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

        return 0;
    }

Measured memory_bytes: 384