akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

vll a(19, vl());
vl keta;

bool dfs(int i, ll d, int now) {
	if (d == 0) {
		fill(a[i].begin() + now, a[i].end(), 0);
		return true;
	}
	if (now >= keta.size()) {
		return false;
	}
	for (ll j = max(-9LL, d / keta[now] - 5); j <= min(9LL, d / keta[now] + 5); j++) {
		a[i][now] = j;
		if (dfs(i, d - keta[now] * j, now + 1)) {
			return true;
		}
	}
	return false;
}




int main() {
	ll d, i, j;
	cin >> d;

	vl table(19, 0);
	for (int a = 0; a <= 9; a++) {
		for (int b = 0; b <= 9; b++) {
			table[b - a + 9]++;
		}
	}

	vl head(19, 0);
	for (int a = 1; a <= 9; a++) {
		for (int b = 0; b <= 9; b++) {
			head[b - a + 9]++;
		}
	}

	for (i = 2; i <= 18; i++) {
		keta.clear();
		ll left = pow(10LL, i - 1);
		ll right = 1;
		while (left > right) {
			keta.push_back(left - right);
			left /= 10LL;
			right *= 10LL;
		}
		a[i].resize(keta.size());
		if (!dfs(i, d, 0)) {
			//cout << i << endl;
			a[i].clear();
		}
	}

	ll ans = 0;
	for (i = 2; i < 19; i++) {
		if (a[i].size() == 0) {
			continue;
		}
		//DEBUG(i);
		ll temp = 1LL;
		/*
		for (j = 0; j < a[i].size(); j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
		//*/
		temp *= head[a[i][0] + 9];
		for (j = 1; j < a[i].size(); j++) {
			temp *= table[a[i][j] + 9];
		}
		if (i % 2 == 1) {
			temp *= 10LL;
		}
		ans += temp;
	}
	cout << ans << endl;


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll M=max_element(all(a))-a.begin();
    ll m=min_element(all(a))-a.begin();
    ll count=0;
    if((a[m]<=0&&abs(a[M])>=abs(a[m]))||a[m]>=0){
        cout<<n*2<<endl;
        cout<<M+1<<" "<<n<<endl;
        cout<<M+1<<" "<<n<<endl;
        rep(i,n){
            if(i==0) cout<<M+1<<" "<<i+1<<endl;
            else if(i==n-1){
                cout<<i<<" "<<i+1<<endl;
            }else{
                cout<<M+1<<" "<<i+1<<endl;
                cout<<i<<" "<<i+1<<endl;
            }
        }
    }else{
        cout<<n*2<<endl;
        cout<<m+1<<" "<<1<<endl;
        cout<<m+1<<" "<<1<<endl;
        repm(i,n-1,-1){
            if(i==n-1) cout<<m+1<<" "<<i+1<<endl;
            else if(i==0){
                cout<<i+2<<" "<<i+1<<endl;
            }else{
                cout<<m+1<<" "<<i+1<<endl;
                cout<<i+2<<" "<<i+1<<endl;
            }
        }
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, inf = 1e9;
int dp[nax], dp2[nax], h, n;
int a[nax], b[nax];
int rec(int cur){
    if(cur <= 0) return 0;
    if(dp[cur] != inf) return dp[cur];
    int &res = dp[cur];
    for(int i = 1 ;i <= n ;i ++){
        res = min(res, b[i] + rec(cur - a[i]));
    }
    return res;
}

int main(){
    scanf("%d %d", &h, &n);
    for(int i = 1 ;i <= n ;i ++){
        scanf("%d %d", a + i, b + i);
    }
    fill(dp, dp + 1 + h, inf);
    printf("%d\n", rec(h));
}
/*
    Good Luck
        -Lucina
*/


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

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n;
	cin >> n;
	int a;
	bool f = true;
	for( int i=0; i<n; i++ ) {
		cin >> a;
		if( a%2==0 ) {
			if( !(a%3==0||a%5==0) ) {
				f = false;
			}
		}
	}
	if( f ) {
		cout << "APPROVED";
	}else {
		cout << "DENIED";
	}
	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;

fn solve() -> i64 {
    input! {
        N: usize,
        A: [i64; N],
    }
    if A.iter().any(|&x| x == 0) {
        return 0;
    }
    let M: i64 = i64::pow(10, 18);
    let mut result = 1i64;
    for x in A {
        // result * x > M
        // result > M / x
        // result > ceil(M / x)
        if result > M / x {
            return -1;
        }
        result *= x
    }
    result
}

#[fastout]
fn main() {
    println!("{}", solve());
}


Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
char s[4];
int a[4];
bool flag[4];
main()
{
    scanf("%s",s);
    for(int i=0;i<4;i++)a[i]=s[i]-'0';
    for(int i=0;i<=2;i+=2)for(int j=0;j<=2;j+=2)for(int k=0;k<=2;k+=2)
        if(a[0]+(i-1)*a[1]+(j-1)*a[2]+(k-1)*a[3]==7)
        {
            printf("%d%c%d%c%d%c%d=7\n",a[0],i?'+':'-',a[1],j?'+':'-',a[2],k?'+':'-',a[3]);
            return 0;
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, a, b, z;
int g(int p) {return p > 0 ? p : -p;}
int main()
{
	cin >> n >> a >> b;
	z = g(a - b);
	if (z % 2 == 0) cout << "Alice";
	else cout << "Borys";
    return 0;
}


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

struct Box{
    int cap, amt;
    Box(): amt(0) {}
};

struct Query{
    int t, x, d;
};

int main(){
    int N, Q;
    cin >> N;
    vector<Box> boxes(N);
    int in;
    for(int i=0; i<N; i++){
        cin >> in;
        boxes[i].cap = in;
    }
    cin >> Q;
    int t, x, d;
    vector<Query> queries(Q);
    for(int i=0; i<Q; i++){
        cin >> t >> x >> d;
        queries[i].t = t;
        queries[i].x = x;
        queries[i].d = d;
    }
    for(int i=0; i<Q; i++){
        int t = queries[i].t, x = queries[i].x, d = queries[i].d;
         if(t == 1){
            boxes[x-1].amt += d;
            if(boxes[x-1].amt > boxes[x-1].cap){
                cout << x << endl;
                return 0;
            }
        }
        else{
            boxes[x-1].amt -= d;
            if(boxes[x-1].amt < 0){
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3888
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).Skip(nk[1]).Sum());

    }
}



Measured memory_bytes: 40704
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
double ans=0.0;
int main(int argc,char const* argv[])
{
  int red=0,blue=0;
  int n;
  string s;
  cin >> n;
  cin >> s;
  for(int i=0;i<n;i++)
    {
      if(s[i]=='R') red++;
      else blue++;
    }
  if(red>blue)
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = int.Parse(ReadLine());
            string[] st = cin.ReadStrArray(2);
            string s = st[0];
            string t = st[1];

            
            for (var i= 0;i< N; i++){
                Write(s[i]);
                Write(t[i]);
            }
           
            
            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            a[i] = scanner.nextInt();
        }
        int[] box = new int[n + 1];
        Map<Integer, List<Integer>> number = new HashMap<>();
        for (int i = 1; i <= n; ++i) {
            number.put(i, new ArrayList<>());
        }
        for (int i = 1; i <= n; ++i) {
            for (int k = 1; k * i <= n; ++k) {
                number.get(k * i).add(i);
            }
        }
        for (int i = n; i >= 1; --i) {
            box[i] = a[i] % 2;
            for (int k : number.get(i)) {
                a[k] = Math.abs(a[k] % 2 - box[i] % 2);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                ++count;
            }
        }
        System.out.println(count);
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                System.out.print(i + " ");
            }
        }
        System.out.println();

    }
}

