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

using namespace std;

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	
	if (a > b) {
		cout << "Alice" << endl;
	} else if (a < b) {
		cout << "Bob" << endl;
	} else {
		cout << "Draw" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
 
int main(){
  ll n;
  cin>>n;
  
  ll ans;
  ans=n+n*n+n*n*n;
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int yzd = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }

int n, m, s, t, u, v, c;
struct tt {int to, next, cost; }edge[(N<<2)+5];
int path[N+5], top;
int ans1[N+5], ans2[N+5], vis[N+5], in[N+5];
LL dist1[N+5], dist2[N+5];
queue<int>Q;
vector<int>to[N+5];

void add(int u, int v, int c) {
    edge[++top].to = v, edge[top].cost = c, edge[top].next = path[u], path[u] = top;
}
void SPFA(int s, LL *dist) {
    dist[s] = 0; Q.push(s); vis[s] = 1;
    while (!Q.empty()) {
    int u = Q.front(); Q.pop(); vis[u] = 0;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] > dist[u]+edge[i].cost) {
        dist[edge[i].to] = dist[u]+edge[i].cost;
        if (!vis[edge[i].to]) {
            vis[edge[i].to] = 1; Q.push(edge[i].to);
        }
        }
    }
}
void topsort(int s, LL *dist, int *ans) {
    for (int u = 1; u <= n; u++) {
    to[u].clear();
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] == dist[u]+edge[i].cost) to[u].push_back(edge[i].to), ++in[edge[i].to];
    }
    ans[s] = 1; Q.push(s);
    while (!Q.empty()) {
    int u = Q.front(), size = to[u].size(); Q.pop();
    for (int i = 0; i < size; i++) {
        if (--in[to[u][i]] == 0) Q.push(to[u][i]); (ans[to[u][i]] += ans[u]) %= yzd;
    }
    }
}
void work() {
    read(n), read(m), read(s), read(t);
    for (int i = 1; i <= m; i++) {
    read(u), read(v), read(c); add(u, v, c); add(v, u, c);
    }
    memset(dist1, 127/3, sizeof(dist1));
    SPFA(s, dist1); topsort(s, dist1, ans1);
    memset(dist2, 127/3, sizeof(dist2));
    SPFA(t, dist2); topsort(t, dist2, ans2);
    int ans = 1ll*ans1[t]*ans1[t]%yzd;
    for (int u = 1; u <= n; u++) {
    if (dist1[u] == dist2[u] && dist2[u]*2 == dist1[t]) (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[u]%yzd*ans2[u]%yzd) %= yzd;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist1[u]+edge[i].cost+dist2[edge[i].to] == dist1[t] && dist1[u]*2 < dist1[t] && dist2[edge[i].to]*2 < dist1[t])
        (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[edge[i].to]%yzd*ans2[edge[i].to]%yzd) %= yzd;
    }
    writeln((ans+yzd)%yzd);
}
int main() {
    work();
    return 0;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  while (cin>>n) {
    if (!n) {
      break;
    }
    int ans=0;
    int cnt=0;
    while (cnt++<n/4) {
      int num;
      cin>>num;
      ans+=num;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3084
ZERO_B=Float::INFINITY
z=0
h={}
n=gets.to_i
n.times do
    a, b=gets.split.map(&:to_i)
    if a==0 and b==0
        z+=1
    else
        h[ab=b==0 ? ZERO_B : Rational(a, b)]||=0
        h[ab]+=1
    end
end

MOD=10**9+7
res=1
h.each do |k, v|
    x=k.zero? ? ZERO_B : -1/k
    x=0.to_r if k==ZERO_B

    w=h[x]||0
    res*=2.pow(v, MOD)+2.pow(w, MOD)-1
    res%=MOD

    h[k]=0
    h[x]&&=0
end
puts (res+z+MOD-1)%MOD


Measured memory_bytes: 34780
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;

    map<string, int> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}


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

using namespace std;

#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)

const ll MAXN=1e5+5;

ll h[MAXN],N,A,B;

namespace solution{
	bool ok(ll c){
		ll cnt=0;
		up(i,1,N)cnt+=(max(h[i]-c*B,0LL)+A-B-1)/(A-B);
		return cnt<=c;
	}
	void Prepare(){
		scanf("%lld%lld%lld",&N,&A,&B);
		up(i,1,N)scanf("%lld",&h[i]);
	}
	void Solve(){
		ll le=0,ri=1e9,mi;
		while(le+1<ri){
			mi=(le+ri)>>1;
			if(ok(mi))	ri=mi;
			else 		le=mi;
		}
		cout<<(ok(le)?le:ri)<<endl;
	}
}

int main(){
	//freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    struct edge{int to,cost;};
    vector<vector<edge>> G(K);
    for (int i=0;i<K;++i){
        G[i].emplace_back(edge{(i+1)%K,1});
        G[i].emplace_back(edge{i*10%K,0});
    }
    deque<int> dq;
    vector<int> dist(K,INF);
    dist[1]=1; dq.emplace_back(1);
    while(!dq.empty()){
        int v=dq.front(); dq.pop_front();
        for (auto e:G[v]){
            int u=e.to,c=e.cost;
            if (dist[v]+c<dist[u]){
                dist[u]=dist[v]+c;
                if (c) dq.push_back(u);
                else dq.push_front(u);
            }
        }
    }
    cout << dist[0] << endl;
}

Measured memory_bytes: 6272
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        int w = 0;
        int h = 0;
        while (H != 0 && W != 0) {
            while (h < H) {
                while (w < W) {
                    if (w == (W - 1)) {
                        System.out.println("#");
                    } else if (h == 0 || h == (H - 1)) {
                        System.out.print("#");
                    } else {
                        if (w == 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    w++;
                }
                h++;
                w = 0;
            }
            w = 0;
            h = 0;
            H = scan.nextInt();
            W = scan.nextInt();
            System.out.println();
        }
    }
}


Measured memory_bytes: 35828
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n, maxx = 0, minn = 233333333, cnt = 0;
	cin >> n;
	for (int i = 1, x; i <= n; ++i)
	{
		cin >> x;
		if (x < minn)
			cnt = 0;
		maxx = max(maxx, x);
		minn = min(minn, x);
		if (x == minn)
			cnt++;
	}
	if (maxx - minn > 1)
		cout << "No";
	else if (maxx == minn)
		cout << ((maxx == n - 1 || maxx <= (n >> 1)) ? "Yes" : "No");
	else
		cout << ((cnt < maxx && maxx <= (cnt + ((n - cnt) >> 1))) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static char[][] field;
	static int h;
	static int w;
	static long B=0;
	static long W=0;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		long ans=0; 

		field = new char[h][];
		for (int i = 0; i < h; i++) {
			field[i] = sc.next().toCharArray();
		}
		for(int col=0;col<h;col++) {
			for(int row=0;row<w;row++) {
				if(field[col][row]=='.') {
					serchW(col,row);
				}else if(field[col][row]=='#') {
					serchB(col,row);
				}
				ans=ans+B*W;
				B=0;
				W=0;
			}
		}
		System.out.print(ans); 
		
	}

	public static void serchB(int col, int row) {
		B++;
		field[col][row]='!';
	if(col+1<h)if(field[col+1][row]=='.') {serchW(col+1,row);}
	if(row+1<w)if(field[col][row+1]=='.') {serchW(col,row+1);}
	if(col-1>=0)if(field[col-1][row]=='.') {serchW(col-1,row);}
	if(row-1>=0)if(field[col][row-1]=='.') {serchW(col,row-1);}	
	}
	
	public static void serchW(int col, int row) {
		W++;
		field[col][row]='!';
		if(col+1<h)if(field[col+1][row]=='#') {serchB(col+1,row);}
		if(row+1<w)if(field[col][row+1]=='#') {serchB(col,row+1);}
		if(col-1>=0)if(field[col-1][row]=='#') {serchB(col-1,row);}
		if(row-1>=0)if(field[col][row-1]=='#') {serchB(col,row-1);}	
			
	}
	
}



Measured memory_bytes: 40704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, long[] A)
        {
            var k1 = new int[N];
            var k2 = new int[N];
            for (int i = 0; i < N; ++i)
            {
                var k = (i == 0 || i == N - 1) ? 1 : 2;
                if (i % 2 == 0)
                {
                    k1[i] = -k;
                    k2[i] =  k;
                }
                else
                {
                    k1[i] =  k;
                    k2[i] = -k;
                }
            }
            Array.Sort(k1);
            Array.Sort(k2);
            Array.Sort(A);
            long sum1 = 0;
            long sum2 = 0;
            for (int i = 0; i < N; ++i)
            {
                sum1 += A[i] * k1[i];
                sum2 += A[i] * k2[i];
            }
            return Math.Max(sum1, sum2);
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var A = new long[N];
            for (int i = 0; i < N; ++i) { A[i] = ReadLong(); }
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 18780
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int a, b; cin >> a >> b;
    int h[a][b];
    for(int i=0; i<a; i++){
        for(int j=0; j<b; j++){
            cin >> h[i][j];
        }
    }
    int ans1=0, ans2=0;
    for(int i=0; i<a; i++){
        for(int j=0; j<b; j++){
            cout << h[i][j] << " ";
            ans1 += h[i][j];
        }
        cout << ans1 << endl;
        ans1 =0;
    }
    int g=0;
    for(int j=0; j<b; j++){
        for(int i=0; i<a; i++){
            ans2 += h[i][j];
        }
        cout << ans2 << " ";
        g += ans2;
        ans2 =0;
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<string.h>

int alp[30];

int main()
{
	char s[105000];
	scanf("%s", s);

	for (int i = 0; i < strlen(s) ; i++) {
		alp[s[i] - 'a']++;
	}
	int ope = 0;
	for (int i = 0; i < 26; i++) {
		if (alp[i] == 0) {
			char b;
			b = 'a' + i;
			printf("%c\n", b);
			ope++;
			break;
		}
	}
	if (ope == 0)printf("None\n");

	return 0;
}


Measured memory_bytes: 256
def main():
    from math import floor, log10

    N = int(input())

    def G(x):
        return floor(log10(x)) + 1

    def F(a, b):
        return max(map(G, (a, b)))

    st = [F(1, N)]
    d = 2
    while d * d <= N:
        if N % d == 0:
            st.append(F(d, N // d))  # (d, N // d)
        d += 1

    print(min(st))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#pragma GCC Optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define lp(i,begin,end) for (int i=begin;i<end;i++)
const int N=30,M=N*N,OO=0x3f3f3f3f;
int n,avg,arr[55];  ll mem[55][2555][55];
ll solve(int idx,int sum,int noe){
    //cout<<idx<<" "<<sum<<" "<<noe<<endl;
    if(idx==n){
        if(noe==0||sum%noe)return 0;
        if(sum/noe==avg)return 1;
        return 0;
    }
    ll &ret=mem[idx][sum][noe];
    if(~ret)return ret;
    return ret=solve(idx+1,sum,noe)+solve(idx+1,sum+arr[idx],noe+1);
}
int main(){
    scanf("%d%d",&n,&avg);
    lp(i,0,n)scanf("%d",arr+i);
    memset(mem,-1,sizeof mem);
    printf("%lld",solve(0,0,0));
}


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

int f(int x)
{
	return x * x;
}

int main(void)
{
	int n;

	while(cin >> n){
		int s = 0;

		for(int i = 1; i * n < 600; i++)
			s += f(i * n) * n;

		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   string s;
    cin>>n;
    
    map<string,int> m;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  	int N;
	string S;
  	cin >> N;
  	cin >> S;
  	ll ans = 1;
	map<char, ll> m;
    for(int i = 0; i < N; i++){
    	m[S[i]]++;
    }
  	for(auto x: m){
    	ans *= (x.second+1);
      	ans%=MOD;
    }
  	if(N == 0) ans = 0;
  	else ans = ans-1;
  	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  int Max = a[0];
  int maxi = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] > Max) {
      Max = max(Max, a[i]);
      maxi = i;
    }
  }
  int result = Max + b[maxi];
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main() {
 string A, B, C;
 cin >> A;
 cin >> B;
 cin >> C;
    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
       cout << "YES" << endl;
    }
    else{
     cout << "NO" <<endl;
    }
                 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

vector<int> a;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int m, k;
    cin >> m >> k;
    if (k >= (1 << m)){
        cout << "-1" << endl;
        return 0;
    }
    if (k == 0){
        for (int i = 0; i < (1 << m); ++i) cout << i << " " << i << " ";
        return 0;
    }
    a.push_back(k);
    int cur = 0;
    for (int i = 0; i < (1 << m); ++i){
        if (i != k) cur ^= i, a.push_back(i);
    }
    if (cur != k){
        cout << "-1" << endl;
        return 0;
    }
    a.push_back(k);
    for (int i = (1 << m) - 1; i >= 0; --i){
        if (i != k) a.push_back(i);
    }
    for (auto e : a) cout << e << " ";
    return 0;
}


Measured memory_bytes: 2932
num = int(input())
ary = []
ans = 0
for a in range(num):
    ary.append(int(input()))
ary.sort()
ikkomae = ary[0]
count = 1
for a in range(num):
    ind = a + 1
    if ind == num:
        break
    imano = ary[ind]
    if ikkomae == imano:
        count+=1
    else:
        if(count%2==1):
            ans+=1
        count = 1
    ikkomae = imano
if(count%2==1):
    ans+=1
print(ans)
        

Measured memory_bytes: 7388
#include<cstdio>

bool isPrime(int x) {
  int i;
  if (x < 2) {
    return false;
  } else if (x == 2) {
    return true;
  } else if (x % 2 == 0) {
    return false;
  }

  for (i = 3; i * i <= x; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }

  return true;
}

int main(){
  int n, x;
  int cnt = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (isPrime(x)) {
      cnt++;
    }
  }

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

  return 0;
}


Measured memory_bytes: 2732
n = int(input())
s = input()
cnt = 0
W, E = [], []
w, e = 0, 0
for i in range(n):
    W.append(w); E.append(e)
    if s[i] == 'W':
        w += 1
    if s[-i-1] == 'E':
        e += 1
print(min([w+e for (w, e) in zip(W, E[::-1])]))

Measured memory_bytes: 32076
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int m, n;
        cin >> m >> n;
        if (m == 0 and n == 0) {
            break;
        }
        constexpr int MAX = 7368791;
        vector<bool> ok(MAX + 1, false);
        int plant = 0;
        for (int i = m; i <= MAX; i++) {
            if (not ok[i]) {
                if (plant < n) {
                    for (int j = 1; i * j <= MAX; j++) {
                        ok[i * j] = true;
                    }
                    plant++;
                } else {
                    cout << i << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3972
using System;
using System.Collections.Generic;
using System.Linq;


namespace _510_Score
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] scores = Console.ReadLine ().Trim ().Split (' ').Select (x => int.Parse (x)).ToArray ();
			int[] scores2 = Console.ReadLine ().Trim ().Split (' ').Select (x => int.Parse (x)).ToArray ();

			int max = Math.Max (scores.Sum (), scores2.Sum ());

			Console.WriteLine (max);
		}
	}
}

