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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  ll n=s.size(), m=t.size();
  if(m>n){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  bool flg=false;
  rrep(i,n-m+1){
    rep(j,m){
      if(s[i+j]!='?' && s[i+j]!=t[j]) break;
      if(j==m-1) flg=true;
    }
    if(flg){
      rep(j,m){
        s[i+j]=t[j];
      }
      break;
    }
  }
  if(flg){
    rep(i,n){
      if(s[i]=='?') s[i]='a';
    }
    cout<<s<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
}

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

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

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

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int n,a[MAXN*2];

int main() {

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int cur_mx = 0;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        cur_mx = max(cur_mx,a[i]);
        ans += (cur_mx-a[i]);
    }

    cout << ans;

return 0;
}


Measured memory_bytes: 4396
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    int N,K;cin >> N >> K;
    long long ans = 0;
    long long mini = 0,maxi = 0;
    for(int i = 0;i<N+1;i++){
        mini += i;
        maxi += (N-i);
        if(i >= K-1){
            //cout << mini << " " << maxi << endl;
            ans += maxi-mini+1;
            ans %= MOD;
        }
        
        //ans += maxi-mini+1;
        //ans %= MOD;
    }
    //mini = 0;maxi = 0;
    /*for(int i = K;i<=N;i++){
        
        mini += i;
        maxi += (N-i);
    }*/
    
    cout << ans << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    std::cin >> a[i];

  // Main
  int res = a[0];
  for (int i = 1; i < N; ++i) {
    res ^= a[i];
  }

  // Output
  if (res == 0)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
    int r;
    cin>>r;
    printf("%.10f\n",2*3.14159265*r);
    return 0;
}

Measured memory_bytes: 3716
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;

void solve(){
    ll n, w;
    cin >> n >> w;
    vector<ll> cap(n + 1), val(n + 1);
    ll maxi = 0;
    for(int i = 0; i < n; i++){
        cin >> cap[i] >> val[i];
        maxi += val[i];
    }
    vector<ll> dp(maxi + 1, inf);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = maxi - val[i]; j >= 0; j--){
            dp[j + val[i]] = min(dp[j + val[i]], dp[j] + cap[i]);
        }
    }
    ll res = 0;
    for(ll i = 0; i <= maxi; i++){
        if(dp[i] <= w){
            res = max(res, i);
        }
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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


Measured memory_bytes: 1784
#include<bits/stdc++.h>
# include<iostream>
using namespace std;
 
vector <int> p(0);
 
void Prime(int n){
 
  bool flg[(int)sqrt( pow(10,9) ) +1];
  int indx=2;
 
  flg[0]=flg[1]=0;
  for(int i=0; i<sqrt(n)+1; i++)flg[i]=0;
   
 
  for(int i=2;i<sqrt(n)+1;i++){
        if (flg[i]==1) {i++;}
        else {
            flg[i]==1;
            p.push_back(i);
            for (int j=1;j*i<sqrt(n)+1;j++){
                flg[j*i] == 1;
            }
        }
    }
 
    
   
 
}
 
 
int main(){
 
  int n;
 
  cin >> n;
 
  Prime(n);
 
  cout << n << ':';
 
  int i=0;
  while(n!=1 && i<(int)p.size()){
     
    while(n%p[i]==0){
      cout << ' ' << p[i];
      n /= p[i];
    }
 
    i++;
     
  }
 
  if(i==(int)p.size() && n!=1)cout << ' '<<n;
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int n, m, a[55], b[55], par[55];
int root(int x) {
	if (x == par[x]) return x;
	return par[x] = root(par[x]);
}
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	par[x] = y;
}

signed main(){
	
	cin>>n>>m;
	
	rep(i,m)
	{
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	
	int ans = 0;
	
	rep(i,m)
	{
		rep(j,n) par[j]=j;
		rep(j,m) if(i!=j)unite(a[j],b[j]);
		
		bool ok = true;
		rep(j,n) if(root(0) !=root(j))ok = false;
		if(!ok) ans++;		
	}

	cout << ans << endl;
	
}
 

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

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

    map<int, int> m;
    REP(i, n) m.insert(make_pair(i, 0));

    REP(i, n - 1) {
        int tmp;
        cin >> tmp;
        --tmp;
        m[tmp]++;
    }

    REP(i, n)
        cout << m[i] << '\n';
    return 0;
}


Measured memory_bytes: 13028
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
 
#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut a = vec![];
    for _ in 1..=k {
        input! {
            d: usize,
            mut ad: [usize; d],
        }
        a.append(&mut ad);
    }
    a.sort();
    a.dedup();
    println!("{}", n - a.len());
}


