akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

main()
{
  int h, w;
  char mp[10][10];
  int cnt=0;

  cin >> h >> w;
  for ( int i = 0 ; i < h ; ++i) {
    for ( int j = 0 ; j < w ; ++j) {
      cin >> mp[i][j];
    }
  }

  for (int i = 0 ; i < h ; ++i) {
    for ( int j = 0 ; j < w ; ++j) {
      if ( mp[i][j] == '#') {
	cnt ++;
      }
    }
  }

  if ( cnt == (h+w) - 1 ){
    cout << "Possible" << endl;
  } else { 
    cout << "Impossible" << endl;
  }

  return (0);
}


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

const int N = 101;
int c[N] , v[N];

int main()
{
    int n;
    cin >> n;
    for ( int i = 0; i < n; ++i )
        cin >> v[i];
    for ( int i = 0; i < n; ++i )
        cin >> c[i];

    int mx = 0;
    for ( int i = 0; i < n; ++i ){
        if ( v[i] > c[i] ){
            mx += (v[i] - c[i]);
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int n,m;
int main()
{
    ll mod = 1e9+7;
   cin>>n>>m;
   if(abs(n-m) > 1)
   {
       cout<<0;
   }
   else
   {
           ll maxx = max(n,m);
           ll minx = min(n,m);
           ll ans = 1;
           for(ll i=1;i<=maxx;i++)
           {
               ans = ans*i;
               ans%=mod;
           }

           for(ll i=1;i<=minx;i++)
           {
               ans = ans*i;
               ans%=mod;
           }
       if(abs(n-m) == 1)
       {
           cout<<ans<<endl;
       }
       else
       {
           cout<<(ans*2)%mod;
       }
   }
}


Measured memory_bytes: 256
from bisect import*
n,*t=map(int,open(0).read().split())
s=sorted
a,b,c=s(t[:n]),s(t[n:n+n]),s(t[n+n:])
x=[n-bisect(c,i)for i in b]+[0]
for i in range(n):x[-i-2]+=x[~i]
print(sum(x[bisect(b,i)]for i in a))

Measured memory_bytes: 127704
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b==1):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Measured memory_bytes: 9144
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 10 21:38:08 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t N;
  cin >> N;

  vector<int32_t> arr(N);
  int32_t max_val = INT32_MIN;
  int32_t min_val = INT32_MAX;
  int32_t max_index = 0;
  int32_t min_index = 0;
  bool all_positive = true;
  bool all_negative = true;
  for (uint32_t i = 0; i < N; i++) {
    cin >> arr[i];
    if (arr[i] > 0) {
      all_negative = false;
    } else if (arr[i] < 0) {
      all_positive = false;
    }
    if (max_val < arr[i]) {
      max_index = i;
      max_val = arr[i];
    }
    if (arr[i] < min_val) {
      min_index = i;
      min_val = arr[i];
    }
  }

  if (all_positive) {
    cout << N - 1 << endl;
    for (uint32_t i = 1; i < N; i++) {
      cout << i << " " << i + 1 << endl;
    }
  } else if (all_negative) {
    cout << N - 1 << endl;
    for (int32_t i = N; i > 1; i--) {
      cout << i << " " << i - 1 << endl;
    }
  } else if (abs(min_val) <= abs(max_val)) {
    cout << 2 * N - 1 << endl;
    for (uint32_t i = 1; i <= N; i++) {
      cout << max_index + 1 << " " << i << endl;
    }
    for (uint32_t i = 1; i < N; i++) {
      cout << i << " " << i + 1 << endl;
    }
  } else {
    cout << 2 * N - 1 << endl;
    for (uint32_t i = 1; i <= N; i++) {
      cout << min_index + 1 << " " << i << endl;
    }
    for (int32_t i = N; i > 1; i--) {
      cout << i << " " << i - 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b / x - (a - 1) / x;
    if (a == 0) {
        ans = b / x + 1;
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; 
  cin >> N;
  long double s = 0;
  for(int i = 0; i < N; i++){
    double tmp1;
    string tmp2;
    cin >> tmp1;
    cin >> tmp2;
    if(tmp2=="JPY"){
      s += tmp1;
    } else { 
      s += tmp1 * 380000.0;
    }
  }
  cout << std::setprecision(10) <<  s << endl;
} 

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define trav(it, a) for(auto& it : a)
#define allin(it, a) for(auto it : a)
#define read(v, a, b) for(int i=(a); i<(b); i++) scanf("%d", &v[i]);
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl

const int maxn = 1e3 + 100, MOD = 1e9 + 7;

char grid[maxn][maxn];

int main(){
	int n, m; scanf("%d %d", &n, &m);
	
	vector<vi> dp(n, vi(m, 0));
	
	rep(i,0,n){
		scanf("%s", grid[i]);
	}

	for(int i = 0; i < n && grid[i][0] == '.'; i++)
		dp[i][0] = 1;
	
	for(int i = 0; i < m && grid[0][i] == '.'; i++)
		dp[0][i] = 1;
	
	rep(i,1,n)
		rep(j,1,m)
			if(grid[i][j] == '.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
				
	printf("%d\n", dp[n-1][m-1]);
}


Measured memory_bytes: 5248
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	class E implements Comparable<E> {
		double v;
		int a;
		int b;

		E(double vv, int aa, int bb) {
			v = vv;
			a = aa;
			b = bb;
		}

		public int compareTo(E tar) {
			return v - tar.v > 0 ? 1 : -1;
		}
	}

	class S {
		double x;
		double y;
		double z;
		double r;

		S(double xx, double yy, double zz, double rr) {
			x = xx;
			y = yy;
			z = zz;
			r = rr;
		}

		double dist(S t) {
			double xx = x - t.x;
			double yy = y - t.y;
			double zz = z - t.z;
			double dd = xx * xx + yy * yy + zz * zz;
			double d = Math.sqrt(dd);

			double r2 = r + t.r;

			if (r2 < d) {
				return  d-r2;
			}
			return 0;
		}
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			S[] s = new S[n];
			for (int i = 0; i < n; i++) {
				s[i] = new S(sc.nextDouble(), sc.nextDouble(), sc.nextDouble(),
						sc.nextDouble());
			}
			
			PriorityQueue<E> q = new PriorityQueue<E>();

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					double dd = s[i].dist(s[j]);
					q.add(new E(dd,i,j));
				}
			}
			
			int data[] = new int[n];
			int ne = 0;
			double sum = 0;
			for (;;) {
				if(q.isEmpty()){
					break;
				}
				E now = q.poll();
				if(data[now.a] != 0 && data[now.b] == data[now.a] ){
					continue;
				}
				ne++;
				if((data[now.a] | data[now.b]) == 0){
					data[now.a] = ne;
					data[now.b] = ne;
				}
				if(data[now.a] == 0){
					data[now.a] = data[now.b];
				}
				if(data[now.b] == 0){
					data[now.b] = data[now.a];
				}else{
					for(int i =0 ; i< n ;i++){
						
						if(i!= now.b && data[i] == data[now.b]){
							data[i]= data[now.a];
						}
					}
					data[now.b] = data[now.a];
				}
				sum += now.v;
				if(ne == n-1){
					break;
				}
			}
			long res = (long)(sum * 1000 + 0.5);
			
			System.out.print((res /1000));
			System.out.printf(".%03d\n",(res %1000));
		}
	}

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

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

using namespace std;

int main() {

    int n;
    cin >> n;
    vector <int> a(n);
    const long long INF = (long long) 1e10;

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

    vector <long long> pr (n);
    pr[0] = a[0];

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


    long long ans = INF;
    for (int i = 0; i < n - 1; ++i) {
        ans = min (abs (pr[i] - pr[n - 1] + pr[i]), ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
inf = 1e9
dp = [inf] * (1 << n)
dp[0] = 0

for _ in range(m):
  a, b = map(int, input().split())
  cs = list(map(int, input().split()))
  r = 0
  for c in cs:
    r |= 1 << (c - 1)
  for i in range(1 << n):
    if dp[i | r] > dp[i] + a:
      dp[i | r] = dp[i] + a
      
if dp[(1 << n) - 1] == inf:
  print("-1")
else:
  print("{}".format(dp[(1 << n) - 1]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int flag=0;
    for(int i=min(a,b);i>=1;i--) {
        if(a%i==0&&b%i==0)flag++;
        if(flag==k){
            cout << i << endl;
            break;
        }
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    REP(i, 0, n) cin >> a[i] >> b[i];
    REP(i, 0, m) cin >> c[i] >> d[i];
    REP(i, 0, n) {
        int point = -1, dist = 1e9;
        REP(j, 0, m) {
            int dst = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist > dst) {
                point = j + 1;
                dist = dst;
            }
        }
        cout << point << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = sorted(p)

cnt = 0
for i in range(n):
  if p[i] != q[i]:
    cnt += 1
    
if cnt == 0 or cnt == 2:
  print('YES')
  
else:
  print('NO')
  


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  LCIN(N);
  vector< ll > a(N);
  REP(i, N)
    cin >> a[i];

  sort(ALL(a));

  ll ans = a[N - 1] - a[0];
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin >>n>>k;
  ll x[n];
  for(ll i=0;i<n;i++) cin >>x[i];
  ll ans=-1;
  if(n==1){
    cout <<abs(x[0])<<endl;
    return 0;
  }
  for(ll i=0;i<=n-k;i++){
    ll j=i+k-1,l;
    if(x[i]>=0&&x[j]>=0){
      l=x[j];
      if(ans==-1) ans=l;
      else ans=min(ans,l);
    }
    else if(x[i]<0&&x[j]<0){
      l=-x[i];
      if(ans==-1) ans=l;
      else ans=min(ans,l);
    }
    else if(x[i]<0&&x[j]>=0){
      l=min(abs(-x[i]),x[j])*2+max(abs(-x[i]),x[j]);
      if(ans==-1) ans=l;
      else ans=min(ans,l);
    }
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        string[] s = new string[N];
        Dictionary<string, long> d = new Dictionary<string, long>();
        for (int i = 0; i < N; i++)
        {
            char[] _s = NextString().ToArray();
            Array.Sort(_s);
            s[i] = new string(_s);
            if (!d.ContainsKey(s[i])) d[s[i]] = 0;
            d[s[i]]++;
        }
        long ans = 0;
        foreach (var e in d) { ans += (e.Value - 1) * e.Value / 2; }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 30776
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int res = 1;
	while (res < b) {
		ans++;
		res += a - 1;
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int a,b;
    if(N==2)cin>>a>>b;
    if(N==1)PUTS("Hello World");
    if(N==2)PUTS(a+b);
}

Measured memory_bytes: 256
S = [i for i in input()]

check = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s == 'L':
        check = 1
    if i % 2 == 1 and s == 'R':
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,MAX=0;
  map<int,int> mp;
  while(cin >> n){
    mp[n]++;
    MAX=max(MAX,mp[n]);
  }
  for(int i=1;i<=100;i++){
    if(mp[i]==MAX){
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0,x;
	cin>>n;
	int a[101];
	for(int i=1;i<=100;i++)a[i]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	for(int i=1;i<=100;i++)
	if(a[i]==1)s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>

#define int long long
#define ld long double
#define db double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debx cout << " X " << endl;
#define deby cout << " Y " << endl;
#define debz cout << " Z " << endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

using namespace __gnu_pbds; 
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; 
/*  
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero) 
    order_of_key()  - The number of items in a set that are strictly smaller than our item 
    Rest same as set
*/
 
int mpow(int a, int b){
    a %= MOD;
    if(!b)
        return 1;
    int temp = mpow(a, b/2);
    temp = (temp*temp) % MOD;
    if(b%2)
        return (a * temp) % MOD;
    return temp;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b/2);
    temp = (temp * temp);
    if(b%2)
        return (a * temp);
    return temp;
}
int mod_in(int n){
    return mpow(n, MOD-2);
}
int cl(int a, int b){
    if(a%b)
        return 1 + a/b;
    return a/b;
}

int32_t main(){
    fastio;
    string s;
    cin >> s;
    cout << s.substr(0,3);
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void) {
	int N, D, i, j, k = 0, n = 0;
	double l;
	int** matrix;
	scanf("%d%d", &N, &D);
	matrix = (int**)malloc(sizeof(int*)* N);
	for ( i = 0; i < N; i++){
		matrix[i] = (int*)malloc(sizeof(int) * D);
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j++) {
			scanf("%d", &matrix[i][j]);
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			int m = 0;
			for (n = 0; n < D; n++) {
				m = (matrix[i][n] - matrix[j][n]) * (matrix[i][n] - matrix[j][n]) + m;
			}
			l = sqrt(m);
			if (ceil(l) == floor(l)) k++;
		}
	}
	printf("%d\n", k);
	free(matrix);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define print(x) cout << x << '\n';

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    
    int n;
    cin >> n;
    long long a[n+1];
    long long res = 0, temp = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int i = 0;
    while(a[i] % 2 == 0){
        a[i] /= 2;
        i++;
        temp++;
        if(temp == n){
            res++;
            temp = 0;
            i = 0;
        }
    }
    cout << res;
   
    return 0;
}


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

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

    vector<int> L(N);
    for (auto &l: L) cin >> l;
    sort(L.begin(), L.end());

    int cnt = 0;
    for (uint i=0; i<N-2; i++) {
        int a = L[i];
        for (uint j=i+1; j<N-1; j++) {
            int b = L[j];
            for (uint k=j+1; k<N; k++) {
                int c = L[k];
                if (c < a + b) ++cnt;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (S.at(i) == 'E') ans++;
    }
    
    int num = ans;
    for (int i = 1; i < N; i++) {
        if (S.at(i - 1) == 'W') num++;
        if (S.at(i) == 'E')  num--;
        ans = min(ans, num);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin>>n;
  vl h(n);
  rep(i, n) cin>>h[i];
  ll ans = 0;
  ll l = 0, r = 1;
  while (l < n) {
    r = l + 1;
    while (r < n && h[r] <= h[r-1]) {
      ans = max(ans, r - l);
      r++;
    }
    l = r;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

	int a,b;

	scanf("%d %d",&a,&b);
	
	if(a==1) a+=30;
	if(b==1) b+=30;

	if(a==b)	printf("Draw\n");
	else if(a>b)	printf("Alice\n");
	else	printf("Bob\n");

	return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
const int N=2e5+5;
char s[N],t[N];int n,pw[N];
bool cmp(char *a,char *b){
	for(int i=1;i<=n;++i)
		if(a[i]<b[i]) return 1;
		else if(a[i]>b[i]) return 0;
	return 1;
}
int calc(int d){
	int ans=0;
	for(int i=1;i<=d;++i)
		if(s[i]=='1') ans=(ans+pw[d-i])%mod;
	for(int st=1;st<=n;st+=d)
		for(int j=st;j<st+d;++j)
			t[j]=(((st-1)/d)&1)?(s[j-st+1]^1):(s[j-st+1]);
	//cout<<d<<endl;
	//for(int i=1;i<=n;++i)
	//	cout<<t[i];
	//cout<<endl;
	if(cmp(t,s)) ++ans;
	return ans%mod;
}
vector<int> vec;
int f[N];
signed main(){
	cin>>n>>(s+1);
	pw[0]=1;
//	for(int i=1;i<=n;++i)cout<<s[i];cout<<endl;
	for(int i=1;i<=n;++i)
		pw[i]=pw[i-1]*2ll%mod;
	for(int i=1;i<=n;++i)
		if(n%i==0 && (n/i)%2==1) vec.push_back(i);
	int ans=0;
	for(int i=0;i<vec.size();++i){
		int u=vec[i];
		f[i]=calc(u);
		for(int j=0;j<i;++j)
			if(vec[i]%vec[j]==0) f[i]=(f[i]+(mod-f[j])%mod)%mod;
		ans=(ans+2ll*f[i]*u%mod)%mod;
	}
	cout<<ans;
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<vector<pair<int, int>>> A;

int main(void) {
    cin >> N;
    A.resize(N);

    rep(i, N) {
        int a;
        cin >> a;
        rep(k, a) {
            int x, y;
            cin >> x >> y;
            A[i].push_back(make_pair(x - 1, y));
        }
    }

    int highest = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        int count = 0;
        bool contradiction = false;

        for (int i = 0; i < N; ++i) {

            // 不親切な人の話は聞かない
            if ((bit & (1 << i)) == 0) {
                continue;
            }

            count++;
            for (auto a : A[i]) {

                int j = (bit >> a.first) & 0x01;

                if (j != a.second) {
                    contradiction = true;
                    break;
                }
            }
            
            if (contradiction) break;
        }

        if (!contradiction) {
            highest = max(highest, count);
        }
    }

    cout << highest << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

vector<int> graph[50];
vector<bool> flag(50);

void dfs(int i) {
  flag.at(i) = true;
  for(auto e : graph[i]) {
    if (flag.at(e)) continue;
    flag.at(e) = true;
    dfs(e);
  }
}

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

  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<P> vec(m);
  rep(i, m) {
    int a, b; cin >> a >> b;
    a--; b--;
    vec.at(i) = P(a, b);
  }

  rep(i, m) {
    rep(k, n) {
      graph[k].clear();
      flag.at(k) = false;
    }

    rep(j, m) {
      if (i == j) continue;
      int a = vec.at(j).first;
      int b = vec.at(j).second;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }

    dfs(0);
    rep(k, n) {
      if (!flag.at(k)) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()


int main() {
    string S;
    cin >> S;
    int len = S.length(), ans = len;
    deque<int> dq;
    REP(i, len) {
        int count = 1;
        char c = S[i];
        while (i < len && S[i + 1] == c) {
            count++;
            i++;
        }
        dq.push_back(count);
    }

    while (dq.size() > 2 && 2 * dq.front() <= len) {
        int n1 = dq.front(); dq.pop_front();
        int n2 = dq.front(); dq.pop_front();
        dq.push_front(n1 + n2);
        ans = min(ans, len - n1);
    }
    while (dq.size() > 2 && 2 * dq.back() <= len) {
        int n1 = dq.back(); dq.pop_back();
        int n2 = dq.back(); dq.pop_back();
        dq.push_back(n1 + n2);
        ans = min(ans, len - n1);
    }

    if (dq.size() == 1) cout << dq[0] << endl;
    else cout << min(ans, max(dq[0], dq[1])) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

bool P[1000000];

int main() {
    int n, ans;
    while (cin >> n) {
        fill(P, P + n + 1, true);
        P[0] = P[1] = false;
        for (int i = 0; i * i <= n; i++) {
            if (P[i]) {
                for (int j = i + i; j <= n; j += i) {
                    P[j] = false;
                }
            }
        }
        ans = 0;
        for (int i = 0; i <= n; i++) if (P[i]) ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3972
n = int(input())
sa = []
ans = 0
for i in range(n):
    a = int(input())
    k = []
    for j in range(a):
        x,y = map(int, input().split())
        k.append([x, y])
    sa.append(k)

for b in range(2 ** n):
    f = True
    for i in range(len(sa)):
        if ((b >> i) & 1):
            for x1, y1 in sa[i]:
                if (b >> (x1-1))&1 != y1:
                    f = False
                    break
    if f:
        ans = max(ans, bin(b)[2:].count("1"))

print(ans)

Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	while (1) {
		auto field = new char[14][14];
		field[0][] = '0';
		field[$-1][] = '0';
		foreach (i; 1..13) {
			field[i][] = '0';
			auto str = readln.chomp;
			foreach (j; 1..13) {
				field[i][j] = str[j-1];
			}
		}
		int cnt;
		foreach (i; 1..13) {
			foreach (j; 1..13) {
				if (field[i][j] == '0') continue;
				void solve(int x, int y) {
					field[x][y] = '0';
					for (int i = -1; i <= 1; i+=2) {
						if (field[x][y+i] == '1')
							solve(x, y+i);
						if (field[x+i][y] == '1')
							solve(x+i, y);
					}
				}
				cnt++;
				solve(i,j);
			}
		}
		cnt.writeln;
		if (!readln) break;
	}
}

Measured memory_bytes: 1044
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp       make_pair
#define inf         0x3f3f3f3f
//#define INF         0x3f3f3f3f3f3f3f3fLL
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi     pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define see(x)      cout<<x<<endl;
#define see2(x,y)   cout<<x<<" "<<y<<endl;
#define see3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
//using namespace __gnu_pbds;

//typedef priority_queue<int> maxHeap;
//typedef priority_queue<int,vector<int>,greater<int>()) minHeap;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
//typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

ll solve(vi& v,int n,int k){
    ll dp[n+2][k+2];
    loop(j,0,k+1)
        dp[1][j] = (j > v[1]) ? 0 : 1 ;
    loop(i,2,n+1){
        loop(j,0,k+1){
            if(j == 0)
                dp[i][j] = dp[i-1][j] ;
            else
                dp[i][j] = (dp[i][j-1] + dp[i-1][j] - ((j-v[i]-1 >= 0) ? dp[i-1][j-v[i]-1] : 0) + hell)%hell ; 
        }
    }
    return dp[n][k] ;
}

void solution(){
    int n , k;
    cin >> n >> k;
    vi arr(n+1);
    loop(i,1,n+1)
        cin >> arr[i] ;
    cout << solve(arr,n,k);
}

signed main(){
    fastio
    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r" , stdin);
    //  freopen("output.txt", "w", stdout);
    // #endif

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}




Measured memory_bytes: 78848
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;
#define MOD 1000000007
LL dp[404][404],n,c,a[404],b[404],po[404][404];

long long powmod(long long a, long long n){
    if(n==0) return 1;
    long long re=powmod((a*a)%MOD,n/2)%MOD;
    if(n%2==1) re= (re*a)%MOD;
    return re%MOD;
}

void solve(int n, int c){
    REPN(i,1,n){
        REPN(j,0,c+1){
            FOR(k,0,j+1){
                dp[i][j]=(dp[i][j]+dp[i-1][j-k]*((po[b[i]][k]-po[a[i]-1][k]+MOD)%MOD))%MOD;

            }
            //OUT(dp[i][j])
        }
    }

}

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

        dp[0][0]=1;

    REP(i,n){
        cin >> a[i+1];
    }
    REP(i,n){
        cin >> b[i+1];
    }
    REPN(i,1,401){
        REPN(j,0,401){
            po[i][j]=(po[i-1][j]+powmod(i,j))%MOD;
            //OUT(po[i][j])
        }
    }
    solve(n,c);
    cout << dp[n][c] <<endl;



    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;

char s[N],c[N];

int main()
{
	fast;
	cin>>s+1;
	cin>>c+1;
	fo(i,1,3)
	if(s[i]==c[i])
		sum++;
	cout<<sum;



}



/*     cd onedrive\desktop\kod
cls


*/

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

const int MAXN = 300;
const int MOD = 1e9 + 7;

int n, m, ans;
int a[MAXN | 1], b[MAXN | 1], c[MAXN | 1], dp[MAXN + 2][MAXN + 2][MAXN + 2];
std::vector < int > limit[MAXN | 1];

inline int read() {
	register int x = 0;
	register char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

int main() {
	n = read();
	m = read();
	for (int i = 1; i <= m; ++i) {
		a[i] = read();
		b[i] = read();
		c[i] = read();
		limit[b[i]].push_back(i);
	}
	dp[0][0][0] = 1;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (i == j && j) continue;
			for (int k = 0; k <= n; ++k) {
				// if ((j == k && j) || (i == k && i)) continue;
				if (k && (j == k || i == k)) continue;
				int max = std::max(i, std::max(j, k));
				bool flag = false;
				for (std::vector < int >::iterator it = limit[max].begin(); it != limit[max].end(); ++it) {
					int now = *it, foo = 0;
					if (i >= a[now]) ++foo;
					if (j >= a[now]) ++foo;
					if (k >= a[now]) ++foo;
					if (foo != c[now]) {
						flag = true;
						break;
					}
				}
				if (flag) continue;
				dp[max + 1][j][k] = (dp[max + 1][j][k] + dp[i][j][k]) % MOD;
				dp[i][max + 1][k] = (dp[i][max + 1][k] + dp[i][j][k]) % MOD;
				dp[i][j][max + 1] = (dp[i][j][max + 1] + dp[i][j][k]) % MOD;
				if (max == n) ans = (ans + dp[i][j][k]) % MOD;
				// printf("i=%d j=%d k=%d ans=%d max=%d\n", i, j, k, dp[i][j][k], max);
				// printf("i=%d j=%d k=%d ans=%d max=%d\n", i, j, k, dp[i][j][k], max);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 107904
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList()
    val B = IntArray(1000001) { 0 }
    for (i in A) {
        B[i]++
        if (B[i] > 1) continue
        for (j in i * 2..1000000 step i) {
            B[j]++
        }
    }
    println(A.count { B[it] == 1 })
}

Measured memory_bytes: 72824
#include<stdio.h>
typedef long long LL;
int N,i,j,p,A[200000],town[200000];LL K;
inline LL IN(void)
{
  LL x=0;int f=1;char c=getchar();
  while((c<'0'||c>'9')&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();
  return f*x;
}
int main(void)
{
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),town[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(town[i]<0)town[i]=j;else break;
  for(p=0;K>0;p=A[p]-1,K--)if(i==p){K%=town[i]-j;if(!K)break;}
  return printf("%d\n",p+1),0;
}

Measured memory_bytes: 3160
#include <stdio.h>
int mas(int n);
int main()
{
	int A, B, N, i, total = 0, m;
	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);
	for (i = 1; i <= N; i++) {
		m = mas(i);
		if (m >= A && m <= B) {
			total += i;
		}
	}
	printf("%d", total);
}
int mas(int n)
{
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n /= 10;
	}
	return s;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  cout<<((n%2)? n/2:n/2-1)<<endl;

  return 0;
}

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

int main(){
    long N;
    int K, h;
    long count = 0;

    cin >> N >> K;
    for(long i=0;i<N;i++){
        cin >> h;
        if(h >= K) count++;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	for i := 0; i < 1<<uint(len(s)-1); i++ {
		t := s
		for j := len(s) - 1; j >= 0; j-- {
			b := 1 << uint(j)
			if b == i&b {
				t = t[:j+1] + "+" + t[j+1:]
			}
		}
		for _, v := range strings.Split(t, "+") {
			iv, _ := strconv.Atoi(v)
			ans += iv
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

vector<int> primes;
map<int, int> factors;

void erathosthenes(int n) {
    bool primeFlags[n+1];//boolでふるいを用意する。素数であればtrueであるとする
    for (int i = 0; i <= n; i++) primeFlags[i] = true;//ふるいをリセット
    primeFlags[0] = primeFlags[1] = false;//0と1は素数ではないのでふるい落とす(=falseにする)
    vector<int> sqrtprimes;//ルートnまでの素数を入れておくための配列
    for (int i = 2; i*i <= n; i++) {
        bool mod0 = false;
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) mod0 = true;
        }
        if (!mod0) sqrtprimes.push_back(i);
    }
    for (int i = 0; i < sqrtprimes.size(); i++) {
        for (int j = 2; j <= n; j++) {
            if (j%sqrtprimes[i] == 0) primeFlags[j] = false;
        }
    }
    for (int i = 0; i < sqrtprimes.size(); i++) primeFlags[sqrtprimes[i]] = true;
    for (int i = 1; i <= n; i++) if (primeFlags[i]) primes.push_back(i);
    return;
}

void factoring(int n) {
    for (int i = 0; i < primes.size(); ++i) {
        while(n%primes[i] == 0){
            factors[primes[i]]++;
            n /= primes[i];
        }
    }
}

void factorial(int n) {
    erathosthenes(n);
    for (int i = 2; i <= n; ++i) {
        factoring(i);
    }
}

//---------以上ライブラリ--------//--------------------//

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    factorial(n);
    int count74 = 0, count242 = 0, count144 = 0, count442 = 0;
    for (auto &x: factors) {
        int X = x.second;
        if (X >= 74) count74++;
        for (auto &y: factors) {
            if (x.first == y.first) continue;
            int Y = y.second;
            if (X >= 24 && Y >= 2) count242++;
            if (X >= 14 && Y >= 4) count144++;
            for (auto &z: factors) {
                if (x.first == z.first || y.first == z.first) continue;
                int Z = z.second;
                if (X >= 4 && Y >= 4 && Z >= 2) count442++;
            }
        }
    }
    ll ans = 0;
    //printf("74 = %d, 242 = %d, 144 = %d, 442 = %d\n", count74, count242, count144, count442);
    ans = count74+count242+count144+count442/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (r, d, mut x) = scan!(usize, usize, usize);

    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}


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

struct UnionFind {
  vector<int> par;
  
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par.at(i) = i;
  }
  
  int root(int x) {
    if (par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }
  
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par.at(rx) = ry;
  }
  
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    A.at(i)--;
    B.at(i)--;
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    UnionFind tree(N);
    for (int j = 0; j < M; j++) {
      if (i != j) tree.unite(A.at(j), B.at(j));
    }
    for (int j = 0; j < N; j++) {
      if (!(tree.same(0, j))) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int h[N];
    REP(i, N)
    {
        cin >> h[i];
    }
    int currentH[N] = {0};
    bool isOk[N] = {false};
    int ans = 0;

    while(true)
    {
        REP(i, N)
        {
            if (currentH[i] == h[i]) isOk[i] = true;
            else currentH[i]++;
        }
        
        bool countFlag = false;
        REP(i, N)
        {
            if (isOk[i]) 
            {
                if (countFlag)
                {
                    ans++;
                    countFlag = false;
                }
            }
            else
            {
                if (!countFlag) countFlag = true;
            }
        }
        if (countFlag) ans++;

        bool check = true;
        REP(i, N) check = check && isOk[i];
        if (check) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256