akhauriyash/Code-Regression huggingface dataset:
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
vector <int> g[N] ;
int dp[N] ;
 
void dfs(int u, int par) {
    int cnt[25] ;
    memset(cnt,0,sizeof(cnt));
    for(int i = 0; i < (int)g[u].size(); i++) {
        int v = g[u][i] ;
        if(v == par) 
			continue;
        dfs(v,u);
        for(int j = 0; j < 20; j++) 
            if((dp[v] & (1 << j))) 
				cnt[j]++ ;
    }
    int myCol = 0;
    for(int i= 20 - 1; i >= 0; i--) {
        if(cnt[i] > 1) {
            myCol = i + 1;
            break;
        }
    }
    while(cnt[myCol]) 
		myCol++ ;
    dp[u] |= (1 << myCol) ;
    for(int i = myCol + 1; i < 20; i++) 
        if(cnt[i]) 
			dp[u] |= (1 << i);
}
 
int32_t main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v); 
		g[v].pb(u);
    }
    dfs(1,0) ;
    int ans = 0;
    while(dp[1] > 0) {
        dp[1] /= 2 ;
        ans++ ;
    }
    cout << ans - 1;
    return 0 ;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned long, unsigned long>> A;
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        A.emplace_back(a, i);
    }
    sort(A.begin(), A.end(), greater<>());
    vector<unsigned long> dp(N + 1), prev(N + 1);
    for(unsigned long i{0}; i < N; ++i){
        dp.swap(prev);
        fill(dp.begin(), dp.end(), 0UL);
        const auto& [a, idx] = A[i];
        for(unsigned long j{0}; j <= i; ++j){
            unsigned long k{N + j - i - 1};
            dp[j] = max(dp[j], prev[j] + a * (max(idx, k) - min(idx, k)));
            dp[j + 1] = max(dp[j + 1], prev[j] + a * (max(idx, j) - min(idx, j)));
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 3708
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,q;
int a[100001];
vector<int> f;
vector<int> ff;
bool used[100001];
int place[100001];
int freq[100001];

int main(void){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<q;i++){
		scanf("%d",&a[i]);
	}
	memset(used,false,sizeof(used));
	for(int i=q-1;i>=0;i--){
		if(!used[a[i]]){
			used[a[i]]=true;
			f.push_back(a[i]);
		}
	}
	for(int i=1;i<=m;i++){
		if(!used[i])f.push_back(i);
	}
	for(int i=0;i<m;i++){
		place[f[i]]=i;
	}
	freq[0]=n;
	for(int i=q-1;i>=0;i--){
		if(freq[place[a[i]]]>0){
			freq[place[a[i]]]--;
			freq[place[a[i]]+1]++;
		}
	}
	int mini=m;
	for(int i=m-1;i>=0;i--){
		if(freq[i]>0)mini=i;
	}
	memset(used,false,sizeof(used));
	for(int i=0;i<mini;i++){
		ff.push_back(f[i]);
		used[f[i]]=true;
	}
	for(int i=1;i<=m;i++){
		if(!used[i])ff.push_back(i);
	}
	bool flag=true;
	for(int i=mini;i<m;i++){
		if(f[i]!=ff[i])flag=false;
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 2680
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, x, y = MAP()
x -= 1; y -= 1
nodes = [[] for i in range(N)]
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

def dfs(x):
    dist  = [INF] * N
    stack = [(x, 0, -1)]
    while stack:
        u, cost, prev = stack.pop()
        if dist[u] != INF:
            continue
        dist[u] = cost
        for v in nodes[u]:
            if v == prev:
                continue
            stack.append((v, cost+1, u))
    return dist

# 追われる側、追う側それぞれからの最短距離
res1 = dfs(x)
res2 = dfs(y)

mx = -INF
for i in range(N):
    # 追われる側のが先に着く場所は逃げ込む候補になりうる
    if res1[i] <= res2[i]:
        # その中で一番追う側から遠い場所
        mx = max(mx, res2[i])
# 最終的に1歩手前で捕まるので-1
print(mx - 1)


Measured memory_bytes: 29232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map> 
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)



int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int res = 0;
  for (int i = 0;i <= n;i++){
     for (int j = 0; j <= n;j++){
        if ((n-i*r - g*j) >= 0 && (n-i*r - g*j)%b == 0) {
           res++;
           //printf("(i,j,k) = (%d,%d,%d)\n",i,j,(n-i*r - g*j)/b); 
        } 
     }
  }
  cout << res << endl;

   return 0;
}



Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	a, b := ReadInt(), ReadInt()
	fmt.Println((1 + a + b) / 2)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
# your code goes here

def main(base, new):
	new_base = []
	for member in base:
		if member in new:
			new_base.append(member)
		else:
			pass
	return new_base


init = input()
base = input().split(' ')[1:]
try:
	while True:
		base = main(base, input().split(' ')[1:])
except:
	pass
print(len(base))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;++i)for(int j=1;j<=d;++j)if(j/10>=2&&j%10>=2&&(j/10)*(j%10)==i)++ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

