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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int x = 0, y = 0;
  for (char c : s) {
    if (c == 'A') x++;
    else y++;
  }
  if (x && y) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

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

const int MAX = 3e5 + 111;

int n, k;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    ll ans = 0;
    if (k % 2 == 0)
        ans = ((2 * n / k + 1) / 2LL) * ((2 * n / k + 1) / 2LL) * ((2 * n / k + 1) / 2LL);
    cerr << ans;
    ans += (n / k) * 1LL * (n / k) * 1LL * (n / k);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = 1;i <= n;i++)
#define fi first
#define se second
const int inf = 1e18;
typedef pair<int,int> P;

vector<P> x[200001], y[200001], G[400010];
priority_queue<P, vector<P>, greater<P> > q;
int d[400010], w, h, n;

void input(){
	fill(d, d+400010, inf);
	scanf("%lld%lld%lld", &w, &h, &n);
	for(int i = 1;i <= n;i++){
		int yy, xx;
		scanf("%lld%lld", &xx, &yy);
		x[xx].push_back(P(yy, i));
		y[yy].push_back(P(xx, i));
	}
	x[1].push_back(P(1, 0));
	x[w].push_back(P(h, n+1));
	y[h].push_back(P(w, n+1));
	n++;
}

void add_edge(){
	for(int i = 1;i <= w;i++){
		sort(x[i].begin(), x[i].end());
		for(int j = 1;j < x[i].size();j++){
			int from = x[i][j-1].se, to = x[i][j].se;
			int cost = x[i][j].fi-x[i][j-1].fi;
			G[from].push_back(P(to, cost));
			G[to].push_back(P(from, cost));
		}
	}
	for(int i = 1;i <= h;i++){
		sort(y[i].begin(), y[i].end());
		for(int j = 1;j < y[i].size();j++){
			int from = y[i][j-1].se+n, to = y[i][j].se+n;
			int cost = y[i][j].fi-y[i][j-1].fi;
			G[from].push_back(P(to, cost));
			G[to].push_back(P(from, cost));
		}
	}
	for(int i = 1;i <= n-1;i++){
		G[i].push_back(P(i+n, 1));
		G[i+n].push_back(P(i, 1));
	}
}

void dijkstra(){
	d[0] = 0;
	q.push(P(0, 0));
	while(!q.empty()){
		P p = q.top();q.pop();
		if(d[p.se] < p.fi)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i].fi;
			int cost = G[from][i].se;
			if(d[from]+cost < d[to]){
				d[to] = d[from]+cost;
				q.push(P(d[to], to));
			}
		}
	}
}

signed main(){
	input();
	add_edge();
	dijkstra();
	int ans = min(d[n], d[2*n]);
	if(ans == inf)printf("-1\n");
	else printf("%lld\n", ans);
	return 0;
} 


Measured memory_bytes: 69596
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100 + 10;
int h[maxn];

int main(){
    for(int i = 0; i < 2; i++){
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 0; i < 2 ; i++){
        int maxx = -1, idx = -1;
        for(int j = 0; j < 2; j++){
            if(h[j] > maxx){
                maxx = h[j];
                idx = j;
            }
        }
        ans += maxx;
        h[idx] -= 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	double f[] = {0.2,0.6,1.1};
	double a,b;
	vector<int> v1(4),v2(4);
	while(cin>>a>>b){
		v1[upper_bound(f,f+3,a) - f]++;
		v2[upper_bound(f,f+3,b) - f]++;
	}
	FOR(i,4){
		printf("%d %d\n",v1[3-i],v2[3-i]);
	}

	return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		char b = a.charAt(0);
		char c = a.charAt(1);
		char d = a.charAt(2);
		char f = 'R';

		if(b==c && c==d && d==f) {

			System.out.println("3");

		}else if((b==c && c==f) || (c==d && d==f)) {

			System.out.println("2");

		}else if(!(b==f || c==f || d==f)) {

			System.out.println("0");

		}else {
			System.out.println("1");
		}
	}
}

Measured memory_bytes: 35680
#include<stdio.h>

