akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>

long long a,b,d;

long long extgcd(long long a,long long b,long long &x,long long &y)
{
    long long d=a;
    if(b){
        d=extgcd(b,a%b,y,x);
        y-=(a/b) * x;
    }
    else{
        x=1,y=0;
    }
    return d;
}

long long ab(long a)
{
    return (a<0)?-a:a;
}

long long f(long long la,long long lb)
{
    return ab(la) + ab(lb);
}

long long fun(long long la,long long lb)
{
    return a*ab(la) + b*ab(lb);
}

int main()
{
    while(~scanf("%lld%lld%lld",&a,&b,&d),a+b+d)
    {
        long long x,y;
        long long gcd = extgcd(a,b,x,y);
        long long k =  d/gcd;
        x *= k; y *= k;
        //printf("%lld %lld\n",x,y);

        long long dx = b/gcd;
        long long dy = a/gcd;

        long long mina = f(x,y), minb = f(x,y);

        long long t1 = 0,t2 = 0;
        long long sum1 = -1,sum2 = -1;

        for(long long k1=1;;k1++)
        {
           // printf("1: %lld -> f(%lld,%lld) = %lld\n",k1,x+k1*dx,y-k1*dy,f(x+k1*dx,y-k1*dy));
            if(f(x+k1*dx,y-k1*dy)>mina)
                break;
            else if(f(x+k1*dx,y-k1*dy)<mina)
            {
                mina = f(x+k1*dx,y-k1*dy);
                sum1 = fun(x+k1*dx,y-k1*dy);
                t1 = k1;
            }
            else
            {
                if(a*ab(x+k1*dx)+b*ab(y-k1*dy)<sum1)
                {
                    mina = f(x+k1*dx,y-k1*dy);
                    sum1 = fun(x+k1*dx,y-k1*dy);
                    t1 = k1;
                }
            }
        }
        int cnt = 0;
        for(long long k2=1;;k2++)
        {
            //printf("2: %lld -> f(%lld,%lld) = %lld\n",k2,x-k2*dx,y+k2*dy,f(x-k2*dx,y+k2*dy));
            if(f(x-k2*dx,y+k2*dy)>minb)
                break;
            else if(f(x-k2*dx,y+k2*dy)<minb)
            {
                minb = f(x-k2*dx,y+k2*dy);
                t2 = k2;
                sum2 = fun(x-k2*dx,y+k2*dy);
            }
            else
            {
                if(a*ab(x-k2*dx)+b*ab(y+k2*dy)<sum2)
                {
                    minb = f(x-k2*dx,y+k2*dy);
                    t2 = k2;
                    sum2 = fun(x-k2*dx,y+k2*dy);
                }
            }
        }

        //printf("%lld %lld %lld %lld\n",mina,minb,t1,t2);
        if(minb<mina)
        {
            printf("%lld %lld\n",ab(x-t2*dx),ab(y+t2*dy));
        }
        else if(minb>mina)
        {
            printf("%lld %lld\n",ab(x+t1*dx),ab(y-t1*dy));
        }
        else
        {
            if(a*ab(x+t1*dx)+b*ab(y-t1*dy)>a*ab(x-t2*dx)+b*ab(y+t2*dy))
                printf("%lld %lld\n",ab(x-t2*dx),ab(y+t2*dy));
            else
                printf("%lld %lld\n",ab(x+t1*dx),ab(y-t1*dy));
        }
    }
    return 0;
}

/*

1 4733 35498

*/

Measured memory_bytes: 1028
package main

import "fmt"

func main() {
	var(
		N,A,B int
	)
	fmt.Scan(&N, &A, &B)
	q := N / (A + B)
	r := N % (A + B)
	var lasta int
	if r < A {
		lasta = r
	} else {
		lasta = A
	}
	fmt.Println(q*A + lasta)
}


Measured memory_bytes: 512
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int A, B;
    cin >> A >> B;
    if (A <= 5) {
        cout << 0 << endl;
    } else if (A >= 6 && A <= 12) {
        cout << B / 2 << endl;
    } else {
        cout << B << endl;
    }

    return 0;
}

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


