akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%s", $s);
$ln = strlen($s) - 1;
for ($p = $ln; $p >= 2; $p--) {
	$s = substr($s, 0, $p);
	if ($p % 2) continue;
	if (substr($s, 0, $p / 2) == substr($s, $p / 2)) {
		exit("$p");
	}
}

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

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

int k = N; int x = 0; int sum = 0;
while(k){
  x = k % 10;
  k = (k - x) / 10;
  sum += x;
}
if(N % sum == 0) cout << "Yes" << endl;
else cout << "No" << endl;
// cout << 2 * cnt - 4 << endl;
  return 0;
 
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    int ans=inf;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    for(int x=-100;x<=100;x++){
        int sum=0;
        rep(i,n) sum+=(a[i]-x)*(a[i]-x);
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;++i)
    	if(i<10 || (i/100<10 && i/100>0) || (i/10000>0 && i/10000<10))
    	    ans++;
    cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2*10**5)


# 入力
L = input()

MOD = 10**9 + 7


# 最上位ビットから順に、0にする場合と1にする場合の個数を求める
# 最上位ビットが0の場合、直ちに解が求められる（3のべき乗になる）ことに注意
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


def f(n):
    return (
        ModInt(1) if n == 0 else
        ModInt(3)**(n - 1) + 2 * f(n - 1) if L[-n] == '1' else
        f(n - 1)
    )


ans = f(len(L))

# 出力
print(ans)


Measured memory_bytes: 108716
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
	int n;\
	int temp;
	long maxnum, minnum, sum;
	cin >> n;
	if (n > 0) {
		cin >> temp;
		maxnum = temp;
		minnum = temp;
		sum = temp;
		for (int i = 0; i < n - 1; i++) {
			cin >> temp;
			if (maxnum <= temp) {
				maxnum = temp;
			}
			if (minnum >= temp) {
				minnum = temp;
			}
			sum += temp;
		}
	}

	printf("%ld %ld %ld", minnum, maxnum, sum);

	cout << endl;
	return 0;
}

Measured memory_bytes: 3232
#include <stdio.h>

int main(void){
  int k, x;
  scanf("%d %d", &k, &x);

  int low, up;
  low = x - k + 1;
  up = x + k - 1;

  for(int i=low; i<=up; i++)
    printf("%d\n", i);

  return 0;
}


Measured memory_bytes: 128
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F551C':
    sys.stdin = open('b1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M, X, Y = read_int_list()
    x = read_int_list()
    y = read_int_list()
    x.append(X)
    y.append(Y)
    if max(x) < min(y):
        res = 'No War'
    else:
        res = 'War'
    print(res)


main()


Measured memory_bytes: 3696
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val t = readLine()!!
    var ans = 2 * n
    for (i in n downTo 1) {
        if (s.endsWith(t.substring(0, i))) {
            ans -= i
            break
        }
    }
    println(ans)
}

Measured memory_bytes: 18996
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = 0; r = 10**9
while r-l > 1:
    b = 0; x = (l+r)//2
    for i in range(n): b += (a[i]-1)//x
    if k < b:
        l = x
    else:
        r = x
print(r)

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

using namespace std;

const int MAX_N = 2e3 + 5;

int ans [MAX_N];
int X, Y;
int dist (int u, int v) {
  return min({abs(v - u), abs(v - X) + 1 + abs(u - Y), abs(v - Y) + 1 + abs(u - X)});
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n >> X >> Y;

  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ans[dist(i, j)]++;
    }
  }

  for (int i = 1; i < n; i++) {
    cout << ans[i] << '\n';
  }
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x7fffffff;
const ll LINF = 0x7fffffffffffffff;
const int maxn = 1e6;
const int modn = 1e9 + 7;



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

	int n,k;
	cin>>n>>k;
	double ans=0;
	if (n>=k)
        ans+=(double)(n-k+1)/n;
    for (int i=1;i<=min(k-1,n);++i){
        ans+=1.0/n*pow(0.5,ceil(log((double)k/i)/log(2)));
    }
    printf("%.12f\n",ans);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    ll n;
    cin>>n;
    vi v;ll aa;
    rep(i,n){
        cin>>aa;
        v.pb(aa);
    }
    ll ans= 0;
    rep(i,n){
        if(v[i]%2==0){
            while(v[i]%2==0){
                v[i]/=2;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    while (cin >> n, n)
    {
        vector<ld> s(n);
        ld sum = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> s[i];
            sum += s[i];
        }
        sum /= n;
        ld p = 0;
        for (int i = 0; i < n; i++)
        {
            p += (s[i] - sum) * (s[i] - sum) / n;
        }
        cout << fixed << setprecision(10) << sqrt(p) << endl;
    }
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes"
                                                                     : "No")
         << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int A,B,sum1,sum2;
    cin>>A>>B;
    if(B%A==0){
        sum1=A+B;
        cout<<sum1<<endl;

    }else{
        sum2=B-A;
        cout<<sum2<<endl;
    }

    return 0;
}

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