int main()
{
    int a,i;
    scanf("%d", &a);
    int b[a];

    for(i=1; i <=a; i++){
	scanf("%d", &b[i]);
        }
    for(i=0; i <a-1; i++){
	printf("%d ",b[a-i]);
	}
    printf("%d",b[1]);
    printf("\n");
    return 0;
}




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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,k,n,a[100000],ans=inf;
	cin>>n>>k;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for (i=k-1;i<n;i++){
		ans=min(ans,a[i]-a[i-k+1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
        int A, B, max, coin;

        scanf("%d %d", &A, &B);

        if (A > B) {
                coin = A;
                A--;
        } else {
                coin = B;
                B--;
        }

        if (A > B) {
                coin += A;
                A--;
        } else {
                coin += B;
                B--;
        }

        printf("%d\n", coin);

        return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    string S, T; cin >> S >> T;
    int c = 0;
    REP(i, 0, 3)
    {
        if (S[i] == T[i]) ++c;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
def calc_gcd(a, b):
    return calc_gcd(b, a % b) if b else a


def p_d():
    a, b = map(int, input().split())
    gcd = calc_gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if gcd != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 38512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

ll TSP(vector<vll> &d, ll N){
    vector<vll> dp(1<<N, vll(N, INF));
    dp[(1<< N)-1][0] = 0;

    for(ll S = (1LL<< N) -2; S >= 0; S--){
        REP(v, N){
            REP(u, N){
                if(!(S >> u & 1)){
                    dp[S][v] = min( dp[S][v], dp[S| 1LL<< u][u]+ d[v][u]);
                }
            }
        }
    }
    return dp[0][0];
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vll> d(N, vll(N, INF));
    REP(i, M){
        ll s, t, cost;
        cin >> s >> t >> cost;
        d[s][t] = cost;
    }
    ll res = TSP(d, N);
    if(res < INF)
        cout << res << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 7576
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

int main()
{
    optimiza_io
    string s;
    int K;
    cin >> K >> s;
    if( s.size() <= K )
        cout << s << "\n";
    else
        cout << s.substr(0,K) << "...\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 1000006;
//////////////////////////////

struct Matrix {
	Int val[50][50];
	Matrix() {
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 50; j++) {
				val[i][j] = 0;
			}
		}
	}
};

Matrix I;

Matrix operator*(Matrix a, Matrix b) {
	Matrix c;
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			for (int k = 0; k < 50; k++) {
				c.val[i][j] += a.val[i][k] * b.val[k][j] % MOD;
				c.val[i][j] %= MOD;
			}
		}
	}
	return c;
}

Int n, k;

Matrix matrix_power(Matrix a, Int p)
{
	if (p == 0) return I;
	Matrix res = matrix_power(a, p / 2);
	res = res * res;
	if (p % 2 == 1) res = res * a;
	return res;
}

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

	for (int i = 0; i < 50; i++) I.val[i][i] = 1;

	Matrix A;
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> A.val[i][j];
		}
	}

	Matrix A_k = matrix_power(A, k);
	Int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += A_k.val[i][j];
			ans %= MOD;
		}
	}

	cout << ans << endl;

 	return 0;
}

Measured memory_bytes: 9600
// https://atcoder.jp/contests/agc007/tasks/agc007_a
#include <bits/stdc++.h>
using namespace std;

bool dfs(vector<vector<bool>> g, int i, int j, int n, int m) {
    g[i][j] = 0;
    if(i==n-1 && j==m-1) {
        for(int k=0;k<n;k++) {
            for(int l=0;l<m;l++) {
                if(g[k][l])
                    return 0;
            }
        }
        return 1;
    }
    bool d=0,r=0;
    if(i<n-1)
        d = dfs(g, i+1, j, n, m);
    if(j<m-1)
        r = dfs(g, i, j+1, n, m);
    return (d || r);
}

int main() {
    int n, m;cin>>n>>m;
    vector<vector<bool>> g(n, vector<bool>(m));
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            char ch; cin>>ch;
            if(ch=='.') g[i][j] = 0;
            else g[i][j] = 1;
        }
    }
    if (dfs(g, 0, 0, n, m)) {
        cout<<"Possible\n";
    } else {
        cout<<"Impossible\n";
    }

}

Measured memory_bytes: 3640
<?php
$lowers = range("a", "z");
$counts = array();
foreach ($lowers as $lower) $counts[$lower] = 0;

while (true) {
  $s = trim(fgets(STDIN));
  if ($s == '') break;
  
  $s = str_split($s);
  foreach ($s as $c)
    if (ctype_lower($c) || ctype_upper($c))
      $counts[strtolower($c)]++;
}

