akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 1;
ll dp[N];
void solve(){
  ll n, k;
  cin >> n  >> k;
  ll a[n + 1];
  foa(i, 1, n+1){
    cin >> a[i];
  }
  dp[1] = 0;
  dp[2] = abs(a[1]-  a[2]);
  for(ll i = 3; i <= n; i++){
    dp[i] = inf;
    for(ll j = i - 1; j >= 1 && j >= i - k; j--){
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
  }
  cout << dp[n] << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 5284
N,M=map(int,input().split())
P=[[] for i in range(M)]
Y=[1 for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    P[i].append(i)
    P[i].append(a)
    P[i].append(b)
P.sort(key=lambda x:x[2])
for i in range(M):
    P[i].append(str(P[i][1]*1000000+Y[P[i][1]]))
    Y[P[i][1]]+=1
P.sort(key=lambda x:x[0])
for i in range(M):
    print(P[i][3].zfill(12))



Measured memory_bytes: 33024
#include<iostream>
using namespace std;
int main(){
	int a[50] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << a[n] << endl;
	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int p[100010];
vi vec;

int main() {
	cin >> N;
	rep(i, N) {
		cin >> p[i];
		if (p[i] == i+1) {
			vec.pb(i);
		}
	}
	int ret = 0;
	int cnt = 0, la = -1;
	rep(i, vec.size()) {
		if (i == 0) {
			cnt = 1;
			la = vec[i];
		} else {
			if (vec[i] == la + 1) {
				++cnt;
			} else {
				ret += (cnt+1) / 2;
				cnt = 1;
				la = vec[i];
			}
		}
	}
	ret += (cnt+1) / 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>

int main(void){
    long long int N, K;
    long long int i;
    long long int a = 0;

    scanf("%lld %lld", &N, &K);
    for (i = K; i <= N + 1; i++)
    {
        a += (N * 2 - i + 3) * i / 2 - i * (i + 1) / 2 + 1;
        a %= 1000000007;

    }
    printf("%lld", a);
    return (0);
}


Measured memory_bytes: 1736
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main(string[] args) {
        var s = ReadLine();
        var t = ReadLine();

        if (String.Compare(new String(s.ToCharArray().OrderBy(str => str).ToArray()),
                           new string(t.ToCharArray().OrderBy(str => -str).ToArray())) < 0) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}



Measured memory_bytes: 13536
n = int(input())

A = list(map(int,input().split()))
from collections import Counter

for a in A:
  if a != 0:
    break
else:
  print('Yes')
  exit()

A = list(Counter(A).most_common())

if len(A) == 2 and A[1][0]==0 and A[1][1] == n//3:
  print('Yes')
  exit()

B = []
for a,c in A:
  if c != n//3:
    print('No')
    exit()
  B.append(a)
n = len(str(max(B)))
  
B = [[(1<<j&i)>>j for j in range(30)] for i in B]
for i in range(30):
  if B[0][i]^B[1][i]^B[2][i] != 0:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 60784
#include <iostream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int popcnt(uint32_t bits){
  int res=0;
  REP(i,32){
    if((bits>>i) & 1) ++res;
  }
  return res;
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<double>> dist(n,vector<double>(n));
  vector<valarray<double>> clr(n, valarray<double>(3));
  REP(i,n){
    double l,a,b;
    cin>>l>>a>>b;
    clr[i][0] = l;
    clr[i][1] = a;
    clr[i][2] = b;
  }
  REP(i,n)REP(j,n){
    valarray<double> d = clr[i] - clr[j];
    d = d*d;
    dist[i][j] = d.sum();
  }
  double dmx=0;
  REP(i,1<<n){
    if(popcnt(i) != m) continue;
    double dm=0;
    REP(j,n)
      if((i>>j)&1)
        REP(k,n)
          if((i>>k)&1)
            dm+=dist[j][k];
    dmx=max(dmx,dm/2);
  }
  cout<<setprecision(10)<<fixed<<dmx<<endl;
  return 0;
}

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

int main (){
    char S[100];
    int k;

    scanf("%d", &k);
    scanf("%s", S);
    int len = strlen(S);
    
    if(len <= k){
        printf("%s", S);
    }
    else{
        S[k] = '\0';
        printf("%s...", S);
    }
    
    return 0;
}

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

using namespace std;


template< typename T >
struct edge
{
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
template< typename T >
using UnWeightedGraph = vector< vector< T > >;
template< typename T >
using Matrix = UnWeightedGraph< T >;


template< typename T >
T prim(WeightedGraph< T > &g)
{
  using Pi = pair< T, int >;

  T total = 0;
  vector< bool > used(g.size(), false);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.emplace(0, 0);
  while(!que.empty()) {
    Pi p = que.top();
    que.pop();
    if(used[p.second]) continue;
    used[p.second] = true;
    total += p.first;
    for(auto &e : g[p.second]) {
      que.emplace(e.cost, e.to);
    }
  }
  return (total);
}

int main()
{
  int V, E;
  cin >> V >> E;
  WeightedGraph< int > g(V);
  for(int i = 0; i < E; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].emplace_back(y, z);
    g[y].emplace_back(x, z);
  }
  cout << prim(g) << endl;
}


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int k;
    cin>>k;
    int l=(k/2)*2;
    if(l==k)k=l-1;

    cerr<<k<<','<<l<<endl;
    cout<<(++k/2)*(++l/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int x, t;
    cin >> x >> t;

    if(x - t <= 0){
        p(0);
    }else{
        p(x - t);
    }
}


Measured memory_bytes: 256
let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f
let rec calc_n l = if l = 0 then 0 else 1 + calc_n (l/2)

let () = Scanf.scanf "%d" @@ fun l ->
  let n = calc_n l in

  let edges =
    Array.init (n-1) (fun i -> [(i, i+1, 1 lsl (n-2-i)); (i, i+1, 0)])
    |> Array.to_list |> List.concat |> List.rev
  in

  let edges =
    for_fold 1 n (1 lsl (n-1), edges) (fun (m, es) i ->
      if l land (1 lsl (n-1-i)) = 0 then m, es
      else (m + 1 lsl (n-1-i), (0, i, m) :: es)
    ) |> snd |> List.rev in

  Printf.printf "%d %d\n" n (List.length edges);
  List.iter (fun (a, b, c) -> Printf.printf "%d %d %d\n" (a+1) (b+1) c) edges

Measured memory_bytes: 2432
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

const ll INF = 1e18+7;
#define all(v) v.begin(),v.end()
#define repi(i,m,n) for(ll i = m;i < n;i++)
#define rep(i,n) repi(i,0,n)
typedef pair<ll,ll> P;
#define fi first
#define se second

//Range Minimum(Maximum) Query (RMQ)
//Big Range Query
//セグメント木 P(x, y) = P(値, 要素番号)
//インデックス取得したい場合: seg.update(k, k)
class SegmentTree{
public:
	ll n = 1;
	vector<P> seg[1];		//0:最大	1:最小
	void init(ll N){		//N要素のセグメントツリー作成
		while(n < N)n *= 2;
		rep(i,1)seg[i].resize(2*n);
		fill(all(seg[0]), P(-1, -1));
	}
  ll gcd(ll a, ll b) {
    if(a==-1)return b;
    if(b==-1)return a;
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
  P cmp_gcd(P x, P y){		//比較関数
		P zz;
    zz.fi=gcd(x.fi,y.fi);
    zz.se=x.se;
		return zz;
	}
	void update(ll k, ll x, bool flag=false){		//kの値をxに変更
		k += n-1;
		seg[0][k] = P(x, k-(n-1));
		if(flag){seg[0][k] = P(-1, -1);}
		while(k > 0){
			k = (k-1)/2;
			seg[0][k] = cmp_gcd(seg[0][k*2+1], seg[0][k*2+2]);
		}
	}
	P calc(ll a, ll b, ll k, ll l, ll r, ll f){
		if(b <= l || r <= a)return P(-1, -1);
		if(a <= l && r <= b)return seg[f][k];
		P vl = calc(a, b, k*2+1, l, (l+r)/2, f);
		P vr = calc(a, b, k*2+2, (l+r)/2, r, f);
		return cmp_gcd(vl, vr);
	}
	void erase(ll k){update(k, -1, true);}
	ll get_gcd(ll a, ll b){return calc(a, b, 0, 0, n, 0).fi;}
};


int main(){
  SegmentTree st;
  ll nn;
  cin>>nn;
  ll ans=0;
  vector<ll>v(nn,0);
  for(ll i=0;i<nn;i++){
    cin>>v[i];
  }
  st.init(nn);
  for(ll i=0;i<nn;i++){
    st.update(i,v[i]);
  }

  for(ll i=0;i<nn;i++){
    st.update(i,-1);
    ans=max(ans,st.seg[0][0].fi);
    st.update(i,v[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second




int main() {
	int x, sa;
	cin >> x;
	sa = x - 9;
	int p = (sa + 7 * 4) % 7;
	if (p == 1)cout << "sun" << endl;
	else if (p == 2)cout << "mon" << endl;
	else if (p == 3)cout << "tue" << endl;
	else if (p == 4)cout << "wed" << endl;
	else if (p == 5)cout << "thu" << endl;
	else if (p == 6)cout << "fri" << endl;
	else cout << "sat" << endl;
	return 0;
}



Measured memory_bytes: 3116
import math
S=input()
N=len(S)
L=[0]*N
count=0
for i in range(N-1):
    if S[i]=='R':
        count+=1
        if S[i+1]=='L':
            L[i]=math.ceil(count/2)
            L[i+1]=count//2
            count=0
            

count=0
for j in range(N-1):
    if S[N-1-j]=='L':
        count+=1
        if S[N-1-(j+1)]=='R':
            L[N-1-j]+=math.ceil(count/2)
            L[N-1-(j+1)]+=count//2
            count=0
            

print(" ".join([str(x) for x in L]))


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

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//const ll MOD = 1e+9 + 7;

int main() {

    string S; cin >> S;
    int p = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'p') p++;
    }
    int max_p = S.size() / 2;


    int ans = max_p - p;
    cout << ans << '\n';


}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

//LIS,最長増加部分列
template<typename T>
T LIS (int N,vector<T> &a){
	T INF = numeric_limits<T>::max();
	vector<T>dp(N+5, INF);//最後がaiの最長増加部分列の長さ
	for (int i = N-1; i >=0;--i) {
		*upper_bound(dp.begin(), dp.end(), a[i]) = a[i];//広義ならupper_boundに変える
	}
	int ans=lower_bound(dp.begin(), dp.end(), INF)-dp.begin();
  return ans;
}

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ans=LIS(n,a);
  cout<<ans;
  
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll a[maxn], num[maxn];//a records the number string, num[i] records the number of number string who modules p has remainder i
int qpow(int a, int b, int p)
{
	int ans=1;
	while(b)
	{
		if(b&1) ans = (ans*a) % p;
		a=a*a%p;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll n,p;
	scanf("%lld%lld",&n,&p);
	for(int i=1;i<=n;i++)
	{
		scanf("%1d",&a[i]);
	}
	ll ans=0;
	if(p==2 || p==5)
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]%p == 0) ans+=i;
		}
	}
	else
	{
		num[0]=1;//0 % p = 0, so initialize 1
		ll sum=0, x=1;//sum is the number corresponding to number string, x is 1ex
//		for(int i=n;i>=1;i--)
//		{
//			(sum+=a[i]*x)%=p;//sum=sum+s[i]*x, sum=sum%p;
//			x=x*10%p;
//			ans+=num[sum]++;
//		}
		for(int i=1;i<=n;i++)
		{
			sum=(sum*10+a[i]) % p;
			ans += num[( sum * qpow(x, p-2, p) )% p]++;
			x=x*10%p;
		}
	}
	cout<<ans<<endl;
}

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

#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int a,b,n;cin>>a>>b>>n;
  if(n<1e8){
    int ans=0;
    for(int i=1;i<=n;i++)chmax(ans,a*i/b-a*(i/b));
    fin(ans);
  }
  if(b<1e8){
    int ans=0;
    for(int i=1;i<=b;i++)chmax(ans,a*i/b-a*(i/b));
    fin(ans);
  }
  int ans=0;
  for(int k=0;k<=a*n/b;k++){
    //a*x==k*b+rの形でrをもっとも大きくする　だから、kb<=ax<(k+1)b
    int l=((k-1)*b)/a,r=(k+2)*b/a;//lが条件を満たす
    while(r-l>1){
      int mid=(r+l)>>1;
      (mid*a>=(k+1)*b?r:l)=mid;
    }
    if(a*l<k*b||a*l>=(k+1)*b)continue;
    chmax(ans,a*l/b-a*(l/b));
  }
  fin(ans);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn= 2e5+5;
int n,m,k;
int a[maxn],b[maxn];
ll sum[maxn];
int f(int c){
    int l=1,r=n;
    while(l<r){
        int mid=(l+r)>>1;
        if(sum[mid]>c)r=mid;
        else l=mid+1;
    }
    if(sum[l]>c)l--;
    return l;
}
int main() {
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
    }

    for(int i=1;i<=m;i++)cin>>b[i];

    ll sum1=0;
    int ans=0;

    for(int i=0;i<=m;i++){
        sum1+=b[i];
        if(sum1>k)break;
        ans= max(ans,i+f(k-sum1));
    }
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main(){
	int a,b,c,d,e;
	std::cin>>a>>b>>c>>d>>e;
	std::cout<<std::min(std::min(a,b),c)+std::min(d,e)-50<<std::endl;
}

Measured memory_bytes: 3092
n = int(input())
cnt = 0
if n == 1:
    print(4)
    exit()
if n == 2:
    print(4)
    exit()
if n == 4:
    print(4)
    exit()
while n != 4:
    if n%2 == 0:
        n = n//2
        cnt += 1
    else:
        n = 3*n+1
        cnt += 1
print(cnt+4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009


int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	ll ct=0;
	map<PLL,int> mp;
	VL arr;
	fr(i,1,n+1)
		arr.PB(i);
	int i=0,j=n-1;
	while(i<j)
	{
		if(arr[i]+arr[j]>n)
		{
			j--;
		}
		else if(arr[i]+arr[j]<n)
		{
			i++;
		}
		else
		{
			ct++;
			i++;
			j--;
		}
	}
	// fr(i,1,n)
	// {
	// 	fr(j,i,n)
	// 	{
	// 		if(i+j==n&&i!=j)
	// 		{
	// 			if(!mp.count(MP(j,i)))
	// 			{
	// 				ct++;
	// 				mp[MP(i,j)]=1;
	// 			}
	// 		}
	// 	}
	// }
	wl(ct);
	NL;
	return 0;
}

Measured memory_bytes: 10348
/**
 * Title: D - Disjoint Set of Common Divisors
 * Url: https://atcoder.jp/contests/abc142/tasks/abc142_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const ll MAX_N = 2000000;
bool prime[MAX_N];

set<ll> getPrimeFactors(ll n) {
    set<ll> primeFactors;
    ll sqrt_n = sqrt(n);
    for(ll i=2; i<=sqrt_n+1; i++) {
        if(prime[i]) {
            if(n%i==0) primeFactors.insert(i); 
        }
    }
    return primeFactors;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


void eratosthenes(bool prime[MAX_N]){
    for(int i=0; i<MAX_N; i++) {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i=0; i<MAX_N; i++) {
        if(prime[i]){
            for(int j = i + i; j < MAX_N; j+=i){
                prime[j] = 0;
            }
        }
    }
}

// 最大公約数
ll gcd(ll a, ll b) {
    if(a==b) return a;
    if(a<b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a%b;
    while(r!=0) {
        ll tmp_r = r;
        r = b % r;
        b = tmp_r;
    }
    return b;
}

int main() {
    ll a, b; cin >> a >> b;
    eratosthenes(prime);
    ll gcdn = gcd(a, b);
    auto primeFactors = prime_factor(gcdn);
    // set<ll> bPrimeFactors = getPrimeFactors(b);
    // set<ll> res;
    // set_intersection(aPrimeFactors.begin(), aPrimeFactors.end(), bPrimeFactors.begin(), bPrimeFactors.end(), inserter(res, res.end()));
    // ans = res.size();
    ll ans = primeFactors.size();
    cout << ans+1 << endl;

    return 0;
}

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

struct N {
  int i, d, c;
};

struct M {
  int i, bef, vel;
  double d;
};

bool operator<(const M &l, const M &r) { return l.d > r.d; }

int main() {
  while (true) {
    int n, m, s, g;
    cin >> n >> m;
    if (n + m == 0)
      break;
    cin >> s >> g;
    s--;
    g--;
    vector<vector<N>> p(n);
    for (int i = 0; i < m; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x--;
      y--;
      p[x].push_back(N{y, d, c});
      p[y].push_back(N{x, d, c});
    }
    vector<vector<vector<bool>>> used(
        n, vector<vector<bool>>(n + 1, vector<bool>(31)));
    priority_queue<M> q;
    q.push(M{s, n, 0, 0.});
    bool breaked = false;
    while (q.size()) {
      M now = q.top();
      q.pop();
      if (now.i == g && now.vel <= 1) {
        printf("%.9lf\n", now.d);
        breaked = true;
        break;
      }
      if (used[now.i][now.bef][now.vel])
        continue;
      used[now.i][now.bef][now.vel] = true;
      for (auto &path : p[now.i]) {
        if (path.i == now.bef)
          continue;
        for (int k = now.vel - 1; k <= now.vel + 1; k++) {
          if (k <= 0)
            continue;
          if (k > path.c)
            continue;
          if (used[path.i][now.i][k])
            continue;
          q.push(M{path.i, now.i, k, now.d + (double)path.d / k});
        }
      }
    }
    if (breaked)
      continue;
    cout << "unreachable" << endl;
  }
}


Measured memory_bytes: 15344
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 2e5+9;
int a[N], cnt[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll t1, t2; cin >> t1 >> t2;
    ll a1, a2; cin >> a1 >> a2;
    ll b1, b2; cin >> b1 >> b2;
    ll p = (a1-b1) * t1, q = (a2-b2) * t2;
    // ll p, q; cin >> p >> q;
    if(p + q == 0) {
        cout << "infinity" << endl;
        return 0;
    } 
    if(p < 0) {p *= -1; q *= -1;}
    if(p + q > 0) {
        cout << "0\n";
        return 0;
    }
    // p > 0 && q < 0
    ll r = -p-q;
    ll ans = 2*(p / r + 1) - (p%r==0) - 1;
    cout << ans << "\n";





    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    rep(i, m) {
        while('0' <= *pos) {
            b[i + 1] <<= 1;
            b[i + 1] += b[i + 1] << 2;
            b[i + 1] += *pos++ - '0';
        }
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


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

using namespace std;

#define int long long

int ans;
int inf = 1e18;

inline int oks(int x, int y) {
    if (y == 1) return 0;
    int cur = 1;
    while (cur < x) {
        if (cur > inf / y) return 0;
        cur *= y;
    }
    return cur == x;
}

void go(int i, int n) {
    int to = n / i;
    if (to == 1) {
        for (int j = 1; j * j <= n; ++j) {
            if (oks(n, j)) ans++;
            if (j * j != n && oks(n, n / j)) ans++;
        }
        return;
    }
    to--;
    for (int d = 1; d * d <= to; ++d) {
        if (to % d == 0) {
            if ((to + 1) % d != 0 && oks(i, d)) ans++;
            int D = to / d;
            if (D != d && (to + 1) % D != 0 && oks(i, D)) ans++;
        }
    }
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            go(i, n);
            if (i * i != n) go(n / i, n);
        }
    }
    /*for (int i = 2; i <= n; ++i) {
        int x = n;
        while (x >= i) {
            if (x % i == 0) x /= i;
            else x -= i;
        }
        if (x == 1) ans--;
    }*/
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
string a, b;
const int MAXN = 3005;
ll dp[MAXN][MAXN];
int n,m;
string ans;
ll solve(int i, int j){
    if(i == n) return 0;
    if(j == m) return 0;
    ll r = dp[i][j];
    if(r != -1) return r;
    if(a[i] == b[j])
        r = solve(i + 1, j + 1) + 1;
    else r = max(solve(i + 1,j), solve(i, j + 1));
    return dp[i][j] = r;
}
void build(int i,int j){
    if(i == n)return;
    if(j == m)return;
    ll answer = solve(i,j);
    if(a[i] == b[j] && answer == solve(i + 1, j + 1) + 1){
        ans.push_back(a[i]);
        build(i + 1, j + 1);
    }
    else if(answer == solve(i + 1,j))build(i + 1, j);
    else if(answer == solve(i, j + 1))build(i, j + 1);
    return;
}
int main(){
    fast;
    cin >> a >> b;
    n = a.size();
    m = b.size();
    memset(dp, -1, sizeof dp);
    solve(0, 0);
    build(0, 0);
    cout << ans << "\n";
    return 0;
}


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

const int maxn=3;
int a[maxn];
int main()
{
    while(cin>>a[0]>>a[1]>>a[2])
    {
        int k;
        cin>>k;
        sort(a,a+3);
        int ans=0;
        ans+=a[0]+a[1];
        int tmp=1;
        for(int i=1;i<=k;i++)
            tmp*=2;
       // cout<<tmp<<endl;
        //cout<<a[]
        ans+=a[2]*tmp;
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int l[80];
    for (int i = 0; i < N; i++) cin >> l[i];
    
    int res = 0;
    sort(l, l + N, greater<int>());
    for (int i = 0; i < K; i++) res += l[i];
    
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007
#define INF 1e10

using namespace std;

int main() {
    ios
    ll n;
    cin>>n;
    vector <double> p(n+1);
    rep(i, 1, n) cin>>p[i];
    vector <vector<double>> dp(n+1);
    dp[0].pb(1);
    rep(i, 1, n) {
        dp[i].pb(dp[i-1][0]*(1-p[i]));
        rep(j, 1, i) dp[i].pb(dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]));
    }
    double ans = 0;
    for(ll i=1+n/2; i<=n; i++) ans += dp[n][i];
    cout<<setprecision(10)<<ans;
    return 0;
}

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

int n, m;
string b[500];
unsigned int nB[500][16];

int allSearch() {
	int i, j, k;
	int ans = 0;
	
	for (i = 0; i < (1 << n); i++) {
		bool used[25];
		int usedCnt = 0;
		for (j = 0; j < n; j++) {
			used[j] = ((i >> j) % 2);
			usedCnt += used[j];
		}
		
		unsigned int state[16] = {0};
		for (j = 0; j < n; j++) {
			if (!used[j]) continue;
			for (k = 0; k < 16; k++) {
				state[k] ^= nB[j][k];
			}
		}
		
		for (j = 0; j < 16; j++) { if (state[j] != 0) break; }
		if (j == 16) { ans = max(ans, usedCnt); }
	}
	return ans;
}

int bitDP() {
	static int dp[2][1 << 23];
	unsigned int i, j;
	int INF = 114514;
	
	for (i = 0; i < 2; i++) for (j = 0; j < (1 << m); j++) dp[i][j] = -INF;
	dp[0][0] = 0;
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < (1 << m); j++) {
			dp[1][j] = max(dp[1][j], dp[0][j]);
			dp[1][j ^ nB[i][0]] = max(dp[1][j ^ nB[i][0]], dp[0][j] + 1);
		}
		for (j = 0; j < (1 << m); j++) {
			dp[0][j] = dp[1][j];
			dp[1][j] = -INF;
		}
	}
	return dp[0][0];
}

void setNum(int id) {
	for (int i = 0; i < 16; i++) {
		nB[id][i] = 0;
	}
	
	for (int i = 0; ; i++) {
		for (int j = 0; j < 32; j++) {
			if (32 * i + j >= m) { return; }
			nB[id][i] += ((unsigned int)(b[id][32 * i + j] - '0') << j);
		}
	}
}

int main() {
	while (cin >> n >> m) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> b[i];
		for (int i = 0; i < n; i++) setNum(i);
		if (n <= m) { cout << allSearch() << endl; }
		else { cout << bitDP() << endl; }
	}
	return 0;
}

Measured memory_bytes: 19644
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
T = True
for i in range(1, N-1):
  if H[i-1]==H[i] and H[i]<=H[i+1]:
    continue
  elif H[i-1]<H[i] and H[i]-1<=H[i+1]:
    H[i] -= 1
    continue
  else:
    T = False
    break
print("Yes" if T else "No")

Measured memory_bytes: 20800
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long int
#define ull unsigned long long int
 
#define lp(i,n) 	    for(int i=0;i<(int)(n);i++)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);i++)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);i--)
 
#define all(v)  	 ((v).begin()), ((v).end())
#define sz(v)    	 ((int)((v).size()))
#define clr(v, d)    memset(v, d, sizeof(v))
#define PB           push_back
#define MP           make_pair
#define N 100005
 
#define PI 3.14159265359
 
 
ll nChooseR(int n,int k);
ll gcd(ll a, ll b);
vector<string> split(string target,unsigned char c );


int n,k,t,m,x,y;

bool isPrime(ll h);
string s;

 

ll ans;

ll mod=1e9 +7;




int main() {
// freopen("pyramid.in","r",stdin); 
  //freopen("output.txt","w",stdout); 
cout.precision(10);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>m>>n;
lp(i,n)cin>>x,ans+=x;
if(ans>=m)cout<<"Yes";
else cout<<"No";
}
 
	
ll nChooseR( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;
   	ll result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}
 
ll gcd(ll a, ll b){
	return b==0?a:gcd(b,a%b);
	}
 
 
vector<string> split(string target,unsigned char c ){
	string d="";
	vector<string>arr;
	for(auto n:target)
	{
		if(n!=c)
		d+=n;
		else if(d!="")
		arr.push_back(d),d="";
	}
	if (d!="")
	arr.push_back(d),d="";
	return arr;
}
// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

int n, x, m, l[10], r[10], s[10], Max = -1;
vector<int>d, ans;
void dfs(int p) {
	if (p == n) {
		rep(i, m) {
			int cnt = 0;
			for (int j = l[i]; j <= r[i]; j++)cnt += d[j];
			if (cnt != s[i])return;
		}
		int c = accumulate(d.begin(), d.end(), 0);
		if (Max < c) {
			Max = c; ans = d;
		}
		return;
	}
	for (int i = 0; i <= x; i++) {
		d[p] = i; dfs(p + 1);
	}
}
int main() {
	scanf("%d%d%d", &n, &x, &m);
	d = vector<int>(n);
	rep(i, m) {
		scanf("%d%d%d", &l[i], &r[i], &s[i]); l[i]--; r[i]--;
	}
	dfs(0);
	if (Max == -1) {
		puts("-1"); return 0;
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}

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

int main () {
  int N, K;
  cin >> N >> K;
  int M = 1;
  for ( int i = 0; i < N; i++) {
    if ( 2 * M > K + M ) {
      M += K;
    }
    else M += M;
  }
  cout << M << endl;
}

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

int K;
vector<int> num;
void dfs(int keta, int N, vector<int> &num){
  num.push_back(N);
  if( keta == 10 ) return;
  else{
    for( int i = max(0LL, N%10-1); i <= min(9LL, N%10+1); i++ ){
      N = N*10+i;
      dfs(keta+1, N, num);
      N /= 10;
    }
  }
}
signed main() {
  cin >> K;
  for( int i = 1; i <= 9; i++ ) dfs(1, i, num);
  sort(num.begin(), num.end());
  cout << num.at(K-1) << endl;
  
}

Measured memory_bytes: 2420
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
	入力例：
	3
	1 1 3
*/
int main(){
	int iDataNum,st,sx,sy,i;
	int ct,cx,cy;
	int strInput[2];
	for(int i=0;i<2;i++){
	 scanf("%d", &strInput[i]);
	}
	
	for(int i=0;i<=strInput[0];i++){
		if (i*2+(strInput[0]-i)*4 == strInput[1]) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");


  return 0;
}

Measured memory_bytes: 1732
import sys

A, B, C, K = map(int, input().split())
ans = 0

if K > A:
    ans = ans + A
    K = K - A
    if K > B:
        K = K - B
        ans = ans - K
        print(ans)
        sys.exit()
    else:
        print(ans)
        sys.exit()
else:
    print(K)
    sys.exit()

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


int main(){
  int N;
  cin>>N;
  vector<uint64_t> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  uint64_t sum;
  uint64_t suma=0;
  uint64_t sums=0;
  for(int i=0;i<N;i++){
    suma+=a.at(i);
    suma=suma%2000000014;
  }
  suma=suma*suma;
  for(int i=0;i<N;i++){
    sums+=a.at(i)*a.at(i);
    sums=sums%2000000014;
  }
  if(suma>sums){
    sum=(suma-sums)/2;
  }else{
    sum=(sums-suma)/2;
  }
  sum=sum%1000000007;
  cout<<sum<<endl;
}
  

Measured memory_bytes: 4772
#include <stdio.h>

int main(){
  int n = 9, a, m;
  char s[16];

  while(n--){
    scanf("%s %d %d", s, &a, &m);
    printf("%s %d %d\n", s, a + m, a * 200 + m * 300);
  }
  return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>) {
    val (H, W, h, w) = readLine()!!.split(" ").map {it.toInt()}

    if (H % h == 0 && W % w == 0) {
        println("No")
        return
    }

    val A: Array<Array<Long>>

    if (H % h == 0) {
        val B = func(W, H, w, h)
        A = Array(H) { i -> Array(W)  { j-> B[j][i] } }
    } else {
        A = func(H, W, h, w)
    }

    println("Yes")
    for (r in A) {
        println(r.joinToString(" "))
    }
}

fun func(W: Int, H: Int, w: Int, h: Int): Array<Array<Long>> {
    val V = 1e6.toLong()
    val A = Array(W) { Array(H) { -V - 1L } }

    for (i in 0 until W step w) {
        for (j in 0 until H) {
            A[i][j] = V * (w - 1)
        }
    }

    return A
}


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long int lcm(long long int a, long long int b) {
    return a / gcd(a,b) * b;// divide first to avoid overflow
}

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

    long long int ans = 1;
    for(int i=0; i<n; i++){
        long long int t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n;
double p[3100];
double dp[3100][3100];
int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; i++)cin >> p[i];

    for(int i = n/2 + 1 ; i <= n; i++)dp[n][i] = 1;
    for(int i = n-1 ; i >= 0 ; i--)
        for(int cnt = 0 ; cnt <= i ;cnt ++ )
            dp[i][cnt] = p[i]*dp[i+1][cnt+1] + (1-p[i])*dp[i+1][cnt];

    printf("%.10f\n",dp[0][0]);
    return 0;
}


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

int main(){
   int c=0;
   char s[3];
   cin >>s;
   if(s[0]=='o') c++;
   if(s[1]=='o') c++;
   if(s[2]=='o') c++;
   cout <<700+c*100;

 }



Measured memory_bytes: 256
import java.util.Scanner;

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

		for(int i= 0; i<3; i++) {
			for(int j= 0; j<3; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		int N = sc.nextInt();
		int b[]=new int[100];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextInt();
		}

		int cnt=0;
		for(int i= 0; i<N; i++) {
			for(int j= 0; j<3; j++) {
				for(int k=0; k<3; k++) {
					if(A[j][k] == b[i]){
						A[j][k]=0;
					}
				}
			}
		}

		if(A[0][0]+A[0][1]+A[0][2]==0 ||
			A[1][0]+A[1][1]+A[1][2]==0 ||
			A[2][0]+A[2][1]+A[2][2]==0 ||
			A[0][1]+A[1][1]+A[2][1]==0 ||
			A[0][0]+A[1][0]+A[2][0]==0 ||
			A[0][2]+A[1][2]+A[2][2]==0 ||
			A[0][0]+A[1][1]+A[2][2]==0 ||
			A[0][2]+A[1][1]+A[2][0]==0) {
			System.out.print("Yes");
		}else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))

r = -1
s = 0

ans = 0
for l in range(n):
    while r < n - 1 and not (s & a[r+1]):
        s ^= a[r+1]
        r += 1
    ans += r - l + 1
    s ^= a[l]

print(ans)


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

int main() {
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ll sub = a[i - 1] + a[i];
        if (sub > x) {
            ans += abs(x - sub);
            a[i] = a[i] - abs(x - sub);
        }
        if (a[i] < 0) a[i] = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOOD 1000000007

using namespace std;
using ll = long long;
using P = pair<int,int>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n = 0):d(n,-1){};

    int find(int x){
        if(d[x] < 0) {
            return x;
        }
        else{
            return d[x] = find(d[x]);
        }
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);

        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return -d[find(x)];
    }

};

