akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-6
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 3e5 + 10;
const ll mod = 1e9 + 7;
vector<ll> a;
ll n;
ll f(ll val){
    ll ret= 0;
    _rep(i, 1, n){
        ret  += abs(val - a[i]) * abs(val - a[i]);
    }
    return ret;
}
signed main()
{
    cin >> n;
    a.resize(n + 1);
    ll l = 0, r = oo;
    db sum = 0;
    _rep(i, 1, n){
        cin >> a[i];
        l = min(l, a[i]);
        r = max(r, a[i]);
        sum += a[i];
    }
    sum /= n;
    cout << min(f(ceil(sum)) , f(floor(sum))) << endl;
    // while(r - l >= 1 ){
    //     ll mid = l + r + 1 >> 1;
    //     if(f(mid + 1) > f(mid - 1))r = mid-1;
    //     else l = mid;
    // }
    // cout << f(r) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
 
#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 1e11
const int MAX_SPEED = 30;

struct P {
    int city, pcity;
    int speed;
    float time;

    bool operator >(const P& p) const {
        return time > p.time;
    }
};

struct edge{
    int to, dist, limit;
};

typedef vector<float> vf;
typedef vector<vf> vvf;
typedef vector<vvf> vvvf;

int main() {
    int city_n, road_n, start, goal;

    while(cin >> city_n >> road_n, city_n | road_n){
        cin >> start >> goal;

        vector<vector<edge>> E(city_n + 1);

        REP(i, road_n){
            int x, y, d, l;
            cin >> x >> y >> d >> l;
            E[x].push_back({y, d, l});
            E[y].push_back({x, d, l});
        }
        vvvf G(city_n + 1, vvf(city_n + 1, vf(MAX_SPEED + 1, INF)));

        priority_queue<P, vector<P>, greater<P>> que;
        que.push({start, start, 0, 0.0});

        float res = -1;
        while(!que.empty()){
            P p = que.top(); que.pop();

            if(p.city == goal && p.speed == 1){
                res = p.time;
                break;
            }

            for(auto e : E[p.city]) {
                if(e.to == p.pcity) continue;
                FOR(d, -1, 1 + 1){
                    int next_speed = p.speed + d;
                    if (next_speed == 0) continue;
                    float next_time = p.time + (float)e.dist / next_speed;
                    if (0 < next_speed && next_speed <= e.limit &&
                        G[e.to][p.city][next_speed] > next_time) {
                        G[e.to][p.city][next_speed] = next_time;
                        que.push({e.to, p.city, next_speed, next_time});
                    }
                }
            }
        }

        if(res == -1)
            cout << "unreachable" << endl;
        else
            printf("%f\n", res);
    }

    return 0;
}

Measured memory_bytes: 1780
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
check = 0
for i in range(n):
    d = 0
    A = list(map(int,input().split()))
    for j in range(m):
        d += b[j]*A[j]
    if d+c > 0:
        check += 1

print(check)


Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <typeinfo>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;



int main(){
    char z;
    double a,b,c;
    while(cin>>a>>z>>b>>z>>c){
        if(b/(c*c)>=25)cout<<a<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  string s;
  while (cin >> s) {
    ll ans = 0;
    int cur = 0;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] == 'B') {
        cur++;
      } else {
        ans += cur;
      }
    }
    printf("%lld\n", ans);
  }

  return 0;
}


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

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

  string X;
  cin >> X;

  lint P = count(X.begin(), X.end(), '1');
  lint pp = P + 1;
  lint pn = P - 1;

  lint XP = 0, XN = 0;
  string RX = X;
  reverse(RX.begin(), RX.end());
  lint powp = 1;
  lint pown = 1;
  for(lint i=0; i<N; i++) {
    XP += (RX[i] - '0') * powp;
    XP %= pp;
    powp = powp * 2 % pp;

    if(pn == 0) continue;
    XN += (RX[i] - '0') * pown;
    XN %= pn;
    pown = pown * 2 % pn;
  }

  vector<lint> ans;
  powp = pown = 1;
  for(lint i=0; i<N; i++) {
    lint counter = 1;
    lint xi;
    if(RX[i] == '0') {
      xi = (XP+powp) % pp;
    } else {
      if(pn == 0) {
        ans.push_back(0);
        continue;
      }
      xi = (XN-pown) % pn;
      if(xi < 0) xi += pn;
    }
    while(xi) {
      xi = xi % __builtin_popcount(xi);
      counter++;
    }
    ans.push_back(counter);
    powp = powp * 2 % pp;
    if(pn) pown = pown * 2 % pn;
  }
  reverse(ans.begin(), ans.end());

  for(auto e : ans) {
    cout << e << endl;
  }
}