foreach ($lowers as $lower) echo "$lower : $counts[$lower]\n";



Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int W, H, x, y, r;
    string ans = "Yes";
    cin >> W >> H >> x >> y >> r;
    if (x - r < 0 || W < x + r || y - r < 0 || H < y + r) ans = "No";
    cout << ans << endl;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        //long start = System.nanoTime();
        System.out.println(solve(n, W, w, v));
        //long end = System.nanoTime();
        //System.err.println("execution time: " + ((end-start)/1_000_000) + "ms");
    }
    private static long solve(int n, int W, int[] w, int[] v) {
        long[][] dp = new long[n][W+1];
        for (int j = 1; j < W+1; j++) {
            dp[0][j] = (w[0] <= j) ? v[0]: 0;
        }
        for (int i = 1; i < n; i++) {
            for (int j = 1; j <= W; j++) {
                if(j >= w[i]) {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
                }
                else dp[i][j] = dp[i-1][j];
            }
        }
        return dp[n-1][W];
    }
}


Measured memory_bytes: 127440
import sys
input = sys.stdin.readline
def main():
    N, M, K=map(int, input().split())
    friend_or_block = [0] * N
    friends_chain = UnionFindTree(N)

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        friends_chain.unite(a, b)
        friend_or_block[a] += 1
        friend_or_block[b] += 1

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if friends_chain.same(c, d):
            friend_or_block[c] += 1
            friend_or_block[d] += 1

    print(*[friends_chain.count(i) - friend_or_block[i] - 1 for i in range(N)])

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def root(self, x):
        p, s = self.parent[x], list()
        while p >= 0:
            s.append(x)
            x, p = p, self.parent[p]
        for c in s: self.parent[c] = x
        return x

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

    def count(self, x): return -self.parent[self.root(x)]

    def unite(self, x, y):
        xr, yr = self.root(x), self.root(y)
        if xr == yr: return
        if self.parent[xr] > self.parent[yr]: xr, yr = yr, xr
        self.parent[xr] += self.parent[yr]
        self.parent[yr] = xr

if __name__ == '__main__':
    main()



Measured memory_bytes: 13420
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    if(k==1){
        k=n;
    }
    cout << n-k << endl;

    return 0;
}

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

int main()
{
  long long A,C;
  long double B;
  scanf("%lld",&A);
  scanf("%Lf",&B);
  B*=100;
  B=round(B);
  C=A*B/100;
  printf("%lld\n",C);
  return 0;
}




Measured memory_bytes: 2220
h, w = map(int, input().split())
f = [["."] * (w + 2)] + \
    [list("." + input() + ".") for i in range(h)] + \
    [["."] * (w + 2)]

flg = False
for y in range(h):
    for x in range(w):
        if f[y][x] == '#':
            cnt = 0
            if f[y+1][x] == f[y-1][x] == f[y][x+1] == f[y][x-1] == '.':
                flg = True

print('No') if flg else print('Yes')

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

int main()
{
	int k,x;
	cin >> k >> x;
	int a[k+k];
	for(int i = 1;i <= k+k;i++){
		a[i] = x - k + i;
	}
	for(int i = 1;i <= k + k - 1;i++ ){
		cout  << a[i] << " "; 
	}

}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k = read::<i32>();

    println!("{}", (k/2 + k%2) * (k/2));
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

const int MAXN = 2e6+5;
ll factorial[MAXN], inverse[MAXN];

ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

ll modInverse(ll a, ll m){
    return power(a,m-2,m);
}

void pre() {
    factorial[0] = 1LL; inverse[0] = modInverse(factorial[0], MOD);
    for (int i = 1; i < MAXN; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
        inverse[i] = modInverse(factorial[i], MOD);
    }
}

ll binomial_coefficient(ll n, ll k) {
    return factorial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ll n,m; cin>>n>>m;
    pre();
    ll res = 0;
    FOR(j, 0, n + 1) {
        ll curr = (binomial_coefficient(n, j) * binomial_coefficient(m - j, n - j))%MOD;
        curr *= factorial[n - j]; curr %= MOD;
        if(j & 1) res = (res - curr + MOD)%MOD;
        else res = (res + curr)%MOD;
    }
    res *= (binomial_coefficient(m, n) * factorial[n])%MOD;
    res %= MOD;
    cout << res;
    return 0;
}

