akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var A = sc.ArrayLong(N);
        if (A.Any(i => i == 0)) {
            WriteLine(A.Select(i => Math.Abs(i)).Sum());
            return;
        }

        var cnt = A.Count(v => v < 0);
        var abs = A.Select(v => Math.Abs(v));
        if (cnt % 2 == 0) {
            WriteLine(abs.Sum());
        } else {
            var min = abs.Min();
            WriteLine(abs.OrderBy(val => val).Skip(1).Sum() - min);
        }
    }

}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 30428
#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>;

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

  vector<P> ps(m);
  rep(i, m) ps[i] = make_pair(-c[i], b[i]);
  sort(ps.begin(), ps.end());
  rep(i, m) {
    rep(j, ps[i].second) a.push_back(-ps[i].first);
    if (a.size() >= 2 * n) break;
  }
  sort(a.begin(), a.end(), greater<int>());
  ll ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6332
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <double, double> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

using cd = complex<double> ;
const double PI = acos(-1);

// the concept is to characterize the unbalanced strings. in every unbalanced string there would be an unblanced string of length 2 or 3 of the form XX or XYX
// so basically O(n) solution

int main(){
	string s;
	cin>>s;
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]){
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}
		if(i!=1 && s[i]==s[i-2]){
			cout<<i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
import itertools
import os
import sys

from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


M = int(sys.stdin.buffer.readline())
DC = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]


def test(n):
    round = {str(n)}
    ret = 0
    while round:
        next_round = set()
        for n in round:
            for i in range(len(n) - 1):
                s = n[:i] + str(int(n[i]) + int(n[i + 1])) + n[i + 2:]
                if len(s) > 1:
                    next_round.add(s)
        round = next_round
        print(round)
        ret += 1
    print('test:', ret)
    print()


@lru_cache(maxsize=None)
def solve(n):
    n = str(n)
    if len(n) == 1:
        return 0, int(n)
    num = 0
    ret = 0
    for c in str(n):
        ret += 1
        num += int(c)
        while num >= 10:
            ret += 1
            num = num % 10 + 1
    return ret - 1, num


# ans = 0
# num = 0
# for d, c in DC:
#     if d == 0:
#         ans += c
#         n = num + d * c
#         ans += n // 10
#         num = n % 10
#     if d == 1:
#         ans += c
#         n = num + d * c
#         ans += n // 10
#         num = n % 10
#     if d == 2:
#         ans += c
#         n1 = c // 5
#
#         n
#         n = num + d * c
#         ans += c
#         ans += n // 10
#         num = n % 10

memo = [[None] * 11 for _ in range(10)]
for i, j in itertools.product(range(10), range(11)):
    memo[i][j] = solve(str(i) * j)


