akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9) + 7;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] cl = new int[26];
        for(char c : s){
            cl[c - 'a']++;
        }
        long ans = 1;
        for(int i : cl){
            ans *= i+1;
            ans %= mod;
        }
        System.out.println(ans-1);
    }
}

Measured memory_bytes: 25832
import math
def gcd(a,b):
    while a > 0 and b > 0:
        if a > b:
            a = a % b
        elif a < b:
            b = b % a
        else:
            b = 0
    return max(a,b)

a,b = map(int,input().split())

def trial(k):
    factor = []
    m = int(math.sqrt(k)) + 1
    for i in range(2,m):
        while k % i == 0:
            k = k // i
            factor.append(i)
    if not factor:
        return [1,k]
    else:
        factor.append(k)
        factor.append(1)
        return factor

k = gcd(a,b)

ps = trial(k)

count = 1
for i in range(len(ps)-1):
    if ps[i] != ps[i + 1]:
        count += 1

print(count)


Measured memory_bytes: 3064
#include <cstdio>

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    char grid[h][w];
    for (int i = 0; i < h; i++) {
        scanf("%s", grid[i]);
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') {
                bool judge = false;
                if (i > 0) { judge |= (grid[i-1][j] == '#'); }
                if (i < h - 1) { judge |= (grid[i+1][j] == '#'); }
                if (j > 0) { judge |= (grid[i][j-1] == '#'); }
                if (j < w - 1) { judge |= (grid[i][j+1] == '#'); }
                
                if (!judge) { 
                    printf("No\n");
                    return 0;
                } 
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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

using namespace std;

double const pi = 3.1415926535897932384626433832795;
void solve(){
  // 1 hour for minute hand
  // 12 hours for hour hand
  // First find angle, then apply cosine rule
  // 30h - 6min + (min/2)
  double a, b, x, y;
  cin >> a >> b >> x >> y;
  double angle = 30.0 * x - 6.0 * y + (y / 2.0);
  if(angle >= 360){
    angle -= 360;
  }
  angle = (angle * (pi / 180.0));
  double side = sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(angle));
  cout << side << endl;

}

