akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	list := getStdinArr()
	N, _ := strconv.Atoi(list[0])
	M, _ := strconv.ParseFloat(list[1], 64)
	n := N
	m := int(math.Round(M * 100))
	fmt.Printf("%d\n", (n*m)/100)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    ll a, b, m;
    cin >> a >> b >> m;

    vector<long long> vec_a(a);
    ll a_min = INF;
    rep(i, a){
        cin >> vec_a[i];
        a_min = min(a_min, vec_a[i]);
    } 
    vector<long long> vec_b(b);
    ll b_min = INF;
    rep(i, b){
        cin >> vec_b[i];
        b_min = min(b_min, vec_b[i]);
    } 

    ll ans = a_min + b_min;

    vector<ll> x(m);
    vector<ll> y(m);
    vector<ll> c(m);
    rep(i,m){
        cin >> x[i] >> y[i] >> c[i];
        ans = min(ans, vec_a[x[i]-1] + vec_b[y[i]-1] - c[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    ll a,b,c,d;
    cin >> a >> b>> c >> d;
    cout << min(a,b)+min(c,d) << endl;
}

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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		String y = sc.next();
		int z = sc.nextInt();
		int n = sc.nextInt();
		String v = sc.next();
		if (v.equals(x)) {
			z = z - 1;
			System.out.println(z + " " + n);
		} else if (v.equals(y)) {
			n = n - 1;
			System.out.println(z + " " + n);

		}

	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static boolean isIncluded(int inW, int inH, int inX, int inY, int inR) {
        int[] buf;
        buf = new int[4];
        buf[0] = inX + inR;
        buf[1] = inX - inR;
        buf[2] = inY + inR;
        buf[3] = inY - inR;

        if (buf[0] > inW || buf[1] < 0 || buf[2] > inH || buf[3] < 0 ) {
            return false;
        } else {
            return true;
        }

    }

    public static void main(String[] args) {
        int w, h, x, y, r;
        Scanner scan = new Scanner(System.in);
        w = Integer.parseInt(scan.next());
        h = Integer.parseInt(scan.next());
        x = Integer.parseInt(scan.next());
        y = Integer.parseInt(scan.next());
        r = Integer.parseInt(scan.next());

        if (isIncluded(w, h, x, y, r)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    
    set<string> ans;
    bool ok = false;
    irep(i, n-m+1) {
        string s2 = s, u = s.substr(i,m);
        
        bool match = true;
        irep(j, m) {
            if(u[j] != '?' && u[j] != t[j]) {
                match = false;
            }
        }
        if(match) {
            ok = true;
            irep(k, m) {
                s2[i+k] = t[k];
            }
            irep(k, n) {
                if(s2[k] == '?') { s2[k] = 'a'; } 
            }
            ans.insert(s2);
        }
    }
    if(ok) {
        cout << *ans.begin() << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3616
////////////////いろいろあるよ//////////////////////////////////
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream>
 #include<bitset>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////

int main(){
	int A,B;
	cin >> A >> B;
	if(A==B)cout << "Yes" <<endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 998244353;
const int BASE = 27;
const int N = 100002;
const ll oo = 1e18;
const double EPS = 1e-9;

int n;
char tmp[10];
string s[N];

int count(string s){
	int ans = 0;
	for (int i = 0; i+1 < s.size(); ++i){
		if(s[i]=='A'&&s[i+1]=='B')ans++;
	}
	return ans;
}


string ba ="";
string trash = "";

vector<string> ea;
vector<string > eb;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i){
		scanf("%s",tmp);
		s[i] = tmp;
		if(s[i][0]=='B' && s[i][s[i].size()-1] == 'A'){
			ba += s[i];
		}else if(s[i].back() == 'A'){
			ea.push_back(s[i]);
		}else if(s[i][0] == 'B'){
			eb.push_back(s[i]);
		}else{
			trash += s[i];
		}
	}
	string ans = "";
	if(ea.size()){
		ans += ea.back();
		ea.pop_back();
	}
	ans += ba;
	if(eb.size()){
		ans += eb.back();
		eb.pop_back();
	}
	while(ea.size() && eb.size()){
		ans += ea.back();
		ans += eb.back();
		ea.pop_back();
		eb.pop_back();
	}
	while(ea.size()){
		ans += ea.back();
		ea.pop_back();
	}
	while(eb.size()){
		ans += eb.back();
		eb.pop_back();
	}
	ans += trash;
	cout << count(ans) << endl;
	return 0;
}

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


int main() {

  int N,T;
  cin>>N>>T;

  int min_wk=10000;
  for(int i=0;i<N;i++){
    int c,t;
    cin>>c>>t;

    if(t<=T)
      min_wk=min(min_wk,c);
  }

  if(min_wk==10000)
    cout<<"TLE"<<endl;
  else
    cout<<min_wk<<endl;

  return 0;
}




Measured memory_bytes: 3588
def solve(n, t, ab_list):
    a0b_list = [ab[1] for ab in ab_list if ab[0] == 0]
    apb_list = [ab for ab in ab_list if ab[0] > 0]
    a0b_list = sorted(a0b_list)
    apb_list = sorted(apb_list, key=lambda x: - x[0] / (x[1] + 1))
    # DP
    m = len(apb_list)
    dp = [[t + 1] * 30 for _ in range(m + 1)]
    for i in range(m + 1):
        dp[i][0] = 0
    for i in range(m):
        for k in range(1, 30):
            ti = dp[i][k - 1] + 1
            a, b = apb_list[i]
            dp[i + 1][k] = min(dp[i][k], ti + a * ti + b)
    a0b_list_cum_sum = [0]
    s = 0
    for b in a0b_list:
        s += b + 1
        a0b_list_cum_sum.append(s)

    res = 0

    for k in range(len(a0b_list_cum_sum)):
        for p in range(30):
            if dp[m][p] + a0b_list_cum_sum[k] <= t:
                res = max(res, k + p)

    return res


def main():
    n, t = map(int, input().split())
    ab_list = [list(map(int, input().split())) for _ in range(n)]
    res = solve(n, t, ab_list)
    print(res)


def test():
    assert solve(3, 7, [[2, 0], [3, 2], [0, 3]]) == 2
    assert solve(1, 3, [[0, 3]]) == 0
    assert solve(5, 21600, [[2, 14], [3, 22], [1, 3], [1, 10], [1, 9]]) == 5


if __name__ == "__main__":
    test()
    main()


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<VI> r(n+1);
	rep(i, n-1){
		int a, b; cin >>a >>b;
		r[a].push_back(b);
		r[b].push_back(a);
	}
	VI dst(n+1, -1);
	auto f=[&](auto f,int c)->void{
		for(auto v: r[c]) if(dst[v] ==-1){
			dst[v] = (dst[c] + 1) %2;
			f(f, v);
		}
	};
	f(f, 1);
	vector<VI> gk(2), kj(3);
	rep2(i, 1, n+1){
		gk[dst[i]%2].push_back(i);
		kj[i%3].push_back(i);
	}
	
	//for(auto xl: gk){for(auto x :xl) cerr<<x<<":";dbg("gk");}
	//for(auto xl: kj){for(auto x :xl) cerr<<x<<":";dbg("kj");}
	VI ans(n);
	int zz = (sz(gk[0]) < sz(gk[1]))? 0: 1; 
	if(sz(gk[zz]) <= sz(kj[0]) ){
		for(auto v: gk[zz]){
			ans[v-1] = kj[0].back();
			kj[0].pop_back();
		}
	} else {
		for(auto v: gk[zz]){
			if(sz(kj[1]) <=0) break;
			ans[v-1] = kj[1].back();
			kj[1].pop_back();
		}
		for(auto v: gk[zz^1]){
			if(sz(kj[2]) <=0) break;
			ans[v-1] = kj[2].back();
			kj[2].pop_back();
		}
	}
	int j=0;
	for(auto& v: ans){
		if(v > 0) continue;
		while(sz(kj[j]) <1) j++;
		assert(j <=2);
		v = kj[j].back();
		kj[j].pop_back();
	}
	for(auto x :ans) cout<<x<<" "; cout<<"\n";
	return 0;
}


Measured memory_bytes: 17392
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, K; cin >> N >> M >> K;

	set<int>s;
	rep(i, 0, N + 1)rep(j, 0, M + 1) {
		int a(i*(M - j) + j * (N - i));
		dump(a);
		s.insert(i*(M - j) + j * (N - i));
	}
	int f(s.count(K));
	dump(f);
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

#define ok cout<<"ok"<<endl
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back
using namespace std;
	
int main()
{
	int x,y,z;
	cin >> x >> y >> z;
	int ans= (x-z)/(y+z);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
def f(n):
    res = 0
    for d in range(1,51):
        mass = (n // pow(2,d))*pow(2,d-1)
        over = max(n % pow(2,d) - pow(2,d-1),0)
        cnt = mass + over
        if cnt % 2 == 1:
            res += pow(2,d-1)
    return res

ans = f(A)^f(B+1)
print(ans)

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

int main(void){
	int N,sum=0,res=0;
	cin>>N;
	vector<int> s(N);
	rep(i,N)cin>>s[i],sum+=s[i];
	sort(s.begin(), s.end());
	if(sum%10)res=sum;
	else {
		rep(i,N){
			if((sum-s[i])%10){
				res=sum-s[i];
				break;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  int red = 0;
  int blue = 0;
  for(auto c: s){
    if(c=='R') red++;
    else blue++;
  }
  cout << (red>blue ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
//for (auto &x : a) { cin >> x; }
using namespace std;

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

    double d, t, s;
    cin >> d >> t >> s;
    if(d/s <= t){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3740
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    char s[100+5];
    scanf("%d", &n);
    scanf("%s", s);
    
    int ans=0;
    for(int i=1; i<n; i++){
        int cnt=0;
        for(int a='a'; a<='z'; a++){
            int x=0, y=0;
            for(int j=0; j<i; j++){
                if(s[j]==a){
                    x=1;
                    break;
                }
            }
            for(int j=i; j<n; j++){
                if(s[j]==a){
                    y=1;
                    break;
                }
            }
            if(x==1 && y==1)cnt++;
        }
        if(cnt>ans)ans=cnt;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

char s[300][301];
char t[300][301];
int n;
int k = 0;

int f() {
    //for (int i = 0; i < n; i++) {
    //    for (int j = 0; j < n; j++) {
    //        cout << s[i][j];
    //    }
    //    cout << endl;
    //}
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (s[i][j] != s[j][i]) {
                return 0;
            }
        }
    }
    return 1;
}

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

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        memcpy(t, s, sizeof(s));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int i1 = i - 1; if (i1 < 0) i1 += n;
                s[i][j] = t[i1][j];
            }
        }
        r += f() * n;
        k++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>a[i][j];
    }
  }
  int dp[n][3];
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  for(int i=1;i<n;i++){
    int j=0;
    dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
    j=1;
    dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j+1]);
    j=2;
    dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  return 0;
}

Measured memory_bytes: 2688
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    ll a = 1, b = 1;

    auto ceil = [&](ll x, ll d) {
        return (x + d - 1) / d;
    };

    REP(i, n) {
        ll c, d; cin >> c >> d;

        ll g = __gcd(c, d);
        c /= g, d /= g;

        ll k = max(ceil(a, c), ceil(b, d));

        a = k * c;
        b = k * d;
    }

    print(a + b);
    
}


Measured memory_bytes: 3616
#include<stdio.h>
#define N 100
int main()
{
    int n,i;
    float a[N];
    float ans=0.;
    
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%f",&a[i]);
    for(i=0;i<n;i++)
        ans+=1./a[i];
    ans=1./ans;
    printf("%f\n",ans);
    return 0;   
}

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

void solve(long long N, long long T, std::vector<long long> A) {
  long long maxProfitWithOneApple = 0;
  long long waysToMaxProfit = 0;
  long long currMin = 10e10;
  for (int i = 0; i < N; i++) {
      currMin = min(currMin, A[i]);
      long long calculatedProfit = A[i] - currMin;
      if (calculatedProfit == maxProfitWithOneApple) {
	  waysToMaxProfit++;
      } else if (calculatedProfit > maxProfitWithOneApple) {
	  maxProfitWithOneApple = max(maxProfitWithOneApple, A[i] - currMin);
	  waysToMaxProfit = 1;
      }
  }
  cout << waysToMaxProfit << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long T;
  scanf("%lld", &T);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, T, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100
short a[MAXN+10][MAXN+10],s[MAXN+10][MAXN+10];
int h,w;
short query(int x1,int y1,int x2,int y2)
{
	if (x1>x2 || y1>y2  || x1<0 || y1<0 || x2>h || y2>w) return -10000;
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}
short f[MAXN+5][MAXN+5][MAXN+5][MAXN+5];
short max(short a,int b) {
	return max(int(a),b);
}
int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	
	cin>>h>>w;
	int sx,sy;
	for(int i=1; i<=h; ++i) {
		for(int j=1; j<=w; ++j) {
			char t;
			cin>>t;
			if (t=='E') {
				sx=i; sy=j;
			} else if (t=='o') {
				a[i][j]=1;
			}
		}
	}
	for(int i=1; i<=h; ++i) {
		for(int j=1; j<=w; ++j) {
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
			//debug(s[i][j]);
		}
	}
	for(int l=0; l<w; ++l) {
		for(int u=0; u<h; ++u) {
			for(int r=0; r<w-l; ++r) {
				for(int d=0; d<h-u; ++d) {
					//debug(l,u,r,d,f[l][u][r][d]);
					if (sy-(l+1)>r)
					f[l+1][u][r][d]=max(f[l+1][u][r][d],f[l][u][r][d]
						+query(max(sx-u,d+1),sy-(l+1),min(sx+d,h-u),sy-(l+1)));
					if (sx-(u+1)>d)
					f[l][u+1][r][d]=max(f[l][u+1][r][d],f[l][u][r][d]
						+query(sx-(u+1),max(r+1,sy-l),sx-(u+1),min(w-l,sy+r)));
					if (sy+(r+1)<=w-l)
					f[l][u][r+1][d]=max(f[l][u][r+1][d],f[l][u][r][d]
						+query(max(sx-u,d+1),sy+(r+1),min(sx+d,h-u),sy+(r+1)));
					if (sx+(d+1)<=h-u)
					f[l][u][r][d+1]=max(f[l][u][r][d+1],f[l][u][r][d]
						+query(sx+(d+1),max(r+1,sy-l),sx+(d+1),min(w-l,sy+r)));
				}
			}
		}
	}

	//debug(4,0,0,1,f[4][0][0][1]);
	//debug(5,0,0,0,f[5][0][0][0]);
	int ans=*max_element(&f[0][0][0][0],&f[w][h][w][h]+1);
	cout<<ans<<endl;		
	return 0;
}


Measured memory_bytes: 227584
N = int(input())
ts = [int(i) for i in input().split()]
vmax = [int(i) for i in input().split()]
s = []

v = 0
for i in range(N):
    v = min(v, vmax[i])
    for t in range(ts[i]):
        if v < vmax[i]:
            s.append(v + 0.5)
            v += 1
        else:
            s.append(v)

ts = ts[::-1]
vmax = vmax[::-1]
s = s[::-1]

v = 0
count = 0
for i in range(N):
    v = min(v, vmax[i])
    for t in range(ts[i]):
        if v < vmax[i]:
            if s[count] == v + 0.5:
                s[count] = v + 0.25
            else:
                s[count] = min(v + 0.5, s[count])
            v += 1
        else:
            s[count] = min(v, s[count])
        count += 1

print(sum(s))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
signed main()
{
  ios();
  int A,B,C;
  cin >> A >> B >> C;
  cout << ((B/A >= C)? C :B/A) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3200");
            WillReturn.Add("pink");
            //pink
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3199");
            WillReturn.Add("pink");
            //red
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4049");
            WillReturn.Add("red");
            //red
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int a = int.Parse(InputList[0]);
        string s = InputList[1];

        if (a >= 3200) {
            Console.WriteLine(s);
        }
        else {
            Console.WriteLine("red");
        }
    }
}


Measured memory_bytes: 11092
{你无权查看本记录 因为↓}









{你是傻逼
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
    SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBS
}



{
    祝您一路顺风，半路失踪，回家发疯~~~~~~~~~~~~
}








{再见了，SB，我们后会无期}






{别以为我不知道是你YMJ！！！，喜欢看人家程序的**→_→}















var
 x,i,j:longint;
 a:array[0..5,0..5] of longint;
begin
 readln(a[1,1],a[1,2],a[2,2]);
 x:=a[2,2]*3;
 a[1,3]:=x-a[1,1]-a[1,2];
 a[3,1]:=x-a[1,3]-a[2,2];
 a[3,3]:=x-a[1,1]-a[2,2];
 a[2,1]:=x-a[1,1]-a[3,1];
 a[2,3]:=x-a[2,1]-a[2,2];
 a[3,2]:=x-a[1,2]-a[2,2];
 for i:=1 to 3 do
  begin
   for j:=1 to 3 do
    write(a[i,j],' ');
   writeln;
  end; 
end.

Measured memory_bytes: 128
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

#define MD 1000000007

int dp[100005], S[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    dp[0] = S[0] = 1;
    for (int i = 1; i <= K; i++)
    {
        dp[i] = 0;
        S[i] = 1;
    }
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        for (int j = 0; j <= K; j++)
        {
            int l = max(0, j - a);
            if (l) dp[j] = S[j] - S[l - 1];
            else dp[j] = S[j];
            if (dp[j] < 0) dp[j] += MD;
        }
        S[0] = dp[0];
        for (int j = 1; j <= K; j++) S[j] = (S[j - 1] + dp[j]) % MD;
    }
    cout << dp[K] << '\n';
    return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    Int a[n];
    rep(i,n) cin >> a[i];
    Int money = 1000;
    Int stack = 0;
    for (int i = 0; i < n; i++) {
        money += stack * a[i];
        stack = 0;
        if (i < n-1 && a[i] < a[i+1])
        {
            stack += money / a[i];
            money -= stack * a[i];
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 3544
#include <stdio.h>
int main(){
  char c;
  int ans = 0;
  int idx = 0;
  while(1){
    c = getchar();
    if (c == '0' || c == '1'){
      idx++;
      if(idx % 2 != c - '0'){
         ans++;
      }
    }else{
      break;
    }
  }
  if(ans > idx / 2){
    ans = idx - ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int N = sc.nextInt();
				if(N == 0) break;
				
				boolean[][] jud = new boolean[101][101];
				for(int i=1; i<=N; i++) {
					int M = sc.nextInt();
					for(int j=1; j<=M; j++) {
						int num = sc.nextInt();
						jud[i][num] = true;
					}
				}
				
				int K = sc.nextInt();
				int[] k = new int[101];
				for(int i=1; i<=K; i++)
				{
					int l = sc.nextInt();
					for(int j=1; j<=N; j++) {
						if(jud[j][l]) k[j]++;
					}
				}
				
				int end = 0;
				int per = 0;
				for(int i=1; i<=N; i++) {
					if(k[i] == K) {
						end++;
						per = i;
					}
				}
				if(end == 1) System.out.println(per);
				else System.out.println(-1);
			}
		}
	}
}


Measured memory_bytes: 69516
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		int K=nextInt()-1;
		long A[]=new long[N];
		long sum=1;
		for(int i=0;i<N;i++){
			A[i]=nextInt();
			if(i>K)
				if(A[i-K-1]<A[i])
					System.out.println("Yes");
				else
					System.out.println("No");
		}
	}
	static boolean isOK(int index,String key,String[]a){
		if (a[index].compareTo(key)>=0) return true;
	    else return false;
	}
	static int binary_search(String key,String[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 78208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> A(3*N);
    REP(i,3*N)cin >> A[i];
    sort(ALL(A),greater<>());
    ll total = 0;
    REP(i,2*N){
        if(i%2 == 1){
            total += A[i];
        }
    }
    cout << total << "\n";
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
typedef struct { ll n, m; } p2;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	ll ans = 0;
	rep(i, 0, N) {
		cin >> A[i];
		if (A[i] > i || i && A[i] - A[i - 1] > 1) {
			puts("-1");
			return 0;
		}
		if (i && A[i] != A[i - 1] + 1) {
			ans += (ll)A[i - 1];
		}
	}
	ans += (ll)A[N-1];
	printf("%lld\n", ans);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()


int64_t N;
vector<int64_t> A;


int64_t MOD = MOD = 1000000007;

int main() {
  std::cout << std::fixed << std::setprecision(20);

  cin >> N;
  
  A = vector<int64_t>(N,0);

  REP(i,N){
    cin >> A[i];
  }

  int64_t x = 0;
  REP(i,N){
    x += A[i];
    x %= MOD;
  }

  int64_t ans = 0;
  REP(i, N-1){
    x = x - A[i];
    x %= MOD;
    if(x < 0){
      x += MOD;
    }
    ans += A[i] * x;
    ans %= MOD;
    
  }
  
  
  cout << ans << endl;

}

Measured memory_bytes: 4780
import java.util.Scanner;
public class Main {
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  String S_A = scan.next();
	  String S_B = scan.next();
	  String S_C = scan.next();
	  String[] S_Array = { S_A, S_B, S_C };
	  String[] S_NameArray = { "A", "B", "C" };
	  String turn = "A";
	  for( int i = 0 ;; i++ ) {
		  if( turn.equals( S_NameArray[i % 3] ) ) {
			  if( S_Array[i % 3].length() == 0 ) {
				  System.out.println( S_NameArray[i % 3] );
				  break;
			  }else {
				  String S_lead = S_Array[i % 3].substring(0, 1);
				  if( S_lead.equals("a") ) {
					  turn = "A";
				  }else if( S_lead.equals("b") ) {
					  turn = "B";
				  }else if( S_lead.equals("c") ) {
					  turn = "C";
				  }
				  S_Array[i % 3] = S_Array[i % 3].substring(1, S_Array[i % 3].length());
			  }
		  }
	  }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll X, K, D; cin >> X >> K >> D;
    X = abs(X);
    if( X / D >= K ){
        cout << X - D*K << endl;
        return 0;
    }
    ll num = X / D;
    X -= num*D;
    K -= num;
    K%=2;
    if(K == 0) cout << X << endl;
    else cout << abs(X-D) << endl;

}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int K, X;
  cin >> K >> X;
  500 * K >= X ? yes : no;
}

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

int main(){
    int N;
    int D;
    cin>>N>>D;
    int kanshi;
    kanshi=2*D+1;
    int amari;
    amari=N%kanshi;
    if(amari==0){
        cout<<N/kanshi<<endl;
    }
    else{
        cout<<N/kanshi+1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    int N;
    cin >> N;
    int day=0, competer;
    int A[N][N], A_pointer[N];
    REP(i,N){
        REP(j,N-1){
            cin >> A[i][j];
        }
        A[i][N-1] = 0;
        A_pointer[i] = 0;
    }
    bool updated=true, will_update[N];
    while(updated){
        updated = false;
        REP(i,N) will_update[i] = false;
        REP(i,N){
            competer = A[i][A_pointer[i]]-1;
            if(competer!=-1){
                if(A[competer][A_pointer[competer]]==i+1){
                    will_update[i] = true;
                    updated = true;
                }
            }
        }
        if(updated){
            REP(i,N){
                if(will_update[i]){
                    A_pointer[i] += 1;
                }
            }
            day += 1;
        }
    }
    REP(i,N){
        if(A_pointer[i]!=N-1){
            day = -1;
        }
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 4096
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll n;
  string x;
  cin>>n>>x;
  
  ll bit=0,y;
  rep(i,n){
    if(x[i]=='1'){
      bit++;
      y=i;
    }
  }
  
  if(bit==0){
    rep(i,n) cout<<1<<endl;
    return 0;
  }
  
  vector<ll> A(200001),B(200001);
  ll a=bit-1,b=bit+1;
  A[0]=1,B[0]=1;
  for(int i=1;i<=n;i++){
    if(a>0) A[i]=A[i-1]*2%a;
    B[i]=B[i-1]*2%b;
  }
  
  ll ansa=0,ansb=0;
  rep(i,n){
    if(x[n-1-i]=='1'){
      if(a>0) ansa=(ansa+A[i])%a;
      ansb=(ansb+B[i])%b;
    }
  } 
  
  for(int i=0;i<n;i++){
    if(bit==1 && i==y){
      cout<<0<<endl;
      continue;
    }
    
    ll ans,cnt=1;
    if(x[i]=='0'){
      ans=(ansb+B[n-1-i])%b;
    }
    else{
      if(a>0) ans=(ansa-A[n-1-i]+a)%a;
    }
    
    while(ans>0){
      cnt++;
      int m=__builtin_popcount(ans);
      ans=ans%m;
    }   
    cout<<cnt<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 6808
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=2e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int a[N];

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

int Inv(int a, int m) { 
    return power(a, m-2, m); 

} 
  
void solve(){
    int n;
    cin>>n;
    int sum=0,sq=0;
    rep(i,1,n){
        int a;
        cin>>a;
        sum+=a;
        sum%=mod;
        sq+=a*a;
        sq%=mod;
    }
    int ans=((sum*sum)%mod-sq+mod)%mod;
    ans=(ans+mod)%mod;
    ans*=Inv(2,mod);
    ans%=mod;
    cout<<ans<<endl;
}


int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     //freopen("outputf.in", "w", stdout);
    // #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 3656
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] dishes = new int[N];

        int b = 0, c = 0, d = 0;
        double[][][] dp = new double[N + 1][N + 1][N + 1];
        for (int i = 0; i < N; i++) {
            int tmp = sc.nextInt();
            if (tmp == 1) b++;
            else if (tmp == 2) c++;
            else if (tmp == 3) d++;
        }

        System.out.println(backtrack(b, c, d, N, dp));
    }

    public static double backtrack(int b, int c, int d, int N, double[][][] dp) {
        if (b == 0 && c == 0 && d == 0) return 0;
        if (dp[b][c][d] != 0) return dp[b][c][d];

        double res = (double) N / (double) (b + c + d);

        if (b != 0)
            res += backtrack(b - 1, c, d, N, dp) * (double) b / (double) (b + c + d);
        if (c != 0)
            res += backtrack(b + 1, c - 1, d, N, dp) * (double) c / (double) (b + c + d);
        if (d != 0)
            res += backtrack(b, c + 1, d - 1, N, dp) * (double) d / (double) (b + c + d);

        dp[b][c][d] = res;
        return res;
    }
}


Measured memory_bytes: 307156
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;

bool flag[50],pass[50][50];
int n,m;

int dfs(int now,int depth){	//now: 開始頂点;
	if(flag[now])return 0;	
	if(depth==n)return 1;	//底まで探索でansを+1;
	flag[now]=true;			//訪問した頂点の履歴;
	int ans=0;	
	for(int i=0;i<n;i++)
		if(pass[now][i])ans+=dfs(i,depth+1); //深さを+1し探索;
	flag[now]=false;		//履歴の消去;
	return ans;
}

int main(){
	int a[55],b[55];

	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		pass[a[i]][b[i]]=pass[b[i]][a[i]]=true;
	}
	cout<<dfs(0,1)<<endl;

}

Measured memory_bytes: 256
n = int(input())
words = []
for i in range(n):
    words.append(input())
words_uniq = list(set(words))
result = []
if len(words) != len(words_uniq):
    print('No')
else:
    for i in range(1, len(words)):
        if words[i-1][-1] == words[i][0]:
            result.append('Yes')
        else:
            result.append('No')

    if 'No' in result:
        print('No')
    else:
        print('Yes')

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A==1){
      if(B==2) cout << 3;
      if(B==3) cout << 2;
  }
  if(A==2){
      if(B==1) cout << 3;
      if(B==3) cout << 1;
  }
  if(A==3){
      if(B==1) cout << 2;
      if(B==2) cout << 1;
  }
}


Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: u64,
        m: u64,
        mut a: [u64; n],
        mut bc:[(u64,u64); m]
    }

    a.sort();
    bc.sort_by_key(|k| k.1);

    let iter = bc.iter().rev();
    let mut i : usize = 0;
    for ele in iter {
        for _ in 0..ele.0 {

            if i >= n as usize{
                
                break;
            }

            if a[i] < ele.1 {
                a[i] = ele.1;
                i += 1;
            } else {
                break;
            }
        }
    }

    let ans: u64 = a.iter().sum();

    println!("{}", ans);
}


Measured memory_bytes: 7512