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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FIntervalsOnTree {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<pii> E(N-1);
        for(auto& e : E) in>>e.first>>e.second;
        lint ans = 0;
        FOR(i, 1, N+1) ans += 1ll * (N-i+1) * (N-i+2) / 2;
        for(auto& e : E){
            int u = e.first, v = e.second;
            if(u>v) swap(u, v);
            ans -= 1ll * u * (N-v+1);
        }
        out<<ans<<'\n';
    }
};


int main() {
	FIntervalsOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N];
ll ans;
int main(){
    int n=gi()*3;
    for (int i=1; i<=n; ++i)
	a[i]=gi();
    sort(a+1,a+n+1);
    int cnt=0;
    for (int i=n-1; ++cnt<=n/3; i-=2)
	ans+=a[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
    string s;
    getline(cin, s);
    for(int i=0; i<=s.length(); i++){
        if(s[i]>='a' && s[i]<= 'z') s[i]=s[i]+'A'-'a';
        else if(s[i]>='A' && s[i]<='Z') s[i]+='a'-'A';
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3200
n=int(input())
P=str(input())

def ans132(n:int, P:str):
    P=list(map(int,P.split()))
    jugde_count=0
    for i in range(1,n-1):
        n_list=sorted([P[i-1],P[i],P[i+1]])
        if n_list[1]==P[i]:
            jugde_count+=1
    return jugde_count

print(ans132(n,P))

Measured memory_bytes: 9104
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    long double w,h,x,y;
    cin >> w >> h>> x>>y;
    cout <<(w*h)/2 << " ";
    if (x==w/2 && y==h/2)
        cout << "1";
    else
        cout << "0";




    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long n, d;
	cin >> n >> d;
	long long geko = 0;
	cin >> geko;
	geko--;
	geko %= (d + 1);
	REP(i, n - 1) {
		long long t;
		cin >> t;
		t--;
		t %= (d + 1);
		geko ^= t;
	}
	if (geko != 0) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,t,a;
  cin >> n >> t >> a;
  int index = 0;
  double dif = MOD;
  rep(i,n){
    int buf;
    cin >> buf;
    //cout << abs(t-buf*0.006 - a) << endl;
    if(dif > abs(t-buf*0.006 - a)){
      dif = abs(t-buf*0.006 - a);
      index = i + 1;
    }
  }
  cout << index << endl;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
int mod=1e9+7;
const int N=1e5+100;

struct node
{
    ll a,v;
}p[5];
int main()
{
    long double t;
    cin>>p[1].a>>p[1].v>>p[2].a>>p[2].v>>t;
   // sort(p+1,p+3);
    long double tt=fabs(1.0*(p[1].a-p[2].a))/(1.0*(p[1].v-p[2].v));
    if(tt>0&&tt<=t)  puts("YES");
    else  puts("NO");
    return 0;
}



Measured memory_bytes: 3724
from collections import deque
from itertools import permutations
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M = map(int, readline().split())
    OP = [0]*N
    ops = ["T=T&X\n", "T=T&Y\n", "T=T|X\n", "T=T|Y\n", "T=T^X\n", "T=T^Y\n"]
    for i in range(N-1):
        s = readline()
        OP[i+1] = ops.index(s)
    G = [[] for i in range(N)]
    for i in range(N-1):
        u, v = map(int, readline().split())
        G[u].append(v)
        G[v].append(u)
    used = [0]*N
    used[0] = 1
    P = [-1]*N
    V = []
    D = [0]*N
    que = deque([0])
    for i in range(N):
        v = que.popleft()
        d = D[v]+1
        for w in G[v]:
            if used[w]:
                continue
            used[w] = 1
            que.append(w)
            P[w] = v
            D[w] = d
            V.append(w)
    def check(x, y):
        S = [0]*N
        for v in V:
            op = OP[v]
            s = S[P[v]]
            if op & 1:
                if op & 2:
                    s |= y
                elif op & 4:
                    s ^= y
                else:
                    s &= y
            else:
                if op & 2:
                    s |= x
                elif op & 4:
                    s ^= x
                else:
                    s &= x
            S[v] = s
        T = [-1]*N
        for v in reversed(V):
            if T[v] == -1:
                T[v] = S[v]
            p = P[v]
            if D[v] & 1:
                T[p] = max(T[p], T[v]) if T[p] != -1 else T[v]
            else:
                T[p] = min(T[p], T[v]) if T[p] != -1 else T[v]
        return T[0]

    Q = [(1, 1), (1, 0), (0, 1)]
    R = {}
    for (x0, y0), (x1, y1), (x2, y2) in permutations(Q):
        x = x0 + x1*2 + x2*4
        y = y0 + y1*2 + y2*4
        d = check(x, y)
        d0 = d & 1; d1 = +((d & 2) > 0); d2 = +((d & 4) > 0)
        R[(x0, x1, x2), (y0, y1, y2)] = (d0, d1, d2)
        R[(x1, x2), (y1, y2)] = (d1, d2)
        R[(x2,), (y2,)] = (d2,)
    for i in range(M):
        x, y = map(int, readline().split())
        c = 0
        E = {}
        Q = []
        x0 = x; y0 = y
        while x0 or y0:
            x1 = x0 & 1; y1 = y0 & 1
            if x1 or y1:
                E[x1, y1] = c
            Q.append((x1, y1))
            x0 >>= 1; y0 >>= 1
            c += 1
        if not E:
            write("0\n")
            continue
        *S, = E.keys()
        S.sort(key = E.__getitem__)
        x1 = tuple(p for p, q in S)
        y1 = tuple(q for p, q in S)
        d1 = R[x1, y1]
        for p, q, d in zip(x1, y1, d1):
            E[p, q] = d
        Q.reverse()
        ans = 0
        for p, q in Q:
            if p or q:
                ans = (ans << 1) | E[p, q]
            else:
                ans <<= 1
        write("%d\n" % ans)
solve()


Measured memory_bytes: 31256
s = input()
if 'BC' not in s:
  print(0)
  import sys
  sys.exit()
t = s.split('BC')
m = 0
ans = 0
for l in t[:-1]:
  cnt = 0
  for c in l[::-1]:
    if c!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m
print(ans)

Measured memory_bytes: 46960
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int n,k;
  cin >> n >> k;

  vector<long> h = vector<long>(n);

  REP(i,n){
    cin >> h[i];
  }

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

  int min = INF * 100;

  REP(i,n-k+1){
    int diff = h[i+k-1] - h[i];
    if (diff < min) {
      min = diff;
    }
  }

  cout << min << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int main()
{
	long long a,b;
	while (cin >> a>>b) {
		long long c, d;
		c = gcd(a, b);
		d = c*(a / c)*(b / c);
		cout << c <<' '<< d << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n, as = 0, bs = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) (i % 2 == 0 ? as += a[i] : bs += a[i]);
	cout << as - bs << endl;
}

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

typedef long long ll;
const ll MAXN =105;
const ll INF = 1e18;

ll n,sum, cap[MAXN][MAXN],p[MAXN];
vector<ll> adj[MAXN];
queue<pair<ll,ll>> q;

ll bfs(int s, int t){
    while(!q.empty())q.pop();
    
    p[0] = -2;
    q.push({0ll,INF});
    while(!q.empty()){
        ll cur = q.front().first;
        ll flow = q.front().second;
        q.pop();
        for (auto next : adj[cur]){
            if (p[next] == -1 && cap[cur][next] > 0){
                p[next] = cur;
                ll newflow = min(flow,cap[cur][next]);
                if(next == t)
                    return newflow;
                q.push({next,newflow});
            }
        }
    }
    return 0;
}

ll maxflow(int s, int t){
    ll ans = 0;
    
    while(1){
        memset(p,-1,sizeof(p));
        ll newflow = bfs(s,t);
		if(!newflow)break;
        ans += newflow;

		long long cur = t;
		while(cur != s){
			long long prev = p[cur];
			cap[prev][cur] -= newflow;
			cap[cur][prev] += newflow;
			cur = prev;
		}
	}
    return ans;
}

int main(){
    cin>>n;
    ll tmp;
	for(ll i =1;i<=n;i++){
        cin >> tmp;
		
		if(tmp>=0){
			adj[i].push_back(n+1);
			adj[n+1].push_back(i);
			cap[i][n+1]+=tmp;
			sum+=tmp;
		}
		if(tmp<0){
			adj[i].push_back(0);
			adj[0].push_back(i);
			cap[0][i]-=tmp;
		}
		for(int j = 2*i; j <= n;j += i){
			adj[i].push_back(j);
			adj[j].push_back(i);
			cap[i][j]= INF;
		}
	}

    cout << sum - maxflow(0,n+1) << "\n";
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;



int main() {
	int h, w, n;
	cin >> h >> w >> n;

	int m = max(h, w);
	int ans = n / m;
	if (n%m != 0) {
		ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

int gcd(int x, int y){
  if(x < y) swap(x,y);
  if(y == 0) return x;
  return gcd(x%y,y);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int K;
    cin >> K;
    int res=0;
    rep(a,1,K+1){
        rep(b,1,K+1){
            rep(c,1,K+1){
                int d = gcd(a,b);
                res+=gcd(d,c);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3600
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int x,y,z;
  cin >> x >> y >> z;
  
  cout << z SP x SP y << endl; 

  return 0;
}

Measured memory_bytes: 256
/**********************************************

1.score.cpp
2.テァツつュテァツ板ーテゥツォツ佚ィツシツ?
3.sumita.takaki@gmail.com

last updated: 2013-07-10@11:54

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;

int main (void){

        while(1){
                
                int a=0,total1=0;
                int b=0,total2=0;
                
                for(int i=0; i<4; i++){
                        
                        cin >> a;                
                        total1 = total1 + a;
                }
                if(a == NULL)break;
                
                for(int i=0; i<4; i++){
                        
                        cin >> b;
                        total2 = total2 +b;                
                }
                
                if(total1 > total2){
                        cout << total1 <<endl;
                }else{
                        cout << total2 << endl;
                }
                
        }



}

Measured memory_bytes: 1160
import sys

*I, = map(int, sys.stdin.read().split())
n = I[0]
f = list(zip(*[iter(I[1:1+10*n])] * 10))
p = list(zip(*[iter(I[1+10*n:])] * 11))

def main():
    res = -float('inf')
    for i in range(1, 2**10):
        cnt = [0] * n
        for j in range(10):
            if i >> j & 1:
                for k in range(n):
                    cnt[k] += f[k][j]
        profit = 0
        for k in range(n):
            profit += p[k][cnt[k]]
        res = max(res, profit)

    return res
        
if __name__ == '__main__':
    ans = main()
    print(ans)

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

using namespace std;

int main() {
    int A, B;
    int ans = 0;

    cin >> A >> B;

    for (int i = A; i <= B; i++) {
        string str_i = to_string(i);
        int len = str_i.length();
        bool flag = true;
        for (int j = 0; j < len/2; j++) {
            if (str_i[j] != str_i[len-j-1]) {
                flag = false;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
MOD = 998244353
N,S= map(int,input().split())
A = list(map(int,input().split()))

def dpinit(ps, val=0):
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [res[:] for k in [0]*i]
    return res

dp = dpinit((N+1,S+1))

dp[0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        dp[i+1][j] += dp[i][j]*2
        dp[i+1][j] %= MOD
        if j+a <= S:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= MOD
        
print(dp[N][S]%MOD)



Measured memory_bytes: 134908
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50 == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 8944
N,M=map(int,input().split())
graph=[[] for _ in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

s=[-1]*N
d=[-1]*N
next=[[] for _ in range(N)]
next[0].append(0)

s[0]=0
d[0]=0


for i in range(N):
  finish=1
  for j in next[i]:
    if d[j]==i:
      for saki in graph[j]:
        if d[saki]==-1:
          d[saki]=i+1
          s[saki]=j
          next[i+1].append(saki)
          finish=0
  if finish==1:
    break

print("Yes")
for i in range(N-1):
  print(s[i+1]+1)

Measured memory_bytes: 103448
/* author   : mpily :-()
title : Competing.cpp
time :Wed May  6 19:26:13 2020

*/
#include<bits/stdc++.h>
using namespace std;
void reset(vector<vector<int>>&arr){
	for(auto & a : arr){
		for(auto & b : a){
			b = INT_MAX;
		}
	}
}
void dijkstra(vector<vector<int>>&dist, vector<vector<bool>>&visited,const vector<string>&mp){
	//find closest
	//update all connected to it
	bool d = true;
	int n = dist.size();
	int m = dist[0].size();
	while(d){
		d = false;
		int row = 0; int col = 0;int mndist = INT_MAX;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				if(!visited[i][j] && dist[i][j] < mndist){
					mndist = dist[i][j];
					row = i;
					col = j;
					d = true;
				}
				
			}
		}
		if(!d){
			break;
		}
		visited[row][col] = true;
		for(int i = max(0,row-1); i < min(n,row+2); ++i){
			for(int j = max(0,col-1); j < min(m,col+2); ++j){
				if(i == row-1 && j ==col-1){
					continue;
				}
				if(i == row-1 && j== col+1)continue; if(i == row+1 && j == col+1)continue; if(i == row+1 && j ==col-1)continue;
				if(!visited[i][j] && mp[i][j] != '#' && dist[i][j] > dist[row][col]+1){
					dist[i][j] = dist[row][col]+1;
				}
			}
		}
	}
}
int main(){
	int h,w;
	cin >> h >> w;
	vector<string>mp(h);
	for(int i = 0 ; i < h ; ++i){
		cin >> mp[i];
	}
	vector<vector<int>>dij(h,vector<int>(w,INT_MAX));
	int ans = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(mp[i][j] == '.'){
				reset(dij);
				dij[i][j] = 0;
				vector<vector<bool>>visited(h,vector<bool>(w));
				dijkstra(dij,visited,mp);
				for(auto a : dij){
					for(auto b : a){
						if(b != INT_MAX){
							ans = max(ans,b);
						}
					}
				}
			}
		}
	}
	cout << ans <<"\n";
	return 0;
}

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

int a[200005];
int b[200005];

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
  sort(b, b + n);
  reverse(b, b + n);
  for (int i = 0; i < n; i++)
    cout << (a[i] != b[0] ? b[0] : b[1]) << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,k,d;
	cin>>n>>k;
	ll arr[n+1]={0};
	for(ll i=1;i<=k;i++)
	{
		cin>>d;
		ll a[d];
		for(ll i=1;i<=d;i++)
		{
			cin>>a[i];
			arr[a[i]]++;
		}
	}
	
	ll count = 0;
	for(ll i=1;i<=n;i++)
	{
		if(arr[i]==0)
		count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3624
n = int(raw_input())
a = [int(x) for x in raw_input().split()]


def f(k):
    s = 0
    for ai in a:
        s += max(0, (ai - (n - 1 - k) + n) // (n + 1))
    return s <= k


lb = 0
ub = 500000000000000001

while lb + 1 < ub:
    mid = (lb + ub) // 2
    if f(mid):
        ub = mid
    else:
        lb = mid

m = lb + 1
i = m - 1
while i >= m - 50:
    if f(i):
        m = i
    i -= 1

print m


Measured memory_bytes: 2568
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define ll unsigned long long int
#define pb push_back

ll gcd(ll c, ll d){ // 最大公約数を求めるプログラム
    ll mx = max(c,d);
    ll mi = min(c,d);
    ll tmp=0;
    while(mi > 0){
        tmp = mx % mi;
        if(tmp==0){
            return mi;
        } else{
            mx = mi;
            mi = tmp;
        }
    }
    return 1;
} 

ll lcm(ll c, ll d){ // 最小公倍数を求めるプログラム
    ll mx = max(c,d);
    ll mi = min(c,d);
    ll tmp=0;
    while(mi > 0){
        tmp = mx % mi;
        if(tmp==0){
            return (c*d)/mi;
        } else{
            mx = mi;
            mi = tmp;
        }
    }
    return c*d;
} 

int main() {
  ll A, B;
  cin >> A >> B;
  ll N = gcd(A, B);
  vector<ll> c;

  // AとBの公約数を配列にして入れていく
  // TLEはこれで改善した
  for (int i = 1; i < int(pow(N, 0.5)) + 1; i++){
    if (A % i == 0 && B % i == 0){
      c.push_back(i);
      if (i != N / i){
        c.push_back(N/i);
      }      
    }
  }
  sort(c.begin(), c.end()); // 小さいものから見ていった方が増えるような気がする
  
  // 全探索する
  ll max_num = 1, cnt;
  ll tmp;
  rep(i, c.size()){ // この値が解に入っていると固定する
    tmp = c[i];
    cnt = 1; // 固定の分の値
    rep(j, c.size()){
      if (i==j) continue;
      if (gcd(tmp, c[j]) == 1){ // 互いに素の時
        cnt++;
        // if (lcm(tmp, c[j]) > tmp)
        tmp = lcm(tmp, c[j]); // 最小公倍数を出していく
        
      }
      // cout << cnt<< " "<< tmp << " " << i << " " << j << endl;
    }
    max_num = max(max_num, cnt);
  }
  
  cout << max_num << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  vector<int> data(N);
  for (int i = 0; i < N; i++)
  {
    cin>>data[i];
  }

  vector<int> vec(N);
  int index = 0;

    int A = N;
    while(A>0)
    {
      vec[index] = A-1;
      A -= 2;
      index++;
    }
    A = (N)%2 + 1;
      while(A<=N)
    {
      vec[index] = A-1;
      A  += 2;
      index++;
    }
        // DEBUG(vec);
    for (int i = 0; i < N; i++)
    {
      vec[i] = data[vec[i]];
    }


    for (int i = 0; i < N; i++)
    {
      if(i != 0)cout<<" ";
      cout<<vec[i];
    }
    cout<<endl;
    
    
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 5376
N,A,B,C = map(int,input().split())



def s3(abc_dict):
    ans = []
    for _ in range(N):
        xy = input()
        x = xy[0] 
        y = xy[1]
        if abc_dict[x]==0 and abc_dict[y]==0:
            return False, []
        elif abc_dict[x]>=abc_dict[y]:
            abc_dict[x] -= 1
            abc_dict[y] += 1
            ans.append(y)
        else:
            abc_dict[y] -= 1
            abc_dict[x] += 1
            ans.append(x)
    return True, ans

def s2(abc_dict):

    ans = []
    flag = True
    q_list = []
    for _ in range(N):
        q_list.append(input())

    for i in range(N):
        xy = q_list[i]
        x = xy[0]
        y = xy[1]

        if (abc_dict[x]>=1 and abc_dict[y]==0):
            abc_dict[x]-=1
            abc_dict[y]+=1
            ans.append(y)
        elif (abc_dict[y]>=1 and abc_dict[x]==0):
            abc_dict[y]-=1
            abc_dict[x]+=1
            ans.append(x)
        elif  (abc_dict[x]==1 and abc_dict[y]==1):
            if i==N-1:
                ans.append(x)
            else:
                next_xy = q_list[i+1]
                if xy==next_xy: # 次も同じなのでどちらでもいい
                    abc_dict[x]+=1
                    abc_dict[y]-=1
                    ans.append(x)
                elif (x in next_xy):
                    abc_dict[x]+=1
                    abc_dict[y]-=1
                    ans.append(x)
                else: # 次にyが含まれる
                    abc_dict[y]+=1
                    abc_dict[x]-=1
                    ans.append(y)
        else:
            return False, []
    return True,ans

def s1(abc_dict):
    
    ans = []
    flag = True
    for _ in range(N):
        xy = input()
        x = xy[0] 
        y = xy[1]
        if abc_dict[x]==1:
            abc_dict[x]-=1
            abc_dict[y]+=1
            ans.append(y)
        elif abc_dict[y]==1:
            abc_dict[y]-=1
            abc_dict[x]+=1
            ans.append(x)
        else:
            flag = False
            return flag,[]
    return flag, ans
    
def s0(abc_dict):
    return False, []

abc_dict = {"A":A,"B":B,"C":C}
sumABC = A+B+C
if sumABC>=3:
    flag, ans = s3(abc_dict)
elif sumABC==2:
    flag, ans = s2(abc_dict)
elif sumABC==1:
    flag, ans = s1(abc_dict)
elif sumABC==0:
    flag, ans = False, []

if flag:
    print('Yes')
    for i in range(N):
        print(ans[i])
else:
    print("No")  

Measured memory_bytes: 17040
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0;
    int blue = 0;
    rep(i, n) {
        if ( s[i] == 'R' ) ++red;
        else               ++blue;
    }
    if ( red > blue ) cout << "Yes" << endl;
    else              cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextInt();

		if(n%2==0) {
			System.out.print(n);
		}
		else {
			System.out.print(n*2);
		}
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n, k, ans=0;
int f[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		f[i%k]++;
	for(int i=0;i<=k-1;i++)
	{
		int arem=i;
		int brem=(k-i);
		int crem=(k-i);
		brem%=k;
		crem%=k;
		if((brem+crem)%k!=0)
			continue;
		ans+=f[arem]*f[brem]*f[crem];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int count = 0;
    for ( int i = 0; i < n; i++) {
        cin >> h.at(i);
    }
    int maxint;
    for (int i = 0; i < n; i++) {
        maxint = 0;
        for (int j = 0; j <= i; j++) {
            maxint = max(maxint, h.at(j));
        }
        if (maxint <= h.at(i)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))

gl=[0]*n
gl[0]=a[0]
gr=[0]*n
gr[-1]=a[-1]
for i in range(1,n):
    gl[i]=gcd(gl[i-1],a[i])
    gr[-i-1]=gcd(gr[-i],a[-i-1])
ans=max(gr[1],gl[-2])
for i in range(1,n-1):
    ans=max(ans,gcd(gl[i-1],gr[i+1]))
print(ans)


Measured memory_bytes: 89580
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i,h) cin >> grid[i];
  vector dy = {0,1,0,-1};
  vector dx = {1,0,-1,0};
  ll ans = 0;

  rep(k,h) rep(j,w) {
    if (grid[k][j] == '#') continue;
    queue<P> q;
    Graph d(h,V(w,-1));
    ll tmp = 0;
    ll sy = k, sx = j;
    d[sy][sx] = 0;
    q.push(make_pair(sy,sx));
    while (!q.empty()) {
      ll y = q.front().first; ll x = q.front().second;
      q.pop();
      rep(i,4) {
        ll ny = y + dy[i]; ll nx = x + dx[i];
        if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
        if (grid[ny][nx] == '.' && d[ny][nx] == -1) {
          d[ny][nx] = d[y][x] + 1;
          tmp = max(tmp,d[ny][nx]);
          q.push(make_pair(ny,nx));
        }
      }
    }
    ans = max(ans,tmp);
  }

  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import math
import sys
from collections import defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**60


def gen(a, b, num):
    import random
    result = set()
    while 1:
        while 1:
            v = random.randint(a, b)//2*2+1
            if v not in result:
                break
        for x in range(3, int(math.sqrt(v))+1, 2):
            if v % x == 0:
                break
        else:
            result.add(v)
            if len(result) == num:
                break
    return result


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod-2, mod)

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            num = ord(s[i])
            tmp = (tmp*base + num) % mod
            h[i+1] = tmp

        self.pw = pw = [1]*(len(s)+1)
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


class RRH():
    def __init__(self, s, rand=False, num=5):
        if rand:
            bases = gen(2, 10**3, num)
        else:
            bases = {293, 389, 167}

        MOD = 10**9+7
        self.rhs = [RH(s, b, MOD) for b in bases]

    def calc(self, l, r):
        return tuple(rh.calc(l, r) for rh in self.rhs)



class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)
        self.__rank = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x == y:
            return False

        if self.__rank[x] < self.__rank[y]:
            self.__table[x] = y
            self.__size[y] += self.__size[x]
        else:
            self.__table[y] = x
            self.__size[x] += self.__size[y]
            if self.__rank[x] == self.__rank[y]:
                self.__rank[x] += 1
        return True

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g



def slv(S, T):
    lt = len(T)
    ls = len(S)
    SS = S * (-(-lt // ls) * 2 + 1)
    srh = RRH(SS)
    th = RRH(T).calc(0, len(T))

    ok = []
    for i in range(ls+lt):
        if srh.calc(i, i+lt) == th:
            ok.append(i)
    ok = set(ok)
    uf = UnionFind()
    for i in ok:
        if (i + lt) in ok:
            if not uf.union(i, (i+lt) % ls):
                return -1
    ans = 0
    for i in ok:
        ans = max(ans, uf.size(i))
    return ans



def main():
    S = input()
    T = input()
    print(slv(S, T))



if __name__ == '__main__':
    main()


Measured memory_bytes: 323384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<usize>();

    let mut counter: Vec<usize> = vec![0;n];

    for p in &a{
        counter[*p-1] += 1;
    }

    for count in &counter{
        println!("{}", *count);
    }
}


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

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;

    long A[N] = {0};

    for(int i=0; i < Q; ++i){
        int a; cin >> a;
        --a;
        A[a]++;
    }

    for(int i=0; i<N; ++i){
        A[i] += K-Q;
        if(A[i] <= 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }


}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,m,k;
int mas[30];

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char x;
            cin>>x;
            mas[x - 'a']++;
        }
    }
    int S = n * m;
    if(n % 2) S -= m;
    if(m % 2) S -= n;
    if(n % 2 && m % 2) S++;
    S /= 4;
    for(int i=0;i<26;i++){
        while(S > 0 && mas[i] >= 4){
            S--;
            mas[i] -= 4;
        }
    }
    if(S != 0){
        cout<<"No"<<endl;
        return 0;
    }
    int sum = 0;
    for(int i=0;i<26;i++) sum += mas[i] % 2;
    if(sum > 1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


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

long long N;
vector<long long>v;
int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());

	double cur = v[0];
	for(long long i = 1; i < v.size(); i++){
		cur = (cur + v[i])/2;
	}
	cout << cur << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a,b;
  cin >> a >> b;
  a+=b;
  a%=24;
  pr(a);
}

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


Measured memory_bytes: 256
using System;
using System.Linq;
class program{
  static void Main(){
    var nk = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    var log = Array.ConvertAll(Console.ReadLine().Split(' '),double.Parse);
    int mxlg = (int)log.Max(),mnlg = mxlg/(1+nk[1]),mid;
    uint sum;
    while(mnlg < mxlg){
      sum = 0;
      mid = (mnlg+mxlg)/2;
      for(int i = 0;i<nk[0];i++){
        sum += (uint)Math.Ceiling(log[i]/mid)-1;
      }
      if(sum <= nk[1]){
        mxlg = mid;
      }else{
        mnlg = mid+1;
      }
    }
    Console.Write(mnlg);
  }
}

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

Int ABCs(string S) {
  if (S.size() < 3) return 0;
  else {
    Int ans = 0;
    rep(i, S.size() - 2) {
      if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
    return ans;
  }
}

int main(){ 
  
  int N;
  string S;
  cin >> N >> S;
  
  cout << ABCs(S) << endl;

}


Measured memory_bytes: 256
import queue
N = int(input())
Q = [i for i in range(1, 10)]
q = queue.Queue()
for i in Q:
  q.put(i)
count = 0
while count < N:
  n = q.get()
  d = n%10
  for i in range(max([d-1, 0]), min([d+2 , 10])):
    q.put(n*10+i)
  count += 1
print(n)

Measured memory_bytes: 13040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  ll N,Ga,Sa,Ba,Gb,Sb,Bb;
  cin>>N>>Ga>>Sa>>Ba>>Gb>>Sb>>Bb;
  ll ans=N;
  if(Ga<=Gb&&Sa<=Sb&&Ba<=Bb){
    rep(i,N/Ga+1) rep(j,(N-i*Ga)/Sa+1){
      ll tmp=i*Gb+j*Sb+(N-i*Ga-j*Sa)/Ba*Bb+(N-i*Ga-j*Sa)%Ba;
      if(tmp>ans) ans=tmp;
    }
  }else if(Ga>=Gb&&Sa<=Sb&&Ba<=Bb){
    rep(i,N/Sa+1){
      ll tmp=i*Sb+(N-i*Sa)/Ba*Bb+(N-i*Sa)%Ba;
      if(tmp>ans) ans=tmp;
    }
    ans=ans/Gb*Ga+ans%Gb;
  }else if(Sa>=Sb&&Ba<=Bb&&Ga<=Gb){
    rep(i,N/Ba+1){
      ll tmp=i*Bb+(N-i*Ba)/Ga*Gb+(N-i*Ba)%Ga;
      if(tmp>ans) ans=tmp;
    }
    ans=ans/Sb*Sa+ans%Sb;
  }else if(Ba>=Bb&&Ga<=Gb&&Sa<=Sb){
    rep(i,N/Ga+1){
      ll tmp=i*Gb+(N-i*Ga)/Sa*Sb+(N-i*Ga)%Sa;
      if(tmp>ans) ans=tmp;
    }
    ans=ans/Bb*Ba+ans%Bb;
  }else if(Ga<=Gb&&Sa>=Sb&&Ba>=Bb){
    N=N/Ga*Gb+N%Ga;
    rep(i,N/Sb+1){
      ll tmp=i*Sa+(N-i*Sb)/Bb*Ba+(N-i*Sb)%Bb;
      if(tmp>ans) ans=tmp;
    }
  }else if(Sa<=Sb&&Ba>=Bb&&Ga>=Gb){
    N=N/Sa*Sb+N%Sa;
    rep(i,N/Bb+1){
      ll tmp=i*Ba+(N-i*Bb)/Gb*Ga+(N-i*Bb)%Gb;
      if(tmp>ans) ans=tmp;
    }
  }else if(Ba<=Bb&&Ga>=Gb&&Sa>=Sb){
    N=N/Ba*Bb+N%Ba;
    rep(i,N/Gb+1){
      ll tmp=i*Ga+(N-i*Gb)/Sb*Sa+(N-i*Gb)%Sb;
      if(tmp>ans) ans=tmp;
    }
  }else if(Ga>=Gb&&Sa>=Sb&&Ba>=Bb){
    rep(i,N/Gb+1) rep(j,(N-i*Gb)/Sb+1){
      ll tmp=i*Ga+j*Sa+(N-i*Gb-j*Sb)/Bb*Ba+(N-i*Gb-j*Sb)%Bb;
      if(tmp>ans) ans=tmp;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Map<String,Integer> sales = new HashMap<>();
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		for(int i = 0; i < a;i++){
			int x= sc.nextInt();
			String key = sc.next();
			if(x ==0){
				sales.put(key,sc.nextInt());
			}else{
				System.out.println(sales.get(key));

			}
		}
	}
}



Measured memory_bytes: 194496
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	vector<int> v(4);
	rep(i, 4) v[i] = S[i] - '0';

	rep(i, (1<<3)) {
		int tmp = v[0];
		vector<char> op(3);
		rep(j, 3) {
			if (i & (1 << j)) {
				op[j] = '+', tmp += v[j+1];
			} else {
				op[j] = '-', tmp -= v[j+1];
			}
		}
		if (tmp == 7) {
			rep(k, 3) cout << v[k] << op[k];
			cout << v[3] << "=7" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a ,b, i;

for(int i=1;i<=3000 ;i++){
    cin >> a >> b;
if (a>b)
{
   a = a+b;
   b = a-b;
   a = a-b;
}
   if (a==0 && b==0)
   break ;
   else
  
   cout << a << " " << b<< endl;
}
}


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


using node = tuple<lli, lli, lli, lli, int>;
lli x[300], y[300];
/*struct node {
    lli x, y, diffx, diffy;
    int type;  //0->normal 1-> y=const 2-> x=const
    
};
*/
void show(node x)
{
    return;
    cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << " " << get<3>(x) << " " << get<4>(x) << endl;
}
bool ison(node a, lli x, lli y)
{
    int type = get<4>(a);
    if (type != 0) {
        if (type == 1) {
            return y == get<1>(a);
        } else {
            return x == get<0>(a);
        }
    }
    x -= get<0>(a);
    y -= get<1>(a);
    return x * get<3>(a) == y * get<2>(a);
}
node get(int l, int r)
{
    if (x[l] == x[r]) {
        return make_tuple(x[l], 0, 0, 0, 2);
    } else if (y[l] == y[r]) {
        return make_tuple(0, y[l], 0, 0, 1);
    } else {
        lli diffx = x[r] - x[l];
        lli diffy = y[r] - y[l];
        lli hoge = __gcd(diffx, diffy);
        diffx /= hoge;
        diffy /= hoge;
        if (diffx < 0) {
            diffx *= -1;
            diffy *= -1;
        }
        lli nx = x[r] % diffx;
        lli ny = y[r] - (x[r] / diffx) * diffy;
        return make_tuple(nx, ny, diffx, diffy, 0);
    }
}
lli powm(lli a, lli p, lli mod)
{
    lli ans = 1;
    while (p > 0) {
        if (p & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        p >>= 1;
    }
    return ans % mod;
}
lli M = 998244353;

void add(lli& l, lli r)
{
    (l += (r + M)) %= M;
}
int main()
{
    int n;
    cin >> n;
    set<node> s;
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n) rep(j, i)
    {
        auto g = get(i, j);
        show(g);
        s.insert(g);
    }
    lli ans = powm(2, n, M);
    add(ans, -n - 1);
    for (auto t : s) {
        int k = 0;
        rep(i, n)
        {
            if (ison(t, x[i], y[i])) {
                k++;
            }
        }
        show(t);
        //cout << "#" << k << endl;

        add(ans, -powm(2, k, M) + k + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#define inf 100000000
using namespace std;
int main(void){
    int dp[4096][2];//dp[鍵][店]
    for(int i=0;i<(1<<12);i++) for(int j=0;j<2;j++) dp[i][j] = inf;
    dp[0][0] = 0;
    int n,m; cin >> n >> m;
    for(int j=0;j<m;j++){
        int a,b; cin >> a >> b;
        int c=0;
        for(int i=0;i<b;i++){
            int tmp; cin >> tmp; tmp--;
            c ^= (1<<tmp);
        }
        for(int i=0;i<(1<<n);i++){
            if(dp[i][j&1]!=inf){
                //買わない
                dp[i][!(j&1)] = min(dp[i][!(j&1)],dp[i][j&1]);
                //買う
                dp[i|c][!(j&1)] = min(dp[i|c][!(j&1)],dp[i][j&1]+a);
            }
        }
        
        /*for(int i=0;i<(1<<n);i++){
            cout << dp[i][j] << endl;
        }puts("");*/
        
    }
    if(dp[(1<<n)-1][(m&1)]!=inf) cout << dp[(1<<n)-1][(m&1)] << endl;
    else cout << -1 << endl;
}


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

long long int ans = 0;
int n, k;

void solve(){
  cin >> n >> k;
  if(k % 2 == 1){
    ans = pow(n / k, 3);
  }
  else{
    int a = 0, b = 0;
    for(int i = 1; i <= n; i++){
      if(i % k == 0) a++;
      else if(i % k == k / 2) b++;
    }
    ans = pow(a, 3) + pow(b, 3);
  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


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

int main(){
    int  a, b, c;
    cin >> a >> b >> c;
    int sum = 0;
    sum += a;
    sum += b;
    sum += c;
    if(sum < 22){
        cout << "win";
        return 0;
    }
    cout << "bust";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int N;
	string s;
	int ans = 0;
	int num = 0;

	cin >> N ;
	cin >> s;
	
	for (int i = 0; i < N; i++) {
		if (s[i] == '(') {
			if (num < 0) {
				ans -= num;
				num = 0;
			}
			num++;
		}
		if (s[i] == ')') {
			num--;
		}
	}

	if (num < 0) {
		ans -= num;
		num = 0;
	}

	for (int i = 0; i < ans;i++) {
		s.insert(s.begin(), '(');
	}
	for (int i = 0; i < num; i++) {
		s.push_back(')');
	}
	cout << s << endl;
	

	return 0;
}

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

void solve() {
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int m = A[A.size() - 1];
    vector<bool> dp(m+1, true);
    for (int i = 0; i < N; ++i) {
        int a = A[i];
        if (dp[a]) {
            for (int j = a + a; j <= m; j += a) {
                dp[j] = false;
            }
        }
        if (0<i && a == A[i-1]) dp[a] = false;
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (dp[A[i]]) ans++;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 4060