akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int size = S.size();
    int count = 0;
    for(int i = 0;i < size;i++){
        if(S[i] != T[i]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	int s1=0,s7=0;
	if(a==5) s1++;
	else if(a==7)
		s7++;
	if(b==5)
		s1++;
	else if(b==7)
		s7++;
	if(c==5)
		s1++;
	else if(c==7)
		s7++;
	
	if(s1==2&&s7==1)
		cout<<"YES"<<endl;
	
	
	else
	cout<<"NO"<<endl;
	
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,m,t,val[3010][3010],dp[3010][3010][5];

int main()
{
	cin>>n>>m>>t;
	LL x,y,z;
	rep(i,t)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		x--;
		y--;
		val[x][y]=z;
	}
	rep(i,3005) rep(j,3005) rep(k,5) dp[i][j][k]=-1;
	dp[0][0][0]=0;
	if(val[0][0]>0) dp[0][0][1]=val[0][0];
	rep(i,n) rep(j,m) rep(k,4)
	{
		if(dp[i][j][k]==-1) continue;
		if(j+1<m)
		{
			dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
			if(val[i][j+1]>0&&k<3) dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+val[i][j+1]);
		}
		if(i+1<n)
		{
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
			if(val[i+1][j]>0) dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+val[i+1][j]);
		}
	}
	cout<<max(max(dp[n-1][m-1][0],dp[n-1][m-1][1]),max(dp[n-1][m-1][2],dp[n-1][m-1][3]))<<endl;
	return 0;
}