Measured memory_bytes: 34892
from functools import reduce
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD
  
answer = pow(2, N, MOD) - f(A) - f(B) - 1
answer %= MOD
print(answer)

Measured memory_bytes: 3572
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int ans=0;
        int n=sc.nextInt();
        int x=sc.nextInt();
        long[] a=new long[n];
        for (int i = 0; i < n; i++) {a[i]=sc.nextInt();}
        Arrays.sort(a);
        long[] b=new long[n+1];
        for (int i =1 ; i < 1+n; i++) {
            b[i]=a[i-1]+b[i-1];
        }
        for (int i = 1; i <= n; i++) {
            if(b[i]==x){
                ans=i;
                break;
            }else if(b[i]<x){
                ans++;
            }else{
                break;
            }
        }
        if(ans==n&&b[n]!=x)ans--;
        out.println(ans);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <numeric>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll maxi = a[0];
  ll ans = 0;
  for(int i = 1; i < n; i++) {
    if(maxi > a[i]) {
      ans += maxi - a[i];
    } else if(maxi < a[i]) {
      maxi = a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4836
using System;

namespace ALDS1_5A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var A = sr.Next<int>(N);
            var Q = sr.Next<int>();
            var M = sr.Next<int>(Q);

            var dp = new bool[114514];
            dp[0] = true;

            foreach(var a in A){
                for(var i = dp.Length - 1; i >= 0; i--){
                    if(dp[i]) dp[i + a] = true;
                }
            }

            foreach(var m in M){
                Console.WriteLine(dp[m] ? "yes" : "no");
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10036
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<vector<int>> c(3,vector<int> (3));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin>>c.at(i).at(j);}}
bool ans=true;
for(int i=1;i<3;i++){
for(int j=0;j<3;j++){
if(c.at(i).at(j)-c.at(0).at(j)!=c.at(i).at(0)-c.at(0).at(0)){ans=false;}
else if(c.at(j).at(i)-c.at(j).at(0)!=c.at(0).at(i)-c.at(0).at(0)){ans=false;}
}}
if(ans){cout<<"Yes"<<endl;}
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)
p,b = 2.times.map{Array.new(51,0)}
p[0] = 1
50.times do |i|
    p[i+1] = p[i]*2+1
    b[i+1] = b[i]*2+2
end

ans = 0
while x > 0
    if x >= p[n]+b[n]
        x -= p[n]+b[n]
        ans += p[n]
        break if x == 0
        x -= 1
        ans += 1
        if x >= p[n]+b[n]
            x -= p[n]+b[n]
            ans += p[n]
        end
    else
        x -= 1
        n -= 1
    end
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
typedef int64_t ll;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	int N;
	cin >> N;
	int res = N;
	for (int i = 0; i <= N; i++)
	{
		int cc = 0;
		int t = i;
		while (t > 0)cc += t % 6, t /= 6;
		t = N - i;
		while (t>0) cc += t % 9, t /= 9;
		if (res > cc)res = cc;
	}
	cout << res << endl;
}

Measured memory_bytes: 3588
s = input()

if s[0] == 'A':
  if s[2:-1].count('C') == 1:
    s = s.replace("A", "", 1)
    s = s.replace("C", "", 1)
    if s.islower():
    	print("AC")
    else:
      print("WA")
  else:
    print("WA")
    
else:
  print("WA")

Measured memory_bytes: 3060
#b
s = input()
v = input()
ans = 0
for i in range(len(s)-len(v)+1):
    count = 0
    for j in range(len(v)):
        if s[i+j] == v[j]:
            count += 1
    if count > ans:
        ans = count
print(len(v) - ans)  

Measured memory_bytes: 9056
from collections import*;M=lambda:map(int,input().split());r=range;n,k,l=M()
def f(m):
  a=list(r(n))
  def g(i):
    if a[i]==i:return i
    a[i]=g(a[i]);return a[i]
  for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)
  return g
x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print(' '.join((str(c[x(i),y(i)])for i in r(n))))