#define R (rand() < RAND_MAX / 2)

const int T1[] = {
	51, 102, 204, 816, 1632, 3264, 13056, 26112, 52224
};

const int T2[][5] = {
	{0, 1, 2, 3, 6},
	{0, 1, 2, 4, 7},
	{0, 1, 2, 5, 8},
	{0, 3, 4, 5, 6},
	{1, 3, 4, 5, 7},
	{2, 3, 4, 5, 8},
	{0, 3, 6, 7, 8},
	{1, 4, 6, 7, 8},
	{2, 5, 6, 7, 8}
};

const int M1 = 9;
const int M7 = 4782969;

int n;
int s[366];
set<int> vis[366][9];

int dfs(int d, int p, int st)
{
	if (vis[d][p].count(st)) return 0;
	if (d >= 7){
		int x = st, y = 0;
		rep(i, 7){
			y |= T1[x % M1];
			x /= 9;
		}
		if (y != (1 << 16) - 1){
			// vis[d][p].insert(st);
			return 0;
		}
	}
	if (d == n) return 1;
	if (s[d] & T1[p]){
		if (R) vis[d][p].insert(st);
		return 0;
	}
	for (int to : T2[p]){
		if (dfs(d + 1, to, (st * 9 + p) % M7)){
			return 1;
		}
	}
	if (R) vis[d][p].insert(st);
	return 0;
}

int main()
{
	while (cin >> n, n){
		rep(i, 366) rep(j, 9) vis[i][j].clear();
		rep(i, n){
			s[i] = 0;
			rrep(j, 16){
				int b;
				cin >> b;
				s[i] = s[i] * 2 + b;
			}
		}
		cout << dfs(0, 4, 0) << endl;
	}
}

Measured memory_bytes: 45000
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
int n, Q, f[N][N], a[N], inv2, pow = 1, ans = 0;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
signed main()
{
	n = read(); Q = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++) f[i][j] = (a[i] < a[j]);
	inv2 = (mod + 1) / 2;
	for(int i = 1, x, y; i <= Q; i ++)
	{
		x = read(); y = read(); pow = pow * 2 % mod;
		f[x][y] = f[y][x] = (f[x][y] + f[y][x]) % mod * inv2 % mod;
		for(int j = 1; j <= n; j ++)
		{
			if(j == x || j == y) continue;
			f[x][j] = f[y][j] = (f[x][j] + f[y][j]) % mod * inv2 % mod;
			f[j][x] = f[j][y] = (f[j][x] + f[j][y]) % mod * inv2 % mod;
		}
	}
	for(int i = 1; i <= n; i ++) for(int j = i - 1; j >= 1; j --) ans = (ans + f[i][j]) % mod;
	printf("%lld\n", ans * pow % mod);
	return 0;
}


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

int main() {
	int A, B;
  	cin >> A >> B;
  
  if( A > 0 && B > 0 ) cout << "Positive" << endl;
  else if ( A <= 0 && B >= 0 ) cout << "Zero" << endl;
  else if ( A < 0 && B < 0 && (A + B)%2 == 0 ) cout << "Negative" << endl;
  else cout << "Positive" << endl;

	
}

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

using namespace std;
using ll = long long;

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

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