Measured memory_bytes: 5760
N = int(input())
v = sorted(map(float, input().split()), reverse=True)

for i in range(N - 1):
    v[i] = v[i] / (2.0 ** (i + 1))

v[N - 1] = v[N - 1] / (2.0 ** (N - 1))

print(sum(v))


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int inf = 1<<30;
const LL maxn = 1e5+10;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n*a) << endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main (){

	long long int berapaKali;	
	scanf("%lld", &berapaKali);
	long long int a1[berapaKali];
	long long int a2 = 1;
	long long int max = 1000000000000000000;
	long long int hasil ;
	
	for(int j=0;j<berapaKali;j++){
		scanf("%lld", &a1[j]);
	}
	
	for(int h=0;h<berapaKali;h++){
	
		if(a1[h]==0){
			printf("0\n");
			return 0;
		}
	}
	for(int i=0;i<berapaKali;i++){
		if(a1[i]<=max/a2){	
		a2*= a1[i];	
		}else{
		printf("-1\n");
		return 0;
		}
	}
	
	printf("%lld\n", a2);

	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define MOD 1000000007
#define INF (1LL)<<50;

signed main(){

	lli n;
	cin>>n;
	lli k;
	cin>>k;
	vector<lli> v(n);
	REP(i,0,n)cin>>v[i];

	lli ans=-INF;

	/*まず左側でどこまでとるか*/
	for(lli i=0;i<n;i++){

		vector<lli> p; /*マイナスの宝石入れ*/
		lli left=i;
		lli sum=0;

		/*左端から宝石をとっていく*/
		for(lli ii=0;ii<left;ii++){
			sum += v[ii];
			if(v[ii]<0)p.push_back(v[ii]);
		}

		/*次に右端についてどこまで宝石をとるか*/
		for(lli j=0;j<=n;j++){

			/*操作回数が超えていたらやめる*/
			if(i+j>k)continue;

			/*右端からどこまでとるかについての情報を持つ*/
			/*すでにとっている宝石や、左端まで行ってしまう場合はやめる*/
			lli right=n-j;
			if(left>right)continue;

			/*左端で取った宝石の情報を引き継ぐ*/
			vector<lli> pp;
			lli nextSum=sum;
			REP(g,0,p.size())pp.push_back(p[g]);

			/*右端から宝石をとっていく*/
			for(lli jj=n-1;jj>=right;jj--){
				nextSum+= v[jj];
				if(v[jj]<0)pp.push_back(v[jj]);
			}

			/*マイナスの宝石入れのソートを行う、これで上からマイナスがでかい宝石を捨てれるようになる*/
			sort(pp.begin(),pp.end());

			/*残り操作回数*/
			lli allowCnt = k-(i+j);

			for(lli g=0;(g<allowCnt && g<pp.size());g++){
				nextSum -= pp[g];
			}
			ans = max(ans,nextSum);
		}
	}

	cout<<ans<<endl;
	return 0;
}

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

int main() {
    ll N, X, M; cin >> N >> X >> M;
    map<ll, pair<ll, ll>> m;
    // vector<ll> v(M, -1);  // v[a(i)] = a(i+1)
    // a0 = X
    // a1 = f(a0^2, M) = a0 * a0 % M
    // a2 = f(a1^2, M) = a1 * a1 % M
    ll a = X;
    ll i = 0;
    while(m.count(a) == 0) {
        m[a] = {(a % M) * (a % M) % M, i};
        a = m[a].first;
        ++i;
    }
    ll cycle_start = a;
    ll cycle_size = i - m.at(a).second;
    ll cycle_sum = 0;
    while(true) {
        cycle_sum += a;
        a = m[a].first;
        if (a == cycle_start) break;
    }

    // for (const auto &[k, v]: m) {
    //     cout << k << "\t" << v.first << "\t" << v.second << endl;
    // }
    // cout << cycle_start << endl;
    // cout << cycle_size << endl;
    // cout << cycle_sum << endl;

    ll ans = 0;
    a = X;
    while(a != cycle_start && N > 0) {
        ans += a;
        a = m[a].first;
        --N;
    }
    // std::cout << "p1 " << ans << endl;
    ans += (N / cycle_size) * cycle_sum;
    N = N % cycle_size;
    // std::cout << "p2 " << ans << endl;
    while(N > 0) {
        ans += a;
        a = m[a].first;
        --N;
    }
    // std::cout << "p3 " << ans << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,m,q,ans=0;
    cin >> n >> m >> q;
    int a[q],b[q],c[q],d[q];

    rep(i,q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    for(int i=0;i < (1<<(n+m-1));i++)
    {
        vector<int> num(0);
        rep(j,n+m-1)
        {
            if(1<<j & i) num.push_back(j);
        }
        if(num.size() != n)
        {
            
            continue;
        }else
        {
            int sum=0;
            rep(i,q)
            {
            if(num[b[i]-1]-num[a[i]-1]+a[i]-b[i]==c[i])
            {
                sum += d[i];
            }
            }
            ans = max(ans,sum);
            
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans;
  string str;
  cin>>n>>str;
  ans=0;
  for(int i=0; i<n-2; i++){
    if(str.at(i)=='A'){
      if(str.at(i+1)=='B'){
        if(str.at(i+2)=='C'){
          ans=ans+1;
        }
      }
    }
  }
  cout<<ans;
}

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

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

vector<int> A(3);

int main(){
	//cin >> A >> B >> C
	int N;
	rep (i, 3){
		cin >> A.at(i);
	}

	sort(A.begin(),A.end());
	if (A.at(0) == A.at(1) && A.at(1) == A.at(2)){
		cout << "No" << endl;

	}
	else if (A.at(0) == A.at(1) || A.at(1) == A.at(2)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
double dp[3005][3005];
double p[3005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>p[i];
	
	dp[0][0]=1.00,dp[1][1]=p[1];
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
	}
	
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++){
			dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
		}
	}
	
	double ans=0;
	for(int i=n/2+1;i<=n;i++){
		ans+=dp[n][i];
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 49848
import java.util.Scanner;
import java.util.Arrays;

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

int i=0;
for(i=0;i<n;i++){
    a[i]=scan.nextInt();
}

int sum=0;
for(i=0;i<n;i++){
    if(a[i]%2==1&&i%2==0){
        sum=sum+1;
    }
}

System.out.println(sum);


}
}

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

int main(){
    int second;
    scanf("%d", &second);
    int h, m, s;
    h = second / (3600);
    m = (second - h * 3600) / 60;
    s = second % 60;
    
    printf("%d%s%d%s%d\n", h, ":", m, ":", s);
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  int a = 0,b = 0;
  REP(i,n){
    string s,t;
    cin >> s >> t;
    if(s>t) a += 3;
    else if(s<t) b += 3;
    else a++,b++;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >>A>>B>>C;
  int L=A*B;
  
  if (L>=C) {
    cout<<C<<endl;
  }
  else {
    cout<<L<<endl;
  }
  }

Measured memory_bytes: 3628
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  string s; cin >> s;
  int n = stoi(s);
  int d = 0;
  for (auto c: s) d += c - '0';
  if (n%d==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3576
// segment tree (abstract version)

#include <bits/stdc++.h>

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

using namespace std;

template<class M>
class segment_tree{
	int sz;
	vector<M> seg;
public:
	segment_tree(){}
	segment_tree(int n){ build(n); }
	segment_tree(const vector<M>& a){ build(a); }
	void build(int n){
		for(sz=1;sz<n;sz<<=1);
		seg.assign(2*sz,M());
	}
	void build(const vector<M>& a){
		int n=a.size();
		build(n);
		rep(i,n) seg[sz+i]=a[i];
		for(int i=sz-1;i>0;i--){
			seg[i]=seg[2*i]*seg[2*i+1];
		}
	}
	template<class N,class F>
	N query(int l,int r,const F& f){
		N lcum=N(),rcum=N();
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*f(seg[a++]);
			if(b&1) rcum=f(seg[--b])*rcum;
		}
		return lcum*rcum;
	}
};

template<class T>
class sequence_monoid{
	vector<T> a;
public:
	sequence_monoid(){}
	sequence_monoid(const T& val):a(1,val){}
	sequence_monoid(const vector<T>& x):a(x){
		sort(a.begin(),a.end());
	}
	sequence_monoid operator*(const sequence_monoid& x)const{
		vector<T> res;
		merge(a.begin(),a.end(),x.a.begin(),x.a.end(),back_inserter(res));
		return res;
	}
	int lower_bound(const T& val)const{
		return std::lower_bound(a.begin(),a.end(),val)-a.begin();
	}
};

template<class T>
class add_monoid{
	T a;
public:
	add_monoid():a(){}
	add_monoid(const T& val):a(val){}
	add_monoid operator*(const add_monoid& x)const{
		return a+x.a;
	}
	T& get(){ return a; }
	const T& get()const{ return a; }
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<sequence_monoid<int>> x(n);
	vector<int> pre(n,-1);
	rep(i,n){
		x[i]=pre[a[i]];
		pre[a[i]]=i;
	}

	segment_tree<sequence_monoid<int>> S(x);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		auto ans=S.query<add_monoid<int>>(l,r,[&](const sequence_monoid<int>& x)->add_monoid<int>{
			return x.lower_bound(l);
		});
		printf("%d\n",ans.get());
	}

	return 0;
}


Measured memory_bytes: 125664
#include <stdio.h>

int main() {

  int a,b;
  char op;

  scanf("%d %c %d",&a,&op,&b);

  while(op != '?') {
    if(op == '+') {
      printf("%d\n",a+b);
    } else if(op == '-') {
      printf("%d\n",a-b);
    } else if (op == '*'){ 
      printf("%d\n",a*b);
    } else if(op == '/') {
      printf("%d\n",a/b);
    } 
    scanf("%d %c %d",&a ,&op, &b);

  }

  return 0;

}

Measured memory_bytes: 600
s=input()
t=input()
ans="UNRESTORABLE"
for i in range(len(s)-len(t),-1,-1):
    ss=s[i:i+len(t)]
    flag=0
    for j in range(len(t)):
        if ss[j]=="?":
            ss=ss[0:j]+t[j]+ss[j+1:]
        if ss[j]!=t[j]:
            flag=1
            break
    if flag==0:
        ans=s[0:i].replace("?","a")+ss+s[i+len(t):].replace("?","a")
        break
print(ans)


Measured memory_bytes: 38432
#include<bits/stdc++.h>
using namespace std;  
int a[10005],j[10005]={0};
int main()  
{  
    int n;  
    cin>>n;
    int ans=1000-(n%1000);
    if(ans==1000) cout<<0;
    else cout<<ans;
    return 0;  
}  


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric> // 最大公約数が使える
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main()
{
    ll X;
    cin >> X;
    ll A=100;
    ll ans=0;
    do{
        A*=1.01;
        ans++;
    }
    while (A<X);

    cout << ans << endl;
    
    
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
        for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < m; j++)
      {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < m ; i++){
        cin >> b[i];
    }
    for (int i= 0; i < n;i++){
        int ans = 0;
        for (int j = 0; j < m; j++){
            ans += a[i][j] * b[j];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3120
s = input().split()

a = int(s[0])
b = int(s[1])
x = int(s[2])

def bet_ween(p, q):
    if p < 0:
        return 0
    else:
        return (p // q) + 1


fa = bet_ween(a-1, x)
fb = bet_ween(b, x)
answer = fb - fa
print(int(answer))

Measured memory_bytes: 9052
from fractions import gcd
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
s = input()
t = input()

g = gcd(n, m)
l = n * m // g
n = n // g
m = m // g
for i in range(g):
    if s[n * i] != t[m * i]:
        print(-1)
        exit()
print(l)

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

using namespace std;

typedef long long ll;

const int maxn=3e3+5;

const ll mod=1e9+7;

int dp1[maxn][maxn];
int dp2[maxn][maxn];

int a[maxn];
int b[maxn];

int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
	}
//	memset(dp1,0,sizeof(dp1));
//	memset(dp2,0,sizeof(dp2));
	for(int i=1;i<=n;i++){
		for(int j=0;j<=t;j++){
			dp1[i][j]=dp1[i-1][j];
		} 
		for(int j=a[i];j<=t;j++){
			dp1[i][j]=max(dp1[i][j],dp1[i-1][j-a[i]]+b[i]);
		}
	}
	
	for(int i=n;i>=1;i--){
		for(int j=0;j<=t;j++){
			dp2[i][j]=dp2[i+1][j];
		} 
		for(int j=a[i];j<=t;j++){
			dp2[i][j]=max(dp2[i][j],dp2[i+1][j-a[i]]+b[i]);
		}
	}
	
//	printf("%d %d\n",dp1[n][t],dp2[1][t]);
	
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<t;j++){
			ans=max(ans,dp1[i-1][j]+dp2[i+1][t-1-j]+b[i]);
		}
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    ll n;
    cin>>n;
 
    vector<ll>h(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
    }
 
    vector<ll>cost(n+5);
    cost[1]=0;
    cost[2]=abs(h[2]-h[1]);
 
    for(ll i=3;i<=n;i++)
    {
        cost[i]=min( cost[i-1]+abs(h[i]-h[i-1]),
                     cost[i-2]+abs(h[i]-h[i-2]) );
    }
 
    cout<<cost[n]<<endl;
 
    return 0;
}

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

class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0;i<size;i++)makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }

  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else {
      p[x]=y;
      if(rank[x]==rank[y]){
	rank[y]++;
      }
    }
  }

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

};


