akhauriyash/Code-Regression huggingface dataset:
N = int(input())
flg = 0
count = 0
for n in range(N):
    D = list(map(int,input().split()))
    if D[0]==D[1]:
        count+=1
        if count ==3:
            flg=1
    else:
        count=0
if flg==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62516
<?php
  $tmp = explode(" ", trim(fgets(STDIN)));

  if($tmp[0]>$tmp[1]){
    $a = $tmp[0];
    $b = $tmp[1];
  }else{
    $a = $tmp[1];
    $b = $tmp[0];
  }

  $x = $a * $b;
  
  $r = $a % $b;
  while($r!=0){
    $a = $b;
    $b = $r;
    $r = $a % $b;
  }

  echo ($x / $b)."\n";

Measured memory_bytes: 4728
#include<stdio.h>
int main()
{
    int n,b,s=0,c;
    scanf("%d",&n);
    b=n;
    while(n!=0)
    {
       c=n%10;
       n=n/10;
       s=s+c;
    }
    if(b%s==0)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int mx = *max_element(all(a));
    int mn = *min_element(all(a));
    cout << (mx - mn) << endl;
}

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

Measured memory_bytes: 3624
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = int(input())
    s = input().rstrip()
    if a>=3200:
        print(s)
    else:
        print('red')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
def solve(n, a):
    if a == ['.'*n]*n:
        return -1
    white_column = sum(any(a[j][i] == '.' for j in range(n)) for i in range(n))
    res = float('inf')
    for r in range(n):
        all_white = all(a[i][r] == '.' for i in range(n))
        res = min(res, white_column + all_white + sum(1 for i in range(n) if a[r][i] == '.'))
    return res


n = int(input())
a = [input() for _ in range(n)]
print(solve(n, a))


Measured memory_bytes: 43116
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    bool ok[100000];
    int N,A,B,acnt = 0,bcnt = 0;
    string S;
    cin >> N >> A >> B >> S;
    for(int i = 0;i < N;i++){
        if(S[i] == 'a'){
            if(A + B > acnt+bcnt){
                acnt++;
                ok[i] = 1;
            }else ok[i] = 0;
        }else if(S[i] == 'b'){
            if(A + B > acnt+bcnt && B > bcnt){
                bcnt++;
                ok[i] = 1;
            }else ok[i] = 0;
        }else if(S[i] == 'c')ok[i] = 0;

    }
    for(int i = 0;i < N;i++){
        cout << (ok[i]?"Yes":"No") << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll n,k,a[maxn],dif[maxn];
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++) dif[i]=a[i]-a[i-1];
    ll mo=1000,num=0;
    for(int i=i;i<n;i++){
        if(dif[i]>0){
            num=floor(mo/a[i-1]);
            mo-=floor(mo/a[i-1])*a[i-1];
            mo+=num*a[i];
        }
    }
    cout<<mo<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   pi   acos(-1.0);
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
    fio;
    int a,b,c=0;
    cin>>a>>b;
    for(int i=a; i<=b; i++)
    {
        string s=to_string(i);
        if(s[0]==s[4] && s[1]==s[3]) c++;
    }
    cout<<c;
}  

Measured memory_bytes: 3776
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;
    N = N % K;
    if (K < 2 * N) {
        N = K - N;
    }
    cout << N << endl;
}

Measured memory_bytes: 3644
import math

#x = int(input())
#a = int(input())
n,m,x = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
ls = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()
#ls = [int(input()) for i in range(n)]

left = [i for i in ls if i < x]
right = [i for i in ls if i > x]
print(min([len(left),len(right)]))

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n = int(input())
  A = list(map(int, input().split()))
  cnt = 0

  def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L=[10**9+1]*(n1+1) # 先に入れきった方の配列をヌルポにしないため
    R=[10**9+1]*(n2+1)
    for i in range(n1):
      L[i] = A[left + i]
    for i in range(n2):
      R[i] = A[mid + i]
    i = 0
    j = 0
    for k in range(left, right):
      cnt += 1
      if L[i] <= R[j]:
        A[k] = L[i]
        i += 1
      else:
        A[k] = R[j]
        j += 1

  def mergeSort(A, left, right):
    if left + 1 < right:
      mid = (left + right) // 2
      mergeSort(A, left, mid)
      mergeSort(A, mid, right)
      merge(A, left, mid, right)

  mergeSort(A, 0, n)
  print(*A)
  print(cnt)




