akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

//int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int w[10],k[10];

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

	REP(i,10) cin>>w[i];
	REP(j,10 ) cin>>k[j];
	sort(w,w+10,greater<int>());
	sort(k,k+10,greater<int>());
	cout<<w[0]+w[1]+w[2]<<' '<<k[0]+k[1]+k[2]<<endl;

	return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  vector<int> c(4);
  bool f=0;
  REP(i,6){
    int x;
    cin>>x;
    c[x-1]++;
    if(c[x-1]==3) f=1;
  }

  cout<<(f? "NO":"YES")<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
  int i = 0;
  int j = 0;
  int count = 0;
  char s[11];
  char answer[11];
  
  scanf("%s",s);
  for(i = 0; i < 11; i++){
  	if(s[i] == '0'){
  		answer[j] = '0';
  		j++;
  	}
  	else if(s[i] == '1'){
  		answer[j] = '1';
  		j++;
  	}
  	else if(s[i] == 'B'){
  		if(j != 0){	
  			answer[j - 1] = '\0';
  			j--;
  		}
  		else if(j == 0){
  			answer[j] = '\0';
  		}
  	}
  }
  printf("%s\n",answer);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Handshake_3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
            var inputArray = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
            var _N = inputArray[0];
            var _M = inputArray[1];

            inputArray = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
            var powers = inputArray.OrderBy(x => -x).ToList();

            long top1 = powers.First() * 2 + 1;
            long bottom1 = -1;
            var powerIndex = new List<long[]>((int)_N);
            long thresholdPower = 0;
            do
            {
                powerIndex.Clear();
                long count = 0;
                var mid1 = (top1 + bottom1) / 2;
                for (var i = 0; i < _N; i++)
                {
                    long top2 = _N;
                    long bottom2 = -1;
                    do
                    {
                        var mid2 = (top2 + bottom2) / 2;
                        if (powers[i] + powers[(int)mid2] >= mid1)
                        {
                            bottom2 = mid2;
                        }
                        else
                        {
                            top2 = mid2;
                        }
                    } while (top2 - bottom2 > 1);
                    count += top2;
                    powerIndex.Add(new long[2] { powers[i], top2 });
                }

                if(count >= _M)
                {
                    bottom1 = mid1;
                    thresholdPower = mid1;
                }
                else
                {
                    top1 = mid1;
                }
            } while (top1 - bottom1 > 1);

            var accumulation = new long[_N + 1];
            accumulation[0] = 0;
            for (var i = 0; i < _N; i++)
            {
                accumulation[i + 1] = accumulation[i] + powers[i];
            }

            {
                long ans = 0;
                long count = 0;
                foreach (var item in powerIndex)
                {
                    ans += (item[0] * item[1] + accumulation[item[1]]);
                    count += item[1];
                }
                ans -= (count - _M) * thresholdPower;
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 46688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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; }