Measured memory_bytes: 9520
#include <iostream>
using namespace std;
int main(void){
    int n,a,b;
    string s;
    int insuccess = 0;
    int outsuccess = 0;
    
    cin >> n >> a >> b;
    cin >> s;
    
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'c'){
            cout << "No" << endl;
        }else if(s[i] == 'a'){
            if(insuccess+outsuccess < a + b){
                insuccess++;
                cout << "Yes" << endl;
            }else {
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(insuccess + outsuccess < a + b && outsuccess < b){
                outsuccess++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }
    
}

Measured memory_bytes: 896
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,x = I()
ca = (a-1)//x
cb = b//x
ans += cb-ca
print(ans)


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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


long long totient(long long a) {
	ll ret = a;
	for(int i = 2;i * i <= a;i++){
		if(a % i == 0){
			ret = ret * (i - 1) / i;
			while(a % i == 0)a /= i;
		}
	}
	if(a > 1)ret = ret * (a - 1) / a;
	return ret;
}

// a / b (mod p) b と p は互いに素
// O(sqrt(p))かかるので注意
long long totient_div(long long a, long long b, long long p) {
	long long ret = a;
	long long tp = totient(p) - 1;
	long long c = b;
	for(int i = 0;i <= 60;i++){
		if(tp & (1LL << i))ret = (ret * c) % p;
		c = (c * c) % p;
	}
	return ret;
}

//a^b % MOD
long long modpow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}


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


