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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DDisjointSetOfCommonDivisors {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

// 素因数
    set<int> getPrimeFactors(int a) {
        set<int> s;
        for (int i = 2; i * i <= a; i++) {
            if (a % i != 0) continue;
            s.insert(i);
            while (a % i == 0) a /= i;
        }
        if (a > 1) s.insert(a);
        return s;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int A, B;
        cin >> A >> B;

        auto a = getPrimeFactors(A);
        auto b = getPrimeFactors(B);
        vector<int> v;
        v.push_back(1);
        for(auto i: b) {
            if (a.count(i) > 0) v.push_back(i);
        }
        cout << v.size() << endl;
        return;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DDisjointSetOfCommonDivisors solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll dist;
	Edge(){}
	Edge(int to,ll dist):to(to),dist(dist){}
};

template <class E>
using Graph = vector<vector<E>>;
 
template<class D, D INF>
struct Dijkstra {
    vector<D> res; //res[i] = sからiまでの最短距離
    
    template<class E>
    Dijkstra(const Graph<E> &g, int s) {
        int V = (int)g.size();
        res = vector<D>(V, INF);
        
        using P = pair<D, int>;
        priority_queue<P, vector<P>, greater<P>> q;
        q.push(P(0, s));
        res[s] = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();
            if (res[p.second] < p.first) continue;
            for (E e: g[p.second]) {
                if (p.first+e.dist < res[e.to]) {
                    res[e.to] = p.first+e.dist;
                    q.push(P(res[e.to], e.to));
                }
            }
        }
    }
};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m,r; cin >> n >> m >> r;
	Graph<Edge> g(n);
	for(int i=0;i<m;i++){
		int a,b,c; cin >> a >> b >> c;
		g[a].push_back(Edge(b,c));
	}
	Dijkstra<ll,(ll)1e15> di(g,r);
	for(int i=0;i<n;i++){
		if(di.res[i]==1e15){
			cout << "INF" << endl;
		}
		else{
			cout << di.res[i] << endl;
		}
	}
}


Measured memory_bytes: 19340
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = int64_t;
using ull = uint64_t;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}
 