Measured memory_bytes: 160796
n= int(input())
s = {}

for _ in range(n):
    t = input()
    s.setdefault(t, 1)
    s[t] += 1

ans = []
m = max(s.values())
for k, v in s.items():
    if v == m:
        ans.append(k)

for m in sorted(ans):
    print(m)

Measured memory_bytes: 32988
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> ans;

int main(void){
	int k,x,p,i;
	cin >> k >> x;
	for(p=-1000000; p<=1000000; ++p){
		if(abs(p-x)<k){
			ans.push_back(p);
		}
	}
	for(i=0; i<ans.l_ength(); ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int p[202020];
int c[202020][2];
bool vis[202020];
int rt[202020];
int getr(int x)
{
	if(x==rt[x])
		return x;
	rt[x]=getr(rt[x]);
	return rt[x];
}
double calc(int a,int b)
{
	if(b==0)
		return 1e100;
	else
		return (double)a/b;
}
priority_queue<pair<double,int> > q;
int main()
{
	int n,x,now,pp;
	long long ans=0;
	scanf("%d",&n);
	memset(c,0,sizeof(c));
	for(int i=2;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		c[i][x]++;
		if(i!=1)
			q.push(make_pair(calc(c[i][0],c[i][1]),i));
		rt[i]=i;
	}
	memset(vis,0,sizeof(vis));
	while(!q.empty())
	{
		now=q.top().second;
		q.pop();
		if(vis[now])
			continue;
		vis[now]=true;
		pp=getr(p[now]);
		rt[now]=pp;
		ans+=(long long)c[pp][1]*c[now][0];
		c[pp][0]+=c[now][0];
		c[pp][1]+=c[now][1];
		if(pp!=1)
			q.push(make_pair(calc(c[pp][0],c[pp][1]),pp));
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9456
import java.util.Scanner;

public class Main {

	private static Scanner in;

	public static void main(String[] args) {
		in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		
		for(int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}
		
		long[] pre = new long[n];
		
		int MOD = (int)1e9+7;
		
		for(int i=0; i<n; i++) {
			pre[i] = ((i-1>=0?pre[i-1]:0)+a[i])%MOD;
		}
		
		long ans = 0;
		
		for(int i=0; i<n; i++) {
			long val = (pre[n-1]-pre[i]+MOD)%MOD;
			ans = (ans+(a[i]*val)%MOD)%MOD;
			ans %= MOD;
		}
		
		System.out.println(ans);
		
	}

}


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

int main(){
  int p, q, r;
  cin >> p >> q >>r;
  
  int tibi = 0;
  
  tibi = min(p+q, q+r);
  tibi = min(tibi , p+r);
  
  cout << tibi << endl;
  
}


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

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

#define ll long long
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

const int MOD=1e9+7;

void solve(){
  int s;cin>>s;
  vt<int> dp(s+1);
  dp[0]=1;
  FOR(i,1,s+1) FOR(j,3,i+1){
    if(i-j<0) continue;
    dp[i]+=dp[i-j];
    dp[i]%=MOD;
  }
  cout<<dp[s]<<endl;
}

int main(){solve();}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	string in;
	cin>>in;
	string ans=in;
	int j=0;
	lp2(i,in.size()){
		if(in[i]=='B'){
			if(j!=0){
				j--;
				//cout<<1;
			}
		}
		else {
			ans[j]=in[i];
			j++;
			//cout<<2;
		}
		//cout<<in[i]<<endl;
	}
	lp2(i,j)cout<<ans[i];
	cout<<endl;
	return 0;
}


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

int main() {
	while (1) {
		string str, left;
		int m, h;
		cin >> str;
		if (str == "-")
			break;
		cin >> m;
		for (int i = 0;i < m;i++) {
			cin >> h;
			left = str.substr(0, h);
			str.erase(0, h);
			str += left;
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 3200
n, m = map(int, input().split())
like = [0] * m
for _ in range(n):
    ka = list(map(int , input().split()))
    for i in range(1, ka[0]+1):
        like[ka[i]-1] += 1

ans = 0
for li in like:
    if li == n:
        ans += 1
print(ans)

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

int main(){

    ll h,w;
    cin >> h >> w;

    if(h%3==0||w%3==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=min(h,w);

    for(ll i=0;i<h;i++){
        ll a=w*i;
        ll t=h-i;
        ll b=t*(w/2);
        ll c;
        if(w%2==0){
            c=b;
        }else{
            c=b+t;
        }
        ans=min(ans,max(abs(a-b),max(abs(a-c),abs(b-c))));
    }

    for(ll i=0;i<w;i++){
        ll a=h*i;
        ll t=w-i;
        ll b=t*(h/2);
        ll c;
        if(h%2==0){
            c=b;
        }else{
            c=b+t;
        }
        ans=min(ans,max(abs(a-b),max(abs(a-c),abs(b-c))));
        //cout << a << " " <<b << " " << c << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
const int sz = 1 << 20;

ll modpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	a %= m;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

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

	int n;
	cin >> n;
	int now = 0;
	vector<int> a(n), x(n), zero(n);
	vector<vector<int>> pl(sz, vector<int>());
	rep(i, n) {
		cin >> a[i];
		now ^= a[i];
		x[i] = now;
		int pre = 0;
		if (i) pre = zero[i - 1];
		if (now == 0) pre++;
		zero[i] = pre;
		pl[now].pb(i);
	}
	if (now == 0) {
		ll ans = modpow(2, pl[0].size() - 1);
		for (int num = 1; num < sz; num++) {
			vector<int> vec;
			int s = pl[num].size();
			if (s == 0) continue;
			rep(i, s - 1) {
				vec.pb(1);
				vec.pb(zero[pl[num][i + 1]] - zero[pl[num][i]]);
			}
			vec.pb(1);
			vector<vector<ll>> dp(2 * s, vector<ll>(2));
			dp[0][0] = 1;
			rep(i, 2 * s - 1) {
				dp[i + 1][0] += dp[i][0];
				if (i % 2 == 1) {
					dp[i + 1][0] += dp[i][1] * vec[i];
				}
				dp[i + 1][1] += dp[i][1];
				if (i % 2 == 0) {
					dp[i + 1][1] += dp[i][0] * vec[i];
				}
				dp[i + 1][0] %= mod;
				dp[i + 1][1] %= mod;
			}
			ans += dp[2 * s - 1][1];
		}
		ans %= mod;
		cout << ans << '\n';
	}
	else {
		int num = now;
		vector<int> vec;
		int s = pl[num].size();
		rep(i, s - 1) {
			vec.pb(1);
			vec.pb(zero[pl[num][i + 1]] - zero[pl[num][i]]);
		}
		vector<vector<ll>> dp(2 * s - 1, vector<ll>(2));
		dp[0][0] = 1;
		rep(i, 2 * s - 2) {
			dp[i + 1][0] += dp[i][0];
			if (i % 2 == 1) {
				dp[i + 1][0] += dp[i][1] * vec[i];
			}
			dp[i + 1][1] += dp[i][1];
			if (i % 2 == 0) {
				dp[i + 1][1] += dp[i][0] * vec[i];
			}
			dp[i + 1][0] %= mod;
			dp[i + 1][1] %= mod;
		}
		cout << dp[2 * s - 2][0] << '\n';
	}
}

Measured memory_bytes: 68460
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())

        for i in range(1, 10):
            for j in range(1, 10):
                if i * j == N:
                    print('Yes')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <queue>

int h, w;

bool S[20][20];


int enc(int a, int b){
  return (b << 16) | a;
}

int bfs(int a, int b){
  int v[20][20];
  std::queue<int> q;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      v[i][j] = -1;
    }
  }
  q.push(enc(a,b));
  v[a][b]=0;
  
  while(!q.empty()){
    int z = q.front();
    q.pop();
    int a = z % (1<<16);
    int b = z >> 16;
    if(a && S[a-1][b] && v[a-1][b] == -1) q.push(enc(a-1, b)), v[a-1][b] = v[a][b]+1;
    if(a<h-1 && S[a+1][b] && v[a+1][b] == -1) q.push(enc(a+1, b)), v[a+1][b] = v[a][b]+1;
    if(b && S[a][b-1] && v[a][b-1] == -1) q.push(enc(a, b-1)), v[a][b-1] = v[a][b]+1;
    if(b<w-1 && S[a][b+1] && v[a][b+1] == -1) q.push(enc(a, b+1)), v[a][b+1] = v[a][b]+1;
  }

  int ml = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(v[i][j] > ml){
        ml = v[i][j];
      }   
    }
  }
  return ml;
}

int main(){
  scanf("%d%d", &h, &w);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char c;
      do { scanf("%c", &c); } while(c != '#' && c != '.');
      S[i][j] = c == '.';
    }
  }

  int ml = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(!S[i][j]) continue;
      int x = bfs(i, j);
      if(x > ml) ml = x;
    }
  }

  printf("%d\n", ml);

  return 0;
}


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