int main()
{
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 4244
def prime_factor_2(n):
  if n % 2 == 0 and n % 4 != 0:
    return 1
  if n % 2 == 1:
    return 0
  
  return 1 + prime_factor_2(int(n/2))

N = int(input())
A = list(map(lambda a: int(a), input().split(" ")))
print(sum([prime_factor_2(a) for a in A]))

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

int main(){
    int x;
    cin >> x;
    rep(i,15){
        rep(j,26){
            int total = 7*i + 4 *j;
          	//cout << total << endl;
            if (x == total){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

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

#define int long long

using namespace std;
 main() {
    int n , m , k , l , r ,mid ;
    cin >> n >> m;
    k = m / n;
    for (int i = k ;i >=1;i--)
    {
        if (m%i==0)
        {
            cout << i;
            exit(0);
        }
    }
}

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

using namespace std;

string f(string x){
	for (int i = 0; i < x.size(); i++){
		if ('a' <= x[i] && x[i] <= 'z') continue;
		x[i] = x[i] - 'A' + 'a';
	}
	return x;
}

int main(){
	string W, T;
	int ans = 0;
	cin >> W;
	while (1){
		cin >> T;
		if (T == "END_OF_TEXT") break;
		T = f(T);
		if (T == W) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3200
n=gets.to_i
s=gets.chomp.split('')
ans=0
rarray=[]
garray=[]
barray=[]

n.times{|i|
    if s[i]=="R"
        rarray.push(i+1)
     elsif s[i]=="G"
        garray.push(i+1)
     elsif s[i]=="B"
        barray.push(i+1)
    end
}

rgbarray=[rarray,garray,barray].sort_by{|value| value.count}
maxarray=rgbarray[2]
midarray=rgbarray[1]
minarray=rgbarray[0]


maxcount=maxarray.count
hash=maxarray.map { |value| [value,true] }.to_h

minarray.map{|min|
    
    midarray.map{|mid|
        
        add=maxcount
        if hash[(min+mid)/2] && (mid-min)%2==0
            add-=1
        end
        
        if hash[2*min-mid]
            add-=1
        end
        
        if hash[2*mid-min]
            add-=1
        end
        
        ans+=add
    }
    
}



puts ans

Measured memory_bytes: 28640
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> num;
    int result =0;

    for(int i=0;i<N;i++){
        int buff;
        cin>>buff;
        for(;;){
            if(buff%2!=0){
                break;
            }
            buff=buff/2;
            result++;
        }
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
 
using namespace std;
 
//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(typeof((c).begin()) 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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e9;

const int MAX_N = 101, MAX_L = 101;
int dp[MAX_N][MAX_L];
struct Edge{
  int to, cost, num;
  Edge(int t, int c, int n):
	to(t), cost(c), num(n){}  
};
typedef vector<vector<Edge>> G;
typedef pair<int,PII> PPII;

int N, M, L;
int dijkstra(G& edges){
  fill((int*)dp, (int*)dp+MAX_N*MAX_L, INF);
  priority_queue<PPII, vector<PPII>, greater<PPII>> pq;
  // num,node,cost
  pq.push(MP(0,MP(0,L)));
  dp[0][L] = 0;
  
  int ans = INF;
  while(!pq.empty()){
	int num, node, cost;
	PPII ppii = pq.top(); pq.pop();
	num = ppii.first, node = ppii.second.first, cost = ppii.second.second;
	
	if(node == N-1) ans = min(ans, num);
	if(dp[node][cost] < num) continue;
	for(auto& e: edges[node]){
	  int n_ = num + e.num;
	  if(dp[e.to][cost] > n_){
		dp[e.to][cost] = n_;
		pq.push(MP(n_, MP(e.to, cost)));
	  }
		
	  int c_ = cost - e.cost;
	  if(c_ < 0 || dp[e.to][c_] <= num) continue;
	  dp[e.to][c_] = num;
	  pq.push(MP(num, MP(e.to, c_)));
	}
  }

  return ans;
}

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

  while(cin>>N>>M>>L, N){
	G g(N);
	REP(i,M){
	  int a, b, d, e; cin >> a >> b >> d >> e;
	  --a, --b;
	  g[a].PB(Edge(b,d,e));
	  g[b].PB(Edge(a,d,e));
	}

	cout << dijkstra(g) << endl;;
  }
  
  return 0;
}

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

int nums[1005];
int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif
    int n;

    while (scanf("%d", &n), n != 0) {
        double sum = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%d", &nums[i]);
            sum += nums[i];
        }
        sum = sum / n;
        double ans = 0;
        for (int j = 0; j < n; ++j) {
            ans += ((nums[j] - sum) * (nums[j] - sum));
        }
        printf("%f\n", sqrt(ans / n));
    }
    return 0;
}



Measured memory_bytes: 2132
from itertools import combinations
import sys
"""
10の６条
ijklm
"""

X = int(input())
P = [1, 2, 3, 4, 5]

if 1 <= X <= 99:
    print("0")
    sys.exit(0)

a = X % 100
b = X // 100

if a == 0:
    print("1")
    sys.exit(0)

for i in range(20):
    for j in range(25):
        for k in range(34):
            for l in range(50):
                ans = 5 * i + 4 * j + 3 * k + 2 * l
                if a -ans <= b - (i + j + k + l) and a - ans >= 0:
                    print("1")
                    sys.exit(0)
print('0')

Measured memory_bytes: 3064
N, K = [int(a) for a in input().split()]

p = 10 ** 9 + 7
C1 = 1  # (K-1)C(i-1), where i = 1
C2 = N - K + 1  # (N-K+1)Ci, where i = 1

print(C1 * C2 % p)

# inv[i] : inverse of i mod p
inv = [0, 1]
for i in range(2, K + 1):
    inv.append(( inv[p % i] * (p - p//i) ) % p ) # inv[i]

    # (K-1)C(i-1) = (K-1)C(i-2) * (K-i+1)/(i-1) = (K-1)C(i-2) * (K-i+1) * (i-1)^(-1) (mod p)
    C1 = (C1 * (K - i + 1) % p) * inv[i - 1] % p  # (K-1)C(i-1)

    # (N-K+1)Ci = (N-K+1)C(i-1) * (N-K-i+2)/i = (N-K+1)C(i-1) * (N-K-i+2) * i^(-1) (mod p)
    C2 = (C2 * (N - K - i + 2) % p) * inv[i] % p  # (N-K+1)Ci

    print(C1 * C2 % p)

Measured memory_bytes: 42480
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i <= (int)n; ++i)
#define REPT(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

string zeroPadding(ll n) {
    string s = to_string(n);
    while (s.length() < 6) {
        s = "0" + s;
    }
    return s;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll mod = 1e9 + 7;

int main() {
    int N = 0, M, K, O, a = 0, b = 0;
    ll x, y, sum, pos = 0, c = 0;
    string k, v;
    bool flag = true;
    cin >> k;
    sum = 0;
    bool B[3];
    for (int bit = 0; bit < (1 << k.length() - 1); ++bit) {
        //cout << bitset<10>(bit) << endl;
        ll s = 0, t = 0;
        t = k[0] - '0';
        REP(i, k.length() - 1) {
            if (bit & (1 << i)) {
                t += k[i + 1] - '0';
                B[i] = true;
            } else {
                t -= k[i + 1] - '0';
                B[i] = false;
            }
        }
        if (t == 7) {
            cout << k[0];
            REP(i, 3) {
                if (B[i])cout << "+";
                else cout << "-";
                cout << k[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }

    }
    return 0;
}

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

using namespace std;

int main ()
{
	int N, i, j;
	scanf ("%d", &N);
	int c[N], dd[N];
	for (i = 0; i < N; i++)
	{
		scanf ("%d", &(c[i]));
	}
	if (N == 2)
	{
		printf ("%d\n", abs (c[0] - c[1]));
		return 0;
	}
	dd[0] = 0;
	dd[1] = abs (c[0] - c[1]);
	for (i = 2; i < N; i++)
	{
		dd[i] = min (dd[i - 1] + abs (c[i - 1] - c[i]),
				dd[i - 2] + abs (c[i - 2] - c[i]));
	}
	printf ("%d\n", dd[N - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    int n;  cin>>n;
    mk(h, n, int);  forI(i, 0, n-1) cin>>h[i];
    mk(cost, n, int);
    cost[1] = abs(h[0]-h[1]);
    cost[2] = min(cost[1] + abs(h[2]-h[1]), abs(h[0]-h[2]));

    forI(i, 3, n-1){
        cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]-h[i-2]));
    }

    cout<<cost[n-1]<<endl;
}

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	for(llong h = 1; h <= 3500; h++){
		for(llong w = 1; w <= 3500; w++){
			llong bunsi = N*h*w;
			llong bunbo = 4*h*w - N*(w+h);
			// cerr << h << " " << w << " " << bunsi << " " << bunbo << endl;
			if(bunbo > 0 && bunsi%bunbo == 0){
				cout << h << " " << w << " " << bunsi/bunbo << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(MAX_V,-1);//訪問したかどうか
bool judgebuf=true;
void dfs(ll k,ll x){
  t[k]=x;
  for(ll i=0;i<G[k].size();i++){
    if(t[G[k][i]]==-1){
      dfs(G[k][i],x^1); 
    }
    else if(t[G[k][i]]==x)judgebuf=false;
  }
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<string>a(n);
  vector<vector<ll>> matrix(n,vector<ll>(n,INF));
  rep(i,0,n)cin>>a[i];
  rep(i,0,n-1)rep(j,i+1,n){
    if(a[i][j]=='1'){
      G[i].PB(j);
      G[j].PB(i);
      matrix[i][j]=1;
      matrix[j][i]=1;
    }
  }
  rep(i,0,n)matrix[i][i]=0;
  dfs(0,0);
  for(ll i=0;i<n;i++)matrix[i][i]=0;
  for(ll j=0;j<n;j++){
    for(ll i=0;i<n;i++){
      for(ll o=0;o<n;o++){
        chmin(matrix[i][o],matrix[i][j]+matrix[j][o]);
      }
    }
  }
  rep(i,0,n)rep(j,0,n){
    chmax(res,matrix[i][j]);
  }
  if(judgebuf)cout<<res+1<<endl;
  else cout<<-1<<endl;
  //debug(t,n);
  return 0;
}

Measured memory_bytes: 7296
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x<0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(m):
  uf=UnionFind(n)
  for j in range(m):
    if i==j:continue
    uf.unite(ab[j][0]-1,ab[j][1]-1)
  if uf.group_count()==2:
    uf.unite(ab[i][0]-1,ab[i][1]-1)
    if uf.group_count()==1:
      ans+=1
print(ans)

Measured memory_bytes: 3188
n = int(input())
A = list(map(int,input().split()))

A.sort(reverse=True)
E = [0,0]

j = 0
for i in range(n):
    if E[j] == A[i]:
        j += 1
        if j == 1:
            continue
        else:
            break
    E[j] = A[i]
    
print(E[0]*E[1])

Measured memory_bytes: 14252
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto AB = RD + RD;
	auto CD = RD + RD;

	writeln(AB == CD ? "Balanced" : AB > CD ? "Left" : "Right");
	stdout.flush();
	debug readln();
}


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

typedef long long ll;
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(ll i = ll(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll N, K;
std::vector<ll> v;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
	
	cin >> N >> K;
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	
	std::sort(v.begin(),v.end(),std::greater<ll>());
	ll ans = INF;
	rep(i, v.size()) {
		if (i+K-1 < v.size()) {
			ll max_tmp = v[i];
			ll min_tmp = v[i+K-1];
			ll tmp = max_tmp - min_tmp;
			if (tmp < ans) {
				ans = tmp;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,sw,ans,i;
  ans=0;
  sw=0;
  cin >> n;
  int c1[n],c2[n];
  
  for(i=0;i<n;++i)
  {
    cin >> c1[i] >> c2[i];
    if(c1[i]==c2[i]) sw++;
    else sw=0;
    
    if(sw>=3) ans++;
  }
  
  if(ans >0) cout << "Yes";
  else cout << "No";
  
return 0;}

Measured memory_bytes: 3632
read_name = {0: 'pon', 1: 'pon', 2: 'hon', 3: 'bon', 4: 'hon', 5: 'hon',
             6: 'pon', 7: 'hon', 8: 'pon', 9: 'hon'}
N = input()
print(read_name[int(N[-1])])


Measured memory_bytes: 9168
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define Maxn 200010
#define LL long long

using namespace std;

const double eps = 0.00001;

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

LL n, k, a[Maxn], maxone;

LL calc(int len) {
    if(!len) return 1e9 + 1;
    LL tim = 0;
    for(int i = 1; i <= n; ++i) {
        tim += (a[i] - 1) / len;
    }
    return tim;
}

int main() {
    n = read(); k = read();
    for(int i = 1; i <= n; ++i) a[i] = read(), maxone = max(maxone, a[i]);
    int l = 0, r = maxone;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(calc(mid) > k) l = mid + 1;
        else r = mid;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 5092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = n;
		for (int i = 0; i < m; i++) {
			sum -= sc.nextInt();
		}
		if (sum < 0) {
			System.out.println(-1);
		} else {
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 46312
unittest
{
	assert( [ "ATCODER" ].parse.expand.solve == 3 );
	assert( [ "HATAGAYA" ].parse.expand.solve == 5 );
	assert( [ "SHINJUKU" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto ans = 0L;
	auto m = 0L;
	foreach( c; s )
	{
		if( c == 'A' || c == 'C' || c == 'G' || c == 'T' )
		{
			m++;
			if( ans < m ) ans = m;
		}
		else
		{
			m = 0;
		}
	}
	return ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    long long a;
    long long maxValue = -1000000;
    long long minValue = 1000000;
    long long sum = 0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>a;
        if(a < minValue) minValue = a;
        if(a > maxValue) maxValue = a;
        sum += a;
    }

    cout<< minValue <<" "<< maxValue <<" "<< sum << endl;

    return 0;}

Measured memory_bytes: 1172
import java.util.Scanner;
class Main
{
public static void main(String[] args)
 {
 Scanner sc = new Scanner(System.in);
  int  n  = sc.nextInt();
  int  i,j;
  boolean[][] card = new boolean[4][13];

 for(i=0;i<n;i++){
  char suit = sc.next().charAt(0);
  int num = sc.nextInt();
   switch(suit){
   case 'S': card[0][num-1]=true;
   break;
   case 'H': card[1][num-1]=true;
   break;
   case 'C': card[2][num-1]=true;
   break;
   case 'D': card[3][num-1]=true;
   break;
   }
}
   for(i=0;i<4;i++){
    for(j=0;j<13;j++){
     if(card[i][j]==false)System.out.println("SHCD".charAt(i)+" "+(j+1));
}

} 
 }
}
   




Measured memory_bytes: 26312
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    ll l = LLONG_MIN / 2, r = LLONG_MAX / 2;
    while(l + 1 < r) {
        ll tmp = 0, t2 = 0;
        ll x = (l + r) / 2;
        for(int i = 0; i < n; i++) {
            t2 += (a[i] * a[i] <= x);
            if(a[i] > 0) {
                int left = -1, right = n;
                while(left + 1 < right) {
                    int m = (left + right) / 2;
                    if(a[m] * a[i] <= x) {
                        left = m;
                    } else {
                        right = m;
                    }
                }
                tmp += right;
            }
            if(a[i] == 0) {
                if(0 <= x) {
                    tmp += n;
                }
            }
            if(a[i] < 0) {
                int left = -1, right = n;
                while(left + 1 < right) {
                    int m = (left + right) / 2;
                    if(a[m] * a[i] <= x) {
                        right = m;
                    } else {
                        left = m;
                    }
                }
                tmp += n - right;
            }
        }
        tmp -= t2;
        tmp /= 2;
        // cout << x << " " << tmp << endl;
        if(tmp < k) {
            l = x;
        } else {
            r = x;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>

#define int long long

using namespace std;

void solve() {
    int x;
    cin >> x;
    x -= 400;
    x /= 200;
    cout << 8 - x;
}

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

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 3192
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#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>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	set<ll> L;
	set<ll,greater<ll>> R;
	string S;
	READ(S);
	ll N=S.length();
	ll ans[N]={0};
	FORI(i,0,N)
	{
		if (S[i]=='L')
		{
			L.insert(i);
		}
		else
		{
			R.insert(i);
		}
	}
	FORI(i,0,N)
	{
		if (S[i]=='L')
		{
			ll x=*(R.lower_bound(i));
			if (abs(x-i)%2==0)
			{
				ans[x]++;
			}
			else
			{
				ans[x+1]++;
			}
		}
		else
		{
			ll x=*(L.lower_bound(i));
			if (abs(x-i)%2==0)
			{
				ans[x]++;
			}
			else
			{
				ans[x-1]++;
			}
		}
	}
	FORI(i,0,N)
	{
		cout<<ans[i]<<" ";
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 6096
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int x, y, z;
  cin >> x >> y >> z;
  int ans = 0;
  if(x >= y+2*z) ans = 1;
  int cur = y+2*z;
  while(cur + z + y <= x){
    ans++;
    cur += z+y;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s[0]==s[s.size()-1]){
		if(s.size()%2==0){
			cout<<"First"<<endl;
		}
		else{
			cout<<"Second"<<endl;
		}
	}
	else{
		if(s.size()%2!=0){
			cout<<"First"<<endl;
		}
		else{
			cout<<"Second"<<endl;
		}
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int n = Integer.parseInt(line);
            int m = n - 1;
            boolean[] ns = new boolean[n + 1];

            for (int i = 2; i < n + 1; i++) {
                for (int j = i; j < n / i + 1; j++) {
                    if (!ns[i * j]) {
                        //System.out.println(i * j);
                        ns[i * j] = true;
                        m--;
                    }
                }
            }
            System.out.println(m);
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    REP(i,n){
        cin >> a[i];
    }
    ll kabu = 0;
    ll kane = 1000;
    REP(i,n-1){
        if(a[i]<a[i+1]){
            kabu = kane/a[i];
            kane += kabu*(a[i+1]-a[i]);
        }
    }
    cout << kane << endl;
}

Measured memory_bytes: 3548
import java.io.*;
import java.util.*;
public class Main {
    static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static String line;
    static int n, k, T, N, m, Q, q, R, C, x, M, id, x0, y0, g, y, d, SCC,A,B,D;
    static StringTokenizer st;
    static Scanner in = new Scanner(System.in);
    static char[][] word;
    static IP[][] parent;
    static BitSet onStack = new BitSet(100000);
    static ArrayList<Integer> graph[];
    static int[] low, ids;
    static Stack<Integer> stack;

    public static void main(String[] args) throws IOException {
        st = new StringTokenizer(br.readLine());
        A = Integer.parseInt(st.nextToken());B = Integer.parseInt(st.nextToken());
        C = Integer.parseInt(st.nextToken()); D = Integer.parseInt(st.nextToken());
        int i=0;
        while (A>0&&C>0){
            if(isEven(i++)){
                C-=B;

            }else{
                A-=D;
            }
        }
        pw.println (A>0?"Yes":"No");
            pw.flush();

        }
        static class IP {
            int row, col;

            public IP(int row, int col) {
                this.row = row;
                this.col = col;
            }
        }
        static void extendedEuclid ( int a, int b){
            if (b == 0) {
                x = 1;
                y = 0;
                d = a;
                return;
            }
            extendedEuclid(b, a % b);
            int x1 = y;
            int y1 = x - (a / b) * y;
            x = x1;
            y = y1;
        }
        static boolean isEven ( int i){
            return (i & 1) == 0;
        }
        static boolean isOdd ( int i){
            return (i & 1) == 1;
        }
        static class Edge implements Comparable<Edge> {
            int u, v;
            double weight;

            Edge(int u, int v, double weight) {
                this.u = u;
                this.v = v;
                this.weight = weight;
            }

            @Override
            public int compareTo(Edge edge) {
                return (int) (weight - (int) edge.weight);
            }
        }
        static class DisjointSet {
            int[] parent, rank;

            void make_set(int v) {
                parent = new int[v];
                for (int i = 0; i < v; i++)
                    parent[i] = i;
                rank = new int[v];
            }

            int find_set(int v) {
                if (v == parent[v])
                    return v;
                return parent[v] = find_set(parent[v]);//compress the step
            }

            void union_set(int a, int b) {
                a = find_set(a);
                b = find_set(b);
                if (a != b) {
                    if (rank[a] < rank[b]) {
                        int c = a;
                        a = b;
                        b = c;
                    }
                    parent[b] = a;
                    if (rank[a] == rank[b])
                        rank[a]++;
                }
            }
        }
    }



Measured memory_bytes: 35864
#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>;
using namespace std;

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
constexpr int kN = 1 << 10, kM = 1 << 21;
vector<int> graph[kM];
stack<int> s;
int in[kM], dfs_clock;
int sccno[kM], scc_cnt;
int dfs(int u) {
	int lowu = in[u] = ++dfs_clock;
	s.push(u);
	for(int v : graph[u]) {
		if(!in[v]) lowu = min(lowu, dfs(v));
		else if(!sccno[v]) lowu = min(lowu, in[v]);
	}
	if(lowu == in[u]) {
		scc_cnt++;
		while(true) {
			int x = s.top(); s.pop();
			sccno[x] = scc_cnt;
			if(x == u) break;
		}
	}
	return lowu;
}
 
int main() {
	int n, m, q, l, r;
	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d%d", &l, &r);
		graph[l + 1].PB(r + 1);
	}
	for (int i = 1; i <= n; i++) if (!in[i]) dfs(i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", (sccno[l + 1] == sccno[r + 1]) ? 1 : 0);
	}
	
}



Measured memory_bytes: 53228
using System;

namespace ABC160C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int a1 = int.Parse(s[0]);
            int a2 = int.Parse(s[1]);
            int[] a = new int [a1 + 1];
            int[] b = new int[a1 + 1];
            int c = 0;
            int x = 0;

            var n = Console.ReadLine().Split(' ');

            
            for (int i = 1;i <= a2;i++)
            {
                a[i] = int.Parse(n[i - 1]);
            }

            for(int i = 1;i <= a2 - 1;i++)
            {
                b[i] = a[i + 1] - a[i];
                x += b[i]; 
                if (b[i] >= c)
                    c = b[i];

            }
            x += a1 + a[1] - a[a2];
            if (a1 + a[1] - a[a2] >= c)
                c = a1 + a[1] - a[a2];
            x -= c;
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 32348
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const lli mod_ = 998244353;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;
const int MAX = 1e5 + 5;

int n, cap;
int weights[105], values[105];
lli dp[105][MAX];

int main() {
	// ifstream cin("input.in");
	// ofstream cout("output.out");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> cap;
	for(int i = 0; i < n; i++)
		cin >> weights[i] >> values[i];

	for(int wt_available = 1; wt_available <= cap; wt_available++)
		dp[0][wt_available] = (weights[0] <= wt_available ? values[0] : 0);

	for(int ind = 1; ind < n; ind++) {
		for(int wt_available = 1; wt_available <= cap; wt_available++) {
			if(wt_available >= weights[ind]) {
				lli ans1 = dp[ind-1][wt_available-weights[ind]] + values[ind]; // take
				lli ans2 = dp[ind-1][wt_available];							   // leave
				dp[ind][wt_available] = max(ans1, ans2);
			}
			else {
				dp[ind][wt_available] = dp[ind-1][wt_available];
			}
		}
	}
	
	cout << dp[n-1][cap];

	return 0;
}

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

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

  if((a==b&&b==c)||(a!=b&&b!=c&&a!=c)){cout << "No" << endl;}
  else{cout << "Yes" << endl;}
    
  return 0;

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    int lenS = S.length();
    int l = 0, r = lenS-1;
    int cnt = 0;
    while(l < r){
        if(S[l] != S[r]) cnt++;
        l++; r--;
    }
    cout << cnt << endl;
    return 0;
}

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

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;loop(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull aint;

typedef vector<aint> vaint;
typedef list<aint> laint;

int main(void){
	aint a[3][3];
	bool c[3][3];
	loop(i, 0, 3){
		loop(j, 0, 3){
			cin >> a[i][j];
			c[i][j] = false;
		}
	}
	init(aint, n);

	loop(k, 0, n){
		aint b;
		cin >> b;
		loop(i, 0, 3){
			loop(j, 0, 3){
				if (a[i][j] == b){
					c[i][j] = true;
				}
			}
		}
	}

	bool ans = false;
	if (c[0][0] && c[1][1] && c[2][2])ans = true;
	if (c[2][0] && c[1][1] && c[0][2])ans = true;
	loop(i, 0, 3)if (c[i][0] && c[i][1] && c[i][2])ans = true;
	loop(j, 0, 3)if (c[0][j] && c[1][j] && c[2][j])ans = true;

	outl((ans ? "Yes" : "No"));

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5],k;
  bool flag = false;
  for(auto& i:a) cin >> i;
  cin >> k;
  for(int i=0;i<4;i++){
    for(int j=i+1;j<5;j++){
      if(a[j]-a[i]>k) flag = true;
    }
  }
  if(flag) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K;
  string S;

  cin >> N >> K >> S;

  S[K-1] = S[K-1] - 'A' + 'a';

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
using namespace std; 

int main() {
    int N, M; cin >> N >> M;
	vector<int> LIKE(M, 0);
	for(int i = 0; i < N; i++){
		int K; cin >> K;
		for(int j = 0; j < K; j++){
			int A; cin >> A; A--;
			LIKE[A] += 1;
		}
	}
	int sum = 0;
	for(int i = 0; i < M; i++){
		if(LIKE[i] == N) sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : NotSoDiverse.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 200001;
int n, k, buf,
	arr[MAX], freq[MAX];
vector<int> freqs;

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

	cin >> n >> k;

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

	for (int i = 1; i <= n; ++i) {
		if(freq[i]){
			freqs.push_back(freq[i]);
		}
	}

	sort(freqs.begin(), freqs.end());

	if(freqs.size() <= k){
		printf("0\n");
		return 0;
	}

	int sum = 0;

	for(int i = 0; i < freqs.size() - k; i++){
		sum += freqs[i];
	}

	printf("%d\n", sum);
}


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

int main() {
	// your code goes here
	int n,x;
	cin >> n >> x;
	int l,d[n+2];
	d[1] = 0;
	for(int i = 2 ; i <= n+1 ; i++)
	{
		cin >> l;
		d[i] = d[i-1]+l;
	}
	int c = 0;
	for(int i = 1 ; i <= n+1 ; i++)
	{
		if(d[i] <= x)c++;
	}
	cout << c << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){

	int v[4];
	
	for(int i=0; i<3; i++) scanf("%d", &v[i]);
	
	sort(v, v+3);
	int ans=INT_MAX;
	do{
		int sum=0;
		for(int i=1; i<3; i++) sum+=abs(v[i]-v[i-1]);
		ans = min(ans, sum);
	}while(next_permutation(v, v+3));
	printf("%d\n", ans);


}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll N;
    cin >> N;
    set<ll> A;
    while(N--){
        ll a; cin >> a;
        A.insert(a);
    }

    ll M;
    cin >> M;
    set<ll> B;
    while(M--){
        ll b; cin >> b;
        B.insert(b);
    }

    vector<ll> C;
    set_difference(ALL(A), ALL(B), back_inserter(C));

    for(ll c : C){
        p(c);
    }

    return 0;
}


Measured memory_bytes: 23656
import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right

W, H = map(int,input().split())

P = [int(input()) for _ in range(W)]
Q = [int(input()) for _ in range(H)]

P.sort()
Q.sort()

res = 0

for i in range(W):
    res += (H + 1 - bisect_left(Q, P[i])) * P[i]

for i in range(H):
    res += (W + 1 - bisect_right(P, Q[i])) * Q[i]
    
print(res)

Measured memory_bytes: 11468
/******************************************
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fin for(int i = 1; i <=n; i++)
#define fiab for(int i=a;i<b;i++)
#define fi1b for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int m;int h[100004];int n;LL dp[100004];
long frog1(int i){
   
	 if(i==1){
        return 0;
     }if(i==2){
        return (abs(h[i]-h[i-1]));
     } LL &ans=dp[i];
    if(ans!=-1){
        return ans;
    } 
     ans=min(frog1(i-1)+abs(h[i]-h[i-1]),frog1(i-2)+abs(h[i]-h[i-2]));
     return ans;
     }

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

 
      
     memset(dp,-1,sizeof(dp));
     cin>>n;m=n;
     
     fin{
     	cin>>h[i];
     } 
     long p=frog1(n);
     cout<<p<<endl;
return 0;
}

Measured memory_bytes: 2944
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
	int a,b;
	cin>>a>>b;
	out((a+b)%24);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256