int main(){
    int n;
    ll c;
    cin >> n >> c;
    VL x(n), v(n);
    rep(i,n) cin >> x[i] >> v[i];

    VL xx(2*n+1), vv(2*n+1);
    rep(i,n){
        xx[i] = c - x[i];
        vv[i] = v[i];
        
        xx[n+i+1] = x[i];
        vv[n+i+1] = v[i];
    }

    VL mx(2*n+1), sums(2*n+1);
    for(int i = 1;i <= n; i++){
        sums[n-i] = sums[n-i+1] + vv[n-i] - (xx[n-i] - xx[n-i+1]);
        sums[n+i] = sums[n+i-1] + vv[n+i] - (xx[n+i] - xx[n+i-1]);
    }

    for(int i = 1;i <= n; i++){
        mx[n-i] = max(sums[n-i], mx[n-i+1]);
        mx[n+i] = max(sums[n+i], mx[n+i-1]);
    }

    ll ans = max(mx[0], mx[2*n]);
    for(int i = 1; i < n; i++){
        ll sumLeft = sums[n-i] - (xx[n-i] - xx[n]);
        ll sumRight = sums[n+i] - (xx[n+i] - xx[n]);

        ll totLeft = sumLeft + mx[2*n-i];
        ll totRight = sumRight + mx[i];

        ans = max(ans, totLeft);
        ans = max(ans, totRight);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11108
import sys
input = sys.stdin.readline

MOD = pow(10, 9) + 7

def main():
  s = input().strip()
  sd = [[0 for _ in range(13)] for _ in range(len(s))]
  if s[-1] == '?':
    for i in range(10):
      sd[0][i] = 1
  else:
    sd[0][int(s[-1])] = 1

  for i, _s in enumerate(s[::-1]):
    if i == 0:
      continue
    if _s != '?':
      rem = int(_s) * pow(10, i, 13) % 13
      for j in range(13):
        sd[i][(j+rem)%13] = sd[i-1][j]
    else:
      for k in range(10):
        rem = k * pow(10, i, 13) % 13
        for j in range(13):
          sd[i][(j+rem)%13] += sd[i-1][j]
          sd[i][(j+rem)%13] %= MOD
  print(sd[len(s)-1][5])


if __name__ == '__main__':
  main()


Measured memory_bytes: 68396
def isup(s)
  /[[:upper:]]/.match(s)
end

S=gets.strip
if S[0]!='A'
  puts 'WA'
  exit
end

a=[]
a<<0

ok=false
(2..S.size-2).each do |i|
  if S[i]=='C'
    ok=true
    a<<i
  end
end

if !ok || a.size!=2
  puts 'WA'
  exit
end

(0..S.size-1).each do |i|
  if !a.include?(i) && isup(S[i])
    puts 'WA'
    exit
  end
end

puts 'AC'


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int n,k; cin >> n >> k;
  int ans = 0;
  while(n>0){
    n /= k;
    ++ans;
  }
  cout << ans << endl;
}




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

using namespace std;

#define ll long long
#define fi first
#define se second
const int maxn = 1e6 + 10, INF = 1000000009;

ll a[maxn];
bool flg = false;
vector<pair<int,ll> > E[maxn];

void init() {
    for(int i = 0;i < maxn;i++) a[i] = INF;
}
int n,m;
bool vis[maxn];

void dfs(int idx) {
    for(int i = 0;i < E[idx].size();i++) {
        int to = E[idx][i].fi;
        int v = E[idx][i].se;
        if(vis[to]) continue;
        if(a[to] != INF) {
            if(a[to] - a[idx] != v) {
                flg = true;
                return ;
            }
        } else {
            a[to] = a[idx] + v;
            dfs(to);
            if(flg) return;
        }
    }
    vis[idx] = true;
    if(flg) return;

}
int L[maxn];
int main(){
    ios_base::sync_with_stdio(0);

	cin>>n>>m;
	for(int i = 0;i < m;i++) {
        int l,r,d;cin>>l>>r>>d;
        L[i] = l;
        E[l].push_back(make_pair(r,d));
        E[r].push_back(make_pair(l,-d));
	}
	init();
	for(int i = 0;i < n;i++) {
        if(E[L[i]].size() >= 1) {
            if(vis[L[i]]) continue;
            
            a[L[i]] = 0;
            dfs(L[i]);
            if(flg) break;
        }
	}
	if(flg) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 48256
s=list(input())


ans=[0 for _ in range(len(s))]

a=0
b=0
r=0
l=0
ind=-1
for i in range(len(s)-1):
    if(s[i]=='R'):
        r+=1

        if(s[i+1]=='L'):
            ind=i
            if(r%2==0):
                a+=r//2
                b+=r//2
            else:
                a+=(r//2)+1
                b+=r//2
    else:
        l+=1

        if(s[i+1]=='R'):
            if(l%2==0):
                a+=l//2
                b+=l//2
            else:
                a+=l//2
                b+=(l//2)+1
            ans[ind]=a
            ans[ind+1]=b
            a=0
            b=0
            l=0
            r=0
            ind=-1
else:
    i+=1
    l+=1

    if(l%2==0):
        a+=l//2
        b+=l//2
    else:
        a+=l//2
        b+=(l//2)+1
    ans[ind]=a
    ans[ind+1]=b

print(*ans)

Measured memory_bytes: 7096
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 999999

for i in range(M):
    x, y, c = map(int, input().split())
    if x <= A and y <= B:
        d = a[x - 1] + b[y - 1] - c
        if d < ans:
            ans = d

if (min(a) + min(b)) < ans:
    ans = min(a) + min(b)

print(ans)

Measured memory_bytes: 18612
#include <iostream>
#include <cstdio>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn = 100009;
int n;
ll sum;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a%b);}
int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int k = 1; k <= n; k++){
                sum += gcd(gcd(i,j),k);
            }
    printf("%lld",sum);
    return 0;
}

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

#define MAX_V 10000

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    int temp_s = ('0' + 1);
    /*cout << typeid(temp_s).name() << endl;*/
    for (int i = 0; i < 1000; i++){
        int V[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        for (int n = 0; n < N; n++){
            if (S[n] == ('0' + V[f])){
                f++;
                /*cout << typeid(S[n]).name() << endl;*/
            }
            if (f == 3){
                break;
            }
        }
        if (f == 3){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<double> dp(n), tmp(n);
    vector<vector<int>> g(n);
    vector<pair<int, int>> e(m);
    rep(i, 0, m) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        e[i] = {s, t};
        g[s].emplace_back(t);
    }
    for (int i = n - 2; i >= 0; i--) {
        double res = 0, cnt = 0;
        for (int j : g[i]) {
            res += dp[j];
            cnt++;
        }
        if (cnt == 0) continue;
        dp[i] = res / cnt + 1;
    }
    tmp = dp;
    for (int i = n - 2; i >= 0; i--) {
        double mx = 0, sum = 0;
        for (int j : g[i]) {
            mx = max(mx, dp[j]);
            sum += dp[j];
        }
        if (g[i].size() > 1) {
            tmp[i] = (sum - mx) / (g[i].size() - 1) + 1;
        }
    }
    debug(dp, tmp);
    double ans = tmp[0];
    rep(t, 1, n - 1) {
        vector<double> x = dp;
        x[t] = tmp[t];
        for (int i = t - 1; i >= 0; i--) {
            double res = 0, cnt = 0;
            for (int j : g[i]) {
                res += x[j];
                cnt++;
            }
            if (cnt == 0) continue;
            x[i] = res / cnt + 1;
        }
        ans = min(ans, x[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    if(A1*T1+A2*T2 == B1*T1+B2*T2){
        cout << "infinity\n"; return 0;
    }

    ll l1 = (B1-A1)*T1;
    ll l2 = (B2-A2)*T2;
    if(l1<0){
        l1 *= -1; l2 *= -1;
    }
    if(l1+l2>0){
        cout << 0 << endl; return 0;
    }

    ll d = -l1 - l2;
    ll ans = 0;
    if(l1 % d != 0) ans = l1 / d * 2 + 1;
    else ans = l1 / d * 2;

    cout << ans << endl; 
}

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

int main() {
  int S;
  int S1; 
  int S2;
  int S3;
  
  cin >> S;
  S1 = S/100;
  S2 = S%100 / 10;
  S3 = S%100 %10 /1;
  cout << S1 + S2 + S3 << endl;

}

Measured memory_bytes: 256
N = int(input())
V= list(map(int,input().split()))
C= list(map(int,input().split()))
v_c = [v-c for v,c in  zip(V,C)]
v_c = sorted(v_c)[::-1]
cand = [sum(v_c[:i] )for i in range(N+1)]

print(max(cand))

Measured memory_bytes: 3064
/*test*/
#include<bits/stdc++.h>

using namespace std;

int main() {
    long long int i = 0,b = 0, bko = 0, sum = 0;
    string s;
    cin >> s;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            b += bko;
            bko += 1;
            sum += s.size() - 1 - i;
        }
    }
    cout << sum - b << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	ll n, k;
	cin >> n >> k;

	if (n > k) {
		ll t = n / k;
		n -= t * k;
	}

	cout << min(n, abs(n - k)) << "\n";

	return 0;
}


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

int main(void) {
	char top[3];
	int num = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%c", &top[i]);
		if (top[i] == 'o') num++;
	}
	printf("%d\n", 700 + num * 100);

	return 0;
}


Measured memory_bytes: 3756
n = int(input())
ans = 0
sqrt = int(n ** 0.5)
for i in range(1, sqrt+1):
    if n % i == 0:
        m = n // i - 1
        if m != 0 and n // m == n % m:
            ans += m
        if n // i == i: continue
        m = i - 1
        if m != 0 and n // m == n % m:
            ans += m
print(ans)

Measured memory_bytes: 9392
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 998244353
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

struct fentree{
	int n;
	vector<ll> tree;

	void init(int n){
		this->n=n;
		tree.assign(n+2,0);
	}

	void set(int i,ll val){
		while (i<=n){
			tree[i]+=val;
			tree[i]%=mod;
			i+=i&-i;
		}
	}

	ll get(int a){
		ll s=0;
		while (a>0){
			s+=tree[a];
			s%=mod;
			a-=a&-a;
		}

		return s;
	}

	ll get(int a,int b){
		//a and b are inclusive
		ll t=get(b)-get(a-1);
		if(t<0)t+=mod;
		return t;
	}
};


void solve(){
	int i,j;
	int n,k;
	cin >> n >> k;

	vector<pair<int,int>> intervals(k);
	for (int i = 0; i < k; ++i)
	{
		cin >> intervals[i].ff >> intervals[i].ss;
	}

	fentree t;
	t.init(n);
	t.set(1,1);

	for (int i = 2; i <= n; ++i)
	{
		ll s=0;
		for (int j = 0; j < k; ++j)
		{
			int a=max(0,i-intervals[j].ss);
			int b=min(i-1,i-intervals[j].ff);


			s+=t.get(a,b);
			s%=mod;

		}

		t.set(i,s);
	}

	printf("%lld\n",t.get(n,n)%mod);
	
}


int main(){
	// ios_base::sync_with_stdio(false);
 //    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 4848
#include <iostream>
    #include <string>
    #include <algorithm>
    #include <set>
    #include <math.h>
    using namespace std;
     
    int main() {
        int a,b,c,d,e,f;
        cin>>a>>b>>c>>d>>e>>f;
        int w=100*a,s=0;
        int i,j,k,l;
        for(i=1;100*a*i<=f;++i){
            for(j=0;100*a*i+100*b*j<=f;++j){
                for(k=0;100*a*i+100*b*j+c*k<=f;++k){
                    for(l=0;100*a*i+100*b*j+c*k+d*l<=f;++l){
                        if((c*k+d*l)*(100+e)<=(100*a*i+100*b*j+c*k+d*l)*e
                           &&s*(100*a*i+100*b*j+c*k+d*l)<w*(c*k+d*l)){
                            s=c*k+d*l;
                            w=100*a*i+100*b*j+c*k+d*l;                }
                }
            }
        }
        }
        cout<<w<<" "<<s<<endl;
        return 0;
    }

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

//put debug temp

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int a[Sz];
int n, A, b;

bool calc (int t) 
{
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		ll x = a[i] - t * 1ll * b;
		if (x >= 0)
			res += (x+(A-b)-1) / (A-b);
	}
	return (res <= t);
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  cin >> A >> b;
  for (int i = 1; i <= n; i++) {
 	cin >> ::a[i];
 }
 int l = 1, r = MX, ans = 1e9;
 while (l <= r) {
 	int m = (l + r) / 2;
  if (calc (m)) {
 		r = m- 1;
 		ans = m;
 	}
 	else {
 		l = m+1;
 	}
 }
 cout << ans;


  return 0;
}





// Coded by Z..

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
//#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

const ll inf = 1LL << 63;

struct edge {int to; ll cost; bool use;};
struct node {int pos; ll cost;};
bool operator < (const node &a, const node &b){
    return a.cost > b.cost;
}

vector<ll> dijkstra(vector<vector<edge>> &G, int root){
    vector<ll> ret(G.size(), inf);
    priority_queue<node> pq;
    pq.push({root, 0});
    while (!pq.empty()) {
        node t = pq.top();
        pq.pop();
        
        if (ret[t.pos] == inf) ret[t.pos] = t.cost;
        else continue;
        
        for (edge e : G[t.pos]) {
            pq.push({e.to, t.cost + e.cost});
        }
    }
    return ret;
}


vector<ll> C1, C2, D1, D2;

void dfs1(vector<vector<edge>> &G, vector<ll> &D, int cur, int par = -1) {
    for(edge &e: G[cur]){
        if(D[e.to] < D[cur] && e.to != par){
            if(D[cur] - D[e.to] == e.cost) {
                e.use = true;
                dfs1(G, D, e.to, cur);
            }
        }
    }
}


ll dfs(vector<vector<edge>> &G, vector<ll> &C, vector<ll> &D, int cur, int par = -1) {
    ll ret = 0;
    if(C[cur] >= 0) return C[cur];
    for(edge e: G[cur]){
        if(D[e.to] + e.cost == D[cur]) {
            (ret += dfs(G, C, D, e.to, cur)) %= mod;
        }
    }
    return C[cur] = ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--, T--;
    vector<vector<edge>> G(N);
    rep(i, M){
        int u, v;
        ll d;
        cin >> u >> v >> d;
        d *= 2;
        u--, v--;
        G[u].pb({v, d, false});
        G[v].pb({u, d, false});
    }
    
    
    
    D1 = dijkstra(G, S);
    D2 = dijkstra(G, T);
    ll dist = D1[T];
    ll meet = dist / 2;
    
    
    C1.assign(N, -1);
    C1[S] = 1;
    dfs(G, C1, D1, T);
    C2.assign(N, -1);
    C2[T] = 1;
    dfs(G, C2, D2, S);
    
    vector<ll> tak, aok;
    rep(i, N){
        if(D1[i] == meet && D2[i] == meet){
            tak.pb(C1[i]), aok.pb(C2[i]);
        }
    }
    
    rep(i, N){
        for(edge e: G[i]){
            if(D1[i] < meet && D2[e.to] < meet && D1[i] + D2[e.to] + e.cost == dist){
                tak.pb(C1[i]);
                aok.pb(C2[e.to]);
            }
        }
    }
    
    ll ans = C1[T] * C1[T] % mod;
    rep(i, tak.size()){
        ll sub = tak[i] * aok[i] % mod;
        (ans -= sub * sub) %= mod;
    }
    (ans += mod) %= mod;
    output(ans);
    
    return 0;
}


Measured memory_bytes: 28172
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    lint A[X],B[Y],C[Z];
    rep(i,X) cin >> A[i];
    rep(i,Y) cin >> B[i];
    rep(i,Z) cin >> C[i];
    lint N=X*Y;
    lint cake[N];
    rep(i,X) rep(j,Y) cake[i*Y+j]=A[i]+B[j];
    sort(cake,cake+N,greater<lint>());
    lint n=min(3000LL,X*Y);
    lint nw[n];
    rep(i,n) nw[i]=cake[i];
    lint ans[n*Z];
    rep(i,n) rep(j,Z) ans[i*Z+j]=nw[i]+C[j];
    sort(ans,ans+n*Z,greater<lint>());
    rep(i,K) cout << ans[i] << endl;
}

Measured memory_bytes: 31744
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()		# 配列を降順に並べ替える

alice = 0
bob = 0
for i in range(n):
	if i % 2 == 0:
		alice = alice + a[i]
	else:
		bob = bob + a[i]
print(alice - bob)


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
  string s; cin>>s;
  vector<ll>v(s.size());
  rep(i,s.size()){
  if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
  v[i]=1;
  }
  ll t=0,ans=0;
  rep(i,v.size()){
  if(v[i]>0) t++;
    else t=0;
    ans=max(ans,t);
  }

 cout<<ans<<endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
// #define INF 9223372036854775807
# define INF 1e9
using namespace std;

int gcd(int a, int b){
  if(a > b) swap(a, b);
  if(a == 0){
    return b;
  } else {
    return gcd(b % a, a);
  }
}

int main(){

  int N;
  cin >> N;
  int A[N];
  for(int i= 0; i< N; i++){
      cin >> A[i];
  }
  int v = A[0];
  for(int i=1; i < N; i++){
    v = gcd(v, A[i]);
  }

  cout << v  << endl;

}

Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    sc = [list(map(int, input().split())) for _ in range(m)]
    
    if n == 1:
        start = 0
        stop = 10
    elif n == 2:
        start = 10
        stop = 100
    else:
        start = 100
        stop = 1000
    
    for i in range(start, stop):
        num = [i for i in str(i)]
        flag = True
        for j in range(m):
            if num[sc[j][0] - 1] != str(sc[j][1]):
                flag = False
        if flag:
            print(''.join(num))
            return
    else:
        print(-1)
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vec<int, 2> grid = make_v(N, N, 0);
    for (int y = (N % 3 == 1 ? 0 : 1); y < N; y += 3) {
      for (int x = 0; x < N; x++) {
        if ((y + x) % 2 == 1) {
          grid[y][x] = 1;
        }
      }
    }
    for (int y = 0; y < N; y++) {
      if (y % 2 == 1) grid[y][0] = 1;
    }
    vector<int> ys, xs;
    for (int y = 0; y < N; y++) {
      for (int x = 0; x < N; x++) {
        if (grid[y][x]) {
          ys.push_back(y);
          xs.push_back(x);
        }
      }
    }
    cout << ys.size() << endl;
    for (int i = 0; i < ys.size(); i++) {
      cout << ys[i] << " " << xs[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6892
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// PfsMap : 素因数分解し、マップを作成
func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B := getInt(), getInt()
	gcd := GCD(A, B)
	pfs := PfsMap(gcd)
	// out(gcd, pfs)

	l := len(pfs) + 1
	out(l)

}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * String Search - Naive String Search
 */
public class Main {

	static final int B = 37;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		char[] T, P;
		T = br.readLine().toCharArray();
		P = br.readLine().toCharArray();

		if (T.length < P.length) return;

		int t = 0, p = 0;
		for (int i = 0; i < P.length; i++) {
			t = t * B + T[i];
			p = p * B + P[i];
		}


		//solve
		if (t == p) System.out.println(0);
		for (int i = 1; i < T.length - P.length + 1; i++) {
			t = t * B + T[i + P.length - 1] - T[i - 1] * power(B, P.length);
			if (t == p) System.out.println(i);
		}
	}

	static int power(int x, int n) {
		if (n == 0) return 1;
		int ret = power(x * x, n / 2);
		if ((n & 1) == 1) ret *= x;
		return ret;
	}

}

Measured memory_bytes: 24328
from heapq import heappop,heappush

N, M = map(int, input().split())
A = list(map(int, input().split()))

H = []

for i in A:
    heappush(H, -i)

for _ in range(M):
    heappush(H, -((-heappop(H)//2)) )

print(-sum(H))


Measured memory_bytes: 14180
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);

int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0; i<n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = 0;
    }
    d[0] = 0;
    
    while(true)
    {
        minv = INFTY;
        u = -1;
        for(int i=0; i<n; i++)
        {
            if(minv > d[i] && color[i] != 2)
            {
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = 2;
        for(int v=0; v<n; v++)
        {
            if(color[v] != 2 && M[u][v] != INFTY)
            {
                if(d[v] > M[u][v])
                {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = 1;
                }
            }
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++)
    {
        if(p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main() 
{
    ios::sync_with_stdio(false);
    
    cin >> n;
    
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    
    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll res = 1;
	for (ll i = k;i < n;++i) {
		if (a[i] > a[i - k])puts("Yes");
		else {
			puts("No");
		}
	}
	return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int h,w,i,j;
	while (1) {
		cin >> h >> w;
		if (h==0&&w==0) {
			break;
		}
		
		for (i=0;i<h;i++) {
			for (j=0;j<w;j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

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

int main(){
    string S; cin >> S;
    vector<int> ans(S.size(), 0);
    char prev = S[0];
    int count = 1;
    for (int i = 1; i < S.size(); i++)
    {
        if(prev=='R' && S[i]=='L'){
            ans[i]   += 1 + count/2;
            ans[i-1] += count/2 + (count%2 == 1);
            count = 0;
            int pos = i;
            while(i<S.size()-1 && S[i+1]=='L'){
                if(count%2==0) ans[pos-1]++;
                else ans[pos]++;
                i++; count++;
            }
            count = 0;
        }
        else {
            count++;
        }
    }
    for (int i = 0; i < ans.size(); i++)
    {
        if(i!=ans.size()-1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
    
    
}


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

int main() {
  string s;
  cin >> s;
  int end = 0;
  int best = 0;
  bool streak = false;
  for (int i = 0; i < s.size(); i++)
  {
    if(s[i] == 'R')
    {
      if (i == 0 or streak == true)
      {
        streak == true;
        end++;
        if (best < end)
        {
          best = end;
        }
      }
      else
      {
        streak == true;
        end++;
        if (best < end)
        {
          best = end;
        }
      }
    }
    else if(s[i] == 'S')
    {
      streak = false;
      end = 0;
    }
  }
  cout << best;
	return 0;    
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
int main(){
    ll t,i;
    ll n;
    cin>>n;
    ll sum=(1+n)*n/2;
    ll t3=n/3,t5=n/5,t15=n/15,s1=3*(1+t3)*t3/2,s2=5*(1+t5)*t5/2,s3=15*(1+t15)*t15/2;
    cout<<sum-s1-s2+s3;
}

Measured memory_bytes: 3636
#include<stdio.h>

int m[101][101];
int p[101];
int length;

void MCO(){
  int n,i,l,q,j,k;

  n = length;

  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = 9999999;
      for(k = i; k <= j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = min(m[i][j],q);
      }
    }
  }
}

int min(int A,int B){
  if(A > B){
    return B;
  }else{
    return A;
  }
}

int main(){
  int i;

  scanf("%d",&length);
  for(i = 0; i < length; i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }

  MCO();
  printf("%d\n",m[1][length]);

  return 0;
}

Measured memory_bytes: 636
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn dfs(
    n: usize,
    d: &mut Vec<i64>,
    graph: &Vec<Vec<(usize, i64)>>,
    xmin: &mut i64,
    ymin: &mut i64,
    r: usize,
) -> bool {
    if n < r {
        *xmin = min(*xmin, d[n]);
    } else {
        *ymin = min(*ymin, d[n]);
    }
    for i in &graph[n] {
        let (v, dis) = *i;
        if d[v] == 1 << 61 {
            d[v] = dis - d[n];
            let check = dfs(v, d, graph, xmin, ymin, r);
            if !check {
                return false;
            }
        } else if d[v] + d[n] != dis {
            return false;
        }
    }
    return true;
}

fn main() {
    let (r, c): (usize, usize) = (read(), read());
    let n: usize = read();
    let mut graph: Vec<Vec<(usize, i64)>> = vec![Vec::new(); r + c];
    for _ in 0..n {
        let (ri, ci, ai) = (read::<usize>() - 1, r + read::<usize>() - 1, read::<i64>());
        graph[ri].push((ci, ai));
        graph[ci].push((ri, ai));
    }
    let mut d: Vec<i64> = vec![1 << 61; r + c];
    let mut ok = true;
    for i in 0..r + c {
        if d[i] == 1 << 61 {
            d[i] = 0;
            let mut xmin: i64 = 1 << 61;
            let mut ymin: i64 = 1 << 61;
            let po = dfs(i, &mut d, &graph, &mut xmin, &mut ymin, r);
            if !po || xmin + ymin < 0 {
                ok = false;
                break;
            }
        }
    }
    println!("{}", if ok { "Yes" } else { "No" });
}

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


Measured memory_bytes: 26492
dim = int(input())
x = [int(s) for s in input().split()]
y = [int(s) for s in input().split()]
one = 0
two = 0
three = 0
infinity = 0
for i in range(dim):
    term = abs(x[i] - y[i])
    one += term
    two += term ** 2
    three += term ** 3
    infinity = max(infinity, term)
print(round(one, 6))
print(round(two ** (1 / 2), 6))
print(round(three ** (1/3), 6))
print(infinity)


Measured memory_bytes: 5652
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int N,K=0;
    
    scanf("%d",&N);
    scanf("%d",&K);
    
    if (K==1) {
        printf("0");
    }else{
        printf("%d",N-K);
    }
    
    return 0;
}


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

int t[1010];
int a, b;

int main(){
	cin >> a >> b;
	t[1]=1;
	for(int i=2; i<=b-a; i++){
		t[i] += t[i-1] + i;
	}
	cout << t[b-a] - b << endl;
}

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


int main(){
  int n, r ,x;
  cin >>n>>r;
  x =r+(100*(10-n));
  if(n>=10){
    cout <<r<<endl;
  }  else cout<< x<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define EPS 1e-9
using namespace std;

template <class T>
static T read()
{
	T t;
	cin >> t;
	return t;
}

template <class T>
static vector<T> read_n(int n)
{
	vector<T> v;
	REP(i,n) { v.push_back(read<T>()); }
	return v;
}

template <class T>
static void write(const T &t)
{
	cout << t << endl;
}

/// template end ///

int main()
{
	while (true)
	{
		int n = read<int>();
		if (!n) { break; }
		vector<int> v = read_n<int>(n);
		sort(ALLOF(v));
		int ret = accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2);
		write(ret);
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	bool flag = false;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){
		flag = true;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	if(flag) x = -x;
}
inline LL gcd(LL a, LL b){
	return b ? gcd(b, a % b) : a;
}
LL a, b, lcm;
int c, d;
inline LL calc(LL x){
	return x - x / c - x / d + x / lcm;
}
int main(){
	read(a); read(b); read(c); read(d); lcm = (LL) c / gcd(c, d) * d;
	printf("%lld\n", calc(b) - calc(a - 1));
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;

typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;

typedef map<int,int> mii;
typedef map<int,v32> mvi;
typedef map<int, p32> mpi;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define Acc(i,n,a) for(int i=0;i<(int)n;i++) cin>>a[i]
#define Acc2(i,n,a,b) for(int i=0;i<(int)n;i++) cin>>a[i]>>b[i]
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)

ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV( ll a, ll m) { return MPOW(a,m-2,m);}
ll MFACT( ll n, ll m){ if(m<=n) return 0; else if(n==0) return 1; else return ((MFACT(n-1,m)*n)%m);}
inline ll max( ll a, ll b) { return (a>b)?a:b;}
inline ll min( ll a, ll b){ return (a<b)?a:b;}
inline void swap( ll &a, ll &b){ ll temp=a; a=b; b=temp; return;}
inline ll max3( ll a, ll b, ll c){ return max(a,max(b,c));}
inline ll min3( ll a, ll b, ll c){ return min(a,min(b,c));}

int main()
{
    ll h,w, n;
    cin>>h>>w>>n;
    ll ans;
    if(h>=w)
    {
        ans = n/h;
        if(n%h!=0)
        {
            ans+=1;
        }
    }
    else
    {
        ans = n/w;
        if(n%w!=0)
        {
            ans+=1;
        }
    }
    cout<<ans;
    
    
    return 0;
}

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

using namespace std;

int main(){
    long N, M;
    cin>>N>>M;
    vector<double> A(N);
    double a;
    priority_queue<double> pq;
    for(int i=0; i<N; ++i){
        cin>>a;
        pq.push(a);
    }

    for(int i=0; i<M; ++i){
        a = pq.top();
        pq.pop();
        pq.push(a/2);
        //auto itr = max_element(A.begin(), A.end());
        //(*itr) /= 2;
    }

    long sum = 0;
    for(int i=0; i<N; ++i){
        //cout<<A[i]<<" "<<floor(A[i])<<endl;
        a = pq.top();
        pq.pop();
        sum += floor(a);
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
bool can[12][12][12] = {};
int main(){
  int n; cin >> n;
  string s; cin >> s;
  rep(i,n){
    int tar = s[i] - '0';
    rep(i,10)rep(j,10)can[i][j][tar] = can[i][j][11];
    rep(i,10)can[i][tar][11] = can[i][11][11];
    can[tar][11][11] = 1;
  }
  ll ans = 0;
  rep(i,10)rep(j,10)rep(k,10)  ans += ll(can[i][j][k]);
  cout << ans << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#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 loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
int bitcount(int x) { int c = 0; while (x) { x -= x & -x; c++; }return c; }
signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	int a, b, c; cin >> a >> b >> c;

	vector<int>l(N); rep(i, 0, N) { cin >> l[i]; }
	vector<pii>v;
	rep(mask,1, 1ll << N) {
		int sum = 0;
		rep(i, 0, N) {
			if ((mask >> i) & 1)sum += l[i];
		}
		v.eb(mask, sum);
	}

	int ans = INF;

	for (auto x : v) {
		for (auto y : v) {
			if (x.first&y.first)continue;
			for (auto z : v) {
				if (x.first&z.first or y.first&z.first) continue;
				int tmp = 0;
				tmp += 10 * (bitcount(x.first) + bitcount(y.first) + bitcount(z.first) - 3);
				tmp += abs(a - x.second) + abs(b - y.second) + abs(c - z.second);
				chmin(ans, tmp);
			}
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int prev = Integer.parseInt(sc.next());
    int max = 0;
    int count = 0;
    for (int i = 1; i < n; i++) {
      int after = Integer.parseInt(sc.next());

      if (prev >= after) {
        count++;
      } else {
        count = 0;
      }
      max = Math.max(max, count);
      prev = after;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 45640