vector<int> v;

ll culc()
{
	ll a = 0, b = 0;
	int i;
	for (i = 1; i < v.size(); i++) {
		if (v[i] == v[i-1]) {
			a = v[i];
			i+=2;
			break;
		}
	}
	for (; i < v.size(); i++) {
		if (v[i] == v[i-1]) {
			b = v[i];
			break;
		}
	}
	return a*b;
}


int main()
{
	CIN(int, N);
	rep(i, N) {
		CIN(int, a);
		v.PB(-a);
	}
	sort(all(v));
	cout << culc() << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>x(n),y(n),p(n); 
  rep(i,n) cin >> x[i] >> y[i] >> p[i]; 
  vector<ll>ans(n+1,1e18);
  
  vector<vector<ll>> distx(1<<n,vector<ll>(n));
  vector<vector<ll>> disty(1<<n,vector<ll>(n));
  for(int bit=0;bit<(1<<n);bit++){
    rep(i,n){
      distx[bit][i]=abs(x[i]);
      disty[bit][i]=abs(y[i]);
      rep(j,n){
        if(bit&(1<<j)){
          distx[bit][i]=min(distx[bit][i],abs(x[i]-x[j]));
          disty[bit][i]=min(disty[bit][i],abs(y[i]-y[j]));
        }
      }
    }
  }
  for(int bit=0;bit<(1<<n);++bit){
    int cnt = __builtin_popcount(bit);
    for(int i=bit;i>=0;--i){
      i&=bit;//bitで表せる選び方の部分集合i
      ll cost = 0;
      rep(j,n){
        if(!(i&(1<<j))){
          cost += min(distx[i][j],disty[bit-i][j])*p[j];
        }
      }
      ans[cnt]=min(ans[cnt],cost);
    }
  }
  rep(i,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 12972
import static java.lang.Math.max;
import static java.lang.Math.min;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Locale;
import java.util.Scanner;

public class Main {

	final static int INF = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Locale.setDefault(Locale.ENGLISH);
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		solve(in, System.out);
		in.close();
	}

	protected static void solve(Scanner in, PrintStream out) {
		int n = in.nextInt();
		int w = in.nextInt();
		int[] a = new int[n];
		int[] wt = new int[n];
		for (int j = 0; j < n; j++) {
			wt[j] = in.nextInt();
			a[j] = in.nextInt();
		}
		long ret = solveLine(n, w, a, wt);
		out.printf(Locale.ENGLISH, "%s%n", ret);
	}

	private static long solveLine(int n, int w, int[] v, int[] wt) {
		int maxval = n * 1000 + 1;
		long[][] dp = new long[n + 1][maxval + 1];
		for (int i = 1; i <= maxval; i++) {
			dp[0][i] = i <= v[0] ? wt[0] : INF;
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j <= maxval; j++) {
				dp[i][j] = j < v[i] ? dp[i - 1][j] : min(dp[i - 1][j], dp[i - 1][j - v[i]] + wt[i]);
			}
		}
		long ans = INF;
		for (int i = 0; i <= maxval; i++) if (dp[n - 1][i] <= w) ans = i;
 		return ans;
	}

}

Measured memory_bytes: 127316
s = input()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        ans += 1
print(ans)


