akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

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

Node T[10000];
int n;

void preParse(int);
void inParse(int);
void postParse(int);

int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=-1)T[l].p=v;
    if(r!=-1)T[r].p=v;
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1)root=i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}

void preParse(int u){
  if(u==-1)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==-1)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==-1)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------


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

    int l[3], k;
    REP(i, 3) cin >> l[i];
    cin >> k;
    sort(l, l + 3);
    REP(i, k) l[2] *= 2;
    cout << l[0] + l[1] + l[2] << endl;

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 1000005

int main()
{
    i64 sum = 0 , cnt = 0 ;

    int n ;
    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++)
    {
        int d ; i64 c ;
        scanf("%d %lld",&d,&c) ;
        cnt += c ;
        sum += d*c ;
    }

    i64 ans = cnt-1 + (sum/9) ;

    if( sum%9 == 0 ) ans-- ;

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

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
vl segtree[1000005];

void build(ll node,ll tl,ll tr,vector<ll> &ar)
{
    if(tl == tr)
    {
        segtree[node] = vector<ll> (1,ar[tl]);
    }
    else
    {
        ll mid = (tl + tr)/2;
        build(2 * node,tl,mid,ar);
        build(2 * node + 1,mid + 1,tr,ar);
        merge(segtree[2 * node].begin(),segtree[2 * node].end(),segtree[(2 * node) + 1].begin(),segtree[2 * node + 1].end(),back_inserter(segtree[node]));

    }
    
}

ll query(ll node,ll tl,ll tr,ll ql,ll qr,ll k)
{
    if(ql > qr) return 0;
    else if((ql == tl) and (qr == tr))
    {
        auto it = lower_bound(segtree[node].begin(),segtree[node].end(),k);
        ll dist = segtree[node].end() - it;
        return dist;
    }
    else
    {
        ll mid = (tl + tr)/2;
        ll l = query(2 * node,tl,mid,ql,min(qr,mid),k);
        ll r = query(2 * node + 1,mid + 1,tr,max(ql,mid + 1),qr,k);
        return (l + r);
    }
    
}

void Compute(ll n,ll k)
{
    KAKA
    vector<ll> v(n);
    pragi(0,n)
    {
        cin>>v[i];
    }
    vector<ll> prefix(n);
    prefix[0] = v[0];
    pragi(1,n)
    {
        prefix[i] = prefix[i - 1] + v[i];
    }
    vector<ll> ar(n);
    pragi(0,n)
    {
        ar[i] = prefix[i] - (k * i);
    }
    build(1,0,n - 1,ar);
 ll ans = 0;
 ll tmp = query(1,0,n - 1,0,n - 1,k);
 ans += tmp;
 pragi(1,n)
 {
     tmp = query(1,0,n - 1,i,n - 1,prefix[i - 1] - (k * (i - 1)));
     ans += tmp;
 }
 cout<<ans<<"\n";
}
int main()
{
    KAKA
    ll n,k;
    cin>>n>>k;
    Compute(n,k);
}

Measured memory_bytes: 75340
#include <cstdio>
#include <bitset>
#include <algorithm>

const int N = 5010;

std::bitset<N> bt;

int n, a[N], k;

inline bool check(int x) {
    if(a[x] >= k) {
        return 1;
    }
    bt.reset();
    for(int i = 1; i <= n; i++) {
        if(i == x) {
            continue;
        }
        if(a[i] > N - 1) {
            break;
        }
        bt |= (bt << a[i]);
        bt.set(a[i]);
    }
    for(int i = k - a[x]; i < k; i++) {
        if(bt[i]) {
            return 1;
        }
    }
    return 0;
}

int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    std::sort(a + 1, a + n + 1);
    int l = 1, r = n, mid;
    while(l < r) {
        mid = (l + r + 1) >> 1;
        if(check(mid)) {
            r = mid - 1;
        }
        else {
            l = mid;
        }
    }
    if(r == 1 && check(1)) {
        r = 0;
    }
    printf("%d", r);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i]--;
  }
  //累積和
  vector<int> B(N+1);
  B[0] = 0;
  for (int i = 0; i < N; i++){
    B[i+1] = (B[i] + A[i])%K;
  }
  //map, queue
  long long count = 0;
  map<int,int> M;
  queue<int> Q;
  for (int i = 0; i < N + 1; i++){
    Q.push(B[i]);
    if (Q.size() > K){
      int p = Q.front();
      Q.pop();
      int a = M.at(p);
      M.erase(p);
      if (a>1) M[p]=a-1;
    }
    if (M.count(B[i]) == 0){
      M[B[i]] = 1;
    } else {
      int a = M.at(B[i]);
      M.erase(B[i]);
      count+=a;
      M[B[i]]=a+1;
    }
  }
  cout << count;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