Measured memory_bytes: 2304
N,X = (int(x) for x in input().split())

def gcd(a, b):
    if b > a:
        return gcd(b, a)
    if a % b == 0:
        return b
    return gcd(b, a % b)

d = -1
for x_str in input().split():
    x = int(x_str)
    dx = abs(X-x)
    if d == -1:
        d = dx
        continue
    d = gcd(d, dx)

print(d)


Measured memory_bytes: 11480
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a+b>=10) cout << "error" << endl;
    else cout << a+b << endl;
    debug(a+b);
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a, a+n, greater<int>());
    ll ans = 0ll;
    ans += a[0];
    for(int i=1;i<n/2;++i){
        ans += 2*a[i];
    }
    if(n % 2 == 1){
        ans += a[n/2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5152
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    X = int(inputs[0])
    max = 1
    for x in range(1, X + 1):
        for y in range(2, X + 1):
            c = x ** y
            if c <= X:
                max = c if c > max else max
            else:
                break
    return max


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= 1000000; i++) {
		if (a * i % b == c) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
}


Measured memory_bytes: 256
function Main(input) {
    var S  = input;
    var ch = "Yes";
    for(var i = 1; i < S.length; i++){
        if(i % 2 == 0){
            if(S[i-1] != "L" && S[i-1] != "U" && S[i-1] != "D"){
                ch = "No";
            }
        }else{
            if(S[i-1] != "R" && S[i-1] != "U" && S[i-1] != "D"){
                ch = "No";
            }
        }
    }
    console.log(ch)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n, tot = 0;
    cin >> n;

    // ll three, five = 0;
    // REP(i, n/3.0){
    //     three += 3*i; 
    // }

    // REP(i, n/3.0){
    //     three += 3*i; 
    // }

    REP(i, n){
        if (i%3 != 0 && i%5 != 0) tot += i;
    }

    cout << tot << endl;

}

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;++i) {
			h[i]=sc.nextInt();
		}
		long cost[]=new long[n];
		cost[0]=0;
		cost[1]=Math.abs(h[1]-h[0]);
		
		for(int i=2;i<n;++i) {
			cost[i]=Math.min(cost[i-2]+Math.abs(h[i-2]-h[i]),cost[i-1]+Math.abs(h[i-1]-h[i]));
		}
		
		System.out.println(cost[n-1]);
	}
}


Measured memory_bytes: 51052
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    write(N * (N - 1) / 2 + M * (M - 1) / 2);
}

Measured memory_bytes: 256
import sys

s = input()

Ll = [i for i, x in enumerate(s) if x == 'L']
Rl = [i for i, x in enumerate(s) if x == 'R']

for i in range(len(Ll)):
    if Ll[i] % 2 == 0:
        print('No')
        sys.exit()
for i in range(len(Rl)):
    if Rl[i] % 2 == 1:
        print('No')
        sys.exit()
print('Yes')


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