Measured memory_bytes: 61652
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const int N=(int)(2*1e5+10);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
int inv(int x){return binpow(x, MOD - 2);}
int divide(int x, int y){return mul(x, inv(y));}
//int fact[N];
//void precalc(){fact[0] = 1;for(int i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
//int C(int n, int k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================

int main()
{ IOS;
int h,w,k;
cin>>h>>w>>k;
string s[h];
rep(i,0,h)
{
    cin>>s[i];
}
int ans=0;
rep(maskr,0,(1<<h))
{
    rep(maskc,0,(1<<w))
    {
        int black=0;
        rep(i,0,h)
        {
            rep(j,0,w)
            {
                if ((((maskr)>>i)&1)==0 && (((maskc)>>j)&1)==0 && s[i][j]=='#')
                {
                    black++;
                }
            }
        }
        if (black==k)
        {
            ans++;
        }
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 3604
n = int(input())
cnt = 0

for i in range(n//4+1):
    p = n - i*4
    for j in range(p//7+1):
        if p - 7*j ==0:
            cnt += 1
        else:
            pass
if cnt == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 2940
class Main{
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if( a < b && b < c ) System.out.println( "Yes" );
		else System.out.println( "No" );
	}
}

Measured memory_bytes: 26236
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};
int a[100001]={};
int main() {
	int a,b;
	cin>>a>>b;

	if(a==b){
		cout<<"Draw"<<endl;
	}else if((a==1)&&(b==13)){
		cout<<"Alice"<<endl;
	}else if((a==13)&&(b==1)){
		cout<<"Bob"<<endl;
	}else if(a>b){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Bob"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;


void _sol(){
    ll n; cin >> n;
    vector<ll> v(n);
    forr(i,n) cin >> v[i];
    ll ans = 0;
    for(int i=n-2;i>=0;i--){
        ans = (ans + v[i]*v[i+1])%mod;
        v[i] = ( v[i] + v[i+1] )%mod;
    }
    cout << ans;

}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 4724
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(k, n) printf("%lld%c", a[k], k + 1 == n ? '\n' : ' ')

const int N_MAX = 100;
const int W_MAX = 1000000000;
const int V_MAX = 1000;
const int DP_MAX = V_MAX * N_MAX;
const int INF = W_MAX + 10;

int N, W;
int w[N_MAX];
int v[N_MAX];

int dp[DP_MAX + 1];

void solve() {
  fill(dp, dp + DP_MAX + 1, INF);
  dp[0] = 0;
  REP(i, N) {
    for (int j = DP_MAX; j >= v[i]; j--) {
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
  }
  // DUMP(dp, 100);

  int ans = 0;
  REP(i, DP_MAX + 1) {
    if (dp[i] <= W) ans = i;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &W);
  REP(i, N) scanf("%d%d", w + i, v + i);
}

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


Measured memory_bytes: 512
#include<iostream>
#include<cstring> 
#include<cstdio>
using namespace std;
const int Maxn=100010;
int n,vis[Maxn][3],num[Maxn];
int g1,g2,g3,g4;
int maxn1=0,second1=0;
int maxn2=0,second2=0;
int main(){
	scanf("%d",&n);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;++i){
		scanf("%d",&num[i]);
		if(i%2==0) vis[num[i]][2]++;
		else vis[num[i]][1]++;
	}
	for(int i=1;i<=n;i+=2){
	    if(maxn1<vis[num[i]][1]){
			second1=maxn1;
			maxn1=vis[num[i]][1];
			g2=g1; g1=i;
		}
		else 
		  if(second1<vis[num[i]][1]&&num[i]!=num[g1]){
		  	second1=vis[num[i]][1];
		  	g2=i;
		  }
	}
    for(int i=2;i<=n;i+=2){
    	if(maxn2<vis[num[i]][2]){
			second2=maxn2;
			maxn2=vis[num[i]][2];
			g4=g3; g3=i;
		}
		else 
		  if(second2<vis[num[i]][2]&&num[i]!=num[g3]){
		  	 second2=vis[num[i]][2];
		  	 g4=i;
		  }
	}
	if(num[g1]!=num[g3]) printf("%d",n-vis[num[g1]][1]-vis[num[g3]][2]);
	else printf("%d",n-max(maxn1+second2,maxn2+second1));
	return 0;
}

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

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for ( int i = 0; flag; i++ ) {
        flag = 0;
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j] < A[j - 1] ) {
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for ( int i = 0; i < N; i++ ) cin >> A[i];

    sw = bubbleSort(A, N);

    for ( int i = 0; i < N; i++ ) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

const int maxn = 2e6 + 5;
vi primes;
bool composite[maxn];

void generatePrimes(){
	for(int i = 2; i < maxn; i++){
		if(!composite[i]){
			primes.push_back(i);
		}
		for(int j = 0; j < primes.size() && i * primes[j] < maxn; j++){
			composite[i * primes[j]] = true;
			if(i % primes[j] == 0){
				break;
			}
		}	
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int x;
	cin >> x;
	generatePrimes();
	cout << primes[lower_bound(all(primes), x) - primes.begin()] << endl;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    vector <bool> is_sosu(120000, true);
    for(int i=2; i<120000; i++){
        if (!is_sosu[i]){
            continue;
        }
        for (int j=i*2; j<120000; j+=i){
            is_sosu[j] = false;
        }
    }
    ll x; cin >> x;
    for (int i=x; x<120000-1; i++){
        if (is_sosu[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>

using namespace std;
int main(){
  int op;
  stack<int> intStack;
  while(cin>> op){
    if(op == 0){
      cout << intStack.top() << endl;
      intStack.pop();
    } else {
      intStack.push(op);
    }
  }
  return 0;
}
    
      

Measured memory_bytes: 1204
#include<cstdio>
#include<math.h>
#include<algorithm>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int N,K;
bool W=false;
int A[100002];
pair<int,int> R[100002];//????????¨??????


int main(){
	while(1){
	scanf("%d %d",&N,&K);
	if(N==0&&K==0)break;
	rep(i,K){
		int a;
		scanf("%d",&a);
		if(a==0){i--;K--;W=true;continue;}
		A[i]=a;
	}
	sort(A,A+K);
	int rn=0;//?????°???????????????
	R[rn].first=A[0];
	rep(i,K){
		if(A[i]+1==A[i+1]){
		}else{
			R[rn].second=A[i];
			rn++;
			R[rn].first=A[i+1];
		}
	}
	R[rn].second=A[K-1];
	int ans=0;
	rep(i,rn){
		if(W==false){
			ans=max(ans,R[i].second-R[i].first+1);
		}else{
			ans=max(ans,R[i].second-R[i].first+2);
			if(i==rn-1)continue;
			if(R[i].second==R[i+1].first-2){
				ans=max(R[i+1].second-R[i].first+1,ans);
			}
		}
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 2140
def main():
    from collections import deque
    n, k, *td = map(int, open(0).read().split())
    s = list(zip(*[iter(td)] * 2))
    t = sorted(s, key=lambda x: x[1], reverse=True)

    variety = set()
    base = 0
    duplicated = deque([])

    for x, y in t[:k]:
        base += y
        if x in variety:
            duplicated.append(y)
        else:
            variety.add(x)

    now = base + len(variety) ** 2

    nx = deque(t[k:])
    c = len(variety)
    tmp = now
    while c < k and nx:
        i, j = nx.popleft()
        if i in variety:
            continue

        d = duplicated.pop()
        dif = j - d + 2 * c + 1
        variety.add(i)
        tmp = max(tmp, now + dif)
        now += dif
        c += 1

    print(tmp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25484
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int64_t> a(n);
    map<int64_t, int> s;
    rep(i, n)
    {
        cin >> a[i];
        s[a[i]]++;
    }

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

    int result = 0;
    rrep(i, n)
    {
        if (s[a[i]] == 0) {
            continue;
        }
        int64_t b = a[i];
        b |= b >> 1;
        b |= b >> 2;
        b |= b >> 4;
        b |= b >> 8;
        b |= b >> 16;
        b |= b >> 32;
        b++;
        int64_t c = b - a[i];
        if ((c != a[i] && s[c] > 0) || (s[c] > 1)) {
            s[c]--;
            s[a[i]]--;
            result++;
            //cout << "a=" << a[i] << " c=" << c << endl;
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 26752
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        String line = sc.nextLine();
        check(num, line);
    }

    public static void check(String num, String line) {
        String[] strs = line.split(" ");
        int cnt=0;
        for (int i=1; i<strs.length-1; i++) {
            if(Integer.parseInt(strs[i-1]) < Integer.parseInt(strs[i]) &&
                    Integer.parseInt(strs[i]) < Integer.parseInt(strs[i+1]) ||
            Integer.parseInt(strs[i-1]) > Integer.parseInt(strs[i]) &&
                    Integer.parseInt(strs[i]) > Integer.parseInt(strs[i+1])) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>theval;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        theval.push_back(a);
    }
    vector<int>dp(n+1,1000000000);
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=min(dp[i-1]+abs(theval[i]-theval[i-1]),dp[i]);
        if(i-2>=0){  dp[i]=min(dp[i],dp[i-2]+abs(theval[i]-theval[i-2]));}
        
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1144
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222

vll edge[3 * MAX], node[MAX];
ll dist[3 * MAX];
map<pll, ll> idx;

void add_e(ll p,ll q,ll c) {
  if (!idx.count(pll(p, c))) {
	idx[pll(p, c)] = cnt++;
  }
  edge[idx[pll(p, c)]].pb(q);
}


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

  cin >> n >> m;
  FOR(i, 1, n + 1) idx[pll(i, 0)] = cnt++;
  rep(i, m) {
	ll a, b, c;
	cin >> a >> b >> c;
	add_e(a, b, c); node[a].pb(c);
	add_e(b, a, c); node[b].pb(c);
  }
  rep(i, cnt) dist[i] = inf;
  pll p = pll(1, 0);
  dist[idx[p]] = 0;
  deque<pll> dq;
  dq.push_front(p);
  while (!dq.empty()) {
	p = dq.front();
	dq.pop_front();
	ll d = dist[idx[p]];
	if (p.second) {
	  for (ll to : edge[idx[p]]) {
		if (d >= dist[idx[pll(to, p.second)]]) continue;
		dist[idx[pll(to, p.second)]] = d;
		dq.push_front(pll(to, p.second));
	  }

	  if (d < dist[idx[pll(p.first, 0)]]) {
		dist[idx[pll(p.first, 0)]] = d;
		dq.push_front(pll(p.first, 0));
	  }

	}
	else {
	  for (ll com : node[p.first]) {
		if (d + 1 >= dist[idx[pll(p.first, com)]]) continue;
		dist[idx[pll(p.first, com)]] = d + 1;
		dq.push_back(pll(p.first, com));
	  }
	}
  }



  if (dist[idx[pll(n, 0)]] == inf) cout << "-1" << endl;
  else cout << dist[idx[pll(n, 0)]] << endl;

  return 0;
}


Measured memory_bytes: 78196
#include <iostream>
#include <algorithm>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int t, n, k;
lint x[100010];
lint d[100010];

int main(){
    cin >> t;
    while(t){
    t--;
	cin >> n >> k;
	rep(i, n) cin >> x[i];
	if(k >= n){
	     cout << 0 << endl;
	     continue;
	}
	lint sum = 0;
	rep(i, n-1) d[i] = x[i+1] - x[i], sum += d[i];
	sort(d, d+n-1);
	rep(i, k-1) sum -= d[n-2-i];
	cout << sum << endl;
    }
}



Measured memory_bytes: 4716
#include <iostream>
#include <cstring>
#include <map>
#include <queue>
using namespace std;

const int N = 3;
const int N2 = 9;
int dx[5] = {0, 0, 1, -1};
int dy[5] = {1, -1, 0, 0};
//string dir[5] = {"r", "l", "d", "u"};//右、左、下、上
char dir[5] = {'r', 'l', 'd', 'u'};//右、左、下、上
struct Puzzle
{
    int f[N2];
    int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for(int i=0; i<N2; i++)
        {
            if(f[i]==p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};
Puzzle P;
bool isTarget(Puzzle s)
{
    for(int i=0; i<N2-1; i++)
    {
        if(s.f[i]!=i+1) return 0;
    }
    return 1;
}
int bfs(Puzzle P)
{
    map<Puzzle, bool> V;
    queue<Puzzle> Q;
    Q.push(P);
    V[P] = true;
    Puzzle u, v;
    while(!Q.empty())
    {
        u = Q.front();
        Q.pop();
        if(isTarget(u)) return u.path.size();
        int sx = u.space/N, sy = u.space%N;
        //cout << 1 << endl;
        for(int i=0; i<4; i++)
        {
            int tx = sx + dx[i], ty = sy + dy[i];
            if(tx>=N || tx<0 || ty>=N || ty<0) continue;
            v = u;
            swap(v.f[u.space], v.f[tx*N+ty]);
            v.space = tx*N+ty;
            if(!V[v])
            {
                V[v] = true;
                v.path += dir[i];
                Q.push(v);
            }
        }
    }
    return -1;
}
int main()
{
    for(int i=0; i<N2; i++)
    {
        cin >> P.f[i];
        if(P.f[i]==0)
        {
            P.space = i;
        }
    }
    P.path = "";
    cout << bfs(P) << endl;
    return 0;
}



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

int main(){
  int N,a;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  a = v.at(N/2)-v.at(N/2-1);
  cout << a << endl;
}  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long a,b,c,d,e,f,g,h,i,j,k,l;
    string sr;
    cin>>sr;
    if(sr=="ABC")
        cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;




}


Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

typedef long long i64;

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

    i64 len=S.length();
    i64 ub=1<<(len-1);
    i64 res=0;

    int i, j;
    for (i=0; i<ub; i++) {
        i64 tmp=0;
        for (j=0; j<len; j++) {
            tmp *= 10;
            tmp += S[j]-'0';

            if (i&(1<<j)) {
                res += tmp;
                tmp = 0;
            }
        }
        res += tmp;
    }

    cout << res << endl;

    return 0;
}


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

vector<int> p;

void QS(int a,int b){
  if(b-a<=1){
    if(p.at(b)<p.at(a)){
      swap(p.at(b),p.at(a));
    }
    return;
  }
  int P=(p.at(a)+p.at(b))/2;
  int i=a,j=b;
  int X,Y;
  while(true){
    while(i<j){
      if(p.at(i)>P){
        break;
      }
      i++;
    }
    while(i<j){
      if(p.at(j)<=P){
        break;
      }
      j--;
    }
    if(i==j){
      X=j-1,Y=j;
    }
    else if(j-i==1){
      swap(p.at(i),p.at(j));
      X=i,Y=j;
    }
    else{
      swap(p.at(i),p.at(j));
      continue;
    }
    break;
  }
  if(X-a<=1){
    if(p.at(X)<p.at(a)){
      swap(p.at(X),p.at(a));
    }
  }
  else{
    QS(a,X);
  }
  if(b-Y<=1){
    if(p.at(b)<p.at(Y)){
      swap(p.at(b),p.at(Y));
    }
  }
  else{
    QS(Y,b);
  }
  return;
}

int main() {
  int N,K,Z=0;
  cin>>N>>K;
  p.resize(N);
  for (int i=0;i<N;i++){
    cin>>p.at(i);
  }
  QS(0,N-1);
  for(int i=0;i<K;i++){
    Z+=p.at(i);
  }
  cout<<Z<<endl;
}



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

int main(void) {
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	rep (i, n) cin >> l[i];
	int ans = 1;
	int p = 0;
	rep(i, n) {
		p += l[i];
	    if (p <= x) ans++;
	}
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func sumSlice(nums []int) int {
	sum := 0
	for _, n := range nums {
		sum += n
	}
	return sum
}

func binarySearch(target int, list []int) int {
	left := 0
	right := len(list) - 1
	mid := (left + right) / 2

	for {
		if list[mid] < target {
			left = mid + 1
		} else {
			right = mid
		}
		mid = (left + right) / 2
		if left >= right {
			break
		}
	}
	return mid
}

func main() {
	scanner.Split(bufio.ScanWords) // switch to separating by space
	// scanner.Buffer([]byte{}, 1000000009) // switch to read large size input
	N := nextInt()
	coordinates := scanNums(N)
	coordinates = append(coordinates, 0)
	costs := make([]int, N+1)

	prev := 0
	cost := 0
	for i, c := range coordinates {
		cost = abs(c - prev)
		costs[i] = cost
		prev = c
	}

	totalCost := sumSlice(costs)

	difference := 0
	reference := 0

	for i := 0; i < N; i++ {
		if i == 0 {
			reference = 0
		} else {
			reference = coordinates[i-1]
		}

		difference -= costs[i]
		difference -= costs[i+1]
		difference += abs(coordinates[i+1] - reference)

		fmt.Println(totalCost + difference)
		difference = 0
	}
}


Measured memory_bytes: 8448
N = int(input())
S = input()
#%%
cum = [[0]*(N+1) for _ in range(3)]
for i in range(N):
    cum[0][i+1] = cum[0][i] + (S[i]=='R')
    cum[1][i+1] = cum[1][i] + (S[i]=='G')
    cum[2][i+1] = cum[2][i] + (S[i]=='B')
    
def color(i,j):
    RGB = [0]*3
    if S[i]=='R' or S[j]=='R':
        RGB[0] = 1
    if S[i]=='G' or S[j]=='G':
        RGB[1] = 1
    if S[i]=='B' or S[j]=='B':
        RGB[2] = 1
    
    if RGB[0]==0:
        return 0
    elif RGB[1]==0:
        return 1
    else:
        return 2
def col(s):
    if s=='R':
        return 0
    elif s=='G':
        return 1
    else:
        return 2

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


Measured memory_bytes: 75592
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	ans += n / (a + b) * a;
	ans += min(n % (a + b), a);
	cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
         mut a:[usize;n],
    }
    let mut allgcd = gcd_list(&a);
    let mut st = BTreeSet::new();
    let mut all = true;
    for &x in a.iter() {
        if x != 1 {
            let mut pf = prime_factor(x as i64);
            for (k, _) in pf {
                let kk = k;
                if st.contains(&k) {
                    all = false;
                    break;
                } else {
                    st.insert(kk);
                }
            }
            if !all {
                break;
            }
        }
    }
    if all {
        println!("{}", "pairwise coprime");
    } else {
        if allgcd == 1 {
            println!("{}", "setwise coprime");
        } else {
            println!("{}", "not coprime");
        }
    }
}
fn prime_factor(mut n: i64) -> std::collections::HashMap<i64, i64> {
    let mut res: std::collections::HashMap<i64, i64> = std::collections::HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let v = match res.get(&i) {
                Some(v) => *v + 1,
                None => 1,
            };
            res.insert(i, v);
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}
pub fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn gcd_list(list: &[usize]) -> usize {
    list.iter().fold(list[0], |a, &b| gcd(a, b))
}


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

using namespace std;

int main(){
    int N, K, Q;
    cin>>N>>K>>Q;
    int a[Q+1], m[N+1];

    for(int i = 0; i<= N; i++){
        m[i] = 0;
    }
    for(int i = 0; i<Q; i++){
        cin>>a[i];
        m[a[i]-1]+=1;
    }
    for(int i = 0; i<N; i++){
        if(K-Q+m[i]>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
N=int(input())
A=input()
B=input()
C=input()

score=0
for i in range(N):
    chas=[]
    chas.append(A[i])
    chas.append(B[i])
    chas.append(C[i])
    lens=len(list(set(chas)))
    score+=(lens-1)

print(score)


Measured memory_bytes: 3060
import java.util.*;
//import java.io.*;
//import static java.util.Arrays.*;
//import static java.util.Collections.*;
//import static java.lang.Math.*;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
        int a,b,c,n,i,q,j,k;
        k=0;
        Scanner scan=new Scanner(System.in);
        n=scan.nextInt();
        int s[]=new int [n];
        for(i=0;i<n;i++)
        {
        	s[i]=scan.nextInt();
        }
        q=scan.nextInt();
        int t[]=new int [q];
        for(j=0;j<q;j++)
        {
        	t[j]=scan.nextInt();
        }
        for(j=0;j<q;j++)
        {
        a=0;
        b=n;
        while(a<b)
        {
        	c=(a+b)/2;
        	if(s[c]==t[j])
        	{
        		k++;
        		a=b+1;
        	}
        	else if(s[c]>t[j])
        	{
        		b=c;
        	}
        	else
        	{
        		a=c+1;
        	}
        }
        }
        System.out.println(k);
	}

}

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

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

int n , k , fac[N] , inv[N] , ans;

int Pow(int a , int k){
	if(k == 1) return a;
	int S = Pow(a , k >> 1);
	if(k & 1) return 1ll * S * S % mod * a % mod;
	else return 1ll * S * S % mod;
}

int C(int n , int m){
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main(){
	fac[0] = 1; for(int i = 1; i < N; i++)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[N - 1] = Pow(fac[N - 1] , mod - 2);
	for(int i = N - 2; i >= 0; i--)
		inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	scanf("%d %d" , &n , &k);
	for(int i = 0; i <= min(n - 1 , k); i++)
		ans = (1ll * ans + 1ll * C(n - 1 , n - i - 1) * C(n , i)) % mod;
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

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

    if (s[0] == s[1] && s[1] == s[2])
    {
        cout << "Yes" << endl;
    }
    else if (s[1] == s[2] && s[2] == s[3])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, q;
	cin >> n >> q;
	int arr[n + 1] = {0};
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	int h = sqrt(n);
	vector<pair<int, int>> v;
	vector<vector<pair<int, int>>> v1;
	v1.resize(h + 1);

	while (q--)
	{
		int l, r;
		cin >> l >> r;
		v.pb(mk(l, r));
		int u = l / h;
		v1[u].pb(mk(r, l));
		// cout << u << endl;
	}
	for (int i = 0; i <= h; i++)
		sort(v1[i].begin(), v1[i].end());
	/*for (int i = 0; i <= h; i++)
	{
		cout << i << endl;
		for (int j = 0; j < v1[i].size(); j++)
		{
			cout << v1[i][j].ff << " " << v1[i][j].ss << endl;
		}
	}*/
	map<pair<int, int>, int> ans;

	for (int i = 0; i <= h; i++)
	{
		//cout << i << endl;
		int count[n + 1] = {0};
		int cnt = 0;
		if (v1[i].size() == 0)
			continue;
		int l = v1[i][0].ss; int r = v1[i][0].ff;
		int l1 = v1[i][0].ss; int r1 = v1[i][0].ff;
		for (int j = l; j <= r; j++)
		{
			if (count[arr[j]] == 0)
				cnt++;
			count[arr[j]]++;
		}
		ans[mk(l, r)] = cnt;
		//cout << l << " " << r << " " << mp.size() << endl;
		for (int j = 1; j < v1[i].size(); j++)
		{
			l1 = v1[i][j].ss; r1 = v1[i][j].ff;
			if (l1 < l)
			{
				for (int w = l - 1; w >= l1; w--)
				{
					if (count[arr[w]] == 0)
						cnt++;
					count[arr[w]]++;
				}
				//cout<<"as";
			}
			else if (l1 == l)
			{

			}
			else
			{
				for (int w = l; w < l1; w++)
				{
					count[arr[w]]--;
					if (count[arr[w]] == 0)
						cnt--;
				}

			}
			if (r1 < r)
			{
				for (int w = r; w < r1; w--)
				{
					count[arr[w]]--;
					if (count[arr[w]] == 0)
						cnt--;
				}
			}
			else if (r1 == r)
			{

			}
			else
			{
				for (int w = r + 1; w <= r1; w++)
				{
					if (count[arr[w]] == 0)
						cnt++;
					count[arr[w]]++;
				}
			}
			//cout << l1 << " " << r1 << " " << mp.size() << endl;
			ans[mk(l1, r1)] = cnt;
			l = l1; r = r1;
		}

	}
	for (int i = 0; i < v.size(); i++)
	{
		int l = v[i].ff; int r = v[i].ss;
		cout << ans[mk(l, r)] << endl;
	}


	return 0;
}



Measured memory_bytes: 48732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
int a[N];
bool used[N];
vector<int> path;

int solve(int n, ll k) {
    for (int i = 1; i <= n; i++) {
        used[i] = 0;
    }
    path.clear();
    int ptr = 1;
    while (!used[ptr]) {
        used[ptr] = 1;
        path.pb(ptr);
        ptr = a[ptr];
    }
    int pos = -1;
    for (int i = 0; i < path.size(); i++) {
        if (path[i] == ptr) {
            pos = i;
            break;
        }
    }
    if (k <= path.size() - 1) {
        return path[k];
    }
    else {
        return path[pos + (k - pos) % (path.size() - pos)];
    }
}

int slow(int n, ll k) {
    int ptr = 1;
    for (int i = 1; i <= k; i++) {
        ptr = a[ptr];
    }
    return ptr;
}

void stress() {
    while (1) {
        int n = rnd() % 10 + 2;
        int k = rnd() % 100 + 1;
        for (int i = 1; i <= n; i++) {
            a[i] = rnd() % n + 1;
        }
        int ans = solve(n, k), res = slow(n, k);
        if (ans != res) {
            cout << "Wa" << endl;
            cout << n << " " << k << endl;
            for (int i = 1; i <= n; i++) {
                cout << a[i] << " ";
            }
            cout << endl << endl;
            cout << ans << " " << res << endl;
            break;
        }
        else {
            cout << "ok" << endl;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    ll k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    cout << solve(n, k) << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> a(1+N);
	int cur=0;
	for (int i=1; i<=N; i++)
		cin>>a[i], cur^=a[i];
	for (int i=1; i<=N; i++)
		cur^=a[i]^a[i-1], cout<<cur<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3896
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

bool sosuhantei(ll x){
  if(x==1)return false;
  if(x==2)return true;
  if(x==3)return true;
  int  i = 2;
  bool res = true;
  for(int i = 2;i*i<=x;i++){
    if(x%i==0){
      res = false;
      break;
    }
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  if(N==1){
    cout << 0 << endl;
    return 0;
  }
  ll M = N;
  ll max = 1;
  for(ll i = 1;i*i <= N;i++)max = i;
  vector<ll> num;
  map<ll,ll> cnt;
  for(int i = 2;i <= max;i++){
    if(M%i==0)num.push_back(i);
    while(M%i==0){
      cnt[i]++;
      M /= i;
    }
  }
  if(M!=1){
    num.push_back(M);
    cnt[M]++;
  }
  /*
  rep(i,num.size()){
    cout << num[i] << " ";
  }
  cout << endl;
  */
  ll ans = 0;
  for(int i = 0;i < num.size();i++){
    int j = 1;
    while(cnt[num[i]]-j>=0){
      cnt[num[i]] -= j;
      j++;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std ;
int main ()
{
 int n  ;
 double a ;
 cin>> n;
 double ans=0 ;
 for(int i=0;i<n ; i++)
 {
     cin>> a ;
     ans+= 1/a ;
 }
 cout<< 1/ans ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int n, cnt = 0;
int a[500500];
int b[500500];

void merge_sort(int l, int r) {
    if(r - l == 1) return ;

    int mid = (l + r) / 2;
    merge_sort(l, mid);
    merge_sort(mid, r);

    // merge
    int lp = l, rp = mid;
    for(int i = l; i < r; i++) {
        if(rp == r) {
            b[i] = a[lp];
            lp++;
        } else if(lp == mid) {
            b[i] = a[rp];
            rp++;
        }

        else if(a[lp] < a[rp]) {
            b[i] = a[lp];
            lp++;
        } else {
            b[i] = a[rp];
            rp++;
        }

        cnt++;
    }

    for(int i = l; i < r; i++) {
        a[i] = b[i];
    }
}

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

    cin >> n;
    rep(i, n) cin >> a[i];

    merge_sort(0, n);

    rep(i, n) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 10992
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int p,q,r;
  cin >> p >> q >> r;

  vec a = {p,q,r};
  int m = *max_element(a.begin(),a.end());
  int sum = 0;
  REP(i, 3) sum += a[i];
  cout << sum - m << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    string str;
    cin>>str;
    int sum=0;
    for(int i = 0; i < str.size(); i++)
      sum+=(str[i]-'0');
    // Jèãªéñ
    int ct=0;
    int s=sum;
    while(s>=10){
      ct+=s/10;
      int left=s%10+s/10;
      s=left;
    }
    int cnt=ct+str.size()-1;
    if(cnt%2==0)
      cout<<"Audrey ";
    else
      cout<<"Fabre ";
    cout<<"wins."<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
long long gekoa[200000] = {};
long long gyaku(long long n) {
	if (gekoa[n]) return gekoa[n];
	long long ans = 1;
	long long now = n;
	long long hoge = n;
	long long geko = MAX_MOD - 2;
	while (geko != 0) {
		if (geko % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		geko /= 2;
	}
	return gekoa[hoge] = ans;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		long long a;
		cin >> a;
		if (a % 2 == 1) {
			cout << "first" << endl;

			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n, m = map(int, input().split())
 
N = math.factorial(n)
M = math.factorial(m)
INF = 10**9 + 7
 
if abs(n-m) > 1:
    print(0)
elif abs(n-m) == 1:
    print(N*M%INF)
else:
    print(2*N*M%INF)

Measured memory_bytes: 5324
ans = 'keyence'
S = input()

N = len(ans)
k = 0

flag = False

if S[:N] == ans:
    flag = True
elif S[-N:] == ans:
    flag = True
else:
    for i,s in enumerate(S):
        if s == ans[k]:
            k += 1
        else:
            # print("remain:",ans[k:])
            # print("to search in:",S[i:])
            break
    # print(ans[k:],S[-(N-k):])
    if ans[k:] == S[-(N-k):]:
        flag = True

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064