# define ll long long
struct node
{
    ll val,wt;

};
int cmp(node a,node b)
{
    return a.wt<b.wt;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll n,w;
    cin>>n>>w;
    node arr[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i].wt>>arr[i].val;
    sort(arr+1,arr+n,cmp);
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(j-arr[i].wt>=0)
            {
                dp[i][j]=max((arr[i].val+dp[i-1][j-arr[i].wt]),max(dp[i-1][j],dp[i][j-1]));
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    cout<<dp[n][w];
    //code goes here
	return 0;
}



Measured memory_bytes: 79232
import itertools
import sys

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

def read_int_list():
    return list(map(int, readline().split()))

def read_int():
    return int(readline())

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())

    inf = float("inf")
    d = [[inf] * (N + 1) for _ in range(N + 1)]
    for n in range(1, N + 1):
        d[n][n] = 0

    for _ in range(M):
        a, b, c = map(int, input().split())
        d[a][b] = c
        d[b][a] = c

    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    min_cost = inf
    for p in itertools.permutations(r):
        cost = 0
        for i in range(len(p) - 1):
            src, dst = p[i:i + 2]
            cost += d[src][dst]
        min_cost = min(min_cost, cost)

    print(min_cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4672
#include<cstdio>
char a[110][110];
int h,w;

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

void dfs(int x,int y){
	char b = a[x][y];
	a[x][y] = '.';
	for(int i = 0;i < 4;i ++){
		int nx = x+dx[i],ny = y+dy[i];
		if(nx >= 0&&nx < h&&ny >= 0&&ny < w&&a[nx][ny] == b){
			dfs(nx,ny);
		}
	}
	return ; 
}

int main(){
	while(scanf("%d%d",&h,&w)!=EOF){
		getchar();
		int ans = 0;
		if(h == 0&&w == 0) break;
		for(int i = 0;i < h;i ++){
			for(int j = 0;j < w;j ++){
				scanf("%c",&a[i][j]);
			}
			getchar();
		}
		for(int i = 0;i < h;i ++){
			for(int j = 0;j < w;j ++){
				if(a[i][j] != '.'){
					dfs(i,j);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
} 


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;}
template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main() {
    int n;cin >> n;
    vector<int> a(n),b(n); 
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<int> x(n);
    rep(i,n) x[i] = i+1;
    int p = 0,q = 0,t=0;
    do{
	t++;
	bool ok1=true,ok2=true;
	for(int i=0;i<n;i++){
	    if(x[i]!=a[i]) ok1 = false;
	    if(x[i]!=b[i]) ok2 = false;
	}
	if(ok1) p = t;
	if(ok2) q = t;
    }while(next_permutation(x.begin(),x.end()));
    cout << abs(q-p) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793

int main() {
	string s;
	cin >> s;
	stack<char>st;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')st.push('0');
		else if (s[i] == '1')st.push('1');
		else if (s[i] == 'B') {
			if (st.size() == 0) {

			}
			else st.pop();
		}
	}
	vector<char>memo(st.size());
	for (int i = st.size() - 1; i >= 0; i--) {
		memo[i] = st.top(); 
		st.pop();
	}
	for (int i = 0; i < memo.size(); i++)cout << memo[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
A.reverse()

match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-N-N] * (N + 1)
dp[0] = 0

for i in range(1, N + 1):
  for j in A:
    if i >= match[j]:
      dp[i] = max(dp[i], dp[i - match[j]] + 1)

max_list = []
while N:
  for j in A:
    if N >= match[j] and dp[N] == dp[N - match[j]] + 1:
      max_list.append(j)
      N -= match[j]
      break

for j in max_list:
  print(j, end="")
print("")

Measured memory_bytes: 4208
#include <iostream>
#include <queue>


#define N 160

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

using namespace std;

int main(void)
{

	int t,n;
	int xx,yy;
	int x,y;
	int start_x,start_y;
	
	int i1,i2;

	int f[N][N];

	int num;
	int count;



	while(1){

		for(i1=0;i1<N;i1++){
			for(i2=0;i2<N;i2++){
				f[i1][i2] = 100;
			}
		}

		cin >> t;
		cin >> n;
		if(t == 0 && n == 0) break;


		for(i1=0;i1<n;i1++){
			cin >> xx;
			cin >> yy;


			f[yy+(N/2)][xx+(N/2)] = 500;
		}

		count = 1;
		num = 0;


		cin >> start_x;
		cin >> start_y;

		start_x += (N/2);
		start_y += (N/2);


		queue<pair<int, int> > q;

		f[start_y][start_x] = 0;
		q.push(make_pair(start_x,start_y));


		while(!q.empty()) {

			x = q.front().first;
			y = q.front().second;
			q.pop();

//				cout << x << " " << y << " " << num << endl;
			if ( f[y][x] < t){
				num = f[y][x];

				for(i1=0;i1<6;i1++){

					if (f[y+dy[i1]][x+dx[i1]]==100){
						f[y+dy[i1]][x+dx[i1]] = num + 1;
						q.push(make_pair(x+dx[i1],y+dy[i1]));
						count++;
					}
				}
			}

		}


		cout << count << endl;

	}

	return 0;
}

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

int main() {
	char x[1000] = {};
	while (1) {
		cin >> x;
		int a = 0;
		if (x[0] == '0') break;
		for (int i = 0;x[i]!='\0';i++) {
			if (x[i] == '\n') break;
			a += x[i] - '0';
		}
		cout << a << endl;
	}
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;

#define faster ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define debug(x) cout<<#x<<" = "<<(x)<< endl
#define nl "\n"
#define sp " "

const ll MOD = 1000000007;
ll n, a, b, pw[int(2e5 + 10)];
map<pair<ll,ll>, pair<ll, ll> > mp;

ll fix(ll x){
	return (x % MOD + MOD) % MOD;
}

int main() {
	faster
	cin >> n;
	pw[0] = 1;
	for(int i = 1; i <= n; i++){
		pw[i] = fix(2 * pw[i - 1]);
	}

	ll ans = 1, zero = 0;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a == 0 && b == 0){
			zero++;
			continue;
		}

		ll g = __gcd(a,b);
		a /= g, b /= g;

		if(a < 0){
			a *= -1, b *= -1;
		}

		if(b > 0){
			mp[{a, b}].first++;
		}else{
			mp[{-b, a}].second++;
		}
	}

	for(auto it : mp){
		ans *= pw[it.second.first] + pw[it.second.second] - 1;
		ans = fix(ans);
	}

	cout << fix(ans + zero - 1) << nl;
}


Measured memory_bytes: 20792
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n;
    cin>>n;
    int a=n%10;
    if(a==3)cout<<"bon";
    else if(a==0||a==1||a==6||a==8)cout<<"pon";
    else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int n;cin>>n;
  char s[n];
  rep(i,n) cin>>s[i];
  int r=0,g=0,b=0;
  P map[n];
  rep(i,n){
    if(s[n-1-i]=='R'){
      r++;
      map[n-1-i]=P(g,b);
    }
    if(s[n-1-i]=='G'){
      g++;
      map[n-1-i]=P(r,b);
    }
    if(s[n-1-i]=='B'){
      b++;
      map[n-1-i]=P(r,g);
    }
  }
      
  ll ans=0;
  
  rep(i,n){
    char a1=s[i];
    Rep(j,i+1,n){
      if(a1==s[j]) continue;
      char a2=s[j];
      if(a1=='R'){
        
        ans+=map[j].se;
      }
      if(a1=='B'){

        ans+=map[j].fi;
      }
      if(a1=='G' &&a2=='R'){

        ans+=map[j].se;
      }
      if(a1=='G' &&a2=='B'){

        ans+=map[j].fi;
      }
      if(2*j-i<n){
      if(a1!=s[2*j-i] &&a2!=s[2*j-i]){
        ans--;
      }
      }
    }
  }
  
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 3656
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)




signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl cnt[n + 1];
    m0(cnt);
    for(intl x = 1;x * x <= n;x++){
        for(intl y = 1;y * y <= n;y++){
            for(intl z = 1;z * z <= n;z++){
                intl num = x * x + y * y + z * z + x * y + x * z + y * z;
                if(num <= n)cnt[num]++;
            }
        }
    }
    repi(i,1,n+1)cout << cnt[i] << endl;
    return 0;
}


Measured memory_bytes: 3640
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    F=list(map(int,input().split()))
    A.sort()
    F.sort(reverse=True)
    
    def count(m):
        ret=0
        for a,f in zip(A,F):
            ret+=max(0,a-(m//f))
        return ret
    ng=-1
    ok=10**12+1
    while ok-ng>1:
        mid=(ok+ng)//2
        cnt=count(mid)
        if cnt<=k:
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__=='__main__':
    main()

Measured memory_bytes: 120396
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int sum = 0;
    for(int x = 0; x <= K; x++){
      for(int y = 0; y <= K; y++){
        int z = S - (x + y);
        if(z <= K && z >= 0){
          sum++;
        }
      }
    }
    System.out.println(sum);
  }
}

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

using namespace std;

int N, ans;

int F(int a, int b) {
    if (a < b) return 0;
    if (a % b == 0) return a / b;
    int x = a % b, y = a / b + 1;
    if (x % y) x += y;
    x -= x % y;
    return F(a - x, b);
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        int a, b; scanf("%d%d", &a, &b);
        ans ^= F(a, b);
    }
    printf(ans ? "Takahashi\n" : "Aoki\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
signed main(){
    int n,m;cin>>n>>m;
    vector<int> v;
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,m){
        int a;cin>>a;
        a+=114514;
        v.ps(a);
    }
    sort(all(v));
    vector<int>key;
    int sum=v[m-1]-v[0];
    rep(i,1,m){
        key.ps(v[i]-v[i-1]);
    }
    sort(all(key));
    reverse(all(key));
    rep(i,0,n-1){
        sum-=key[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
using namespace std;
int jud (int x,int n,int s)
{
	if(n==0&&s==0){
		return 1;
	}else if(n<0&&s<0)return 0;
	
	if(x==10){
		if(n==0&&s==0)return 1;
		else return 0;
	}
	
	
	
	
	int ans=0;
	
	ans+=jud(x+1,n-1,s-x);
	ans+=jud(x+1,n,s);
	return ans;
}



int main ()
{
	int n,s;
	
	while(1)
	{
		cin>>n>>s;
		if(n==0&&s==0)break;
		cout<<jud(0,n,s)<<endl;;
		
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1160
def calc_sum_digits(n):
    sumd = 0
    while(int(n) > 0):
        sumd += int(n%10)
        n /= 10
    return sumd

N = int(input())
sumd = calc_sum_digits(N)
if(N%sumd == 0):
     print('Yes')
else:
     print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,m;cin>>n>>m;
    ll xx[m];
    vector<ll> x;
    for(ll i=0;i<m;i++){
        cin>>xx[i];
        x.push_back(xx[i]);
    }
    sort(x.begin(),x.end());
    ll ans=0;
    vector<ll> sa;
    if(n>=m){
        ans=0;
    }else{
        for(ll i=0;i<m-1;i++){
            sa.push_back(x[i+1]-x[i]);
        }
        sort(sa.begin(),sa.end());
        for(ll i=0;i<m-n;i++){
            ans+=sa[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

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

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) a--;
	else b--;
	cout << a << ' ' << b << '\n';

	return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder{
    public static class AtCoder{
        public static void Main(){
            var input = long.Parse(Console.ReadLine());
            decimal output = 0;
            for(long i = 1; i<= input; i++){
                if(i % 3 != 0 && i % 5 != 0){output+= i;}
            }
            Console.WriteLine(output);
        }
    }
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  long long N;
  cin >> N;
  vector<long long> A(N);
  for(long long i = 0; i < N; ++i) {
    cin >> A[i];
  }

  long long tmp = A[0], cnt = 0;
  for(long long i = 1; i < N; ++i) {
    if(tmp > A[i]) {
      cnt += tmp - A[i];
    }
    else {
      tmp = A[i];
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 4764
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<String> = get_vec();
    let a : i32 = v[0].parse().ok().unwrap();
    let b : i32 = v[2].parse().ok().unwrap();
    println!("{}", if v[1] == "+" { a+b } else { a-b });

}


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

bool judge(int bit, int n){
    rep(i, n){
        if (!(bit & (1 << i))) continue;
        for(auto xy:a[i]){
            int x, y; tie(x, y) = xy;
            if (y == 1 && !(bit & (1 << x))) return false;
            if (y == 0 && (bit & (1 << x))) return false;
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    a.resize(n);
    rep(i, n){
        int tmp; cin >> tmp;
        a[i].resize(tmp);
        rep(j, tmp){
            cin >> a[i][j].first >> a[i][j].second;
            a[i][j].first --;
        }
    }
    int res = 0;
    for (int bit = 0; bit < (1 << n); bit++){
        if (judge(bit, n)){
            int cnt = 0;
            rep(i, n){
                if (bit & (1<<i)) cnt++;
            }
            res = max(cnt, res);
        }
    }
    cout << res << endl;
}   


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int  x,y;
   while(1){
       scanf("%d %d",&x,&y);
       if(x==0&&y==0)break; 
       if(x<y){
           printf("%d %d\n",x,y);
       }else{
           printf("%d %d\n",y,x);
       }
      
   }// Your code here!
    return(0);
}



Measured memory_bytes: 1920
s=list(input())
n=int(input())

a='abcdefghijklmnopqrstuvwxyz'
d=dict()
for i in range(26):
	d[a[i]]=i
	
for i in range(len(s)):
	if 26-d[s[i]]<=n:
		n-=(26-d[s[i]])%26
		s[i]='a'

s[len(s)-1]=a[(d[s[len(s)-1]]+n)%26]
print(''.join(s))

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

//const long double M_PI = 3.141592653589793238462643383279L;

int main() {

    long long int a, b, h, m;
    cin >> a >> b >> h >> m;

    long double aang = 1.00L * ( h * 60 + m ) / 720 * M_PI * 2;
    long double ax = sinl( aang ) * a;
    long double ay = cosl( aang ) * a;
    long double bang = 1.00L * m / 60 * M_PI * 2;
    long double bx = sinl( bang ) * b;
    long double by = cosl( bang ) * b;

    long double dx = ax - bx;
    long double dy = ay - by;

    cout << fixed << setprecision(15) << sqrtl( dx * dx + dy * dy ) << endl;

    return 0;

}


Measured memory_bytes: 4160
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  if(n==1||m==1){
    cout<<1<<endl;
    return 0;
  }
  ll ret = 0;
  int ou = (m+1)/2;
  int ji = m/2;
  int oucc = (n+1)/2;
  int jicc = n - oucc;
  ret = ou * (ll)oucc + ji * (ll)jicc;
  cout<<ret<<endl;
  return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << (char)('A'+j) << i+1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    private int N, M;
    private int[] X;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        X = sc.IntArray();
        var count = new int[100001];
        var countModM = new int[M];
        foreach (int i in X)
        {
            count[i]++;
            countModM[i % M]++;
        }


        // mod Mでいくつ同じ数字のペアが作れるか
        var countPair = new int[M];

        for (int i = 0; i <= 100000; i++)
        {
            countPair[i % M] += count[i] / 2;
        }

        int ans = 0;

        ans += countModM[0] / 2;
        if (M % 2 == 0)
        {
            ans += countModM[M / 2] / 2;
        }

        for (int i = 1; i * 2 < M; i++)
        {
            int min = Math.Min(countModM[i], countModM[M - i]);
            ans += min;
            countModM[i] -= min;
            countModM[M - i] -= min;
            ans += Math.Min(countPair[i], countModM[i] / 2);
            ans += Math.Min(countPair[M - i], countModM[M - i] / 2);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

int main(){
	long long n, d, x, y, s=0;
	cin >> n >> d;
	
	for(int i=0; i<n; i++){
		cin >> x >> y;
		if (x*x+y*y<=d*d) s++;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    string S;cin>>S;
    int length = S.size();

    int MOD = pow(10,9) + 7;

    // 
    int amari[length+1];
    amari[1] = 1;
    for(int i=2;i<length+1;i++){
        amari[i] = (amari[i-1]*10)%13;
    }

    // いわゆる桁DPで片が付く
    int DP[length+1][13];
    for(int i=0;i<13;i++){
        for(int j=0;j<length+1;j++){
            DP[j][i]=0;
        }
    }

    DP[0][0] = 1;

    for(int i=1;i<length+1;i++){
        if(S.at(length-i)=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    DP[i][(j+amari[i]*k)%13]  = (DP[i][(j+amari[i]*k)%13] +DP[i-1][j])%MOD;
                }
            }
        }else{
            int val = charToInt(S.at(length-i));
            for(int j=0;j<13;j++){
                DP[i][(val*amari[i]+j)%13]  = DP[i-1][j];
            }
        }
    }
    cout<<DP[length][5]<<endl;




    return 0;
}

Measured memory_bytes: 14652
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A<=C && C<=B) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	long long int ans=0;
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		if(i%3!=0 && i%5!=0){
			ans+=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector <int>H(N);
    for(int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    
    int ans = 0;
    int maxHeight = -1;
    for (int i=0; i<N; i++)
    {
        if(maxHeight <=H[i]){
            ans++;
            maxHeight = H[i];
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=500100;
int A[MAXN],T[MAXN];
int n;
int tot;
void input()
{
	cin>>n;
	for(int i=0;i<n;i++)
	    cin>>A[i];
}

void merge_sort(int l,int r)
{
	if(l==r) return;
	int mid=(l+r)/2;
	merge_sort(l,mid);
	merge_sort(mid+1,r);
	int x(l),y(mid+1),q(l);
	while(q<=r)
	{
		if((x<=mid && A[x]<=A[y]) || y>r) {T[q]=A[x];q++;x++;}
		else {T[q]=A[y];q++;y++;}
		tot++;
	}
	for(int i=l;i<=r;i++) A[i]=T[i];
}

void xxj()
{
	merge_sort(0,n-1);
}

void output()
{
	for(int i=0;i<n-1;i++)
	    cout<<A[i]<<' ';
    cout<<A[n-1]<<endl;
    cout<<tot<<endl;
}

int main()
{
	input();
	xxj();
	output();
	return 0;
}

Measured memory_bytes: 6980
#include <iostream>
#include <cstdlib>
#include <vector>
#include <climits>

// #define LOOP(N) for(int i=0; i<N; i++)
#define LOOP(N, i) for(int i=0; i<N; i++)
#define LOOP_s(N, i, start) for(int i=start; i<N; i++)


using namespace std;

int get_min(vector<int> &h, vector<int> &c, int start, int now) {
    int min_cost = INT_MAX;
    int cost;
    
    for (int i = start; i < now; i++) {
        cost = c[i] + abs(h[i] - h[now]);
        if (cost < min_cost) min_cost = cost;
    }

    return min_cost;
}


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N), c(N);
    LOOP(N, i) {
        cin >> h[i];
    }

    c[0] = 0;
    // cout << 0 << " " << h[0] << " " << c[0] << endl;
    LOOP_s(N, i, 1) {
        c[i] = get_min(h, c, max(0, i-K), i);
        // cout << i << " " << h[i] << " " << c[i] << endl;
    }
    
    cout << c[N-1] << endl;
}


Measured memory_bytes: 1024
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

const intt init = (1 << 31) - 1;

intt n, q;
intt t[maxx << 2];

void build (intt v, intt l, intt r) {
    if (l == r) {
        t[v] = init;
        return;
    }
    intt mid = (l + r) >> 1;
    build (v << 1, l, mid);
    build (v << 1 | 1, mid + 1, r);
    t[v] = min (t[v << 1], t[v << 1 | 1]);
}

void update (intt v, intt l, intt r, intt i, intt val) {
    if (i < l || i > r)
        return;
    if (l == r) {
        t[v] = val;
        return;
    }
    intt mid = (l + r) >> 1;
    update (v << 1, l, mid, i, val);
    update (v << 1 | 1, mid + 1, r, i, val);
    t[v] = min (t[v << 1], t[v << 1 | 1]);
}

intt query (intt v, intt l, intt r, intt i, intt j) {
    if (j < l || i > r)
        return init;
    if (i <= l && r <= j)
        return t[v];
    intt mid = (l + r) >> 1;
    return min (query (v << 1, l, mid, i, j), query (v << 1 | 1, mid + 1, r, i, j));
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    cin >> n >> q;
    build (1, 1, n);
    while (q --) {
        intt type, x, y;
        cin >> type >> x >> y;
        x ++;
        if (type == 0)
            update (1, 1, n, x, y);
        else
            y ++, cout << query (1, 1, n, x, y) << endl;
    }
    return 0;
}

Measured memory_bytes: 5240
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input())) for _ in range(h)]
b=deque()
n=[-1]*(h*w)
c=0
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
             b.append((i,j))
             n[i*w+j]=0
        else:
            continue
p = [(1,0),(-1,0),(0,1),(0,-1)]

while b:
    i,j=b.popleft()
    for s,t in p:
      if 0 <= i+s <= h-1 and 0 <= j+t <= w-1:
        if n[(i+s)*w+(j+t)]==-1:
          n[(i+s)*w+(j+t)]=n[i*w+j]+1
          c=max(c,n[i*w+j]+1)
          b.append(((i+s),(j+t)))
    
print(c)
        

Measured memory_bytes: 122204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BABC {
public:
void solve(std::istream& cin, std::ostream& cout) {
    string s;
    cin >> s;
    _for(i,s.size()){
        ll res = 0;
        ll temp = 0;
        while(i<s.size()){
            while(s[i] == 'A' || (s[i] == 'B' && i<s.size()-1 && s[i+1] == 'C')){
                if(s[i] == 'A')i++,temp++;
                else i+=2,res += temp;
            }
           temp = 0;
            i++;
        }
        cout << res << endl;
    }
}
};


#undef int
int main() {
	BABC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    int ans = 0;
    rep(i, n) if (s[i] != t[i])++ ans;
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3796
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		long X = sc.nextLong();
		long num = 100;
		int cur = 0;
		
		while(X > num) {
			num *= 1.01;
			cur++;
		}
		System.out.println(cur);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a,b;
  cin>>a>>b;
  int flag = 1;
  for( int i=a;i<=b;i++){
    if( i%n==0 ){
      cout<<"OK";
      flag = 0;
      break;
    }
  }
      if(flag) cout<<"NG";
      }

Measured memory_bytes: 3640
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if V>W:
    if A>B:
        if A-V*T<=B-W*T:
            print("YES")
        else:
            print("NO")
    elif A==B:
        print("YES")
    else:
        if A+V*T>=B+W*T:
            print("YES")
        else:
            print("NO") 
elif V==W and A==B:
    print("YES")
elif V==W and A!=B:
    print("NO")
elif V<W and A==B:
    print("YES")
elif V<W and A!=B:
    print("NO")











        


























            
    


    


    
    














    


    














Measured memory_bytes: 9212
class Ball():
    def __init__(self, S: str, T: str, A: int, B: int):
        self.S = S
        self.T = T
        self.A = A
        self.B = B

    def select_ball(self, U: str):
        if self.S == U:
            self.A -= 1
        else:
            self.B -= 1
        return

    def remain_balls(self):
        print(self.A, self.B)


S, T = input().split(" ")
A, B = [int(i) for i in input().split(" ")]
U = input()

ball = Ball(S, T, A, B)
ball.select_ball(U)
ball.remain_balls()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin >> S[i];
  int LH[2010][2010]={0}, LW[2010][2010]={0};
  rep(i,H){
    int num=0;
    rep(j,W){
      if(S[i][j]=='.') LH[i][num]++;
      else LH[i][j]=-1*LH[i][num], num=j+1;
    }
  }
  rep(i,H){
    rep(j,W-1) LH[i][j+1]+=LH[i][j];
  }
  rep(j,W){
    int num=0;
    rep(i,H){
      if(S[i][j]=='.') LW[num][j]++;
      else LW[i][j]=-1*LW[num][j], num=i+1;
    }
  }
  rep(j,W){
    rep(i,H-1) LW[i+1][j]+=LW[i][j];
  }
  int ans=0;
  rep(i,H){
    rep(j,W){
      int num=LH[i][j]+LW[i][j]-1;
      ans=max(ans,num);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll a,b;
	cin >> a >> b;
	if(a<=5){
		cout << 0 << endl;
	}else if(a<=12){
		cout << b/2 << endl;
	}else{
		cout << b << endl;
	}

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  int ans = 0;
  rep(i,1,n+1) if(i%2==1){
    int cnt=0;
    rep(j,1,i+1){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256