akhauriyash/Code-Regression huggingface dataset:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
a = na()
d = defaultdict(int)
flag = True
for i in range(n):
    if d[a[i]] > 0:
        flag = False
    d[a[i]] += 1

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 100692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

class UnionFind{
public:
    //親の番号，親の場合-(その集合のサイズ)
    vector<int> Parent;
    
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A, int B){
        //root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if(A==B) return false;//すでにくっついてる

        //大きい方に小さい方をくっつける
        if(size(A) < size(B)) swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    vector<int> A(M),B(M);
    REP(i,M){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
    vector<ll> ans(M);
    ans[M-1] = (ll)N * (N-1) / 2;
    UnionFind Uni(N);
    for(int i=M-1;i>=1;i--){
        ans[i-1] = ans[i];
        if(Uni.root(A[i]) != Uni.root(B[i])){
            ans[i-1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
            Uni.connect(A[i],B[i]);
        }
    }
    for(int i=0;i<M;i++) cout<<ans[i]<<endl;
}

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

int main() {
	int N, Q, l, r, A[100000] = { 0 };
	string S;
	cin >> N >> Q >> S;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == 'A' && S[i] == 'C') A[i] = A[i - 1] + 1;
		else A[i] = A[i - 1];
	}
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << A[r - 1] - A[l - 1] << endl;
	}
}

Measured memory_bytes: 1408
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)


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