Measured memory_bytes: 3956
#include<stdio.h>
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	N>=1;
	N<=100;
	M>=0;
	M<= N;
	if(M==N){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
s = input()
K = int(input())


def substring(s, K):
    substrings = []
    length = len(s)
    for i in range(length):
        for j in range(1, K+1):
            if i + j > length:
                break
            substrings.append(s[i:i + j])
    unique_substrings = list(set(substrings))
    unique_substrings.sort()
    return unique_substrings[K - 1]


print(substring(s, K))


Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
using P = pair<pi,pi>;

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

    vector<int> t(n),v(n);
    rep(i,n) cin >>t[i];
    rep(i,n) cin >>v[i];

    vector<int> st(n);
    st[0] = t[0];
    for(int i=1; i<n; ++i) st[i] = st[i-1]+t[i];

    int T=st[n-1];

    vector<P> cond;
    cond.pb({{1,0},{0,T}});
    cond.pb({{-1,T},{0,T}});

    int pre = 0;
    rep(i,n)
    {
        cond.pb({{0,v[i]},{pre,pre+t[i]}});
        cond.pb({{-1,v[i]+pre},{0,pre}});
        cond.pb({{1,v[i]+pre},{pre+t[i],T}});
        pre += t[i];
    }

    double ans = 0;
    double nv = 0;
    rep(i,2*T)
    {
        double now = 0.5*i;
        double nx = now+0.5;
        // printf("%5.2f: v = %5.2f\n", now,nv);

        double lim = nv+0.5;
        rep(j,cond.size())
        {
            pi para = cond[j].fi;
            pi range = cond[j].se;
            if(range.fi<=now && now<range.se)
            {
                lim = min(lim, para.fi*nx+para.se);
            }
        }

        ans += (nv+lim)/2;
        nv = lim;
    }

    printf("%.10f\n", ans/2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,m; cin>> n>>m;
	if (n>m) swap(n,m);
	if (n>1) cout << 1LL*(n-2)*(m-2);
	else if (m>1) cout << m-2;
        else cout << 1;
       return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

template<typename T>
struct segtree{
    int n;
    vector<T> dat;
    T unit;

    void init(int n_, T unit_) {
        unit = unit_;
        n = 1;
        while(n < n_) n *= 2;
        dat.assign(2*n-1, unit);
    }

    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }

    //(a,b,0,0,seg.n)で呼ぶ
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return unit;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl, vr);
        }
    }
};

segtree<int> segm,segM;
int N, K;
int P[200000];
int sum[200000];

int main() {
    cin >> N >> K;
    segm.init(N,inf);
    segM.init(N,0);
    rep(i,N) cin >> P[i];
    rep(i,N-1) {
        if (P[i] > P[i+1]) sum[i+1]++;
        if (i > 0) sum[i+1] += sum[i];
    }
    rep(i,N) {
        segm.update(i, P[i]);
        segM.update(i, -P[i]);
    }
    int hoge = 0;
    int ans = 1;
    if (sum[K-1]-sum[0] == 0) hoge = 1;
    for (int i = 1; i < N-K+1; i++) {
        int mi = segm.query(i, i+K, 0, 0, segm.n);
        int ma = -segM.query(i, i+K, 0, 0, segM.n);
        if (ma == P[i+K-1] && mi > P[i-1]) continue;
        if (sum[i+K-1]-sum[i] == 0) {
            if (hoge == 0) ans++;
            hoge = 1;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string ans = "";
                int[] memo = new int[10];

                for (int i = 0; i < input.Length; i++)
                {
                    int index = int.Parse(input[i].ToString());
                    memo[index]++;
                }

                for (int i = 1; i <= 9; i++)
                {
                    if (memo[i] == 4) continue;
                    if (Check(memo, i)) ans += (i + " ");
                }

                if (ans == "") sb.AppendLine("0");
                else sb.AppendLine(ans.TrimEnd());
            }
            Console.Write(sb);
        }

        static bool Check(int[] source, int add)
        {
            for (int i = 1; i <= 9; i++)
            {
                int[] nums = (int[])source.Clone();
                nums[add]++;

                if (nums[i] < 2) continue;
                nums[i] -= 2;

                for (int j = 1; j <= 9; j++)
                {
                    if (nums[j] >= 3) nums[j] -= 3;

                    if (nums[j] < 3 && j < 8)
                    {
                        while (nums[j] != 0)
                        {
                            nums[j]--;
                            nums[j + 1]--;
                            nums[j + 2]--;
                        }

                        if (nums[j + 1] < 0 || nums[j + 2] < 0) break;
                    }
                }
                if (nums.All(n => n == 0)) return true;
            }
            return false;
        }
    }
}

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n;
  cin >> n;
  vector<P> ans(n);
  rep(i,n){
    cin >> ans[i].first;
    ans[i].second = i+1;
  }
  sort(ans.begin(),ans.end());
  rep(i,n){
    cout << ans[i].second << endl;
  }
  return 0;
  
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string s;
size_t cur=0;

