akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}

    // bool check(ll y){}
    ll binsearch(ll l,ll r)
    {
        // while(r-l>1)
        // {
        //     ll mid=(l+r)/2;
        //     if(check(mid))l=mid;
        //     else r=mid;
        // }
        return l;
    }
    const ll man=(ll)1e5+5;
    // vector<ll>adj[man];
    // bool vis[man][man];
    // ll d[man],depth[man],par[man];
    // void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/

signed main()/*Check flow...question galat mat padhna */
{
    fast;
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={0},cnt[n+1]={0};
    
    f(i,1,m+1)
    {
        ll x;
        cin>>x;
        string s;
        cin>>s;
        if(s=="WA")
        {
            if(a[x]==0)cnt[x]++;
        }
        else
        {
            a[x]=1;
        }
    }
    ll ans1=0,ans2=0;
    For(i,n+1)
    {
        if(a[i]==1)
        {
            ans1++;
            ans2+=cnt[i];
        }
        
    }
    cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 5160
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }

    let f = |s: &Vec<char>| {

        let odd = vec!['R', 'U', 'D'];
        let even = vec!['L', 'U', 'D'];
        let v = vec![odd, even];

        for (i, c) in s.iter().enumerate() {
            if !v[i % 2].contains(c) {
                return false;
            }
        }
        return true;
    };

    let result = if f(&s) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

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

    bool zero = false;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += (l + i);
        if (l + i == 0)
            zero = true;
    }

    if (zero)
        cout << sum;
    else {
        if (sum < 0) {
            cout << sum - (l + n - 1);
        } else {
            cout << sum - l;
        }
    }
}


Measured memory_bytes: 3644
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b = inpl()
res = 0
for x in range(a,b+1):
    tmp = str(x)
    if tmp == tmp[::-1]:
        res += 1
print(res)

Measured memory_bytes: 10404
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// constexpr ll lcm(ll a, ll b) { return a * modinv(gcd(a, b), MOD) * b; }


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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