int main() {
	
	string s;
	cin >> s;
	int n = s.size();
	int ans = 1000;
	rep(i, n-2){
		int tmp = abs(753 - ((s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0')));
		if(ans > tmp) ans = tmp;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
const LL inf=16777216;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int gcd (int a,int b){return b==0?a:gcd(b,a%b);}
int main()
{
    int n,a[200005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int i=1,num=0;
    while(i!=2&&num<=n)
    {
        i=a[i];
        num++;
    }
    if(num>=n)
    {
        printf("-1\n");
       return 0;
    }
    printf("%d\n",num);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  using P=pair<string,int>;
  vector<P> rest(N);
  vector<int> ord(N);
  for(int i=0;i<N;i++){
    cin >> rest[i].first >> rest[i].second;
    rest[i].second*=-1;ord[i]=i+1;
  }
  {
    bool flag;
    do{
      flag=true;
      for(int i=0;i+1<N;i++){
        if(rest[i]>rest[i+1]){
          flag=false;
          swap(rest[i],rest[i+1]);
          swap(ord[i],ord[i+1]);
        }
      }
    }while(!flag);
  }
  for(int i=0;i<N;i++){
    cout << ord[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    string X;
    cin >> X;
    ll bit = 0;
    REP(i,N)if(X[i] == '1')bit++;
    vector<P> A(N);
    ll base1 = 0,base0 = 0;
    vector<ll> tp1(N);
    tp1[0] = 1;
    if(bit - 1!=0){
        REPS(i,N-1){
            tp1[i] = (tp1[i-1]*2)%(bit-1);
        }
    }
    vector<ll> tp2(N);
    tp2[0] = 1;
    REPS(i,N-1){
        tp2[i] = (tp2[i-1]*2)%(bit+1);
    }
    REP(i,N){
        if(bit - 1 == 0){
            base1 = -1;
        }else{
            if(X[i] == '1'){
                base1 = (base1+tp1[N-i-1])%(bit-1);
            }
        }
        if(X[i] == '1'){
            base0 = (base0 + tp2[N-i-1])%(bit+1);
        }
    }
    REP(i,N){
        if(X[i] == '1'){
            if(base1 == -1){
                A[i] = mp(-1,1);
            }else{
                ll tmp = base1 - tp1[N-i-1];
                if(tmp < 0)tmp += bit-1;
                A[i] = mp(tmp,1);
            }
        }else{
            A[i] = mp((base0 + tp2[N-i-1])%(bit+1),0);
        }
    }
    vector<ll> Ans(N);
    REP(i,N){
        if(A[i].S == 1){
            if(A[i].F < 0){
                Ans[i] = 0;
            }else{
                ll count = 1;
                ll tmp = A[i].F;
                while(tmp){
                    count++;
                    tmp = tmp%__builtin_popcountll(tmp);
                }
                Ans[i] = count;
            }
        }else{
            ll count = 1;
            ll tmp = A[i].F;
            while(tmp){
                count++;
                tmp = tmp%__builtin_popcountll(tmp);
            }
            Ans[i] = count;
        }
    }
    REP(i,N)cout << Ans[i] << "\n";
}

Measured memory_bytes: 11268
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll k,n;
  	cin>>k>>n;
  
  	ll a[n];
  
  	for(ll i = 0; i < n ; i++){
    	cin>>a[i];
    }
  	
  	ll val = -1;
  	for(ll i = 1; i < n ; i++){
    	val = max(val,a[i] - a[i-1]);
    }
  
  val = max(val,a[0] + k - a[n-1]);
  
  cout<<k - val<<endl;
  
  
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ans;
map<int, bool> m;   
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        int a; cin >> a;
        m[a] = !m[a];
        if (m[a]) ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <algorithm>
 
struct Card {
    char suit;
    int value;
};
 
void trace(Card a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%c%d", a[i].suit, a[i].value);
    }
    printf("\n");
}
 
void BubbleSort(Card A[], int N) {
    int count  = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = N - 1; j > i; --j) {
            if ( A[j].value < A[j-1].value ){
                std::swap(A[j], A[j-1]);
                ++count;
            }
        }
    }
 
    trace(A, N);
}
 
void SelectionSort(Card A[], int N) {
    int count  = 0;
    for (int i = 0; i < N; ++i) {
        int min = i;
        for (int j = i; j < N; ++j) {
            if (A[j].value < A[min].value) {
                min = j;
            }
        }
        if (i != min) {
            std::swap(A[i], A[min]);
            count++;
        }
    }
 
    trace(A, N);
}
 
bool IsStable (Card A[], Card B[], int N) {
    for (int i = 0; i < N; ++i) {
        if (A[i].suit != B[i].suit || A[i].value != B[i].value) {
            return false;
        }
    }
    return true;
}
 
int main() {
    int N;
    Card A[100], B[100];
 
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i].suit >> A[i].value;
        B[i] = A[i];
    }
 
    BubbleSort(A, N);
    printf("Stable\n");
    SelectionSort(B, N);
    IsStable(A, B, N) ? printf("Stable\n") : printf("Not stable\n");
    return 0;
}

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

int main()
{
  int A, B; cin >> A >> B;
  if (B == 1) cout << 0 << endl;
  else 
  {
    for (int i = 1; i < 20; i++)
    {
      if (A + (A - 1) * (i - 1) >= B) {
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())

mod = 10 ** 9 + 7
ans = 0

for k in range(K, N + 2):
    last = k * N - k * (k - 1) // 2
    init = N + k * (k - 1) // 2
    ans += init - k * (k - 1) // 2 + 1 + (last - init)
    ans %= mod
    
print(ans)

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


int main() {
  int n, sum = 0, avg = 0, ans = 0, avg1 = 0, ans1 = 0;
  cin >> n;
  int X[n];
  rep(i, n){
    cin >> X[i];
    sum += X[i];
  }
  avg = sum / n;
  avg1 = avg + 1;
  rep(i,n){
    ans += (int)pow((double)(X[i] - avg), 2.0);
    ans1 += (int)pow((double)(X[i] - avg1), 2.0);
  }
  cout << min(ans, ans1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int d;
	cin >> d;
	cout << "Christmas";
	REP(i, 25 - d) cout << " Eve";
	cout << endl;
	return 0;
}
 

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut it = buf.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let mut x = it.next().unwrap();
    let k = it.next().unwrap();
    let mut exp = 0;
    while x > 0 {
        if x > 0 {
            exp += 1;
            x = x / k;
        } else {
            break;
        }
    }
    println!("{}", exp);
}


Measured memory_bytes: 4352
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let (n, k) = get!(usize, i64);
    let p = get!([usize1]);
    let c = get!([i64]);
    let mut ans = -((1 as i64) << 60);
    for i in 0..n {
        let mut now = i;
        let mut len = 0;
        let mut cycle_score: i64 = 0;
        loop {
            now = p[now];
            cycle_score += c[now];
            len += 1;
            if now == i {
                break;
            }
        }
        if k <= len || cycle_score <= 0 {
            let mut score = 0;
            let mut now = i;
            for _ in 0..k.min(n as i64) {
                now = p[now];
                score += c[now];
                ans = ans.max(score);
            }
        } else {
            let mut score = cycle_score * (k / len - 1);
            let left = k % len + len;
            let mut now = i;
            for _ in 0..left {
                now = p[now];
                score += c[now];
                ans = ans.max(score);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2320
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int MX=2005;

int g[MX][MX],ev[MX][MX],eh[MX][MX],v[MX][MX];
int n,m,q;
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		static char t[MX];
		scanf("%s",t+1);
		for(int j=1;j<=m;j++)
			g[i][j]=t[j]-'0';
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1]+g[i][j];
	for(int i=2;i<=n;i++)
		for(int j=1;j<=m;j++)
			ev[i][j]=ev[i-1][j]+ev[i][j-1]-ev[i-1][j-1]+(g[i][j]&g[i-1][j]);
	for(int i=1;i<=n;i++)
		for(int j=2;j<=m;j++)
			eh[i][j]=eh[i-1][j]+eh[i][j-1]-eh[i-1][j-1]+(g[i][j]&g[i][j-1]);
	for(int i=1;i<=q;i++){
		int X1,Y1,X2,Y2;
		scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
		printf("%d\n",
		(v[X2][Y2]-v[X1-1][Y2]-v[X2][Y1-1]+v[X1-1][Y1-1])
		-(ev[X2][Y2]-ev[X1][Y2]-ev[X2][Y1-1]+ev[X1][Y1-1])
		-(eh[X2][Y2]-eh[X1-1][Y2]-eh[X2][Y1]+eh[X1-1][Y1])
		);
	}
	return 0;
}


Measured memory_bytes: 64512
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m==-1 && f == -1 && r == -1){
                break;
            }else{
                if(m == -1 || f == -1 || m+f < 30) {
                    System.out.println("F");
                }else if(m+f >= 80){
                    System.out.println("A");
                }else if(m+f >= 65 && m+f <80){
                    System.out.println("B");
                }else if(m+f >= 50 && m+f < 65 || ((m+f <= 30 && m+f < 50) && r >= 50)){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }
        }
    }
}



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

int main(){
  int X;
  cin >> X;
  long shin[X];
  for(int i=0;i<X;i++){
    cin >> shin[i];
  }
  long dai = 0;
  for(int i=1;i<X;i++){
    //cout << shin[i-1] << shin[i] << endl;
    if(shin[i-1]>shin[i]){
      dai = dai +shin[i-1]-shin[i];
      shin[i] = shin[i-1];
    }
  }
  cout << dai;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    REP(i,m) cin >> x[i];
    sort(x.begin(), x.end());
    vector<int> y(m-1);
    REP(i,m-1) y[i] = x[i+1]-x[i];
    sort(y.begin(), y.end(), greater<>());
    ll ans = 0;
    for (int i = n-1; i < m-1; ++i) ans += y[i];
    cout << ans << endl;
    return 0;
}

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

bool f(int x){
    int keta=0;
        while(x){
            keta++;
            x/=10;
        }
        return keta%2==1;}
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(f(i))ans++;
    }
    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n;

void Preorder(int x)
{
  if(x==NIL) return;
  printf(" %d",x);
  Preorder(T[x].l);
  Preorder(T[x].r);
}

void Inorder(int x)
{
  if(x==NIL) return;
  Inorder(T[x].l);
  printf(" %d",x);
  Inorder(T[x].r);
}

void Postorder(int x)
{
  if(x==NIL) return;
  Postorder(T[x].l);
  Postorder(T[x].r);
  printf(" %d",x);
}

int main()
{
  int i,num,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&num,&l,&r);
    T[num].l=l;
    T[num].r=r;
    if(l!=NIL) T[l].p=num;
    if(r!=NIL) T[r].p=num;
  }

  for(i=0;i<n;i++) if(T[i].p==NIL) root=i;
  printf("Preorder\n");
  Preorder(root);
  printf("\nInorder\n");
  Inorder(root);
  printf("\nPostorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}



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

int main(){
  int N;cin>>N;
  int h[101];
  int now[101]={0};
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  int i=0;
  while(i<N){
    
    if(h[i]-now[i]>0){
      
      for(int j=i;h[j]-now[j]>0;j++){
        now[j]++;
      }
      ans++;
      i=0;
    }else{
      i++;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0 ; i < size(s); i++) if(s[i] != t[i]) cnt++;
    	cout << cnt << endl;
}
  
int32_t main() {
 
    FAST;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    // #endif
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)
		    sum+=i;
	}
	cout<<sum;
	return 0;
}

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

using namespace std;
#define MAX 300

int parent(int i) {
  return i / 2;
}
int left(int i) {
  return i * 2;
}
int right(int i) {
  return i * 2 + 1;
}

int main() {
  int A[MAX];
  int H; cin >> H;

  for (int i = 1; i <= H; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3100
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
W = np.array(lr())
Wcum = W.cumsum()
remain = W.sum() - Wcum
answer = np.min(np.abs(Wcum - remain))
print(answer)


Measured memory_bytes: 12508
#include <iostream>

int hit(int x[],int y[]){
	int num = 0;
	for(int i = 0; i < 4; ++i){
		if(x[i] == y[i])
			++num;
	}
	return num;
}

int blow(int x[],int y[]){
	int num = 0;
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 4;++j){
			if(x[i] == y[j])
				++num;
		}
	}
	return num - hit(x,y);
}

int checkDomain(int x[],int y[]){
	for(int i = 0; i < 4; ++i)
		if((x[i] / 10) != 0 || (y[i] / 10) != 0) return 0;
		
	return 1;
}

int checkNumber(int x[],int y[]){
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 4; ++j){
			if(i != j && (x[i] == x[j] || y[i] == y[j])) return 0;
		}
	}
	return 1;
}