int main(){
    string s, t;
    cin >> s >> t;
    int n=int(s.size()), m=int(t.size());
    vector<vector<int>> is(26);

    rep(i,n) is[s[i]-'a'].push_back(i);
    rep(i,n) is[s[i]-'a'].push_back(i+n);

    ll ans = 0;
    int p = 0;

    rep(i, m){
        int c=t[i]-'a';
        if(int(is[c].size())==0){
            puts("-1");
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
        if(p >= n){
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1724
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

map<int, int> mp;
int cnt(int n) {
	int c = 0;
	rep2(m, mp) {
		if (m.second >= n)c++;
	}
	return c;
}
int main()
{
	int n, ans = 0;
	cin >> n;
	vector<int> f(101);
	rep(i, 2, 101)rep(i2, 2, i)f[i] |= (i % i2 == 0);
	rep(i, 2, n + 1) {
		if (f[i])continue;
		int temp = n;
		while (temp)mp[i] += temp / i, temp /= i;
	}
	ans = cnt(74) + cnt(24) * (cnt(2) - 1) + cnt(14) * (cnt(4) - 1) + cnt(4) * (cnt(4) - 1) * (cnt(2) - 2) / 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int B[100005];
  cin >> N;
  rep(i, N-1){
    cin >> B[i];
  }

  ll ans = 0;
  rep(i, N){
    if (i == 0) {
      ans += B[0];
    } else if (i == N-1) {
      ans += B[N-2];
    } else {
      ans += min(B[i-1], B[i]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func isOK(n, m int64) bool {
	return m > 0 && n/m == n%m
}

func main() {
	var n int64
	fmt.Scan(&n)

	ans := int64(0)
	for d := int64(1); d*d <= n; d++ {
		if n%d == 0 {
			if isOK(n, d-1) {
				ans += d - 1
			}
			if d != n/d {
				if isOK(n, n/d-1) {
					ans += n/d - 1
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){

	string W, T;
	cin >> W;

	transform(W.begin(), W.end(), W.begin(), ::toupper);
//	cout << W << endl;

	int count = 0;

	while(cin >> T){
		if(T == "END_OF_TEXT") break;
		transform(T.begin(), T.end(), T.begin(), ::toupper);
		if(T == W) count++;
	}

	cout << count << endl;

	return 0;
}

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

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

int main()
{
	int h,a; cin>>h>>a;
	int ans=0;
	while(h>0){
		h-=a;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],b[100005],c[100005];
map<ll,ll> p;
set<ll> q;
int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++){
		cin>>b[i]>>c[i];
		p[c[i]]+=b[i];
		q.insert(-c[i]);
	}
	for(int i=1;i<=n;i++){
		ll x=a[i];
		while(q.size()){
			ll num=-(*q.begin());
			if(num>a[i]){
				x=num;p[num]--;
				if(!p[num]) q.erase(-num);
				break;
			}
			else if(num<=a[i]){
				p[num]=0;q.erase(-num);
			}
		}
		ans+=x;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13568
n = int(input())
sp_list = [input().split() for i in range(n)]
for i in range(n):
    sp_list[i][1] = int(sp_list[i][1])
    sp_list[i].append(i + 1)
sp_list.sort(key=lambda x: x[1], reverse=True)
sp_list.sort(key=lambda x: x[0])
[print(sp[2]) for sp in sp_list]

Measured memory_bytes: 3060
import math
N,K=input(),input()
x = [int(_) for _ in raw_input().split()]
sum = 0

for i in range(N):
	if K < x[i]:
		sum += (x[i]-K)*2
	elif K/2 < x[i]:
		sum += (K-x[i])*2
	else:
		sum += x[i]*2
print(sum)

Measured memory_bytes: 2568
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n, s, s_max, s_min, s_sum;

    while ((n = sc.nextInt()) != 0) {
      s_max = 0;
      s_min = 1000;
      s_sum = 0;
      // 初期入力
      for (int i = 0; i < n; i++) {
        s = sc.nextInt();// 得点のデータセット
        if (s_max < s) s_max = s;
        if (s_min > s) s_min = s;
        s_sum += s;
      }
      s_sum = s_sum - s_max - s_min;

      System.out.printf("%d\n", s_sum/(n-2));
    }
  }
}



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

int gcd(int a, int b);

int main()
{
  int k;
  cin >> k;
  
  int64_t sum = 0;
  
  for (int i = 1; i <= k; i ++)
  {
    for (int j = 1; j <= k; j ++)
    {
      for (int l = 1; l <= k; l ++)
      {
        sum += gcd(i, gcd(j, l));
      }
    }
  }
    
  cout << sum << endl;
  return 0;
}

int gcd(int a, int b)
{
  int r = a % b;
  int gcd = b;
 
  int tmp;
  while (r != 0)
  {
    tmp = r;
    r = gcd % r;
    gcd = tmp;
  } 
  
  return gcd;
}

Measured memory_bytes: 3592
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

lucas :: [Int] -> Int -> [Int]
lucas xs (-1) = xs
lucas [] n = lucas [2] (n -1)
lucas [x] n = lucas [1, 2] (n -1)
lucas xs n = lucas ((head xs + head (tail xs)) : xs) (n -1)

main = do
  n <- getInt
  print $ head (lucas [] n)


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

// map<ll, ll> t;
ll turns(ll h)
{
  // if (t[h])
  //   return t[h];
  if (h == 1)
    return 1;
  return /*t[h] = */turns(h / 2) * 2 + 1;
}

int main()
{
  ll h;
  cin >> h;
  cout << turns(h) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll L, R;
    ll answer;

    cin >> L >> R;
    
    if (L % 2019 >= R % 2019 || R - L >= 2018 || L % 2019 == 0){
        cout << 0 << endl;
        return 0;
    }else{
        ll r = R % 2019;
        ll l = L % 2019;
        answer = 2019;

        for(int i = l; i < r; i ++){
            for (int j = i + 1; j <= r; j ++){
                answer = min(answer, ll(i * j % 2019));
            }
        }
        cout << answer << endl;
        return 0;
    }

    return 0;
}

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

int main(){
  long long N;
  cin >>N;
  int keta=11;
  
  for (int i=1;i<pow(N,0.5)+1;i++){
    if(N%i==0){
      keta=min(keta,max((int)(log10(i))+1,(int)(log10(N/i))+1));
    }
  }
  
  cout<<keta<<endl;
  return 0;
}

     


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n+1);
    map<p, ll> I{};
    for(ll i = 0; i < m; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        g[a].push_back(b);
        g[b].push_back(a);
        I[p(a, b)] = c; I[p(b, a)] = -c;
    }
    vector<ll> use(n+1, 0);
    vector<ll> dist(n+1, -1000000);
    ll count = 0;
    bool ok = true;
    for(ll i = 1; i <= n; i++){
        if(use[i]!=0) continue;
        queue<ll> que;
        que.push(i);
        dist[i] = 0;
        use[i] = 1;
        while(!que.empty()){
            ll v = que.front();
            que.pop();
            for(ll nv : g[v]){
                if(dist[nv]!= -1000000) continue;
                dist[nv] = dist[v] + I[p(v, nv)];
                use[nv] = 1;
                que.push(nv);
            }
        }
    }
   // for(ll i = 1; i <= n; i++)
     //   cout << i << " " << dist[i] << endl;
    for(auto &x : I){
        p check = x.first;
        ll a = check.first, b = check.second, d = x.second;
        if(d!=dist[b]-dist[a]) ok = false;
    }
    if(ok==true) cout << "Yes" << endl;
    else  cout << "No" << endl;

    return 0;
}


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

using namespace std;

#define ll long long

void solve() {
	string a, b;
	cin >> a >> b;
	string c = a+b;
	int n = stoi(c);
	int xd = sqrt(n);
	cout << (xd*xd == n ? "Yes" : "No") << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int h[n+1];
    for ( int i = 1 ; i <= n ; i ++ )
        cin >> h[i];
    int f[n+1];
    f[1] = 0;
    f[2] = abs(h[2]- h[1]);
    for ( int i = 3; i <= n; i++ )
    {
        f[i] = min(f[i-1]+abs(h[i]-h[i-1]), f[i-2] + abs(h[i]-h[i-2]));
    }
    cout << f[n];
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<double>> dis(n, vector<double> (n, 0));
  vector<vector<int>> pos(n, vector<int> (2));
  for(int i = 0; i < n; i++){
    cin >> pos.at(i).at(0) >> pos.at(i).at(1);
  }
  double ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(dis.at(i).at(j) != 0 || i ==j) continue;
      double d;
      d = sqrt(pow((pos.at(i).at(0) - pos.at(j).at(0)), 2) + pow((pos.at(i).at(1) - pos.at(j).at(1)), 2));
      dis.at(i).at(j) = d;
      ans += d;
    }
  }
  
  ans /= n;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <utility>
#include <iomanip>
#define input(a) cin >> a
#define print(x) cout << x << endl
#define rep(a,n) for(int i = a; i < n; i++)
#define ll long long int
using namespace std;


int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if (e-a<=k) print("Yay!");
    else print(":(");
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char S[100001];
  int i,j=0,k=0;
  scanf("%s",S);
  for(i=0;i<100001;i++){
    j++;
    if(S[i]=='\0') i=100001;
  }
  int a=j-1;
  j=0;
  char b[a+1];
  for(i=0;i<a;i++){
    if(i%2==0) b[i]='0';
    else b[i]='1';
  }
  for(i=0;i<a;i++){
    if(S[i]!=b[i]) j++;
  }
  for(i=0;i<a;i++){
    if(i%2==1) b[i]='0';
    else b[i]='1';
  }
  for(i=0;i<a;i++){
    if(S[i]!=b[i]) k++;
  }
  if(j<k) printf("%d\n",j);
  else printf("%d\n",k);
  return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

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

int n;
vector <int> t[100000];
ll m;
ll dp[100000];
ll ans[100000];

void rec(int cur, int par) {
	dp[cur] = 1;
	for (int i = 0; i < t[cur].size(); i++) {
		if (t[cur][i] == par) {
			swap(t[cur][i], t[cur][t[cur].size() - 1]);
			break;
		}
	}
	if (t[cur].size() > 0 && t[cur][t[cur].size() - 1] == par)
		t[cur].pop_back();
	
	for (int i = 0; i < t[cur].size(); i++) {
		rec(t[cur][i], cur);
		dp[cur] *= (dp[t[cur][i]] + 1) % m;
		dp[cur] %= m;
	}
}

void solve(int cur, int par, ll pval) {
	ans[cur] = dp[cur] * pval;
	ans[cur] %= m;

	vll le(t[cur].size()), ri(t[cur].size());
	int sz = t[cur].size();

	if (sz > 0) {
		le[0] = dp[t[cur][0]] + 1;
		ri[sz - 1] = dp[t[cur][sz - 1]] + 1;
	}
	for (int i = 1; i < t[cur].size(); i++) {
		le[i] = le[i - 1] * (dp[t[cur][i]] + 1);
		le[i] %= m;
		ri[sz - i - 1] = 
			(dp[t[cur][sz - i - 1]] + 1) * ri[sz - i];
		ri[sz - i - 1] %= m;
	}
	// for (int i = 0; i < t[cur].size(); i++) {
	// 	cout << le[i] << " " << ri[i] << endl;
	// }
	// cout << endl;
	for (int i = 0; i < t[cur].size(); i++) {
		ll left = 1;
		ll right = 1;
		if (i > 0) left = le[i - 1];
		if (i < t[cur].size() - 1) right = ri[i + 1];
		solve(t[cur][i], cur, ((((pval * left) % m) * right) + 1) % m);
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n >> m;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		t[b].push_back(a);
		t[a].push_back(b);
	}
	rec(0, -1);
	solve(0, -1, 1);
	for (int i = 0; i < n; i++) {
		printf("%lld\n", ans[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for(int i = 1; i <= n; i+=2){
		cnt++;
	}

	if(cnt >= k) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int w, h;
char field[51][51];
bool visited[51][51];
bool white_flg;
bool black_flg;

int dfs(int i, int j){
    if(i<0 || h<=i || j<0 || j>=w || visited[i][j]) return 0;
    if(field[i][j] == 'B'){
        black_flg = true;
        return 0;
    }
    if(field[i][j] == 'W'){
        white_flg = true;
        return 0;
    }
    visited[i][j] = true;
    int res = 1;
    REP(k,4){
        res += dfs(i+di[k], j+dj[k]);
    }
    return res;
}

int main(){
    while(cin >> w >> h){
        if(w+h==0) break;
        int white = 0;
        int black = 0;
        memset(visited, false, sizeof(visited));
        REP(i,h) cin >> field[i];

        REP(i,h){
            REP(j,w){
                if(!visited[i][j] && field[i][j] == '.'){
                    white_flg = false;
                    black_flg = false;
                    int s = dfs(i,j);
                    if(white_flg && !black_flg) white += s;
                    else if(black_flg && !white_flg) black += s;
                }
            }
        }
        cout << black << ' ' << white << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if (b/a>=c) {
            System.out.println(c);
        }else{
            System.out.println(b/a);
        }
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

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()

void solve() {
    int N;
    cin >> N;

    vector<int> diff1[N + 1], diff2[N + 2];
    ll ans = 0;
    REP(i, N) {
        int K, L, R;
        cin >> K >> L >> R;
        if (L >= R) diff1[K].push_back(L - R);
        else diff2[K + 1].push_back(R - L);
        ans += min(L, R);
    }

    priority_queue<int, vector<int>, greater<int>> que;
    FOR(i, 1, N + 1) {
        for (int d : diff1[i]) que.push(d);
        while (que.size() > i) que.pop();
    }
    while (!que.empty()) {
        ans += que.top(); que.pop();
    }

    FOR(i, 1, N + 1) {
        for (int d : diff2[N + 1 - i]) que.push(d);
        while (que.size() > i) que.pop();
    }
    while (!que.empty()) {
        ans += que.top(); que.pop();
    }

    cout << ans << endl;
}

int main() {
    int T;
    cin >> T;
    REP(i, T) solve();
    return 0;
}

Measured memory_bytes: 17756
#include<iostream>
#include<cmath>
#include<algorithm>


using namespace std;

int main(){
  int n;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int r=0;
  long long xor_ = 0, sum_ = 0;
  long long ans = 0;
  for(int l=0;l<n;l++){    
    while(r<n){
      xor_ ^= a[r];
      sum_ += a[r];
      if(xor_ != sum_){
        xor_ ^= a[r];
        sum_ -= a[r];
        break;
      }else{
        r++;
      }
    }
    ans += r-l;
    xor_ ^= a[l];
    sum_ -= a[l];
//    cout << xor_ << " " << sum_ << " " << r << " " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return T+S


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 70392
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;
int main(){
    Shazam;
    priority_queue<pair<int,int>> q;
    priority_queue<ll> fin;
    int n; cin>>n;
    int m; cin>>m;
    for(int i = 0 ; i < n; i++){
        ll k; cin>>k;
        fin.push(k);
    }
    for(int i =0 ; i < m; i++){
        int qty; cin>>qty;
        ll val; cin>>val;
        q.push({val,qty});
    }
    int take = 0;
    while(!q.empty() && take < n){
        for(int i = take ; i <min(n,take+q.top().ss); i++){
            fin.push(q.top().ff);
        }
        take+=q.top().ss;
        q.pop();
    }
    ll ans = 0;
    for(int i = 0 ; i < n; i++){
        ans+=fin.top();
        fin.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6308
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

import math
import copy
import bisect
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 
n=input()
 
 
 
def func():
    if n<="2019/04/30":
        return "Heisei"
    return "TBD"
 
 
print(func()) 

Measured memory_bytes: 3700
#include<string>
#include<vector>
#include<cctype>
#include<cmath>
#include<iostream>
using namespace std;

int main(){
    string s1;
    cin >> s1;
    for(auto &x:s1){
        x = 'x';
    }

    cout << s1 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    if n%9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

const int MOD = (int) 1e9 + 7;

int add(int a, int b) {
        a += b;
        if (a >= MOD) {
                return a - MOD;
        }
        if (a < 0) {
                return a + MOD;
        }
        return a;
}

int mul(int a, int b) {
        return a * (ll) b % MOD;
}

int expow(int a, int b) {
        int r = 1;
        while (b) {
                if (b & 1) {
                        r = mul(r, a);
                }
                a = mul(a, a);
                b >>= 1;
        }
        return r;
}

int get_factorial(int i) {
        if (i == 0) {
                return 1;
        } else {
                return mul(get_factorial(i - 1), i);
        }
}

int inv(int x) {
        return expow(x, MOD - 2);
}

int comb(int n, int k) {
        int x = get_factorial(n), y = inv(mul(get_factorial(k), get_factorial(n - k)));
        return mul(x, y);
}

int sqr(int x) {
        return mul(x, x);
}

int n, m, k;

int main() {
        cin >> n >> m >> k;
        int a = comb(n * m - 2, k - 2), b = 0;

        for (int dr = 1; dr < n; dr++) {
                int pick = n - dr;
                b = add(b, mul(dr, mul(pick, sqr(m))));
        }
        for (int dc = 1; dc < m; dc++) {
                int pick = m - dc;
                b = add(b, mul(dc, mul(pick, sqr(n))));
        }

        cout << mul(a, b) << "\n";

        return 0;
}


Measured memory_bytes: 3328
N = input().split()
S = []
for i in N:
    if i.isdigit():
        i = int(i)
        S.append(i)
    else:
        a, b = S.pop(), S.pop()
        if i == '+':
            S.append(b + a)
        elif i == '-':
            S.append(b - a)
        elif i == '*':
            S.append(b * a)
print(S[0])


Measured memory_bytes: 5600
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = map(int,input().split())
cnt = 0

def binary(lft,rgt,m):
    global s,n
    while lft <= rgt:
        mid = (rgt+lft)//2
        if s[mid] == m:
            return True
        elif s[mid] > m:
            rgt = mid - 1
        else:
            lft = mid + 1
    return False
    
     

for i in t:
    if binary(0,n-1,i) and (s[0]<=i and s[n-1]>=i):
        cnt += 1
print(cnt)


Measured memory_bytes: 16712
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class UF:
    def __init__(self, N):
        self.state = [-1] * N
        self.rank = [0] * N
        self.num_group = N
    
    def get_parent(self, a):
        p = self.state[a]
        if p < 0:
            return a
        
        q = self.get_parent(p)
        self.state[a] = q
        return q

    def make_pair(self, a, b):
        pa = self.get_parent(a)
        pb = self.get_parent(b)
        if pa == pb:
            return

        if self.rank[pa] > self.rank[pb]:
            pa, pb = pb, pa
            a, b = b, a
        elif self.rank[pa] == self.rank[pb]:
            self.rank[pb] += 1

        self.state[pb] += self.state[pa]
        self.state[pa] = pb
        self.state[a] = pb
        self.num_group -= 1
    
    def is_pair(self, a, b):
        return self.get_parent(a) == self.get_parent(b)

    def get_size(self, a):
        return -self.state[self.get_parent(a)]


def main():
    N = int(input())
    X = []
    Y = []
    for i in range(N):
        a, b = read_values()
        X.append((a, i))
        Y.append((b, i))
    
    X.sort()
    Y.sort()

    Q = []
    for i in range(N - 1):
        heapq.heappush(Q, (X[i + 1][0] - X[i][0], (X[i][1], X[i + 1][1])))
        heapq.heappush(Q, (Y[i + 1][0] - Y[i][0], (Y[i][1], Y[i + 1][1])))

    res = 0
    uf = UF(N)
    while uf.num_group != 1:
        c, (a, b) = heapq.heappop(Q)

        if not uf.is_pair(a, b):
            res += c
            uf.make_pair(a, b)

    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 63288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b >> c;

    if (a == b)
    {
	    cout << c << endl;
    }
    else if (a==c)
    {
	    cout << b << endl;
    }
    else
    {
	    cout << a << endl;
    }

}


Measured memory_bytes: 256
using namespace std;
#include<string.h>
#include <sstream>
typedef long long int ll;
typedef long double ld;
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <map>
//#define N 4
#include <stack>
#include <unordered_set>
#include <math.h>
#include <cstring>
#include <bitset>
#include <numeric>
#include <set>
#include <sstream>
#include <list>
#include <queue>
#define PI 3.14159265358979323846264338327950
#define mp make_pair
#define inf 1e9
//#define M 1000000007
#define M 10000000
#define N 100000

int arr[2000005];
int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		arr[a[i]]--;

		int f = 0;

		for (int j = 1; j <= sqrt(a[i]); j++) {
			if (a[i] % j == 0) {

				if (arr[j]) {
					f = 1;
				}

				int k = a[i] / j;
				if (arr[k]) {
					f = 1;
				}
			}
		}

		arr[a[i]]++;
		if (!f) {
			ans++;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 8168
#include <bits/stdc++.h>
#include<set>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
    ll n,k,d,a;
    set<int> s;
    cin>>n>>k;
    int c=0;
    while(k--)
    {
      cin>>d;
      for(int i=0;i<d;i++){
        cin>>a;
        s.insert(a);
      }
    }
    c+=s.size();
    cout<<n-c;
    return 0;
   }



Measured memory_bytes: 3632
#include <iostream>

void InputNumbers(int*, const int&);
void OutputReverseNumbers(int[], const int&);

int main(){
	const int MAX_SIZE = 100;
	int a[MAX_SIZE];
	int n;
	std::cin >> n;
	InputNumbers(a, n);
	OutputReverseNumbers(a, n);
}

void InputNumbers(int a[], const int& n){
	for (int i = 0; i < n; ++i){
		std::cin >> a[i];
	}
}

void OutputReverseNumbers(int a[], const int& n){
	for (int i = n; i > 0; --i){
		std::cout << a[i - 1]; 
		if (i != 1)
		{
			std::cout << " ";
		}
		else{
			std::cout << std::endl;
		}
	}
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int H, W;
char D[20][20];

void solve() {
	cin >> H >> W;
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> D[i][j];
		}
	}
	int h = -1, w = -1;
	rep(i, 0, H) {
		rep(j, 0, W) {
			if(D[i][j] == '#' && h == -1) {
				h = i;
				w = j;
			}
		}
	}
	if(h != -1) {
		while(true) {
			D[h][w] = '.';
			if(h + 1 < H && D[h + 1][w] == '#') {
				h++;
			}
			else if(w + 1 < W && D[h][w + 1] == '#') {
				w++;
			}
			else break;
		}
	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			if(D[i][j] == '#') {
				cout << "Impossible\n";
				return;
			}
		}
	}
	cout << "Possible\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




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

using namespace std;

int main()
{
    int n;
    cin >> n;
    double a[n];
    double sum = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += 1/a[i];
    }
    cout << 1.0/sum << endl;
    return 0;
}


Measured memory_bytes: 256
fun main() {
    val (h, n) = readLine()!!.split(' ').map { it.toInt() }
    val ms = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a to b
    }
    val dp = IntArray(h + 1) { 1e9.toInt() }
    dp[h] = 0
    for (i in h downTo 0) {
        for (j in 0 until n) {
            val (a, b) = ms[j]
            val ni = (i - a).coerceAtLeast(0)
            dp[ni] = dp[ni].coerceAtMost(dp[i] + b)
        }
    }
    println(dp[0])
}


Measured memory_bytes: 39684
#include <bits/stdc++.h>
using namespace std;
int n, z, x, f[200020];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		z = max(z, f[x] = f[x - 1] + 1);
	}
	printf("%d\n", n - z);
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque

""" 最短の距離でスタートからゴールまで行けば残りの移動可能部分はすべてスコアにすることができる。
    ただ、たどり着けない場合も考える必要がある
"""

def bfs(h, w, board, start, goal):

    bfs_deque = deque()
    bfs_deque.append(start)

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    x, y = start
    reached_area[y][x] = 0

    min_distance = INF

    while len(bfs_deque) > 0:

        coord = bfs_deque.popleft()
        x, y= coord

        if coord == goal:
            # 終了処理 いろいろ書く
            if min_distance > reached_area[y][x]:
                min_distance = reached_area[y][x]


        # 4方向に移動
        for i in range(len(dx)):
            nx = x + dx[i]
            ny = y + dy[i]

            # 移動してキューに加える
            if 0 <= nx < w and 0 <= ny < h and board[ny][nx] != "#" and reached_area[ny][nx] == INF:
                # 到達済みリストに距離を記録
                reached_area[ny][nx] = reached_area[y][x] + 1
                # キューに座標を加える
                bfs_deque.append([nx, ny])

    if min_distance != INF:
        return min_distance
    else:
        return -1


h, w = map(int, input().split())
board = [input().rstrip() for i in range(h)]

start = [0, 0]
goal = [w-1, h-1]

movable_area_count = 0
INF = 999
reached_area = [[INF for i in range(w)] for j in range(h)]

# 移動可能なエリアを算出
for i in range(h):
    for j in range(w):
        if board[i][j] == ".":
            movable_area_count += 1

# 最短手数を算出
min_distance = bfs(h, w, board, start, goal)

if min_distance != -1:
    print(movable_area_count - min_distance -1)
else:
    print(min_distance)



Measured memory_bytes: 40816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k; cin >>  n>> k;
    cout << min(n%k,k-n%k) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	#define ll long long
	#define MP make_pair
	#define PB push_back
	#define F first
	#define S second
	#define endl "\n"
	#define pi 3.14159265358979323846264338327950288
	#define MOD 1000000007
	#define INF -100000000000000
	#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	using namespace std;
	#define lld long double
	using namespace __gnu_pbds;
	int main()
	{
	    fast;
	 //   #ifndef ONLINE_JUDGE
	  //  freopen("input.txt", "r", stdin);
	  //  freopen("output.txt", "w", stdout);
	  //  #endif
	    ll int n;
	    cin>>n;
	    ll int a[n];
	    ll int i,j,z;
	    vector<vector<ll int>> fin;
	    for(i=0;i<n;i++)
	    {
	    	cin>>a[i];
	    	j=0;z=a[i];
	    	vector<ll int> v(35,0);
	    	while(z!=0)
	    	{
	    		ll int k=z%2;
	    		v[j]=k;
	    		z=z/2;
	    		j++;
	    	}
	    	//reverse(v.begin(),v.end());
	    	fin.PB(v);


	    }
	   /* for(i=0;i<n;i++)
	    {
	    	for(j=0;j<35;j++)
	    		cout<<fin[i][j];
	    	cout<<endl;
	    }*/
	    z=0;ll int o=0;
	    for(i=0;i<35;i++)
	    {
	    	z=0,o=0;
	    	for(j=0;j<n;j++)
	    	{
	    		if(fin[j][i]==0)
	    			z++;
	    		else
	    			o++;
	    	}
	    	if(fin[0][i]==0 && o%2!=0)
	    	{
	    		for(j=0;j<n;j++)
	    		{
	    			fin[j][i]^=1;//cout<<fin[j][i]<<endl;

	    		}
	    	}
	    	else if(fin[0][i]==1 && (o-1)%2==0)
	    	{
	    		for(j=0;j<n;j++)
	    		{
	    			fin[j][i]^=1;

	    		}
	    	}
	    	

	    }
	    vector<ll int> ans;
	    ll int val=0;
	  /*  for(i=0;i<n;i++)
	    {
	    	for(j=0;j<35;j++)
	    		cout<<fin[i][j];
	    	cout<<endl;
	    }*/
	    for(j=0;j<n;j++)
	    {
	    	val=0;
	    	for(i=0;i<35;i++)
	    	{
	    		val+=fin[j][i]*pow(2,i);
	    	}
	    	ans.PB(val);
	    }
	    for(i=0;i<ans.size();i++)
	    	cout<<ans[i]<<" ";
	}


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

int main(){
 
  int N, X, Y, i, j;
  cin >> N >> X >> Y;
  vector<int> Cnt(N - 1, 0);
  X--; Y--;
  
  for(i = 0; i < N; i++){
    for(j = i + 1; j < N; j++){
      
      int saitan = min(abs(i - j), abs(X - i) + abs(Y - j) + 1);
      Cnt.at(saitan - 1)++;
    }
  }
  
  for(i = 0; i < N - 1; i++){
    cout << Cnt.at(i) << endl;
  }
  return 0;
}

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

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

int main(void){
	int N,D,I,ii,ans(0),mus(0),II;
	double *a;
	scanf("%d %d",&N,&D);
	int X[N][D];
	rep(i,N){
		rep(I,D){
			scanf("%d",&X[i][I]);
		}	
	}
	rep(i,N - 1){
		for(I = i + 1 ; I < N ; I ++){
			rep(ii,D){
				mus += int(pow(fabs(double(X[i][ii] - X[I][ii])),2.));
			}
			for(II = 0 ; II * II <= mus ; II ++){
				if(II * II == mus) ans++;
			}
			mus = 0;
		}
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ALL(s) s.begin(),s.end()
#define IN(l,x,r) (l)<=(x) && (x) < (r)
typedef long long ll;
typedef pair<ll ,ll> Q;

struct UnionFind{
  vector<int> par,rank,ss;int size;
  UnionFind(int n){
	REP(i,n) par.push_back(i);
	rank=vector<int>(n);ss=vector<int>(n,1);size=n;
  }
  int root(int x){
	if(par[x]==x)return x;
	return par[x]=root(par[x]);
  }
  bool same(int x,int y){
	return root(x)==root(y);
  }
  void unite(int x,int y){
	x=root(x);y=root(y);
	if(x==y)return;
	if(rank[x]<rank[y]){
	  par[x]=y;ss[y]+=ss[x];
	}else{
	  par[y]=x;ss[x]+=ss[y];
	}
	if(rank[x]==rank[y])rank[x]++;
	size--;
  }
  int getS(int x){
	return ss[root(x)];
  }
};

int Y,X;
int enc(int y,int x){
  return y*X+x;
}

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



int main() {
  while (true) {
	int n;cin >>n;if(n==0)break;
	vector<int> xs,ys;

	vector<int> ls(n),ts(n),rs(n),bs(n);
	REP(i,n){
	  cin >> ls[i] >> ts[i] >> rs[i] >> bs[i];
	  ls[i]*=2;ts[i]*=2;rs[i]*=2;bs[i]*=2;
	  for(int d=-1;d<=1;d++){
		xs.push_back(ls[i]+d);ys.push_back(ts[i]+d);
		xs.push_back(rs[i]+d);ys.push_back(bs[i]+d);
	  }
	}
	sort(ALL(xs));xs.erase(unique(ALL(xs)),xs.end());
	sort(ALL(ys));ys.erase(unique(ALL(ys)),ys.end());

	X=xs.size();Y=ys.size();
	vector<vector<bool>> online(Y,vector<bool>(X));

	REP(yi,Y)REP(xi,X){
	  REP(i,n){
		if(xs[xi]==ls[i] && bs[i] <= ys[yi] && ys[yi] <=ts[i] )online[yi][xi]=true;
		if(xs[xi]==rs[i] && bs[i] <= ys[yi] && ys[yi] <=ts[i] )online[yi][xi]=true;
		if(ys[yi]==bs[i] && ls[i] <= xs[xi] && xs[xi] <=rs[i] )online[yi][xi]=true;
		if(ys[yi]==ts[i] && ls[i] <= xs[xi] && xs[xi] <=rs[i] )online[yi][xi]=true;
	  }
	}

	UnionFind uf(Y*X);
	REP(yi,Y)REP(xi,X)if(!online[yi][xi]){
	  REP(d,4){
		int nyi=yi+dy[d],nxi=xi+dx[d];
		if(IN(0,nyi,Y) && IN(0,nxi,X)){
		  if(!online[nyi][nxi]){
			uf.unite(enc(yi,xi),enc(nyi,nxi));
		  }
		}
	  }
	}
	int res=uf.size;
	REP(yi,Y)REP(xi,X)if(online[yi][xi])res--;
	cout << res <<endl;
  }
}

Measured memory_bytes: 2424
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
// for(int p=Set;p;p=(p-1)&Set)  부분집합원소순회
//cout<<fixed<<setprecision(11)<<(double)m/z<<"\n";
ll Gcd(ll a,ll b){
    if(b==0)return a;
    return Gcd(b,a%b);
} //오버플로우조심
ll Lcm(ll a,ll b){
    return (a*b)/Gcd(a,b);
}//오버 플로우 조심
ll n,m;
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    ll x,y; cin>>x>>y;
    ll gcd = Gcd(x,y);
    if(gcd == y){
        cout<<-1; exit(0);
    }
    for(ll i=2;;i++){
        ll num = x*i;
        if(num % y){
            cout<<num; exit(0);
        }
    }
    return 0;
}





Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a+b)%24)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
n = int(input())

counter = 0
for i in range(1, n+1, 2):
  yakusuu = 0
  for j in range(1, i // 2 + 1 + 1, 2):
    if i % j == 0:
      yakusuu += 1
#  print(i, j, yakusuu)
  if yakusuu == 7:
    counter += 1
  yakusuu = 0
print(counter)

Measured memory_bytes: 38512
n = int(input())
l = [int(x) for x in input().split()]

from collections import Counter
c = Counter(l)
x = list(c.values())

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

y = 0
for i in range(len(x)):
    if x[i] != 1:
        y += combinations_count(x[i], 2)

for j in range(n):
    print(y - (c[l[j]] - 1))

Measured memory_bytes: 26140
void sort(int *p,int *q){
    int temp;
    temp =*p;
    *p=*q;
    *q=temp;
}
#include <iostream>
#define And &&
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(b > c)
        sort(&b,&c);
    if(a > b)
        sort(&a,&b);
    if(b > c)
        sort(&b,&c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int n, a, b, x, y, minm;

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

     x = n*a;

     if(x<b)
        minm = x;
     else
        minm = b;

     cout<<minm<<endl;

     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h>>w;
    vector<vector<char>> c(h,vector<char>(w));
    int i,j;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin >> c.at(i).at(j);
        }
    }
    vector<vector<char>> C(2*h,vector<char>(w));
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            C.at(2*i).at(j)=c.at(i).at(j);
        }
    }
     for(i=1;i<h+1;i++){
        for(j=0;j<w;j++){
            C.at(2*i-1).at(j)=c.at(i-1).at(j);
        }
    }

    for(i=0;i<2*h;i++){
        for(j=0;j<w;j++){
            cout << C.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256