akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,Q;
int A[25];
int M[205];
vector<int> ans;
signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&A[i]);
    scanf("%lld",&Q);
    rep(i,Q)scanf("%lld",&M[i]);
    for(int i=0;i<1<<N;i++){//全ての組み合わせを試す 2^20=10^6程度
            int sum=0;
            for(int j=0;j<N;j++){
                if((i>>j)%2==1)sum+=A[j];
            }
            //printf("%lld/",sum);
            ans.pb(sum);
        }
        sort(ans.begin(),ans.end());
    for(int q=0;q<Q;q++){
        if(binary_search(ans.begin(),ans.end(),M[q]))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 10632
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().trim.toInt
  val lst: Array[Int] = (0 until n).map{ _ =>
    StdIn.readLine().trim.toInt
  }.sorted.toArray
  
  var lsize = lst.size

  var evl = 2
  var max = lst.last
  while(evl < scala.math.sqrt(max)){
    (0 until lsize).foreach{ i =>
      val tmp = lst(i)
      if(tmp != evl){
        lst(i) = if(tmp % evl == 0) 0 else tmp
      }
    }
    evl += 1
  }

  println(lst.filter(p => p != 0).size)
  
}



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

int main(){
  int n, a, sum=0;
  cin >> n;
  
  for(int i=1; i <= n; i++){
    cin >> a;
    if((a % 2) == 1){
      if((i % 2) == 1){
        sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3612
A, B, C = list(map(int, input().split()))

if A == 5 and B == 5 and C == 7:
  print("YES")
elif A == 5 and B == 7 and C == 5:
  print("YES")
elif A == 7 and B == 5 and C == 5:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 2940
def main():
    s = input()
    n = len(s)
    output = 0

    ss = s.replace("A", "1").replace("T", "1").replace("G", "1").replace("C", "1")

    for i in range(n + 1):
        if "1" * i in ss:
            output = i

    print(output)
    return 0


if __name__ == '__main__':
    main()


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

using namespace std;

int INF = 1 << 20;

int main() {
  int N, M;

  cin >> N >> M;

  vector<int> a(M), b(M), c(M);

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= 1;
    b[i] -= 1;
  }

  vector<vector<int>> dist(N, vector<int>(N, INF));

  for (int i = 0; i < N; i++) {
    dist[i][i] = 0;
  }

  for (int i = 0; i < M; i++) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (dist[a[i]][b[i]] < c[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	rep(t, N) {
		bool yes = true;
		vector<lint>A(10);
		rep(i, 10) {
			cin >> A[i];
		}
		deque<lint>B;
		deque<lint>C;
		B.push_front(0);
		C.push_front(0);
		rep(i, 10) {
			if (i == 0) {
				B.push_front(A[i]);
			}
			else {
				if (B.front() < A[i] && A[i] < C.front()) {
					B.push_front(A[i]);
				}
				else if (C.front() < A[i] && A[i] < B.front()) {
					C.push_front(A[i]);
				}
				else if (B.front() < A[i] && C.front() < A[i]) {
					if (B.front() > C.front()) {
						B.push_front(A[i]);
					}
					else {
						C.push_front(A[i]);
					}
				}
				else {
					cout << "NO" << endl;
					yes = false;
					break;
				}
			}
		}
		if (yes == true) {
			cout << "YES" << endl;
		}
	}
}


Measured memory_bytes: 2992
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b; cin>>a>>b;
    cout << a*b << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
typedef vector<LL> V;
V v[4];
LL N;
LL W;
LL first;
int main(){
	cin>>N>>W;
	REP(i,N){
            LL w,vv;
            cin>>w>>vv;
            if(i==0)first=w;
            LL a=w-first;
            int b=a;
            v[b].push_back(vv);
	}
	REP(i,4){
	   sort(v[i].begin(),v[i].end());
	   v[i].push_back(0);
	   reverse(v[i].begin(),v[i].end());
	}
	REP(i,4){
	    REP(j,v[i].size()){
	        if(j==0)continue;
	        v[i][j]+=v[i][j-1];
	    }
	}
	LL ans=0;
	
	REP(i,v[0].size()){
	    REP(j,v[1].size()){
	        REP(k,v[2].size()){
	            REP(l,v[3].size()){
	                if((i+j+k+l)*first+j+2*k+3*l<=W){
	                   // cout<<i<<j<<k<<l<<endl;
	                    ans=max(ans,v[0][i]+v[1][j]+v[2][k]+v[3][l]);
	                }
	            }
	        }
	    }
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n == 1 || n == 2) {
		cout << "0" << endl;
	}
	else if(n % 2 == 0) {
		cout << n / 2 - 1 << endl;
	}
	else if(n % 2 == 1){
		cout << n / 2 << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,b,f,r,v,j,k,count;
    int room[4][3][10]={0};
    scanf("%d",&count);
    for(i=0;i<count;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        room[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++)
                printf(" %d",room[i][j][k]);
            printf("\n");
        }
        if(i!=3) printf("####################\n") ;
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define V vector<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
string S;
int a[20], t[20];
int L;
void solve()
{
    L = (int)S.size();
    FOR(i, 0, L)
    {
        FOR(j, 0, 13)
        {
            //dump(t[0]);
            t[(j * 10) % 13] = a[j];
        }
        if (i == 0) {
            t[0] = 1;
        }
        FOR(j, 0, 13)
        {
            a[j] = 0;
        }
        if (S[i] == '?') {
            FOR(j, 0, 10)
            {
                FOR(k, 0, 13)
                {
                    a[(k + j) % 13] += t[k];
                }
            }
        } else {
            int s;
            s = (int)S[i] - '0';
            //dump(s);
            FOR(j, 0, 13)
            {
                //cout << (j + s) % 13 << endl;
                a[(j + s) % 13] = t[j];
            }
        }
        FOR(j, 0, 13)
        {
            // cout << i << " " << j << " " << a[j] << endl;
            a[j] %= MOD;
        }
    }
    a[5] = (a[5] + MOD) % MOD;
    cout << a[5] << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

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

int main() {
  int N, K; cin >> N >> K;

  int P[N];
  rep(i, N) cin >> P[i];

  ll sum = 0;
  rep(i, K) sum += P[i];
  ll ans = sum;
  rep(i, N-K) {
    sum += P[i+K];
    sum -= P[i];
    ans = max(ans, sum);
  }
  cout << fixed << setprecision(16) << (K + ans) / 2.0 << endl;

  return 0;
}


Measured memory_bytes: 1024
n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(''.join(sorted(s)))
l.sort()
res=0
ile = 1
for i in range(1, n):
	if l[i] == l[i-1]:
		ile+=1
	else:
		res+=ile * (ile-1) // 2
		ile=1
res+=ile * (ile-1) // 2
print (res)


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

//繰り返し二乗法
int mod_pow(int x, int n, int m) {
    if (n == 0)
        return 1;
    int res = mod_pow(x * x % m, n / 2, m);
    if (n & 1)
        res = res * x % m;
    return res;
}

int N;
int h[110];
int dp[110][220];
unordered_map<int, int> mp;
int mp_inv[220];
int mod = 1e9 + 7;
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++)cin >> h[i];

    set<int> st;
    st.insert(0), st.insert(1);
    for (int i = 1; i <= N; i++)st.insert(h[i]), st.insert(h[i] - 1);
    vint mp_inv(st.begin(), st.end());
    for (int i = 0; i < mp_inv.size(); i++)mp[mp_inv[i]] = i;

    dp[0][1] = 1;
    h[0] = 1;
    for (int i = 0; i < N; i++) {
        if (h[i] < h[i + 1]) {
            for (int j = 1; j < mp[h[i]]; j++)dp[i + 1][j] = dp[i][j] * mod_pow(2, h[i + 1] - h[i], mod) % mod;
            for (int j = mp[h[i]]; j < mp[h[i + 1]]; j++) {
                int a = h[i + 1] - mp_inv[j];
                int b = mp_inv[j] - mp_inv[j - 1];
                dp[i + 1][j] = dp[i][mp[h[i]]] * mod_pow(2, a, mod) % mod * (mod_pow(2, b, mod) - 1 + mod) % mod;
            }
            dp[i + 1][mp[h[i + 1]]] = dp[i][mp[h[i]]] * 2 % mod;

        } else {
            for (int j = 1; j < mp[h[i + 1]]; j++)dp[i + 1][j] = dp[i][j];
            for (int jp = mp[h[i + 1]]; jp <= mp[h[i]]; jp++)(dp[i + 1][mp[h[i + 1]]] += 2 * dp[i][jp]) %= mod;
        }
    }
    int ans = 0;
    for (int i = 0; i < 220; i++)(ans += dp[N][i]) %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W;
int di[4] = {-1, 0, 1, 0}, dj[4] = {0, -1, 0, 1};
char C[405][405];
bool visited[405][405];
ll ans = 0;

int Solve(){
  int nowi = 0; ll cntw = 0, cntb = 0;
  queue <Pii> que; que.push({0, 0});
  visited[0][0] = true;
  while (!que.empty()){
    Pii Q = que.front(); que.pop();
    
    if (C[Q.fi][Q.se] == '#') cntb++;
    else cntw++;

    for (int k = 0; k < 4; k++){
      int I = Q.fi + di[k], J = Q.se + dj[k];
      if (I < 0 || H <= I || J < 0 || W <= J) continue;
      if (C[Q.fi][Q.se] == C[I][J]) continue;
      if (visited[I][J]) continue;
      que.push({I, J});
      visited[I][J] = true;
    }
    
    if (que.empty()){
      ans += cntb * cntw;
      cntb = 0; cntw = 0;
      for (int i = nowi; i < H; i++){
        for (int j = 0; j < W; j++){
          if (!visited[i][j]){
            que.push({i, j});
            nowi = i; visited[i][j] = true;
            break;
          }
        }
        if (!que.empty()) break;
      }
    }
  }
  printf("%lld\n", ans);

  return 0;
}

int main(){
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++) scanf("%s", C + i);
  Solve();

  return 0;
}


Measured memory_bytes: 4112
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n;
	cin>>n;
	if(n%2==0)cout<<n<<endl;
	else cout<<n*2<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
 
int main() {
    int i, n;
    int cnt[26] = {0};
    char c;
    while(scanf("%c", &c) != EOF) {
            if(isupper(c)) {
                c = tolower(c);
            }
            cnt[c-'a']++;
    }
    for(i =0; i < 26; i++) {
        printf("%c : %d\n", i+'a', cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 548
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	ans := 1000000000
	for i := -100; i <= 100; i++ {
		tmp := 0
		for j := 0; j < n; j++ {
			x := a[j] - i
			tmp += x * x
		}
		if tmp < ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<time.h>
#include<algorithm>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	int a = A + B, b = A - B, c = A * B;
	int ans;
	if (a > b) {
		if (a > c)ans = a;
		else ans = c;
	}
	else if (b > c)ans = b;
	else ans = c;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::setprecision;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;
using std::fill;
using std::max_element;
using std::min_element;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
//#define double long double

const long long MOD = 1e9 + 7;
const long long inf = 1e18;
const long long infsmart = 1e12;

vector<long long> ans;
vector<long long> nums;

double ds(ll x)
{
    ll y = 0;
    while (x > 0)
    {
        y += x % 10;
        x /= 10;
    }
    return y;
}

void Fgen(int stlen, int len, ll x)
{
    if (len == 0)
    {
        if (1)
        {
            nums.push_back(x);
        }
        return;
    }
    if (stlen - len <= 2)
    {
        for (int i = 0 + (stlen == len); i <= 9; i++)
        {
            x = 10 * x + i;
            Fgen(stlen, len - 1, x);
            x /= 10;
        }
    }
    else
    {
        x = 10 * x + 9;
        Fgen(stlen, len - 1, x);
        x /= 10;
    }
}

void gen(int len)
{
    nums.resize(0);
    Fgen(len, len, 0);
    for (int i = 0; i < nums.size(); i++)
    {
        ans.push_back(nums[i]);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    for (int i = 1; i <= 9; i++)
    {
        ans.push_back(i);
    }
    for (int i = 2; i <= 16; i++)
    {
        gen(i);
    }
    sort(all(ans));
    ans.resize(unique(all(ans)) - ans.begin());
    vector<long long> rf(ans.size());
    double mn = ans[ans.size() - 1] / ds(ans[ans.size() - 1]);
    for (int i = ans.size() - 2; i >= 0; i--)
    {
        double x = ans[i] / ds(ans[i]);
        if (x <= mn)
        {
            mn = x;
            rf[i] = 1;
        }
        else
        {
            rf[i] = 0;
        }
    }
    for (int i = 0; k > 0; i++)
    {
        if (rf[i]) {
            cout << ans[i] << "\n";
            k--;
        }
    }
}


Measured memory_bytes: 512
# ダイナミック・プログラミング
# PythonではTLEを起こしてしまう例

INF = float('inf')

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

for i in range(N):
    a_i, b_i = map(int, input().split())
    A.append(a_i)
    B.append(b_i)

dp = [[INF]*(H+1) for i in range(N+1)] # DP用配列
dp[0][0] = 0 # 初期化処理
for i in range(0,N):
    for j in range(0,H+1):
        a, b = j+A[i], H
        min_h = a
        if a>b:
            min_h = b
        a, b = dp[i+1][j], dp[i][j]
        if a>b:
            dp[i+1][j] = b
        a, b = dp[i+1][min_h], dp[i+1][j]+B[i]
        if a>b:
            dp[i+1][min_h] = b

print(dp[N][H])


Measured memory_bytes: 281352
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0;bool b=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')b=1;c=getchar();}
	while(c>='0'&&c<='9')n=(n<<3)+(n<<1)+(c^48),c=getchar();
	return b?-n:n;
}

int k;

string s;

main()
{
	k=read();
	cin>>s;
	if(s.size()<=k)cout<<s;
	else
	{
		for(int i=0;i<k;++i)putchar(s[i]);
		puts("...");
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

#define DIS(x,y) (sqrt((double)(x)*(double)(x)+(double)(y)*(double)(y)))
#define INF 999999


vector<double> dist;	// ÅZ£ði[·éXg
vector<int> route;	  // ÅZ[gði[·éXg

void Dijkstra(vector<vector<double> >& connect, int start)
{
	// m[hÌæ¾
	int node_n = connect.size();


	// ÅZ£ði[·éXgðINFÅú»(n_Í0)
	dist.clear();
	dist.resize(node_n);
	for(int i=0; i<node_n; i++) { dist[i] = INF; }
	dist[start] = 0;
	
	// ÅZ[gði[·éXgðINFÅú»(n_Í-1)
	route.clear();
	route.resize(node_n);
	for(int i=0; i<node_n; i++) { route[i] = INF; }
	route[start] = -1;
	
	// ÅZ£mèóÔð\·XgÌì¬
	vector<int> deci(node_n);
	for(int i=0; i<node_n; i++) { deci[i] = false; }

	// »ÝÌm[h
	int now_node;
	
	while(1)
	{
		// Å¬£Ìm[hðæ¾·é
		// úÌÅ¬lÍINFæèå«­
		now_node = -1;
		double shortest  = INF+1;
		for(int i=0; i<node_n; i++)
		{
			if(!deci[i] && shortest>dist[i])
			{
				shortest = dist[i];
				now_node = i;
			}
		}
		
		// ·×ÄÏÝÈç[vð²¯é
		if(now_node == -1) { break; }
		// »ÝÌm[hðmèÏÝÉ
		deci[now_node] = true;
		
		// »ÝÌm[h©çÌ¼Ì_Ì£ðvZ
		// mèÏÝÅ éi©gÅ éðÜÞjÚ±ªINFÅ éêÍ³
		// em[hÌÅZ£ðvZÊ©³ÌlÌ¬³¢ûÉÝè
		// ÅZHÅ Á½ê¼ÌÅZ[gðXV·é
		for(int i=0; i<node_n; i++)
		{
			if(connect[now_node][i]!=INF && !deci[i])
			{
				double tmp = dist[now_node]+connect[now_node][i];
				if(dist[i]>tmp)
				{
					dist[i] = tmp;
					route[i] = now_node;	
				}
			}
		}
	}

	return;
}

int main()
{
	stringstream ss;
	
	// üÍ
	int n,m,tmp;
	while(1)
	{
		cin >> n;
		if(n==0) { break; }	// 0ÅI¹

		// üÍirÌXgAÚ®Xgj
		// rÔÌÎMAPàì¬
		vector<vector<int> > b_data(n,vector<int>(3));
		map<int,int> bn_list;
		for(int i=0; i<n; i++)
		{
			cin >> b_data[i][0] >> b_data[i][1] >> b_data[i][2];
			bn_list[b_data[i][0]] = i;
		}
		cin >> m;
		vector<vector<int> > m_data(m,vector<int>(2));
		for(int i=0; i<m; i++)
		{
			cin >> m_data[i][0] >> m_data[i][1];
		}
		
		// AóÔð\·zñÌì¬ (AsÂ=INFA©gÆÌ£=0)
		vector<vector<double> > c_data(n,vector<double>(n));
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				double dis = DIS(b_data[i][1]-b_data[j][1],b_data[i][2]-b_data[j][2]);
				if(dis <= 50)	{ c_data[i][j] = dis; }
				else		{ c_data[i][j] = INF; }
			}		
		}

		// Ú®f[^ÉvZ n_ðI_ðüêÖ¦
		// iHõÌÆ«­È¢Ù¤ÖÆ¾ÇêÎ
		// tÉÈéªüêÖ¦Ä¢é½ßûüÉÈé
		for(int i=0; i<m; i++)
		{
			Dijkstra(c_data,bn_list[m_data[i][1]]);
			
			int m_node = bn_list[m_data[i][0]];
			if(route[m_node] == INF)
			{
				ss << "NA" << endl;
			}
			else
			{
				for(; route[m_node]!=-1; m_node=route[m_node])
				{
					ss << b_data[m_node][0] << " ";
				}
				ss << b_data[m_node][0] << endl;
			}
		}
	}

	cout << ss.str();

	return 0;
}

Measured memory_bytes: 0
class Person(val size:Int){
    val history:Array<Boolean> = Array(size){false}
    val isCollectMap:Boolean
        get() = history.size == history.count{it}
}
fun main(args:Array<String>):Unit{
    while(true){
        val n = readLine()!!.toInt()
        if (n == 0) return
        val persons = Array(n){
            Person(n)
        }
        for (i in 0 until n) persons[i].history[i] = true
        val schedules = Array(n){
            Pair(it, readLine()!!.split(' ').drop(1).map(String::toInt))
        }
        dateloop@for (date in 1 .. 30){
            val s = schedules.filter{(_, schedule) -> schedule.contains(date)}.map{persons[it.first]}
            (0 until n).map{
                s.fold(false){b, p -> b || p.history[it]}
            }.withIndex().filter{it.value}.forEach {i -> s.forEach {p -> p.history[i.index] = true  } }
            if (s.any{it.isCollectMap}){
                println(date)
                break@dateloop
            }
        }
        if (persons.none{it.isCollectMap})
            println(-1)
    }
}


Measured memory_bytes: 87568
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int a,b,c;
    cin >> a >> b >> c;
    int d = b;
    
    b += c;
    b = min(b,a);
    P(c - (b-d));
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------

ll d = pow(10,9)+7;


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




int main(void)
{

	ll n;
	cin >> n;

	set<ll> a;

	rep(i, n)
	{
		ll b;
		cin >> b;
		auto r =a.insert(b);
		if (!r.second)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
 
int main()
{
    int n;
    std::cin>>n;
    std::vector<int> X(n),Y(n),Z(n);
    for(int i=0;i<n;i++){
        std::cin>>X[i]>>Y[i]>>Z[i];
    }
    for(int x=0;x<=100;x++){
        for(int y=0;y<=100;y++){
            //基準点
            bool res = true;
            int h = 0;
            auto itr = std::max_element(Z.begin(),Z.end());
            h = std::abs(X[itr - Z.begin()] - x) + std::abs(Y[itr - Z.begin()] - y) + Z[itr - Z.begin()];
            for(int i=0;i<n;i++){
                if(std::max(h - std::abs(X[i] - x) - std::abs(Y[i] - y),0) != Z[i])res = false;
            }
            if(res){
                std::cout<<x<<" "<<y<<" "<<h<<std::endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int n,m;
   scanf("%d %d", &n, &m);
   int a[n];
   int sum = 0;
   int count = 0;
   for(int i = 0; i < n; i++){
      scanf("%d", &a[i]);
      sum += a[i];
   }
   double x = sum/(4.0*m);

   for(int i = 0; i < n; i++){
      if(a[i] >= x){
         count++;
      }
   }
   if(count >= m){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
   return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
int f[200010];
int ans[200010];
int vis[200010];
int cnt=1;
vector<int>ve[200010];
map<int,int>ma[200010];
int val=0;
void dfs(int x)
{
    int sz=ve[x].size();
    for(int i=0;i<sz;i++){
        if(!vis[ve[x][i]]){
            vis[ve[x][i]]=1;
            val++;
            dfs(ve[x][i]);
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        ans[i]=0;
        f[i]=i;
    }
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        if(!ma[a][b]){
            ma[a][b]=1;
            ve[a].push_back(b);
            ve[b].push_back(a);
        }
    }
    int re=1;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            val=0;
            dfs(i);
            re=max(val,re);
        }
    }
    cout<<re;
    return 0;
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   string s;
   cin >> s;
   ll n = s.size();
   vector<ll>alp(26);
   lrep(i, 0, n)alp[s[i]-'a']++;
   ll ans = n*(n-1)/2;
   lrep(i, 0, 26){
       if(alp[i]<2)continue;
       ans -= alp[i]*(alp[i]-1)/2;
   }
   cout << ans+1 << endl;
}

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

const int N = 105;
int x, n, p[N];

int main() {
    cin >> x >> n;
    for(int i=0; i<n; i++) {
        int j; cin >> j;
        p[j] = 1;
    }
    int ans, D = N;
    for(int v=0; v<N; v++) {
        if(p[v])    continue;
        int diff = abs(x-v);
        if(diff < D) {
            ans = v;
            D = diff;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void solve(const string& s, int n)
{
    int m = s.size();
    if(m == n){
        cout << s << endl;
        return;
    }

    for(char c='a'; ; ++c){
        solve(s + c, n);
        if(s.find(c) == string::npos)
            break;
    }
}

int main()
{
    int n;
    cin >> n;
    solve("", n);

    return 0;
}


Measured memory_bytes: 1536
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e3+5;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	char ch;
	cin>>ch;
	if(ch>='a'&&ch<='z') cout<<"a"<<endl;
	else cout<<"A"<<endl;
	
	return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
a = map(int, raw_input().split()) + [1]
DP = [[1] + [0] * (N + 1), [0] * (N + 2)]
path = [[0] * (N + 2), [0] * (N + 2)]

for i in range(N + 1):
    for j in range(i + 1):
        if DP[0][i + 1] < DP[0][j] * a[i]:
            DP[0][i + 1] = DP[0][j] * a[i]
            path[0][i + 1] = (0, j)
        if DP[0][i + 1] < DP[1][j] * a[i]:
            DP[0][i + 1] = DP[1][j] * a[i]
            path[0][i + 1] = (1, j)
        if DP[1][i + 1] > DP[0][j] * a[i]:
            DP[1][i + 1] = DP[0][j] * a[i]
            path[1][i + 1] = (0, j)
        if DP[1][i + 1] > DP[1][j] * a[i]:
            DP[1][i + 1] = DP[1][j] * a[i]
            path[1][i + 1] = (1, j)
ans = []
nex = path[0][-1]
while nex[1] != 0:
    ans += [nex[1]]
    nex = path[nex[0]][nex[1]]

ans = ans[::-1]
if len(ans) == 0:
    print 0
else:
    print len(ans)
    for num in ans:
        print num


Measured memory_bytes: 5064
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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


ll N, P;

int main() {

	scanf("%lld%lld", &N, &P);

	map<ll, ll> primeN;

	for (ll i = 2; i * i <= P; ++i) {
		if (!(P % i)) {
			primeN[i]++;
			P /= i;
			i = 1;
		}
	}

	primeN[P]++;

	ll ans = 1;

	for (auto p : primeN) {
		if (p.second >= N) rep(i, (p.second / N)) ans *= p.first;
	}

	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define MP make_pair
#define X first
#define L second.first
#define R second.second
using namespace std;
int n,a[2][200005],pos[200005],mi[2][200005][20];
typedef pair<int,pair<int,int> > pip;
priority_queue<pip,vector<pip>,greater<pip> > pq;
inline int query(int k,int l,int r){
	int lg=31-__builtin_clz(r-l+1);
	return min(mi[k][l][lg],mi[k][r-(1<<lg)+1][lg]);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		pos[x]=i;
		a[i&1][i]=x;
		a[(i&1)^1][i]=INF;
	}
	//RMQ Init
	for(int k=0;k<2;k++){
		for(int i=0;i<n;i++){
			mi[k][i][0]=a[k][i];
		}
		for(int j=1;(1<<j)<=n;j++){
			for(int i=0;(i+(1<<j)-1)<n;i++){
				mi[k][i][j]=min(mi[k][i][j-1],mi[k][i+(1<<(j-1))][j-1]);
			}
		}
	}
	pq.push(MP(query(0,0,n-1),MP(0,n-1)));
	while(!pq.empty()){
		pip u=pq.top();
		pq.pop();
		int q1=u.X,q2=query((pos[u.X]&1)^1,pos[u.X]+1,u.R);
		cout<<q1<<' '<<q2<<' ';
		if(u.L<pos[q1])pq.push(MP(query(u.L&1,u.L,pos[q1]-1),MP(u.L,pos[q1]-1)));
		if(pos[q1]+1<pos[q2])pq.push(MP(query((pos[q1]+1)&1,pos[q1]+1,pos[q2]-1),MP(pos[q1]+1,pos[q2]-1)));
		if(pos[q2]<u.R)pq.push(MP(query((pos[q2]+1)&1,pos[q2]+1,u.R),MP(pos[q2]+1,u.R)));
	}
	return 0;
}

Measured memory_bytes: 35708
def solve():
  n=int(input())
  a=list(map(int,input().split()))
  s=input()
  base=[]
  for i in range(n-1,-1,-1):
    v=a[i]
    for x in base:
      v=min(v,v^x)
    if v:
      if s[i]=='0':
        base.append(v)
      else:
        return 1
  return 0

t=int(input())
for _ in range(t):
  print(solve())

Measured memory_bytes: 73696
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string n; cin >> n;
	rep(i, 0, 2)
	{
		if (n[i] == '1')n[i] = '9';
		else if (n[i] == '9') n[i] = '1';
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define PI 3.14159265358979323846264338327950L
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[2000006];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<2000006;i++)
	{
		if(sieve[i])
		{
			for(int j=i*i;j<2000006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}
int kadane(int* a,int n)
{
	int loc=a[0],glo=a[0];
	for(int i=1;i<n;i++)
	{
		loc=max(a[i],loc+a[i]);
		glo=max(glo,loc);
	}
	return glo;
}
int prefix[101],dp[401][401];
int help(vector<int>& a,int i,int j)
{
	int s=0;
	for(int k=i;k<=j;k++)
		s+=a[k];
	return s;
}
int solve(vector<int>& a,int i,int j)
{
	if(i==j) return 0;

	int ans=inf;
	if(dp[i][j]!=-1) return dp[i][j];
	for(int k=i;k<j;k++)
	{
		int left=solve(a,i,k);
		int right=solve(a,k+1,j);
		ans=min(ans,left+right+(i==0?prefix[j]:prefix[j]-prefix[i-1]));
	}
	return dp[i][j]=ans;
}


int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	
	
	memset(dp,-1,sizeof dp);
	int n;
	cin>>n;
	vector<int>a(n);
	int s=0;
	for(int i=0;i<n;i++){ cin>>a[i];
	}
	

	prefix[0]=a[0];

	for(int i=1;i<n;i++) prefix[i]=prefix[i-1]+a[i];
	
	cout<<solve(a,0,a.size()-1);
	
}



Measured memory_bytes: 4900
n,y = map(int,input().split())
ans_a = -1
ans_b = -1
ans_c = -1

for i in range(n+1):
  for j in range(n+1-i):
    k = n- i- j
    if y == 10000 * i + 5000 * j + 1000 * k :
      ans_a = i
      ans_b = j
      ans_c = k
print(ans_a,ans_b,ans_c)

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;


ll arr[100] = {};

int main() {

	arr[0] = 2;
	arr[1] = 1;

	int n;
	cin >> n;

	for (int i = 2; i <= n; i++) {
		arr[i] = arr[i - 1] + arr[i - 2];
	}

	cout << arr[n] << endl;

	return 0;
}

Measured memory_bytes: 256
/*  I won't be silenced                       */
/*  You can't keep me quiet                   */
/*  Won't tremble when you try it             */
/*  All I know is I won't go speechless       */
/*  'Cause I'll breathe                       */
/*  When they try to suffocate me             */
/*  Don't you underestimate me                */
/*  'Cause I know that I won't go speechless  */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
{

string s,p;
cin>>s>>p;

ll ans=0;
for(ll i=0;i<s.size();i++)
{
  if(s[i]!=p[i])
    ans++;
}

cout<<ans<<endl;
}
return 0;
}













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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    // int N;
    // cin >> N;
    // vector<int> a(N);
    // REP(i, N){
    //     cin >> a[i];
    // }
    ll H, W;
    cin >> H >> W;
    ll ans = 0;

    ans = H * W;
    if(ans % 2 == 1){
        ans = (ans + 1) / 2;
    }else{
        ans = ans / 2;
    }

    if(H == 1 || W == 1)ans = 1;

    cout << ans << endl;





}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main(){
    int N,X;
    scanf("%d %d",&N,&X);
    int L[N];
    for(int i=0;i<N;i++) scanf("%d",&L[i]);
    int D=0;
    int i=1;
    int cnt = 0;
    while(D <= X && i <= N+1){
        cnt++;
        D = D + L[i-1];
        i++;
    }
    printf("%d\n",cnt);
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 100000;
int n;
int dp[MAX_N];
int a[MAX_N];
int res;

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

  rep(i, n) dp[i] = INF;
  rep(i, n) *lower_bound(dp, dp+n, a[i]) = a[i];

  res = lower_bound(dp, dp+n, INF) - dp;
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1940
def make_divisors(n):
    div=[n]
    for i in range(2,-int(-n**0.5//1)):
        if n%i==0:
            div.append(i)
            div.append(n//i)
    if n%(n**0.5)==0:
        div.append(int(n**0.5))
    div.sort()
    return div

n=int(input())
if n>2:
    ans=make_divisors(n-1)
else:
    ans=[]
for i in make_divisors(n):
    a=n
    while a%i==0:
        a=a//i
    if a%i==1:
        ans.append(i)
print(len(ans))

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

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

using namespace std;

int main(){
	int n,m; cin>>n>>m;
	vector<long long> x(n),y(n),z(n);
	rep(i,n) cin>>x[i]>>y[i]>>z[i];

	long long ans=0;
	rep(_,2){
		rep(__,2){
			rep(___,2){
				vector<long long> a(n);
				rep(i,n) a[i]=x[i]+y[i]+z[i];
				sort(a.begin(),a.end());
				ans=max(ans,accumulate(a.begin()+n-m,a.end(),0LL));
				rep(i,n) z[i]*=-1;
			}
			rep(i,n) y[i]*=-1;
		}
		rep(i,n) x[i]*=-1;
	}
	cout<<ans<<endl;

	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;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

	n %= 10;
	if(n == 3){
		cout << "bon" << endl;
	}else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}

}


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

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

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  int l = S.length();
  REP(i, l - 1) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, m, k, mn = 1e9, c[12], ip[12][12] = {}, ar[12] = {}, to = 0;
void bf(int i)
{
	if (i < n)
	{
		for (int j = 0; j < m; j++) 
		{
			ar[j] += ip[i][j];
		}
		to += c[i];
		bf(i + 1);
		for (int j = 0; j < m; j++) 
		{
			ar[j] -= ip[i][j];
		}
		to -= c[i];
		bf(i + 1);
	}
	else
	{
		int v = 1;
		for (int j = 0; j < m; j++)
		{
			v &= (ar[j] >= k);
		}
		if (v) mn = min(mn, to);
	}
}
int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
		{
			cin >> ip[i][j];
		}
	}
	bf(0);
	if (mn == 1000000000) {cout << "-1\n";}
	else {cout << mn << "\n";}
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N,M,H[100000],A,B,ans=0;
	bool flag;
	vector<int> vec[100000];
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	for(int i=0;i<M;i++){
		cin>>A>>B;A--;B--;
		vec[A].push_back(B);
		vec[B].push_back(A);
	}
	for(int i=0;i<N;i++){
		flag=true;
		for(int j=0;j<vec[i].size();j++){
			if(H[i]<=H[vec[i][j]])flag=false;
		}
		if(flag)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9132