int main(){
	int a[4];
	int b[4];
	
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3] ){
		std::cin >>b[0] >> b[1] >> b[2] >> b[3];
		if(checkDomain(a,b) && checkNumber(a,b)){
					std::cout << hit(a,b) << " " << blow(a,b) << std::endl;
		}
	}
	
}

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

using namespace std;

int main()
{ios_base::sync_with_stdio(false);
    long long int n,a,i;
    cin>>n;
    string s;
    cin>>s;
    a=s.length();
    if(a<=n)
        cout<<s;
    else{
        for(i=n;i<=n+2;i++)
            s[i]='.';
    for(i=0;i<=n+2;i++)
        cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 3616
/*  Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+10;

int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n>=3200)
    {
        cout<<s<<endl;
    }
    else
    {
        cout<<"red"<<endl;
    }
    

}

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

int main() {
  int h,n,amax=0;
  long ans=999999999999;
  cin >> h >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++) {
    cin >> a.at(i) >> b.at(i);
    amax = max(amax,a.at(i));
  };
  vector<long> dp(h+amax,999999999999);
  dp.at(0)=0;
  for(int i=1;i<h+amax;i++) {
    for(int j=0;j<n;j++) {
      if(i-a.at(j)>=0) dp.at(i)=min(dp.at(i),dp.at(i-a.at(j))+b.at(j));
    };
    if(h<=i) ans=min(ans,dp.at(i));
  };
  cout << ans << endl;
}

Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,k;
  cin >> n >> k;
  int a[n+1];
  for(int i=1;i<n+1;i++) cin >> a[i];
  unordered_map<int,int> stateTime;
  int now = 1;
  int t = 0;
  stateTime[now] = t;
  while(true){
    now = a[now];
    t++;
    if(stateTime.find(now) != stateTime.end()) break;
    stateTime[now] = t;
  }
  ll f = t - stateTime[now];
  if(k > stateTime[now]){
    k = stateTime[now]+(k-stateTime[now])%f;
  }
  int ans = 1;
  for(int i=0;i<k;i++) ans = a[ans];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12060
N = int(input())
odds = [i for i in range(1, N + 1) if i % 2 != 0]
ans = 0
for odd in odds:
    cnt = 0
    for bunbo in odds:
        if odd % bunbo == 0:
            cnt += 1
    if cnt == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  map<ll, int> mp;
  ll N, M, a, b;
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> a;
    mp[a]++;
  }
  for(int i = 0; i < M; i++) {
    cin >> b;
    mp[b]++;
  }

  int and_cnt = 0, or_cnt = 0;
  for(auto itr : mp){
    or_cnt++;
    if(mp[itr.first] == 2) and_cnt++;
  }
  cout << and_cnt << " " << or_cnt << endl;

  for(auto itr : mp){
    if(itr.second == 2) cout << itr.first << endl;
  }
  for(auto itr : mp){
    cout << itr.first << endl;
  }
  return 0;
}


Measured memory_bytes: 16548