akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>
// use library with "../library/***.hpp"
#include <vector>
#include <cassert>

class unionfind {
public:
    int _n;
    std::vector<int> d;

    unionfind(int n) :_n(n) {
        d.resize(n, -1);
    }

    int find(int x) {
        assert(0 <= x && x < _n);
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    void unite(int x, int y) {
        assert(0 <= x && x < _n);
        assert(0 <= y && y < _n);
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (d[x] > d[y]) std::swap(x, y);
        d[x] += d[y];
        d[y] = x;
    }

    bool same(int x, int y) {
        assert(0 <= x && x < _n);
        assert(0 <= y && y < _n);
        return find(x) == find(y);
    }

    int size(int x) {
        assert(0 <= x && x < _n);
        return -d[x];
    }
};

// bipartite graphs
// if the given graph is bipartite, returns the way of coloring vertices
// if not, returns {-1}
std::vector<int> is_bipartite(std::vector<std::vector<int>>& g) {
    int n = (int) g.size();
    unionfind uf(2 * n);
    for (int i = 0; i < n; ++i) {
        for (auto j : g[i]) {
            assert(0 <= j && j < n);
            if (!uf.same(i, j + n)) uf.unite(i, j + n);
            if (!uf.same(i + n, j)) uf.unite(i + n, j);
        }
    }
    // this is not bipartite graph
    if (uf.same(0, n)) {
        return {-1};
    }
    std::vector<int> color(n);
    for (int i = 0; i < n; ++i) {
        color[i] = uf.same(0, i);
    }
    return color;
}

using namespace std;

void C3Steps(std::istream& in, std::ostream& out) {
    int n, m;
    in >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        in >> a >> b;
        --a; --b;
        assert(0 <= a && a < n);
        assert(0 <= b && b < n);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> c = is_bipartite(g);
    if (c.front() == -1) {
        out << 1LL * n * (n - 1) / 2 - m << '\n';
    } else {
        long long ans = (long long) count(c.begin(), c.end(), 0);
        ans *= n - ans;
        out << ans - m << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    C3Steps(in, out);
    return 0;
}

Measured memory_bytes: 9752
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

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

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

struct Edge {
    int64_t w;
    int u, v, t;

    Edge(int64_t w, int u, int v, int t)
        : w(w), u(u), v(v), t(t) {}
};

struct DSU {
    vector<int> p, r;
    int n;

    DSU (int n): p(n), r(n, 1), n(n) {
        for (int i = 0; i < n; ++i) p[i] = i;
    }

    int parent(int x) {
        if (p[x] == x) return x;
        return p[x] = parent(p[x]);
    }

    void unite(int a, int b) {
        a = parent(a);
        b = parent(b);
        if (a == b)return;
        if (r[a] < r[b]) swap(a, b);
        p[b] = a;
        n--;
        if (r[a] == r[b]) r[a]++;
    }
};

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int64_t H, W;
    cin >> W >> H;
    vector<int64_t> p(W), q(H);
    cin >> p >> q;
    vector<Edge> e;
    for (int i = 0; i < W; ++i) {
        e.push_back({p[i], i, i + 1, 1});
    }
    for (int i = 0; i < H; ++i) {
        e.push_back({q[i], i, i + 1, 2});
    }
    sort(e.begin(), e.end(), [&](const Edge& A, const Edge& B) {
        return A.w < B.w;
    });
    int64_t ans = 0, num = 0;
    DSU w(W + 1), h(H + 1);
    for (auto& edge : e) {
        if (num >= (W + 1) * (H + 1) - 1) break;
        if (edge.t == 1) {
            int64_t k = h.n;
            ans += k * edge.w;
            num += k;
            w.unite(edge.u, edge.v);
        } else {
            int64_t k = w.n;
            ans += k * edge.w;
            num += k;
            h.unite(edge.u, edge.v);
        }
    }
    cout << ans;
}


Measured memory_bytes: 11052
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    // 整数の入力
    int n,t,c,tt,ct[110];
    bool fl=true;
    cin >> n >> t;
    for(int i=0;i<n;i++){
      cin >> c >> tt;
      ct[i]=1000*(c-1)+(tt-1);
    }
    // スペース区切りの整数の入力
    sort(ct,ct+n);
    for(int i=0;i<n;i++){
      if(ct[i]%1000<t){
        cout<< 1+(ct[i]/1000);
        fl=false;
        break;
      }
    }
    if(fl) cout<< "TLE";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int h[N];
	for(int i = 0; i < N; i++) cin >> h[i];