int digit(){
	int d=(s[cur++]-'0');
	return d;
}

int number(){
	int res=digit();
	int n=s.size();
	while(cur<n&&isdigit(s[cur])){
		res=10*res+digit();
	}
	return res;
}

int lr(){
	int res=number();
	int n=s.size();
	while(cur<n){
		char op=s[cur++];
		int arg=number();
		if(op=='+')
			res+=arg;
		else
			res*=arg;
	}
	return res;
}

int add(){
	int res=number();
	int n=s.size();
	while(cur<n&&s[cur]=='*'){
		cur++;
		int arg=number();
		res*=arg;
	}
	return res;
}

int mul(){
	int res=add();
	int n=s.size();
	while(cur<n&&s[cur]=='+'){
		cur++;
		int arg=add();
		res+=arg;
	}
	return res;
}
int main(void){
	cin >> s;
	int in;
	cin >> in;

	cur=0;
	bool res=(lr()==in);
	cur=0;
	bool res2=(mul()==in);

	if(res&res2)
		puts("U");
	else if(res)
		puts("L");
	else if(res2)
		puts("M");
	else
		puts("I");
	return 0;
}

Measured memory_bytes: 1176
N = int(input())
S = input()

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)


Measured memory_bytes: 39792
#include<stdio.h>

long n,m,par[200000];

long find(long x){
	if(x!=par[x]) par[x]=find(par[x]);
	return par[x];
}