Measured memory_bytes: 2816
{AT3599}
var
n,k,i,s:longint;
function min(x,y:longint):longint;
 begin
 if x<y then
 exit(x)
 else
 exit(y);
 end;
begin
read(n,k);
s:=1;
for i:=1 to n do
inc(s,min(s,k));
writeln(s);
end.

Measured memory_bytes: 128
while True:
    n=list(map(int,input().split()))
    a=n[0] 
    b=n[1]
    if a == 0 and b == 0:
        break
    for i in range(a):
        if i == 0:
            for j in range(b):
                print("#",end="")
        elif i == a-1:
            for j in range(b):
                print("#",end="")
        else:
            print("#",end="")
            for j in range(b-2):
                print(".",end="")
            print("#",end="")
        print()
    print()


Measured memory_bytes: 7000
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1e6+10;
ll a[N];
int n;
int main() {
	cin>>n;
	for(int i = 1;i <= n;i++) {
		int x;
		cin>>x;
		a[i] = (a[i - 1] + x) % mod;
	}
	ll ans = 0;
	for(int i = 1;i < n;i++) {
		ll tmp = (a[n] - a[i] + mod) % mod;
		ans = (ans + (a[i] - a[i - 1] + mod) % mod * tmp % mod) % mod;
	}
	cout<<ans;
	return 0;
}

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