int main(){
  int n,a,b,q;
  int t;
  cin>>n>>q;
  DisjointSet ds=DisjointSet(n);

  for(int i=0;i<q;i++){
    cin>>t>>a>>b;
    if(t==0)ds.unite(a,b);
    else if(t==1){
      if(ds.same(a,b))cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3180
#include <stdio.h>
int main(){

  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x+r > W || x-r < 0 || y+r > H || y-r < 0){
    printf("No\n");
  }

  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 584
#include <iostream>

int main() {
  long coins_per_day, coins_per_week, goal;
  std::cin >> coins_per_day >> coins_per_week >> goal;

  long n_days = 0;
  while (n_days * coins_per_day + n_days / 7 * coins_per_week < goal) {
    ++n_days;
  }

  std::cout << n_days << '\n';
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int n;
double dp[301][301][301];
double sol(int zero,int one,int two,int three)
{
    if (one+two+three==0)
        return 0;
    if (dp[one][two][three]>-0.5)
        return dp[one][two][three];
    double &ret = dp[one][two][three];
    ret=0;
    // Pick 0, p=zero/n
    // dp[one][two][three] += p*dp[one][two][three]+p
    // dp[one][two][three] += p/(1-p)
    double p = ((double)zero)/n;
    ret+=p/(1-p);


    double tot = one+two+three;
    // Pick 1, p=one/tot
    // dp[one][two][three] += p*dp[one-1][two][three] + p
    if (one) {
        p = ((double)one)/tot;
        ret += p*sol(zero+1,one-1,two,three)+p;
    }

    // Pick 2, p=two/tot
    // dp[one][two][three] += p*dp[one+1][two-1][three] + p
    if (two) {
        p = ((double)two)/tot;
        ret += p*sol(zero,one+1,two-1,three)+p;
    }

    // Pick 3, p=three/tot
    // dp[one][two][three] += p*dp[one][two+1][three-1] + p
    if (three) {
        p = ((double)three)/tot;
        ret += p*sol(zero,one,two+1,three-1)+p;
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    int cnt[5]={0};
    for (int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
    for (int i=0;i<=n;i++)
        for (int j=0;j<=n;j++)
            for (int k=0;k<=n;k++)
                dp[i][j][k]=-2;
    cout<<setprecision(10)<<fixed<<sol(cnt[0],cnt[1],cnt[2],cnt[3])<<endl;
}


Measured memory_bytes: 213376
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one_arr = input[0].split("");
  const line_two_arr = input[1].split("");
  let ans = 0;
  for (let i in line_one_arr) {
    if (line_one_arr[i] !== line_two_arr[i]) {
      ans++;
    }
  }

  console.log(ans);
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 48560
from collections import deque
S=input()
Q=int(input())
q=deque()
for i in S:
  q.append(i)
cnt=0
for i in range(Q):
  A=list(input().split())
  if int(A[0])==1:
    cnt+=1
  else:
    if int(A[1])==cnt%2+1:
      q.appendleft(A[-1])
    else:
      q.append(A[-1])
if (cnt%2)==0:
  for i in range(len(q)):
    print(q.popleft(),end='')
else:
  for i in range(len(q)):
    print(q.pop(),end='')

Measured memory_bytes: 7664
n=int(input())
if n<7:print(n//3);quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    multiset<int> s;
    forn(i, n) {
        cin >> a[i];
        s.insert(a[i]);
    }
    forn(i, n) {
        s.erase(s.find(a[i]));
        cout << *s.rbegin() << "\n";
        s.insert(a[i]);
    }

}


Measured memory_bytes: 11776
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n; cin >> n;
	vector<int>h(n); for (auto& e : h)cin >> e;

	int peak=0;
	for (int i = 0; i < n; ++i) {
		peak = max(peak, h[i]);
		if (peak - h[i] >= 2) {
			cout << "No" << endl;
			break;
		}
		else if (i == n - 1) {
			cout << "Yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
def solve(prime, pay)
  turi = pay - prime
  result = {100 => 0, 500 => 0, 1000 => 0}
  if turi >= 1000
    add = turi / 1000
    result[1000] += add
    turi -= add * 1000
  end
  if turi >= 500
    add = turi / 500
    result[500] += add
    turi -= add * 500
  end
  if turi >= 100
    add = turi / 100
    result[100] += add
    turi -= add * 100
  end
  result
end

def main
  STDIN.each_line{|line|
    prime, pay = line.split(" ").map{|n| n.to_i}
    if prime == 0 && pay == 0
      break
    end
    result = solve prime, pay
    puts "#{result[100]} #{result[500]} #{result[1000]}"
  }
end

main

Measured memory_bytes: 6900
using System;

namespace Vanila
{
    public class Program
    {
        static void Main(string[] args)
        {
            string[] p = Console.ReadLine().Split(' ');
            string a = p[0];
            string b = p[1];
            string c = p[2];
            if (p[0] == p[1] && p[1] == p[2])
            {
                Console.WriteLine(1);
            }
            else if ((a != b && b == c)|| (b != c && c == a) || (c != a && a == b))
            {
                Console.WriteLine(2);

            }
            else {
                Console.WriteLine(3);
            }

        }
        public static long Max(long a, long b)
        {
            if (a <= b) return b;
            else return a;
        }
        public static long Min(long a, long b)
        {
            if (a == Max(a, b)) return b;
            else return a;
        }
        public static long GCD(long a, long b)
        {
            while (Max(a, b) % Min(a, b) != 0)
            {
                if (a < b) b %= a;
                else a %= b;
            }
            return Min(a, b);
        }
        public static long LCM(long a, long b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
  cout<<setprecision(12);
  int n,k; cin>>n>>k;
  double ans=0;
  for(int i=1; i<=n; i++){
    int j=i,c=0;
    while(true){
      if(j>=k){
        double x=pow(0.5,c)/n;
        ans+=x;
        break;
      }
      j*=2;c++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int compare_int(const void *a, const void *b);

int main()
{
	int n, p1['n'+1], p2['n'+1], cnt=0;

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p1[i]);
		p2[i]=p1[i];
	}
	qsort(p2,n,sizeof(int),compare_int );

	for(int i=0;i<n;i++)
		if(p1[i]!=p2[i])
			cnt++;

	if(cnt>=3)
		printf("NO");
	else
		printf("YES");

	printf("\n");

	return 0;
}

int compare_int(const void*a,const void *b){
	return(*(int *)a - * (int *)b );
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

double dp[3000][3000];

int main(void){
	int N; cin >> N;
	double p[3000];
	for(int i=0; i<N; i++){
		cin >> p[i];
	}

	dp[0][0] = 1;
	for(int i=0; i<N; i++){
		for(int j=0; j<=i; j++){
			dp[i+1][j+1] += dp[i][j] * p[i];
			dp[i+1][j] += dp[i][j] * (1-p[i]);
		}
	}

	double ans = 0.0;
	for(int i=(N+1)/2; i<=N; i++){
		ans += dp[N][i];
	}
	
	printf("%.10f\n", ans);
}

Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  
  vector<int> L(2*N);
  for(int i=0;i<2*N;i++) {
    cin>>L.at(i);
  }
  
  sort(L.begin(),L.end());
  
  int ans=0;
  
  for(int i=0;i<2*N;i+=2) {
    ans+=L.at(i);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
 int k,n;cin>>n>>k;double p[n+1],ex[n+1];for(int i=0;i<n+1;i++)ex[i]=0;
  double s=0,n2=n;
  
  
  for(int i=1;i<n+1;i++){
    while(i*pow(2,ex[i])<k) ex[i]++;
    p[i]=1/pow(2,ex[i]);//cout<<p[i]<<endl;
  }
  
    for(int i=0;i<n+1;i++) s+=p[i];
  
 printf("%.16f\n", s/n2);
  
  
  
  
}




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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n) for (int i = 1; i <= (int) n; i++)
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &p) {
    os << "{";
    for (auto itr = p.begin(); itr != p.end(); itr++) {
        itr++;
        if (itr != p.end()) { os << ", "; }
        itr--;
    }
    os << "}";
    return os;
}
struct SetUp {
    static constexpr int PREC = 20;
    SetUp() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setUp;

string S;
int K;
signed main() {
    cin >> S >> K;
    if (S.length() == 1) {
        cout << K / 2 << endl;
        return 0;
    }
    string A = S, B = S;
    int a = 0, b = 0;
    for (int i = 1; i < S.length(); i++) {
        if (A[i] == A[i - 1]) { A[i] = '-', a++; }
    }
    for (int i = 2; i < S.length(); i++) {
        if (B[i] == B[i - 1]) { B[i] = '-', b++; }
    }
    dump(a), dump(b);
    if (A[0] != A[S.length() - 1]) { cout << a * K << endl; }
    else {
        if (B[S.length() - 1] != '-') { cout << a + (b + 1) * (K - 1) << endl; }
        else { cout << a * (K - K / 2) + (b + 1) * (K / 2) << endl; }
    }
}


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

char A[200005];
int B[555];

ll Ans = 1;
int N;

int main() {
	scanf(" %s", A);
	N = int(strlen(A));
	for(int i = 0; i < N; i++) {
		B[A[i]]++;
		ll c = i - B[A[i]] + 1;
		Ans += c;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	string S, ans, A, B;

	cin >> N >> S;

	if (N % 2 != 0) ans = "No";
	else {
		A = S.substr(0, N / 2);
		B = S.substr(N / 2, N / 2);
		if (A == B) ans = "Yes";
		else ans = "No";
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long k = scanner.nextLong();
		System.out.println(Math.max(a - k, 0) + " " + Math.max(b - Math.max(k - a, 0), 0));
	}

}


Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;


public class Main {
	
	public static boolean is_covered(int node, int bit, boolean[][] adj){
		for(int upper = node - 1; upper >= 0; upper--){
			if((bit & (1 << upper)) != 0){
				continue;
			}else if(adj[upper][node]){
				return true;
			}
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			System.gc();
			
			if(n == 0){
				break;
			}
			
			int[] x_pos  = new int[n];
			int[] y_pos  = new int[n];
			int[] rs     = new int[n];
			int[] colors = new int[n];
			
			for(int i = 0; i < n; i++){
				x_pos[i]  = sc.nextInt();
				y_pos[i]  = sc.nextInt();
				rs[i]     = sc.nextInt();
				colors[i] = sc.nextInt();
			}
			
			boolean[][] cover = new boolean[n][n];
			
			for(int upper = 0; upper < n; upper++){
				for(int lower = upper + 1; lower < n; lower++){
					final int x_diff = (x_pos[upper] - x_pos[lower]);
					final int y_diff = (y_pos[upper] - y_pos[lower]);
					final int r_diff = (rs[upper] + rs[lower]);
					
					if(x_diff * x_diff + y_diff * y_diff < r_diff * r_diff){
						cover[upper][lower] = true;
					}
				}
			}
			
			final int bit_max = 1 << n;
			
			int[] dp = new int[bit_max];
			Arrays.fill(dp, -1);
			dp[0] = 0;
			
			int max = 0;
			for(int bit = 0; bit < bit_max; bit++){
				if(dp[bit] < 0){
					continue;
				}else{
					max = Math.max(max, dp[bit]);
				}
				
				//System.out.println(dp[bit]);
				
				for(int left = 0; left < n; left++){
					if((bit & (1 << left)) != 0){
						continue;
					}else if(is_covered(left, bit, cover)){
						continue;
					}
					//System.out.println("come");
					
					for(int right = left + 1; right < n; right++){
						if((bit & (1 << right)) != 0){
							continue;
						}else if(is_covered(right, bit, cover)){
							continue;
						}else if(colors[left] != colors[right]){
							continue;
						}
						
						final int next_bit = ((bit | (1 << left)) | (1 << right));
						//System.out.println(next_bit);
						
						dp[next_bit] = Math.max(dp[next_bit], dp[bit] + 2);
					}
				}
			}
			
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 95172
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,c,a[25][25],b[25],ans,sum;
int main(){
	cin>>n>>m>>c;
	for(int i=1;i<=m;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)	
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		sum=c;
		for(int j=1;j<=m;j++)
			sum+=a[i][j]*b[j];
		if(sum>0)
			ans++;
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int arr[n];
    map<int,int> mp;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    sort(arr,arr+n);
    int maxi=mp.rbegin()->first;
    //cout<<maxi<<endl;
    for(int i=0;i<n;i++)
    {
        int val=arr[i];
        if(mp.find(val)==mp.end())
            continue;
        if(mp[val]>1)
            mp.erase(val);
        if(mp.size())
        maxi=mp.rbegin()->first;
        //cout<<val<<" "<<maxi<<" "<<mp.size()<<endl;
        for(int j=2*val;j<=maxi;j+=val)
        {
            if(mp.find(j)!=mp.end())
                mp.erase(j);
        }
        
    }
    cout<<mp.size()<<endl;
    return 0;
}


Measured memory_bytes: 13784
import java.util.Scanner;

public class Main {

	static int max = -1;
	static int[][] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new int[2][n];
		for(int i = 0 ; i < 2 ; i++) {
			for(int j = 0 ; j < n ; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		dfs(0, 0, a[0][0], n);
		System.out.println(max);
	}

	public static void dfs(int x, int y, int sum, int n) {
		if(x == 1 && y == n - 1) {
			max = Math.max(max, sum);
			return;
		}
		if(0 <= x + 1 && x + 1 < 2 && 0 <= y && y < n) {
			dfs(x + 1, y, sum + a[x + 1][y], n);
		}
		if(0 <= x && x < 2 && 0 <= y + 1 && y + 1 < n) {
			dfs(x, y + 1, sum + a[x][y + 1], n);
		}
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)

ll dp[110][MAX];
 
void deal(){
	ll n , w;
	cin>>n>>w;
	for(ll i =1; i<=n; i++){
		ll ed , vi;
		cin>>ed>>vi;
		for(ll j = ed; j<MAX; j++)
			dp[i][j] = dp[i-1][j-ed] + vi;
		forj(MAX)
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
	}
	cout<<dp[n][w];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

using namespace std;

const string ord = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(void) {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
        s[i] = ord[(ord.find(s[i]) + 23) % 26];
    
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
bool p = false, m = false;
vector<int> a(51, 0);

void Incfunc(){ for(int i = 1; i < N; ++i) printf("%d %d\n", i, i + 1); }
void Decfunc(){ for(int i = N; i >= 2; --i) printf("%d %d\n", i, i - 1); }

int main(void){
    
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i){
        scanf("%d", &a[i]);
        if(a[i] >= 0) p = true;
        else m = true;
    }
    
    if(p && !m){ printf("%d\n", N - 1); Incfunc(); }
    else if(!p && m){ printf("%d\n", N - 1); Decfunc(); }
    else{
        auto itr = max_element(a.begin() + 1, a.begin() + N + 1);
        int mx = *itr, idx = distance(a.begin(), itr);
        vector<P> v; 
        if(mx > 0){
            for(int i = 1; i <= N; ++i){
                if(a[i] >= 0) continue;
                int num = abs(a[i] - 0);
                int s = (num % mx) ? num / mx + 1 : num / mx;
                for(int j = 0; j < s && v.size() <= N; ++j) v.push_back(make_pair(idx, i));
            }
            if(v.size() <= N){
                printf("%d\n", (int)v.size() + N - 1);
                for(int i = 0; i < v.size(); ++i) printf("%d %d\n", v[i].first, v[i].second);
                Incfunc();
                return 0;
            }
        }
        
        itr = min_element(a.begin() + 1, a.begin() + N + 1);
        int mn = *itr; idx = distance(a.begin(), itr);
        vector<P> w;
        for(int i = 1; i <= N; ++i){
            if(a[i] < 0) continue;
            int num = abs(a[i] - -1);
            int s = (num % mn) ? num / mn + 1 : num / mn;
            for(int j = 0; j < s && w.size() <= N; ++j) w.push_back(make_pair(idx, i));
        }
        if(w.size() <= N){
            printf("%d\n", (int)w.size() + N - 1);
            for(int i = 0; i < w.size(); ++i) printf("%d %d\n", w[i].first, w[i].second);
            Decfunc();
            return 0;
        }
        
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

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

    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    int modulo = 0, pow = 1;
    map<int, int> mp;
    mp[0]++;
    for (int i = n - 1; i >= 0; i--)
    {
        if (p == 2 || p == 5)
        {
            if ((int)(s[i] - '0') % p == 0)
                ans += i + 1;
            continue;
        }
        modulo += (s[i] - '0') * pow, modulo %= p;
        ans += mp[modulo];
        mp[modulo]++;
        pow = (pow * 10) % p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
const ll mod = 1e9 + 7;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int w = b - a - 1;
    if (w % 2 == 0)
    {
        cout << "Borys" << endl;
    }
    else
    {
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<ll> sum(n + 1, 0);
  for (int i = 0; i < n; i++){
    sum[i+1] = sum[i] + a[i];
  }
  

  multiset<ll> s;
  for (int i = 0; i <= n; i++){
    for (int j = i + 1; j <= n; j++){
      s.insert(sum[j]-sum[i]);
    }
  }

  ll ans = 0;
  for (int i = 40; i >= 0; i--){
    multiset<ll> t;
    for (auto j : s){
      if ((j >> i) & 1)
        t.insert(j);
    }
    if (t.size() >= k){
      s = t;
      ans |= (1LL << i);
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29056
N = int(input())
L = [list(map(int,input().split())) for _ in range(N)]
L.sort(key=lambda x: x[1])
w = 0
for i in range(N):
    x,y = L[i]
    w += x
    if w > y:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 116016
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b;
}
void src(){
    cout<<(a+b)%24;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
E=Counter(V[::2]).most_common()
O=Counter(V[1::2]).most_common()
if E[0][0]!=O[0][0]:
    print(n-E[0][1]-O[0][1])
else:
    if len(set(V))==1:
        print(n//2)
    else:
        print(min(n-E[1][1]-O[0][1],n-E[0][1]-O[1][1]))

Measured memory_bytes: 20700
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)
int main(){
    char s[5];
    int x = 0;
    cin >> s ;
    REP(i,4){
        if(s[i]=='+') x++;
        else x--;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256