def kurikaesi(d, c):
    if c < 10:
        return memo[d][c]
    cnt, n1 = memo[d][10]
    ret = cnt * (c // 10)
    c2, n2 = kurikaesi(n1, c // 10)
    c3, n3 = memo[d][c % 10]
    ret += c2
    ret += c3
    c4, n4 = solve(str(n2) + str(n3))
    ret += c4
    return ret, n4


#
# n = ''
# for d, c in DC:
#     n += str(d) * c
# test(n)
# print(solve(n))

ans = 0
num = 0
for d, c in DC:
    cnt, n = kurikaesi(d, c)
    ans += cnt
    c2, n2 = solve(str(num) + str(n))
    ans += c2
    num = n2
print(ans - 1)


Measured memory_bytes: 79708
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<int,int>

int n,m;
int t[100030];
int x[100030];
int main(){
	cin>>n>>m;	
	rep(i,n)cin>>t[i];
	if(m%2)m--;
	int ma=t[n-1];
	for(int i=n-1;i>=0;i--){
		if(ma<t[i])ma=t[i];
		x[i]=ma;
	}
	int ri=-1,cnt=0;
	rep(i,n)ri=max(ri,x[i]-t[i]);
	rep(i,n)if(ri==x[i]-t[i])cnt++;
	cout<<cnt<<endl;
}


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



int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b<=0){cout<<"No"<<endl;}
    else{
        ll d=c-a-b;
        d=d*d;
        int e=d%4;d/=4;
        if(d>a*b){cout<<"Yes"<<endl;}
        else if(d==a*b && e>0){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int NO = 1000000000;
int main(){
    while(true){
        // miti kazu
        int n;
        cin >> n;
        if(n eq 0) break;
        // miti
        vector<vector<int> > R(10,vector<int>(10,NO));
        // distance
        vector<vector<int> > D(10,vector<int>(10,NO));

        int m = -1;
        for(int i=0;i<n;i++){
            int a,b,c;
            cin >> a >> b >> c;
            R[a][b] = R[b][a] = c;
            m = max(m,max(a,b));
        }

        for(int i=0;i<10;i++){
            R[i][i] = 0;
            D[i][i] = 0;
        }


        m++;
        for(int i=0;i<m;i++){
            for(int j=i+1;j<m;j++){

                // distance where
                priority_queue<pair<int,int> , vector<pair<int,int> > , greater<pair<int,int> > > Q;
                Q.push(mp(0,i));
                vector<char> A(10,false);

                while(!Q.empty()){
                    int dis = Q.top().first;
                    int where = Q.top().second;
                    Q.pop();
                    if(A[where]) continue;
                    A[where] = true;


                    if(where eq j){
                        D[i][j] = D[j][i] = dis;
                        break;
                    }
                    for(int k=0;k<10;k++){
                        if(where eq k) continue;
                        if(R[where][k] not_eq NO){
                            Q.push(mp(R[where][k] + dis,k));
                        }
                    }
                }
            }
        }


        int index_i = -1;
        int sum = NO;
        for(int i=0;i<m;i++){
            int s = 0;
            for(int j = 0;j<m;j++){
                s += D[i][j];
            }
            if(sum > s){
                sum = s;
                index_i = i;
            }
        }

        cout << index_i << " " << sum << endl;
    }
    return 0;
}

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

const int m=1000005;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int ans=m;
  rep(i,100){
    int tp =0;
    rep(j,n){
      int ex=x[j]-(i+1);
      tp+=ex*ex;
    }
    ans=min(ans,tp);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int N = 110;
const ll INF = 1ll << 60;
ll G[25][N][N];
ll cost[N][N];

ll p[55], q[55], r[55];

ll calc(int i, ll d){
	if (i < 0) return 0;
	return r[i] * max(d - q[i], 0ll) + calc(i-1, min(d, q[i]));
}

int main(){
	int n, m, c, s, g;
	while (cin >> n >> m >> c >> s >> g , n|m|c|s|g){
		rep(i, n) rep(j, n) if (i != j) cost[i][j] = INF;
		rep(i, c) rep(j, n) rep(k, n) G[i][j][k] = INF;
		rep(i, m){
			int x, y, d, cc;
			cin >> x >> y >> d >> cc;
			--x, --y, --cc;
			G[cc][x][y] = G[cc][y][x] = min((ll)d, G[cc][x][y]);
		}

		rep(cc, c) rep(i, n) rep(j, n) rep(k, n) G[cc][j][k] = min(G[cc][j][k], G[cc][j][i] + G[cc][i][k]);
		rep(cc, c) cin >> p[cc];
		rep(cc, c){
			rep(i, p[cc]-1) cin >> q[i+1];
			rep(i, p[cc]) cin >> r[i];
			rep(i, n) rep(j, n){
				if (G[cc][i][j] == INF) continue;
				cost[i][j] = min(cost[i][j], calc(p[cc] - 1, G[cc][i][j]));
			}
		}
		rep(i, n) rep(j, n) rep(k, n) cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
		ll ans = cost[s - 1][g - 1];
		if (ans == INF) ans = -1;
		//cout << "***";
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3044
#include <iostream>

using namespace std;

int n;
int a[110];

void show_array() {
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
}


int bubble_sort(int a[], int n) {
  int sw = 0;
  bool flag = 1;
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = n-1; j >= i + 1; j--) {
      if (a[j] < a[j-1]) {
        swap(a[j], a[j-1]);
        //cout << "change" << endl;
        flag = 1;
        sw++;
        show_array();
      }
    }
  }
  return sw;
}

int my_bubble_sort(int a[], int n) {
  int sw = 0;
  bool can_continue = true;
  int j = 0;
  while(can_continue) {
    can_continue = false;
    //cout << j << "----" << endl;
    for (int i = n-1; i > j; i--) {
      int tmp = a[i];
      //cout << tmp << endl;
      //cout << "a[i]" << a[i] << ", a[i-1]" << a[i-1] << endl;
      if (a[i] < a[i-1]) {
        a[i] = a[i-1];
        a[i-1] = tmp;
        can_continue = true;
        sw++;
      }
    }
    j++;
    //show_array();
  }
  return sw;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sw = my_bubble_sort(a, n);
  show_array();
  cout << sw << endl;
  return 0;
  cout << "-------" << endl;

  show_array();
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static int H = 0;
    public static int[] heap = new int[2000000];
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        while(true) {
            String cmd = input.next();
            if(cmd.equals("insert")) {
                int key = Integer.parseInt(input.next());
                insert(key);
            } else if(cmd.equals("extract")){
                System.out.println(extract());
            } else if(cmd.equals("end")){
                break;
            }
        }
    }
    public static void insert(int key) {
        H++;
        heap[H] = Integer.MIN_VALUE;
        heapIncreaseKey(H, key);
    }
    public static void heapIncreaseKey(int i, int key) {
        if(key < heap[i]) return;
        heap[i] = key;
        while( i > 1 && heap[i/2] < heap[i]) {
            int temp = heap[i];
            heap[i] = heap[i/2];
            heap[i/2] = temp;
            i = i/2;
        }
    }
    public static int extract() {
        int max;
        if (H < 1) return Integer.MIN_VALUE;
        max = heap[1];
        heap[1] = heap[H--]; // 取出最大值，将最后一个元素置于堆顶
        maxHeapify(1);
        return max;
    }
    public static void maxHeapify(int i) {
        int left = 2*i;
        int right = 2*i + 1;
        int largest;
        if(left <= H && heap[left] > heap[i]) {
            largest = left;
        } else {
            largest = i;
        }
        if(right <= H && heap[right] > heap[largest]) {
            largest = right;
        }

        if(largest != i) {// i的子节点值更大时
            int temp = heap[i];
            heap[i] = heap[largest];
            heap[largest] = temp;
            maxHeapify(largest);
        }
    }
}



Measured memory_bytes: 301240
from collections import deque

n,q = map(int,input().split())
queue = deque([])

for i in range(n):
  name,time = input().split()
  time = int(time)
  queue.append([name,time])

t = 0
while len(queue) > 0:
  top = queue.popleft()
  spend = min(top[1], q)
  top[1] -= spend
  t += spend
  if top[1] == 0:
    print(top[0], t)
  else:
    queue.append(top)



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  ll minR=INF,maxL=0;
  rep(i,m){
    ll l,r; cin>>l>>r;
    chmin(minR,r);
    chmax(maxL,l);
  }
  ll ans=minR-maxL+1;
  if(ans<0) cout<<0<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 256
N,M,Q=map(int,input().split())
abcd=[]
for i in range(Q):
    abcdabcd=list(map(int,input().split()))
    abcd.append(abcdabcd)
#入れるAはリスト、[]で表現
def cal(A):
    t=0
    for abcdi in abcd:
        a=abcdi[0]
        b=abcdi[1]
        c=abcdi[2]
        d=abcdi[3]
        if A[b-1]-A[a-1]==c:
            t+=d
    return t

maxi=0
for i in range(1,M+1):
    if N==1:
        maxi=max(maxi,cal([i]))
    for j in range(i,M+1):
        if N==2:
            maxi=max(maxi,cal([i,j]))
        for k in range(j,M+1):
            if N==3:
                maxi=max(maxi,cal([i,j,k]))
            for l in range(k,M+1):
                if N==4:
                    maxi=max(maxi,cal([i,j,k,l]))
                for m in range(l,M+1):
                    if N==5:
                        maxi=max(maxi,cal([i,j,k,l,m]))
                    for n in range(m,M+1):
                        if N==6:
                             maxi=max(maxi,cal([i,j,k,l,m,n]))
                        for o in range(n,M+1):
                            if N==7:
                                maxi=max(maxi,cal([i,j,k,l,m,n,o]))
                            for p in range(o,M+1):
                                if N==8:
                                    maxi=max(maxi,cal([i,j,k,l,m,n,o,p]))
                                for q in range(p,M+1):
                                    if N==9:
                                        maxi=max(maxi,cal([ij,k,l,m,n,o,p,q]))
                                    for r in range(q,M+1):
                                        if N==10:
                                            maxi=max(maxi,cal([i,j,k,l,m,n,o,p,q,r]))
                                        

print(maxi)    

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

using namespace std;

const long long MOD = (long long)1e9 + 7;
int N, k;
int arr[2004];

long long SUM(long long x){
    return (x + 1) * x / 2;
}

int main(){
    long long ans = 0;
    scanf("%d %d", &N, &k);
    for(int i = 1; i <= N; ++i) scanf("%d", arr + i);
    for(int i = 1; i <= N; ++i){
        for(int j = i + 1; j <= N; ++j){
            if(arr[i] > arr[j]) ans = (ans + SUM(k)) % MOD;
            else if(arr[i] < arr[j]) ans = (ans + SUM(k - 1)) % MOD;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    long long a[200], b[200];

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    for(int i = 0;i < n;i++){
        cin >> b[i];
    }

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

    for(int i = n-1;i > 0;i--){
        b[i-1] += b[i];
    }

    long long ans = 0;
    for(int i = 0;i < n;i++){
        ans = max(ans, a[i] + b[i]);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX_N 101
#define MAX_W 10001
using namespace std;

int v[MAX_N], w[MAX_N];
int dp[MAX_N][MAX_W];

void solve(int N, int W) {
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] < 0) dp[i][j] = dp[i - 1][j];
      else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
    }
  }
  cout << dp[N][W] << endl;
}

void init() {
  for (int i = 0; i < MAX_N; i++) {
    v[i] = 0;
    w[i] = 0;
    for (int j = 0; j < MAX_W; j++) {
      dp[i][j] = 0;
    }
  }
}

int main() {
  init();
  int N, W;
  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> v[i] >> w[i];
  }

  solve(N, W);

  return 0;
}

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

int main() {
  char a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if(a == f && c == d && b == e){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}




Measured memory_bytes: 384
N = int(input())
X = list(input())

pop = [0]*(N+1)
amari = [0]*(N+1)
for i in range(1,N+1):
    pop[i]=pop[i-(i&(-i))]+1
    amari[i] = amari[i%pop[i]]+1

cnt1 = 0
for i in range(N):
    if X[i]=="1":
        cnt1+=1
Y = cnt1+1
Z = cnt1-1

baseY = 0
baseZ = 0
for i in range(N):
    K = int(X[N-1-i])
    if K==1:
        baseY += pow(2,i,Y)
        if Z!=0:
            baseZ += pow(2,i,Z)
        else:
            baseZ =-1
baseY = baseY%Y
if Z!=0:
    baseZ = baseZ%Z
else:
    baseZ = -1

for i in range(N):
    if X[i]=="0":
        out = (baseY + pow(2,N-1-i,Y))%Y
        print(amari[out]+1)
    elif X[i]=="1":
        if Z!=0:
            out = (baseZ - pow(2,N-1-i,Z))%Z
            print(amari[out]+1)
        else:
            print(0)

Measured memory_bytes: 86268
#include <stdio.h>
#include <stdlib.h>

main()
{
  for (;;) {
    int r, w, col, row;
    
    scanf("%d%d%d%d", &r, &w, &col, &row);
    if (r == 0 && w == 0 && col == 0 && row == 0) break ;
    
    if (w * col <= r)
      puts("0");
    else
      printf("%d\n", (w * col - r) / row + !!((w * col - r) % row));
  }  

  return EXIT_SUCCESS;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());

    int r = a[0];
    rep(i, 1, n) {
        if (a[i] == max) continue;
        if (abs((double)r-(double)max/2.0) > abs((double)a[i]-(double)max/2.0)) r = a[i];
    }

    cout << max << " " << r << endl;
}

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

const int MAX_N = 100000 + 1111;

vector<int> neib[MAX_N];

void add_edge ( int a , int b ) {
  neib[a].push_back ( b );
  neib[b].push_back ( a );
}




int ans = 0;


// root is not leaf!!!

int single_leafs[MAX_N];
bool have_radio[MAX_N];


void clear() {
  ans = 0;
  memset ( single_leafs , 0 , sizeof single_leafs );
  memset ( have_radio , 0 , sizeof have_radio );
}

void DFS( int v , int p = -1 ) {
  
  
  int soons_cnt = 0;
  
  for ( auto x : neib[v] ) {
    if ( x != p ) {
      soons_cnt++;
      DFS ( x , v );
      have_radio[v] = have_radio[v] or have_radio[x];
      
      if ( !have_radio[x] and ( single_leafs[x] == 1 ) )
        single_leafs[v] += single_leafs[x];
    }
  }
  
  if ( soons_cnt == 0 ) {
    // this is leaf
    single_leafs[v] = 1;
  }
  
  
  //cout << "DFS(" << v << "," << p <<  ") " << single_leafs[v] << " sl;ans " << ans << endl;
  
  if ( single_leafs[v] > 1 ) {
    ans += single_leafs[v] - 1;
    single_leafs[v] = 0;
    have_radio[v] = true;
  }
  
}

int main() {
  int n;
  scanf("%d",&n);
  for ( int i = 1 ; i < n ; i++ ) {
    int a,b;
    scanf("%d %d", &a, &b);
    add_edge ( a+1 , b+1 );
    //cout << a + 1 << " " << b + 1 << endl;
  }
  
  int leaf = 0;
  
  for ( int i = 1 ; i <= n ; i++ ) {
    if ( neib[i].size() < 2 ) {
      leaf++;
    }
  }
  
  int minimal_ans = 0;
  int iter_cnt = 32;
  
  for ( int i = 1 ; i <= n ; i++ ) {
    if ( neib[i].size() >= 2 ) {
      clear();
      DFS ( i );
      //cout << "i = " << i << " ans = " << ans << endl;
      minimal_ans = max ( minimal_ans , ans );
      iter_cnt--;
      if ( iter_cnt == 0 ) {
        break;
      }
    }
  }
  
  if ( leaf == 2 ) {
    printf ( "1\n" );
  }
  else {
    printf ( "%d\n", minimal_ans );
  }
  
  
  return 0;
}


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

using namespace std;

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

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

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

    priority_queue<pair<ll, int>> q;
    priority_queue<pair<ll, int>,vector<pair<ll, int>>,greater<pair<ll, int>>> e;
    int t; ll d;
    FOR(i, 0, n) {
        cin >> t >> d;
        q.push({ d,--t });
    }

    VI sel(n);
    ll sum = 0, kind = 0;
    FOR(i, 0, k) {
        tie(d, t) = q.top(); q.pop();
        sum += d;
        if (!sel[t])kind++;
        sel[t]++;
        if (sel[t] > 1)e.push({ d,t });
    }
    ll ans = sum + kind * kind;

    int Et; ll Ed;
    FOR(i, 0, n - k) {
        tie(d, t) = q.top(); q.pop();
        if (sel[t] || e.empty())continue;
        tie(Ed, Et) = e.top(); e.pop();

        sum += d - Ed;
        sel[t]++, kind++;
        chmax(ans, sum + kind * kind);
    }
    cout << ans << "\n";
}


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

const int INFTY =1<<21;

int L[50000],R[50000];

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1] =R[n2]=INFTY;
    int i=0,j=0;
    for(int p=left;p<right;p++){
        if(L[i]<=R[j]) A[p]=L[i++];
        else A[p]=R[j++];
    }
}

