akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

struct Block {
  ll w, s, v;
};

void solve() {
  ll n; cin >> n;
  vector<Block> b;
  rep(i, n) {
    ll w, s, v; cin >> w >> s >> v;
    b.pb({w, s, v});
  }
  sort(all(b), [](const Block& b1, const Block& b2) {
    return b1.s + b1.w < b2.s + b2.w;
  });
  constexpr ll M = ll(1e4+2);
  vector<vector<ll>> dp(2, vector<ll>(M, 0));
  rep(i, n) {
    dp[i+1&1].assign(M, 0);
    rep(j, M) {
      chmax(dp[i+1&1][j], dp[i&1][j]);
      if (b[i].s >= j) {
        ll nj = min(M-1, j + b[i].w);
        chmax(dp[i+1&1][nj], dp[i&1][j]+b[i].v);
      }
    }
  }
  ll ans = 0;
  rep(j, M) chmax(ans, dp[n&1][j]);
  cout << ans << endl;
}


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

const int N = 100001;
struct node {
	int d, id;
	node() {}
	node(int d, int x):d(d), id(x) {}
	friend bool operator < (node a, node b) { return a.d < b.d; }
}d[N];
int sz[N], u[N], v[N];

inline int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}

signed main() {
	int n = read();
	for (int i = 1; i <= n; ++i) {
		d[i] = node{read(), i};
		sz[i] = 1;
	}
	sort(d + 1, d + 1 + n);
	int sum = 0, cnt = 0;
	for (int i = n; i > 1; --i) {
		int dis = d[i].d - n + (sz[i] << 1);
		int pos = lower_bound(d + 1, d + 1 + n, node{dis, 0}) - d;
		if (d[pos].d != dis) return puts("-1"), 0;
		cnt++;
		u[cnt] = d[i].id;
		v[cnt] = d[pos].id;
		sz[pos] += sz[i];
		sum += sz[i];
	}
	if (sum != d[1].d) puts("-1");
	else {
		for (int i = 1; i <= cnt; ++i) {
			printf("%lld %lld\n", u[i], v[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 7636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int k = cin.nextInt();
        int x = cin.nextInt();

        WriteLine(k * 500 >= x? "Yes" : "No");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int n;
  cin>>n;
  vector<int>vec(n);
  rep(i,n){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int64_t sum=0;
  int k;
  for(int i=0;i<n;i++){
    if(i==0){
      sum+=0;
    }
    else if(i==1){
      sum+=vec.at(0);
    }else{
      sum+=vec.at(i/2);
    }
  }
  cout<<sum<<endl;
}

  

Measured memory_bytes: 4064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

type node struct {
	item int
	prev *node
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, q int
	fmt.Scanf("%d %d", &n, &q)

	groups := make([]*node, n)
	for i := 0; i < n; i++ {
		groups[i] = &node{item: i, prev: nil}
	}

	for i := 0; i < q; i++ {
		com, x, y := next(), next(), next()
		if com == 0 {
			var parentX, parentY *node
			for parentX = groups[x]; parentX.prev != nil; parentX = parentX.prev {
				continue
			}
			for parentY = groups[y]; parentY.prev != nil; parentY = parentY.prev {
				continue
			}
			if parentX.prev != nil || parentY.prev != nil {
				panic(fmt.Sprintf("%v, %v", parentX, parentY))
			}
			if parentX.item != parentY.item {
				parentX.prev = parentY

			}

		} else {
			var parentX, parentY *node
			for parentX = groups[x]; parentX.prev != nil; parentX = parentX.prev {
				continue
			}
			for parentY = groups[y]; parentY.prev != nil; parentY = parentY.prev {
				continue
			}
			if parentX.item == parentY.item {
				fmt.Println("1")
			} else {
				fmt.Println("0")
			}
		}
	}

}



Measured memory_bytes: 2576
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int ans[MAXN];
vector<int>bian[MAXN];
vector<int>color[2];
void dfs(int x,int now,int fa){
    color[now].push_back(x);
    for(int i=0;i<bian[x].size();i++){
        int to=bian[x][i];
        if(to==fa)continue;
        dfs(to,now^1,x);
    }
}
void getans(int co,int &mod){
    while(color[co].size()&&mod<=n){
        ans[color[co].back()]=mod;
        color[co].pop_back();
        mod+=3;
    }
}
int main(){
    cin>>n;
    REP(i,1,n-1){
        int a,b;
        sci(a);sci(b);
        bian[a].push_back(b);
        bian[b].push_back(a);
    }
    dfs(1,0,0);
    int a=1,b=2,c=3;
    getans(color[0].size()<color[1].size(),a);
    getans(color[0].size()<color[1].size(),b);
    getans(1,c);
    getans(0,c);
    REP(i,1,n)cout<<ans[i]<<' ';
}

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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define sz s.size();
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

LL a, b;

void init(){
	sll2(a, b);
	b = b / 2;
	if(a >= b)
	{
		printf("%lld\n", b);
	}
	else {
		b = b - a;
		LL res = b / 2;
		if(!res)
			printf("%lld\n", a);
		else 
			printf("%lld\n", (a + res));
	}

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   set<long int> s;

   for(long int i = 2; i * i <= n; i++){
     if(n % i == 0){
        long int divisor1 = i;
        long int divisor2 = n / i;
        auto copy = n;

        while(copy % divisor1 == 0)
          copy /= divisor1;

        if(copy == 1)
          s.insert(divisor1);

        copy %= divisor1;
        if(copy == 1)
          s.insert(divisor1);

        copy = n;

        while(copy % divisor2 == 0)
          copy /= divisor2;

        if(copy == 1)
          s.insert(divisor2);

        copy %= divisor2;
        if(copy == 1)
          s.insert(divisor2);
      
     }
   }

   s.insert(n);
   n--;

   for(long int i = 2; i * i <= n; i++){
     if(n % i == 0){
      s.insert(i);
      s.insert(n / i);
     }
   }

   s.insert(n);
   s.erase(1);
   s.erase(0);

   cout<<s.size();   

   return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
  int main() {
  int N;
  cin >> N;
  long long L[90];
  L[0] = 2ll;
  L[1] = 1ll;
  for(int i = 2; i < N + 1; i++){
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
}

Measured memory_bytes: 384
#include <iostream>
 
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
#include <chrono>

#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
 
#define itn int
#define fro for
#define lowbit(x) (x & (-x))
#define Fast freopen("in.txt", "r", stdin)
#define manx maxn
#define ceil(n, p) ((n + p - 1) / p)

#define DBG(x) (void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n')

using namespace std;
typedef long long ll;

/*------------------------------------------------------------------------------------*/
template <typename _t>
inline void read(_t &x){
    
    x = 0; _t fu = 1; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') fu = - 1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){
        x = (x << 3) + (x << 1) + (ch & 15);
        ch = getchar();
    }
    x *= fu ;
}
/*------------------------------------------------------------------------------------*/
ll gcd(ll x, ll y){return !x? y: gcd(y % x, x);}
void exgcd(ll a, ll b, ll &x, ll &y){
    if(!b){x = 1; y = 0;return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}
/*------------------------------------------------------------------------------------*/
struct Mart{
    int a, b, c, d;
    Mart operator *(Mart &m){
        Mart temp;
        temp.a = a * m.a + b * m.c;
        temp.b = a * m.b + b * m.d;
        temp.c = c * m.a + d * m.c;
        temp.d = c * m.b + d * m.d;
        return temp;
    }
    Mart(){a = b = c = d = 0;}
    Mart(int x[4]){a = x[0]; b = x[1]; c = x[2]; d = x[3];}
    Mart(int u, int v, int w, int x){a = u; b = v; c = w; d = x;}
    int det(){return a * d - b * c;}
};
/*------------------------------------------------------------------------------------*/

const int maxn = 5e2 + 10;

int n;
int vis[maxn][maxn];
int dis[maxn][maxn];

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

void dfs(int x, int y){
    int now = dis[x][y] + vis[x][y];
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(nx >= 0 && nx < n && ny >= 0 && ny < n && dis[nx][ny] > now){
            dis[nx][ny] = now;
            dfs(nx, ny);
        }
    }
}

int main(){
//    Fast;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
        vis[i][j] = 1;
        dis[i][j] = min(min(i, j), min(n - 1 - i, n - 1 - j));
    }
    int x, y ;
    ll ans = 0;
    for(int i = 0, u; i < n * n; i++){
        scanf("%d", &u); u--; x = u / n; y = u % n;
        ans += dis[x][y];
        
        vis[x][y] = 0; dfs(x, y);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 24660
import collections
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
N, K, L = map(int, input().split())
road = UnionFind(N)
train = UnionFind(N)
pair = []
ans = []
for i in range(K):
    p, q = map(int, input().split())
    road.union(p-1, q-1)
for i in range(L):
    r, s = map(int, input().split())
    train.union(r-1, s-1)
for i in range(N):
    pair.append((road.find(i), train.find(i)))
c = collections.Counter(pair)
for i in range(N):
    ans.append(c[(road.find(i), train.find(i))])
print(*ans)

Measured memory_bytes: 44392
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b,c,d;
  cin >> a >> b >> c >>d;
  cout << max(a*b,c*d)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c;
    char op;
    cin>>a>>op>>b;
    if(op=='+'){
        c=a+b;
    }
    else{
        c=a-b;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,ans=-INF;cin>>n;
    vector<vector<int>> v(n,vector<int>(10));
    for(int i=0;i < n;i++)
    {
        for(int j=0;j < 10;j++)
        {
            cin>>v[i][j];
        }
    }

    vector<vector<int>> ri(n,vector<int>(11));

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

    vector<int> dub(n,0);  

    for(int i=1;i < 1024;i++)
    {
        int x=i,res=0;
        dub.assign(n,0);

        for(int j=0;j < 10;j++)
        {
            if(x&1){
                for(int k=0;k < n;k++)
                {
                    if(v[k][j]){
                        dub[k]++;
                    }
                }
            }
            x/=2;
        }

        for(int l=0;l < n;l++)
        {   
            res+=ri[l][dub[l]];
        }
        ans=max(res,ans);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

/* prototype declaration */
void differential();

int main(int argc, const char *argv[])
{
	differential();	
	return 0;
}

void differential()
{
	double mt, max=0, min=1e10;
	while(scanf("%lf", &mt)!=EOF){
		if(max<mt) max = mt;
		if(mt<min) min = mt;	
	}
	printf("%.1f\n", (max-min));
}

Measured memory_bytes: 0
#if 0

#endif

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

int N;
int gx, gy;
int p;
int T[15+10][15+10];
int FL[15+10][15+10];
int FU[15+10][15+10];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int x = 0; x < 15+10; x++) {
      for (int y = 0; y < 15+10; y++) {
        T[x][y] = (x == 0 && y == 0); FL[x][y] = (x != 0); FU[x][y] = (y != 0);
      }
    }
    cin >> gx >> gy >> p;
    int x1, y1, x2, y2;
    for (int j = 0; j < p; j++) {
      cin >> x1 >> y1 >> x2 >> y2;
      if (x1 == x2)
        FU[max(x1, x2)][max(y1, y2)] = false;
      if (y1 == y2)
        FL[max(x1, x2)][max(y1, y2)] = false;
    }
    for (int x = 0; x <= gx; x++) {
      for (int y = 0; y <= gy; y++) {
        if (!(x == 0 && y == 0)) {
          T[x][y] = (FL[x][y] ? T[x-1][y] : 0) + (FU[x][y] ? T[x][y-1] : 0);
        }
      }
    }
    cout << (T[gx][gy] ? to_string(T[gx][gy]) : "Miserable Hokusai!") << endl;
  }
}



Measured memory_bytes: 3224
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int result = 1;
        int pos = 0;
        for(int i = 0; i < N; i++){
            int L = sc.nextInt();
            if(pos + L > X){
                break;
            }
            pos += L;
            result++;
        }
        System.out.println(result);
    }
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    map<char,string> m;
    map<char,int> cnt;
    string s;
    for (char i = 'a'; i <= 'c'; i++){
        cin >> s;
        m[i] = s;
        cnt[i] = 0;
    }
    char ans;
    char t = m['a'][0];
    cnt['a']++;
    while(1){
        if (cnt[t] == m[t].size()) {
            ans = t;
            break;
        }
        t = m[t][cnt[t]++];
    }


    std::locale l = std::locale::classic();
    cout << toupper(ans,l) << endl;


        


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s;
  cin >> s;
  i64 n = s.size();
  i64 rm = 0;
  for (i64 i = 0, scnt = 0; i < n; ++i) {
    if (s[i] == 'S') ++scnt;
    else if (scnt > 0) {
      rm += 2;
      --scnt;
    }
  }
  cout << n - rm << '\n';
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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<typename T>
struct BIT{
    //1-index
    //0-indexで取ると無限ループする
    private:
    V<T> arr;
    int n;

    public:
    BIT(int siz){
        n=siz;
        arr.assign(n+1,0);
    }
    //一点更新 aにvを加える
    void add(T a,T v){
        //x+=(x&-x) 初項a,それ以降a<=2^Nが列挙
        for(T x=a;x<=n;x+=(x&-x)){
            arr[x]+=v;
        }
    }
    T sum(T a){
        // 1からaまでの区間和
        T ret=0;
        for(T x=a;x>0;x-=(x&-x))ret+=arr[x];
        return ret;
    }
    T get(T x){//x番目に大きい数　// 区間和がw以上となる最小のindを返す
        if(x<=0) return 0;
        T N=1;
        while(N*2<=n)N*=2;
        T v=0;
        for(T i=N;i>0;i/=2){
            if(v+i<=n&&arr[v+i]<x){
                x-=arr[v+i];
                v+=i;
            }
        }
        return v+1;
    }
    T query(int l,int r){
        return sum(r)-sum(l);
    }
};
using pp=pair<P,int>;
map<int,queue<int>> mp;
int main(){
  ll n,q;
  cin>>n>>q;
  V<ll> a(n);
  BIT<ll> bit(n+10);
  for(int i=0;i<n;i++){
      cin>>a[i];
    if(mp.count(a[i])){
        mp[a[i]].push(i+1);
    }
    else {
       mp[a[i]].push(i+1);
       bit.add(i+1,1);
   }
  }
  V<pp> que(q);
  for(int i=0;i<q;i++){
      cin>>que[i].fi.fi>>que[i].fi.se;
      que[i].se=i;
  }
  V<ll> ans(q,0);
  sort(all(que));
 int i=0;
  for(int k=0;k<n;k++){
      while(i<q&&k+1==que[i].fi.fi){
         // cout<<k<<"\n";
        ans[que[i].se]=bit.query(que[i].fi.fi-1,que[i].fi.se);
      //  cout<<que[i].fi.fi-1<<" "<<que[i].fi.se<<"\n";
         i++;
      }
        mp[a[k]].pop();
        if(bit.query(k,k+1)==1&&mp[a[k]].size()){
             bit.add(mp[a[k]].front(),1);
         }
  }
  for(int i=0;i<q;i++){
      cout<<ans[i]<<"\n";
  }
}


Measured memory_bytes: 387352
n = int(input())
xs = list(map(int, input().split()))

min_cnt = set()
max_cnt = set()

rename = -1
for x in xs:
    if x >= 3200:
        max_cnt.add(rename)
        rename -= 1
    else:
        max_cnt.add(x//400)
        min_cnt.add(x//400)

print(max(1, len(min_cnt)), len(max_cnt))


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

 
int main() {
    ll n,m;
    cin>>n>>m;
    ll scc=0;
    if(2*n>=m)cout<<m/2<<endl;
    else cout<<n+(m-2*n)/4<<endl;
}

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let n=tn(),ar=tnn(n),ans=ar[0]
  for(let i=1;i<n;i++){
    if(ar[i-1]<ar[i]){
      ans+=ar[i]-ar[i-1]
    }
  }
  to(ans)
}
main()


Measured memory_bytes: 7500
#include "bits/stdc++.h"
using namespace std;


//int h[100001];


unsigned long long dp[100001] = {};
/*
int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return 0;
	if(memo[i] != -1) return memo[i];
	int m = INT_MAX;
	for(int d = 1; d <= k; d++){
		if(i - d < 0) break;
		m = min(solve(i-d, k)+abs(h[i]-h[i-d]), m);
	}
	return memo[i] = m;
}
*/

int main(){

	int n;
	cin >> n;

	int w; cin >> w;

	pair<int, int> wv[100];
	for(int i = 0; i < n; i++){
		cin >> wv[i].first >> wv[i].second;
	}

	dp[0] = 0;

	unsigned long long ans = 0;
	
	for(int j = 0; j < n; j++){
		for(int i = w - wv[j].first; i >= 0; i--){
			dp[i + wv[j].first] = max(dp[i] + wv[j].second, dp[i + wv[j].first]);
			ans = max(ans, dp[i + wv[j].first]);
		}
	}


	cout << ans << endl;

    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n, a, b;
	cin >> n >> a >> b;
	const int all = 1 << n;
	const int num = __builtin_popcountll(a^b);

	if(num % 2 != 1){
		puts("NO");
		return 0;
	}

	
	vector<int> ans;
	rep(i, all) ans.push_back(i ^ (i >> 1));
	vector<int> diff(all - 1);
	rep(i, all - 1) diff[i] = ans[i] ^ ans[i + 1];
	reverse(begin(diff), end(diff));

	int cur = all / 2, start = n - 3;

	rep(loop, num / 2){
		int flip = 3 << start;
		start -= 2;

		rep(i, cur - 1){
			if((diff[i] & flip)){
				diff[i] ^= flip;
			}
		}

		cur /= 4;
	}

	reverse(begin(diff), end(diff));
	
	int cnt = n - num;
	rep(i, n){
		const int tmp = a ^ b;
		if((tmp >> i) & 1){
			if(cnt != i){ 
				const int flip = (1 << i) | (1 << cnt);
				rep(j, all - 1){
					if(diff[j] & flip){
						diff[j] ^= flip;
					}
				}
			}
			cnt++;
		}
	}


	ans[0] = a;
	rep(i, all - 1) ans[i + 1] = ans[i] ^ diff[i];

	assert(ans[0] == a);
	rep(i, all -1) assert(__builtin_popcountll(ans[i] ^ ans[i + 1]) == 1);
	assert(ans[all - 1] == b);
	
	
	puts("YES");
	rep(i, all) cout << (i ? " " : "") << ans[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 2168
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
    string s;
    int k;
    cin >> s;
    cin >> k;
    int len = s.size();
    for(int i = 0;i < len; i++){
        if(i == (len - 1)){
            char c = s[i];
            int num = c;
            int cnt = k % 26;
            num = num + cnt;
            if(num >= 123){
                num = num - 26;
            }
            c = num;
            string cn;
            cn = c;
            s.erase(i,1);
            s.insert(i,cn);
        }else{
            char c = s[i];
            int num = c;
            if(num == 97){
                
            }else if(123 - num <= k){
                k = k - (123 - num);
                s.erase(i,1);
                s.insert(i,"a");
            }
        }
        if(k == 0){
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 640
H, W, D = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]

P = {}

for i in range(H):
    for j in range(W):
        P[A[i][j] - 1] = (i, j)

cum = [0] * (H * W + 1)

for a in range(H * W - D):
    i, j = P[a]
    x, y = P[a + D]
    cum[a + D] = cum[a] + abs(x - i) + abs(y - j)

Q = int(input())
ans = []

for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(cum[r - 1] - cum[l - 1])

print('\n'.join(map(str, ans)))

Measured memory_bytes: 37448
#include<cstdio>
#include<string>
#include<map>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
const int MAXN=1<<11;
int dp[MAXN+5][MAXN+5];
int num[200];
int n,m;
///dp[s1][s2]=min(dp[s1|1<<k][s2],dp[s1|1<<k][s2^(1<<k)])+1;
int dfs(int x,int y)
{
    if(dp[x][y]!=1e9)return dp[x][y];
    int &ans=dp[x][y];
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if((num[i]&x)==y)cnt++;
    }
    if(cnt<=1)
    {
        dp[x][y]=0;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        int z=(1<<i);
        if(x&z)continue;
        ans=min(ans,max(dfs(x|z,y),dfs(x|z,y^z))+1);
    }
    return ans;
}
int main()
{
  //freopen("out.txt","w",stdout);
    while(scanf("%d%d",&n,&m))
    {
        if(n==0&&m==0)break;
        for(int i=0;i<m;i++)
        {
            string str;
            cin>>str;
            num[i]=0;
            for(int j=0;j<n;j++)
            {
                if(str[j]=='1')
                {
                    num[i]|=(1<<j);
                }
            }
          //  cout<<i<<" "<<num[i]<<endl;
        }
       // cout<<"!"<<endl;
        for(int i=0;i<MAXN;i++)
        {
            for(int j=0;j<MAXN;j++)
            {
                dp[i][j]=1e9;
            }
        }
        cout<<dfs(0,0)<<endl;

    }
}

Measured memory_bytes: 17664
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	const int MOD = 998244353;
	int k, n;
	scanf("%d%d", &k, &n);
	long[][] r = new long[][](2,k+1);
	long[] dp = new long[n+1];
	dp[0] = 1;
	foreach (i; 0..k) {
		foreach (j; 0..n) {
			(dp[j+1] += dp[j]) %= MOD;
		}
	}
	foreach (i; 0..k+1) {
		r[0][i] = dp[n];
		foreach_reverse (j; 0..n) {
			(dp[j+1] += MOD - dp[j]) %= MOD;
		}
		r[1][i] = (dp[n] + dp[n-1]) % MOD;
		foreach_reverse (j; 0..n) {
			(dp[j+1] += MOD - dp[j]) %= MOD;
		}
		long[] a = dp.dup;
		foreach (j; 0..n) {
			(a[j+1] += a[j]) %= MOD;
		}
		foreach (j; 0..n) {
			(dp[j+1] += a[j]*2) %= MOD;
		}
	}
	foreach (i; 2..2*k+1) {
		int a = 1-i%2;
		int b = -a;
		foreach (j; 1..k+1) {
			int nj = i-j;
			if (1 <= nj && nj <= k) b++;
		}
		b /= 2;
		//writeln(i," ",a," ",b);
		writeln(r[a][b]);
	}
}

Measured memory_bytes: 4348
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>=13){
    printf("%d\n",b);
  }else if(a<=5){
    printf("0\n");
  }else{
    printf("%d\n",b/2);
  }
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, m, x; cin >> n >> m >> x;
        int cost[n], algo[n][m];
        for (int i = 0; i < n; i++) {
                cin >> cost[i];
                for (int j = 0; j < m; j++) {
                        cin >> algo[i][j];
                }
        }

        int ans = 1e9;
        for (int mask = 0; mask < (1 << n); mask++) {
                int price = 0;
                vector<int> A(m);
                for (int bit = 0; bit < n; bit++) {
                        if (1 << bit & mask) {
                                for (int i = 0; i < m; i++) A[i] += algo[bit][i];
                                price += cost[bit];
                        }
                }
                if (*min_element(all(A)) >= x) ans = min(ans, price);
        }

        cout << (ans == 1e9 ? -1 : ans);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll res=1;
    if(k==n||a.back()>=0){
        for(int i=0;i<k;i++){
            (res*=a[i])%=mod;
        }
    }
    else if(a[0]<=0){ // 全部負または0
        if(k%2==0)sort(a.begin(), a.end());
        for(int i=0;i<k;i++){
            (res*=a[i])%=mod;
        }
    }
    else{
        vector<ll> p,m,mul;
        for(int i=0;i<n;i++){
            if(a[i]>=0)p.push_back(a[i]);
            else m.push_back(-a[i]);
        }
        sort(p.rbegin(), p.rend());
        sort(m.rbegin(), m.rend());
        if(k%2)res=p[0],p.erase(p.begin());
        for(int i=0;i<p.size()/2;i++){
            mul.push_back(p[2*i]*p[2*i+1]);
        }
        for(int i=0;i<m.size()/2;i++){
            mul.push_back(m[2*i]*m[2*i+1]);
        }
        sort(mul.rbegin(), mul.rend());
        for(int i=0;i<k/2;i++){
            (res*=mul[i]%mod)%=mod;
        }
    }
    if(res<0)res+=mod;
    cout << res << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(100001);
  for (int i = 0, a; i < N && cin >> a; i++) A.at(a)++;

  int ans = 0;
  for (int i = 1; i < 100000; i++) {
    ans = max(ans, A.at(i - 1) + A.at(i) + A.at(i + 1));
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1148
#include <iostream>
using namespace std;
int main(void){
    long long a,b,c,sum=0;
    cin >> a >> b >> c;
    int flag = 0;
    for(long long i=0;i<1000000;i++){
        sum += a;
        if(sum%b == c) {
            flag = 1;
            break;
        }
    }
    if(flag) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 102
int x[N],y[N];
int main() {
	int i,n,m,X,Y;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	for( i=0;i<n;i++ )
	{
		scanf("%d",&x[i]);
	}
	for( i=0;i<m;i++ )
	{
		scanf("%d",&y[i]);
	}
	sort(x,x+n);
	sort(y,y+m);
	int t1=max(x[n-1],X),t2=min(y[0],Y);
	if( t1<t2 )
		printf("No War\n");
	else
		printf("War\n");
	return 0;
	}



Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "abc162_b.cpp"

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

  int n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i < n + 1; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int num, d, x;
    cin >> num >> d >> x;
    for(int i=1;i<=10;i++){
        x *= num;
        x -= d;
        cout << x << endl;
    }
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

void Main()
{
    ll a = in(), b = in();
    cout << lcm(a, b) << endl;
}

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


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int a,b;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b;
    if(b>=a){
        cout<<"unsafe"<<endl;
    }
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
	int k; cin>>k;
	int d=max({a,b,c});
	//d*=2;
	rep(i,0,k) d*=2;
	cout<<(a+b+c-max({a,b,c})+d);
	
	
	return 0;
}

Measured memory_bytes: 3496
n = gets.to_i
as = gets.split.map(&:to_i)
rates = 8.times.map { |i| (i * 400...(i + 1) * 400) }

count = 0
ans = as.each_with_object([]) do |a, arr|
  if a >= 3200
    count += 1
  else
    arr << rates.index { |r| r.include?(a) }
  end
end.uniq

min = ans.count > 0 ? ans.count : 1
max = ans.count + count
puts [min, max].join(" ")


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<P<int, int> > v(n + 1);
    for(int i = 1; i <= n; i++){
        int x, y; cin >> x >> y;
        v[i] = make_pair(x, y);
    }

    V<int> nums(n);
    iota(ALL(nums), 1);
    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        for(int i = 0; i < n - 1; i++){
            double a = pow(v[nums[i]].first - v[nums[i + 1]].first, 2);
            double b = pow(v[nums[i]].second - v[nums[i + 1]].second, 2);
            sum += sqrt(a + b);
        }
    } while(next_permutation(nums.begin(), nums.end()));
    printf("%.10f", sum / cnt);

    return 0;
}


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

int main() {
  int r, D, x; cin >> r >> D >> x;

  for (int i = 0; i < 10; i++)
  {
    int ans = 0;
    ans = r * x - D;
    x = ans;
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
a.insert(0,0)

for i in range(int(n/2)+1,n+1):
    b[i]=a[i]

for i in reversed(range(1,int(n/2)+1)):
    c=0
    if a[i]==0:
        for j in range(2*i,n+1,i):
            if b[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=0
        else:
            b[i]=1
    if a[i]==1:
        for j in range(2*i,n+1,i):
            if b[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=1
        else:
            b[i]=0

cx=0
for i in range(1,n+1):
    if b[i]==1:
        cx=cx+1

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    print(cx)
    print(' '.join(map(str, idx)))

Measured memory_bytes: 86120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    int ans;
    if(a == b) ans = a * 2;
    if(a != b) ans = max(a,b) + max(a,b) - 1;
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lld;
 
vector<pair<int,int> > v,v2;
string a;
int rr = 0,pl = 0,mi = 0;
bool tmr(pair<int,int> a,pair<int,int> b){
	if(a.second!=b.second) return a.second>b.second;
	return a.first > b.first;
}
bool tmr2(pair<int,int> a,pair<int,int> b){
	if(a.second!=b.second) return a.second < b.second;
	return a.first > b.first;
}
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=0;e<n;e++){
		cin >> a;
		int vv = 0, vv2 = 1e9;
		for(int p=0;p<(int)a.size();p++){
			if(a[p]=='(') vv++;
			else vv--;
			vv2 = min(vv2,vv);
		}
		rr += vv;
		if(vv2==0&&vv==0) continue;
		if(vv2>=0&&vv>0) pl += vv;
		else if(vv>0&&vv2<0) v.push_back(make_pair(vv,vv2));
		else if(vv!=vv2) v2.push_back(make_pair(vv,vv2));
	}
	if(rr!=0) printf("No");
	else{
		sort(v.begin(),v.end(),tmr);
		for(int p=0;p<v.size();p++){
			if(pl<-v[p].second){
				printf("No");
				return 0;
			}
			pl += v[p].first;
		}
		sort(v2.begin(),v2.end(),tmr2);
		for(int p=0;p<v2.size();p++){
			if(pl<-v2[p].second){
				printf("No");
				return 0;
			}
			pl += v2[p].first;
		}
		printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 5412