	int ans = h[0];
	for(int i = 1; i < N; i++) ans += max(0, h[i] - h[i - 1]);
	cout << ans;
	return 0;
}

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

li choose2(li n) {
    return n * (n - 1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> cnt(n);
    rep(i, n) cnt[a[i]]++;
    li tot = 0;
    rep(i, n) tot += choose2(cnt[i]);
    rep(i, n) {
        li ans = tot;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]] - 1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n, k;
    scanf("%d%d", &n, &k);

    vector<int> a(n);
    int i;
    ll sum=0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    vector<int> v;
    for(i=1; i<sqrt((double)sum+0.001); i++) {
        if(sum%i==0) {
            v.push_back(i);
            if(sum/i!=i) v.push_back(sum/i);
        }
    }
    sort(v.rbegin(), v.rend());

    int siz=(int)v.size();
    for(i=0; i<siz; i++) {
        int p=v[i];

        vector<pair<int,int> > z;
        int j;
        for(j=0; j<n; j++) {
            z.push_back( make_pair(a[j]%p, (p-a[j]%p)%p));
        }
        sort(z.begin(), z.end());

        ll sum0=0;
        for(j=0; j<n; j++) {
            sum0+=z[j].second;
        }
        ll sum1=0;
        for(j=0; j<n; j++) {
            sum1 += z[j].first;
            sum0 -= z[j].second;
            if(sum0==sum1) {
                break;
            }
        }
        if(j<n) {
            if(sum0<=k) {
                printf("%d\n", v[i]);
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

int main(){
    int n, q;
    ll k;
    cin >> n >> k >> q;
    vector<int> a(q);
    REP(i, q){
        cin >> a[i];
    }

    vector<ll> h(n);
    REP(i, n){
        h[i] = k;
    }

    REP(i, q){
        h[a[i] - 1]++;
    }

    REP(i, n){
        if(h[i] - q > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.numL;
        var res = 0L;
        for (var i = 1L; i * i < num; i++)
            if (num % i == 0 && num / i - 1 != i)
                res += num / i - 1;
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
const int maxn = 100010;
int main()
{
    int N;
    cin >> N;
    int dp[maxn], vh[maxn];
    for (int i = 0; i < N; i++)
    {
        cin >> vh[i];
    }
    dp[0] = 0;
    dp[1] = abs(vh[0] - vh[1]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i - 1] + abs(vh[i - 1] - vh[i]), dp[i - 2] + abs(vh[i - 2] - vh[i]));
    }
    cout << dp[N - 1];
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://atcoder.jp/contests/abc179/tasks/abc179_c

void rrrrrrrrrrrrrresi() {
  int N;
  cin>>N;
  ll ans=0;
  for(int i=1;i<N;i++) {
    for(int j=1;j*i<N;j++) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int Q=1;
//cin>>Q;
while(Q--)
  rrrrrrrrrrrrrresi();
return 0;
}




Measured memory_bytes: 3652
N = int(input()) #入力->3(数値単独型)
L = map(int, input().split())#入力->3 4(数値分割型)
flag = 0
listn = []
for i in L:
    if (i % 2) == 0:
        listn.append(i)

for j in listn:
    if ((j % 3)==0) | ((j % 5)==0):
        continue
    else:
        flag=1
        break

if flag == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int ans = Math.max(A+A-1, B+B-1);
		ans = Math.max(ans, A+B);


		System.out.print(ans);
		reader.close();

	}

}





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

cnt_set = {}
total = 0
for a in A:
    if a in cnt_set:
        cnt_set[a] += 1
    else:
        cnt_set[a] = 1

    if cnt_set[a] == 2:
        total += 1
    elif cnt_set[a] > 2:
        total += (cnt_set[a]-1)

for a in A:
    if cnt_set[a] == 2:
        print(total - 1)
    elif cnt_set[a] < 2:
        print(total)
    else:
        print(total - (cnt_set[a]-1))


Measured memory_bytes: 24748
#include <bits/stdc++.h>
using namespace std;
int n,a[123456],A;
long long s=9999999999;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<s){
            s=a[i];
            A=(i+1);
        }
    }
    cout<<A<<endl;
}



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

string s,t;
int q;
int r1[111111],r2[111111];


int main(){
	cin>>s>>t;
	
	rep(i,s.size())r1[i]=(s[i]=='A')? 1:2;
	rep(i,t.size())r2[i]=(t[i]=='A')? 1:2;

	rep2(i,1,s.size())r1[i]+=r1[i-1];
	rep2(i,1,t.size())r2[i]+=r2[i-1];

	cin>>q;
	rep(i,q){
		int a,b,c,d;		
		cin>>a>>b>>c>>d;
		int x,y;
		a--;b--;c--;d--;
		x=r1[b];
		if(a>0)x-=r1[a-1];
		y=r2[d];
		if(c>0)y-=r2[c-1];

		if(x%3==y%3)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
ll f(int n) {
    ll ans = 1;
    for (ll i = 2; i <= n; ++i) ans = (ans * i) % mod;
    return ans;
}
void solve(){
    int n, m;
    cin >> n >> m;
    if (abs (n - m) == 1) cout << (f(n) * f(m)) % mod;
    else if (abs(n - m) == 0) cout << (2ll * f(n) * f(m)) % mod;
    else cout << 0;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    ll n;
    cin >> n;
  	n--;

    ll ans = n * (n + 1) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    cin >> num[i];
  }
  int tmp;
  for(int i = 0; i < N; i++){
    for(int j = 1; j< N; j++){
      if(num[j] > num[j-1]){
        tmp = num[j];
        num[j] = num[j-1];
        num[j-1] = tmp;
      }
    }
  }
  /*for(int i = 0; i < N; i++){
    cout << num[i] << " ";
  }
  cout << "バブルソートできたか確認" << endl;*/
  int ans = 0;
  int fugou = 1;
  for(int i = 0; i<N; i++){
    if(i%2 != 0){
      fugou = -1;
    }
    else{
      fugou = 1;
    }
    ans = ans+num[i]*fugou;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(200000, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    sort(cnt.begin(), cnt.end());

    int kind = 0;
    for (int i = 1; i <= 200000; i++) {
        if (cnt[i] != 0) kind++;
    }
    
    if (kind <= k) cout << 0 << endl;
    else {
        int ans = 0;
        for (int i = 1; i <= 200000; i++) {
            if (cnt[i] == 0) continue;
            ans += cnt[i];
            kind--;
            if (kind == k) {
                cout << ans << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int x = sc.nextInt();
		int t = sc.nextInt();
		int a = 0;
      	int b = 0;
      	while (b < n){
          a += t;
          b += x;
        }
        // 出力
		System.out.println(a);
	}
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5;
int n;
ll sum, a[maxn + 10], a1, a2;
ll s[maxn + 10], mn;
bool f[maxn + 10];

bool chk(ll x) {
	f[0] = 1; mn = 0;
	for (int i = 2; i <= n; i += 2) {
		if (s[i - 1] - mn >= x) {
			f[i] = 1; mn = min(mn, s[i]);
		} else f[i] = 0;
	}
	for (int i = 0; i <= n; i += 2)
		if (f[i] && s[n] - s[i] >= x) return 1;
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]); sum += a[i];
	}
	for (int i = 1; i <= n; ++i) 
		if (i & 1) a1 += a[i];
		else a2 += a[i];
	if (~n & 1) {
		a1 = max(a1, a2);
		printf("%lld %lld", a1, sum - a1);
		return 0;
	}
	for (int i = 1; i <= n; ++i) {
		if (~i & 1) a[i] = -a[i];
		s[i] = s[i - 1] + a[i];
	}
	ll l = 0, r = 1e9;
	while (l != r) {
		ll mid = (l + r + 1) >> 1;
		if (chk(mid)) l = mid;
		else r = mid - 1;
	}
	a1 = max(a1, a2 + l);
	printf("%lld %lld", a1, sum - a1);
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
    ll N;
    cin>>N;
    ll ans = 0;
    ans = pow(10LL,N,mod)-2LL*pow(9LL,N,mod)+pow(8LL,N,mod);
    ans %= mod;
    if(ans<0) ans += mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>

const int MAXN = 100000;

int find(int i);
bool merge(int L, int R, int D);

int id[MAXN + 1];
int distance[MAXN + 1];

int main(void){
  int N,M;

  std::cin >> N >> M;

  for (int i = 1; i <= N; i++) {
    id[i] = i;
    distance[i] = 0;
  }

  for (int i = 1; i <= M; i++) {
    int L, R, D;
    std::cin >> L >> R >> D;

    if (!merge(L, R, D)) {
      std::cout << "No";
      return 0;
    }
  }
  std::cout << "Yes";
  return 0;
}

bool merge(int L, int R, int D) {
  int originL = find(L);
    int originR = find(R);
    if (originL == originR) {
      return (distance[L] + D) == distance[R];
    } else {
      distance[originR] = distance[L] + D - distance[R];
      id[originR] = originL;
      return true;
    }
}

int find(int i) {
  int tmp = i;
  while(id[i] != i) {
    i = id[i];
    distance[tmp] += distance[i];
  }
  id[tmp] = i;
  return i;
}


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

void print_map(const vector<vector<int>> m){
    for(int i = 0; i < m.size(); ++i) {
        for(int j = 0; j < m.at(0).size(); ++j) {
            cout << m.at(i).at(j) << " ";
        }
        cout << endl;
    }
}

int main(void)
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> map;
    vector<vector<int>> cost_map(H, vector<int>(W, 10000));
    for(int i = 0; i < H; ++i) {
        string a;
        cin >> a;
        vector<int> gyo;
        for(int j = 0; j < W; ++j) {
            if(a.substr(j, 1) == "#") {
                gyo.push_back(1);
            } else {
                gyo.push_back(-1);
            }
        }
        map.push_back(gyo);
    }
//    print_map(map);
    if(map.at(0).at(0) == -1) {
        cost_map.at(0).at(0) = 0;
    } else {
        cost_map.at(0).at(0) = 1;
    }
    while(1) {
        int n = 0;
        for(int i = 0; i < map.size(); ++i) {
            for(int j = 0; j < map.at(0).size(); ++j) {
                if(cost_map.at(i).at(j) < 10000 && map.at(i).at(j) == -1) {
                    n = cost_map.at(i).at(j);
                    if(i+1 < map.size() && map.at(i+1).at(j) == -1) {
                        cost_map.at(i+1).at(j) = min(cost_map.at(i+1).at(j),n);
                    }  
                    if(j+1 < map.at(0).size() && map.at(i).at(j+1) == -1) {
                        cost_map.at(i).at(j+1) = min(cost_map.at(i).at(j+1),n);
                    }
                    if(i+1 < map.size() && map.at(i+1).at(j) == 1) {
                        cost_map.at(i+1).at(j) = min(cost_map.at(i+1).at(j), n+1);
                    }  
                    if(j+1 < map.at(0).size() && map.at(i).at(j+1) == 1) {
                        cost_map.at(i).at(j+1) = min(cost_map.at(i).at(j+1), n+1);
                    }
                } else if(cost_map.at(i).at(j) < 10000 && map.at(i).at(j) == 1) {
                    n = cost_map.at(i).at(j);
                    if(i+1 < map.size() && map.at(i+1).at(j) == 1) {
                        cost_map.at(i+1).at(j) = min(cost_map.at(i+1).at(j), n);
                    }  
                    if(j+1 < map.at(0).size() && map.at(i).at(j+1) == 1) {
                        cost_map.at(i).at(j+1) = min(cost_map.at(i).at(j+1), n);
                    }
                    if(i+1 < map.size() && map.at(i+1).at(j) == -1) {
                        cost_map.at(i+1).at(j) = min(cost_map.at(i+1).at(j), n);
                    }  
                    if(j+1 < map.at(0).size() && map.at(i).at(j+1) == -1) {
                        cost_map.at(i).at(j+1) = min(cost_map.at(i).at(j+1), n);
                    }
                }
            }
        }
//        print_map(cost_map);
        if(cost_map.at(H-1).at(W-1) < 10000) break;
    }
//    print_map(cost_map);
    cout << cost_map.at(H-1).at(W-1) << endl;
}




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

int main(){
  long long x;
  cin>>x;
  
  long long ans=x/11;
  if(x%11==0){
    cout<<2*ans<<endl;
  }else if(x%11<=6){
    cout<<2*ans+1<<endl;
  }else{
    cout<<2*ans+2<<endl;
  }
}

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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a + 3);
	cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	while (1) {
		int H, W;
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			return 0;
		}

		for (int i = 0; i < H; i++) {
			for (int i2 = 0; i2 < W; i2++) {
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>




int ans=0;

int a[500001];

int n;




void merge(int left,int mid,int right)

{

 int i,j,k;




 int n1=mid-left;

 int n2=right-mid;

 

 int l[n1+1],r[n2+1];




 for(i=0;i<n1;i++){

  l[i]=a[left+i];

 }

 for(i=0;i<n2;i++){

  r[i]=a[mid+i];

 }




 l[n1]=1000000001;

 r[n2]=1000000001;

 i=0;

 j=0;




 for(k=left;k<right;k++){

  ans++;

  if(l[i]<=r[j])

   a[k]=l[i++];

  else

   a[k]=r[j++];

 }

}




void mergeSort(int left,int right)

{

 int mid;




 if(left+1<right){

  mid=(left+right)/2;

  mergeSort(left,mid);

  mergeSort(mid,right);

  merge(left,mid,right);

 }

}




int main(void)

{

 int i;




 scanf("%d",&n);

 for(i=0;i<n;i++){

  scanf("%d",&a[i]);

 }

 

 mergeSort(0, n);




 for(i=0;i<n-1;i++){

  printf("%d ",a[i]);

 }

 printf("%d\n",a[n-1]);

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




 return 0;

}

Measured memory_bytes: 6576
#include<iostream>

using namespace std;

int main() {
	int n,a[1000];
	cin >> n;
	for (int i=0;i<n;i++){ cin >> a[i];}
	for (int j=n-1;j>0;j--){
		cout << a[j] << " " ;
	}
	cout << a[0] << endl;

	return 0;
}


Measured memory_bytes: 3084
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

n = int(input().rstrip())
if n % 2 == 0:
	print((n//2)**2)
else:
	print(n//2 * (n//2 + 1))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n,a,b;
	cin>>n>>a>>b;
	int ans;
	if(a*n < b)cout<<a*n<<endl;
	else cout<<b<<endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  long sum = 0;
  for (int i = 0; i < S.size(); i++) {
    sum += S.at(i) - '0';
  }
  cout << ((sum % 9) ? "No" : "Yes") << "\n";
}

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

const int W = 30;
const int H = 60;
const int INF = 1 << 29;

struct foot{
  int ly, lx, ry, rx;
  foot(int ly=0, int lx=0, int ry=0, int rx=0):ly(ly),lx(lx),ry(ry),rx(rx){}
};

struct state{
  foot p;
  int c;
  bool isRight;
  state(foot p=foot(0,0,0,0), bool ir=true, int c=0):p(p),c(c),isRight(ir){}
  bool operator < (const state &s) const {
    return c > s.c;
  }
};

int w,h,v[H][W];

bool check(const int &y, const int &x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return v[y][x] != -1;
}

vector<foot> nextFoot(const state &s){
  vector<foot> res;

  for(int i=1;i<=3;i++){
    for(int j=-3+i;j<=3-i;j++){
      if(s.isRight){
        if(!check(s.p.ly+j, s.p.lx+i)) continue;
        res.push_back(foot(s.p.ly, s.p.lx, s.p.ly+j, s.p.lx+i));
      } else {
        if(!check(s.p.ry+j, s.p.rx-i)) continue;
        res.push_back(foot(s.p.ry+j, s.p.rx-i, s.p.ry, s.p.rx));
      }
    }
  }

  return res;
}

  int d[H][W][H][W];

int solve(){
  priority_queue<state> q;
  state u,u2;  
  vector<foot> next;

  for(int i=0;i<h*w;i++) for(int j=0;j<h*w;j++) d[i/w][i%w][j/w][j%w] = INF;

  for(int i=0;i<w;i++){
    if(v[h-1][i] != -3) continue;
    u = state(foot(h-1, i, h-1, i), true);
    next = nextFoot(u);
    for(int j=0;j<next.size();j++){
      if(v[next[j].ry][next[j].rx] < 0) q.push(state(next[j], false));
      else q.push(state(next[j], false, v[next[j].ry][next[j].rx]));
    }
    
    u.isRight = false;
    next = nextFoot(u);
    for(int j=0;j<next.size();j++){
      if(v[next[j].ly][next[j].lx] < 0) q.push(state(next[j], true));
      else q.push(state(next[j], true, v[next[j].ly][next[j].lx]));
    }
  }
  
  while(!q.empty()){
    u = q.top();
    q.pop();

    if(v[u.p.ly][u.p.lx] == -2 || v[u.p.ry][u.p.rx] == -2){
      return u.c;
    }

    //cout << u.p.ly << ' ' << u.p.lx << ' ' << u.p.ry << ' ' << u.p.rx << ' ' << u.c << endl;

    next = nextFoot(u);
    for(int i=0;i<next.size();i++){
      if(u.isRight){
        u2 = state(next[i], !u.isRight);
        if(v[u2.p.ry][u2.p.rx] < 0) u2.c = u.c;
        else u2.c = u.c + v[u2.p.ry][u2.p.rx];
      } else {
        u2 = state(next[i], !u.isRight);
        if(v[u2.p.ly][u2.p.lx] < 0) u2.c = u.c;
        else u2.c = u.c + v[u2.p.ly][u2.p.lx];
      }
      if(d[u2.p.ly][u2.p.lx][u2.p.ry][u2.p.rx] <= u2.c) continue;
      d[u2.p.ly][u2.p.lx][u2.p.ry][u2.p.rx] = u2.c;
      q.push(u2);
    }
  }

  return -1;
}

int main(){
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        char c;
        cin >> c;
        if(c == 'S') v[i][j] = -3;
        else if(c == 'T') v[i][j] = -2;
        else if(c == 'X') v[i][j] = -1;
        else v[i][j] = c - '0';
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 13960
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		String S = in.next();
		char small = Character.toLowerCase(S.charAt(K-1));
		System.out.println(S.substring(0,K-1)+small+S.substring(K));
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

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

int main(){
	int n,a[100000],ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		if(i + 1 == a[i]){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

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


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

const int MOD=1000000007;

void add_self(int &a, int b){
  a+=b;
  if(a>=MOD){
    a-=MOD;
  }
}

void sub_self(int &a, int b){
  a-=b;
  if(a<0){
    a+=MOD;
  }
}


int main(){
  fastio; 
  
  int N,W;
  cin >> N >> W;
  vi w(N),v(N);
  for0(i,N){
    cin >> w[i] >> v[i];
  }
  vvll dp(N,vll(W+1));
  for0(i,N){
    if(i==0){
      dp[i][w[i]]=v[i];
      continue;
    }
    for0(j,W+1){
      dp[i][j]=dp[i-1][j];
      if(j>=w[i]){
        dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
      }
    }
  }
  ll ans=0;
  for0(i,W+1){
    ans=max(ans,dp[N-1][i]);
  }
  cout << ans;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int M,K;
    Scd2(M,K);
    int N = 1<<M;

    int ans = 0;
    if( M == 1 ){
        K--;
        if( K == -1 ){
            printf ("%d ", 1);
            printf ("%d ", 0);
            printf ("%d ", 0);
            printf ("%d\n", 1);
            return 0;
        }
        K+=2;
    }
    if( K > N-1 ) ans = -1;

    if( ans == -1 ){
        printf ("%d\n", ans );
    }else{
        Rep(i,N) if( i==K ) continue; else printf ("%lld ", i );
        printf ("%d ", K );
        RRep(i,N) if( i==K ) continue; else printf ("%lld ", i );
        printf ("%d\n", K );
    }

    return 0;
}






Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	ll n, k;
	cin >> n >> k;
	if (n >= k)
		n %= k;
	ll mn = n;
	for (int i = 0; i < 2; i++) {
		n = k - n;
		mn = min(mn, n);
	}
	cout << mn << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
    for(int i=0;i<s.size();i++)
	{
    if(s[i]!=t[i])
	{
		cout<<"No";
		return 0;
	}
	} 
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144C
{
    class Program
    {
        public static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            var ans = n - 1;

            for (int i = 1; i < System.Math.Pow(n, 0.5) + 1; i++) {
                if (n % i == 0) {
                    var m = i + (n / i) - 2;
                    if (m < ans) {
                        ans = m;
                    }  
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
    int A1,A2,A3,sum;
    scanf("%d %d %d",&A1,&A2,&A3);
    sum=A1+A2+A3;
    if(sum >= 22)
    {
        printf("bust\n") ;
    }
    else
    {
        printf("win\n");
    }
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes";
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No";
            break;
        }
    }
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <cstddef>
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int f = 0;
    for(int i = 0; i <3; i++)
    {
        if(S.at(i)==T.at(i)) f += 1;
    }
    cout << f << endl;
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  long long ans{};
  for (int i = 0; i != N; ++i) {
    auto d = min(B[i], A[i] + A[i + 1]);
    ans += d;
    A[i + 1] -= max(d - A[i], 0);
  }
  cout << ans << endl;
}


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

#define ll long long 

const ll mod = 1e9 +7 ; 

int main(){
      
     ll s ; 
     cin >> s; 
     
     if (s < 3 ) {
           
           cout << "0" ; 
           return 0 ; 
     }
     
     if (s == 3 ) {
          
           cout << "1" ; 
           
           return 0 ; 
     }
     
     ll dp[2001] ; 
     
     dp[0] = 0 ; 
     dp[1] = 0 ;
     dp[2] = 0 ; 
     dp[3] = 1 ; 
     
     for(ll i = 4 ; i <= s ; i ++ ) {
            
            ll state = 0 ; 
            
            for(ll j = 3 ; j <= i ; j ++ ){
                  
                   state += ((dp[i - j])%mod) ; 
            }
            
            dp [i] = (state + 1)%mod ; 
     }
     
     cout << dp[s]%mod << "\n";  
     
     
     
     
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt();
		long[][] A=new long[n][m],B=new long[m][l],C=new long[n][l];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				A[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<l;j++){
				B[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				for(int k=0;k<m;k++){
					C[i][j]=C[i][j]+A[i][k]*B[k][j];
				}
				if(j==l-1){
					System.out.print(C[i][j]);
					System.out.println();
				}else
					System.out.print(C[i][j]+" ");
			}
		}
	}
}



Measured memory_bytes: 53588
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2
        if a[i]<=j: dp[i+1][j] += dp[i][j-a[i]]
        dp[i+1][j] %= mod
print(dp[n][s])

Measured memory_bytes: 132440
import           Control.Applicative
import           Data.List

splitSet :: [String] -> [[String]]
splitSet xs = unfoldr f xs
  where
    f [] = Nothing
    f (a:b:cs) = Just (a : b : ds, fs)
      where
        (ds, fs) = splitAt (read b) cs

shuffle :: [String] -> String
shuffle (cards:_:hs) = foldl' (\acc h -> one (read h) acc) cards hs
  where
    one :: Int -> String -> String
    one n xs = let (as, bs) = splitAt n xs
                in bs ++ as

main :: IO ()
main = do
    cs <- takeWhile (/= "-") . lines <$> getContents
    let as = fmap shuffle $ splitSet cs
    mapM_ putStrLn as



Measured memory_bytes: 4124
from sys import exit
N,K = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()

# print(A)
sums = []
maximum_size = len(bin(max(A))) - 2
countdic = [{"0":0,"1":0} for _ in range(maximum_size)]
for i in range(N):
    # print(bin(A[i]))
    ta = bin(A[i])[2:].zfill(maximum_size)
    ta = ta[::-1]
    # print(ta)
    # print(ta)
    for i in range(len(ta)):
        if ta[i] == "0":
            countdic[i]["0"] +=1
        else:
            countdic[i]["1"] +=1
# print(countdic)
ans = ""
for num in countdic:
    if num["0"] < num["1"]:
        ans = "0" + ans
    else:
        ans = "1" + ans
lim = bin(K)[2:]
# print("lim:" + str(lim))
if K != 0:
    maxcand_size = len(bin(K)) - 2
    # print(maxcand_size)
    ans = abs(maxcand_size - len(ans))*"1" + ans
    ans = ans[-maxcand_size:]
    # if(int(ans,2) > K):
    # print(int(ans,2))
    if(int(ans,2) > K):
        for i in range(1,len(lim)):
            if(lim[i] == "0" and ans[i] == "1"):
                ans = ans[:i] + "0" + ans[i+1:]
                if(int(ans,2) <= K):break
    # print(int(ans,2))
else:
    ans = "0"
# print(bin(K))
# print("asako" + str(maxcand_size))

# print(ans)
# print(int(ans,2))
ans = int(ans,2)
answer = 0
# print(ans)
for i in range(N):
    answer+=ans^A[i]
print(answer)


Measured memory_bytes: 14620
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e4+5;

int main(){
	int r; cin >> r;
	cout << r*r;
}

Measured memory_bytes: 256
n = int(input())
d = [
    list(map(int, input().split()))
    for _ in range(n)
]

c = 0
maxc = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
        maxc = max(maxc, c)
    else:
        c = 0
if maxc >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    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<tuple<int, int, int, int>> ans;
    rep(i, h){
        rep(j, w){
            if(a[i][j] % 2 == 0){
                continue;
            }

            if(i == h - 1 && j == w - 1){
                continue;
            }

            if(j == w - 1){
                ans.emplace_back(i+1, j+1, i+2, j+1);
                a[i+1][j]++;
                continue;
            }

            ans.emplace_back(i+1, j+1, i+1, j+2);
            a[i][j+1]++;
        }
    }

    cout << ans.size() << endl;
    for(tuple<int, int, int, int> t : ans){
        cout << get<0>(t) << " ";
        cout << get<1>(t) << " ";
        cout << get<2>(t) << " ";
        cout << get<3>(t) << endl;
    }

    return 0;
}


Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
 
bool hasOdd(vector<int> a);
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
      for(int i = 0;i<a.size();i++){
      cin >> a.at(i);
    }
  int count =0;
  while(!hasOdd(a)){
    for(int i = 0;i<a.size();i++){
      a.at(i) /=2;
    }
    count++;
  }

  cout << count;
  
 
}
bool hasOdd(vector<int> a){
  bool result = false;
  for(int elm : a){
    if(elm % 2 !=0){
      result = true;
      break;
    }
  }
  return result;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    long a,b;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Read();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        if(a < 0 && b < 0 && (b-a)%2 == 0){
            sb.Append("Negative\n");
        }
        else if(a <= 0 && b >=0){
            sb.Append("Zero\n");
        }
        else{
            sb.Append("Positive\n");
        }
    }
    void Read(){
        string[] str = Console.ReadLine().Split(' ');
        a = Int64.Parse(str[0]);
        b = Int64.Parse(str[1]);
    }    
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  REP(i, N) cin >> x[i];
  sort(rall(x));
  int X = x[0];
  vector<vector<vector<int>>> dp(
      N + 1, vector<vector<int>>(N + 1, vector<int>(N * X + 1, 0)));
  dp[0][0][0] = 1;
  REP(i, N) REP(j, N) REP(k, N * X) {
    dp[i + 1][j][k] += dp[i][j][k];
    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
  }
  int ans = 0;
  FOR(i, 1, N + 1) { ans += dp[N][i][i * A]; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 52224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    System.out.println(calcGreatestCommonDivisor(a,b));
  }
  
  static int calcGreatestCommonDivisor(int x, int y) {
    // x≥y のとき gcd(x,y) と gcd(y,xをyで割った余り) は等しい
    if (x < y) {
      int tmp = x;
      x = y;
      y = tmp;
    }
    while (y > 0) {
      int r = x % y;
      x = y;
      y = r;
    }
    return x;
  }
}



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

using namespace std;

int n, x, rating[8], topster = 0;
int main() {

	scanf("%d", &n);

	for (int i=0; i<n; ++i) {
		scanf("%d", &x);

		if (x <= 399) 
			rating[0] = 1;
		if (x >= 400 && x <=799)
			rating[1] = 1;
		if (x >= 800 && x <=1199)
			rating[2] = 1;
		if (x >= 1200 && x<=1599)
			rating[3] = 1;
		if (x >= 1600 && x <= 1999)
			rating[4] = 1;
		if (x >=2000 && x <= 2399)
			rating[5] = 1;
		if (x >= 2400 && x <= 2799)
			rating[6] = 1;
		if (x >= 2800 && x <= 3199)
			rating[7] = 1;
		if (x >= 3200)
			++topster;
	}

	int mini = 0;
	for (int i=0; i<=7; ++i)
		mini += rating[i];

	int maxi = mini+topster;

	printf("%d %d\n", max(mini, 1), maxi);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,apoint=0,bpoint=0;
  char a[100],b[100];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",a,b);
    if(strcmp(a,b) == 0){
      apoint++;
      bpoint++;
    }
    else if(strcmp(a,b) > 0) apoint += 3;
    else bpoint += 3;
  }
  printf("%d %d\n",apoint,bpoint);
  return 0;
}



Measured memory_bytes: 2148
n = int(input())
a_l = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= a_l[i]
    if ans > 10**18:
        if 0 not in a_l[i:n]:
            print(-1)
        else:
            print(0)
        quit()
    if ans == 0:
        print(0)
        quit()


if ans > 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 21604