Measured memory_bytes: 427512
//written by libra9z
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define RET(p,x) return p<<x<<endl,0
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
#define sqr(x) ((x)*(x))
const int inf=1e9;
const ll lnf=1e18;
const int mod=1e9+7;
int h,w;
char s[13][13];
string ss[13];
int a[13];
int b[13];
void dfs1(int x,bool f)
{
	if (x==w)
	{
		puts("YES");
		exit(0);
	}
	else if (b[x]!=-1) dfs1(x+1,f);
	else
	{
		for (int i=x+1;i<w;++i)
		{
			if (b[i]!=-1) continue;
			int j;
			for (j=0;j<h;++j) if (s[j][x]!=s[a[j]][i]) break;
			if (j==h)
			{
				b[x]=i;
				b[i]=x;
				dfs1(x+1,f);
				b[x]=b[i]=-1;
			}
		}
		if (!f)
		{
			int j;
			for (j=0;j<h;++j) if (s[j][x]!=s[a[j]][x]) break;
			if (j==h)
			{
				b[x]=x;
				dfs1(x+1,true);
				b[x]=-1;
			}
		}
	}
}
void dfs2(int x,bool f)
{
	if (x==h) dfs1(0,!(w&1));
	else if (a[x]!=-1) dfs2(x+1,f);
	else
	{
		for (int i=x+1;i<h;++i)
		{
			if (a[i]!=-1) continue;
			if (ss[x]!=ss[i]) continue;
			a[x]=i;
			a[i]=x;
			dfs2(x+1,f);
			a[x]=a[i]=-1;
		}
		if (!f)
		{
			a[x]=x;
			dfs2(x+1,true);
			a[x]=-1;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>h>>w;
	for (int i=0;i<h;++i) cin>>s[i],ss[i]=s[i],sort(ss[i].begin(),ss[i].end());
	for (int i=0;i<1000000000;++i)h*=-1;
	for (int i=0;i<h;++i) a[i]=-1;
	for (int i=0;i<w;++i) b[i]=-1;
	dfs2(0,!(h&1));
	cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    char b; cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)




n=int(input())
M=[0]*(n+1)
for i in range(n):
    M[i],M[i+1]=map(int,input().split())
dp=[[float('inf')]*n for i in range(n)]
for i in range(n):
    dp[i][i]=0
for k in range(1,n):
    for i in range(n-k):
        j=i+k
        for l in range(i,j):
            dp[i][j]=min(dp[i][j],dp[i][l]+dp[l+1][j]+M[i]*M[l+1]*M[j+1])
print(dp[0][n-1])
# print(dp)



Measured memory_bytes: 5668
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
using namespace std;

using ll = long long;
ll n, a, b;
ll v[50];

ll memo[55][55];
ll dp(int i, int j)
{
	if (j < 0)return -123456789012345678;
	if (memo[i][j] != -1)return memo[i][j];
	ll ans = 0;
	if (i == 0)
	{
		if (j == 0)ans = 0;
		else ans = -123456789012345678;
	}
	else
	{
		ans = dp(i - 1, j - 1) + v[i - 1];
		ans = max(ans, dp(i - 1, j));
	}
	return memo[i][j] = ans;
}

ll mem2[55][55];
ll dp2(int i, int j)
{
	if (j < 0)return 0;
	if (mem2[i][j] != -1)return mem2[i][j];
	if (i == 0)
	{
		if (j == 0)return 1;
		else return 0;
	}
	ll r1 = dp(i - 1, j - 1) + v[i - 1];
	ll r2 = dp(i - 1, j);
	ll ans = dp2(i - 1, j - 1) + dp2(i - 1, j);
	if (r1 > r2)
	{
		ans = dp2(i - 1, j - 1);
	}
	else if (r1 < r2)
	{
		ans = dp2(i - 1, j);
	}
	return mem2[i][j] = ans;
}

long double eps = 1e-14;
bool same(long double a, long double b)
{
	if (abs(a - b) < eps)return true;
	return false;
}

int main(void)
{
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)cin >> v[i];
	memset(memo, 0xff, sizeof(memo));
	memset(mem2, 0xff, sizeof(mem2));
	long double big = 0;
	for (int i = a; i <= b; ++i)
	{
		ll ret = dp(n, i);
		big = max(big, (long double)ret / i);
	}
	cout.precision(25);
	cout << big << endl;
	ll ans = 0;
	for (int i = a; i <= b; ++i)
	{
		ll ret = dp2(n, i);
		if (round(big * i) == dp(n, i))
		{
			ans += ret;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
	constexpr int64_t wall = 1000000000000000000;
	int64_t temp = wall;

	int n = 0;
	cin >> n;
	int64_t temp1 = 0;
	int64_t ans = 1;
	
	for (int i = 0; i < n; i++)
	{
		cin >> temp1;
		if (temp1 == 0)
		{
			ans = 0;
			temp = 1;
			break;
		}
		temp /= temp1;
		ans *= temp1;
	}

	if (temp == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}

	
	return 0;
}


Measured memory_bytes: 3620
import sys
from itertools import accumulate

input = sys.stdin.readline


class UnionFind:
    """Union Find class.

    "Path compression" and "Union by rank" are used.

    References:
        <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
    """

    def __init__(self, N):
        self.N = N
        self.__make_set()

    def __make_set(self):
        self._parent = list(range(self.N + 1))
        self._rank = [0] * (self.N + 1)
        self._size = [1] * (self.N + 1)

    def find(self, x):
        if self._parent[x] != x:
            self._parent[x] = self.find(self._parent[x])
        return self._parent[x]

    def union(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)

        if x_root == y_root:
            return

        x_rank = self._rank[x_root]
        y_rank = self._rank[y_root]
        if x_rank > y_rank:
            self._parent[y_root] = x_root
            self._size[x_root] += self._size[y_root]
        elif x_rank < y_rank:
            self._parent[x_root] = y_root
            self._size[y_root] += self._size[x_root]
        else:
            self._parent[y_root] = x_root
            self._rank[x_root] += 1
            self._size[x_root] += self._size[y_root]

    def same_set(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self._size[self.find(x)]


def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    uf = UnionFind(N)
    for i, p in enumerate(P, 1):
        uf.union(i, p)

    ans = -float("inf")
    visited_cc = set()
    for i in range(1, N + 1):
        cc = uf.find(i)
        if cc in visited_cc:
            continue
        visited_cc.add(cc)

        CC = []
        j = P[i - 1]
        while True:
            CC.append(C[j - 1])
            if i == j:
                break
            j = P[j - 1]
        n_CC = len(CC)
        loop_cost = sum(CC)
        CC = list(accumulate([0] + CC * 2))

        if K < n_CC:
            cost = [-float("inf")] * n_CC
            for n_move in range(1, K + 1):
                for j in range(n_CC):
                    tmp = CC[j + n_move] - CC[j]
                    cost[n_move - 1] = max(cost[n_move - 1], tmp)
            res = max(cost)
        else:
            cost = [-float("inf")] * n_CC
            for n_move in range(1, n_CC):
                for j in range(n_CC):
                    tmp = CC[j + n_move] - CC[j]
                    cost[n_move - 1] = max(cost[n_move - 1], tmp)
            q, r = divmod(K, n_CC)
            if loop_cost > 0:
                if r > 0:
                    res = max(loop_cost * q + max(cost[:r]), loop_cost * (q - 1) + max(cost))
                else:
                    res = max(loop_cost * q, loop_cost * (q - 1) + max(cost))
            else:
                res = max(cost)

        ans = max(ans, res)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71008
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    vec<string> grid(2);
    range(i, 0, 2) cin >> grid.at(i);
    bool is_satisfactory = (grid.at(0).at(0) == grid.at(1).at(2))
        and (grid.at(0).at(1) == grid.at(1).at(1))
        and (grid.at(0).at(2) == grid.at(1).at(0));
    cout << (is_satisfactory ? "YES" : "NO") << "\n";
}

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

using namespace std;

const int M = 1e5 + 1;
int memo[M][5][5][5], n;
string s[M];

bool solve(int i, int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0)
        return 0;
    int &r = memo[i][a][b][c];

    if (r == -1) {
        if (i == n)
            r = 1;
        else if (s[i] == "AB")
            r = max(solve(i + 1, a + 1, b - 1, c), solve(i + 1, a - 1, b + 1, c));
        else if (s[i] == "AC")
            r = max(solve(i + 1, a + 1, b, c - 1), solve(i + 1, a - 1, b, c + 1));
        else
            r = max(solve(i + 1, a, b + 1, c - 1), solve(i + 1, a, b - 1, c + 1));
    }

    return r;
}

void build(int i, int a, int b, int c) {
    if (i == n)
        return;
    if (s[i] == "AB") {
        if (b && memo[i + 1][a + 1][b - 1][c])
            cout << "A\n", build(i + 1, a + 1, b - 1, c);
        else
            cout << "B\n", build(i + 1, a - 1, b + 1, c);
    } else if (s[i] == "AC")
        if (c && memo[i + 1][a + 1][b][c - 1])
            cout << "A\n", build(i + 1, a + 1, b, c - 1);
        else
            cout << "C\n", build(i + 1, a - 1, b, c + 1);
    else {
        if (c && memo[i + 1][a][b + 1][c - 1])
            cout << "B\n", build(i + 1, a, b + 1, c - 1);
        else
            cout << "C\n", build(i + 1, a, b - 1, c + 1);
    }
}

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

    memset(memo, -1, sizeof memo);
    int a, b, c;
    cin >> n >> a >> b >> c;
    a = min(a, 4);
    b = min(b, 4);
    c = min(c, 4);

    for (int i = 0; i < n; i++)
        cin >> s[i];

    if (solve(0, a, b, c)) {
        cout << "Yes\n";
        build(0, a, b, c);
    } else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 63428
#include<stdio.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

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

    int ans[3];
    for(int i = 0; i < 3; i++) {
      ans[i] = true;
    }

      ans[a-1] = false;
      ans[b-1] = false;

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

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

vector<vector<int> > vConnected;
void FindConnected(int a, set<int>& list, int ignore1, int ignore2) {

	for (int i = 0; i != vConnected[a].size(); ++i) {
		if (list.find(vConnected[a][i]) == list.end()) {
			if (!((a == ignore1 && vConnected[a][i] == ignore2) || (a == ignore2 && vConnected[a][i] == ignore1))) {
				list.insert(vConnected[a][i]);
				FindConnected(vConnected[a][i], list, ignore1, ignore2);	
			}
		}
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int N, M;
	cin >> N >> M;

	vConnected.resize(N);

	vector<int> vA(M, 0);
	vector<int> vB(M, 0);

	for (int i = 0; i != M; ++i) {
		int a, b;
		cin >> a >> b;
		vA[i] = a-1;
		vB[i] = b-1;
		vConnected[a-1].push_back(b-1);
		vConnected[b-1].push_back(a-1);
	}

	int cnt = 0;
	for (int i = 0; i != M; ++i) {
		set<int> conlist;
		FindConnected(0, conlist, vA[i], vB[i]);
		if (conlist.size() != N) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  bool bl = true;
  h[0] -= 1;
  for (int i = 1; i <= n-1; i++) {
    if (h[i] > h[i-1]) h[i]--;
    else if (h[i] < h[i-1]) bl = false;
  }
  if (bl) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int a;
    cin >> a;
    int ans = a + a * a + a * a * a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 6005
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/
int mod;
int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

int dp2[N],dp3[N];
int combi[N][N];
void init() {
  for(int i=0;i<N;++i) {
    combi[i][i] = combi[i][0] = 1;
    for(int j=1;j<i;++j) {
      combi[i][j] = add(combi[i-1][j],combi[i-1][j-1]);
    }
  }
}
void solve() {
  int n;
  scanf("%d %d ", &n,&mod);
  init();
  dp2[0] = 1;
  dp2[2] = 1;
  for(int i=4;i<N;i+=2) {
    dp2[i] = mul(dp2[i-2], i-1);
  }
  dp3[0] = 1;
  dp3[3] = 2;
  for(int i=6;i<N;i+=3) {
    dp3[i] = mul(2,mul(combi[i-1][2], dp3[i-3]));
  }
  int ret = 0;
  for(int one=0;one<=3*n;++one) {
    for(int two=0;two<=one && two*2+one<=3*n;++two) {
      int num = one + two*2;
      if(num%3==0) {
        int tmp = mul(combi[n*3][num], mul(combi[num][one], mul(dp2[two*2],dp3[3*n - num])));
        ret = add(ret, tmp);
      }
    }
  }
  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 139520
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC116B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInt;

            int[] count = new int[10000000];
            int ans = 0;
            for (int i = 0; i < 1000000; i++)
            {
                count[s]++;
                if (count[s] > 1)
                {
                    ans = i + 1;
                    break;
                }
                if (s % 2 == 0) s /= 2;
                else s = 3 * s + 1;

            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	if (b.compare(0, a.size(), a) == 0 && a.size() + 1 == b.size())
		cout << "Yes";
	else
		cout << "No";
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const ll MAX = 10000;
static const ll INFTY = 1e12;

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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;
// 入力
// 入力
ll h, w;
ll startX, startY, endX, endY;
vector<vector<char>> s;
vector<vector<ll>> cnts; // 魔法使った回数


int main() {

  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;


   
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3620
n = int(input())
#a = [list(map(int, input().split())) for _ in range(n)]
start = []
end = []
for i in range(n):
    a,b = map(int, input().split())
    start.append(a)
    end.append(b)
start.sort()
end.sort()
if (n%2==1):
    print(end[n//2]-start[n//2]+1)
else:
    s = start[n//2-1]+start[n//2]
    e = end[n//2-1]+end[n//2]
    print(e-s+1)

Measured memory_bytes: 25416
use std::io;


fn main() {
    let a : u32 = get_line().parse().unwrap();
    let d1 = a / 10;
    let d2 = a % 10;
    if d1 == 9 || d2 == 9 {
        println!("Yes");
    }else{
        println!("No");
    }
}

fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return String::from(line.trim())
}


Measured memory_bytes: 4352
import math

def main():
    #0. 入力
    N = int(input())
    MAX = 55555
    
    #1. 5で割ると1余る素数列を作る
    #1-1. 素数列の作成
    prime = [2]
    for num in range(3,MAX):
        cand = 2
        while cand < int(math.sqrt(num))+1:
            if num % cand == 0:
                break
            cand += 1
        if cand==int(math.sqrt(num))+1:
            prime.append(num)

    #1-2. 5で割って1余るものを抽出
    prime_five = []
    for pr in prime:
        if pr%5 == 1:
            prime_five.append(pr)

        
    #2. Nの数だけ詰め込む
    answer = prime_five[:N]
    answer = [str(pr) for pr in answer]
    print(" ".join(answer))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>

int main() {
  long long int N, ans;
  scanf("%lld", &N);
  for (long long int i = sqrt(N); i >= 1; i--) {
    if (N % i == 0) {
      printf("%lld\n", i + N/i - 2);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>

#define conv 0.0174532925199

using namespace std;

int main()
{
	double x=0.0,y=0.0,m,r,rad=0;
	char a;
	
	for(;;)
	{
		cin >> m >> a >> r ;
		if(m==0 && r==0)
			break;
		x+=m*sin(rad*conv);
		y+=m*cos(rad*conv);
		rad+=r;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
}

Measured memory_bytes: 0
/*
author : seryu
title : ABC173C_"H and V"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
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; }

void solve()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> c(h);
	rep(i, h)cin >> c[i];
	int ans = 0;
	rep(mask, 1 << (h+w))
	{
		int tmp = 0;
		rep(i, h)rep(j, w)
		{
			if((mask >> i & 1) && (mask >> (h + j) & 1) && c[i][j] == '#')tmp++;
		}
		if(tmp == k)ans++;
	}
	cout << ans << endl;
	return;	
}

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


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define N_MAX 3005

using namespace std;
typedef long long ll;
int N;
ll M, MOD;
ll pow2[10000000];
ll powpow2[3005];
ll dp[3005][3005];
ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    pow2[0] = 1;
    powpow2[0] = 2;
    for(int i = 1; i < 10000000; i++){
        pow2[i] = pow2[i-1]*2;
        pow2[i] %=M;
    }
    for(int i = 1; i <= 3004; i++){
        powpow2[i] = powpow2[i-1]*powpow2[i-1];
        powpow2[i] %= M;
    }
    for(int i = 1; i <= 3004; i++){
        dp[i][1] = 1;
        dp[i][i] = 1;
        for(int j = 2; j < i; j++){
            dp[i][j] = dp[i-1][j]*j+dp[i-1][j-1];
            dp[i][j] %= M;
        }
    }
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

template <typename T>
T pow(T a, ll n){
    T ans = 1;
    T tmp = a;
    for(int i = 0; i <= 60; i++){
        ll m = (ll)1 << i;
        if(m&n){
            ans *= tmp;
            ans %= M;
        }
        tmp *= tmp;
        tmp %= M;
    }
    return ans;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    MOD = M;
    init();
    ll ans = powpow2[N];
    // cout  << ans << endl;
    for(int i = 1; i <= N; i++){
        ll tmp = 0;
        for(int j = 0; j <= i; j++){
            tmp += dp[i+1][j+1]*pow2[(N-i)*j];
            tmp %= M;
        }
        tmp *= powpow2[N-i];
        tmp %= M;
        tmp *= comb(N, i);
        tmp %= M;
        ans += (i%2 == 0 ? tmp:-tmp);
        ans %= M;
        ans += M;
        ans %= M;
        // cout << tmp << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 147456
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		ll a[100002];
		i=0;
		rep(i,11ll)
		{
			a[i]=i;
		}
		i=10;
		j=1;
		while(i<=n)
		{
			k=a[j]%10;
			if(k!=0) a[i++]=a[j]*10+(k-1);
			a[i++]=a[j]*10+(k);
			if(k!=9) a[i++]=a[j]*10+(k+1);
			j++;
			// debug3(a[i-3],a[i-2],a[i-1]);
		}
		c=a[n];
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    ll n,q,i,sum=0,x,y;
    
    cin >> n ;

    ll ar[100005] = {0};

    for(i=1; i<=n; i++) 
    {
        cin >> x;
        ar[x]++;
        sum += x;
    }

    // cout << sum << endl;

    cin >> q ;

    while(q--)
    {
        cin >> x >> y ;

        sum -= x*ar[x];
        sum += ar[x]*y;
        // cout << "x - " << x << " y - " << y << " sum - " << sum << endl;
        ar[y] += ar[x];
        ar[x] = 0 ;
        
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 4436
import java.util.Scanner;
 
class Main{
 public static void main(String[] args){
  int a;
  int b;
  Scanner sc = new Scanner(System.in);
  a = sc.nextInt();
  b = sc.nextInt();
 
  int area = a*b;
  int syu = 2*(a+b);
   
  System.out.println(area+" "+syu);
 }
}

Measured memory_bytes: 17224
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int n;
string s = "";

void solve(int idx, char c) {
	if (idx == n) {
		cout << s << endl;
		return;
	} else {
		for (char nc = 'a'; nc <= c; nc++) {
			s[idx] = nc;
			solve(idx + 1, c);
		}
		s[idx] = c + 1;
		solve(idx + 1, c + 1);
	}
}

int main() {
	cin >> n;
	s = string(n, 'a');
	solve(1, 'a');
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
int main()
{
    ll a,b,x,ans;

    cin >> a >> b >> x;

    if(a%x == 0)
        ans = (b/x) - (a/x) +1;
    else
        ans = (b/x) - (a/x);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
n = int(input())
A = []
for i in range(n):
    a = int(input())
    tmp_A = [list(map(int,input().split())) for j in range(a)]
    A.append(tmp_A)

ans = 0
for bit in range(2**n): #2**nパターン考える
    flg = True
    cnt = 0
    for i in range(n):
        if (bit >> i) & 1: #i番目の人は正直者
            cnt += 1
            for j in A[i]: #i番目の人の証言を確認する
                x = j[0]-1
                y = j[1]
                if (bit >> x)&1 != y:
                    flg = False
                    break
        if not flg:
            break

    if flg:
        ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main()
{
    long long n, x, y, z, b;
    long long k  ; //= 50e16;
    cin >> k;

    int N = 50;

    vector<long long > v;
    b = k / N;
    for(int i = 0; i < N; i++)
    {
        v.push_back(b + i);
    }

    n = k - b * N;
    while(n--)
    {
        v[0] += N;
        for(int i = 1; i < 50; i++) v[i]--;
        sort(v.begin(), v.end());
    }

    cout << N << endl;
    for(long long out: v)
        cout << out << ' ';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  ll bsum = 0;
  multiset<ll> l, r;
  ll lsum = 0, rsum = 0;
  rep(i,Q){
    int x;
    cin >> x;
    if(x == 1){
      ll a, b;
      cin >> a >> b;

      bsum += b;
      l.insert(a);
      lsum += a;
      if(l.size()-r.size()>1){
        auto itr = --l.end();
        ll x = *itr;
        l.erase(itr);
        lsum -= x;
        r.insert(x);
        rsum += x;
      }
      if(r.size() != 0){
        auto itrl = --l.end();
        auto itrr = r.begin();
        ll x = *itrl;
        ll y = *itrr;
        if(x > y){
          l.erase(itrl);
          lsum -= x;
          r.erase(itrr);
          rsum -= y;
          l.insert(y);
          lsum += y;
          r.insert(x);
          rsum += x;
        }
      }
    }else{
      if(l.size() == 0){
        cout << 0 << endl;
      }else{
        auto itr = --l.end();
        ll x = *itr;

        ll N = l.size();
        ll M = r.size();
        //cout << N << " " << M << " " << x << endl;
        
        cout << x << " " << bsum + N * x - lsum + rsum - M * x << endl;
      }
    }
  }
    
  return 0;
}


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

using namespace std;

int main(void){
    int n;
    long long sum_x = 0;
    long long ans = 0;

    cin >> n;

    vector<int> x(n);

    for(int i=0; i<n; i++){
        cin >> x[i];
        sum_x += x[i];
    }
    int mean = roundl(sum_x / (double)n);

    for(int i=0; i<n; i++){
        ans += (x[i] - mean) * (x[i] - mean);
    }
    

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n;
  cin>>n;
  
  bool ans=false;
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      if(i*j==n){
        ans=true;
      }
    }
  }
  
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,(n)-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
int N;
int a[101];
int num = -1;
/**********************************/


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    int ans = 0;
    UP(i, 1, N-1) {
        if(a[i] == a[i-1]) {
            ans++;
            a[i] = num;
            num--;
        }
    }
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;

  int cnt = 0;
  int len = s.length();
  int half = s.length() / 2;
  for (int i = 0; i < half; i++) {
    if (s[i] != s[len - i - 1]) {
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_PEAPLE	( 10000 )

int needTime[ MAX_PEAPLE ];

int tmp[ MAX_PEAPLE ];

void sort( int data[], int size );
long long getWaitTime( int data[], int size );

int main( void )
{
	int n;
	int i;
	
	while( scanf( "%d", &n ) != EOF )
	{
		if( n == 0 )break;
		for( i = 0; i < n; i++ )
		{
			scanf( "%d", &needTime[i] );
		}
		sort( needTime, n );
		printf( "%llu\n", (unsigned)getWaitTime( needTime, n ) );
	}
	
	return (0);
}

long long getWaitTime( int data[], int size )
{
	long long waitTime[ MAX_PEAPLE ];
	int i;
	long long totalWaitTime;
	
	waitTime[0] = 0;
	for( i = 1; i < size; i++ )
	{
		waitTime[i] = waitTime[i - 1] + data[i - 1];
	}
	
	for( i = 0, totalWaitTime = 0; i < size; i++ )
	{
		totalWaitTime += waitTime[i];
	}
	
	return (totalWaitTime);
}

void sort( int data[], int size )
{
	int i;
	int j;
	int k;
	int l;
	
	if( size <= 1 )return;
	
	i = 0;
	j = size / 2;
	k = 0;
	
	sort( data, size / 2 );
	sort( data + size / 2, size - (size / 2) );
	
	while( i < size / 2 && j < size )
	{
		if( data[i] < data[j] )
		{
			tmp[k] = data[i];
			k++;
			i++;
		}
		else
		{
			tmp[k] = data[j];
			k++;
			j++;
		}
	}
	while( i < size / 2 )
	{
		tmp[k] = data[i];
		k++;
		i++;
	}
	while( j < size )
	{
		tmp[k] = data[j];
		k++;
		j++;
	}
	
	for( l = 0; l < size; l++ )
	{
		data[l] = tmp[l];
	}
}

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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DBG         cerr << __LINE__ << " Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline LL setBit(LL N, LL pos) { return N=N | (1LL<<pos); }
inline LL resetBit(LL N, LL pos) { return N= N & ~(1LL<<pos); }
inline bool checkBit(LL N, LL pos) { return (bool)(N & (1LL<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction
int n, A[60], B[60];
bool G[60][60];
int main()
{
    //freopen("maxon.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    sf(n);
    for(int i = 1; i<=n; i++)
        sf(A[i]);
    for(int i = 1; i<=n; i++)
        sf(B[i]);
    LL total = (1LL<<52)-1-1;
    LL mask = (1LL<<52)-1;

    for(int mx = 51; mx>=1; mx--)
    {
        mem(G, 0);
        LL tmp = resetBit(mask, mx);
        for(int i = 0; i<=50; i++)
        {
            G[i][i] = 1;
            for(int j = 1; j<=50; j++)
            {
                if(checkBit(tmp, j) == 1)
                    G[i][(i%j)] = 1;
            }
        }

        for(int k = 0; k<=50; k++)
        {
            for(int i = 0; i<=50; i++)
            {
                for(int j = 0; j<=50; j++)
                {
                    G[i][j] |= (G[i][k] & G[k][j]);
                }
            }
        }

        bool ok = true;
        for(int i = 1; i<=n; i++)
        {
            if(G[A[i]][B[i]] == 0)
            {
                ok = false;
                break;
            }
        }
        if(!ok && mx == 51)
        {
            puts("-1");
            return 0;
        }
        else if(ok)
        {
            mask = tmp;
            total -= (1LL<<mx);
        }
    }
    cout << total << endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,i,s,k,j=1,h;
    scanf("%d%d",&a,&b);
    i=(int)log10(b)+1;
    for(h=1;h<=i;h++)
        j*=10;
    s=a*j+b;
    k=(int)sqrt(s);
    if(s==(k*k))
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main(){
  int n,sum=0;
  cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
    sum+=num[i];
  }
  sort(num.begin(),num.end());
  cout<<sum-num[n-1]/2<<endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using Edge = pair<ll, pii>;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {
  }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  void merge(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return;
    if (-par[rx] < -par[ry]) swap(rx, ry);
    par[rx] += par[ry];
    par[ry] = rx;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  vector<Edge> edges;

  vector<int> ids(N);
  iota(ids.begin(), ids.end(), 0);
  sort(ids.begin(), ids.end(), [&](int i, int j) { return X[i] < X[j]; });
  for (int i = 0; i + 1 < ids.size(); i++) {
    int u = ids[i], v = ids[i + 1];
    edges.emplace_back(Edge(X[v] - X[u], make_pair(u, v)));
  }

  sort(ids.begin(), ids.end(), [&](int i, int j) { return Y[i] < Y[j]; });
  for (int i = 0; i + 1 < ids.size(); i++) {
    int u = ids[i], v = ids[i + 1];
    edges.emplace_back(Edge(Y[v] - Y[u], make_pair(u, v)));
  }

  sort(edges.begin(), edges.end());
  UnionFind uf(N);
  ll res = 0;
  for (auto e : edges) {
    int u = e.second.first, v = e.second.second;
    ll cost = e.first;
    if (uf.issame(u, v)) continue;
    uf.merge(u, v);
    res += cost;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 8432
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<String> list = Arrays.asList(sc.next().split(""));
        boolean flag = true;
        for(int i=0; i<list.size(); i++){
            String back = list.get(list.size()-1-i);
            if(!back.equals(list.get(i))){
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 23764
N = int(input())
nums = list(map(int, input().split()))

total = 0

while nums:
    total += max(nums)
    nums.remove(max(nums))
    if nums:
        total -= max(nums)
        nums.remove(max(nums))

print(total)


# sample
##N = int(input())
##l = list(map(int, input().split()))
##l.sort(reverse=True)
##print(sum(l[0::2]) - sum(l[1::2]))
    


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

int main()

{
    int m,n,i,j=0;
    cin>>n>>m;
    int arr[m];
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
        j=j+arr[i];
    }
    if(j<=n)j=n-j;
    else
        j=-1;
    cout<<j<<endl;

    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int min=1000000,num;
  cin >> s;
  for(int i=0;i<(int)(s.length())-2;i++){
    num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    num=abs(num-753);
    min=(min<num)?min:num;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD =  998244353; //   1000000009 , 1000000023 ,1000000007
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

using namespace __gnu_pbds;
template<typename T, class cmp = std::less<T>>
using Tree = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a , ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}
bool can(ll n , string s){
  bool ok = 1;
  for(auto &x:s){
    if(x=='-')n--;
    else n++;
    if(n<0){ok = 0 ; break;}
  }
  return ok;
}
int main() {
  
#ifdef AVI  
  freopen("input.txt" , "r" , stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  
  vector<ll>divc(ll(1e7)+1 , 0);
  for(ll i=1 ; i<=(1e7) ; i++){
  	for(ll j=i ; j<=(1e7) ; j+=i)divc[j]++;
  }
  ll n;
  cin >> n;
  ll res = 0;
  for(ll i=1 ; i<=n ; i++)res += i*divc[i];
  cout << res;

}

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

int s(int x) {
  int a = 0;
  while (x) {
    a += x % 10;
    x /= 10;
  }
  return a;
}

int main() {
  int n;
  cin >> n;
  int a = s(n);
  cout << (n % a == 0 ? "Yes" : "No") << endl;
}

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

typedef long long ll;

int k, a, b;
ll res;

int main()
{
    scanf("%d %d %d", &k, &a, &b);
    res = 1 + k;
    if (b > a && a - 1 <= k) {
        k -= (a - 1);
        ll cur = ll(a) + ll(b - a) * (k / 2);
        if (k % 2) cur++;
        res = max(res, cur);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = []
for i in range(H):
    a = input()
    if a.count("#") >= 1:
        A.append(a)
#print(A)
B = [""]*len(A)
#print(B)
for i in range(len(A[0])):
    b = False
    for j in range(len(A)):
        #print(A[j][i])
        if A[j][i] == "#":
            b = True

    if b == True:
        for j in range(len(A)):
            B[j] += A[j][i]
        #print(1)
    #print("------------")

for k in B:
    print(k)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define I push_back(k)
std::deque<int>A,B;
long long n;
int m,k=1;
int main(){
	for(std::cin>>n,++n;n>>++m;);
	for(m--;~--m;++k){
		B.I,A.I;
		if(n>>m&1)B.push_front(++k),A.I;
	}
	for(int k:B)A.I;
	printf("%d\n",A.size());
	for(int w:A)printf("%d ",w);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int h(int a,int b)
{
    if(a-b>=0)
    return 1;
    else
    return 0;
}
int main()
{
    int j,i,g,n,k;
    while(~scanf("%d%d%d",&i,&j,&g))
    {
        if(h(i,j))
            n=i-j;
        else
            n=j-i;
        if(h(i,g))
            k=i-g;
        else
            k=g-i;
        if(n<k)
            printf("A\n");
        else
            printf("B\n");

    }
}


Measured memory_bytes: 128