int main()
{
    int A,B;
    cin>>A>>B;
    if((A+B)%2==0){
        if((A-B)/2>0){
            cout<<(A-B)/2+B<<endl;
        }else{
            cout<<0-(A-B)/2+A<<endl;
        }
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
signed main(){
    int n;cin>>n;
    vector<int> v;
    int sum=0;
    rep(i,0,n){
        int a;cin>>a;
        sum+=a;
        v.ps(a);
    }
    sort(all(v));
    reverse(all(v));
    if(sum-v[0]>v[0])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		if((A+B)<=C*2){
			System.out.println(A*X+B*Y);
			return;
		}
		if(X>=Y){
			int volume = 0;
			X -= Y;
			volume += C*Y*2;
			if(A<C*2){
				volume += X*A;
				System.out.println(volume);
			}else{
				volume += C*2*X;
				System.out.println(volume);
			}
		}else{
			int volume = 0;
			Y -= X;
			volume += C*X*2;
			if(B<C*2){
				volume += Y*B;
				System.out.println(volume);
			}else{
				volume += C*2*Y;
				System.out.println(volume);
			}
		}

	}

}


Measured memory_bytes: 21972
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()
S=[input() for i in range(N)]

l=[]
for char in string.ascii_letters[:26]:
	#print(char)
	res = min([s.count(char) for s in S])
	l.append(res)
	
#print(l)
ans =""
for lidx,l in enumerate(l):
	ans+=string.ascii_letters[lidx]*l
print(ans)


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

int main ( void )
{
	long long a , b , number;
	cin >>  number >> a  >> b;
	long long ci_shu = number / ( a + b );
	long long sheng_yu = number - ci_shu * ( a + b );
	if ( sheng_yu <= a ) {
		cout << ci_shu * a + sheng_yu;
	} else {
		cout << ci_shu * a + a;
	}
	return 0;
 } 

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<P> A(n), B(n);
  rep(i, n) {
    int s, t, x;
    cin >> s >> t >> x;
    s -= x;
    t -= x;
    A[i] = P(s, x);
    B[i] = P(t, x);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  vector<int> D(q);
  rep(i, q) cin >> D[i];
  multiset<int> st;
  int a_idx = 0, b_idx = 0;
  rep(i, q) {
    int d = D[i];
    while (A[a_idx].first <= d && a_idx < n) {
      st.insert(A[a_idx].second);
      ++a_idx;
    }
    while (B[b_idx].first <= d && b_idx < n) {
      auto it = st.find(B[b_idx].second);
      st.erase(it);
      ++b_idx;
    }
    if (st.empty()) {
      cout << -1 << endl;
    } else {
      int tmp = *st.begin();
      cout << tmp << endl;
    } 
  }
  return 0;
}

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

using namespace std;


int main()
{
    //freopen("in.txt","r",stdin);
    int n,a=1;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        if(t%2 == 0)
        {
            if(t%3 == 0 || t%5 ==0)
                continue;
            else
                a=0;

        }
    }
    if(a==1)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    bool present[26] = {false};
    for(int i=0; i<s.size(); i++){
        if(s[i]>='a' && s[i]<='z'){
            present[s[i]-'a'] = true;
        }
    }
    for(int i=0; i<26; i++){
        if(present[i]==false){
            cout << (char)(i+'a');
            return 0;
        }
    }
    cout << "None" <<endl;
}

Measured memory_bytes: 3680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		String[] in = null;
		ArrayList<Integer> Length = new ArrayList<>();
		int a, b, c;
		int numDataset;

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String line = null;
		try {
			line = input.readLine();
		} catch (IOException e1) {
			System.out.println("最初の行における入出力例外");
		}
		numDataset = Integer.valueOf(line);

		try {
			for(int i = 0; i < numDataset; i++) {
				line = input.readLine();
				in = line.split(" ");
				for (String number : in) {
					Length.add(Integer.valueOf(number));
				}
				Collections.sort(Length, Collections.reverseOrder());

				a = Integer.valueOf(Length.get(0));
				b = Integer.valueOf(Length.get(1));
				c = Integer.valueOf(Length.get(2));
				Length.clear();

				a *= a;
				b *= b;
				c *= c;

				if(b+c == a) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			}
		} catch (NumberFormatException e) {
			System.out.println(line + "は整数でないものが含まれる");
		} catch (IOException e) {
			System.out.println("2行目以降の入出力例外");
		}

	}

}


Measured memory_bytes: 26128
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll (i) = (s); (i) < (x); (i) ++)
#define MREP(i, s, x) for(ll (i) = (s); (i) >= (x); (i) --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main() {
	ll x, y;
	cin >> x >> y;
	
	if(abs(x-y) <= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>  
char c[55][55];  
int f[55][55];  
int main(){  
    int h,w;  
    scanf("%d%d",&h,&w);  
    for(int i=0;i<h;i++){  
        scanf("%s",c[i]);  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(c[i][j]=='#'){  
                if(i-1>=0){  
                    f[i-1][j]++;  
                }  
                if(j-1>=0){  
                    f[i][j-1]++;  
                }  
                if(i+1<h){  
                    f[i+1][j]++;  
                }  
                if(j+1<w){  
                    f[i][j+1]++;  
                }  
                if(i-1>=0&&j-1>=0){  
                    f[i-1][j-1]++;  
                }  
                if(i+1<h&&j-1>=0){  
                    f[i+1][j-1]++;  
                }  
                if(i-1>=0&&j+1<w){  
                    f[i-1][j+1]++;  
                }  
                if(i+1<h&&j+1<w){  
                    f[i+1][j+1]++;  
                }  
            }  
        }  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(c[i][j]=='#') printf("#");  
            else printf("%d",f[i][j]);  
        }printf("\n");  
    }  
    return 0;  
}

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