int main(){
	long i,x,y;
	scanf("%ld %ld",&n,&m);
	for(i=0;i<n+m;i++){
		par[i]=i;
	}
	for(i=0;i<n;i++){
		scanf("%ld",&x);
		while(x){
			scanf("%ld",&y);
			y=y-1+n;
			par[find(i)]=find(y);
			x--;
		}
	}
	for(i=0;i<n;i++){
		if(find(i)!=find(0)){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N,K,S;
	cin >> N >> K >> S;
	
	
	//SOLVE
	vector<llint> A(N);
	llint buf;
	if (K == 0) {
		if(S == (llint)(1e9)) {
			buf = (llint)(1e9) -1;
		} else {
			buf = (llint)(1e9);
		}
		rep(i,0,N) {
			puts(buf);
		}
		cout << endl;
		return 0;
	}
	
	llint nk = N+1-K;  //何個でS？ //K 1~N
	
	llint a1 = S / nk;
	if (a1 == 0) {
		rep(i,0,K) {
			A[i] = S;
		}
		rep(i,K,N) {
			A[i] = (llint)(1e9);
		}
		
	} else {
		rep(i,0,N) {
			A[i] = a1;
		}
		// rep(i,nk*K,N) {
		// 	A[i] = (llint)(1e9);
		// }
		buf = S%nk;
		for(llint i=nk-1 ;i<N;i+=nk) {
			A[i] += buf;
		}
	}
	
	//OUTPUT
	rep(i,0,N) {
		puts(A[i]);
	}
	cout << endl;
	return 0;
}






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

int a, b;
string s;

int main(){
	cin >> a >> b >> s;
	if (s.size() != a + b + 1) {
		cout << "No" << endl;
		return 0;
	}
	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < a; i++) {
		if (s[i] - '0' < 0 || s[i] - '0'>10) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = a + 1; i < a + b + 1; i++) {
		if (s[i] - '0' < 0 || s[i] - '0'>10) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
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;}

const int N = 4e3 + 10;
int suffr[N];
int suffg[N];
int suffb[N];


void solve()
{
    int n; cin>>n;
    string s; cin>>s;
    ll ans = 0;
    rep(i, n)
    {
        if(s[i] == 'R') suffr[i+1]++;
        if(s[i] == 'G') suffg[i+1]++;
        if(s[i] == 'B') suffb[i+1]++;
        suffr[i+1] += suffr[i];
        suffg[i+1] += suffg[i];
        suffb[i+1] += suffb[i];
    }
    rep(i, n)
    {
        REP(j, i+1, n-1)
        {
            if(s[i] == 'R' && s[j] == 'G'){
                ans += suffb[n] - suffb[j] - 1*(s[j+j-i] == 'B');
            }
            if(s[i] == 'R' && s[j] == 'B'){
                ans += suffg[n] - suffg[j] - 1*(s[j+j-i] == 'G');
            }
            if(s[i] == 'G' && s[j] == 'B'){
                ans += suffr[n] - suffr[j] - 1*(s[j+j-i] == 'R');
            }
            if(s[i] == 'G' && s[j] == 'R'){
                ans += suffb[n] - suffb[j] - 1*(s[j+j-i] == 'B');
            }
            if(s[i] == 'B' && s[j] == 'G'){
                ans += suffr[n] - suffr[j] - 1*(s[j+j-i] == 'R');
            }
            if(s[i] == 'B' && s[j] == 'R'){
                ans += suffg[n] - suffg[j] - 1*(s[j+j-i] == 'G');
            }
        }
    }
    cout<<ans;
    
    
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    while(t-- )
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string a, b; cin >> a >> b;
    
    if(a.length() == b.length()){
        for(int i= 0; i < a.length(); i++) cout << a[i] << b[i];
        cout << endl;
    } else {
        for(int i= 0; i < b.length(); i++) cout << a[i] << b[i];
        cout << a.back() << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int32_t main(){
    fast;
    
     ll n;
     cin>>n;
     
     vi v(n);
     for(ll i=0;i<n;i++)
     cin>>v[i];
     ll INF=1e+18;
     vi dp(n,INF);
     dp[0]=0;
     dp[1]=abs(v[1]-v[0]);
     
     for(ll i=2;i<n;i++)
     dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
     
     cout<<dp[n-1];
     
    
    return 0;
    
}

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

#define MAX 3000
int dp[MAX+1][MAX+1];

string getLCS(string& s,string& t,int len) {
    int i=0,j=0;
    string LCS;

    while(len>0) {
        if(s[i]==t[j]) {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else {
            if(dp[i][j+1] > dp[i+1][j]) {
                j++;
            } else {
                i++;
            }
        }
    }

    return LCS;
}

int lenOfLCS(string&s ,string& t,int i, int j) {
    if(i>=s.size() || j>= t.size()) {
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];

    if(s[i]==t[j])
        return dp[i][j]=1+lenOfLCS(s,t,i+1,j+1);
    else 
        return dp[i][j]=max(lenOfLCS(s,t,i+1,j), lenOfLCS(s,t,i,j+1));
}

string printLCS(string& s,string& t) {
    int lcsLen = lenOfLCS(s,t,0,0);
    return getLCS(s,t,lcsLen);
}

int main() {
    string s,t;
    cin >> s >> t;

    memset(dp,-1,sizeof dp);

    cout << printLCS(s,t) << "\n";

    return 0;
}

Measured memory_bytes: 35968
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 1;
    String s[] = new String[n];
    s[0] = sc.next();
    for (int i = 1; i < n; i++){
      String p = sc.next();
      s[i] = p;
      String g = s[i-1].substring(s[i-1].length() - 1);
      if (!(p.substring(0, 1).equals(g))){
        ans *= 0;
      }
    }
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n-1; j++){
        if (i != j){
          if (s[i].equals(s[j])){
            ans *= 0;
          }
        }
      }
    }
    System.out.println(ans == 0 ? "No" : "Yes");
  }
}

Measured memory_bytes: 35532
#include <bits/stdc++.h>
using namespace std;
#define N 210000
const double PI=acos(-1);
int n,n1,num;
double ans;
struct node
{
	int x,y;
	friend bool operator < (const node &r1,const node &r2)
	{return r1.x<r2.x;}
}st,ed,a[N],b[N];
int c[N];
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d%d%d",&st.x,&st.y,&ed.x,&ed.y);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	if(st.x>ed.x)swap(st,ed);
	if(st.y>ed.y)
	{
		st.y=-st.y;ed.y=-ed.y;
		for(int i=1;i<=n;i++)a[i].y=-a[i].y;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i].x>=st.x&&a[i].x<=ed.x&&a[i].y>=st.y&&a[i].y<=ed.y)
			b[++n1]=a[i];
	}
	sort(b+1,b+1+n1);
	for(int i=1;i<=n1;i++)
	{
		if(!num||b[i].y>c[num])c[++num]=b[i].y;
		else
		{
			int t=upper_bound(c+1,c+1+num,b[i].y)-c;
			c[t]=b[i].y;
		}
	}
	if(num==min(ed.y-st.y,ed.x-st.x)+1)
	{
		ans=10*PI-20;
		num--;
	}
	ans+=(double)(ed.y-st.y+ed.x-st.x)*100-num*20.0+num*5*PI;
	printf("%.11lf\n",ans);
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF (2e9)

