akhauriyash/Code-Regression huggingface dataset:
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    int,
    null_type,
    less<long long int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;if(b%2==1) c*=a;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//


  int main()
{    fast;
    ll n;cin>>n;
     ll ans=(n*(n+1))/2;
     for(ll i=2;i<=n;i++)
     {
         for(ll j=i;j<=n;j+=i)ans+=j;
     }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> B(N - 1);

    for (ll i = 0; i < N - 1; i++)
    {
        cin >> B.at(i);
    }

    ll count = 0;
    for (ll i = 1; i < N - 1; i++)
    {
        count += min(B.at(i - 1), B.at(i));
    }

    // 最初と最後
    count += B.at(0);
    count += B.at(N - 2);
    cout << count << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;

ll a , b , c , d ;

int main()
{
	speed;

    vector<int>vc;

    int n ;
    cin >> n ;
    for(int i = 0 ; i < n ; i ++ ){
        char s ;
        cin >> s ;
        if( s == 'P' ){
            a=1;
        }
        if( s == 'W' ){
            b=1;
        }
        if( s == 'G' ){
            c=1;
        }
        if( s == 'Y' ){
            d=1;
        }
    }
    vc.push_back(a);
    vc.push_back(b);
    vc.push_back(c);
    vc.push_back(d);
    for(int i = 0 ; i < 4 ; i ++ ){
        if(vc[i]==1){
            z++;
        }
    }
    if(z==3){
        cout<<"Three"<<endl;
    }
    else{
        cout<<"Four"<<endl;
    }

	time;
}


Measured memory_bytes: 256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 15:41:57

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	ll n, x;
	cin >> n;
	ll mmin = 1e18;
	for(int i = 1; i <= 5; ++i){
		cin >> x;
		mmin = min(mmin, x);
	}
	cout << ((n+mmin-1)/mmin + 4) << endl;
	return 0;
}

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

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

    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max({(N-1)/A, (N-1)/B, (N-1)/C, (N-1)/D, (N-1)/E})+5 << "\n";
}

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

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long ExtGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (ExtGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static private long ModInverseInner(long a, long dummy1 = 0, long dummy2 = 0) => ExtGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);
    static public long ModInverse(long a) => ModInverseInner(a, 0, 0);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        var lr = Console.ReadLine().ToIntArray();
        long L = lr[0];
        long R = lr[1];

        long ans = 2018;

        //iとjそれぞれせいぜい2019個見れば十分
        for (long i = L; i <= Math.Min(R - 1, L + 2019); i++)
        {
            for (long j = i + 1; j <= Math.Min(R, L + 2019); j++)
            {
                ans = Math.Min(ans, (i * j) % 2019);
            }
        }

        Console.WriteLine(ans);
    }
    
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int k; string s;  cin >> k>>s;
  if (s.length()<=k) {
    cout << s << endl;
    return 0;
  } 
  rep(i,k) {
    cout << s[i];
  }
  cout << "..." << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	int n, m, x, y;
	cin >> n >> m >> x >> y;

	vi xi(n);
	vi yi(m);

	REP(i, n) {
		cin >> xi[i];
	}
	REP(i, m) {
		cin >> yi[i];
	}

	sort(ALL(xi));
	sort(ALL(yi));

	int z = x + 1;
	if(xi[n-1] > x) z = xi[n - 1] + 1;

	bool warFlag = (z <= yi[0] && z <= y);

	if (warFlag) {
		out<string>("No War");
	}
	else {
		out<string>("War");
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int h,w;
ll dp[1005][1005];
void builddp(string s[])
{
	for(int i=0;i<h;i++)
	{
		if(s[i][0]=='.')
			dp[i][0]=1;
		else
			break;
	}
	for(int i=0;i<w;i++)
	{
		if(s[0][i]=='.')
			dp[0][i]=1;
		else
			break;
	}
	for(int i=1;i<h;i++)
	{
		fab(1,w,j)
		{
			if(s[i][j]=='#')
				continue;
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}
int main()
{ quick;

    cin>>h>>w;
    string s[h];
    fab(0,h,i)
    cin>>s[i];
    builddp(s);
	

	return 0;
}

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

template<typename T>
struct Kruskal{
    struct edge{
        int from,to,used; T cost;
        edge(int from,int to,T cost):
            from(from),to(to),cost(cost),used(0){}
        bool operator<(const edge &e) const{
            if (cost!=e.cost) return cost<e.cost;
            else if (from!=e.from) return from<e.from;
            else return to<e.to;
        }
    };
    int num;
    vector<int> par,rank;
    vector<edge> es;
    Kruskal(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
    void add_edge(int u,int v,T c){
        es.emplace_back(u,v,c);
    }
    T build(){
        sort(es.begin(),es.end());
        T res=0;
        for (auto &e:es){
            if (!same(e.from,e.to)){
                res+=e.cost;
                merge(e.from,e.to);
                e.used=1;
            }
        }
        return res;
    }
    vector<int> used_es(T &c){
        int E=es.size();
        map<edge,int> m;
        for (int i=0;i<E;++i) m[es[i]]=i;
        c=build();
        vector<int> list(E);
        for (int i=0;i<E;++i) list[m[es[i]]]=es[i].used;
        return list;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin >> n >> m,n,m){
        Kruskal<int> K(n);
        for (int i=0;i<m;++i){
            int a,b,cost; cin >> a >> b >> cost;
            K.add_edge(a,b,cost);
        }
        cout << K.build() << '\n';
    }
}


Measured memory_bytes: 3036
#include <iostream>
#include<map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long

int main() {
	string s;
	int k;
	cin >> s >> k;
	map<string, int> ma;
	rep(i, k) {
		rep(j, s.size() - i) {
			ma[s.substr(j, i + 1)]++;
		}
	}
	int i = 0;
	for (auto itr : ma) {
		i++;
		if (i == k) {
			cout << itr.first;
		}
	}

	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#define abs(X) ((X) < 0 ? -(X) : (X))
using namespace std;
typedef long long ll;

ll n, k;
ll x[100005];
ll ans = 1ll << 60ll;

int main() {
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> x[i];
    }

    for (ll i = 0; i < n; i++) {
        if (i + k - 1 >= n) break;

        ll j = i + k - 1;

        if (x[j] <= 0) {
            ans = min(ans, abs(x[i]));
        }
        if (x[i] <= 0 && x[j] >= 0) {
            ll d = x[j] - x[i];
            d += min(x[j], abs(x[i]));

            ans = min(ans, d);
        }
        if (x[i] >= 0) {
            ans = min(ans, x[j]);
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
input()
a = list(map(int, input().split()))
for _ in range(int(input())):
	b,m,e = map(int, input().split())
	x=a[m:e]
	a[b+e-m:e]=a[b:m]
	a[b:b+e-m]=x
print(" ".join(list(map(str,a))))


Measured memory_bytes: 5628
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


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

   int app[n];
  
   for(int i=1;i<=n;i++){
     
      app[i-1] = i+l-1;
     
     
   }

   // cout << "Good" << endl;

   sort(app, app + n); 
  
  
   int ans = 0;
   int sum = 0;
    
    for(int i=0;i<n;i++){
     
    
      
    //  if(ans>app[i]){
       
    //    ans = app[i];
    //  }
      
       sum = sum+app[i];
    // cout << app[i] << endl;
     
   }
   int minnum = 0;
   int min = 100000;
  
   for(int i=0;i<n;i++){
     
     int ab=abs(app[i]);
     
      
      if(min>app[i]){
       
        min = ab;
        minnum = i;
      }
      
       //sum = sum+app[i];
    // cout << app[i] << endl;
     
   }
  
  
  cout << sum-app[minnum] << endl;
  
  return 0;
}

Measured memory_bytes: 256
def solve_B():
    s = input()
    n = len(s)
    
    ans = 1000
    for i in range(n-2):
        x = 100 * int(s[i]) + 10 * int(s[i+1]) + int(s[i+2])
        x -= 753
        if x < 0:
            x = -1 * x
        ans = min(x, ans)
    return ans

print(solve_B())

Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
H.append((H[N - 1] + 1))
count = 0
count_list = []

for i in range(N):
    if H[i + 1] <= H[i]:
        count += 1
    else:
        count_list.append(count)
        count = 0

print(max(count_list))

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_161c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long K = long.Parse(input[1]);

            long first = 0;
            long second = 0;
            
            first = N % K;
            second = K - first;

            if (first < second)
            {
                Console.WriteLine(first);
            }
            else
            {
                Console.WriteLine(second);
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 27472
#include <stdio.h>
#include <math.h>

int main()
{
	int i, w;
	int n, k, j;
	double all=0;

	scanf("%d %d",&n,&k);

	for(i=n; i>0; i--){
		for(j=0; ; j++){
		if(i*pow(2,j)>=k)
			break;
		}
		all+=pow(0.5,j)*(1.0/n);
	}

	printf("%.12lf\n",all);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
vector<int> v[100010];
bool vis[100010];
vector<int> f,g;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<n;i++)vis[i]=false;
	f.push_back(0),g.push_back(0);
	vis[0]=true;
	
	while(true){
		int x=f[f.size()-1];
		bool ok=true;
		for(int i=0;i<v[x].size();i++){
			if(vis[v[x][i]]==false&&ok){
				f.push_back(v[x][i]);
				vis[v[x][i]]=true;
				ok=false;
			}
		}
		if(ok)break;
	}
	while(true){
		int x=g[g.size()-1];
		bool ok=true;
		for(int i=0;i<v[x].size();i++){
			if(vis[v[x][i]]==false&&ok){
				g.push_back(v[x][i]);
				vis[v[x][i]]=true;
				ok=false;
			}
		}
		if(ok)break;
	}
	cout<<f.size()+g.size()-1<<endl;
	for(int i=f.size()-1;i>0;i--)cout<<f[i]+1<<" ";
	for(int i=0;i<g.size();i++){
		cout<<g[i]+1;
		if(i<g.size()-1)cout<<" ";
	}cout<<endl;
	return 0;
}


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

int main(){
  int n;cin >> n;
  int p[n],sum=0;
  for(int i=0;i<n;i++)cin >> p[i];
  for(int i=2;i<n;i++){
    if(p[i-2]<p[i-1]&&p[i-1]<p[i])sum++;
    if(p[i-2]>p[i-1]&&p[i-1]>p[i])sum++;
  }
  cout << sum;
}

Measured memory_bytes: 256
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n;
ll a[N];

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

    #ifdef krauch
//        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    cin >> n;
    forn(i, 1, n) {
        cin >> a[i];
    }

    if (a[n] != 2) {
        cout << "-1\n";
        return 0;
    }

    ll mn = 2, mx = 2;
    for1(i, n - 1, 1) {
        ll mn2 = ((mn + a[i] - 1) / a[i]) * a[i];
        if (mn2 >= mn + a[i + 1] && (mn2 / a[i + 1]) * a[i + 1] > mx) {
            cout << "-1\n";
            return 0;
        }
        ll mx2 = ((mx + a[i + 1] - 1) / a[i]) * a[i];
        if (mx2 < mx && (mx2 / a[i + 1]) * a[i + 1] < mn) {
            cout << "-1\n";
            return 0;
        }
        mx = mx2;
        mn = mn2;
    }

    mx += a[1] - 1;

    cout << mn << " " << mx << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
    int n,cnt=0;
    ll a[100000],ans=0,mini=1000000001;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]>0){
            ans+=a[i];
            mini=min(mini,a[i]);
        }
        else{
            ans-=a[i];
            cnt++;
            mini=min(mini,-a[i]);
        }
    }
    if(cnt%2){
        printf("%lld\n",ans-2LL*mini);
    }
    else{
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
# define int ll
//int arr[SIZE]={};
//???????????§???????????¬
//????????????????±???????SegmentTree
struct SegmentTreeSum {
private:
    int n;
    vector<int> node;

public:
    // ????????? v ????????°???????????¨??§??¨?????????
    SegmentTreeSum(vector<int> v) {
        // ???????????????????????°??????????????????????????\????????????????°???? 2 ??? -> ????????? n ??¨??????
        // ?????°???????????¨??¨?????§????????????????????°??? 2n-1 ?????§??????
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);

        // ????????????????????\???????????¨??????????????????????????????????????\??????
        // ????????\?????????????????????????????? 2 ???????????§????????°??????
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = (node[2*i+1] + node[2*i+2]);
    }
	void update(int x, int val) {
		// ??????????????????????????¢???????????????
		x += (n - 1);

		// ??????????????????????????´??°?????????????????¨??????????????£?????´??°????????????
		node[x] = val;
		while(x > 0) {
			x = (x - 1) / 2;
			node[x] = (node[2*x+1] + node[2*x+2]);
		}
	}
	int getsum(int a, int b, int k=0, int l=0, int r=-1) {
		// ?????????????????????????????¨??????????±?????????? [0, n)
		if(r < 0) r = n;

		// ????±?????????¨????±????????????????????????? -> ???????????????
		if(r <= a || b <= l) return 0;

		// ????±??????????????±???????????????¨????¢???? -> ????±????????????????????¨?????????????
		if(a <= l && r <= b) return node[k];

		// ????±??????????????±???????????????¨????¢???? -> ?????????????????¢?´¢?????????
		// ?????´????????? vl ??? ?????´????????? vr ??¨????????????
		// ??°??????????±??????????????????¨???????±????????????????????????£?????????
		int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
		int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
		return (vl + vr);
	}
};
//????????????????±???????SegmentTree

vector<int> node;
signed main(){
	int N,Q;
	cin>>N>>Q;
	for(int i=0;i<N+1;i++){
		node.push_back(0);
	}
	SegmentTreeSum sum(node);
	for(int i=0;i<Q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(a){
			cout<<sum.getsum(b,c+1)<<endl;
		}
		else{
			sum.update(b,c+sum.getsum(b,b+1));
		}
	}
	return 0;
}

Measured memory_bytes: 6564
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

string s;

int abs(int a){
	if(a < 0) return -a;
	else return a;
}

int main(){
	cin >> s;
	int res = 100000;
	for(int i = 2; i < s.length(); i++){
		int a = 100 * (s[i - 2] - '0') + 10 * (s[i - 1] - '0') + s[i] - '0';
		res = min(res, abs(a - 753));
	}
	cout << res << endl;
	return 0;
}


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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n,m;
		cin >> n >> m;
		int ans = (n*(n-1))/2;
		ans += (m*(m-1))/2;
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 256
def calc(a, b):
    m = min(a, b)
    l = max(a, b)
    while m != 0:
        s = m
        m = l % m
        l = s
    return l

K = int(input())
ans = 0
for i in range(K):
    for j in range(i+1):
        for k in range(j+1):
            if i == j == k:
                ans += i+1
            elif i == j:
                ans += 3 * calc(i+1, k+1)
            elif j == k:
                ans += 3 * calc(i+1, j+1)
            else:
                ans += 6 * calc(calc(i+1, j+1), k+1)

print(ans)

Measured memory_bytes: 9216
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N = int(input())
S = str(input())
dp = [[0 for j in range(3)] for i in range(N)]
ans = 0
temp = temp2 = temp3 = 0

RGB = [["R", "G"], ["R", "B"], ["B", "R"], ["B", "G"], ["G", "R"], ["G", "B"]]


for j in range(6):
  for i in range(N):
    if(S[i]== RGB[j][0]):
      temp += 1
    elif(S[i]==RGB[j][1]):
      temp2 += temp
    else:
      temp3 += temp2
  ans += temp3
  temp = temp2 = temp3 = 0

for i in range(N):
  for j in range(1, N+1):
    if(i+2*j > N-1):
      continue
    if(S[i] != S[i+j] and S[i+j] != S[i+2*j] and S[i] != S[i+2*j]):
      ans -= 1


print(ans)


Measured memory_bytes: 71152
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int dp[101][101];

int fun(vector<vector<char>> arr,int si,int sj,int ti,int tj,int count,bool flag)
{

   if(dp[si][sj]!=-1)
    return dp[si][sj];

  if(arr[si][sj]=='#')
   {
    if(!flag)
   {
     count++;
      flag=true;
   }
   }

  else
  flag=false;




  if(si==ti && sj==tj)
  {
  // cout<<count<<endl;

    dp[si][sj]=count;
    return count;
  }
  int ans=INT_MAX;
  
 if(si+1<=ti)
 ans= min(ans, fun(arr,si+1,sj,ti,tj,count,flag));

  if(sj+1<=tj)
 ans= min(ans, fun(arr,si,sj+1,ti,tj,count,flag));


  dp[si][sj]=count;
 return ans;
}
   


int main()
{
  int n,m;
   cin>>n>>m;
   
  int a= (n*(n-1))/2;
   int b= (m*(m-1))/2;

   a= max(0,a);
    b= max(0,b);

   cout<<a+b;
 
return 0;
}

    
  

   


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll mmax[500001]={};
int main(){
	string S;
	scan(S);
	int N=S.size()+1;
	ll ans=0;
	rep(i,N-2){
		if(S[i]=='>'&&S[i+1]=='<'){
			ll cnt=0;
			for(int j=i;j>=0;j--){
				if(S[j]=='>'){
					cnt++;
				}
				else break;
				mmax[j]=max(mmax[j],cnt);
			}
			cnt=0;
			for(int j=i+1;j<=N-2;j++){
				if(S[j]=='<'){
					cnt++;
				}
				else break;
				mmax[j+1]=max(mmax[j+1],cnt);
			}
		}
	}
	if(S[0]=='<'){
		ll cnt=0;
		for(int j=0;j<=N-2;j++){
			if(S[j]=='<'){
				cnt++;
			}
			else break;
			mmax[j+1]=max(mmax[j+1],cnt);
		}
	}
	if(S[N-2]=='>'){
		ll cnt=0;
		for(int j=N-2;j>=0;j--){
			if(S[j]=='>'){
				cnt++;
			}
			else break;
			mmax[j]=max(mmax[j],cnt);
		}
	}
	rep(i,N){
		ans+=mmax[i];
		//printf("%lld ",mmax[i]);
	}
	//kaigyo;
	prin(ans);
	return 0;
}


Measured memory_bytes: 4740
# coding: UTF-8
import sys
import numpy as np
import time

# f = open("input.txt", "r")
# sys.stdin = f

n = int(input())
a = list(map(int, input().split()))
tmpMax = a[0]
ans = 0
for num in a:
	ans += max(0, tmpMax-num)
	if tmpMax < num:
		tmpMax = num
print(ans)

Measured memory_bytes: 50864
d,g = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(d)]
m = 10000
for i in range(2**d):
  cur = bin(i)[2:]
  cur = '0' * (d-len(cur)) + cur
  s = 0
  c = 0
  nu = [] #not use
  for i in range(d):
    if cur[i] == '0':
      nu.append(i)
    else:
      s += (i+1) * 100 * pc[i][0] + pc[i][1]
      c += pc[i][0]
  if s < g:
    if g - s <= (nu[-1]+1) * 100 * pc[nu[-1]][0]:
      c += (g-s-1)//((nu[-1]+1)*100) + 1
      m = min(c,m)
  else:
    m = min(c,m)
print(int(m))

Measured memory_bytes: 3064
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#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;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
void AcDegaYe()
{
    ll n,cnt=0;
    cin>>n;
    vec a;
    inpvec(a,n);
    sort(all(a));
    vec visited(1000001);
    for(ll i=0;i<n;i++) 
    {
        if(visited[a[i]]==0)
        {
            for(int j=2*a[i];j<=1000000;j+=a[i])visited[j]++;
            if(i+1<n && a[i]==a[i+1])visited[a[i]]++;
        }
    }
    for(auto x:a)if(!visited[x])cnt++;
    cout(cnt);
}
int main()
{   
    fastio
    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 12712
import sys
sys.setrecursionlimit(10**5)
from collections import defaultdict

n = int(input())
e = [[] for i in range(n)]
for i in range(1,n):
    x = int(input())
    e[x-1].append(i)

def dfs(x):

    count = len(e[x])
    if count == 0:
        return 0
    d = defaultdict(int)
    ma = 0
    s = set()
    for nex in e[x]:
        v = dfs(nex)
        d[v] += 1
        s.add(v)
        ma = max(ma,v)
    now = count
    bef = 0
    for v in sorted(list(s),reverse=True):
        bef += d[v]
        now = max(now,bef+v)
    return now

print(dfs(0))

Measured memory_bytes: 159372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(s[i]=='W'){
			cnt++;
		}
	}
//	cout <<cnt<<endl;
	ll ans=0;
	for(ll i=n-1;i>=0;i--){
		if(cnt==0){
			break;
		}		
		cnt--;
		if(s[i]!='W'){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int const MAXN=100009;

int main(){
	LL n,a,b;
	cin>>n>>a>>b;
	LL arr[MAXN];
	for(LL i=0;i<n;i++){
		cin>>arr[i];
	}
	LL sum=0;
	for(LL i=1;i<n;i++){
		if((arr[i]-arr[i-1])*a<b){
			sum+=(arr[i]-arr[i-1])*a;
		}else{
			sum+=b;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <string>


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

  std::string S, T;
  std::cin >> S >> T;
  std::cout << T+S << std::endl;

  return 0;
}


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

int main(){
  string s;
  cin>>s;
  int minimum=999;
  for(int i=0;i<s.length()-2;i++){
    int hyaku=s[i]-'0';
    int juu=s[i+1]-'0';
    int iti=s[i+2]-'0';
    int picked=100*hyaku+10*juu+iti;
    minimum=min(abs(picked-753),minimum);
  }
  cout<<minimum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, R;
  cin >> N >> R;
  ll ans = R;
  if (N < 10) ans += 100 * (10 - N);
  cout << ans << endl;
  return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e3 + 5;

bool visited[maxr];
int32_t main()
{
	GO;
	int n, k;
	cin >> n >> k;
	memset(visited, 0, sizeof(visited));
	for (int i = 0; i < k; i++) {
		int d, a;
		cin >> d;
		for (int i = 0; i < d; i++) {
			cin >> a;
			visited[a] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (visited[i] == 0)
			ans++;
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll a, b;
    cin >> a >> b;
    ll dh = b - a;
    ll h = 0;
    for(ll i = dh - 1; i >= 1; i--) h += i;
    cout << h - a << endl;
    return;
}

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


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W = map(int, rl().split())
    grid = [[] for _ in range(H)]
    que = deque()
    for i in range(H):
        grid[i] = list(rl().rstrip())
        for j in range(W):
            if grid[i][j] == '#':
                que.append((i, j))
    
    ans = -1
    while que:
        n = len(que)
        for _ in range(n):
            cy, cx = que.popleft()
            for dy, dx in ((-1, 0), (0, 1), (1, 0), (0, -1)):
                ny, nx = cy + dy, cx + dx
                if 0 <= nx < W and 0 <= ny < H:
                    if grid[ny][nx] == '.':
                        grid[ny][nx] = '#'
                        que.append((ny, nx))
        ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 141408
n, a, b, k = map(int, input().split())

mod = 998244353

# combination---
# nとmodは適宜変える

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+5):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
for ca in range(n+1):
    cb = (k - a * ca) // b
    if (k - a * ca) % b != 0:
        continue
    ans += nck(n, ca) * nck(n, cb)
    ans %= mod

print(ans)


Measured memory_bytes: 38936
import java.util.Scanner;
class Main {
	int[] ai = new int [100];
	int n = 0,w,j = 1,h,i;
	public void nu () {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		if(n >= 0 || n <= 100) {
			for(w = 0; w < n; w++) {
				ai[w] = sc.nextInt();
			}
			for(w = n-1; w > 0; w--) {
				System.out.printf("%d ",ai[w]);
			}
			System.out.println(ai[0]);
		}
	}
	public static void main(String[] args) {
		new Main().nu();
	}
}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

LLI func(LLI N, LLI ga, LLI sa, LLI ba, LLI gb, LLI sb, LLI bb){
    LLI gN=0, sN=0, bN=0, gsN=0, gbN=0, sbN=0, gsbN=0;

    if(ga < gb) gN = N%ga + (N/ga) * gb;
    if(sa < sb) sN = N%sa + (N/sa) * sb;
    if(ba < bb) bN = N%ba + (N/ba) * bb;


    if(ga < gb and sa < sb){
      FORE(g,0,N){
	if(g*ga>N) break;
	chmax(gsN, g*gb+(N-g*ga)%sa+((N-g*ga)/sa)*sb);
      }
    }

    if(ba < bb and sa < sb){
      FORE(b,0,N){
	if(b*ba>N) break;
	chmax(sbN, b*bb+(N-b*ba)%sa+((N-b*ba)/sa)*sb);
      }
    }

    if(ba < bb and ga < gb){
      FORE(b,0,N){
	if(b*ba>N) break;
	chmax(gbN, b*bb+(N-b*ba)%ga+((N-b*ba)/ga)*gb);
      }
    }

    if(ga < gb and sa < sb and ba < bb){
      FORE(g,0,N){
	FORE(s,0,N){
	  LLI t = g*ga+s*sa;
	  if(t > N) break;

	  chmax(gsbN, g*gb+s*sb	+ (N-t)%ba + ((N-t)/ba)*bb);
	}
      }
    }


    dump(N,gN,sN,bN,gsN,gbN,sbN,gsbN);

    return max({N,gN,sN,bN,gsN,gbN,sbN,gsbN});
}

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

  LLI N;
  while(cin >> N){
    LLI ga,sa,ba,gb,sb,bb; cin >> ga >> sa >> ba >> gb >> sb >> bb;

    LLI n = func(N,ga,sa,ba,gb,sb,bb);
    LLI ans = func(n,gb,sb,bb,ga,sa,ba);
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, K;
	
	cin>>A>>B>>K;
	
	if(A >= K) cout<<A - K<<" "<<B<<endl;
	else if(A + B >= K) cout<<0<<" "<<A + B - K<<endl;
	else cout<<0<<" "<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
      if(i<=k)
        ans+=x;
      else
        ans+=y;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
def main():
    n,m = map(int,input().split())
    a = [-1]
    d = 10**9+7
    for i in range(m):
        a.append(int(input()))
    a.append(n+1)
    fib = [1,1]
    for i in range(n):
        fib.append(fib[-2]+fib[-1])
    ans = 1
    for i in range(m+1):
        x = a[i+1]-a[i]-2
        if x == -1:
            ans = 0
            break
        ans = ans*fib[x]%d
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 464036
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int n;
int S[100001];

int BinarySearch(int key){
    int left = 0;
    int right = n - 1;
    int mid;

    while(left <= right){
        mid = (left + right) / 2;

        if(S[mid]  == key){
            return 1;
        }else if(S[mid] < key){
            left = mid + 1;
        }else{
            right = mid - 1;
        }
    }

    return 0;
}

int main()
{
    cin >> n;
    int q,c = 0;
    vector<int> T(n);

    rep(i, n){
        cin >> S[i];
    }

    cin >> q;

    rep(i, q){
        cin >> T.at(i);
        c += BinarySearch(T.at(i));
    }

    cout << c << endl;
}


Measured memory_bytes: 3496
N = gets.to_i
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i
time_list = [A,B,C,D,E]
min = time_list.min
min_index = time_list.index(min)
puts (N/min) + (N%min==0 ? 0 : 1) + 4-min_index + min_index

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String temp = scanner.nextLine();
		char[] list = temp.toCharArray();
		int flag  = 0;

		for(int i = 1; i <= list.length; i++) {

			if(i % 2 == 0) {
					if(list[i - 1] == 'L' || list[i - 1] == 'U' || list[i - 1] == 'D') {
					}else {flag++; break;}
			}else {

					if(list[i - 1] == 'R' || list[i - 1] == 'U' || list[i - 1] == 'D') {
					}else {flag++; break;}
				}
		}

		if(flag == 0) {
			System.out.println("Yes");
		}else System.out.println("No");

	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll twonum = (n / 2LL), fivenum = 0;
  n /= 2;
  ll now = 2;
  while (now <= n){
    twonum += n / now;
    if (now > LLONG_MAX / 2LL) break;
    now *= 2;
  }
  now = 5;
  while (now <= n) {
    fivenum += n / now;
    if (now > LLONG_MAX / 5LL) break;
    now *= 5;
  }
  cout << min(twonum, fivenum) << endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
mod = 998244353

def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(0, k+1):
  ans += m*cmb(n-1, i, mod)*powerDX(m-1, n-i-1, mod)
  ans %= mod
print(ans)

Measured memory_bytes: 33084
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[]str = Console.ReadLine().Split();
		string[]str2 = Console.ReadLine().Split();
		string[]str3 = Console.ReadLine().Split();
		int[]A = new int[N];
		int[]B = new int[N];
		int[]C = new int[N];
		int ans = 0;
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
			B[i] = int.Parse(str2[i]);
			ans += B[i];
		}
		for(var i=0;i<N-1;i++){
			C[i] = int.Parse(str3[i]);
		}
		for(var i=0;i<N-1;i++){
			if(A[i]+1==A[i+1]){
				ans += C[A[i]-1];
			}
		}
		Console.WriteLine(ans);
	}
}

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

int main(){
  
  int n, u, k, v;
  bool a[110][110] = {};
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v;
      a[u][v] = true;
    }
  }
  
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      cout << (j - 1?" ":"");
      cout << a[i][j];
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var K, S int
	fmt.Scanf("%d %d", &K, &S)

	result := 0
	for x := 0; x <= K; x++ {
		yPlusz := S - x
		if yPlusz > 2*K || yPlusz < 0 {
			continue
		} else if yPlusz > K {
			result += 2*K - yPlusz + 1
		} else {
			result += yPlusz + 1
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512