int main()
{
    ll a,b,c,x,y,d,p,k,i;

    ll num[5];
    for(i=0;i<3;i++)
    {
        cin>>num[i];
    }
    sort(num,num+3);
    d=num[2]*10+num[1];
    d=d+num[0];
    cout<<d<<endl;


    return 0;
}





Measured memory_bytes: 256
# coding:utf-8

import itertools

N = int(input())

ans = 0
for i in range(2, len(str(N))):
    for s in itertools.product('753', repeat=i+1):
        if int(''.join(s)) > N:
            continue
        if all(s.count(c) > 0 for c in '753'):
            ans += 1

print(ans)


Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline
def main():
    N = int(input())
    S = list(input().rstrip().decode())

    c = lambda x: ord(x) - ord('a')
    tree = [SegmentTree(N, lambda x,y:x|y) for _ in range(26)]
    for i, l in enumerate(S):
        tree[c(l)].update(i, 1)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().rstrip().decode().split()
        if t == '1':
            a = int(a) - 1
            tree[c(S[a])].update(a, 0)
            tree[c(b)].update(a, 1)
            S[a] = b
        else:
            a, b = int(a)-1, int(b)-1
            ans = 0
            for i in range(26):
                t = tree[i].query(a, b+1)
                ans += 1 if t else 0
            print(ans)

class SegmentTree:
    def __init__(self, n=None, f=max, zero_factory=int, converter=lambda x:x, initial_values=None):
        assert(n or initial_values)
        size = n if n else len(initial_values)
        self.__f, self.__z, self.__c = f, zero_factory, converter
        self.__n = 1 << ((size - 1).bit_length())
        self.__dat = [zero_factory() for _ in range(2 * self.__n)]
        if initial_values:
            zi = self.__get_leaf(0)
            for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
            for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))

    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))

    def query(self, from_inclusive, to_exclusive):
        ans = self.__z()
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 436016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

struct XY{
    ll x,y,count=0;
};