int main() {
  ll H, W, K; cin >> H >> W >> K;
  char C[6][6];

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c; cin >> c;
      C[i][j] = c;
    }
  }

  vector<vector<ll>> line_combinations, row_combinations;
  for(int bit = 0; bit < (1<<H); ++bit){
    vector<ll> combination;
    for(int i = 0; i < H; ++i){
      if(bit & (1<<i)){
        combination.push_back(i);
      }
    }
    line_combinations.push_back(combination);
  }
  for(int bit = 0; bit < (1<<W); ++bit){
    vector<ll> combination;
    for(int i = 0; i < W; ++i){
      if(bit & (1<<i)){
        combination.push_back(i);
      }
    }
    row_combinations.push_back(combination);
  }

  ll ans = 0;
  for(int i = 0; i < (1<<H); ++i){
    for(int j = 0; j < (1<<W); ++j){
      char C_copy[6][6];
      for(int k = 0; k < H; ++k){
        for(int l = 0; l < W; ++l){
          C_copy[k][l] = C[k][l];
        }
      }  
      for(int k = 0; k < line_combinations[i].size(); ++k){
        for(int l = 0; l < W; ++l){
          C_copy[line_combinations[i][k]][l] = '.';
        }
      }
      for(int k = 0; k < row_combinations[j].size(); ++k){
        for(int l = 0; l < H; ++l){
          C_copy[l][row_combinations[j][k]] = '.';
        }
      }
      ll cnt = 0;
      for(int k = 0; k < H; ++k){
        for(int l = 0; l < W; ++l){
          if(C_copy[k][l] == '#') ++cnt;
        }
      }
      if(cnt == K) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
  int n; cin>>n;
  int a[15]={},x[15][15]={},y[15][15]={};

  REP(i,n){
    cin>>a[i];
    REP(j,a[i]) cin>>x[i][j]>>y[i][j];
  }
  
  int reg=0;
  REP(bit,1<<n){
    int s[n]={};
    REP(i,n) s[i]=(bit>>i)&1;
    
    bool check=true;
    REP(i,n){
      if(s[i]==0) continue;
      REP(j,a[i]){
        if(s[x[i][j]-1]!=y[i][j]) check=false;
      }
    }

    int cnt=0;
    if(check==true){
      REP(i,n) cnt+=s[i];
    }
    reg=max(reg,cnt);
  }
  cout<<reg<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
 
  cout << sum << endl;
}

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

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

int main(void) {
	int n=0, i;
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i])n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3916
using System;
using static System.Math;

class Program {
  static void Main() {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int t = a + b;
    if (t % 2 == 1) {
      Console.WriteLine("IMPOSSIBLE");
    } else {
      Console.WriteLine(t / 2);
    }
  }
}

Measured memory_bytes: 11092
from collections import deque
N, M = map(int, input().split())

edge = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)


seen = [0] * (N + 1)
seen[1] = 1
ans = deque([1])

# 1から前後に伸ばしていく
s = 1
while True:
    update = False
    for t in edge[s]:
        if seen[t]:
            continue
        update = True
        seen[t] = 1
        break
    if not update:
        break
    ans.append(t)
    s = t

s = 1
while True:
    update = False
    for t in edge[s]:
        if seen[t]:
            continue
        update = True
        seen[t] = 1
        break
    if not update:
        break
    ans.appendleft(t)
    s = t

print(len(ans))
print(*ans)

Measured memory_bytes: 28432
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

int n;
vector<string> w;
vector<int> p;