void sort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left + right)/2;
        sort(A,left,mid);
        sort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    int n;
    double ans;
    int A[100];
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    sort(A,0,n);
    ans=A[0];
    for(int i=1;i<n;i++){
        ans+=A[i];
        ans=ans/2.0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/* Written in FCP - alpha version */
#ifdef false
/* Original code */
$i
n:int k:int
a:vi:n
$p
int l=1, r=pow(10, 9), ans
while l<=r {
    int m=(l+(r-l)/2)
    ll moves=0
    i:0..n {
        moves += (int)ceil((double)a[i]/m)-1
    }
    if moves <= k {
        r = m-1
        ans = m
    } {
        l = m+1
    }
}
<<ans
#endif
/* Transpiled code */

#include <bits/stdc++.h>

#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second

using namespace std;

using str = string;
using uint = unsigned int;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<str>;
using vvs = vector<vector<str>>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<typename T>
std::ostream& operator<<(std::ostream& s, std::vector<T> t) {
    for (int i = 0; i < sz(t); i++) {
        s << t[i] << (i == sz(t) - 1 ? "" : " ");
    }
    return s;
}



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

    
        int n;
cin >> n;
int k;
cin >> k;
vi a(n);
for (int __i = 0; __i < n; __i++) {
cin >> a[__i];
}
int l=1, r=pow(10, 9), ans;
while (l<=r) {
    int m=(l+(r-l)/2);
    ll moves=0;
for (int i = 0; i < n ; ++i) {
        moves += (int)ceil((double)a[i]/m)-1;
    };
    if (moves <= k) {
        r = m-1;
        ans = m;
} else {
        l = m+1;
    };
};
cout <<ans;
        goto end_tc_label;
        end_tc_label:;
    
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
char a[100][101],b[102][102];

int main() {
  int H,W;
  cin >> H >> W;

  for (int i=0; i < H; i++) cin >> a[i];

  for (int i=0; i < H+2; i++)
    for (int j=0; j < W+2; j++) b[i][j] = '#';

  for (int i=0; i < H; i++)
    for (int j=0; j < W; j++) b[i+1][j+1] = a[i][j];

  for (int i=0; i < H+2; i++){
    for (int j=0; j < W+2; j++) cout << b[i][j];
    cout << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int temp;

	temp = A;
	A = B;
	B = temp;

	temp = A;
	A = C;
	C = temp;

	cout << A  << " " << B << " " << C;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
//ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
int a[n][3];
for(int i=0;i<n;i++)
cin>>a[i][0]>>a[i][1]>>a[i][2];
int dp[n][3];
dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
for(int i=1;i<n;i++)
{
    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 4992
s = input()
K = int(input())

r = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        x = s[i:j]
        r.append(x)
        if len(x) == 5:
            break

x = sorted(list(set(r)))
print(x[K-1])

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

using namespace std;

int main(){
  string s;
  int flg=0;
  int cnt=0;

  cin >> s;

  for(int i=0;i < s.size();i++)
    {
      if(s[i] == 'A' && flg == 0)
	{
	  flg=1;
	}
      if(s[i] == 'Z' && flg == 1)
	{
	  flg=0;
	  cnt++;
	}
    }
  if(cnt >= 1)
    {
      for(int j=0;j < cnt;j++)
	{
	  cout << "AZ";
	}
    }
  else
    {
      cout << "-1";
    }
  cout << endl;
}
      
      


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
typedef long long ll;
pii inter[111111];
int minsuf[111111];
int main()
{
    int n;scanf("%d",&n);
    pii lmax={-1,0},rmin={1e9+7,0};
    rep(i,1,n+1)
        scanf("%d%d",&inter[i].first,&inter[i].second),
        lmax=max(lmax,{inter[i].first,i}),rmin=min(rmin,{inter[i].second,i});
    int maxlen=-1;
    rep(i,1,n+1)if(i!=lmax.second&&i!=rmin.second)
        maxlen=max(maxlen,inter[i].second-inter[i].first+1);
    ll res=max(0,rmin.first-lmax.first+1)+maxlen;
    if(lmax.second!=rmin.second)
    {
        int maxl=-1;
        sort(inter+1,inter+n+1);
        minsuf[n+1]=1e9+7;
        for(int i=n;i;i--)minsuf[i]=min(minsuf[i+1],inter[i].second);
        rep(i,1,n)
        {
            maxl=max(maxl,inter[i].first);
            res=max(res,max(0,rmin.first-maxl+1)+0ll+max(0,minsuf[i+1]-lmax.first+1));
        }
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 1408
// #pragma GCC target("avx2")  // CPU 処理並列化
 // #pragma GCC optimize("O3")  // CPU 処理並列化
 // #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[210000];
int L[210000];
int R[210000];
int segtree[2][524288];
int query(int a,int b,int c,int d,int e,int f){
	if(c>d)return -mod;
	if(d<a||b<c)return -mod;
	if(c<=a&&b<=d)return segtree[f][e];
	return max(query(a,(a+b)/2,c,d,e*2,f),query((a+b)/2+1,b,c,d,e*2+1,f));
}
void update(int a,int b,int c){
	a+=262144;
	while(a){
		segtree[c][a]=max(segtree[c][a],b);
		a/=2;
	}
}
 
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<524288;i++)for(int j=0;j<2;j++)segtree[j][i]=-mod;
	for(int i=0;i<a;i++){
		update(i,p[i],0);
		update(i,-p[i],1);
	}
	int cur=0;
	for(int i=0;i<a;i++){
		if(i==0||p[i]>p[i-1])cur++;
		else cur=1;
		R[i]=cur;
	}
	cur=0;
	for(int i=a-1;i>=0;i--){
		if(i==a-1||p[i]<p[i+1])cur++;
		else cur=1;
		L[i]=cur;
	}
	set<pair<int,int> > S;
	for(int i=0;i<=a-b;i++){
		if(L[i]>=b){
			S.insert(make_pair(-1,-1));continue;
		}
		int left=0;
		int right=min(b,L[i])+1;
 
		while(left+1<right){
			int M=(left+right)/2;
			int las=p[i+M-1];
			int tmp=-query(0,262143,i+M,i+b-1,1,1);
			if(las<tmp)left=M;else right=M;
		}
 
		int st=i+left;
		left=0;
		right=min(R[i+b-1],b)+1;
		while(left+1<right){
			int M=(left+right)/2;
			int las=p[i+b-M];
			// printf("%d: %d\n",M,las);
			int tmp=query(0,262143,i,i+b-M-1,1,0);
			if(las>tmp)left=M;else right=M;
		}
 
 
		int en=i+b-1-left;
		 // printf("%d %d\n",st,en);
		S.insert(make_pair(st,en));
	}
	printf("%d\n",(int)S.size());
}

Measured memory_bytes: 16128
from collections import deque


def shell_sort(arr, n):
    def insertion_sort(arr, n, dist):
        nonlocal cnt
        for right_idx in range(dist, n):
            right_val = arr[right_idx]
            left_idx = right_idx - dist
            while left_idx >= 0 and arr[left_idx] > right_val:
                arr[left_idx + dist] = arr[left_idx]
                left_idx -= dist
                cnt += 1
            arr[left_idx + dist] = right_val
    cnt = 0
    dists = deque()
    dist = 1
    while dist <= n:
        dists.appendleft(dist)
        dist = dist * 3 + 1
    dists = list(dists)
    m = len(dists)

    for i in range(m):
        insertion_sort(arr, n, dists[i])

    return m, dists, cnt


def main():
    n = int(input())
    arr = [int(input()) for _ in range(n)]
    m, dists, cnt = shell_sort(arr, n)
    print(m)
    print(" ".join(list(map(str, dists))))
    print(cnt)
    for i in arr:
        print(i)


if __name__ == "__main__":
    main()



Measured memory_bytes: 45900
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    while (k > 0 && (a >= b || b >= c)) {
      if (a >= b) {
        b = b * 2;
        k--;
        continue;
      }
      if (b >= c) {
        c = c * 2;
        k--;
        continue;
      }
    }
    pw.println(
      (a < b && b < c) ? "Yes" : "No"
    );
  }
}


Measured memory_bytes: 35668
#if 0
2020.03.25

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 1010;
char s[maxn][maxn];

void solve3 (int i, int j) {
	s[i][j] = s[i][j + 1] = s[i + 1][j + 2] = s[i + 2][j + 2] = 'e';
}

void solve2_a (int i, int j) {
	s[i][j] = s[i][j + 1] = 'a';
	s[i + 1][j] = s[i + 1][j + 1] = 'b';
}

void solve2_b (int i, int j) {
	s[i][j] = s[i + 1][j] = 'c';
	s[i][j + 1] = s[i + 1][j + 1] = 'd';
}

void solve_even (int i, int j, int k) {
	for (int l = 0; l < k; l ++)
		solve2_a(i + l * 2, j + l * 2);
	for (int l = 0; l < k - 1; l ++)
		solve2_b(i + l * 2 + 2, j + l * 2);
	solve2_b(i, j + k * 2 - 2);
}

/* void solve9 (int i, int j) { */
/* 	for (int x = 0; x < 3; x ++) */
/* 		for (int y = 0; y < 3; y ++) */
/* 			solve3(i + x * 3, j + y * 3); */
/* } */

void solve5 (int i, int j) {
	char t[10][10] = {
		".ijjl",
		"fi..l",
		"f.ppm",
		"hho.m",
		"ggonn",
	};
	for (int x = 0; x < 5; x ++)
		for (int y = 0; y < 5; y ++)
			s[i + x][j + y] = t[x][y];
}

void solve7 (int i, int j) {
	char t[10][10] = {
		"a...lmm",
		"a.nnl..",
		".b..jkk",
		".b..ji.",
		"ccd..i.",
		"..dgg.h",
		"eeff..h",
	};
	for (int x = 0; x < 7; x ++)
		for (int y = 0; y < 7; y ++)
			s[i + x][j + y] = t[x][y];
}

int main () {
	int n = read;
	for (int i = 1; i <= n; i ++)
		std::fill(s[i] + 1, s[i] + n + 1, '.');

	if (n == 2) return puts("-1"), 0;

	if (n == 5)
		solve5(1, 1);
	else if (n == 7)
		solve7(1, 1);
	else if (n % 3 == 0)
		for (int i = 1; i <= n; i += 3)
			solve3(i, i);
	else if (n % 2 == 0)
		solve_even(1, 1, n / 2);
	else {
		solve5(1, 1);
		solve_even(6, 6, (n - 5) / 2);
	}

	for (int i = 1; i <= n; i ++)
		puts(s[i] + 1);
}


Measured memory_bytes: 2176
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
	  #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
      }
	
int main()
{   
   //sublime();
   ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   
	  ll n,i;
	    string str;
	    cin>>str;
	    ll ans=0;
	    ll var=0;
	    for(i=0; i<str.length(); i++)
	    {
           if(str[i]=='R')
           {
           	var++;
           }
           else
           {
           	 ans=max(var,ans);
           	 var=0;
           }
	    }
	    ans=max(ans,var);
	    cout<<ans;

	return 0;
}

Measured memory_bytes: 3608
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


s = input()
t = input()
dif = 0
for i in range(len(s)):
    if s[i] != t[i]:
        dif += 1

print(dif)


Measured memory_bytes: 68932
using System;

namespace AOJ.Volume0
{
    public class BloodGroups
    {
        public static int Main()
        {
            int a = 0;
            int b = 0;
            int ab = 0;
            int o = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                string type = input.Substring(input.IndexOf(',') + 1);
                switch (type)
                {
                    case "A":
                        a++;
                        break;
                    case "B":
                        b++;
                        break;
                    case "O":
                        o++;
                        break;
                    case "AB":
                        ab++;
                        break;
                }
            }

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(ab);
            Console.WriteLine(o);
            return 0;
        }
    }
}