int main()
{
    ll H,W,Ch,Cw,Dh,Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    struct XY start={Ch-1,Cw-1};
    struct XY goal={Dh-1,Dw-1};

    const ll HH=H,WW=W;
    char S[HH][WW];
    F(i,0,H){
        F(j,0,W){
            cin >> S[i][j];
        }
    }

    bool seen[HH][WW];
    F(i,0,H){
        F(j,0,W){
            seen[i][j]=false;
        }
    }

    deque<struct XY> q;
    q.push_front(start);

    ll min[HH][WW];
    F(i,0,H){
        F(j,0,W){
            min[i][j]=H*W+1;
        }
    }
    while(!q.empty()){
        struct XY r=q.front(); q.pop_front();

        if(min[r.x][r.y] > r.count){
            min[r.x][r.y] = r.count;
        }
        else if(seen[r.x][r.x]){
            continue;
        }
        seen[r.x][r.x]=true;

        F(i,-2,3){
            F(j,-2,3){
                struct XY r2={r.x+i,r.y+j,r.count};

                if(r2.x<0 || H<=r2.x || r2.y<0 || W<=r2.y || S[r2.x][r2.y]=='#' || i==0 && j==0)
                    continue;
                if(i==-1 && j==0 || i==0 && j==1 || i==1 && j==0 || i==0 && j==-1){
                    q.push_front(r2);
                    continue;
                }

                ++r2.count;
                q.push_back(r2);
            }
        }
    }

    if(min[goal.x][goal.y] != H*W+1) cout << min[goal.x][goal.y] << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 15644
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(N);
    rep(i, N) cin >> X[i];

    sort(all(X));

    vv<int> cnt_modM(M);

    for (int i = 0, j; i < N; i = j) {
        for (j = i + 1; j < N && X[j] == X[i]; ++j);
        cnt_modM[X[i] % M].push_back(j - i);
    }

    int ans = 0;

    // 0(mod. M)
    ans += accumulate(all(cnt_modM[0]), 0) / 2;

    // M/2 (mod. M) M=2n
    if (M % 2 == 0) {
        ans += accumulate(all(cnt_modM[M / 2]), 0) / 2;
    }

    rep(i, 1, (M + 1) / 2) {
        int cnt0 = accumulate(all(cnt_modM[i]), 0);
        int cnt1 = accumulate(all(cnt_modM[M - i]), 0);

        if (cnt0 > cnt1) {
            int selfpair = 0;
            for (int c : cnt_modM[i]) {
                selfpair += c / 2;
            }
            ans += cnt1 + min(selfpair, (cnt0 - cnt1) / 2);
        }
        else {
            int selfpair = 0;
            for (int c : cnt_modM[M - i]) {
                selfpair += c / 2;
            }
            ans += cnt0 + min(selfpair, (cnt1 - cnt0) / 2);
        }
    }

    write(ans);
}

Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int exi[9];
int main() {
	int n; cin >> n;
	rep(i, n) {
		int a; cin >> a;
		exi[min(a / 400,8)]++;
	}
	int c = 0;
	rep(i, 8) {
		if (exi[i])c++;
	}
	int ma = c + exi[8];
	int mi = c; if (c == 0)mi = 1;
	cout << mi << " " << ma << endl;
	//stop
	return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  char matrix[105][105];
  for(int i=0; i<h; i++){
    string str;
    cin >> str;
    for(int j=0; j<w; j++){
      matrix[i][j] = str[j];
    }
  }
  int dismap[105][105];
  if(matrix[0][0] == '.') dismap[0][0] = 0;
  else dismap[0][0] = 1;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(i == 0 && j == 0) continue;
      else if(i == 0){
        if(matrix[i][j-1] == '.' && matrix[i][j] == '#'){
          dismap[i][j] = dismap[i][j-1] + 1;
        }else{
          dismap[i][j] = dismap[i][j-1];
        }
      }
      else if(j == 0){
        if(matrix[i-1][j] == '.' && matrix[i][j] == '#'){
          dismap[i][j] = dismap[i-1][j] + 1;
        }else{
          dismap[i][j] = dismap[i-1][j];
        }
      }else{
        if(matrix[i][j] == '.') dismap[i][j] = min(dismap[i-1][j], dismap[i][j-1]);
        else{
          if(matrix[i-1][j] == '.' && matrix[i][j-1] == '.') dismap[i][j] = min(dismap[i-1][j], dismap[i][j-1]) + 1;
          else if(matrix[i-1][j] == '#' && matrix[i][j-1] == '.') dismap[i][j] = min(dismap[i-1][j], dismap[i][j-1]+1);
          else if(matrix[i-1][j] == '.' && matrix[i][j-1] == '#') dismap[i][j] = min(dismap[i-1][j]+1, dismap[i][j-1]);
          else dismap[i][j] = min(dismap[i-1][j], dismap[i][j-1]);
        }
      }
    }
  }
  cout << dismap[h-1][w-1] << endl;
  return 0;
}
      
      
      
      

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 1e5 + 5;
vector<int> adj[MAX];
int dis[MAX][3];
int n, m;

void bfs(int source) {
    memset(dis, -1, sizeof dis);
    queue<ii> q;
    q.emplace(source, 0);
    dis[source][0] = 0;
    while (!q.empty()) {
        ii cur = q.front();
        q.pop();
        int u, p;
        tie(u, p) = cur;
        for (auto &each : adj[u]) {
            ii nxt = ii(each, (p + 1) % 3);
            if (dis[nxt.first][nxt.second] == -1) {
                dis[nxt.first][nxt.second] = dis[u][p] + 1;
                q.push(nxt);
            }
        }
    }
}