int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> Ais;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    struct Info {
        ll idx;
        ll value;
    };
    auto mod = [N](ll x) -> ll {
        return ((x % N) + N) % N;
    };
    ll ans = numeric_limits<ll>::max();
    for (ll magic = 0; magic <= N-1; magic++) {
        deque<Info> deq;
        vector<ll> count(N);
        ll end = N-1;
        for (ll start = N-1; start >= 0; start--) {
            do {
                while (!deq.empty() && deq.back().value >= Ais[end]) {
                    deq.pop_back();
                }
                deq.push_back(Info{end, Ais[end]});
                end = mod(end - 1);
            } while (end != mod(start - magic - 1));
            count[deq.front().idx]++;
            if (deq.front().idx == start) {
                deq.pop_front();
            }
        }
        ll cost = 0;
        for (ll i = 0; i < N; i++) {
            cost += Ais[i] * count[i];
        }
        cost += magic * X;
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;
	
signed main()
{
	fastio(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	loop(i,0,n) cin>>a[i];
	int prefix[k+1],dp[k+1];
	init(dp,0);
	init(prefix,0);
	//no of ways for n=1, fill upto a[0], is 1.
	loop(i,0,k+1)
	{
		if(i<=a[0]) dp[i] = 1;
		else dp[i] = 0;
		if(i==0) prefix[i] = dp[i];
		else prefix[i] = (prefix[i-1] + dp[i])%mod;
	}
	

	// dp[k][n] = sum(dp[k-ai][n-1]) ; ai E [0,min(k,an)].
	for(int N=2;N<=n;N++)
	{
		for(int K=0;K<=k;K++)
		{
			if(a[N-1]<K)
				dp[K] = (prefix[K] - prefix[K-a[N-1]-1] + mod)%mod; 
			else dp[K] = prefix[K]%mod;
		}
		// update prefix array
		for(int K=0;K<=k;K++)
		{
			if(K==0) prefix[K] = dp[K]%mod;
			else prefix[K] = (prefix[K-1] + dp[K])%mod;
		}
	}

	cout<<dp[k]%mod<<endl;
	return 0;	
}


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

int main (){
    int sum=0;
    int n;
    bool tf =true;
    cin >> n;
    vector <pair<int,int>> data;
    rep(i,n){
        int a,b;
        cin >>a >> b;
        data.emplace_back(b,a);
    }
    sort(data.begin(),data.end());
    rep(j,n){
        sum +=data.at(j).second;
        if(sum>data.at(j).first){
            tf=false;
            break;
        }
    }
    if(tf) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int A,B,C;

int main(){
	cin >> A >> B >> C;
	if(A < B) swap(A,B);
	if(A < C) swap(A,C);
	int ans = (A-B)/2 + (A-C)/2;
	if((A-B)&1){
		if((A-C)&1) ++ans;
		else ans += 2;
	} else if((A-C)&1) ans += 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 998244353
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

inline int read()
{
    int res = 0, sgn = 1;
    char c = getchar();

    while(c < '0' || c > '9')
    {
        if(c == '-')
            sgn = -1;
        c = getchar();
    }

    while(c >= '0' && c <= '9')
    {
        res = res * 10 + c - '0';
        c = getchar();
    }

    return res * sgn;
}

int main()
{
    string s, t;
    cin >> s >> t;
    int a , b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    ab = [LI() for _ in range(n-1)]
    e = collections.defaultdict(list)
    for a,b in ab:
        e[a].append(b)
        e[b].append(a)
    t = sorted([(-len(e[i]), i) for i in range(1,n+1)])
    d = collections.defaultdict(set)
    r = {}
    for _, a in t:
        i = 1
        for b in e[a]:
            if (a,b) in r:
                continue
            while i in d[a] or i in d[b]:
                i += 1
            d[a].add(i)
            d[b].add(i)
            r[(a,b)] = r[(b,a)] = i
            i += 1
    rr = []
    for a,b in ab:
        rr.append(r[(a,b)])

    return JA([max(rr)] + rr, "\n")


print(main())





Measured memory_bytes: 118304
#include <iostream>

using namespace std;

int main()
{
	int n, ans = 0;
	char c, lst = '\0';
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> c;
		if (c == lst)
			continue;
		lst = c;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
ans = float('inf')

for i in range(2**D):
    score = 0
    tmp_ans = 0
    used = [0]*D
    for j in range(D):
        if (i>>j) & 1:
            score += pc[j][0]*(100*(j+1)) + pc[j][1]
            tmp_ans += pc[j][0]
            used[j] = 1
    
    if score >= G:
        ans = min(ans, tmp_ans)
    else:
        for j in range(D-1, -1, -1):
            if (used[j] == 0 and 0 <= (G-score-1)//(100*(j+1))+1 <= pc[j][0]):
                tmp_ans += (G-score-1)//(100*(j+1))+1
                score += ((G-score-1)//(100*(j+1))+1)*(100*(j+1))
            if score >= G:
                ans = min(ans, tmp_ans)
                break

print(ans)


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	B := ReadInts(N)
	ans := 0
	needed := 0
	margins := []int{}
	marginSum := 0
	for i := 0; i < N; i++ {
		if A[i] < B[i] {
			ans++
			needed += B[i] - A[i]
		}
		if A[i] > B[i] {
			margin := A[i] - B[i]
			marginSum += margin
			margins = append(margins, margin)
		}
	}
	if marginSum < needed {
		fmt.Println(-1)
		return
	}
	sort.Sort(sort.Reverse(sort.IntSlice(margins)))
	for needed > 0 {
		needed -= margins[0]
		margins = margins[1:]
		ans++
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7336
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, i;
	cin >> N >> i;

	cout << N-i+1 << "\n";


}


Measured memory_bytes: 256
import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K = list(map(int,input().split()))
A = sorted(tuple(map(int,input().split())))
B = tuple(A[i+1]-A[i]  for i in range(len(A)-1))
lim = math.ceil(len(B)/2)

L = 10**9+7
ans = 0
multi = cmb(N,K,mod)
for j in range(lim):
    front = j + 1
    back = N - front
    tmp_b = 0
    tmp_f = 0
    if front >= K:
        tmp_f = cmb(front,K,mod)
    if back >= K:
        tmp_b = cmb(back,K,mod)
    if j == (len(B)-1)/2:
        ans += (multi - tmp_b - tmp_f)*(B[j]) % L
    else:
        ans += (multi - tmp_b - tmp_f)*(B[j]+B[len(B)-1-j]) % L
print(ans%L)

Measured memory_bytes: 31872
#include <stdio.h>

int main(){
	long long N, sum;
	scanf("%lld", &N);
	sum = N*(N+1)/2;

	long long Un3 = N/3;
	long long Sn3 = 3*(Un3*(Un3+1)/2);
	
	long long Un5 = N/5;
	long long Sn5 = 5*(Un5*(Un5+1)/2);
	
	long long Un15 = N/15;
	long long Sn15 = 15*(Un15*(Un15+1)/2);

	printf("%lld", sum-Sn3-Sn5+Sn15);
			
	return 0;
}

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


#define N 50000

int main(){
    int n;

    bool is_prime[N];
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<N;i++){
      is_prime[i] = true;
    }
    for(int i=2; i*i<N; i++){
      if(is_prime[i]){
        for(int j=i*i;j<N; j+=i){
          is_prime[j] = false;
        }
      }
    }


    while(1){
      int counter = 0;
      cin >> n;
      if(n == 0)
        break;
      if(cin.eof())
        break;
      int i=0;
      while(i <= n/2){
        if(is_prime[n-i] && is_prime[i])
          counter++;
        i++;
      }
        cout << counter << endl;
      }

    return 0;
}



Measured memory_bytes: 3144
H,W = map(int,input().split(" "))
s = []
s.append('.'*(W+2))
for i in range(H):
    s.append('.'+input()+'.')
s.append('.'*(W+2))
H+=1
W+=1
for h in range(H):
    for w in range(W):
        g = s[h][w]
        if g == ".":
            continue
        if '#' in [s[h-1][w],s[h+1][w],s[h][w-1],s[h][w+1]]:
            continue
        print("No")
        exit()

print("Yes")

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

void main_()
{
    ll N, T;
    vector<ll> ts;
    cin >> N >> T;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(ts));

    // tsはソート済み
    vector<ll> result;
    adjacent_difference(begin(ts), end(ts),
        back_inserter(result),
        [T](ll b, ll a) { return min(b - a, T); });

    auto ans = accumulate(begin(result), end(result), 0LL) + T;

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 4848
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

template <size_t T>
bool prevSubset(bitset<T>& bs, const bitset<T>& mask)
{
    bs = bs.to_ulong() - 1ull;
    bs &= mask;
    if(bs.none())
        return false;
    return true;
}

int n, m;
vector<vector<int> > r;

vector<vector<vector<int> > > memo;

int solve(int d, int win, bitset<16> rest)
{
    if(rest.count() == 1)
        return 1;
    if(d == -1)
        return 0;

    if(memo[d][win][rest.to_ulong()] != -1)
        return memo[d][win][rest.to_ulong()];

    int ret = 0;
    bitset<16> bs1 = rest;
    while(prevSubset(bs1, rest)){
        bitset<16> bs2 = rest ^ bs1;
        if(bs1.count() > (1<<d) || bs2.count() > (1<<d))
            continue;
        if(!bs1[win])
            continue;

        for(int i=0; i<n; ++i){
            if(bs2[i] && r[win][i] == 1)
                ret += solve(d-1, win, bs1) * solve(d-1, i, bs2);
        }
    }

    return memo[d][win][rest.to_ulong()] = ret;
}

int main()
{
    for(;;){
        cin >> n >> m;
        if(n == 0)
            return 0;

        r.assign(n, vector<int>(n));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cin >> r[i][j];
            }
        }

        int d = 1;
        while((1 << d) < n)
            ++ d;

        memo.assign(d, vector<vector<int> >(n, vector<int>(1<<n, -1)));
        cout << solve(d-1, m-1, (1<<n)-1) << endl;
    }
}

Measured memory_bytes: 24440
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    ll cnt = ((B-1)+(A-2))/(A-1);
    cout << cnt << endstr;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(210100);
    vector<ll> x(210100);
    for (int i = 0; i < n; i++) {
        ll p;
        cin >> p;
        if (p + i < 210000)z.at(p + i)++;
        if (i - p < 210000 && i - p >= 0)x.at(i - p)++;
    }
    ll ans = 0;
    for (int i = 0; i < 200001; i++) {
        ans += z.at(i) * x.at(i);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  int ans = 0, l, r;
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &l, &r);
    ans += (r - l + 1);
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std ;


int n;
int temp;

int Joy(vector<vector<int>>&a)
{
	
	vector<vector<int>>j(n,vector<int>(3,0));
    for(int i=0;i<3;i++)j[0][i]=a[0][i];

	for(int i=1;i<n;i++)
	{   

		j[i][0] = max(j[i-1][1],j[i-1][2])+a[i][0];
		j[i][1] = max(j[i-1][0],j[i-1][2])+a[i][1];
		j[i][2] = max(j[i-1][1],j[i-1][0])+a[i][2];

	}

	return max(j[n-1][0], max(j[n-1][1],j[n-1][2]));
   

}
int main()
{
	#ifdef patil
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
     
   cin>>n;
   vector<vector<int>>a(n, vector<int> (3,0));

   for(int i=0;i<n;i++)
   {
    for(int j=0;j<3;j++)
    {
    cin>>temp;
   	a[i][j]=temp;
    }
   	
   }
  
   cout<<Joy(a);
	return 0;
}

Measured memory_bytes: 14064
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	int ans = 1;
	for (int a = 1; a * a <= m; a++) {
		if (m % a != 0) continue; //aはmの約数

		int b = m / a;

		if ((ll)a * n <= m) ans = max(ans, a); //aがn個存在
		if ((ll)b * n <= m) ans = max(ans, b); //bがn個配れるか
	}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f,maxn=2e5+10,mod=1e9+7;
long long a[maxn],n,m,sum[maxn];
int main()
{
	long long i,j,k,ans=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
		//sum[i]%=mod;
	}
	for(i=1;i<=n;i++)
	{
		long long plus=0;
		plus=sum[n]-sum[i];
	//	cout<<plus<<endl;
		plus%=mod;
		ans+=(plus*a[i])%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Vector;


public class Main {

	static final int INF = 10000000;
	/**
	 * @param args
	 * @throws IOException 
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");

		int v = Integer.parseInt(tmpArray[0]);
		int e = Integer.parseInt(tmpArray[1]);
		int f = Integer.parseInt(tmpArray[2]);
		
		V = v;
		G = new Vector[V];

		for(int i = 0; i < G.length; i++){
			G[i] = new Vector<Edge>();
		}
		dist = new int[V];
		prevv = new int[V];
		preve = new int[V];
		h = new int[V];
		
		for(int i = 0; i < e; i++){
			tmpArray = br.readLine().split(" ");
			int from = Integer.parseInt(tmpArray[0]);
			int to = Integer.parseInt(tmpArray[1]);
			int c = Integer.parseInt(tmpArray[2]);
			int d = Integer.parseInt(tmpArray[3]);
			
			addEdge(from, to, c, d);
			
		}

		int result = minCostFlow(0, V - 1, f);

		System.out.println(result);
			
	}
	
	static int V;
	static Vector<Edge> G[];
	static int dist[];
	static int prevv[];
	static int preve[];
	static int h[];

	static void addEdge(int from, int to, int cap, int cost){
		G[from].add(new Edge(to, cap, cost, G[to].size()));
		G[to].add(new Edge(from, 0, -cost, G[from].size() - 1));
	}

	static int minCostFlow(int s, int t, int f){
		int res = 0;

		Arrays.fill(h, 0);
		
		while(f > 0){
			//dijkstra
			PriorityQueue<Dist> que = new PriorityQueue<Dist>();
			
			Arrays.fill(dist, INF);
			dist[s] = 0;
			que.add(new Dist(0, s));
			while(!que.isEmpty()){
				Dist p = que.remove();
				int v = p.v;
				if(dist[v] < p.dist){
					continue;
				}


				for(int i = 0; i < G[v].size() ;i++){
					Edge e = G[v].get(i);

					if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.add(new Dist(dist[e.to], e.to));
					}
				}
			}
			
			if(dist[t] == INF){
				return -1;
			}
			for(int v=0; v < V; v++){
				h[v] += dist[v];
			}

			//s-t間経路に沿って目一杯流す
			int d = f;
			for(int v = t; v != s; v = prevv[v]){
				d = Math.min(d, G[prevv[v]].get(preve[v]).cap);
			}
			f -= d;
			res += d * h[t];
			for(int v = t; v != s; v = prevv[v]){
				Edge e = G[prevv[v]].get(preve[v]);
				e.cap -= d;
				G[v].get(e.rev).cap += d;
			}
			
		}
		return res;
	}
}
class Edge {
	int to, cap, cost, rev;

	Edge(int to, int cap, int cost, int rev){
		this.to = to;
		this.cap = cap;
		this.cost = cost;
		this.rev = rev;
	}
}

class Dist implements Comparable<Dist>{
	int dist;
	int v;
	
	Dist(int dist, int v){
		this.dist = dist;
		this.v = v;
	}

	//近い順に並べる
	@Override
	public int compareTo(Dist d) {
		return this.dist - d.dist;
	}
}


Measured memory_bytes: 26724
import sys
import numpy as np

c = [list(map(int, input().split())) for ii in range(3)]

for a1 in range(101):
    # a1 が決まると b1, b2, b3は決まる
    b1, b2, b3 = c[0][0]-a1, c[0][1]-a1, c[0][2]-a1
    if b1 < 0 or b2 < 0 or b3 < 0:
        # この a1 で１列目は満たせない
        continue
    # b1 が決まれば a2, a3 も決まる。
    a2, a3 = c[1][0]-b1, c[2][0]-b1
    if a2 < 0 or a3 < 0:
        # この a1 では満たせない
        continue
    # ここまでで１列目、C21, c31 はOK
    # 2列目の残りチェック
    if a2 + b2 != c[1][1] or a2 + b3 != c[1][2]:
        # この a1 で２列目は満たせない
        continue
    # 3列目の残りチェック
    if a3 + b2 != c[2][1] or a3 + b3 != c[2][2]:
        # この a1 で３列目は満たせない
        continue
    # 一致した!!
    print("Yes")
    break
else:
    print("No")

Measured memory_bytes: 12500
n = gets.strip.to_i

def counter(int)
  cnt = 0
  while int % 2 == 0
    int /= 2
    cnt += 1
  end
  cnt
end

tmp = 0
ans = 0
(1..n).each do |i|
  num = counter(i)
  if num >= tmp
    ans = i
    tmp = num
  end
end

p ans

Measured memory_bytes: 1788
N,M = map(int,input().split())
graph = [[]for _ in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
for i in range(1,N-1):
    if 0 in graph[i] and N-1 in graph[i]:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")

Measured memory_bytes: 38396
N = int(input())
S = input()

R = [i+1 for i, x in enumerate(S) if x == 'R']
G = [i+1 for i, x in enumerate(S) if x == 'G']
B = [i+1 for i, x in enumerate(S) if x == 'B']

ans = len(R) * len(G) * len(B)

count = 0

for r in R:
    for g in G:
        a = r+g
        if a % 2 == 0:
            if S[int(a/2)-1] == 'B':
                count += 1

for r in R:
    for b in B:
        a = r+b
        if a % 2 == 0:
            if S[int(a/2)-1] == 'G':
                count += 1

for g in G:
    for b in B:
        a = g+b
        if a % 2 == 0:
            if S[int(a/2)-1] == 'R':
                count += 1

print(ans - count)


Measured memory_bytes: 68620
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x==1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
//vector <bool> prime(boolsize,1);
//void seive()
//{
//    ll n=boolsize;
//    prime[0]=prime[1]=0;
//    for(ll i=2;i<=sqrt(boolsize);i++)
//    {
//        if(prime[i]==1)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//            {
//                prime[j]=0;
//            }
//        }
//    }
//}

/// check for test case before submitting
void vfun()
{
    ll n,k,a,b,sum=0;
    cin>>n>>k;
    vii v(n);
    fo(i,n)
    {
        cin>>v[i].fst>>v[i].sec;
    }
    sort(v.begin(),v.end());
    fo(i,n)
    {
        sum+=v[i].second;
        if(sum>=k)
        {
            cout<<v[i].first;
            return;
        }
    }

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        //fun();
        vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not



Measured memory_bytes: 4796
#include<cstdio>
#include<iostream>
using namespace std;
const long long Maxn=100000+20;
long long n,m;
long long a[Maxn],c[Maxn];
int main()
{
//	freopen("in.txt","r",stdin);
	scanf("%lld",&n);
	long long tot=0;
	for(long long i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		++c[a[i]],tot+=a[i];
	}
	scanf("%lld",&m);
	while(m--)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		tot=tot-(c[x]*x)+c[x]*y;
		c[y]+=c[x],c[x]=0;
		printf("%lld\n",tot);
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  long power = 1;
  for(int i = 1; i <= N; i++){
	power *= i;
    power %= 1000000000 + 7;
  }
  
  cout << power << endl;
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const long long Inf=1ll<<60;
const int maxm=1e2+10;
const int maxn=1e5+10;

int N,M,Max;
long long W[maxm],V[maxm],DP[maxn];

int main(){
	register int i,j,Ans=0;
	scanf("%d%d",&N,&Max);
	for(i=1;i<=N;i++) scanf("%lld%lld",W+i,V+i),M+=V[i];
	for(i=1;i<=M;i++) DP[i]=Inf;
	for(i=1;i<=N;i++){
		for(j=M;j>=V[i];j--){
			if(DP[j-V[i]]==Inf || DP[j-V[i]]+W[i]>Max) continue;
			DP[j]=min(DP[j],DP[j-V[i]]+W[i]);
			Ans=max(Ans,j);
		}
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 1024
def solve():
    from sys import stdin
    f_i = stdin
    
    A = []
    for i in range(3):
        A += list(map(int, f_i.readline().split()))
    
    nums = dict()
    for a in A:
        nums[a] = True
    
    N = int(f_i.readline())
    
    for i in range(N):
        b = int(f_i.readline())
        if b in nums:
            nums[b] = False
    
    line = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7),
            (2, 5, 8), (0, 4, 8), (2, 4, 6)]
    
    for l in line:
        for n in l:
            if nums[A[n]]:
                break
        else:
            ans = 'Yes'
            break
    else:
        ans = 'No'
    
    print(ans)

solve()

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    int A,B;
    A=(int)fabs(x-a);
    B=(int)fabs(x-b);
    if(A<B)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}


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

inline ll rd() {
  ll x = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}

ll mx1, mx2, mn1, mn2;

int main() {
  mn1 = mn2 = inf;
  mx1 = mx2 = -inf;
  ll n = rd(), x, y;
  for (; n; --n) {
    x = rd(); y = rd();
    mx1 = max(mx1, x + y);
    mx2 = max(mx2, x - y);
    mn1 = min(mn1, x + y);
    mn2 = min(mn2, x - y);
  }
  printf("%lld\n", max(mx1 - mn1, mx2 - mn2));
  return 0;
}


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

using namespace std;

int main()
{
  int A, B, C; cin >> A >> B >> C;
  int K; cin >> K;

  int ans = 0;
  for (int a_i = 0; a_i <= K; ++a_i) {
    for (int b_i = 0; b_i <= K - a_i; ++b_i) {
      for (int c_i = 0; c_i <= K - a_i - b_i; ++c_i) {
        ans = max(ans, A * (int)pow(2, a_i) + B * (int)pow(2, b_i) + C * (int)pow(2, c_i));
      }
    }
  }

  cout << ans;
}

Measured memory_bytes: 384
#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 RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w));
    rep(i,h){
        vector<int> seen(w);
        rep(j,w){
            if(s[i][j] == '#') continue;
            if(seen[j]) continue;
            int l = 0;
            while(j + l < w){
                if(s[i][j+l] == '#') break;
                l++;
            }
            for(int k = j; k < j+l; k++) {
                cnt[i][k] += l; 
                seen[k] = 1;
            }
        }
    }
    rep(j,w){
        vector<int> seen(h);
        rep(i,h){
            if(s[i][j] == '#') continue;
            if(seen[i]) continue;
            int l = 0;
            while(i + l < h){
                if(s[i+l][j] == '#') break;
                l++;
                seen[i] = 1;
            }
            for(int k = i; k < i+l; k++) {
                cnt[k][j] += l; 
                seen[k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        ans = max(ans, cnt[i][j] - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 20096
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 2000;

int n, K, val[10][N], dp[N+1];
vector<int> data[10];

main(){
  cin >> n >> K;
  for(int i=0;i<n;i++){
    int a, b;
    cin >> a >> b;
    data[b-1].push_back(a);
  }
  for(int i=0;i<10;i++){
    if(data[i].size() == 0) continue;
    sort(data[i].begin(), data[i].end(), greater<int>());
    val[i][0] = data[i][0];
    for(int j=1;j<data[i].size();j++){
      val[i][j] = val[i][j-1] + data[i][j] + 2*j;
    }
  }
  fill(dp, dp+K+1, -1);
  dp[0] = 0;
  for(int i=1;i<=data[0].size();i++) dp[i] = val[0][i-1];
  for(int i=1;i<10;i++){
    for(int j=K;j>=0;j--){
      if(dp[j] == -1) continue;
      for(int k=0;k<data[i].size()&&k+1+j<=K;k++) dp[k+1+j] = max(dp[k+1+j], dp[j] + val[i][k]);
    }
  }
  int ans = 0;
  for(int i=0;i<=K;i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}

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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

int main() {
  string S; cin >>S;
  string ans="No";
  if (S.size()>=4 && S.substr(0,4)=="YAKI") {
    ans="Yes";
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == '2') {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
count = 0
for i in range(n):
    res = c
    for j in range(m):
        res += a[i][j]*b[j]
    if res > 0:
        count += 1
print(count)


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

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

	int i,k;
	int ans=0;
	int ctr=0;
	string S;

	cin >> S;

	
	if(S[S.size()-1]=='s')
		cout << S << "es" << endl;
	else
		cout << S << "s" << endl;

	return 0;
}



Measured memory_bytes: 3652
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 mut a = read_as_vec::<usize>();

    let mut limits: Vec<usize> = vec![0;n+1];
    limits[0] = 1;

    if n == 0 && a[0] > 1 {
        println!("-1");
        return;
    }
    for i in 1..limits.len(){
        if limits[i-1] <= a[i-1]{
            println!("-1");
            return;
        }
        if limits[i-1] - a[i-1] >= std::usize::MAX/2{
            limits[i] = std::usize::MAX;
        }else{
            limits[i] = (limits[i-1] - a[i-1])*2;
        }
    }

    //println!("{:?}", limits);
    for i in (1..n+1).rev(){
        if a[i] > limits[i]{
            println!("-1");
            return;
        }

        if limits[i-1] < a[i-1] + a[i]{
            a[i-1] = limits[i-1];
        }else{
            a[i-1] += a[i];
        }
    }
    println!("{}", a.iter().sum::<usize>());
}


Measured memory_bytes: 3940
N=int(input())
LA=[int(x) for x in input().split()]
for i in range(len(LA)-1):
    if LA[i]>=0:
        pass
    else:
        LA[i]*=-1
        LA[i+1]*=-1

if LA[-1]<0:
    LA[-1]*=-1
    print(sum(LA)-min(LA)*2)
else:
    print(sum(LA))


Measured memory_bytes: 14412
#include<stdio.h>
#include<string.h>
#define L 200

int main(){
	int i, j;
	char str[L];
	scanf("%s",str);
	j = strlen(str);
	for(i=0;i<j;i++){
		printf("%c",str[j-i-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        s: chars,
    );

    let mut ans = 1<<30;

    let mut s = s.iter().map(|c| if c == &'0' { 0 } else { 1 }).collect::<Vec<i32>>();

    for i in 0..2 {
        let mut tmp = 0;
        for j in 0..s.len() {
            tmp += if s[j] != i ^ (j % 2) as i32 {
                1
            } else {
                0
            }
        };
        ans = min(ans, tmp);
    };
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

ll N, A, B;
vector<ll> H(100001, 0);

bool Solve(ll mid){
    ll num = 0;
	for(int i = 0; i < H.size(); ++i){
	   ll h = H[i] - (B * mid);
	   if(h <= 0) continue;
	   num += h / (A - B);
	   if(h % (A - B)) ++num;
	}
	return mid >= num;
}

int main(void){
	
	scanf("%lld %lld %lld", &N, &A, &B);
	for(int i = 0; i < N; ++i) scanf("%lld", &H[i]);
	
    ll ng = 0, ok = 1000000010;
	while(abs(ok - ng) > 1){
	    ll mid = (ng + ok) / 2;
	    if(Solve(mid)) ok = mid;
	    else ng = mid;
	}
	printf("%lld\n", ok);
	
    return 0;
}


Measured memory_bytes: 1024
# C - Exception Handling
N = int(input())
A = list(int(input()) for _ in range(N))
A_sorted = list((sorted(A, reverse = True)))
A_sorted = A_sorted[0:2]

ans = []
for i in A:
    if i == A_sorted[0]:
        ans.append(A_sorted[1])
    else:
        ans.append(A_sorted[0])

for j in ans:
    print(j)

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

using namespace std;

vector<string> out;

void print(string str,int a,int b){
    string temp;
    temp = str.substr(a,b - a + 1);
    out.push_back(temp);
}

void reverse(string &str,int a,int b){
    for (int i = a,j = b;i < j;i++,j--){
        char temp;
        temp = str[i];
        str[i] = str[j];
        str[j] = temp;
    }
}

void replace(string &str,int a,int b,string s){
    for (int i = a,j = 0;i <= b;i++,j++){
        str[i] = s[j];
    }
}

int main(){
    string str;
    cin >> str;
    int q;
    cin >> q;
    for (int i = 0;i < q;i++){
        string ins;
        cin >> ins;
        if (ins == "print"){
            int a,b;
            cin >> a >> b;
            print(str,a,b);
        }
        else if (ins == "reverse"){
            int a,b;
            cin >> a >> b;
            reverse(str,a,b);
        }
        else {
            int a,b;
            string s;
            cin >> a >> b >> s;
            replace(str,a,b,s);
        }
    }
    for (int i = 0;i < out.size();i++){
        cout << out[i] << endl;
    }
}

Measured memory_bytes: 1228
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip> //do setprecision
#include <ctime>
#include <complex>
using namespace std;

int main(void){
	int N,A;
	scanf("%d",&N);
	scanf("%d",&A);
	if((N%500)<=A){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 256