Measured memory_bytes: 60512
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N;
    cin >> N;
    vector<int> arr(N, 0);
    for(int i = 0; i < N; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    if (arr[N/2] == arr[N/2-1]) {
        cout << 0 << endl;
    } else {
        cout << arr[N/2] - arr[N/2-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string s[2];
    cin>>s[0]>>s[1];
    for(int i=0;i<3;i++){
        if(s[0][i]!=s[1][2-i]) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define piii pair<int,pair<int,int>>
#define endl "\n"
 
using namespace std;

const int mlt=(1<<18)+69;
const ll inf=1e18;
//TTBDC

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

int n,m;
bool inside(int r,int c){
  if(r<n && r>=0 && c<m && c>=0)return true;
  else return false;
}

int main()
{
  fatafat
  cin>>n>>m;
  int sx,sy,fx,fy;
  cin>>sx>>sy>>fx>>fy;
  sx--;sy--;fx--;fy--;
  string mat[n];
  for(int i=0;i<n;i++)cin>>mat[i];
  if(mat[fx][fy]=='#'){cout<<-1;return 0;}
  // int dp[n][m];
  // memset(dp,0,sizeof(dp));
  vector<vector<int>> dp(n,vector<int> (m,-1));
  // queue<pair<pair<int,int>,int> > q;
  // q.push({{sx,sy},0});
  priority_queue<piii,vector<piii>,greater<piii>> pq;
  pq.push({0,{sx,sy}});
  dp[sx][sy] = 0;
  while(!pq.empty()){
    auto prs = pq.top();
    int x = prs.sd.ft;
    int y = prs.sd.sd;
    int d = prs.ft;
    pq.pop();
    // if(dp[x][y]!=-1)continue;
    // dp[x][y] = d;
    for(int i=0;i<24;i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(inside(nx,ny) && (dp[nx][ny]>d+dc[i] || dp[nx][ny]==-1) && mat[nx][ny]=='.'){
        dp[nx][ny] = d+dc[i];
        pq.push({d+dc[i],{nx,ny}});
      }
    }
  }
  cout<<dp[fx][fy];
  return 0;
}

Measured memory_bytes: 8460
#include<bits/stdc++.h>
using namespace std;
string s,t,ans="";
int i,j,r;
int main(){
	cin>>s>>t;
	if(s.size()<t.size()){
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(i=0;i<=s.size()-t.size();i++){
		int k=i;
		string ss=s;
		j=0;
		while(j<t.size()){
			if(ss[k]=='?')
				ss[k]=t[j];
			else if(s[k]!=t[j])
				break;
			k++;
			j++;
		}
		if(j==t.size()){
			for(r=0;r<ss.size();r++){
				if(ss[r]=='?')
					ss[r]='a';
			}
			if(ans=="")
				ans=ss;
			else ans=min(ans,ss);
		}
	}
	if(ans=="")
		cout<<"UNRESTORABLE";
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"), "3\n");
    assert_eq!(
        solve("4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n"),
        "428\n"
    );
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let cmx: usize = sc.read();

    let d: Vec<Vec<usize>> = (0..cmx)
        .map(|_| (0..cmx).map(|_| sc.read()).collect())
        .collect();
    let c: Vec<Vec<usize>> = (0..n)
        .map(|_| (0..n).map(|_| sc.read()).collect())
        .collect();
    let mut cnt = vec![vec![0; cmx]; 3];
    for i in 0..n {
        for j in 0..n {
            cnt[(i + j) % 3][c[i][j] - 1] += 1;
        }
    }
    let cnt = cnt;

    let mut ans = 1000 * 500 * 500;
    for i in 0..cmx {
        for j in 0..cmx {
            if i == j {
                continue;
            }
            for k in 0..cmx {
                if i == k || j == k {
                    continue;
                }
                let mut res = 0;
                for c in 0..cmx {
                    res += cnt[0][c] * d[c][i];
                }
                for c in 0..cmx {
                    res += cnt[1][c] * d[c][j];
                }
                for c in 0..cmx {
                    res += cnt[2][c] * d[c][k];
                }
                ans = std::cmp::min(ans, res);
            }
        }
    }

    format!("{}\n", ans)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 6396
n = input()
k = int(input())
keta = len(n)
ans = 0


dp = [[[0] * 2 for i in range(4)] for i in range(keta + 1)]
dp[0][0][0] = 1

for i in range(keta):
    # 同じ -> 同じ
    if n[i] == "0":
        for j in range(4):
            dp[i + 1][j][0] += dp[i][j][0]
    else:
        for j in range(3):
            dp[i + 1][j + 1][0] += dp[i][j][0]
    
    # 同じ -> 違う
    for ii in range(int(n[i])):
        if ii == 0:
            for j in range(4):
                dp[i + 1][j][1] += dp[i][j][0]
        else:
            for j in range(3):
                dp[i + 1][j + 1][1] += dp[i][j][0]
    # 違う -> 違う
    for ii in range(10):
        if ii == 0:
            for j in range(4):
                dp[i + 1][j][1] += dp[i][j][1]
        else:
            for j in range(3):
                dp[i + 1][j + 1][1] += dp[i][j][1]
print(sum(dp[keta][k]))

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

    int n,m;
    cin >> n >> m;
    if (n==m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test   ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    io ; 
    char ch ; cin>>ch ; 
    if( int(ch)>=65 and int(ch)<=90){
        cout<<"A\n" ; 
    }else{
        cout<<"a" ; 
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 int main() {
   string A;
   cin >>A;
   string B;
   cin >>B;
   int a;
   cin >>a;
   int b;
   cin >>b;
   string c;
   cin >>c;
   if (c==A) {
     a--;
   }
   else if (c==B) {
     b--;
   }
   cout <<a <<" "<< b<<endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    long x, t;
    cin >> x >> t;
    cout << max(0L, x-t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  int ans =0;
  int len = 1;
  vector<int>a(n);
  for(int i= 0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      len++;
    }
    else{
      ans +=len/2;
      len= 1;
    }
    if(i == n-2){
      ans +=len/2;
    }
  }
  cout <<ans;
    
}

Measured memory_bytes: 256
class Gate
  attr_reader :left, :right

  def initialize(left, right)
    @left, @right = left, right
  end

  def &(other)
    Gate.new([@left, other.left].max, [@right, other.right].min)
  end

  def size
    [@right - @left + 1, 0].max
  end
end

def prison(n, params)
  (params.map { |l, r| Gate.new(l, r) }.inject { |a, b| a & b } & Gate.new(1, n)).size
end

n, m = gets.split.map(&:to_i)
params = []
m.times{ params << gets.split.map(&:to_i) }

puts prison(n, params)

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

const int N = (int)1e5;

int dat[2*N + 5];

int main() {
    for (int i=0; i<2*N+3; i++) dat[i] = 0;

    int n; scanf("%d", &n);
    for (int i=1; i<=n; i++) {
        int a; scanf("%d", &a);
        dat[N + a - 1] += 1;
        dat[N + a] += 1;
        dat[N + a + 1] += 1;
    }

    int res = N-1;
    for (int i=N-1; i<=N+N; i++) {
        if (dat[i] > dat[res]) res = i;
    }

    printf("%d\n", dat[res]);
    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
int dx,dy;
void f(){
  swap(dx,dy);
  dx*=-1;
}
  

int main(){
  
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  dx=x2-x1;dy=y2-y1;
  f();
  int x3=x2+dx,y3=y2+dy;
  f();
  int x4=x3+dx,y4=y3+dy;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
}
    
    
  

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

	public final static String YES = "YES";
	public final static String NO = "NO";

	public static void main(String[] args) {

		Main myself = new Main();
		myself.execute();

	}

	/**
	 * 実処理メソッド
	 */
	public void execute() {

		final List<String> lines = readStdin();

		final InputData inputData = parse(lines);

		System.out.print(inputData.isSameOnRotateing180() ? YES : NO);

	}

	/**
	 * @return
	 */
	private List<String> readStdin() {
		List<String> lines = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)).lines()
				.collect(Collectors.toList());
		return lines;
	}

	/**
	 * @param inputlines
	 * @return
	 */
	private InputData parse(List<String> inputlines) {

		InputData data = new InputData();

		String firstLine = inputlines.get(0);
		String secondLine = inputlines.get(1);

		data.c11 = firstLine.charAt(0);
		data.c12 = firstLine.charAt(1);
		data.c13 = firstLine.charAt(2);

		data.c21 = secondLine.charAt(0);
		data.c22 = secondLine.charAt(1);
		data.c23 = secondLine.charAt(2);

		return data;
	}

	/**
	 * 
	 *
	 */
	private class InputData implements Serializable {

		/**
		 * 
		 */
		private static final long serialVersionUID = -6938809350516466787L;

		/**
		 * 
		 */
		public char c11;

		/**
		 * 
		 */
		public char c12;

		/**
		 * 
		 */
		public char c13;

		/**
		 * 
		 */
		public char c21;

		/**
		 * 
		 */
		public char c22;

		/**
		 * 
		 */
		public char c23;

		/*
		 * (non-Javadoc)
		 * 
		 * @see java.lang.Object#toString()
		 */
		public boolean isSameOnRotateing180() {

			return c11 == c23 && c12 == c22 && c13 == c21;
		}

	}

}


Measured memory_bytes: 26708
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int N, M;
map<pair<int, int>, int> m;
vector<vector<int> > v;

int main()
{
    cin >> N >> M;
    v.resize(N);

    int s = N;

    for (int i = 0; i < M;i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        s = min(s, a);
        if (a > b)
        {
            swap(a, b);
        }
        v[a].push_back(b);
        v[b].push_back(a);
        m[make_pair(a, b)]++;
        
    }

    int cnt = 0;
    int start = s;
    int end;

    while(cnt < M)
    {
        bool flag = false;
        for (int i = 0;i <  v[s].size(); i++)
        {
            int t = v[s][i];
            int t1, t2;
            if(s > t)
            {
                t1 = t;
                t2 = s;
            }
            else
            {
                t1 = s;
                t2 = t;
            }
            auto e = make_pair(t1, t2);
            //cout << "t1:" << t1 << " t2:" << t2 << endl;
            if (m.find(e) == m.end())
            {
                continue;
            }
            if(m[e] == 0)
            {
                continue;
            }
            flag = true;
            //cout << s << "->" << t << endl;

            s = t;
            m[e]--;
            cnt++;
            break;
        }
        if(flag == false)
        {
            if(s == start)
            {
                s++;
                start = s;
            }
            else
            {
                break;
            }
        }
    }
    end = s;

    if(cnt == M && start == end)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 10112
A,B,K=input().split(" ")
A=int(A)
B=int(B)
K=int(K)

if K>=A:

    K-=A
    A = 0
    if K>=0:
        B=max(0,B-K)
else:
    A=max(0,A-K)
print(A,B)

Measured memory_bytes: 2940
N, X = input().split()
N = int(N)
X = int(X)

l = list(map(int, input().split()))

sum_lst = list()
sum_lst.append(0)
for i in range(0, len(l)):
    sum_lst.append(sum_lst[i]+l[i])

cnt = 0
for i in range(0, len(sum_lst)):
    if sum_lst[i] <= X:
        cnt += 1
    else:
        break

print(cnt)

Measured memory_bytes: 3064
import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   ans = 0
   if i + l > L:
      continue
   for j in range(l):
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Measured memory_bytes: 93116
H, W, M = map(int, input().split())
R = [0]*H #各行にある爆弾の個数
C = [0]*W #各列にある爆弾の個数
bombs = []
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    R[h] += 1
    C[w] += 1
    bombs.append((h, w))

R_max = max(R)
C_max = max(C)

### Rが最大かつCが最大な座標であって、
# そこに爆弾がない場合があれば
# 答えがR_max+C_max
# なければR_max+C_max-1
count = 0 # 爆弾がある座標であって、Rが最大かつCが最大の組の個数
for bx, by in bombs:
    if R[bx] == R_max and C[by] == C_max:
        count += 1

count_R = R.count(R_max)
count_C = C.count(C_max)
if count >= count_R*count_C:
    ans = R_max + C_max - 1
else:
    ans = R_max + C_max
print(ans)

Measured memory_bytes: 110140
N = int(input())
ans = 0
if N % 2 == 1:
    pass
else:
    two = 0
    five = 0
    tmp = 2
    while tmp <= N:
        two += N // tmp
        tmp *= 2
    tmp = 10
    while tmp <= N:
        five += N // tmp
        tmp *= 5
    ans = min(two, five)
print(ans)

Measured memory_bytes: 9184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        boolean approved = true;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 == 0) {
                if (!(a % 3 == 0) && !(a % 5 == 0)) {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 21844
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double calc(int[] a) {
    a.sort();
    double ans = a[0];
    for (int i = 1; i < a.length; i++) {
        ans = (ans + a[i]) / 2;
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int ones[100'000];
int zeros[100'000];
int oacc[100'000];
int zacc[100'000];

int main()
{
    int n, k;
    string s;

    cin >> n >> k;
    cin >> s;

    int onum = 0;
    int znum = 0;

    bool prev_is_zero = false;
    onum++;
    ones[0] = 0;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == '0')
        {
            if (!prev_is_zero)
            {
                znum++;
            }
            zeros[znum - 1]++;
            prev_is_zero = true;
        }
        else
        {
            if (prev_is_zero)
            {
                onum++;
            }
            ones[onum - 1]++;
            prev_is_zero = false;
        }
    }
    if (prev_is_zero)
    {
        onum++;
        ones[onum - 1] = 0;
        prev_is_zero = false;
    }

    int oa = 0;
    for (int i = 0; i < onum; i++)
    {
        oa += ones[i];
        oacc[i] = oa;
    }
    int za = 0;
    for (int i = 0; i < znum; i++)
    {
        za += zeros[i];
        zacc[i] = za;
    }

    k = min(k, znum);
    int msigma = 0;
    for (int i = 0; i < znum - k + 1; i++)
    {
        const int osum = oacc[i + k + 1 - 1] - oacc[i] + ones[i];
        const int zsum = k == 0 ? 0 : zacc[i + k - 1] - zacc[i] + zeros[i];
        const int sigma = osum + zsum;

        msigma = max(msigma, sigma);
    }

    cout << msigma << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<string>
#include<cstdio>
#include<cctype>
#include<iostream>
#include <algorithm>
#include<cmath>
#include<queue>
using namespace std;

int main(){
    int n,a,cut=0;
    string ring, f;
    cin >>f>>n;
    for(int i=0;i<n;i++){
        a=0;
        cin >>ring;
        ring += ring;
        int a = ring.find(f);
        if(a>=0)cut++;
    }
    cout <<cut<<endl;
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int MOD = 998244353;
int tree[222'222];
void update(int idx, int val)
{
    while(idx < 222'222)
    {
        tree[idx] = (tree[idx] + val)%MOD;
        idx += idx & -idx;
    }
}
int sum(int idx)
{
    int ret = 0;
    while(idx > 0)
    {
        ret += tree[idx];
        idx -= idx & -idx;
        ret %= MOD;
    }
    return ret;
}

int n, k;
vector<pair<int, int>> v;
int qry(int idx)
{
    int ret = 0;
    for(auto& it: v)
    {
        int l = it.x;
        int r = it.y;
        ret += sum(max(idx - l, 0LL)) - sum(max(0LL, idx - r -1));
        ret %=MOD;
        ret +=MOD;
        ret %=MOD;
    }
    //debug(idx, ret);
    return ret;
}
void solve()
{
    update(1, 1);

    cin>>n>>k;
    v.resize(k);
    forn(i, k)
    {
        int l, r; cin>>l>>r;
        v[i].x = l;
        v[i].y = r;
    }

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

           // forn(i, n+1) cout << sum(i) - sum(i-1) << '\n';
            //cout << endl;
            update(j, qry(j));
        }


    //forn(i, n+1) cout << sum(i) - sum(i-1) << '\n';
    cout<< (sum(n) - sum(n-1)+MOD)%MOD << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << '\n';
        solve();
    }
    return 0;
}


Measured memory_bytes: 5188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i=0; i<M; i++)
        cin >> B[i];

    vector<vector<int>> A(N, vector<int>(M));
    for(int i=0; i<N; i++)
        for(int j=0; j<M; j++)
            cin >> A[i][j];

    int ans = 0;
    for(int i=0; i<N; i++){
        int tmp = C;
        for(int j=0; j<M; j++)
            tmp += A[i][j] * B[j];
        if(tmp > 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())
check = [False] * (10**5 + 10)
check_list = [x]
a = x
# ループを見つける
for i in range(n):
    a = (a * a) % m
    if check[a]:
        break
    check[a] = True
    check_list.append(a)

# ループの長さを算出
index = check_list.index(a)
# ループはいる前のやつ
roop_bef = check_list[0:index]
# ループのやつ
roop = check_list[index:]
# print(roop_bef, roop)

# ループが何周あるのかと，ループ終わりがいくつ要素あるかを計算
roop_num = (n - len(roop_bef)) // len(roop)
roop_after_num = (n - len(roop_bef)) % len(roop)

# ループ前+ループのsum*ループ数+ループ後のsumが答え
ans = sum(roop_bef) + sum(roop) * roop_num + sum(roop[:roop_after_num])

print(ans)


Measured memory_bytes: 12364