vector<P> factorizer(ll n) {
    vector<P> facts;
    for (ll p=2; p*p<=n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        facts.push_back(P(p, num));
    }
    if (n != 1) facts.push_back(P(n, 1));
    return facts;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    unordered_map<ll, ll> mp;
    unordered_map<ll, ll> max_exp;
    set<ll> base;
    rep(i, n) cin >> a[i];
    // ll lc = a[0];
    // for (int i=1; i<n; ++i) {
    //     lc = lcm(lc, a[i]);
    //     cout << lc << endl;
    // }
    rep(i, n) {
        vector<P> facts = factorizer(a[i]);
        for (auto prime_exp : facts) {
            base.insert(prime_exp.first);
            // mp[prime_exp.first] += prime_exp.second;
            chmax(max_exp[prime_exp.first], prime_exp.second);
        }
    }
    ll lc = 1;
    for (auto b : base) {
        lc *= modpow(b, max_exp[b]) % MOD;
        lc %= MOD;
    }
    ll ans = 0;
    rep(i, n) {
        ans += lc % MOD * modinv(a[i], MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n;
    cin>>n;
    vector<pair<int,int>> p;
    rep(i,n){
        double a,b;
        cin>>a>>b;
        p.push_back(make_pair(a,b));
    }
    cout << fixed << setprecision(24);
    double ans=0.0;
    rep(i,n){
        rep(j,n){
            double dx=p[i].first-p[j].first,dy=p[i].second-p[j].second;
            ans+=pow(dx*dx+dy*dy,0.5)/double(n);
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int n;
char str[40];
char rstr[40];

char arr[20], brr[20];
ll D[20][20];
ll cnt(int bit) {
    int i, j, sum, l = 0, r = 0;
    for (i=0;i<n;i++) {
        if (bit>>i&1) arr[l++] = str[i];
        else brr[r++] = str[i];
    }
    for (i=0;i<=l;i++) {
        for (j=0;j<=r;j++) {
            if (i==0&&j==0) D[i][j] = 1;
            else {
                D[i][j] = 0;
                if (i&&rstr[i+j-1]==arr[i-1]) {
                    D[i][j] += D[i-1][j];
                }
                if (j&&rstr[i+j-1]==brr[j-1]) {
                    D[i][j] += D[i][j-1];
                }
            }
        }
    }
    return D[l][r];
}

int main() {
    int i;

    scanf("%d",&n);
    scanf("%s",str);
    for (i=0;i<2*n;i++) rstr[i] = str[2*n-1-i];
    ll ans = 0;
    for (i=0;i<(1<<n);i++) {
        ans+= cnt(i);
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    vector<pair<int,int>> h(H+1), w(W+1);
    rep(i,0,H+1) h[i] = make_pair(0,i);
    rep(i,0,W+1) w[i] = make_pair(0,i);
//    vector<pair<int,int>> target(M);
    set<pair<int,int>> target;
    rep(i,0,M) {
        int h_, w_;
        cin >> h_ >> w_;
        h[h_].first++;
        w[w_].first++;
//        target[i] = make_pair(h_,w_);
        target.insert(make_pair(h_,w_));
    }
/*    rep(i,1,H+1) cout << h[i] << " ";
    cout << endl;
    rep(i,1,W+1) cout << w[i] << " ";
    cout << endl;

    int ans = 0;
    for (auto p : target) {
        int h_ = p.first, w_ = p.second;
        ans = max(ans, h[h_] + w[w_] - 1);
        cout << h_ << " " << w_ << " " << ans << endl;
    }
    cout << ans << endl;
*/
//    cout << *max_element(all(h)) + *max_element(all(w)) - 1 << endl;
    sort(all(h));
    sort(all(w));
    int h_max = h[H].first, w_max = w[W].first;

    int l = 1, r = H;
    while (l < r) {
        if (h[(l+r)/2] < make_pair(h_max,0)) {
            l = (l+r)/2 + 1;
        } else {
            r = (l+r)/2;
        }
    }
    int i_ = l;
    l = 1; r = W;
    while (l < r) {
        if (w[(l+r)/2] < make_pair(w_max,0)) {
            l = (l+r)/2 + 1;
        } else {
            r = (l+r)/2;
        }
    }
    int j_ = l;

    rep(i,i_,H+1) rep(j,j_,W+1) {
        int a = h[i].second, b = w[j].second;
        if (!target.count(make_pair(a,b))) {
            cout << h_max + w_max << endl;
            return 0;
        }
    }
    cout << h_max + w_max - 1 << endl;
}

Measured memory_bytes: 21976
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
using namespace std;
const ll M = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0;i<t.size();i++){
    	if(s[i] != t[i]){
    		ans++;
    	}
    }
    cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    n -= a;
  };
  int ans = n >= 0 ? n : -1;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    bool ans = true;
    bool flag = true;
    if(S[0] != 'A') ans = false;
    for(int i = 1; i < S.size(); i++) {
        if(!islower(S[i])) {
            if(flag && i >= 2 && i <= S.size()-2 && S[i] == 'C') {
                flag = false;
                continue;
            }
            ans = false;
            break;
        }
    } 
    if(flag) ans = false;

    if(ans) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev, col;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n,k;
    cin>>n>>k;
    Array a(n),l,r;
    l.push_back(0);
    r.push_back(0);
    REP(i,n){
        cin>>a[i];
        if(a[i]<0){
            l.push_back(-a[i]);
        }else{
            r.push_back(a[i]);
        }
    }
    sort(all(l));

    ll ans=INF;
    REP(i,k+1){
        if(l.size()-1<i) break;
        if(r.size()-1<k-i) continue;
        chmin(ans, l[i]*2+r[k-i]);
        chmin(ans, l[i]+r[k-i]*2);
    }
    cout<<ans<<en;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int image[10][10];

int main(){
    int case_n = 0;

    int N;
    while(std::cin >> N, N){
        printf("Case %d:\n", ++case_n);

        int counter = 0;
        REP(i, 2*N){
            int x, y;
            if(i % 2 == 0){
                x = 0; y = i;
                while(y >= 0){
                    if(x < N && y < N){
                        image[y][x] = ++counter;
                    }
                    x++; y--;
                }
            }else{
                x = i; y = 0;
                while(x >= 0){
                    if(x < N && y < N){
                        image[y][x] = ++counter;
                    }
                    x--; y++;
                }
            }
        }

        REP(i, N){
            REP(j, N){
                printf("%3d", image[i][j]);
            }
            puts("");
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

// (y,x) ~ (y+ky-1,x+kx-1) に +1 する
// [0,cell.size()-1] x [0,cell.size()-1] で考える
void add(vector<vector<int> > &cell, int y, int x, int ky, int kx){

    // はみ出す部分
    if(y+ky>cell.size()){
        int d=y+ky-cell.size();
        add(cell,y,x,ky-d,kx);
        add(cell,0,x,d,kx);
        return;
    }
    if(x+kx>cell.size()){
        int d=x+kx-cell.size();
        add(cell,y,x,ky,kx-d);
        add(cell,y,0,ky,d);
        return;
    }

    cell[y][x]++;
    if(x+kx<cell.size()) cell[y][x+kx]--;
    if(y+ky<cell.size()) cell[y+ky][x]--;
    if(x+kx<cell.size() && y+ky<cell.size()) cell[y+ky][x+kx]++;

}

int main(){

    int n,k;
    cin>>n>>k;

    vector<vector<int> > cell(2*k,vector<int>(2*k,0));

    while(n--){
        int x,y;
        string c;
        cin>>x>>y>>c;

        if(c=="W") y+=k;

        x%=(2*k);
        y%=(2*k);

        add(cell,(y-k+1+2*k)%(2*k),(x-k+1+2*k)%(2*k),k,k);
        add(cell,(y+1)%(2*k),(x+1)%(2*k),k,k);
    }

    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k-1;j++){
            cell[i][j+1]+=cell[i][j];
        }
    }
    for(int i=0;i<2*k-1;i++){
        for(int j=0;j<2*k;j++){
            cell[i+1][j]+=cell[i][j];
        }
    }

    int res=0;
    for(int i=0;i<2*k;i++) res=max(res,*max_element(cell[i].begin(),cell[i].end()));

    cout<<res<<endl;


	return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MX = 251;
const ll INF = ll(1e17);

struct MaxFlow //by yutaka1999, have to define INF and MX (the Max number of vertices)
{
	struct edge
	{
		ll to,cap,rev;
		edge(ll to=0,ll cap=0,ll rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[MX];
	ll level[MX];
	ll iter[MX];
	
	void addedge(int s,int t,ll c) //adds an edge of cap c to the flow graph
	{
		int S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(int s)
	{
		memset(level,-1,sizeof(level));
		queue <int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
		{
			int v = que.front();que.pop();
			for(int i=0;i<vec[v].size();i++)
			{
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0)
				{
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	ll flow_dfs(int v,int t,ll f)
	{
		if (v==t) return f;
		for(ll &i=iter[v];i<vec[v].size();i++)
		{
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to])
			{
				ll d=flow_dfs(e.to,t,min(f,ll(e.cap)));
				if (d>0)
				{
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	ll maxflow(int s,int t) //finds max flow using dinic from s to t
	{
		ll flow = 0;
		while(1)
		{
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1)
			{
				ll f=flow_dfs(s,t,INF);
				if(f==0) break;
				flow += f;
			}
		}
	}
};

MaxFlow mf;
ll a[111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; 
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int s=MX-1; int e=MX-2;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=0)
		{
			sum+=a[i];
			mf.addedge(i,e,a[i]);
		}
		else
		{
			mf.addedge(s,i,-a[i]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=2*i;j<=n;j+=i)
		{
			mf.addedge(i,j,ll(1e13));
		}
	}
	ll ans=mf.maxflow(s,e);
	cout<<sum-ans<<'\n';
}


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

int main(){
    int a,b,w;
    
    cin>>w>>a>>b;
  	if (abs(a-b)<=w){
        cout<<'0'<<endl;
    }else{
    	cout<<abs(a-b)-w<<endl;
    }
        return 0;
}


Measured memory_bytes: 256
main = getLine>>=print.solve

solve :: String -> Int
solve s = sum $ map f converted
  where
  converted = words $ go s
    where
    go [] = []
    go ('A':s) = 'a' : go s
    go ('B':'C':s) = 'b' : go s
    go (c:s) = ' ' : go s
  count a = length.filter(==a)
  f s = go (count 'b' s) s
  go _ [] = 0
  go n ('a':s) = n + go n s
  go n ('b':s) = go (n-1) s
  go _ _ = undefined

Measured memory_bytes: 14716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  reverse(all(s));
  ll dp[100010][13]={0};
  dp[0][0]=1;
  ll mul=1;
  ll mod=1e9+7;
  for(ll i=1;i<=s.size();i++){
    if(s[i-1]=='?'){
      for(int j=0;j<10;j++){
        ll r=j*mul;
        ll g=r%13;
        rep(h,13){
          dp[i][(h+g)%13]+=dp[i-1][h];
          dp[i][(h+g)%13]%=mod;
        }
      }
    }
    else{
      ll c=(s[i-1]-'0');
      ll e=c*mul%13;
      rep(h,13){
        dp[i][(h+e)%13]+=dp[i-1][h];
        dp[i][(h+e)%13]%=mod;
      }
    }
    mul*=10;
    mul%=13;
  }
  ll q=s.size();
  COUT(dp[q][5]);
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

ll comb(int n, int r){
	if(r == 0 || r == n) return 1;
    ll si = 1; ll bo = 1;
    for(int i=0; i<r; i++){
        bo *= (i+1);
        si *= (n-i);
    }
    return si / bo;
}

int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int k = max(a);
	int ans = 0;
	int m = -1;
	rep(i,n){
		if(a[i] != k){
			if(min(a[i], k-a[i]) > m){
				ans = a[i];
				m = min(a[i], k-a[i]);
			}
		}
	}
	cout << k << ' ' << ans << endl;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    ll sum = 0;
    for(ll x : A) sum += x;
    ll x = 0;
    ll ans = 1000000000000000000LL;
    for(int i = 0; i < N; i++){
        x += A[i];
        if(i + 1 < N) ans = min(ans, abs(sum - 2 * x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    int z;
    for(int i=0;i<=x;i++){
        z=y-i*2-(x-i)*4;
        if(z==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3600
import java.io.*;
import java.util.Arrays;
 
class Main{
static int[] a=new int[5];
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line;
while((line=br.readLine())!=null){
String[] value=line.split(",");
a[0]=Integer.parseInt(value[0]);
a[1]=Integer.parseInt(value[1]);
a[2]=Integer.parseInt(value[2]);
a[3]=Integer.parseInt(value[3]);
a[4]=Integer.parseInt(value[4]);
Arrays.sort(a);
if(a[1]==a[4]||a[0]==a[3]){
System.out.println("four card");
}
else if((a[0]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[2]==a[4])){
System.out.println("full house");
}
else if((a[0]==a[2])||(a[1]==a[3])||(a[2]==a[4])){
System.out.println("three card");
}
else if((a[0]==a[1]&&a[2]==a[3])||(a[0]==a[1]&&a[3]==a[4])||(a[1]==a[2]&&a[3]==a[4])){
System.out.println("two pair");
}
else if((a[0]==a[1])||(a[1]==a[2])||(a[2]==a[3])||(a[3]==a[4])){
System.out.println("one pair");
}
else if((a[0]+4==a[1]+3&&a[1]+3==a[2]+2&&a[2]+2==a[3]+1&&a[3]+1==a[4])||(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13)){
System.out.println("straight");
}
else{
System.out.println("null");
}
}
}
}

Measured memory_bytes: 16920
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  long long int ans=0;
  for(int i=1;i<=n;i++)
  {
    long long int f=floor(n/i);
    ans+=i*f*(f+1)/2;
  }
  cout<<ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long  ll;
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<endl; 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const int N = 300010;
const ll INF = 1e8;
const ll MOD1=998244353;
using namespace std;
bool comp(string a, string b)
{
          return a.size()<b.size();
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 string s;
 cin>>s;
 if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
 else cout<<"No";
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector <int> l(n);
  for(int i=0;i<n;++i) cin >> l[i];
  sort(l.begin(),l.end(),greater<int>());
  int sum=0;
  for(int i=1;i<n;++i) {
    sum+=l[i];
  }
  if(sum>l[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int INF=(1<<29),n,i,j,dp[1000010],dp1[1000010];
  vector<int> a,b;
  i=0;
  while(1){
    a.push_back((i+1)*(i+2)*(i+3)/6);
    if(a[i]%2==1){
      b.push_back(a[i]);
    }
    if(a[i]>1000000){
      break;
    }
    i++;
  }
  for(i=0;i<=1000000;i++){
    dp[i]=INF;
    dp1[i]=INF;
  }
  dp[0]=0,dp1[0]=0;
  for(i=0;i<a.size();i++){
    for(j=0;j<=1000000;j++){
      if(j-a[i]>=0){
        dp[j]=min(dp[j],dp[j-a[i]]+1);
      }
    }
  }
  for(i=0;i<b.size();i++){
    for(j=0;j<=1000000;j++){
      if(j-b[i]>=0){
        dp1[j]=min(dp1[j],dp1[j-b[i]]+1);
      }
    }
  }
  while(1){
    scanf("%d\n",&n);
    if(n==0){
      break;
    }
    printf("%d %d\n",dp[n],dp1[n]);
  }
  return 0;
}


Measured memory_bytes: 11084
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N;
    char S[11];
    char Sbuf[11][2];
    int Ss[10] = {0};
    int Sn = 0;
    scanf("%d", &N);
    sprintf(S, "%d", N);

    for(int i=0; S[i] != '\0'; i++){
        Sbuf[i][0] = S[i];
        Sbuf[i][1] = '\0';
        Ss[i] = atoi(Sbuf[i]);
        Sn += Ss[i];
    }
    
    if(N % Sn == 0)
        printf("Yes\n");
    else
        printf("No\n");


    return 0;
}

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

int f[256];

int power10(int n){
	int a=1;
	for( ; n-- ; a *= 10);
	return a;
}

bool isMCXI(char c){
	return ( c == 'm' || c == 'c' || c == 'x' || c == 'i' )? true : false ;
}

int to_int(string s){
	int n = 0;
	
	for(int i=0 ; i < (int)s.size() ; i++ ){
		if( isMCXI(s[i]) ){
			n += f[ s[i] ];
		}else{
			n += ( s[i] - '0' ) * f[ s[i+1] ];
			i++;
		}
	}
	return n;
}

string to_MCXI(int n){
	string s = "";
	for(int i=0 ; i <=3 ; i++ ){
		int a = ( n % power10(i+1) ) / power10(i);
		if( a >= 1 ){
			s.push_back( f[i] );
		}
		if( a >= 2 ){
			s.push_back( a + '0' );
		}
	}
	reverse( s.begin() , s.end() );
	return s;
}

int main(){
	int n;
	string a, b;
	f['m'] = 1000;
	f['c'] = 100;
	f['x'] = 10;
	f['i'] = 1;
	f[3] = 'm';
	f[2] = 'c';
	f[1] = 'x';
	f[0] = 'i';
	
	cin >> n;
	for(int i=0 ; i<n ; i++ ){
		cin >> a >> b;
		cout << to_MCXI( to_int(a) + to_int(b) ) << endl;
	}
}

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

using namespace std;

string s[333];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int c = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++)
				if (s[(i + j) % n][k] != s[(i + k) % n][j])
					goto pnz;
		}
		c++;
	pnz:;
	}
	cout << n * c << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	reverse(ALL(s));
	vector<string> v={"dream", "dreamer", "erase", "eraser"};
	rep(i,v.size()){
		reverse(ALL(v[i]));
		// cout << v[i] << endl;
	}
	bool update = true;
	int p = 0;
	// cout << s << endl;
	while(update){
		update=false;
		rep(i,v.size()){
			if(s.substr(p,v[i].size()) == v[i]){
				p+=v[i].size();
				// cout <<v[i]<<endl;
				update = true;
			}
		}
	}
	if(p == s.size()){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using node = tuple<int,int,int,int>;
const int MAX_N = (1 << 21) - 1;
const ll inf = numeric_limits<ll>::max()/3;


ll seg_add[MAX_N];
ll seg_min[MAX_N];
int res[MAX_N];

// call init(0,0,n) to init
// node k => [l,r)
void init(int k,int l,int r){
  if(r - l == 1){
    seg_add[k] = 0; // init leaf
    seg_min[k] = 0;
  }else{
    int chl = k*2+1;
    int chr = k*2+2;
    seg_add[k] = 0; // init internal-node
    seg_min[k] = 0;
    init(chl, l, (l+r)/2);
    init(chr, (l+r)/2, r);
  }
}

// call add(a,b,x,0,0,n) to add
// node k => [l,r)
void add(int a,int b,int x,int k,int l, int r){
  // not cross
  if(r <= a || b <= l)return;
  else if(a <= l && r <= b){
    // [a,b) contain [l,r)
    seg_add[k] += x;
  } else{
    // otherwise
    int chl = k*2+1;
    int chr = k*2+2;
    add(a,b,x,chl,l,(l+r)/2);
    add(a,b,x,chr,(l+r)/2,r);
    seg_min[k] = min(seg_min[chl] + seg_add[chl],
                     seg_min[chr] + seg_add[chr]);
  }
}

// call find(a,b,0,0,n) to find min-value in  [a,b)
// node k => [l,r)
ll find(int a,int b,int k,int l,int r){
  if(r <= a || b <= l) return inf;
  else if(a <= l && r <= b){
    // [a,b) contain [l,r)
    return seg_min[k] + seg_add[k];
  } else{
    // otherwise
    int chl = k*2+1;
    int chr = k*2+2;
    ll vl = find(a,b,chl,l,(l+r)/2);
    ll vr = find(a,b,chr,(l+r)/2,r);
    return min(vl,vr) + seg_add[k];
  }
}




int main(void){
  int n,m,q;
  cin >> n >> m >> q;
  vector< node > vec;
  init(0,0,n);
  fill(res,res+MAX_N,0);
  for(int i = 0;i < m;++i){
    int d,a,b;
    cin >> d >> a >> b;
    vec.push_back((node){2*d+1,a,b,-1});
  }
  for(int i = 0;i < q;++i){
    int e,s,t;
    cin >> e >> s >> t;
    vec.push_back((node){2*e,s,t,i});
  }
  sort(vec.begin(),vec.end());
  for(int i = 0;i < (int)vec.size();++i){
    int t,a,b,index;
    tie(t,a,b,index) = vec[i];
    if(index == -1){
      add(a,b,1,0,0,n);
    }else{
      ll calc = find(a,b,0,0,n);
      if(calc == 0){
        res[index] = 0;
      }else{
        res[index] = 1;
      }
    }
  }
  for(int i = 0;i < q;++i){
    if(res[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, A, B; cin >> N >> A >> B;
  string S; cin >> S;

  int a = 0, b = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == 'c'){
      No();
    }else if (S[i] == 'a'){
      if (a + b < A + B){
        Yes(); a++;
      }else{
        No();
      }
    }else{
      if (a + b < A + B && b < B){
        Yes(); b++;
      }else{
        No();
      }
    }
  }

  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int n, m, c;
	cin >> n >> m >> c;
	int b[100];
	for(int i = 0; i < m; i++)
		cin >> b[i];
	int res = 0;
	for(int i = 0; i < n; i++){
		int cnt = 0;
		for(int j = 0; j < m; j++){
			int x;
			cin >> x;
			cnt += x * b[j];
		}
		cnt += c;
		res += (cnt > 0);
	}
	cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
#include <cmath>
#include <cstring>
#include <numeric>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <complex>
#include <list>
#include <cassert>

#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}

using namespace std;
using ll = long long;

/*
struct UnionFind {
    // union tree
    // used for tracking a set of elements partitioned into a number of disjoint subsets
    // rankなしでの実装

    vector<int> par;
    // par[i] means i's parent
    // (ex) par[3] = 2 means 2 is a parent of 3

    UnionFind(int N) : par(N) {
      //used for initialization
      for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
      // データxが属する木の根を再帰で得る
      // root(x) = {xの木の根}
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
      // xとyのtreeのmerge
      int rx = root(x); //xの根をrx
      int ry = root(y); //yの根をry
      if (rx == ry) return; //同じ時はそのままに
      par[rx] = ry; //xの根rxをyの根ryにつける
    }

    bool same(int x, int y) {
      // 2つのデータx, yが属する木が同じならtrueを返す
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }
};

template<typename T>
struct SegTree {
  //segment tree

  //木は配列で表現
  vector<T> seg;
  //木の1/2の大きさ
  int size;
  //単位元
  const T unit;
  //比較関数の型
  using F = function<T(T,T)>;
  //mergeする関数
  const F f;

  //単位元がaで大きさnのsegtreeの初期化を行う
  //大きさnとはすなわち葉の数がnであることをいう
  SegTree(int n, const T a, const F f) : unit(a), f(f) {
    size = 1;
    while(size < n) size <<= 1;
    seg.assign(2*size, unit);
    size--;
  }

  //k番目にtを代入する
  void set(int k, const T& t) {
    seg[k + size] = t;
  }

  //関数fによって木を構築する
  void build(){
    for (int i = size - 1; i >=0; i--){
      seg[i] = f(seg[i*2+1],seg[i*2+2]);
    }
  }

  //i番目の要素を返す
  T operator[](const int i){
    return seg[i + size];
  }

  //k番目の値をaに更新する
  void update(int k, T a){
    k = k + size;
    //必要ならばここを変えても良い
    seg[k] = a;
    //自分の親の情報を再帰的に更新していく
    while(k>0){
      k = ((k-1) >> 1);
      seg[k] = f(seg[k*2+1],seg[k*2+2]);
    }
  }

  //[a,b)についてfをした結果を返す
  //例えば、fがminだったらどうなるかを考えるとわかりやすい
  //unitについては足し算なら0,掛け算なら1,minならinf,どんな値が来てもその値を返すもの
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return unit;
    } else if (a <= l && r <= b) {
      return seg[k];
    } else {
      T lch = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T rch = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return f(lch, rch);
    }
  }
  T query(int a, int b) { return query(a, b, 0, 0, size+1); }
};
*/

/* --- ここからコード --- */

int main(){
  int A, B;
  cin >> A >> B ;
  for(int i = 0; i < 2000; i++){
    if((i * 8) / 100 == A && (i * 10) / 100 == B) {cout << i << endl; return 0;}
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final long answer = IntStream.range(0, n)
                .mapToObj(i -> scanner.next())
                .distinct()
                .count();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

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


int main() {

	float N;

	cin >> N;
	float target = N * (25.0 / 27.0);
	int t = ceil(target);
	//if (abs(target - t) < 1e-10)
	if (abs(floor(1.08*t)-N)<1e-10)
		cout << t << endl;
	else
		cout << ":(" << endl;
	

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int n,c[100],T=1;scanf("%d",&n),n;T++){
		rep(i,n)	scanf("%d",c+i);

		if(c[0]!=1){
			printf("Case #%d: Cannot pay some amount\n",T);
			continue;
		}

		const int L=2*c[n-1];
		int dp1[2000];	dp1[0]=0;
		fill(dp1+1,dp1+L,INF);
		rep(k,n)for(int p=c[k];p<L;p++)	dp1[p]=min(dp1[p],dp1[p-c[k]]+1);

		int dp2[2000];	dp2[0]=0;
		fill(dp2+1,dp2+L,INF);
		rep(p,L)for(int k=n-1;k>=0;k--){
			if(p-c[k]>=0){
				dp2[p]=dp2[p-c[k]]+1;
				break;
			}
		}

		bool ok=true;
		rep(i,L)if(dp1[i]<dp2[i]){ ok=false; break; }
		printf("Case #%d: %s\n",T,ok?"OK":"Cannot use greedy algorithm");
	}

	return 0;
}

Measured memory_bytes: 776
fn main() {
    proconio::input! {
        n: usize,
        a1: proconio::marker::Usize1,
        a2: proconio::marker::Usize1,
        a: [(proconio::marker::Usize1, proconio::marker::Usize1, proconio::marker::Usize1); n-1],
        an: proconio::marker::Usize1
    };
    let mut dp = vec![vec![-1; n]; n];
    let mut line = vec![-1; n];
    let mut all = 0;
    let mut plus = 0;
    dp[a1][a2] = 0;
    dp[a2][a1] = 0;
    line[a1] = 0;
    line[a2] = 0;
    for &p in &a {
        if p.0 == p.1 && p.1 == p.2 {
            plus += 1;
            continue;
        }
        let mut update = Vec::new();
        update.push((p.1, p.2, all.max(dp[p.0][p.0] + 1)));
        update.push((p.2, p.0, all.max(dp[p.1][p.1] + 1)));
        update.push((p.0, p.1, all.max(dp[p.2][p.2] + 1)));
        for i in 0..n {
            if dp[i][p.1] != -1 && p.1 == p.2 {
                update.push((i, p.0, dp[i][p.1] + 1));
            }
            if dp[i][p.2] != -1 && p.2 == p.0 {
                update.push((i, p.1, dp[i][p.2] + 1));
            }
            if dp[i][p.0] != -1 && p.0 == p.1 {
                update.push((i, p.2, dp[i][p.0] + 1));
            }
            if line[i] != -1 {
                update.push((i, p.0, line[i]));
                update.push((i, p.1, line[i]));
                update.push((i, p.2, line[i]));
            }
        }
        for &u in &update {
            dp[u.0][u.1] = dp[u.0][u.1].max(u.2);
            dp[u.1][u.0] = dp[u.1][u.0].max(u.2);
            line[u.0] = line[u.0].max(u.2);
            line[u.1] = line[u.1].max(u.2);
            all = all.max(u.2);
        }
    }
    let mut res = 0;
    for i in 0..n {
        for j in 0..n {
            res = res.max(dp[i][j] + plus + if i == j && i == an { 1 } else { 0 });
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 18072
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(i = 0;i < n;++i)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

struct rsqsegtree{
  vector<int> t;
  int re;
  int n;
  void use(int N){
    re = 0; n = N;
    int i, j;
    for(i = 0;;++i)if((1 << i) >= n)break;
    ++i; t.resize(1 << i); t[0] = 1 << i;
    for(i = 1;i < t[0];++i)t[i] = re;
    t[0] >>= 1;
    return;
  }
  void update(int at, int data){
    t[t[0] + at] += data;
    int tmp;
    for(int x = t[0] + at;x >= 2;x >>= 1)
    t[x >> 1] = (t[(x >> 1) << 1] + t[((x >> 1) << 1) + 1]);
    return;
  }
  int query(int l, int r, int k, int kl, int kr){
    //printf("%d %d %d %d %d\n", l, r, k, kl, kr);
    if(k >= t.size())return re;
    if(kl >= r || kr <= l)return re;
    if(l <= kl && kr <= r)return t[k];
    return query(l, r, k * 2, kl, (kl + kr) >> 1) + query(l, r, k * 2 + 1, (kl + kr) >> 1, kr);
  }
  int getsum(int l, int r){ return query(l, r, 1, 0, t[0]); }
  void deb(void){
    int x = 1;
    t[0] *= 2;
    printf("t[0] : %d\n", t[0]);
    for(int i = 1;i < t[0];++i){
      printf("%11d", t[i]);
      if(i == (1 << x) - 1){ puts(""); ++x; }
    }
    t[0] /= 2;
    return;
  }
};

rsqsegtree ST;

signed main(void){
  int i, j;
  int2(n, q);
  ST.use(n);
  for(;q--;){
    int3(z, x, y);
    if(z == 0)ST.update(x - 1, y);
    else printf("%d\n", ST.getsum(x - 1, y));
    //ST.deb();
  }

  return 0;
}

Measured memory_bytes: 3872
#!/usr/bin/python

if __name__ == "__main__":
	S = raw_input()
	c = ['A','B','C']
	
	while True:
		if len(S) <= 3:
			print "Yes" if S == "ABC" else "No"
			break
		
		T = S.strip().split("ABC")
		if len(T) == 1:
			print "No"
			break
			
		P = ''.join(T)
		cnt = 0
		for x in c:
			if x in P:
				cnt += 1
			else:
				S = x.join(T)
		
		if cnt != 2:
			print "No"
			break

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    int n = N / 100;
    n = n * 100 + n * 10 + n;
    if(N <= n) cout << n << endl;
    else cout << n + 111 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256