int main(){
    int n, i;
    cin >> n;
    pair<int, int> p[n];
    for(i=0; i<n; i++){
        cin >> p[i].first;
        p[i].second = i+1;
    }
    sort(p, p+n);
    for(i=0; i<n; i++){
        cout << p[i].second << ' ';
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long
int isb[200005];
int ise[200005];
int main()
{
    int n,m,a,b;
    while(cin >> n >> m)
    {
        memset(isb,0,sizeof(isb));
        memset(ise,0,sizeof(ise));
        while(m--)
        {
            cin >> a >> b;
            if(a == 1)
                isb[b] = 1;
            else if(a == n)
                ise[b] = 1;
            if(b == 1)
                isb[a] = 1;
            else if(b == n)
                ise[a] = 1;
        }
        int i;
        for(i = 1;i <= n;i++)
        {
            if(isb[i] && ise[i])
            {
                cout << "POSSIBLE" << endl;
                break;
            }
        }
        if(i == n + 1)
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


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

int main(){
  char cs[10];
  for(int i=0;i<4;i++){
    cin >> cs[i];
  }
  int s[10];
  for(int i=0;i<4;i++) s[i]=(int)cs[i]-48;
  int ans;
  char pm[10];
  
  for(int bit=0;bit<(1<<3);bit++){
    ans = s[0];
    for(int i=0;i<3;i++){
      if(bit & (1<<i)){
        ans += s[i+1];
        pm[i] = '+';
      }else{
        ans -= s[i+1];
        pm[i] = '-';
      }
    }
    if(ans==7){
      cout<<s[0]<<pm[0]<<s[1]<<pm[1]<<s[2]<<pm[2]<<s[3]<<'='<<7<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN
	
	int n, m, i, u, v, c = 0;
	cin >> n >> m;
	vi hs(n + 1), gd(n + 1, 1);
	for (i = 1; i <= n; i++)
		cin >> hs[i];
	for (i = 0; i < m; i++)	{
		cin >> u >> v;
		if (hs[u] < hs[v])
			gd[u] = 0;
		else if (hs[v] < hs[u])
			gd[v] = 0;
		else if (hs[u] == hs[v]) {
			gd[u] = 0;
			gd[v] = 0;
		}
	}
	
	for (i = 1; i <= n; i++)
		c += gd[i];
		
	cout << c << "\n";
		
	return 0;
}


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

int main(){
    short a,b,n;
    cin>>a>>b>>n;
    bool R[10001];
    for(int i=0;i<=10001;i++){
        R[i]=false;
    }
    for(int i=0;i<n;i++){
        short s,f;
        cin>>s>>f;
        for(int j=s;j<f;j++){
            R[j-1]=true;
        }
    }
    /*
    for(int i=0;i<20;i++){
        cout<<R[i]<<" ";
    }
    cout<<endl;
    */
    for(int i=a;i<b;i++){
        if(R[i-1]==true){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
	return 0;	
}


Measured memory_bytes: 3108
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  long double a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<setprecision(10)<<a*b/2<<" ";
  if(a/2==c&&b/2==d){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }

}


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

using namespace std;
int main()
{
    string s;
    cin>>s;
    int i=0;
    while(s[i]!='\0'){
         s[i] = 'x';
         cout<<s[i];
        i++;
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
wl = list(map(int, input().split()))

res = 10**5
for i in range(n):
    s1 = sum(wl[0:i])
    s2 = sum(wl[i:])
    res = min(res, abs(s1-s2))

print(res)


Measured memory_bytes: 2940
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (n, m, x) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        let (n, x) = (sc.next(), sc.next::<u64>());
        (n, sc.vec::<u64>(n), x)
    };
    let s = m.iter().cloned().sum::<u64>();
    let t = m.iter().cloned().min().unwrap();
    println!("{}", n as u64 + (x - s) / t);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

const ll MOD = 1000000007;

ll pow_(ll a,ll p){
  if(p == 0) return 1;
  if(p == 1) return a%MOD;
  if(p%2 == 0) return pow_((a*a)%MOD,p/2);
  else return (a*pow_((a*a)%MOD,p/2))%MOD;
}

ll inv(ll a){
  return pow_(a,MOD-2);
}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  ll ans = pow_(2,n);
  ans --;
  vector<ll> con(2*100000+1,1);
  rep1(i,2*100000){
    con[i] = con[i-1]*(n-i+1)%MOD;
    con[i] = con[i]*inv(i)%MOD;
  }
  cout << (ans-con[a]-con[b]+2*MOD)%MOD << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,m,fa[100005],vv[100005];
int find(int x){
	if(x==fa[x])return x;
	int k=find(fa[x]);
	vv[x]+=vv[fa[x]];
	fa[x]=k;
	return k;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)fa[i]=i;
	while(m--){
		int u,v,val;
		scanf("%d%d%d",&u,&v,&val);
		int fu=find(u),fv=find(v);
		if(fu!=fv){
			fa[fu]=fv;
			vv[fu]=vv[v]+val-vv[u];
		}
		else{
			if(vv[u]-vv[v]!=val){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 4532
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 105,M = 20005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ec = 1,hed[N],cur[N],cap[M],nxt[M],to[M];
void add_edge(LL f,LL t,LL c){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; cap[ec] = c;
	++ ec; to[ec] = f; nxt[ec] = hed[t]; hed[t] = ec; cap[ec] = 0;
}

LL lev[N];
queue <LL> q;
void bfs(LL s){
	memset(lev,0,sizeof(lev));
	while(!q.empty()) q.pop();
	q.push(s); lev[s] = 1; 
	while(!q.empty()){
		LL u = q.front(); q.pop();
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(lev[v] || !cap[i]) continue;
			lev[v] = lev[u] + 1;
			q.push(v);
		}
	}
}

LL dfs(LL u,LL t,LL f){
	if(u == t) return f;
	for(LL i = cur[u];i;i = nxt[i]){
		cur[u] = i;
		LL v = to[i];
		if(lev[v] == lev[u] + 1 && cap[i]){
			LL tmp = dfs(v,t,min(cap[i],f));
			if(tmp){
				cap[i] -= tmp;
				cap[i ^ 1] += tmp;
				return tmp;
			}
		}
	}
	return 0;
}

LL mxf = 0;
void dinic(LL s,LL t){
	LL f = 0;
	while(1){
		bfs(s);
		if(!lev[t]) return;
		for(LL i = 1;i <= t;i ++) cur[i] = hed[i];
		while(1){
			f = dfs(s,t,INF);
			mxf += f;
			if(!f) break;
		}	
	}
}

int main(){
	LL n,S,T,a,sum = 0;
	cin >> n; S = n + 1; T = S + 1;
	for(LL i = 1;i <= n;i ++){
		cin >> a; sum += max(0LL,a);
		if(a > 0) add_edge(i,T,a);
		if(a < 0) add_edge(S,i,-a);
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = i + 1;j <= n;j ++){
			if(j % i == 0) add_edge(i,j,INF);
		}
	}
	dinic(S,T);
	cout << sum - mxf << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int b143(void);

int main(void) {
	b143();
	return 0;
}

int b143(void) {
	int n;
	std::cin >> n;
	std::vector<int> k;
	int temp;
	for (int i = 0; i < n; i++) {
		std::cin >> temp;
		k.push_back(temp);
	}
	int sum = 0;
	for (int i = 0; i+1 < n;  i++) {
		for (int j = i+1; j < n; j++) {
			sum += k[i] * k[j];
		}
	}
	std::cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int mx=max(max(a,b),c);
  int ans=(mx-a+mx-b+mx-c);
  if(ans%2)ans+=4;
  cout<<ans/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

// cout << fixed << setprecision(12)

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a; 
    ans %= m;
    a *= a; 
    a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

///////////////////////////////////

int main(){
  lint N,K; cin>>N>>K;
  vi A(N);
  for(lint i=0; i<N; i++) cin>>A[i];
  
  for(lint i=K; i<=N-1; i++){
    if(A[i]>A[i-K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
  
    
  

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int saiki(int,int);
int main(){
  int x,y;
  cin >> x >> y;
  if(x<y)swap(x,y);
  int ans = saiki(y,x%y);
  cout << ans  << endl;
  return 0;
}
int saiki(int a,int b){
  if(b==0)return a;
  int re;
  re = saiki(b,a%b);
  return re;
}

  

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int n, s, t, c, p, f;
	cin >> n;
	
	while(n--){
		s = f = t = 0;
		for(int i = 0; i < 10; i++){
			cin >> p;
			if(p < s && p < t){
				f = 1;
			} else if(p > s){
				s = p;
			} else if(p > t){
				t = p;
			} else {
				f = 1;
			}
		}
		if(f == 0){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

typedef struct{
    int a;
    int x;
    int y;
    int cost;
} cell_t;

int sort(const void *a, const void *b){
    return ((cell_t*)a)->a- ((cell_t*)b)->a ;
}

int main(void){
    int h,w,d,count=0;
    scanf("%d%d%d",&h,&w,&d);
    cell_t cell[h*w];
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            int p;
            scanf("%d",&p);
            cell[count].a=p;
            cell[count].x=i+1;
            cell[count].y=j+1;
            count++;
        }
    }
    qsort (cell,count,sizeof(cell_t),sort);
    for (int i=0; i<count; i++){
        if (i<d){
            cell[i].cost=0;
        } else {
            cell[i].cost=cell[i-d].cost+abs(cell[i].x-cell[i-d].x)+abs(cell[i].y-cell[i-d].y);
        }
    }
    int q;
    scanf("%d",&q);
    for (int i=0; i<q; i++){
        int l,r;
        scanf("%d%d",&l,&r);
        long long ans=cell[r-1].cost-cell[l-1].cost;
        printf("%lld\n",ans);
    }
	return 0 ;
}

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

using namespace std;

int main() {

    double D, T, S;
    cin >> D >> T >> S;

    double minutes = D / S;

    // cout << minutes << endl;

    if(T >= minutes) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

ll getdigits(ll a)
{
	ll res = 0;
	while(a != 0)
	{
		res++;
		a /= 10;
	}
	return res;
}

int main()
{
	ll N;
	cin >> N;
	ll ans = 100;
	for (ll i = 1; i*i <= N; ++i)
	{
		if (N % i == 0)
		{
			ll temp = N / i;
			ans = min(ans,(max(getdigits(i),getdigits(temp))));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std ;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i++)


int sum = 0;

bool check(ll x)
{
    bool flag3=0;
    bool flag5=0;
    bool flag7=0;
    int b;
    while (x)
    {
        b = x%10;
        x/=10;
        if (b==3) flag3=1;
        if (b==5) flag5=1;
        if (b==7) flag7=1;
    }
    return (flag3&flag5&flag7);
}

int rdo(ll s, ll N)
{
	if (s > N)
	{
		return 0;
	}

	sum+= check(s);

	rdo(s*10+3, N);
	rdo(s*10+5, N);
	rdo(s*10+7, N);

	return 0;
}

int main()
{
	cin.tie(NULL);

	ll N;
	cin >> N;

	rdo(0, N);

	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
li = []
for i in range(n-1):
    c,s,f = map(int,input().split())
    li.append((c,s,f))
for i in range(n-1):
    cur = li[i][1]+li[i][0]
    for j in range(i+1,n-1):
        c,s,f = li[j]
        cur = max(s,-(-cur//f)*f)+c
    print(cur)
print(0)

Measured memory_bytes: 3188
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

ans = r*g*b

for i in range(0,N):
  for j in range(i,N):
    k = 2*j - i
    if j < k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1

print(ans)













Measured memory_bytes: 73732
/*input
5000
01000001011101000100001101101111011001000110010101110010000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=5005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll f[maxn];
ll inv[maxn];
ll dp[maxn][maxn];

int main()
{
	IOS;
	int n;
	string s;
	cin>>n>>s;

	dp[0][0]=1;

	for(int len=1;len<maxn;len++){
		dp[len][0]=(dp[len-1][0]+dp[len-1][1])%MOD;
		for(int j=1;j<maxn-1;j++){
			dp[len][j]=(dp[len-1][j-1]*2+dp[len-1][j+1])%MOD;
		}
		dp[len][maxn-1]=dp[len-1][maxn-2]*2%MOD;
	}
	cout<<dp[n][SZ(s)]*mypow(2,MOD-1-SZ(s))%MOD<<'\n';
	return 0;
}


Measured memory_bytes: 195968