struct mint {
    ll x;

    mint(ll x) : x((x % MOOD + MOOD) % MOOD) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOOD) x -= MOOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOOD-a.x) >= MOOD) x -= MOOD;
        return *this;
    }

    mint &operator*=(const mint a) {
        if ((x *= a.x) %= MOOD);
        return *this;
    }

    mint operator+(const mint a)const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const{
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(MOOD-2);
    }

    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }

};

mint kaijyo(int n) {
    if (n == 0) return 1;
    mint x = kaijyo(n/2);
    x *= x;
    if (n%2 == 1) x *= 2;
    return x;
}

mint choose(int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main() {
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==B && A !=C){
        printf("Yes");
    }
    else if(A==C && C != B){
        printf("Yes");
    }
    else if(B==C && C != A){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}



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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  int ans = 0;
  int N;
  cin >> N;

  FOR(i, 1, N + 1) {
    if (i % 2 == 0) {
      continue;
    }

    int range = sqrt(i) + 1;
    int count = 0;
    FOR(j, 1, range) {
      if (i % j == 0) {
        count++;
      }
    }

    if (count == 4) {
      ans++;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n;
char s[30010];
int main(){
	scanf("%d %s",&n,s);
	int ans=0;
	rep(a,0,10)rep(b,0,10)rep(c,0,10){
		int i=0;
		while(i<n&&s[i]!=a+'0')i++;
		i++;
		while(i<n&&s[i]!=b+'0')i++;
		i++;
		while(i<n&&s[i]!=c+'0')i++;
		if(i<n)ans++;
	}
	printf("%d",ans);
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			char[][] pattern = new char[8][];
			for (int i = 0; i < 8; i++)
			{
				pattern[i] = Console.ReadLine().ToCharArray();
			}
			Console.WriteLine(90);
			pattern = Rotate(pattern);
			WritePattern(pattern);
			Console.WriteLine(180);
			pattern = Rotate(pattern);
			WritePattern(pattern);
			Console.WriteLine(270);
			pattern = Rotate(pattern);
			WritePattern(pattern);
		}

		static void WritePattern(char[][] c)
		{
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 8; j++)
				{
					Console.Write(c[i][j]);
				}
				Console.WriteLine();
			}
		}

		static char[][] Rotate(char[][] pattern)
		{
			char[][] r = new char[8][];
			for (int i = 0; i < 8; i++)
				r[i] = new char[8];
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 8; j++)
				{
					r[i][j] = pattern[7 - j][i];
				}
			}
			return r;
		}
	}
}

Measured memory_bytes: 5552
t = input()
s = input()
ans = ""
l = len(s)
for i in range(len(t)-len(s)+1):
    p = t[i:i+l]
    count = 0
    for j in range(l):
        if s[j] == p[j] or p[j] == "?":
            count += 1
        else:
            break
    if count == l:
        ans = t[:i]+s+t[i+l:]
if ans == "":
    print("UNRESTORABLE")
    exit()

for i in range(len(ans)):
    if ans[i] == "?":
        print("a", end="")
    else:
        print(ans[i], end="")
print()


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


using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "SUN")  cout << 7;
    if (s == "MON") cout << 6;
    if (s == "TUE") cout << 5;
    if (s == "WED") cout << 4;
    if (s == "THU") cout << 3;
    if (s == "FRI") cout << 2;
    if (s == "SAT") cout << 1;
}


Measured memory_bytes: 256