Measured memory_bytes: 9144
import Control.Applicative

main = do
  [a,b,c] <- map (read :: String -> Int) . words <$> getLine
  let residues = map (mod c) [a..b]
  let divisables = map (fromEnum :: Bool -> Int) $ map (== 0) residues
  putStrLn $ show $ foldr (+) 0 divisables




Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
struct node {
	int l, r;
}a[maxn];

bool cmp(node a, node b) {
	return a.r > b.r;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].l >> a[i].r;
	}
	sort (a + 1, a + n + 1, cmp);
	int mm = 2e9;
	for (int i = 1; i <= n; i++) {
		mm = min(mm, a[i].r);
		mm = min(mm, mm - a[i].l);
	}
	if (mm < 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int L = S.size();
 string ans = "AC";
 if(S[0] != 'A'){
 ans = "WA";
}
 int cnt = 0;
 for(int i = 1; i < L; ++i){
 if(isupper(S[i])){
 if(i == 1 || i == L - 1 || S[i] != 'C'){
 ans = "WA";
 }
 ++cnt;
 }
 }
 if(cnt != 1){
 ans = "WA";
 }
 cout << ans << endl;
 }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double n = Integer.parseInt(sc.nextLine());
        if(n % 2 == 0)  System.out.println(n / 2 / n);
        else    System.out.println(((int)(n / 2) + 1) / n);
    }
}