int readUsoperant(string& s)
{
    int m = s.size();
    vector<int> dp(m+1, -INF);
    dp[0] = 0;

    for(int i=0; i<m; ++i){
        for(int j=0; j<n; ++j){
            if(s.substr(i, w[j].size()) == w[j])
                dp[i+w[j].size()] = max(dp[i+w[j].size()], dp[i] + p[j]);
        }
    }

    return dp[m];
}

int writeUsoperant(int a)
{
    vector<int> dp(a+1, INF);
    dp[0] = 0;

    for(int i=0; i<a; ++i){
        for(int j=0; j<n; ++j){
            if(i + p[j] <= a)
                dp[i+p[j]] = min(dp[i+p[j]], dp[i] + (int)w[j].size());
        }
    }

    return dp[a];
}

int main()
{
    for(int c=1; ; ++c){
        cin >> n;
        if(n == 0)
            return 0;

        w.resize(n);
        p.resize(n);
        for(int i=0; i<n; ++i)
            cin >> w[i] >> p[i];

        string s;
        cin >> s;

        int ret = writeUsoperant(readUsoperant(s));
        cout << "Case " << c << ": " << ret << endl;
    }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int inf=100000000;

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

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S; cin>>S;
    int ans=0;
    for(int i=0; i<S.size(); i++)
    {
        if(S[i]=='1') ++ans;
    }
    cout<<ans<<endl;
    return  0;
}


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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 3; i++) {
    if (S[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

void reader(int *x) {
	int k = getchar(); *x = k - '0';
	while (true) {
		k = getchar();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
bool b[200000], ok[100000];

void bfs(int u) {
	queue<int>que;
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int v : E[p]) {
			if (d[v] == d[p] + 1 && !ok[v]) {
				ok[v] = true; cnt++; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);
	}
	queue<int>que;
	memset(d, -1, sizeof(d));
	d[0] = 0; que.push(0);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int i : E[p]) {
			if (d[i] == -1) {
				d[i] = d[p] + 1; que.push(i);
			}
		}
	}
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = true;
	}
	ok[0] = true;
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = true;
				bfs(v[r[i]]);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13692
n,Y = map(int,input().split())
x = -1
y = -1
z = -1

for i in range(Y//10000 + 1):
    for j in range(n-i+1):
        if 9*i + 4*j == Y/1000 - n:
            x = i
            y = j
            z = n-i-j
print(x,y,z)

Measured memory_bytes: 3060
M,K = map(int, input().split())

if 2 ** M <= K:
  print(-1)
  exit(0)
  
if M == 0:
  print(0,0)
elif M == 1 and K == 0:
  print(0,0,1,1)
elif M == 1 and K >= 1:
  print(-1)
else:
  A = list(range(2**M))
  B = A[:K] + A[K+1:]
  C = map(str, B + [K] + B[::-1] + [K])
  print(" ".join(C))
  
    

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

int main() {
  int N;
  cin >> N;
  map<string,int> A;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    A[S]++;
  }
  cout << "AC x " << A["AC"] << endl;
  cout << "WA x " << A["WA"] << endl;
  cout << "TLE x " << A["TLE"] << endl;
  cout << "RE x " << A["RE"] << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <map>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

string to_string(int a, int l) {
    string s;
    repeat (i, l) {
        s += a % 10 + '0';
        a /= 10;
    }
    whole(reverse, s);
    return s;
}
int from_string(string const & s) {
    int a = 0;
    for (char c : s) {
        a *= 10;
        a += c - '0';
    }
    return a;
}
string updated(string const & s) {
    string down = s;
    whole(sort, down);
    string up = down;
    whole(reverse, up);
    int l = s.length();
    return to_string(from_string(up) - from_string(down), l);
}
int main() {
    while (true) {
        int a, l; scanf("%d%d", &a, &l);
        if (a == 0 and l == 0) break;
        int i = 0;
        string s = to_string(a, l);
        map<string, int> used;
        while (not used.count(s)) {
            used[s] = i;
            ++ i;
            s = updated(s);
        }
        printf("%d %d %d\n", used[s], from_string(s), i - used[s]);
    }
    return 0;
}

Measured memory_bytes: 2812