akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  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の根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int n;
  int res = 0;
  cin >> n;
  int m = BIG_NUM;
  rep(i,0,n){
    int a;
    cin >> a;
    if(a < m){
     m = a;
     res++;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){

    int n;
    cin >> n;

    vector<bitset<64>> mask(n);
    for(int i = 0; i < n; i++){
        int k, b;
        cin >> k;
        while(k-- > 0){
            cin >> b;
            mask[i].set(b);
        }
    }

    bitset<64> bs;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int op, m;
        cin >> op >> m;
        if(op == 0) cout << bs[m] << endl;
        if(op == 1) bs |= mask[m];
        if(op == 2) bs &= ~mask[m];
        if(op == 3) bs ^= mask[m];
        if(op == 4) cout << ((bs&mask[m]) == mask[m]) << endl;
        if(op == 5) cout << (bs&mask[m]).any() << endl;
        if(op == 6) cout << (bs&mask[m]).none() << endl;
        if(op == 7) cout << (bs&mask[m]).count() << endl;
        if(op == 8) cout << (bs&mask[m]).to_ullong() << endl;        
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
char s[1010];
int a,b,c,d;
int main() {
	//freopen("2.txt","r",stdin);
	scanf("%s",s);
	for (int i=0;i<strlen(s);i++)
		if (s[i]=='N') a++;
		else if (s[i]=='S') b++;
		else if (s[i]=='E') c++;
		else d++;
	if (!a&&b) printf("No\n");
	else if (!b&&a) printf("No\n");
	else if (!c&&d) printf("No\n");
	else if (!d&&c) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
priority_queue<pll>pq;
const int N = 1e5;
multiset<ll>st;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >>m;
	for(int i=1;i<=n;i++){
		ll a;
		cin >> a;
		st.insert(a);
	}
	for(int i=1;i<=m;i++){
		ll b,c;
		cin >> b >> c;
		pq.push(mp(c,b));
	}
	ll sum = 0;
	while(!pq.empty())
	{
		pll u = pq.top();
		pq.pop();
		auto it = st.lower_bound(u.first+1);
		while(it!=st.end())
		{
			ll temp = *it;
			sum += temp;
			it++;
			st.erase(st.lower_bound(temp));
		}
		it = st.begin();
		ll cnt = 0;
		while(it!=st.end()&&cnt<u.second)
		{
			sum += u.first;
			ll temp = *it;
			it++;
			cnt++;
			st.erase(st.lower_bound(temp));
		}
	}
	for(auto it:st)
	{
		sum += it;
	}
	cout << sum << "\n";
}


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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int v = ty - sy;
	int w = tx - sx;
	for (int i = 0; i < v; i++)
		cout << 'U';
	for (int i = 0; i < w; i++)
		cout << 'R';
	for (int i = 0; i < v; i++)
		cout << 'D';
	for (int i = 0; i < w; i++)
		cout << 'L';
	cout << 'L';
	for (int i = 0; i < v + 1; i++)
		cout << 'U';
	for (int i = 0; i < w + 1; i++)
		cout << 'R';
	cout << 'D';
	cout << 'R';
	for (int i = 0; i < v + 1; i++)
		cout << 'D';
	for (int i = 0; i < w + 1; i++)
		cout << 'L';
	cout << 'U' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    string s;
    cin >> s;
    for(int i=1;i<s.size();i++){
        if(((s.size()-i)%2)==0){
            if(s.substr(0,(s.size()-i)/2)==s.substr((s.size()-i)/2,(s.size()-i)/2)){
                int k =s.size()-i;
                cout << k <<endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
def main():
  s = input()[::-1]
  multiplier = 1
  divisor = 10 ** 9 + 7
  list10 = list(range(10))
  list13 = list(range(13))
  p = [0] * 13
  np = [0] * 13
  rt = [i % 13 for i in range(121)]
  p[0] = 1
  for i in range(len(s)):
    if s[i] != '?':
      r = rt[int(s[i]) * multiplier]
      for j in list13:
        np[rt[j + r]] = p[j]
    else:
      r = 0
      for j in list10:
        for k in list13:
          np[rt[k + r]] += p[k]
        r = rt[r + multiplier]
    for j in list13:
      p[j] = np[j] % divisor
      np[j] = 0
    multiplier = rt[10 * multiplier]
  print(p[5])
main()


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

int main(){
  int n, m;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    if(n % 2 == 0 || m % 2 == 0){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> fact;
  for (int i = 1; i <= N; i++){
    if (N % i == 0){
      fact.push_back(i);
    }
  }
  int fact_cnt = fact.size();
  vector<vector<vector<int>>> cnt(fact_cnt);
  for (int i = 0; i < fact_cnt; i++){
    cnt[i] = vector<vector<int>>(fact[i], vector<int>(26, 0));
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < fact_cnt; j++){
      cnt[j][i % fact[j]][S[i] - 'a']++;
    }
  }
  vector<vector<int>> type_cnt(fact_cnt);
  for (int i = 0; i < fact_cnt; i++){
    type_cnt[i] = vector<int>(fact[i], 0);
    for (int j = 0; j < fact[i]; j++){
      for (int k = 0; k < 26; k++){
        if (cnt[i][j][k] > 0){
          type_cnt[i][j]++;
        }
      }
    }
  }
  vector<int> ng_cnt(fact_cnt, 0);
  for (int i = 0; i < fact_cnt; i++){
    for (int j = 0; j < fact[i]; j++){
      if (type_cnt[i][j] > 1){
        ng_cnt[i]++;
      }
    }
  }
  for (int i = 0; i < Q; i++){
    int p;
    char c;
    cin >> p >> c;
    p--;
    int ans = N;
    for (int j = 0; j < fact_cnt; j++){
      cnt[j][p % fact[j]][S[p] - 'a']--;
      if (cnt[j][p % fact[j]][S[p] - 'a'] == 0){
        type_cnt[j][p % fact[j]]--;
        if (type_cnt[j][p % fact[j]] == 1){
          ng_cnt[j]--;
        }
      }
      cnt[j][p % fact[j]][c - 'a']++;
      if (cnt[j][p % fact[j]][c - 'a'] == 1){
        type_cnt[j][p % fact[j]]++;
        if (type_cnt[j][p % fact[j]] == 2){
          ng_cnt[j]++;
        }
      }
      if (ng_cnt[j] == 0){
        ans = min(ans, fact[j]);
      }
    }
    cout << ans << endl;
    S[p] = c;
  }
}


Measured memory_bytes: 50052
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut graph: Vec<Vec<(usize, i64)>> = vec![vec![]; n];
    for _ in 0..n-1 {
        let (f, t, c): (usize, usize, i64) = read();
        graph[f-1].push((t-1, c));
        graph[t-1].push((f-1, c));
    }

    let (q, k): (usize, usize) = read();
    let mut distances: Vec<i64> = vec![0; n];


    dfs(k-1, n, 0, &graph, &mut distances);

    for _ in 0..q {
        let (from, to): (usize, usize) = read();
        println!("{}", distances[from-1] + distances[to-1]);
    }
}

fn dfs(from: usize, par: usize, cost: i64, graph: &Vec<Vec<(usize, i64)>>, dist: &mut Vec<i64>) {
    dist[from] = cost;
    for &(to, length) in &graph[from] {
        if to == par {
            continue
        }
        dfs(to, from, cost + length, graph, dist);
    }
}

Measured memory_bytes: 22396
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):

            edge_list = sorted([L[i], L[j], L[k]])
            if edge_list[0] != edge_list[1] != edge_list[2] and edge_list[2] < edge_list[0] + edge_list[1]:

                ans += 1


print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
long long dp[100005][4];
int main()
{
    int n;
    cin>>n;
    int i;
    long long a[n+1],b[n+1],c[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for(i=2;i<=n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
        //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

}



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


int main()
{
	vector<int> val(3);
	rep(i,3) cin>>val[i];
	sort(val.begin(),val.end(),greater<int>());
	int ab=val[0]-val[1];
	int bc=val[0]-val[2];
	if((ab+bc)%2==0)
	{
		cout<<(ab+bc)/2<<endl;
	}
	else
	{
		cout<<1+(ab+bc+1)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  cout<<max(0ll,(b*(n-1)+a)-(a*(n-1)+b)+1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>

using myTuple = std::tuple<int, int, int>;
using myPair = std::pair<int, std::string>;

int main()
{
	int N, M;
	std::cin >> N >> M;

	std::vector<myTuple> v;
	for ( int i = 0; i < M; i++ )
	{
		int tmpP, tmpY;
		std::cin >> tmpP >> tmpY;
		v.emplace_back( std::make_tuple( tmpP, tmpY, i ) ); // 後で元の順番に戻すためにインデックスも入れる
	}

	// 誕生した年代順にソート
	std::sort( v.begin(), v.end(), []( myTuple a, myTuple b ) {
			return ( std::get<1>( a ) < std::get<1>( b ) );
		} );

	// 市のID順にソート（安定）
	std::stable_sort( v.begin(), v.end(), []( myTuple a, myTuple b ) {
			return ( std::get<0>( a ) < std::get<0>( b ) );
		} );

	int pCounter = 1;
	std::vector<myPair> vv;

	for ( int i = 0; i < v.size(); i++ )
	{
		char tmpbuf[128] = { 0 };
		sprintf( tmpbuf, "%06d%06d", std::get<0>( v[i] ), pCounter++ );
		vv.emplace_back( std::make_pair( std::get<2>( v[i] ), tmpbuf ) );
		if ( i < v.size() - 1 )
		{
			if ( std::get<0>( v[i] ) != std::get<0>( v[i + 1] ) )
			{
				pCounter = 1;
			}
		}
	}

	// 元の順番に戻して出力
	std::sort( vv.begin(), vv.end(), []( myPair a, myPair b ) {
			return ( a.first < b.first );
		} );

	for ( auto &&it : vv )
	{
		std::cout << it.second << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 9444
import sys
from math import *

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


n = Num()
ans = 0
for i in range(1, n + 1):
    ans += n // i


def div(n):
    count = 0
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            if n // i == i:
                count += 1
            else:
                count += 2
    return count


print(ans - div(n))


Measured memory_bytes: 9196
#include<stdio.h>
#include<string.h>

int main(){
	char s[6];
	scanf("%s",s);
	int count=0;
	for(int i=0;i<6;i++){
		if(s[2]==s[3] && s[4]==s[5]){
			count++;
		}
	}
	if(count!=0){
		puts("Yes");
	}
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
count = 0

for i in range(1, n+1):
    if i*2 % k == 0:
        count += 1
        x = (n-i) // k
        count += x*6
        if x >= 2:
            count += 6 * (x*(x-1)//2)

print(count)

Measured memory_bytes: 40300
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
	int N ;
	vector<int> c(3); cin >> c[0] >>c[1] >> c[2] >> N;
	int count = 0;
	sort(c.begin(),c.end());
	if(c[0] != 1){
	rep(i,N /c[0]+1){
		rep(j,N/c[1]+1){
			rep(k,N/c[2]+1){
				
				if(i*c[0]+j*c[1]+k*c[2] == N) count++;
			}
		}
	}
	}
	else{
		rep(j,N/c[1]+1){
			rep(k,N/c[2]+1){		
				if(j*c[1]+k*c[2] <= N) count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string R;
    std::cin >> R;
    
    bool firstA = false;
    bool findC = false;
    bool singleC = false;
    bool otherLower = true;
    
    if (R.front() == 'A') {
        firstA = true;
    }
        
    for (size_t i = 2; i < R.size()-1; i++) {
        if (R[i]=='C') {
            if (!findC) {
                findC = true;
                singleC = true;
            } else {
                singleC = false;
            }
        } else {
            if (R[i] < 'a')
                otherLower = false;
        }
    }
    if (R[1] < 'a' || R.back() < 'a')
        otherLower = false;
    
    if (firstA && findC && singleC && otherLower)
        std::cout << "AC" << std::endl;
    else
        std::cout << "WA" << std::endl;
}

Measured memory_bytes: 256
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
K=read()
mod=7%K
index=1
dic=defaultdict(int)
while(True):
    if mod==0:
        print(index)
        exit()
    if dic[mod]==1:
        print(-1)
        exit()
    dic[mod]=1
    mod=mod*10+7
    mod%=K
    index+=1
    

Measured memory_bytes: 159152
N,L = map(int,input().split())
c = 0
if L >= 0:
    skip = 0
else:
    if N - (-L) > 0:
        skip = L*-1
    else:
        skip = N-1
for i in range(N):
    if i == skip:
        continue
    c += L+i
print(c)

Measured memory_bytes: 61812
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,t;
int main()
{
	scanf("%d",&m);
	while(m)
	{
		if(m%10==2)
		{
			t++;
		}
		m=m/10;
	}
	printf("%d",t);
	return 0;
}

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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using ull = unsigned long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

const int MX = 2010;

int main(){
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    sort(s.begin(), s.end());
//    vector<vector<vector<bool>>> d(3, vector<vector<bool>>(3, vector<bool>(MX, true)));
    bool d[3][3][MX];
    rep(i, 3)rep(j, 3)rep(k, MX) d[i][j][k] = true;
    int ans = MX * 3;
    do{
        rep(i, 3) for(int j = i + 1; j < 3; j++) rep(k, s[i].size()){
            string pre = s[i], post = s[j];
            bool ok = true;
            for (int ni = k; ni < pre.size(); ni++){
                int nj = ni - k;
                if (nj >= post.size()) break;
                if (pre[ni] == '?' or post[nj] == '?') continue;
                if (pre[ni] != post[nj]) ok = false;
            }
            d[i][j][k] = ok;
        }
        auto f = [&](int i, int j, int k) {
            if (k >= s[i].size()) return true;
            return d[i][j][k];
        };
//        rep(x, s[0].size() + 1)rep(y, max(s[1].size() + 1, s[0].size() - x + 1)){
        int mx = max(s[1].size() + 1, s[0].size());
        rep(x, s[0].size() + 1)rep(y, mx){
            if (!f(0, 1, x)) continue;
            if (!f(1, 2, y)) continue;
            if (!f(0, 2, x + y)) continue;
            int now = 0;
            now = max<int>(now, s[0].size());
            now = max<int>(now, x + s[1].size());
            now = max<int>(now, x + y + s[2].size());
            ans = min(ans, now);
        }
    }while(next_permutation(s.begin(), s.end()));
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = 0;
		int W = 0;
		String sh = "#";
		while(true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W ==0)break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print(sh);
				}
				System.out.println("");
			}
			System.out.println("");
		}
		sc.close();
	}
}


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

import numpy as np
import scipy

N = int(input())
#C = [[0 for i in range(3)] for j in range(3)]
#for i in range(3):
#    C[i] = list(map(int, input().split()))
#print(C)
A = list(map(int, input().split()))

split = 0
order = ""
for i in range(len(A)-1):
    if order == "up" and A[i] > A[i+1]:
        split += 1
        order = ""
    elif order == "down" and A[i] < A[i+1]:
        split += 1
        order = ""
    elif order == "":
        if A[i] < A[i+1]:
            order = "up"
        elif A[i] > A[i+1]:
            order = "down"

print(split+1)


Measured memory_bytes: 23460
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

void main() {
    int N, M;
    int[] A;
    
    bool input() {
        scanf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) return false;
        A = readln.chomp.split(" ").map!(to!int).array;
        return true;
    }

    void solve() {
        int[] I = [0];
        int X = M / A[0] * A[0];
        for (int i = 1; i < N; i++) {
            int Y = M / A[i] * A[i];
            if (Y > X) continue;
            if (Y == X) {
                int p = A[ I[0] ], q = A[i];
                if (p == q) {
                    I ~= i;
                } else if (p > q) {
                    I = [i];
                }
            } else {
                X = Y;
                I = [i];
            }
        }
        if (I.length == 1) {
            writeln(I[0] + 1);
        } else {
            writeln(N);
        }
    }

    while (input) solve;
}

Measured memory_bytes: 1264
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    
   int a, b;
   double c;
   cin >> a >> b;
   cout << a / b << " " << a % b << " ";
   
   c = ((double)a) / ((double)b);
   
   printf("%f\n",c);
}


Measured memory_bytes: 3208
#include <iostream>

unsigned long gcd(int a, int b);

int main(int argc, char** argv) {
	unsigned long a, b, g, l;
	double t;
	while(std::cin >> a >> b) {
		g = gcd(a, b);
    	t = (double)a / g;
	    l = (int)(b * t);
	    std::cout << gcd(a, b) << " " << l << std::endl;
	}
}

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


Measured memory_bytes: 3096
N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W+1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])

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

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

using namespace std;

const int INF=1<<29;

struct Magic{ int cost,dmg; };

int main(){
	for(int n,m;scanf("%d",&n),n;){
		int hp[100],hp_max=-1;
		rep(i,n) scanf("%d",hp+i), hp_max=max(hp_max,hp[i]);

		scanf("%d",&m);
		int ms=0,ma=0; // s:single, a:all
		Magic magic_s[100],magic_a[100];
		rep(i,m){
			int cost,dmg;
			char s[7];
			scanf("%*s%d%s%d",&cost,s,&dmg), dmg=min(dmg,hp_max);
			if(dmg>0){
				if(s[0]=='S') magic_s[ms++]=(Magic){cost,dmg};
				else          magic_a[ma++]=(Magic){cost,dmg};
			}
		}

		static int dp_a[200001];
		rep(j,2*hp_max+1) dp_a[j]=(j==0?0:INF);
		rep(i,ma){
			int cost=magic_a[i].cost,dmg=magic_a[i].dmg;
			rep(j,2*hp_max-dmg+1) dp_a[j+dmg]=min(dp_a[j+dmg],dp_a[j]+cost);
		}

		static int dp_s[200001];
		rep(j,2*hp_max+1) dp_s[j]=(j==0?0:INF);
		rep(i,ms){
			int cost=magic_s[i].cost,dmg=magic_s[i].dmg;
			rep(j,2*hp_max-dmg+1) dp_s[j+dmg]=min(dp_s[j+dmg],dp_s[j]+cost);
		}
		for(int j=2*hp_max;j>0;j--) dp_s[j-1]=min(dp_s[j-1],dp_s[j]);

		int ans=INF;
		if(ms==0) ans=*min_element(dp_a+hp_max,dp_a+2*hp_max+1);
		else{
			rep(j,2*hp_max+1){
				int cost=dp_a[j];
				rep(i,n) cost+=dp_s[max(hp[i]-j,0)];
				ans=min(ans,cost);
			}
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 2332
#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--)
int N;
int c[100001];
int sw[100001];
bool check(){
     for(int i=1;i<N-1;i++){
         int temp=c[i];
         if(sw[i]==1)temp=1-temp;
         if(temp==0){
            sw[i+1]=sw[i-1];
         }else{
            sw[i+1]=1-sw[i-1];
         }
     }
     /*
     REP(i,N){
         cout<<sw[i];
     }
     cout<<endl<<endl;
     */
     //0とN-1を試す
     {
     int temp=c[0];
     if(sw[0]==1)temp=1-temp;
     if(temp==0){
        if(sw[N-1]!=sw[1])return false;
     }else{
        if(sw[N-1]==sw[1])return false;
     }
     }
     
     {
     int temp=c[N-1];
     if(sw[N-1]==1)temp=1-temp;
     if(temp==0){
        if(sw[N-2]!=sw[0])return false;
     }else{
        if(sw[N-2]==sw[0])return false;
     }
     }
     return true;
}

int main(){
	cin>>N;
        string s;
	cin>>s;
	REP(i,N){
	    if(s[i]=='o'){
	       c[i]=0;
	    }else{
	       c[i]=1;
	    }
	}
	//cout<<"aaa"<<endl;return 0;
	sw[0]=0;
	sw[1]=0;
	if(check()){
	   REP(i,N){
	       if(sw[i]==0){
	          cout<<"S";
	       }else{
	          cout<<"W";
	       }
	   }
	   cout<<endl;
	   return 0;
	}
	sw[0]=0;
	sw[1]=1;
	if(check()){
	   REP(i,N){
	       if(sw[i]==0){
	          cout<<"S";
	       }else{
	          cout<<"W";
	       }
	   }
	   cout<<endl;
	   return 0;
	}
	sw[0]=1;
	sw[1]=0;
	if(check()){
	   REP(i,N){
	       if(sw[i]==0){
	          cout<<"S";
	       }else{
	          cout<<"W";
	       }
	   }
	   cout<<endl;
	   return 0;
	}
	sw[0]=1;
	sw[1]=1;
	if(check()){
	   REP(i,N){
	       if(sw[i]==0){
	          cout<<"S";
	       }else{
	          cout<<"W";
	       }
	   }
	   cout<<endl;
	   return 0;
	}
	
        cout<<-1<<endl;
	return(0);
}

Measured memory_bytes: 1408
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
 
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x) % M;
        n=n/2;
    }
    return result % M;
}
 
class dsu{
    vi p,rank;
    vi set_count;
  
  public:
    dsu(int n){
        p.assign(n,0); 
        rank.assign(n,0);
        set_count.assign(n,1);
        for(int i=0;i<n;i++) p[i] = i;
    }
    int findSet(int x){
        return (p[x] == x) ? x:(p[x] = findSet(p[x]));
    }
    bool isSame(int i, int j){
        return (findSet(i) == findSet(j));
    }
    void unionSet(int i, int j){
        if(!isSame(i,j)){
            int x = findSet(i), y = findSet(j);
            if(rank[x] > rank[y]) {p[y] = x; set_count[x]+=set_count[y];}
            else{
                p[x] = y;
                set_count[y]+=set_count[x];
                if(rank[x] == rank[y]) rank[y]++;
            }
        }
    }
    int count(int x){
        return set_count[findSet(x)];
    }
};

// code copied from god_arham
int mod_inv(int a,int m){
    a=a%m;
    return power(a,m-2)%M;
}
int fact[200005];
void count_fact(){
    int i,x=1;
    fact[0]=1;
    for(int i=1;i<200002;i++){
        
        x=(x*i)%M;
      //  cout<<x<<" ";
        fact[i]=x;
        
    }
}
 
int ncr(int n,int r){
    if(n < r) return 0;
    int a=fact[n],b=fact[r],c=fact[n-r];
    
    return (a*mod_inv(b*c,M))%M;
} 
//copied code ends here
 
signed main()
{
    tezz
 
    count_fact();

    int n, k;
    cin>>n>>k;

    vi v(n);
    for(int &x:v) cin>>x;
        sort(all(v));

    int ans = 0;
    for(int i=0;i<n;i++){
        ans = (ans + ((ncr(i, k-1) * v[i]) % M - (ncr(n - i - 1, k-1) * v[i]) % M + M) % M) % M;
    }
    cout<<ans;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int i,j,k,X,Y,p[101],N,n,m,temp;

int main()
{
  cin>>X>>N;
  
  n=200;
  
  for(i=0;i<N;i++)
  {
    cin>>p[i];
  }
  
  for(Y=-100;Y<102;Y++)
  {
    temp=0;
    for(i=0;i<N;i++)
    {
      if(p[i]==Y)
      {
        temp=1;
        break;        
      }
    }
    if(temp==1) continue;
    
    if(abs(Y-X)<n)
    {
      n=abs(Y-X);
      m=Y;
    }
  }
  
  cout<<m;
  
  
}

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

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

   if(N % 2 == 1) {
      cout << "No" << endl;
      return 0;
   }

   string a = S.substr(0, N/2);
   string b = S.substr(N/2, N/2);
   if(a == b) {
      cout << "Yes" << endl;
      return 0;
   }
   else {
      cout << "No" << endl;
   }
}

Measured memory_bytes: 3564
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    println(problem097a(a, b, c, d))
}

fun problem097a(a: Int, b: Int, c: Int, d: Int): String {
    return if((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) "Yes" else "No"
}

Measured memory_bytes: 29472
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		List<Integer> array = new ArrayList<Integer>();
		
		for(int i = 0; i < num; i ++ ){
			array.add(scanner.nextInt());
		}
		
		

        System.out.println( count(array, 0, num) );
        
        scanner.close();
	}

	public static long merge(List<Integer> array, int left, int middle, int right) { 
		long count = 0;
		int sub_left,sub_right;
		int max = 1000000000;
		int i,j,k;
		
		//ソート処理
		sub_left = middle - left;
		sub_right = right - middle;
		List<Integer> array_left = new ArrayList<Integer>(sub_left + 1);
		List<Integer> array_right = new ArrayList<Integer>(sub_right + 1);
		
		for(i = 0;i < sub_left;i ++){
			array_left.add( array.get(left + i) );
		}
		
		for(i = 0;i < sub_right;i ++){
			array_right.add( array.get(middle + i) );
		}
		
		array_left.add(max);
		array_right.add( max);
		
		i = 0; j = 0;
		for(k = left;k < right;k ++){
			if(array_left.get(i) < array_right.get(j)) {
				//i ++;
				array.set(k, array_left.get(i ++));
			}else{
				//j ++;
				array.set(k, array_right.get(j ++));
				count += (sub_left - i);
			}
		}
		return count;
	}

	public static long count(List<Integer> array, int left, int right) { 
		int middle;
		if(left + 1 >= right){
			if(left < right)return 0;
			return 1;
		}else{
			middle = (left + right) / 2;
			return (count(array, left, middle) + count(array, middle, right) +
					merge(array, left, middle, right));
		}
	}
}



Measured memory_bytes: 108844
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xs = readints;
    int a = xs[0], b = xs[1], t = xs[2];

    int ans = t / a * b;
    writeln(ans);
}


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

int n;
int x[10];
int y[10];
double res = 0;

int fact(int n){
  if(n == 1){
    return 1;
  }
  return n * fact(n - 1);
}

double dist(int pos, int ppos){
  int distx = abs(x[pos] - x[ppos]);
  int disty = abs(y[pos] - y[ppos]);
  distx = pow(distx, 2);
  disty = pow(disty, 2);
  return sqrt(distx + disty);
}

int main(){
  cin >> n;
  rep(i, n){
    cin >> x[i] >> y[i];
  }
  int seq[n];
  rep(i, n) seq[i] = i;
  
  int nn = fact(n);
  do{
    double sum = 0;
    rep(i, n - 1){
      int ppos = seq[i];
      int pos = seq[i+1];
      sum += dist(pos, ppos);
    }
    sum /= nn;
    res += sum;
  }while(next_permutation(seq, seq+n));
  
  cout << setprecision(10);
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
ll a[2003],b[2003];
ll dp[2003][2003];
int main()
{
 int n,m;
 cin>>n>>m;
 for(int i=1;i<=n;i++)
    cin>>a[i];
 for(int j=1;j<=m;j++)
    cin>>b[j];
 for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
 { dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%mod;
   if(a[i]==b[j])dp[i][j]=(dp[i][j]+dp[i-1][j-1]+1)%mod;}
   cout<<(dp[n][m]+1+mod)%mod;
}



Measured memory_bytes: 31616
N, A, B = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
d = Array.new(N, 0)
(N-1).times do |i|
  d[i+1] = d[i] + [A * (a[i+1] - a[i]), B].min
end
puts d.last

Measured memory_bytes: 22628
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N, M = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(M)]

    A = sorted(A, key=lambda x: x[1])

    INF = 10**10
    cur = -INF
    cnt = 0

    for i in range(M):
        if A[i][0] < cur:
            continue
        else:
            cur = A[i][1]
            cnt += 1
    print(cnt)


resolve()

Measured memory_bytes: 92176
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
typedef long long ll;

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, start, n) for (int i = (int)(start); i < (int)(n); i++)
#define sz(x) int(x.size())

string alphabets = "abcdefghijklmnopqrstuvwxyz";

int main(int argc, char const *argv[])
{
    string s,t;
    cin >> s >> t;
    int n,m;
    n = sz(s), m = sz(t);
    vector<vector<int>> char_map(26);
    rep(i, n){
        char_map[s[i] - 'a'].push_back(i);
    }
    rep(i,n){
        char_map[s[i] - 'a'].push_back(i+n);
    }

    ll ans = 0;
    int p = 0;

    rep(i, m){
        int c = t[i] - 'a';
        if( char_map[c].size() == 0){
            cout << "-1" << endl;
            return 0;
        }
        p = *lower_bound(char_map[c].begin(), char_map[c].end(), p)+1;
        if( p >= n){
            p -= n;
            ans += n;
        }
    }

    ans += p;
    cout << ans << endl;
    return 0;
}

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

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

    cout << !n << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

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

int main() {
    int N, n, d;
    cin >> N;
    n = N;
    d = 0;
    while (n) {
        d += n % 10;
        n /= 10;
    }
    if (N % d == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for (ll i=a;i<n;i++)
#define loopm(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define Graph(n) vector < vector < ll > > (n,vector < ll >(0,0))
#define tr(container,it)\
for(auto it=container.begin();it!=container.end();it++)
#define SZ(x) ((int)(x).size())
typedef vector<long long> VI;
typedef long long ll;
typedef vector < vector < ll > > VII;
typedef pair<ll,ll> PII;
typedef double db;
const ll m=2019;
ll binpow(ll a ,ll b)
{
    //b=b%(m-1);//remove if m is not a prime
    a=a%m;
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll ans=0;
    vector < ll > v(2019,0);
    string s="";
    cin>>s;
    ll curr=0;
    v[0]++;
    ll n=s.size();
    loopm(i,0,s.size())
    {
        ll thistime=binpow(10,n-i-1)*(s[i]-'0')+curr;
     //   cout<<binpow(10,n-i-1)<<" "<<s[i]-'0'<<"\n";
        thistime%=m;
      //  cout<<thistime<<"\n";
        v[thistime]+=1;
        curr=thistime;
    }
    loop(i,0,2019)
    {
        //cout<<v[i]<<" ";
        ans+=(v[i]*(v[i]-1))/2;
    }
    cout<<ans<<"\n";
}


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

int main(){
  string s;
  cin>>s;
  if(s.size()==2){
    cout<<s;
  }else{
    for(int i=s.size()-1;i>=0;i--){
      cout<<s[i];
    }
  }
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < sz(s); ++ i)
	{
		cnt += (s[i] != t[i]);
	}
	cout << cnt << '\n';
	
	return 0;
}






Measured memory_bytes: 3808
import queue

k = int(input())

queue = queue.Queue()
for i in range(1,10):
    queue.put(i)

for i in range(k):
    x = queue.get()
    if x % 10 != 0:
        l = queue.put(10*x + (x%10) -1)
    l = queue.put(10*x + (x%10))
    if x % 10 != 9:
        l = queue.put(10*x + (x%10) +1)
print(x)


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

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

    if ( (a + b) * 10 / 2 % 10 >= 5)
    {
        cout << (a + b) / 2 + 1 << endl;
    } else
    {
        cout << (a + b) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,K;
  int max = 0;
  cin >> A >> B >> C >> K;
  
  for (int i = 0; i < K; K--) {
    if (A >= K) {
      max = K;
      break;
    }
    if (A > 0) {
      A--;
      max++;
    }
    else if (B > 0) {
      B--;
    }
    else if (C > 0) {
      C--;
      max--;
    }
  }
  cout << max << endl;
}

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

int main(){
  int N,X,T;
  cin >> N >> X >> T;
  int time=0;
  if(N%X!=0){
    time=(N/X+1)*T;
  }else{
    time=(N/X)*T;
  }  
  cout << time << endl;
  return 0;
}

Measured memory_bytes: 3592
IDENTIFICATION DIVISION.
PROGRAM-ID. A-Birthday.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 IN-A     PIC 9(2).
01 IN-B     PIC 9(2).
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO IN-A IN-B.

  IF (IN-A <= 8) AND (IN-B <= 8)
    DISPLAY 'Yay!'
  ELSE 
    DISPLAY ':('
  END-IF.
 
MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  long double p = 0;
  long double ratio = 1;
  while (N > 0)
  {
    if (N >= K)
    {
      p += ratio * (N - (K - 1));
      N = K - 1;
    }
    K = (K + 1) / 2;

    ratio /= 2;
  }

  p /= n;

  cout << std::fixed << std::setprecision(20) << p << endl;

  return 0;
}


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

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    int rb[2] = {0,0};
    for (char c: s)
        ++rb[c == '1'];
    cout << 2*min(rb[0], rb[1]) << "\n";
}


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

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

  int mn = 1e9;
  int mni = -1;
  rep(i,n) {
    if(mn > abs(a[i])) {
      mn = abs(a[i]);
      mni = i;
    }
  }
  rep(i, mni) {
    if(a[i] < 0) {
      a[i] *= -1;
      a[i+1] *= -1;
    }
  }
  for(int i=n-1; i> mni; i--) {
    if(a[i] < 0) {
      a[i] *= -1;
      a[i-1] *= -1;
    }
  }
  ll ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 3764
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d){
        puts("Yes");
    }else if(abs(a-b)<=d && abs(b-c)<=d){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;

    int H[N+1]={}, A=0, B=0, check[N+1]={};
    int i,j;


    for (i = 1; i <= N; ++i)
    {
        cin >> H[i];    
    }
    int tmp;
    for (i = 1; i <= M; ++i)
    {
        cin >> A >> B;
        if(H[A]==H[B]){
            check[A]=-1;
            check[B] = -1;
        }else if(H[A]>H[B]){
            check[B] = -1;
        }else{
             check[A] = -1;
        }
    }
    int count=0;

    
    for (i = 1; i <= N; i++)
    {
        if(check[i]==0) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4396
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


MOD = (10**9 + 7)
S = z()
# 全部3で分割した場合、
# 2001//3 == 667
max_div_num = 668  # 数列の要素数はこれより大きくならない
ans = 0
fact = [1]*(S + max_div_num)
for i in range(1, S + max_div_num):
    fact[i] = (fact[i - 1] * i) % MOD

# inv_t = [0]+[1]
# for i in range(2, S + max_div_num):
#     inv_t += [inv_t[MOD % i] * (MOD - int(MOD / i)) % MOD]
# div_num = 2
# s = S - (3 * div_num)
# div = div_num-1
# tmp_ans = fact[s+div]//(fact[s]*fact[div])
# print(div_num, tmp_ans)
# exit()


for div_num in range(1, max_div_num):
    if (S < div_num * 3):
        break
    s = S - (3 * div_num)
    div = (div_num-1)
    # print('s', s)
    # print('div', div_num)

    # tmp_ans = fact[s+div]//((fact[s]*fact[div] % MOD))
    gyakugen = pow(fact[s]*fact[div], -1, MOD)
    tmp_ans = fact[s+div]*gyakugen
    # print(div_num, tmp_ans)
    # print()
    ans += (tmp_ans % MOD)
    ans %= MOD
    # sをdiv_num  人に分ける問題
print(ans)


Measured memory_bytes: 9636