Measured memory_bytes: 23636
from sys import stdin


def main():
    _ = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]
    z = 0

    for a in a_lists:
        z ^= a

    if z == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

   

Measured memory_bytes: 14212
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int days = input.nextInt();
		int A = input.nextInt();
		long sum = 0;
		boolean valid = true;
		for (int i = 0; i < A; i++) {
			sum+=input.nextInt();
			if (sum>days) {
				valid = false;
				break;
			} 
		}
		System.out.println(valid?(days-sum):-1);
	}
}

Measured memory_bytes: 37296
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

p = p[:x]
q = q[:y]
a = p + q + r 
a = sorted(a, reverse=True)
print(sum(a[:(x+y)]))

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ull ans = 0;
ll sum = 0;
ll cnt = 0;
ull cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll a, ll p) {
    if (p == 0) return 1;
    if (p == 1) return a;
    if (p % 2 == 0) return ((mod_pow(a, (p / 2)) % MOD) * (mod_pow(a, (p / 2)) % MOD)) % MOD;
    return (a * (mod_pow(a, p - 1) % MOD)) % MOD;
}

int main() {
    cin >> n;
    bool is_even = n % 2 == 0;

    map<ll, ll> m;
    NREP() {
        cin >> tmp;
        if ((is_even && tmp % 2 == 0) || (!is_even && tmp % 2 != 0)) {
            END(0)
        }
        if (tmp == 0) {
            if (m[tmp] >= 1) {
                END(0)
            }
        } else {
            if (m[tmp] >= 2) {
                END(0)
            }
        }
        m[tmp]++;
    }

    MSG(mod_pow(2, n / 2) % MOD)
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	ll sum = 0;
	vector<ll>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum ^= A[i];
	}
	ll ans = 0;
	ans += sum;
	for (int i = 0; i < N; i++)A[i] -= (A[i]&sum);
	//このもとでsubsetのxorの最大値を求める

	//掃き出し法
	int r = 0;
	for (int i = 60; i >= 0; i--) {
		int ok = 0;
		for (int j = r; j < N; j++) {
			if (A[j] >> i & 1) {
				swap(A[r],A[j]);
				ok = 1;
				break;
			}
		}
		if (ok) {
			for (int j = 0; j < N; j++) {
				if (j == r)continue;
				if(A[j] >> i & 1)A[j] = A[j] ^ A[r];
			}
			r++;
		}
	}

	ll x = 0;
	for (int i = 0; i < N; i++)x ^= A[i];
	ans += 2LL*x;
	puts(ans);

	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func group(x int) int {
	switch x {
	case 1: fallthrough
	case 3: fallthrough
	case 5: fallthrough
	case 7: fallthrough
	case 8: fallthrough
	case 10: fallthrough
	case 12:
		return 1
	case 4: fallthrough
	case 6: fallthrough
	case 9: fallthrough
	case 11:
		return 2
	case 2: 
		return 3
	}
	return 0
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	var res string
	if group(a) == group(b) {
		res = "Yes"
	} else {
		res = "No"
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  int A,B;
  cin>>A>>B;
  if((A+B)%2==0)
  {
      cout<<(A+B)/2<<endl;
  }
  else
  {
      cout<<"IMPOSSIBLE"<<endl;
  }

return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n,m,sumt=0;
  cin >> n;
  vll t(n);
  for (ll i=0;i<n;i++) {
    cin>>t[i];
    sumt += t[i];
  }
  cin>>m;
  vll p(m),x(m);
  for (ll i=0;i<m;i++) {
    cin>>p[i]>>x[i];
    cout<<sumt-t[p[i]-1]+x[i]<<endl;
  }
}

Measured memory_bytes: 256