void solve() {
    cin >> n >> m;
    fori (i, 0, m) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    bfs(s);
    int ans = dis[t][0];
    if (ans != -1) ans /= 3;
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 6912
### main

loop do
  a, b, c, d, e, f = gets.split.map(&:to_i)
  break if (a | b | c | d | e | f) == 0

  x = a + d
  y = b + e
  z = c + f

  min = [x, y, z].min
  max_c = 0

  for i in (0..2)
    break if min < i
    n4 = min - i
    c = (x - n4) / 3 + (y - n4) / 3 + (z - n4) / 3 + n4
    max_c = c if max_c < c
  end

  puts max_c
end

Measured memory_bytes: 6124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair

void solve() {
    int x; cin >> x;
    int cur = 100, ans = 0;
    while (cur < x) {
        ++ans;
        cur += cur / 100;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, k, cnt = 0;
    cin >> n >> k;
    while(n >= k){
        cnt++;
        n /= k;
    }
    cout << cnt + 1 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

// 最小公倍数（2変数）
ll lcm(ll x, ll y) {
	return x / gcd(x, y) * y;
}

ll nlcm(vector<ll> &nums) {
	ll l = nums[0];
	for (int i = 1; i < nums.size(); i++) {
		l = lcm(l, nums[i]);
	}
	return l;
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	vector<ll> T(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}

	ll l = nlcm(T);
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 33;
const int MAXM = 110;

int num[MAXN];
char str[MAXM];

int main ()
{
    int n, m;
    scanf ("%d%d", &n, &m);
    memset (num, 0, sizeof (num));
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%s", &str);
        for (int j = 0; j < m; j ++)
        {
            num[str[j] - 'a'] ++;
        }
    }
    bool flag;
    int num_two = 0, num_one = 0;
    for (int i = 0; i < 26; i ++)
    {
        if ((num[i]) && (num[i] % 4 != 0))
        {
            if (num[i] % 2 == 0)
            {
                num_two ++;
            }
            else
            {
                num_one ++;
            }
        }
    }
    if (n % 2 == 1)
    {
        if (m % 2 == 1)
        {
            if ((num_one == 1) && (num_two * 2 <= n + m - 2))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
        }
        else
        {
            if ((num_one == 0) && (num_two * 2 <= m))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
        }
    }
    else
    {
        if (m % 2 == 1)
        {
            if ((num_one == 0) && (num_two * 2 <= n))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
        }
        else
        {
            if ((num_one == 0) && (num_two == 0))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
        }
    }
    if (flag)
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#define M 4

#ifdef __cplusplus
#include <algorithm>
using namespace std;
#else
#define swap(a,b) a^=b,b^=a,a^=b
#endif

int m[10][10];
char s[M+2];
int chk(const char *s){
	int d=0,i=0;
	for(;i<4;i++)d=m[d][s[i]-'0'];
	return d;
}
bool correct(const char *s){
	return m[chk(s)][s[M]-'0']==0;
}
bool solve(char *s){
	int i;char j;
	for(i=0;i<M;i++)if(s[i]!=s[i+1]){
		swap(s[i],s[i+1]);
		if(correct(s))return true;
		swap(s[i],s[i+1]);
	}
	for(i=0;i<=M;i++)for(j='0';j<='9';j++)if(s[i]!=j){
		swap(s[i],j);
		if(correct(s))return true;
		swap(s[i],j);
	}
	return false;
}
int main(){
	int r=0,i,j;
	for(i=0;i<10;i++)for(j=0;j<10;j++)scanf("%d",m[i]+j);
	for(i=0;i<10000;i++){
		sprintf(s,"%04d",i);
		s[M]=chk(s)+'0';
		r+=solve(s);
	}
	printf("%d\n",r);
	return 0;
}

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

#define DIV 1000000007

long long N, K;
long long kaidan[10000000];

void kaical(long long n){
	kaidan[0] = 1;
	for(long long i = 1; i < n; i++){
		kaidan[i] = kaidan[i-1] * i;
		kaidan[i] %= DIV;
	}
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

//nCk
long long combination(long long n, long long k){
	if(n == 0 && k == 0)return 1;
	if(n < k || n < 0 || k < 0)return 0;
	long long n_kai = kaidan[n];
	long long k_kai = kaidan[k];
	long long nmk_kai = kaidan[n-k];

	long long ans = n_kai * modpow(k_kai, DIV - 2);
	ans %= DIV;
	ans *= modpow(nmk_kai, DIV-2);
	ans %= DIV;
	return ans;
}

int main(){
	cin >> N >> K;
	kaical(N + 5);
	
	for(long long i = 1; i <= K; i++){
		long long b = combination(K-1, i-1);
		long long r = combination(N-K+1, i);
		cout << (b * r)%DIV << endl;
	}
}


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

int main()
{
    string a;
    cin >> a;
    rep0(i,3){
        if(a[i]==a[i+1]){
            cout << "Bad" << endl;
            exit(0);
        }
    }
    cout << "Good" << endl;
}


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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int mx = 10000000+5 ;
int d[mx] ;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	queue <int> a,b ;
	int n;
	cin >> n ;
	for(int i=1 ;i<=n ; i++){
		for(int j=i ; j<=n ; j+=i){
			d[j]++;
		}
	}
//	for(int i=1 ;i<= n; i++){
//		cout << i << ' ' <<d[i] << '\n' ;
//	}
	ll ans=0 ;
	for(int i =1 ; i<=n ; i++){
		ans = (ll)ans + (ll)i*(ll)d[i] ;
	}
	cout  << ans ;
	
	return 0 ;
}


Measured memory_bytes: 42656
import bisect
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
A = list(accumulate(A))
s = A[-1]
ans = float("inf")
for i in range(1, n-2):
  left = bisect.bisect(A, A[i]//2)
  right = bisect.bisect(A, (A[i]+s)//2)
  lm = float("inf")
  lM = 0
  rm = float("inf")
  rM = 0
  ld = float("inf")
  rd = float("inf")
  for j in range(-1, 2):
    if 0 <= left+j < i:
      a = A[left+j]
      b = A[i] - a
      if ld > abs(b-a):
        ld = abs(b-a)
        lm = min(a, b)
        lM = max(a, b)
    if i <= right+j < n-1:
      a = A[right+j] - A[i]
      b = s - A[right+j]
      if rd > abs(b-a):
        rd = abs(b-a)
        rm = min(a, b)
        rM = max(a, b)
  ans = min(ans, max(lM, rM) - min(lm, rm))
print(ans)

Measured memory_bytes: 90104
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll M) {
  cout << 48-M << endl;
}

int main() {
  ll M;
  cin >> M;
  solve(M);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int ans = INF;
    for (int i = 0; i < n - k + 1; i++) {
        int l = v[i];
        int r = v[i + k - 1];
        if (r <= 0)
            ans = min(ans, -l);
        else if (l >= 0)
            ans = min(ans, r);
        else
            ans = min({ans, r - 2 * l, r * 2 - l});
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    rep(i,H) rep(j,W) cin >> A[i][j];

    vector<vector<int>> dp(H, vector<int>(W));
    rep(i,H) dp[i][0] = (A[i][0] ? 0 : 1);
    rep(i,W) dp[0][i] = (A[0][i] ? 0 : 1);
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (A[i][j]) dp[i][j] = 0;
            else dp[i][j] = min({dp[i-1][j-1],dp[i][j-1],dp[i-1][j]}) + 1;
        }
    }

    int ans = 0;
    rep(i,H) chmax(ans,*max_element(all(dp[i])));

    cout << ans*ans << endl;
}


Measured memory_bytes: 18428
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    ll ans=0;
    vector<vector<string>> S;
    S.push_back(vector<string>(0));
    rep(i,s.size()-1){
        if(s[i]=='A'){
            S.back().push_back("A");
        }
        else if(s[i]=='B' && s[i+1]=='C'){
            S.back().push_back("BC");
            i++;
        }
        else{
            if(S.back().size()>0) 
            S.push_back(vector<string>(0));
        }
    }
    if(s.back()=='A') S.back().push_back("A");
    for(auto st:S){
        ll cnt=0;
        rep(i,st.size()){
            if(st[i]=="BC"){
                ans+=i-cnt;
                cnt++;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n,d;

int main() {
  cin >> n >> d;
  int ans = ceil((float)n / (float)(2 * d + 1));
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
      
      int w = (x-a)%b;
       
       System.out.print(w);
      
    }
}

Measured memory_bytes: 21204
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)

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

int main(){
	string enzan;
	int a;
	int b;
	int c;
	cin>>a;
	cin>>enzan;
	cin>>b;
	while(enzan!="?"){
		if(enzan=="+"){
			c=a+b;
			cout<<c<<endl;
		}
		else if(enzan=="-"){
			c=a-b;
			cout<<c<<endl;
		}
		else if(enzan=="*"){
			c=a*b;
			cout<<c<<endl;
		}
		else {
			c=a/b;
			cout<<c<<endl;
		}
		cin>>a;
		cin>>enzan;
		cin>>b;
		c=0;
		}
		}





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


int main()
{
	int p,q,r,sum,maxm;
	cin >> p >> q >> r;
	sum = p + q + r;
	maxm = max({p,q,r});
	cout << sum - maxm; 

	
	
}	


Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringBuilder out = new StringBuilder();

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		int n = Integer.parseInt(br.readLine());
		int[] A = new int[n];
		String[] in = br.readLine().split(" ");
		for(int i = 0; i < n; i++)
			A[i] = Integer.parseInt(in[i]);
		int sw = 0;
		
		int t, min;
		for(int i = 0; i<n; ++i){
			min =i;
			for(int j = i; j<n; ++j){
				if(A[j]<A[min]){
					min = j;
				}
					
			}
			if(i != min){
				t = A[i];
				A[i] = A[min];
				A[min] = t;
				sw++;
			}
		}
		
		for(int i = 0; i<n; i++){
			if(i>0)
				System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.print("\n");
		System.out.println(sw);
	}

}

Measured memory_bytes: 24444
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int myfind(int a, vector<int>& relation) {
    if (relation[a] == a) return a;
    int res = myfind(relation[a], relation);
    relation[a] = res;
    return res;
}

void myunion(int a, int b, vector<int>& relation) {
    int ta = myfind(a, relation);
    int tb = myfind(b, relation);
    if (ta == tb) return;
    relation[ta] = tb;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n, 0);
    vector<int> relation(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        relation[i] = i;
    }
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        myunion(a, b, relation);
    }
    unordered_map<int, vector<int>> um;
    for (int i = 0; i < n; i++) {
        um[myfind(i, relation)].push_back(v[i]);
    }
    if (um.size() <= 1) {
        cout << 0 << endl;
        return 0;
    }
    long long int res = 0;
    int c = 0;
    vector<int> other;
    for (auto it = um.begin(); it != um.end(); it++) {
        sort(it->second.begin(), it->second.end());
        res += it->second[0];
        if (it->second.size() == 1) {
            c++;
        } else {
            for (int i = 1; i < it->second.size(); i++) {
                other.push_back(it->second[i]);
            }
        }
    }
    if ((int)other.size() < (int)um.size() - 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    sort(other.begin(), other.end());
    res += accumulate(other.begin(), other.begin() + um.size() - 2, (long long int)0);
    cout << res << endl;
}




Measured memory_bytes: 12936
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<bitset>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int main(){

	while(1){
		int r, c;
		cin >> r >> c;
		if(r==0&&c==0) break;
		int senbei[10001];
		fill_n((int *)senbei,sizeof(senbei)/sizeof(int),0);
		rep(y,r){	
			rep(x,c){	
				int e;
				cin >> e;
				if(e) senbei[x] |= (1 << y);
			}
		}

		int ans = 0;

		rep(bit,1<<r){	
			int a = 0;
			rep(x,c){	
				int n=0, m = senbei[x] ^ bit;
				while(m != 0){
					n++;
					m &= m-1;
				}
				a += max(n,r-n);
			}
			ans = max(ans,a);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c=map(int,readline().split())

    li=[a,b,c]
    li.sort(reverse=True)
    if li[0]==li[1]+li[2]:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
package main
 
import (
    "fmt"
)
 
func main() {
	var A,B int
  	fmt.Scan(&A)
  	fmt.Scan(&B)
  	if B ==1{
      	fmt.Print(0)
    }else if B <= A {
      	fmt.Print(1)
    }else if (B-A)%(A-1)!=0{
      	fmt.Print((B-A)/(A-1) +2)
  	}else{
      	fmt.Print((B-A)/(A-1) +1)
  	}        
}

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

int main() {
    int n;
    cin >> n;
    vector <long> a(n);
    long long wa = 0;
    int now_sign = 0;
    int pre_sign = 0;
    long long count = 0;
    long long min_count = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    pre_sign = 1;
    wa = a[0];
    if(wa != 0) now_sign = wa / abs(wa);
    else  now_sign = 0;
    if(now_sign != pre_sign)
    {
        count += abs(a[0]) + 1;
        wa = 1;
    }
    for(int i = 1; i < n; i++)
    {
        wa += a[i];
        if(wa != 0) now_sign = wa / abs(wa);
        else  now_sign = 0;
        if(now_sign == pre_sign || now_sign == 0)
        {
            count += abs(wa) + 1;
            wa = -1 * pre_sign;
            now_sign = -1 * pre_sign;
        }
        pre_sign = now_sign;
    }
    min_count = count;
//    cout << min_count << endl;
    count = 0;
    pre_sign = -1;
    wa = a[0];
    if(wa != 0) now_sign = wa / abs(wa);
    else  now_sign = 0;
    if(now_sign != pre_sign)
    {
        count += abs(a[0]) + 1;
        wa = -1;
    }

    for(int i = 1; i < n; i++)
    {
        wa += a[i];
        if(wa != 0) now_sign = wa / abs(wa);
        else  now_sign = 0;
        if(now_sign == pre_sign || now_sign == 0)
        {
            count += abs(wa) + 1;
            wa = -1 * pre_sign;
            now_sign = -1 * pre_sign;
        }
        pre_sign = now_sign;
    }
    min_count = min(min_count, count);
//    cout << count << endl;
    cout << min_count << endl;
    return 0;  

}

Measured memory_bytes: 1024
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda a: -a[2])
for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = h+abs(cx-x)+abs(cy-y)
        for i in range(1, N):
            x, y, h = xyh[i]
            if max(H-abs(cx-x)-abs(cy-y), 0) != h:
                break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 41072
A, B, C, X, Y = map(int, input().split())

ans = 0
if 2*C < A+B:
    if X <= Y:
        ans += 2*C*X
        if 2*C < B:
            ans += (Y-X)*2*C
        else:
            ans += (Y-X) * B
    else:
        ans += 2*C*Y
        if 2*C < A:
            ans += (X-Y)*2*C
        else:
            ans += (X-Y) * A
else:
    if X <= Y:
        ans += X*(A+B)
        if 2*C < B:
            ans += (Y-X)*2*C
        else:
            ans += (Y-X) * B
    else:
        ans += Y*(A+B)
        if 2*C < A:
            ans += (X-Y)*2*C
        else:
            ans += (X-Y) * A

print(ans)

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

void print(int a[], int n) {
    for (int i = 0; i < n; i++) {
    cout << a[i];
    if (i < n - 1) {
        cout << ' ';
    }
    else  {
        cout << endl;
    }
}
}

int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    int a[n];
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    
    for (int i = 1; i < n; i++) {
        print(a, n);

        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    }
    
    print(a, n);
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    vector<string> ans;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        exit(0);
    }
    for(int i = 0; i < s.size()-t.size()+1; i++){
        bool ok = true;
        string c = "";
        for(int j = i; j-i < t.size(); j++){
            if(s[j] != '?' && s[j] != t[j-i])ok = false;
        }
        if(ok){
            for(int j = 0; j < s.size(); j++){
                if(i <= j && j <= i+t.size()-1){
                    c += t[j-i];
                }
                else{
                    if(s[j] == '?')c += 'a';
                    else c += s[j];
                }
            }
            ans.push_back(c);
        }
    }
    if(ans.size() == 0)cout << "UNRESTORABLE" << endl;
    else{
        sort(all(ans));
        cout << ans.at(0) << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int inf=1e18;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int k,a,b,ok=0;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
    	if(i%k==0)ok=1;
    }
    if(ok)cout << "OK";
    else cout << "NG";
}

Measured memory_bytes: 3656
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, M int
  NextInt(&N, &M)
  for k := 1; k <= M / 2; k++ {
    WriteIntVec([]int{k, M + 1 - k})
  }
  for k := 1; k <= M - M / 2; k++ {
    WriteIntVec([]int{M + k, 2 * M + 2 - k})
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 5240
def main():
    N,K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    ans = 0
    for i,p in enumerate(sorted(P)):
        if i == K:
            break
        ans += p
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long int llint;

int N;

int main() {
	cin >> N;
	vector<llint> A(N);
	llint sum = 0;
	for (int i = 0; i < N; i++) { 
		cin >> A[i];
		sum += A[i];
	}

	llint ans = sum;
	for (int i = 1; i < N; i += 2) {
		ans -= 2 * A[i];
	}

	cout << ans << " " << flush;
	for (int i = 1; i < N; i++) {
		ans = 2 * A[i - 1] - ans;
		cout << ans << " " << flush;
	}
	cout << endl;

}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll N, L, R, SUM, XOR, RES;
signed main() {
    
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    rep(L, N) {
        while((SUM + A[R]) == (XOR ^ A[R]) && R < N) {
            SUM += A[R];
            XOR ^= A[R];
            R++;
        }
        RES += R - L;
        
        if(L == R) R++;
        SUM -= A[L];
        XOR ^= A[L];
    }
    cout << RES << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

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

int main()
{
	long long H,result;
	result = 0;

	cin >>H;

	long long number = 1;
	while (true) {
		if (H <= 1) {
			result += number;
			break;
		}
		if (H % 2 == 1)H - 1;
		H /= 2;
		result += number;
		number *= 2;

	}

	cout << result<<endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        long n = Long.parseLong(tokenizer.nextToken());
        long m = Long.parseLong(tokenizer.nextToken());
        long countFirst = m /2;
        long count  = Math.min(n, countFirst);
        m -= count * 2;
        count += m / 4;
        System.out.println(count);
    }
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	int a[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&a[i]);}
	sort(a,a+n);
	int tengah1 = a[n/2 - 1], tengah2 = a[n/2];
	printf("%d\n",tengah2 - tengah1);
	return 0;
};

Measured memory_bytes: 640
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]

judge = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i > 0 and i < h - 1:
                if s[i-1][j] == "#" or s[i+1][j] == "#":
                    continue
            if j > 0 and j < w - 1:
                if s[i][j-1] == "#" or s[i][j+1] == "#":
                    continue
            if i == 0:
                if s[i+1][j] == "#":
                    continue
            if j == 0:
                if s[i][j+1] == "#":
                    continue
            if i == h - 1:
                if s[i-1][j] == "#":
                    continue
            if j == w - 1:
                if s[i][j-1] == "#":
                    continue
            
            judge = "No"

print(judge)

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

using namespace std;

int main() {
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(), x.end());
  cout << 10 * x[2] + x[1] + x[0] << "\n";
  return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,0,n){
        cin>>a[i]>>b[i];
    }
    ll num=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=num;
        if(a[i]%b[i]==0)continue;
        if(a[i]<=b[i])num+=b[i]-a[i];
        else{
            num +=b[i]*(a[i]/b[i]+1)-a[i];
        }
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 1792
require 'prime'

class Integer

  def each_divisor &block
    each_divisor_rec prime_division, 0, 1, &block
  end

  def mod_exp n, m
    b, r = self % m, 1
    while n > 0
      r = r * b % m if n.odd?
      b = b * b % m
      n /= 2
    end
    r
  end

  private

  def each_divisor_rec ps, i, d, &block
    if i == ps.size
      block.call d
    else
      f = 1
      (ps[i][1]+1).times do
        each_divisor_rec ps, i+1, f*d, &block
        f *= ps[i][0]
      end
    end
  end

end

loop do
  xs = gets.split.map(&:to_i)
  break if xs.all?(&:zero?)
  p xs.each_slice(2).map {|a, m|
    ps = Prime.prime_division(m).map(&:first)
    phi = m / ps.reduce(1, :*) * ps.reduce(1) {|r, p| r * (p - 1) }
    phi.enum_for(:each_divisor).sort.find {|d| a.mod_exp(d, m) == 1 }
  }.reduce(1, :lcm)
end

Measured memory_bytes: 9064
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 5e5+5;

void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a!=c)cout<<1;
	else cout<<0;
}

int main(){
	ios_base :: sync_with_stdio(false);
	int test = 1; 
	//cin >> test;	
	while (test--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3588