int main(){
  int n,m;
  cin >>n >>m;
  vector<ll> h(n);
  rep(i,n) cin >>h[i];
  int num[n] = {0};
  rep(i,m){
    int a,b;
    cin >>a >>b;
    if(h[a-1]<=h[b-1]) num[a-1]--;
    if(h[b-1]<=h[a-1]) num[b-1]--;
  }
  int cnt = 0;
  rep(i,n){
    if(num[i]==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

vector<VB> check(202, VB(202, false));
VI color(202, 0);
VB colored(202, false);
VVI G(202, VI());

void paint(const auto &n, const auto &precolor, auto &nowcolor)
{
  if (precolor == n-1) nowcolor = 0;
  else nowcolor = precolor+1;
}

bool dfs(auto now, auto n)
{
  if (colored[now]) return true;
  colored[now] = true;
  REPx(x, G[now])
  {
    if (colored[x])
    {
      if (abs(color[now]-color[x]) != 1 && abs(color[now]-color[x]) != n-1) return false;
      continue;
    }
    paint(n, color[now], color[x]);
    if (!dfs(x, n)) return false;
  }
  return true;
}

void warshall_floyd(VVI &GG)
{
  int V = GG.size();
  REP(i, V) GG[i][i] = 0;
  REP(k, V) REP(i, V) REP(j, V) chmin(GG[i][j], GG[i][k] + GG[k][j]);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VVI GG(n, VI(n));
  REP(i, n) REP(j, n)
  {
    char s;
    cin >> s;
    GG[i][j] = s - '0' ? 1 : INF;
    if (check[i][j] || check[j][i]) continue;
    if (s == '1')
    {
      G[i].emplace_back(j);
      G[j].emplace_back(i);
      check[i][j] = true;
    }
  }
  int ans = -1;
  if (dfs(0, 2))
  {
    warshall_floyd(GG);
    REP(i, n) chmax(ans, MAX(GG[i]));
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
N,*H = $<.read.split.map &:to_i
A = Array.new(N,0)
H.fill H[0],N,2

A.map!.with_index {|_,i|
  h = H[i]
  (1..2).map {|j| A[i-j]+(h-H[i-j]).abs }.min
}
p A[-1]

Measured memory_bytes: 12156
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define rep(i,x,y) for(register int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(register int i=(x);i>=(y);--i)
#define view(u,k) for(int k=fir[u];k!=-1;k=nxt[k])
#define maxn 3007
#define maxm 6007
#define LL long long
#define inf 2147483647
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
void write(LL x)
{
	if(x==0){putchar('0'),putchar(' ');return;}
	int f=0;char ch[20];
	if(x<0)putchar('-'),x=-x;
	while(x)ch[++f]=x%10+'0',x/=10;
	while(f)putchar(ch[f--]);
	putchar(' ');
	return;
}
int n,a[maxn],fir[maxn],nxt[maxm],v[maxm],cnt;
void ade(int u1,int v1){v[cnt]=v1,nxt[cnt]=fir[u1],fir[u1]=cnt++;}
int work(int u,int fa)
{
	int res=0;
	view(u,k)if(v[k]!=fa&&a[v[k]]<a[u]){if(!work(v[k],u)){res=1;break;}}
	return res;
}
int main()
{
	memset(fir,-1,sizeof(fir));
	n=read();
	rep(i,1,n)a[i]=read();
	rep(i,1,n-1){int x=read(),y=read();ade(x,y),ade(y,x);}
	rep(i,1,n)if(work(i,0))write(i);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[20], t[20];
  scanf("%s\n%s", s, t);
  int len = strlen(s);
  t[len] = '\0';
  int a = strcmp(s, t);
  if(a == 0) puts("Yes");
  else puts("No");
  return 0;
}

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

const int DIM = 1e5 + 5;

string str1, str2;
int psm1[DIM], psm2[DIM];

int main( void ) {
    
    cin >> str1 >> str2;
    
    for( int i = 1; i <= str1.length(); i ++ )
        psm1[i] = psm1[i - 1] + ( str1[i - 1] == 'A' ? 1 : 2 );
    for( int j = 1; j <= str2.length(); j ++ )
        psm2[j] = psm2[j - 1] + ( str2[j - 1] == 'A' ? 1 : 2 );
    
    int q;
    cin >> q;
    
    for( int i = 1; i <= q; i ++ ) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        
        cout << ( ( psm1[y1] - psm1[x1 - 1] ) % 3 ==
                  ( psm2[y2] - psm2[x2 - 1] ) % 3 ? "YES\n" : "NO\n" );
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[101],n,i,s=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])
			s++;
	}
	printf("%d",s);
	return 0;
} 

Measured memory_bytes: 256
n = int(input())

list_tree = [[] for _ in range(n)]
list_parent = [None for _ in range(n)]

for _ in range(n):

    id, k, *C = map(int, input().split())

    list_tree[int(id)].extend(C)

    for c in C:
        list_parent[int(c)] = int(id)


for id in range(n):
    child = list_tree[id]

    if list_parent[id] == None:
        parent = -1
    else:
        parent = list_parent[id]

    depth = 0
    parent_now = list_parent[id]

    while parent_now != None:
        depth += 1
        parent_now = list_parent[parent_now]

    if depth == 0:
        type_node = "root"
    elif not child:
        type_node = "leaf"
    else:
        type_node = "internal node"

    print(f"node {id}: parent = {parent}, depth = {depth}, {type_node}, {child}")



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

#define long long long 

const long M = 1e9+7;
const int N = 2e5+5;

int n, m;

long frac[N];

long powmod(long a, long b) {
    long ret = 1;
    while(b) {
        if(b & 1) ret = (ret * a) % M;
        a = (a * a) % M;
        b >>= 1;
    }
    return ret;
}

long c(int n, int r) {
    long ret = (frac[n] * powmod(frac[n-r], M-2)) % M; 
    return (ret * powmod(frac[r], M-2)) % M;
}

int main() {
    scanf("%d %d", &n, &m);
    frac[0] = 1;
    for(int i = 1; i < N; ++i) frac[i] = (frac[i-1] * i) % M;
    long ans = 1;
    for(int i = 2; i * i <= m; ++i) {
        int cnt = 0;
        while(m % i == 0) m /= i, cnt++;
        ans = (ans * c(cnt + n - 1, n - 1))% M;
    }
    if(m != 1) ans = (ans * n) % M;
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

int n;
ll x[200005];
vector<ll>V;

int main(){
  cin >> n;
  ll cnt = 0;
  V.push_back(0);
  for(int i = 1; i <= n; ++i){
    cin >> x[i];
    cnt++;
    V.push_back(x[i]);
  }
  sort(V.begin(), V.end());
  ll medium = (cnt + 1) / 2;
  //cout << medium << endl;
  ll l = V[medium];
  ll r = V[medium + 1];
  //cout << l << endl;
  for(int i = 1; i <= n; ++i){
    if(x[i] <= l){
      cout << r << endl;
    }else{
      cout << l << endl;
    }
  }
}

Measured memory_bytes: 5488
#include <cstdio>
#include <iostream>

#define MAXN 2050
#define ll long long
#define Mod 1000000007

using namespace std ; int i, j ; int N, M ; 
ll Fac[MAXN * MAXN], Inv[MAXN * MAXN]/*Co[MAXN][MAXN], */, dp[MAXN][MAXN] ;

ll expow(ll a, int b){
	ll res = 1 ; 
	while (b){
		if (b & 1) res = res * a % Mod ;
		a = a * a % Mod, b = b >> 1 ;
	}
	return res ;
} 
ll Co(int n, int m){
	if (n < m) return 0 ; 
	return Fac[n] * Inv[m] % Mod * Inv[n - m] % Mod ; 
}
int main(){
	cin >> N >> M ; /*Co[0][0] = 1 ; */	 Inv[0] = 1 ;
	for (i = 0 ; i <= N ; ++ i) dp[i][0] = 1 ; Fac[0] = 1 ;
	for (i = 1 ; i <= N * M ; ++ i) Fac[i] = Fac[i - 1] * i % Mod ;
	for (i = 1 ; i <= N * M ; ++ i) Inv[i] = expow(Fac[i], Mod - 2) ;  
	/*for (i = 1 ; i <= N ; ++ i){
        Co[i][0] = 1 ;
        for (j = 1 ; j <= N ; ++ j) Co[i][j] = (Co[i - 1][j - 1] + Co[i - 1][j]) % Mod ;
    }*/
	for (i = 1 ; i <= N ; ++ i)
		for (j = 1 ; j <= i ; ++ j)
			dp[i][j] = (dp[i - 1][j]  + dp[i][j - 1] * (N - j + 1) % Mod * Co(N * M - i - (j - 1) * (M - 1) - 1, M - 2) % Mod) % Mod ;
	cout << (M <= 1 ? 1 : dp[N][N]) << endl ; return 0 ; 
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    REP(i, H) cin >> c[i];

    int result = 0;

    REP(bit_H, 1 << H) {
        REP(bit_W, 1 << W) {
            int n_black = 0;
            REP(i, H) REP(j, W) {
                if ((bit_H & (1 << i)) > 0 && (bit_W & (1 << j)) > 0 && c[i][j] == '#') {
                    ++n_black;
                }
            }
            if (n_black == K) {
                ++result;
            }
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define INF 1000000000000000003
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back
#define POB pop_back
#define MP make_pair
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
      int n,m;
      cin>>n>>m;
      cout<<n*m<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int n,p;
    double d;
    cin >> n;
    int x[n],y[n];
    
    for(int i=0; i<n; i++)
        cin >> x[i];
    for(int i=0; i<n; i++)
        cin >> y[i];
    
    for( p = 1; p < 4; ++p ){
        d = 0.0;
        for(int i = 0; i < n; ++i )
            d += pow(abs(x[i] - y[i]), p);
        d = pow(d, 1.0/p);
        printf("%.6lf\n", d);
    }
    
    d = 0;
    for(int i = 0; i < n; ++i ){
        double tmp = (abs(x[i] - y[i]));
        d = d < tmp ? tmp : d;
    }
    
    printf("%.6f\n",d);
    
    return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
const double tax = 1.08;

int main(){
	IOS
	int n;
	cin >> n;
	for(int i=n;i>=0;i--){
		if(floor(i*tax)==n){
			cout << i << '\n'; return 0;
		}
	}
	cout << ":(" << '\n';
}

Measured memory_bytes: 256
# coding: utf-8
while True:
    line = input().split()
    m = int(line[0])
    f = int(line[1])
    r = int(line[2])
    if (m == -1 and f == -1 and r == -1):
        break
    if (m == -1 or f == -1):
        print("F")
    elif (m+f >= 80):
        print("A")
    elif (m+f < 80 and m+f >= 65):
        print("B")
    elif (m+f < 65 and m+f >=50):
        print("C")
    elif (m+f < 50 and m+f >=30):
        if (r >= 50):
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define ld long double
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define setbits(x) (__builtin_popcount(x))
int mod=998244353;
int INF64=mod*mod+1;

class segTree{
	int sz;
	vector<int> a;

public:
	segTree(int n){
		sz=1;
		while(sz<n)	sz*=2;
		a.resize(2*sz,0);
	}

	void add(int l, int r, int v, int x, int lx, int rx){
		if(l>rx||lx>r)	return;
		if(lx>=l&&rx<=r){
			a[x]=(a[x]+v)%mod;
			return;
		}

		int m=(lx+rx)/2;
		add(l,r,v,2*x+1,lx,m);
		add(l,r,v,2*x+2,m+1,rx);
	}

	void add(int l, int r, int v){
		add(l,r,v,0,0,sz-1);
	}

	int get(int i, int x, int lx, int rx){
		if(lx==rx)	return a[x];

		int m=(lx+rx)/2;
		if(i<=m)
			return (get(i,2*x+1,lx,m)+a[x])%mod;
		else
			return (get(i,2*x+2,m+1,rx)+a[x])%mod;
	}

	int get(int i){
		return get(i,0,0,sz-1);
	}
};

void solve(){
	int n,k;
	cin>>n>>k;

	vector<pair<int,int>> s(k);
	for(int i=0;i<k;i++)
		cin>>s[i].first>>s[i].second;

	segTree st(n);
	st.add(0,0,1);

	for(int i=0;i<n;i++){
		int curr=st.get(i);
		for(int j=0;j<k;j++){
			if(i+s[j].first<n){
				st.add(i+s[j].first,min(n-1,i+s[j].second),curr);
			}
		}
	}

	cout<<st.get(n-1);
}

int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int T;
	// cin>>T;
	T=1;
	for(int i=1;i<=T;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
}

Measured memory_bytes: 7432
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String st = scan.next();
	int t = Integer.parseInt(st);
	int h = t/3600;
	int m = (t - (t / 3600) * 3600) / 60;
	int s = (t % 60);
	System.out.println(h + ":" + m + ":" + s);
    }
}



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

int main(void){

  string s;
  cin >> s;
  int ans = 0;

  for(int i = 0; i < 3; ++i){
    if(s[i] == '1'){
      ++ans;
    } else {
      
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dig(int n)
{
  int t=n;
  int r;
  int sum=0;
  while(t!=0)
  {
    r=t%10;
    sum=sum+r;
    t=t/10;
    
    
      
  }
  return sum;
  
}
int main()
{
  int z;
  int n,a,b;
  cin>>n>>a>>b;
  int res=0;
  for(int i=1;i<=n;i++)
    

      {
        z=dig(i);
        if(z>=a && z<=b)
        {
          res=res+i;

          
        }
        
        
        
      }
  cout<<res<<endl;
  
  
  
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
char s[2521];
vi g[2521];

int cnt[2521];
int memo[2521];

int dfs0(int p, int bef){
    cnt[p] = s[p]-'0';
    for(int to : g[p])if(to != bef){
        cnt[p] += dfs0(to,p);
    }
    return cnt[p];
}
int dfs1(int p, int bef, int d){
    int ret = 0;
    if(s[p]=='1')ret += d;
    for(int to : g[p])if(to != bef){
        ret += dfs1(to, p, d+1);
    }
    memo[p] = ret - cnt[p]*d;
    return ret;
}
// <count, dists>
bool dfs2(int p, int bef, ll rest){
    if(rest<0)return false;
    ll sum = 0;
    ll mx = 0;
    int id = -1;
    for(int to : g[p])if(to != bef){
        int v = memo[to]+cnt[to];
        sum += v;
        if(v > mx){
            mx = v;
            id = to;
        }
    }
    if(mx <= sum-mx){
        return sum%2 <= rest;
    }else{
        ll mn = 2*mx-sum;
        if(mn <= rest)return true;
        if(id==-1)return false;
        return dfs2(id, p, rest+sum-mx-cnt[id]);
    }
}

int main(){
    scanf("%d%s",&n,s);
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(count(s,s+n,'1')==1){
        puts("0");
        return 0;
    }
    ll ans = 1ll<<60;
    vi roots(n);
    REP(i,n)roots[i] = i;
    srand(2521);
    random_shuffle(ALL(roots));
    for(int root : roots){
        // if(root!=0)continue;
        fill(memo,memo+n,-1);
        fill(cnt,cnt+n,0);
        dfs0(root, -1);
        vector<pii> V;
        ll sum = 0;
        for(int to : g[root]){
            int v = dfs1(to, root, 1);
            sum += v;
            V.push_back(pii(v,to));
        }
        if(sum%2==1)continue;
        if(sum/2 >= ans)continue;
        sort(ALL(V));
        reverse(ALL(V));
        if(V[0].first <= sum-V[0].first){
            // ok
            CHMIN(ans, sum/2);
            continue;
        }
        ll rest = sum - V[0].first;
        int p = V[0].second;
        bool ok = dfs2(p, root, rest-cnt[p]);
        if(ok){
            CHMIN(ans, sum/2);
        }
    }
    if(ans == (1ll<<60)){
        puts("-1");
    }else{
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1000005;

int main() {
	
	ll s,t;
	cin >> s;
	t=sqrt(s);
	if(s==(t*t)){
		cout << "0 0 " << t << " 0 0 " << t << endl;
	} else {
		if((t+1)*(t+1)-s<=s-t*t){
			cout << "0 0 " << t+1 << " " << (t+1)*(t+1)-s << " 1 " << t+1 << endl;
		} else {
			cout << "1 0 " << t+1 << " " << s-t*t << " 0 " << t << endl;
		}
	}
	return 0;
}

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

int main() {
    
    int A,B,C,D ;
    cin >> A >> B >> C >> D ;
    
    if ((A+B) > (C+D)){
        cout << "Left" <<endl;
    }
    else if((A+B) < (C+D)){
        cout << "Right" <<endl;
    }
    else{
        cout << "Balanced" <<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N=101;

int main(void){
    int M[N][N]={0};
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int v;
            cin >> v;
            M[u][v]=1;
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j!=1) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
main(){
  int n;cin>>n;
  long long int a[101000],s=0;
  for(int i=1;i<=n;i++){
  cin>>a[i];s+=a[i];}
  int m;cin>>m;
  while(m--){
  int p,x;
  cin>>p>>x;
  cout<<s+x-a[p]<<endl;}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int a[100001],b[100001];

int main(){
    int na,nb,m;
    cin >> na >> nb >> m;

    int min_a = 10000000,min_b = 10000000;

    for(int i=0;i<na;i++){
        cin >>a[i];
        min_a= min(min_a,a[i]);
    }
    for(int i=0;i<nb;i++){
        cin >> b[i]; min_b = min(min_b,b[i]);
    }

    int ans = min_a+min_b;

    for(int i=0;i<m;i++){
        int x,y,c; cin >> x >> y >> c;
        ans = min(ans,a[x-1]+b[y-1]-c);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, a, b, h);
	out((a + b)*h / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
 
int main(){
  ll X;cin>>X;
  ll ans1,ans2;
  vll v = divisor(X);
  for(int i;i<v.size();++i){
    for(ll j=0;j<1000;++j){
      ll tmp1 = j+v[i];
      ll tmp2 = j-v[i];
      if(pow(j,5)-pow(tmp1,5)==X){
        ans1=j;
        ans2=tmp1;
        break;
      }
      if(pow(j,5)-pow(tmp2,5)==X){
        ans1=j;
        ans2=tmp2;
        break;
      }
    }
  }
  cout<<ans1<<" " <<ans2<<endl;
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

vector<ll> dij(const vector<vector<pi>> &e, int s){
	vector<ll> dist(e.size(), 1e18);
	dist[s] = 0;
	priority_queue<pair<ll, int>> q;
	q.emplace(0, s);
	while(!q.empty()){
		ll co = -q.top().first;
		int cur = q.top().second;
		q.pop();
		if(dist[cur] < co) continue;
		for(pi p : e[cur]){
			ll nxt = co + p.second;
			if(nxt < dist[p.first]){
				q.emplace(-nxt, p.first);
				dist[p.first] = nxt;
			}
		}
	}
	return dist;
}


int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m, s, t; cin >> n >> m >> s >> t; s--; t--;
	vector<vector<pi>> e(n), e2(n);
	rep(i, m){
		int u, v, a, b; cin >> u >> v >> a >> b; u--; v--;
		e[u].emplace_back(v, a);
		e[v].emplace_back(u, a);
		e2[u].emplace_back(v, b);
		e2[v].emplace_back(u, b);
	}
	vector<ll> c1 = dij(e, s);
	vector<ll> c2 = dij(e2, t);
	
	//dbg(c1);dbg(c2);
	
	vector<ll> ans;
	ll best = 1e18;
	for(int i = n - 1; i >= 0; i--){
		best = min(best, c1[i] + c2[i]);
		ans.pb(1e15 - best);
	}
	reverse(all(ans));
	for(ll i : ans) cout << i << endl;
	
	return 0;
}

Measured memory_bytes: 17144
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	int n;
	cin>>n;
	while(n--){
		ll a,b;
		cin>>a>>b;
		ll p=pow(a*b,0.5);
		ll sum=0;
		if(a==b){
			sum+=p*2;
			sum-=2;
		}
		else{
			sum+=p*2;
			sum--;
			if(a*b==p*p){
				sum--;
			}
			if(min(a,b)<=p){
				sum--;
			}
			for(int i=1;i<100000000;i++){
				if((p+i)*(p)<a*b){
					sum++;
				}
				else{
					break;
				}
			}
			
		}
		cout<<sum<<endl;
	} 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type
#define int long long
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define openfile(file)      freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
#define testinput(file)     freopen(file".txt", "r", stdin); 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 1000005, MAXM = 200010;
// code

void Solve() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < s.length(); i++)
    cnt += (int) (s[i] != t[i]);
 cout << cnt;
}

signed main(){
    FAST_IO;
    int TC = 1;
	//cin >> TC;
    while(TC--) Solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
int N,C,D[30][30],cnt[30][30]; 
void solve()
{
	string s;
	int i,j,k,l,r,x,y;
	cin>>N>>C;
	for(y=0;y<C;y++)
	{
		for(x=0;x<C;x++)
			cin>>D[y][x];
	}
	for(y=0;y<N;y++)
	{
		for(x=0;x<N;x++)
		{
			cin>>j;
			cnt[(y+x)%3][j-1]++;
		}
	}
	long long ret=1LL<<60;;
	int a,b,c;
	for(a=0;a<C;a++)
	{
		for(b=0;b<C;b++)
		{
			for(c=0;c<C;c++)
			{
				if(a==b || a==c || b==c)
					continue;
				long long tot=0;
				for(y=0;y<C;y++)
					tot+=cnt[0][y]*D[y][a];
				for(y=0;y<C;y++)
					tot+=cnt[1][y]*D[y][b];
				for(y=0;y<C;y++)
					tot+=cnt[2][y]*D[y][c];
				ret=min(ret,tot);
			}
		}
	}
	cout<<ret<<"\n";
}
int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);   
    string s;
    cin>>s;
    int n=s.length();
    string s0=s;
    reverse(s.begin(),s.end());

    if(s==s0 && s.substr(0,n/2)==s.substr((n+1)/2,n/2)) {
        cout<<"Yes";

    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 5010, mod = 998244353;
vector<int> nm[N], s, g, t;

int add(int x, int y) {
  return (x += y) >= mod ? x - mod : x;
}

int mul(int x, int y) {
  return 1ll * x * y % mod;
}

vector<int> gcd(vector<int> a, vector<int> b) {
  if(a.size() < b.size()) swap(a, b);
  if(!b.size()) return a;
/*  puts("WWWW");
  for(int i = 0; i < a.size(); ++i)
    printf("%d", a[i]);
  puts("");
  for(int i = 0; i < b.size(); ++i)
    printf("%d", b[i]);
  puts("");*/
  int l = a.size() - b.size();
  vector<int> d(a.size());
  for(int i = 0; i < b.size(); ++i)
    d[i + l] = a[i + l] ^ b[i];
  for(int i = 0; i < l; ++i) d[i] = a[i];
  while(d.size() && !d[d.size() - 1]) {
    d.pop_back();
  }
/*  for(int i = 0; i < d.size(); ++i)
    printf("%d", d[i]);
  puts("\nd!");*/
//  assert(0);
  return gcd(b, d);
}

char lx[N];

void solve() {
  if(g.size() > s.size()) {
    puts("1");
    return ;
  }  
  t = s;
  int l = s.size() - g.size() + 1;
  int ls = s.size(), lg = g.size();
  int ans = 0;
  for(int i = ls - 1; i >= lg - 1; --i) {
    ans = add(mul(ans, 2), s[i]);
  }
  ans = add(ans, 1);
//  printf("%d\n", ans);
  for(int i = 0; i < g.size() - 1; ++i) t[i] = 0;
//  puts("XX");
  for(int i = ls - 1; i >= lg - 1; --i) {
    if(t[i]) {
      for(int j = 0; j < g.size(); ++j) {
        t[i - j] ^= g[g.size() - j - 1];
      }
    }
  }
//  puts("WWW");
  for(int i = g.size() - 2; i >= 0; --i)
    if(t[i] > s[i]) {
      ans = add(ans, mod - 1);
      break;
    } else if(t[i] < s[i]) {
      break;
    }
  printf("%d\n", ans);
}

// s[0] * x ^ 0 + s[1] * x ^ 1 + s[2] * x ^ 2 + .. +

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", lx + 1);
  int len = strlen(lx + 1);
  for(int i = len; i >= 1; --i) {
    s.push_back(lx[i] - '0');
  }
  for(int i = 1; i <= n; ++i) {
    scanf("%s", lx + 1);
    len = strlen(lx + 1);
    for(int j = len; j >= 1; --j) {
      nm[i].push_back(lx[j] - '0');
    }
  }
  g = nm[1];
  for(int i = 2; i <= n; ++i)
    g = gcd(g, nm[i]);
/*  for(int i = 0; i < g.size(); ++i)
    printf("%d", g[i]);
  puts("\nggg");*/
  solve(); 
  return 0;
}

Measured memory_bytes: 97792
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
Lsorted = sorted(L)
for i in range(n):
    idx = Lsorted.index(L[i])
    bigger = len([b for b in L[i:] if b<L[i]])
    d[i] = [bigger,idx]
# d= num:[x,y]
# x*k + y*k*(k-1)/2を全てのkeyに対して
res = 0
for key in d:
    [x, y] = d[key]
    res += x*k + y*k*(k-1)//2
print(res % (10**9 + 7))

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;
	template<class T>using pair = std::pair<T, T>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<class Range>void sort(Range& rng)
	{
		std::sort(std::begin(rng), std::end(rng));
	}
	template<class Range, class Pred>void sort(Range& rng, Pred pred)
	{
		std::sort(std::begin(rng), std::end(rng), pred);
	}
}

void Main()
{
	std::size_t H, W, M;
	std::cin >> H >> W >> M;
	std::vector<lib::pair<index_t>> xs(H), ys(W);
	for (auto i : boost::irange(H))
	{
		xs[i].second = i;
	}
	for (auto i : boost::irange(W))
	{
		ys[i].second = i;
	}
	std::set<lib::pair<index_t>> set;
	for (auto _ : boost::irange(M))
	{
		index_t x, y;
		std::cin >> x >> y;
		--x; --y;
		++xs[x].first;
		++ys[y].first;
		set.emplace(x, y);
	}
	lib::sort(xs, std::greater<>());
	lib::sort(ys, std::greater<>());
	auto xmax = xs[0].first;
	auto ymax = ys[0].first;
	for (index_t i = 0; i < H && xs[i].first == xmax; ++i)
	{
		for (index_t j = 0; j < W && ys[j].first == ymax; ++j)
		{
			auto x = xs[i].second;
			auto y = ys[j].second;
			if (!set.count(std::make_pair(x, y)))
			{
				std::cout << xmax + ymax << std::endl;
				return;
			}
		}
	}
	std::cout << xmax + ymax - 1 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 31396
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{

        List<int> a = new List<int>();

        //string[] s = Console.ReadLine().Split(' ');

        // int a = int.Parse(Console.ReadLine());

        while(true)
        {
            int b = int.Parse(Console.ReadLine());
            if (0 == b)
            {
                break; 
            }
            else
            {
                a.Add(b);
            }


        }

        for (int i = 0; i < a.Count;i++)
        {
            Console.WriteLine("Case {0}: {1}",i+1,a[i]);
        }

		//Console.WriteLine("");


	}
}

Measured memory_bytes: 9416
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ary = new ArrayList<>();

    for (int i = 0; i < 3; i++) {
      int input = sc.nextInt();
      ary.add(input);
    }

    int a = ary.get(0);
    int b = ary.get(1);
    int c = ary.get(2);
    Collections.sort(ary);

    for (int j = 0; j < ary.size(); j++) {
      if (j == ary.size() - 1) {
        System.out.println(ary.get(j));
      } else {
        System.out.print(ary.get(j) + " ");
      }
    }
  }
}

Measured memory_bytes: 26104
N = int(input())

a,b,c = list(map(int, input().split()))
ai, bi, ci = 0,1,2

dp = [[0]*3 for _ in range(N)]
dp[0][ai] = a
dp[0][bi] = b
dp[0][ci] = c

for day in range(1, N):
    a,b,c = list(map(int, input().split()))
    dp[day][ai] += max(dp[day-1][bi], dp[day-1][ci]) + a
    dp[day][bi] += max(dp[day-1][ci], dp[day-1][ai]) + b
    dp[day][ci] += max(dp[day-1][ai], dp[day-1][bi]) + c

print(max(dp[-1]))

Measured memory_bytes: 28696