long n,m,q,ans=0;
vector<long> a(50);
vector<long> b(50);
vector<long> c(50);
vector<long> d(50);

void zentansaku(vector<long> x) {
  if(x.size()-1==n) {
    long score=0;
    for(long i=0;i<q;i++) {
      if(x[b[i]]-x[a[i]]==c[i]) score+=d[i];
    }
    ans=max(ans,score);
    return;
  }
  for(long i=x.back();i<=m;i++){
    vector<long> y=x;
    y.push_back(i);
    zentansaku(y);
  }
  return;
}

int main() {
  cin >> n >> m >> q;
  for(long i=0;i<q;i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  zentansaku({1});
  cout << ans << endl;
}

Measured memory_bytes: 3640
miar = Array.new

n, x = gets.chomp!.split(" ").map(&:to_i)

n.times do
  mi = gets.chomp.to_i
  x -= mi
  miar.push(mi)
end

min = miar.min
count = miar.size

while x >= min
  x -= min
  count += 1
end

p count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

double a,b,s;

int main(){
	cin>>a>>b>>s;
	s/=a;
	cout<<syosu(9);
	if(s<=a*b/2){
		cout<<90-atan(2*s/b/b)*180/pi<<endl;
	}
	else{
		cout<<atan(2*(a*b-s)/a/a)*180/pi<<endl;
	}
}

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

typedef long long ll;
typedef pair<ll, ll> Pll;

int main() {
    int N; cin >> N;
    vector<Pll> BA(N);
    for (int i = 0; i < N; i++) {
        cin >> BA[i].second;
        cin >> BA[i].first;
    }
    sort(BA.begin(), BA.end(), less<Pll>());
    ll time = 0;
    for (int i = 0; i < N; i++) {
        time += BA[i].second;
        if (time > BA[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Jan 27 21:03:49 2019
//
package main

import "fmt"

func main() {
	var N int
	var A, B, C string
	fmt.Scan(&N, &A, &B, &C)

	ans := 0
	for i := 0; i < N; i++ {
		if A[i] == B[i] && B[i] == C[i] {
			ans += 0
		} else if A[i] == B[i] || B[i] == C[i] || C[i] == A[i] {
			ans++
		} else {
			ans += 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
from collections import deque
from itertools import chain
INF = 10**18 
H, W = map(int, input().split())
S = [input() for _ in range(H)]
def main():
    max_num = 0
    for sy in range(H):
        for sx in range(W):
            if S[sy][sx] == "#":
                continue
            m = check_max_route(sx, sy)
            max_num = max(max_num, m)
    print(max_num)
    
def check_max_route(x,y):
    state=[[INF for _ in range(W)] for _ in range(H)]
    state[y][x]=0
    q = deque([(x, y)])
    while q:
        tx, ty = q.popleft()
        tr = state[ty][tx]
        for dx, dy in [(0, 1), (1, 0), (0, -1), (-1, 0)]:
            x, y = tx+dx, ty+dy
            if not (0 <= x < W and 0 <= y < H):
                continue
            if S[y][x] == "#":
                continue
            if state[y][x] <= tr+1:
                continue
            state[y][x] = tr+1
            q.append((x, y))
    m = max([x for x in chain(*state) if x != INF])
    return m    
main()

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n == 100) {
            cout << 101 << endl;
        } else {
            cout << n << endl;
        }
    } else {
        if (n == 100) {
            cout << n + 1;
        } else {
            cout << n;
        }
        cout << "00";
        if (d == 2) cout << "00" << endl;
    }
}


Measured memory_bytes: 3580
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int S = scanner.nextInt();
		
		int h = S / 3600;
		int m = S % 3600 / 60;
		int s = S % 3600 % 60;

		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26372
import sys


def main():
    n_list = [int(s) for s in sys.stdin.readline().strip().split()]
    n = n_list[0]
    p = [int(s) for s in sys.stdin.readline().strip().split()]
    sorted_p = sorted(p)
    diff = 0
    for i in range(n):
        if p[i] != sorted_p[i]:
            diff += 1
    if diff == 0 or diff == 2:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
S = input()
L = list(S)
N = len(L)

revS = list(reversed(L))

preS = L[:int((N - 1) / 2)]
revPreS = list(reversed(preS))

backS = L[int((N + 2) / 2):]
revBackS = list(reversed(backS))

if L != revS:
    print("No")
elif preS != revPreS:
    print("No")
elif backS != revBackS:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}

int main(){
  int n;
  cin >>n;
  vector<ll>x(n);
  vector<ll>p(n);
  rep(i,n){cin>>x[i];p[i]=x[i];}
  sort(p.begin(),p.end());
  rep(i,n){
  	if(x[i]>=p[n/2]){cout<<p[(n/2)-1]<<endl;}
    else{cout<<p[n/2]<<endl;}
  }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(b<a)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1,  0};
constexpr int dy[] = {0, 1,  0, -1};
constexpr char dir[4] = {'r', 'u', 'l', 'd'};
int main() {
	int H, W; cin >> H >> W;
	vv(int, dp, H, W, 0);
	vv(int, G, H, W, 0);
	rep(i, 0, H) rep(j, 0, W) cin >> G[i][j];
	rep(x, 0, H) dp[x][0] = (G[x][0] == 0 ? 1 : 0);
	rep(y, 0, W) dp[0][y] = (G[0][y] == 0 ? 1 : 0);
	rep(i, 1, H) {
		rep(j, 1, W) {
			if(!G[i][j]) {
				dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
			}
		}
	}
	vi maxWidth(H);
	rep(i, 0, H) maxWidth[i] = *max_element(all(dp[i]));
	P((int)pow(*max_element(all(maxWidth)), 2));
	return 0;
}

Measured memory_bytes: 18356
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1e10;
long long dp[100010];

int main() {
    int N; cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h.at(i);
    
    rep(i, 100010) dp[i] = INF;
    dp[0] = 0;

    rep(i, N){
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 4568
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] ary = new int[N * 3];
        
        long[] f_sum = new long[N + 1];
        long[] r_sum = new long[N + 1];
        
        for(int i = 0; i < N * 3; i++){
            ary[i] = in.nextInt();
        }
        
        long ans = -1000000000000000000l;
        
        PriorityQueue<Integer> f_queue = new PriorityQueue<>();
        PriorityQueue<Integer> r_queue = new PriorityQueue<>();
        
        for(int i = 0; i < N; i++){
            //front
            f_queue.add(ary[i]);
            f_sum[0] += ary[i];
            
            //rear
            r_queue.add(-ary[3*N - 1 - i]);
            r_sum[N] += ary[3*N - 1 - i];
        }
        for(int i = 0; i < N; i++){
            //front
            f_queue.add(ary[N + i]);
            f_sum[i + 1] += f_sum[i] + ary[N + i];
            int top = f_queue.poll();
            f_sum[i + 1] -= top;
            
            //rear
            r_queue.add(-ary[2 * N - i - 1]);
            r_sum[N - i - 1] += r_sum[N - i] + ary[2 * N - i - 1];
            r_sum[N - i - 1] -= -r_queue.poll();
        }
        
        for(int i = 0; i < N + 1; i++){
            if(ans < f_sum[i] - r_sum[i]){
                ans = f_sum[i] - r_sum[i];
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 98012
#include<iostream>
#include<algorithm>
#include<cstdio>
int main(){
    int n;
    std::cin >> n;
    
    int temp_max = -10000000;
    int temp_min = 10000000;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        temp_max = std::max(temp_max, a);
        temp_min = std::min(temp_min, a);
        sum += a;
    }
    printf("%d %d %ld\n", temp_min, temp_max, sum);
    return 0;


}


Measured memory_bytes: 3164
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll x;
    cin>>x;
    //a>0, b>0
    for(ll a=1;a<=200;a++){
        for(ll b=a-1;b>=1;b--){
            if(pow(a,5)-pow(b,5)==x){
                cout<<a<<' '<<b;
                return 0;
            }
        }
    }
    //a>0,b=0
    for(ll a=1;a<=100;a++){
        if(pow(a,5)==x){
            cout<<a<<' '<<'0';
            return 0;
        }
    }
    //a>0,b<0
    for(ll a=1;a<=100;a++){
        for(ll b=a-1;b>=1;b--){
            if(pow(a,5)-pow((-b),5)==x){
                cout<<a<<' '<<(-b);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K,S; cin >> N >> K >> S;
    vector<int> A(N,S-1);
    rep (i,K) A[i] = S;
    if (S==1) {
        for (int i = K; i < N; i++) A[i] = 2;
    }
    if (S==2) {
        for (int i = K; i < N; i++) A[i] = 3;
    }

    rep(i,N) cout << A[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);

        int x=stdIn.nextInt(); //羊
        int y=stdIn.nextInt(); //狼

        if(x>y){
            System.out.println("safe");
            
        }
        else{
            System.out.println("unsafe");
            
        }
        
    }

}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	forn(i, n) cin >> a[i];
	int mx = 0;
	for(int i = 0; i+1 < n; i++) {
		mx = max(mx, a[i+1]-a[i]);
	}
	cout << k-max(k-a[n-1]+a[0], mx) << endl;
	return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string board[55];
li h, w;

li dx[] = { -1, 0, 1, -1, 1, -1, 0, 1};
li dy[] = { -1, -1, -1, 0, 0, 1, 1, 1};

inline li count(li y, li x) {
    li res = 0;
    rep(i, 8) {
        li ny = y + dy[i];
        li nx = x + dx[i];
        if (min(ny, nx) < 0 || ny >= h || nx >= w)continue;
        if (board[ny][nx] == '#')++res;
    }
    return res;
}

int main() {
    cin >> h >> w;
    rep(i, h)cin >> board[i];
    rep(i, h) {
        rep(j, w) {
            if (board[i][j] == '.') {
                board[i][j] = count(i, j) + '0';
            }
        }
    }

    rep(i, h)cout << board[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535

int main() {
    fastio;
    ll n;
    cin>>n;
    ll dp[n][3];
    MSET(dp, 0);
    for(ll i=0;i<n;i++) {
        cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
    }
    for(ll i=1;i<n;i++) {
        dp[i][0] = dp[i][0] + max( dp[i-1][1], dp[i-1][2]);
        dp[i][1] = dp[i][1] + max( dp[i-1][0], dp[i-1][2]);
        dp[i][2] = dp[i][2] + max( dp[i-1][0], dp[i-1][1]);
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!

posi_size = posi.size
nega_size = nega.size

zero_pairs = zeros * (zeros - 1) / 2 + zeros * (N - zeros)

ng = -(10**18 + 1)
ok = 10**18 + 1

ans = (ng..ok).bsearch do |mid|
  
  cnt = 0
  
  cnt += zero_pairs if mid >= 0

  if mid > 0
    cnt += nega_size * posi_size
    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        r -= 1 while l < r && a[l] * a[r] > mid
        cnt += r - l
        l += 1
      end
    end
  else
    r = nega_size - 1
    posi.size.times do |l|
      r -= 1 while(r >= 0 && posi[l] * nega[r] <= mid)
      cnt += nega_size - r - 1
    end
  end

  cnt >= K
end

puts ans

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

int main()
{
    int ct=0;
    char a[10];
    scanf("%s",&a);

    for(int i=0; i<3; i++)
    {
        if(a[i]=='7')
        {
            printf("Yes\n");
            ct=1;
            break;
        }
    }
    if(ct==0)
        printf("No\n");

    return 0;
}


Measured memory_bytes: 3760
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

numLeafs = A
minNonLeafs = [None for i in range(N + 1)]
maxNonLeafs = [None for i in range(N + 1)]

maxNonLeafs[0] = 1
for i in range(1, N + 1):
    maxNonLeafs[i] = 2 * maxNonLeafs[i - 1] - numLeafs[i]

minNonLeafs[N] = 0
maxNonLeafs[N] = 0
if minNonLeafs[N] + numLeafs[N] > 2 ** N:
    print(-1)
    exit()

for i in range(N - 1, -1, -1):
    minNonLeafs[i] = (minNonLeafs[i + 1] + numLeafs[i + 1] + 1) // 2
    if minNonLeafs[i] + numLeafs[i] > 2 ** i:
        print(-1)
        exit()
    maxNonLeafs[i] = min(maxNonLeafs[i], maxNonLeafs[i + 1] + numLeafs[i + 1])
    if minNonLeafs[i] > maxNonLeafs[i]:
        print(-1)
        exit()

count = 0
for i in range(N + 1):
    count += maxNonLeafs[i] + numLeafs[i]
print(count)


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

int main(void){
	int a;
	long long int b,n;
	long long int temp;
	long long int ans;

	scanf("%d %lld %lld",&a,&b,&n);
	temp=b-1;
	if(temp>n){
		temp=n;
	}else if(temp==0){
		temp=1;
	}
	ans=floor(a*temp/b)-a*floor(temp/b);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
using namespace std;
int main(void)
{
   int a = 0,b = 0,c;
   for(int i = 0;i < 4;i++)
   {
      scanf("%d",&c);
      a += c;
   }

   for(int i = 0;i < 4;i++)
   {
      scanf("%d",&c);
      b += c;
   }
   if(a>b) printf("%d\n",a);
   else printf("%d\n",b);
   return 0;
}

Measured memory_bytes: 1020
n = int(input())
D = [list(map(int, input().split())) for i in range(n)]

cnt = 0
for i in range(n):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0


print('Yes' if cnt >= 3 else 'No')

Measured memory_bytes: 9180
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	/* X + Y + Z  = S
	 * 0 <= X,Y,Z <= K
	 * 0 <= S <= 3K
	 */
	int K, S;
  	cin >> K >> S;
  	int X, Y, Z, count;
  
	if( (3*K==S) || (S == 0) ) {
     	cout << "1" << endl;
    	return;
    }
	else{
		count = 0;
		int nmax = min(K,S);
		for(X = 0; X<=nmax; X++){
			for(Y = 0; Y<=nmax; Y++){
					Z = S-Y-X;
					if((0<=Z)&&(Z<=K)){ count++; }
			}
		}
    }
	cout << count << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
from collections import Counter


def prime_factorize(n):
    a=[]
    while n%2==0:
        a +=[2]
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a +=[f]
            n //=f
        else:f +=2
    if n!=1:a +=[n]

    return a


n,p=map(int,input().split())
D=Counter(prime_factorize(p))
ans=1
for i,j in D.items():
    ans *=pow(i,j//n)
print(ans)

Measured memory_bytes: 38768
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    bool isOddOk = true;
    bool isEvenOk = true;
    rep(i, S.size()) {
        if(i % 2 == 1) { // even 
            if(S.at(i) == 'R') {
                isOddOk = false;
            }
        } else { // odd
            if(S.at(i) == 'L') {
                isEvenOk = false;
            }
        }
    }

    string ans = (isOddOk && isEvenOk) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596