akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

string s;
int N, K;
int A[100001], C[100001], Q[100001];
long exp[100001];

const int MOD = 1000000007;
const int INV = 333333336;

long sub(int i) {
  if (s[i] != 'B' && s[i] != '?') return 0;
  long sum = 1;
  sum *= (3 * A[i] + Q[i]) * exp[Q[i]] % MOD * INV % MOD;
  const int Cp = C[N] - C[i + 1];
  const int Qp = Q[N] - Q[i + 1];
  sum *= (3 * Cp + Qp) * exp[Qp] % MOD * INV % MOD;
  return sum;
}

int main() {
  cin >> s;
  N = s.size();
  
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'A') A[i + 1] = 1;
    if (s[i] == 'C') C[i + 1] = 1;
    if (s[i] == '?') Q[i + 1] = 1;
  }
  partial_sum(A, A + N + 1, A);
  partial_sum(C, C + N + 1, C);
  partial_sum(Q, Q + N + 1, Q);
  
  exp[0] = 1;
  for (int i = 1; i <= N; ++i) {
    exp[i] = (exp[i - 1] * 3) % MOD;
  }
  
  long sum = 0;
  for (int i = 1; i < N - 1; ++i) {
    sum += sub(i);
    sum %= MOD;
  }
  cout << sum << endl;
}

Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize, x: [i64; n],
    }
    let tot: i64 = x.iter().sum();
    let nn = n as i64;
    let a = (2 * tot + nn) / (2 * nn);
    let mut sum = 0;
    for i in 0..n {
        sum += (x[i] - a) * (x[i] - a);
    }
    puts!("{}\n", sum); 
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <algorithm>
#include <array>

int test() {
	int A, B, C;
	std::cin >> A >> B >> C;
	std::array<int, 3> ABC = { A, B, C };
	std::sort(ABC.begin(), ABC.end());
	auto diff0 = ABC[2] - ABC[0];
	auto diff1 = ABC[2] - ABC[1];
	if (diff0 % 2 == 0 && diff1 % 2 == 0) {
		return diff0 / 2 + diff1 / 2;
	}
	else if (diff0 % 2 == 1 && diff1 % 2 == 1) {
		return diff0 / 2 + diff1 / 2 + 1;
	}
	else {
		return diff0 / 2 + diff1 / 2 + 2;
	}
}

int main() {
	auto result = test();
	std::cout << result;
	// int i;
	// std::cin >> i;
}

Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict


def trivial_division(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


# n乗のときの最大試行回数
dd = defaultdict(int)
total = 0
for i in range(1, 100):
    for j in range(total, total+i):
        dd[j] = i-1
    total += i

# 素因数分解後、各頻度を抽出
N = int(input())
li = trivial_division(N)
cnt = Counter(li)

ans = 0
for v in cnt.values():
    ans += dd[v]
print(ans)


Measured memory_bytes: 9688
fun main(arr:Array<String>) {
    val inpt = readLine()!!.split(" ")
    var ans = 0
    if(inpt[1] == "+") {
        ans = inpt[0].toInt() + inpt[2].toInt()
    } else {
        ans = inpt[0].toInt() - inpt[2].toInt()

    }
    println(ans)
}

Measured memory_bytes: 36016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <climits>

using namespace std;
#define forn(x, n)         for (int x = 0; x < n; x++)
#define forr(x, n)         for (int x = n; x >= 0; x--)
#define for1(x, n)         for (int x = 1; x < n; x++)
#define fore(x, a, b, c)   for (int x = a; x <= b; x += c)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define eprint(...) 0
#endif
template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int N = 110;
int arr[N];

int main(void)
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    fore(i, 1, n, 1) {
        scanf("%d", &arr[i]);    
        if (i % 2 != 0 && arr[i] % 2 != 0) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		
		long an = 0;
		
		for(long i = 1; i <= n; i++)
		{
			if(i%3 != 0 && i%5 != 0)
			{
				an += i;
			}
			
		}
		
		System.out.println(an);
	}

}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

struct Train {
    ll time, start, between;
};

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

    vector<Train> trains(n - 1);
    rep(i, n - 1) cin >> trains[i].time >> trains[i].start >> trains[i].between;

    for (int j = 0; j < n - 1; j++) {

        ll now = 0;
        for (int i = j; i < n - 1; i++) {
            Train t = trains[i];
            if (now <= t.start) {
                now = t.start + t.time;
                continue;
            }
            ll honme = (now + t.between - 1) / t.between;
            ll start = honme * t.between;
            now = start + t.time;
        }
        cout << now << endl;
    }
    cout << 0 << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	if(a==b)cout<<a+b<<endl;
	else cout<<b+b-1<<endl;
	return 0;
}

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

int main(){
 int A,B,C,X;
 cin >> A >> B >> C >> X;
 
 
 int ans = 0;
 for(int a = 0;a<=A;a++){
   for(int b = 0;b<=B;b++){
     for(int c = 0;c<=C;c++){
       int total = 500*a + 100*b + 50*c;
       if(total == X) ans++;
     }
   }
 }
  cout << ans << endl;
   
 }

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 301;
const int MOD = 1e9 + 7;

template <class T>
void add(T &a, const T b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

long double Sum(long double* begin, long double* end) {
	long double ans = *begin++;
	long double c = 0;
	while (begin != end) {
		long double t = ans + *begin;
		if (abs(ans) >= abs(*begin)) {
			c += (ans - t) + *begin;
		} else {
			c += (*begin - t) + ans;
		}
		ans = t;
		begin++;
	}
	return ans + c;
}

int n;
long double DP[N][N][N];

long double dp(int a, int b, int c) {
	int zero = n - c - a - b;
	if (zero == n) {
		return 0;
	}
	if (DP[a][b][c])
		return DP[a][b][c];
	long double answer = 0;
	int nonzero = n - zero;
	if (a > 0) {
		long double hit = (a + .0) / nonzero;
		answer += hit * (dp(a - 1, b, c));
	}
	if (b > 0) {
		long double hit = (b + .0) / nonzero;
		answer += hit * (dp(a + 1, b - 1, c));
	}
	if (c > 0) {
		long double hit = (c + .0) / nonzero;
		answer += hit * (dp(a, b + 1, c - 1));
	}
	long double stay = (zero + .0) / n;
	answer += 1.0 / (1 - stay);
	return DP[a][b][c] = answer;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	int cnt[4] = { 0,0,0,0 };
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		++cnt[x];
	}
	cout.precision(20);
	cout << dp(cnt[1], cnt[2], cnt[3]) << endl;
	return 0;
}

Measured memory_bytes: 426368
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a[3];
  map<ll, int> m;
  REP(i, 3){
    cin >> a[i];
    m[a[i]]++;
  }
  ll ans = m.size();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
def path(start):
    if dp[start]!=-1:
        return dp[start]
    visited[start]=1
    maxi=-1
    for i in adjacency_list[start]:
        maxi=max(maxi,path(i))
    dp[start]=maxi+1
    return dp[start]
N,M=map(int,input().split())
dp=[-1]*(N+1)
visited=[0]*(N+1)
adjacency_list=[]
for i in range(N+1):
    adjacency_list.append([])
# print(adjacency_list)
for r in range(M):
    u,v=map(int,input().split())
    adjacency_list[u].append(v)
# print(adjacency_list)
for i in range(1,N+1):
    if len(adjacency_list[i])==0:
        dp[i]=0
# print(dp)
for i in range(1,N+1):
    if (visited[i]==0):
        path(i)
print(max(dp))

Measured memory_bytes: 133604
#include<cstdio>
#include<iostream>
using namespace std;
const int N=2e5+5;
int n,len,ans=2e9,p[N];
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++) scanf("%d",&x),p[x]=i;
	len=1;
	for(int i=1;i<=n;i++){
		if(p[i+1]>=p[i]) len++;
		else ans=min(ans,n-len),len=1;
	}
	ans=min(ans,n-len);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 1024
import sys
N = int(input())
H = [int(h) for h in input().split(" ")]

flag = True
h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i] - 1:
    h_previous = H[i] - 1 
  elif h_previous <= H[i]:
    h_previous = H[i]
  else:
    flag = False
    break
    
  
if flag:
  print("Yes")
    
else:   
    
  print("No") 
    
    

  

  
  
  

Measured memory_bytes: 14396
def resolve():
    import sys
    import string
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    n, m = [int(x) for x in input().rstrip().split(" ")]
    left = 1
    right = n
    for i in range(m):
        l, r = [int(x) for x in input().rstrip().split(" ")]
        if left < l:
            left = l
        if right > r:
            right = r

        if right < left:
            print(0)
            return

    print(right - left + 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 75416
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 1000000005
#define MOD 1000000007
#define LOG 20
#define EPS 0.000000001
#define M 305
using namespace std;

int n,k;
int h[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n;
	map<int,int> mp;
	for(int i=1;i<=n;i++) {
		int x;
		cin>>x;
		if(mp[x]) {
			cout<<"NO";
			return 0;
		}
		mp[x]=1;
	}
	cout<<"YES";

}

Measured memory_bytes: 9600
#include <iostream>

int n, a[100000001];

int cal2(int n)
{
  int count = 0;
  while(n%2==0)
  {
    count++;
    n /= 2;
  }
  return count;
}
int main()
{
  std::cin >> n;
  for(int i=0; i<n; i++) std::cin >> a[i];

  int ans = 100;

  for(int i=0; i<n; i++ )
  {
    ans = std::min(ans, cal2(a[i]));
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
/*Author : Prokash
           JU CSE 48
           CF: epiprokash
           UVa: epiprokash
*/

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int i,j;
    cin>>str;
    int cnt=0;
    for(i=0,j=str.size()-1;i<j;i++,j--)
    {
        if(str[i]!=str[j])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;


int main() {
  string s,t;cin>>s>>t;

  for (char c:t) {
    if (s.find(c)==string::npos) {
      OUT(-1);
      return 0;
    }
  }

  vector<vector<int>> pos(26);
  REP(i,siz(s)) {
    char c = s[i];
    pos[c-'a'].push_back(i);
  }

  ll ans = 0;
  int cur = 0;
  int tmp = 0;

  while (cur<siz(t)) {
    int tchar = t[cur]-'a';
    auto it = lower_bound(ALL(pos[tchar]),tmp);
    // 一周して戻ってくる
    if (it==pos[tchar].end()) {
      ans += (pos[tchar].front()+1)+(siz(s)-tmp);
      tmp = (pos[tchar].front()+1)%siz(s);
    } else {
      ans += *it-tmp+1;
      tmp = (*it+1)%siz(s);
    }
    cur++;
  }
  OUT(ans);


  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
typedef long long ll;
const int MAXN = 1e6+10;
const int mod = 1e9+7;
using namespace std;

map<ll,ll>mp;
map<ll,ll>::iterator it;
ll a[MAXN];
int main()
{
    int n;
    cin>>n;
    for(int i = 1;i <= n ; i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    //int ans = n;
    sort(a+1,a+n+1);
    int len = unique(a+1,a+n+1)-(a+1);
/*
    for(it = mp.begin();it!=mp.end();it++)
    {
        if( (it->second-1) > 0 && ( it->second-1) %2 ==0)
        {
            ans -= ( it->second-1);
        }
        else if( (it->second-1) > 0 && ( it->second-1) %2 ==1)
        {
            ans -= (it->second );
        }
    }
    cout<<ans<<endl;
    */

    int ans = len;
    int sum = 0;
    for(it = mp.begin();it!=mp.end();it++)
    {
        if( (it->second-1) > 0 && ( it->second-1) %2 ==1)
        {
            sum+= it->second-1;
        }
    }
    if( sum%2==1)
        ans-=1;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k,a[100005],b[100005],amin=1e6,bmin=1e6;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		amin=min(amin,a[i]);
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		bmin=min(bmin,b[i]);
	}
	int ans=amin+bmin,x,y,t;
	for(int i=1;i<=k;i++){
		cin>>x>>y>>t;
		ans=min(ans,a[x]+b[y]-t);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;
static const int MAX = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, Adjacency_Matrix[MAX][MAX];

int prim(){
  int u, minv;
  int d[MAX], p[MAX], color[MAX];
  // init
  for(int i = 0;i < n; i++){
    d[i] = INF;
    p[i]= -1;
    color[i] = WHITE;
  }

  d[0] = 0;
  while(1){
    minv = INF;
    u = -1;
    for(int i = 0; i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(int v = 0; v < n; v++){
      if(color[v] != BLACK && Adjacency_Matrix[u][v] != INF){
        if(d[v] > Adjacency_Matrix[u][v]){
          d[v] = Adjacency_Matrix[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
    int sum = 0;
    for(int i = 0;i<n; i++){
      if(p[i] != -1) sum += Adjacency_Matrix[i][p[i]];
    } 
    return sum;
}


int main(){
  cin >> n;

  for(int i =0; i<n; i++){
    for(int j=0; j<n; j++){
      int e;
      cin >> e;
      Adjacency_Matrix[i][j] = (e== -1) ? INF : e;
    }
  }

  cout << prim() << endl;

  return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n;
  char s[110];
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    printf("x");
  }
  printf("\n");
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> high;
    vector<int> highList(n);
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        high.push_back(make_pair(t,i));
        highList[i] = t;
    }
    sort(high.begin(), high.end(), greater<pair<int,int>>());

    vector<vector<int>> road(n);
    for(int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        road[a].push_back(b);
        road[b].push_back(a);
    }

    int ans = 0;
    vector<bool> checker(n);
    for(pair<int,int> p : high)
    {
        int cur = p.second;
        if(checker[cur])
        {
            continue;
        }
        checker[cur] = true;
        int curHigh = p.first;
        bool result = true;
        for(int i : road[cur])
        {
            int tHigh = highList[i];
            if(tHigh <= curHigh)
            {
                checker[i] = true;
            }
            if(tHigh >= curHigh)
            {
                result = false;
            }
        }
        if(result)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9636
import java.util.Scanner;

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

    int R = scanner.nextInt();
    int G = scanner.nextInt();
    int B = scanner.nextInt();
    int N = scanner.nextInt();

    long count = 0;
    for (int i = 0; i <= N / R; i++) {
      int r = N - R * i;
      for (int j = 0; j <= r / G; j++) {
        if ((r - G * j) % B == 0) count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int w[n];
  for(int i=0;i<n;i++) cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++) sum+=w[i];
  int l=0,r=sum;
  while(l+1<r){
    int m=(l+r)/2;
    int t=0,tmp=0;
    bool f=0;
    for(int i=0;i<n;i++){
      f|=w[i]>m;
      if(tmp+w[i]>m){
	tmp=w[i];
	t++;
      }else tmp+=w[i];
    }
    if(tmp) t++;
    if(!f&&t<=k) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}



Measured memory_bytes: 3872
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 100010;

ll n, ar[maxn];

void MAIN() {

    cin >> n;
    fori (i, n) cin >> ar[i];
    ll ans = 0;
    fori (i, n - 1) {
        if (ar[i] == i + 1) ++ans, swap(ar[i], ar[i + 1]);
    }
    if (ar[n - 1] == n) ++ans;
    cout << ans << '\n';

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
5
1 4 3 5 2
    )";
    MAIN();
    return 0;
}


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

#define int long long
int prime[2234];
vector<int>vp;


signed main(){
  for(int i=2;i<2234;i++)prime[i]=1;
  for(int i=2;i<2234;i++)
    if(prime[i]){
      vp.push_back(i);
      for(int j=i*i;j<2234;j+=i)prime[j]=0;
    }
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  map<int,int> m;
  int ans=0;
  for(int i=0;i<n;i++){
    for(int p:vp)while(v[i]%(p*p*p)==0)v[i]/=p*p*p;
    if(v[i]==1)ans|=1;
    else m[v[i]]++;
  }
  for(auto p:m){
    int a=p.first;
    int tui=1;
    for(int q:vp){
      if(a%(q*q)==0){
        tui*=q;
        a/=q*q;
      }
      if(a%q==0){
        tui*=q*q;
        a/=q;
      }
    }
    if(a<1e6)tui*=a*a;
    else{
      int tmp=sqrt(a);
      if(a==tmp*tmp)tui*=tmp;
      else if(a==(tmp-1)*(tmp-1))tui*=tmp-1;
      else if(a==(tmp+1)*(tmp+1))tui*=tmp+1;
      else tui*=0;
    }
    if(!(m.count(tui)&&(m[tui]>p.second||(m[tui]==p.second&&tui>p.first))))ans+=p.second;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7296
a, b = map(int, (input().split()))
if a % 2 ==0:
    if b % 2 ==0:
        print(int((b - a) /2 % 2) ^ b)
    else:
        print(int((b - a + 1)/2 % 2))
else:
    if b % 2 ==0:
        print(a ^ b ^ int((b - a)/2 % 2))
    else:
        print(a ^ int((b - a)/2 %2))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> nums;
    for(auto i = 0; i < n; ++i) {
        int num; cin >> num;
        nums.push_back(num);
    }
    
    auto sum_all = accumulate(nums.begin(), nums.end(), 0);
    auto sum_one_side = 0;
    auto min = numeric_limits<int>::max();
    for (int i = 0; i < n; ++i) {
        sum_one_side += nums[i];
        auto diff = abs((sum_all - sum_one_side) - sum_one_side);
        if (min > diff) {
            min = diff;
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int main(){
	int t,x;
	cin >> t >> x;
	cout << (double)t/x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll a; cin>>a;
	ll b; cin>>b;
	ll c; cin>>c;
	ll k; cin>>k;
	if(k<=a){
		cout<<k<<endl;
		return 0;
	}else if(k<=a+b){
		cout<<a<<endl;
		return 0;
	}else{
		cout<<a-(k-a-b)<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    ll xi = x;
    REP(i, 10)
    {
        ll xi1 = r*xi - D;
        cout << xi1 << endl;
        xi = xi1;
    }
}

Measured memory_bytes: 256
//65 - A 90 - Z 97 - a 122 - z
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

int cnt[10000];

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

    string s;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i++)
        cnt[(int)s[i]] ++;
    for(int i = (int)'a'; i <= (int)'z'; i++)
    {
        if(cnt[i] == 0)
        {
            cout << (char)i;
            return 0;
        }
    }
    cout << "None";
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
int maze[55][55]={};
bool reached[55][55]={};
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int w,h;
int islands;

void search(int nowy,int nowx,bool start){

    if(reached[nowy][nowx]||maze[nowy][nowx]==0)return;

    if(start)islands++;

    reached[nowy][nowx]=true;
    //cout<<nowy<<" "<<nowx<<" "<<endl;
    rep(i,8)
    {
        int nx=nowx+dx[i];
        int ny=nowy+dy[i];

        if(nx<1 || nx>w || ny<1 || ny>h||reached[ny][nx]|| !maze[ny][nx])continue;

        search(ny,nx,false);
    }
    //cout<<islands<<" end"<<endl;
    return;
}
int main(){
    

    while(1){
    
    cin>>w>>h;
    if(w==0 && h==0)break;
    //cout<<w<<" "<<h<<endl;
    islands=0;

    rep2(i,50)rep2(k,50){
        reached[i][k]=false;
        maze[i][k]=0;
    }
    rep2(i,h)rep2(k,w){
        int t;
        cin>>t;
        maze[i][k]=t;
    }

    rep2(i,h)rep2(k,w)search(i,k,true);

    cout<<islands<<endl;
    
    }
    return 0;

}
/*


*/



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 && b==2){cout<<"3"<<endl;}
else if(a==2 && b==1){cout<<"3"<<endl;}
else if(a==1 && b==3){cout<<"2"<<endl;}
else if(a==3 && b==1){cout<<"2"<<endl;}
else if(a==2 && b==3){cout<<"1"<<endl;}
else if(a==3 && b==2){cout<<"1"<<endl;}


}


Measured memory_bytes: 256
let main = (input) => {
    let args = input.split(/\s+/)
    let animals = parseInt(args[0])
    let legs = parseInt(args[1])
    let crane = (legs - 2 * animals) / 2
    let turtle = (4 * animals - legs) / 2

    if (crane >= 0 && turtle >= 0 && Number.isInteger(crane) && Number.isInteger(turtle)) {
        console.log("Yes")
    } else {
        console.log("No")
    }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29380
#include <iostream>
using namespace std;
int int_reverse(int n){
    int res = 0;
    while(n > 0){
        res = res*10 + n%10;
        n/=10;
    }
    return res;
}

int main(void){
    int A,B,count = 0;
    cin >> A >> B;
    
    for(int i=A;i<=B;i++){
        if(i - int_reverse(i) == 0){
            count++;
        }
    }
    cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define inf 0x3f3f3f
typedef long long ll;
const int maxn = 2e5+5;
ll n,a[maxn],b[maxn];
int main(){
	scanf("%lld",&n);
	for(int i =1;i <= n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		if(b[i]>1)
			ans += b[i]*(b[i]-1)/2;
	}
	for(int i = 1;i <= n;i++){
		printf("%lld\n",ans-b[a[i]]+1);
	}
	return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define N 40

vector<int> a, b, c;

void postOrder(vector<int>::iterator a1, vector<int>::iterator a2, vector<int>::iterator b1, vector<int>::iterator b2)
{
    //printf("%d %d %d %d\n", *a1, *(a2 - 1), *b1, *(b2 - 1));
    vector<int>::iterator itr;
    c.push_back(*a1);
    //printf("%d\n", *a1);
    itr = find(b1, b2, *a1); //itrator of root on inorder tree walk
    int d = itr - b1;
    if (a1 + d + 1 < a2 && itr + 1 < b2)
        postOrder(a1 + d + 1, a2, itr + 1, b2);
    if (a1 + 1 < a1 + d + 1 && b1 < itr)
        postOrder(a1 + 1, a1 + d + 1, b1, itr);
}

int main()
{
    int n, x;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        b.push_back(x);
    }

    postOrder(a.begin(), a.end(), b.begin(), b.end());

    for (int i = 0; i < c.size(); i++)
    {
        if (i != 0)
            cout << " ";
        cout << c[c.size() - 1 - i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>

int main (int argc, char **argv)
{
    int w, h, n;
    scanf("%d %d %d", &w, &h, &n);

    int left = 0;
    int right = w;
    int top = h;
    int bottom = 0;
    for (int i = 0; i < n; ++i) {
        int x, y, a;
        scanf("%d %d %d", &x, &y, &a);

        if (a == 1) {
            if (x > left) {
                left = x;
            }
        } else if (a == 2) {
            if (x < right) {
                right = x;
            }
        } else if (a == 3) {
            if (y > bottom) {
                bottom = y;
            }
        } else if (a == 4) {
            if (y < top) {
                top = y;
            }
        }
    }

    int s = 0;
    if (top - bottom > 0 && right - left > 0) {
        s = (top - bottom) * (right - left);
    }
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100;
int a[MAXN + 5];
int main() {
	int N;
	long long s1 = 0;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &a[i]);
		s1 += a[i];
	}
	s1 = round(1.0 * s1 / N);
	long long ans = 0;
	for(int i=1;i<=N;i++) {
		ans += (a[i] - s1) * (a[i] - s1);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
let split_on_char =
    BatString.split_on_char

let calc a b s =
    match split_on_char '-' s with
    | [x; y] -> String.length x = a && String.length y = b
    | _ -> false

let main =
    let [a; b] = read_line () |> split_on_char ' ' |> List.map int_of_string in
    let s = read_line () in
    let v = (calc a b s) in
    print_endline (if v then "Yes" else "No")


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

int main()
{
  int N,count=0;
  string s,t;
  cin>>s;
  cin>>t;
  if(s.size()+1!=t.size()){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
    cout<<"No";
    return 0;
    }
  }
  if('a'<=(char)t[s.size()]&&(char)t[s.size()]<='z'){
      cout<<"Yes";
  }else{
    cout<<"No";

  }
  return 0;
}


Measured memory_bytes: 3624
S = input()
l = len(S)
A = [0 for i in range(l+1)]
for i in range(l):
    if S[i] == '<':
        A[i+1] = max(A[i+1],A[i]+1)
for i in range(l-1,-1,-1):
    if S[i] == '>':
        A[i] = max(A[i+1]+1,A[i])
print(sum(A))

Measured memory_bytes: 24092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
   int a[10001];
  for(int i=0;i<3;i++)
  {
      cin>>a[i];
  }
  sort(a,a+3);
  int cnt=1;
  for(int i=0;i<2;i++)
  {
      if(a[i]!=a[i+1])
      {
          cnt++;
      }
  }
  cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define size(v) v.size()

const int N=100005;
const int MOD=1e9+7;

 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define printclock cerr<<"Time : "<<1000*(int)clock()/(int)CLOCKS_PER_SEC<<"ms\n"
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/





int n;
cin>>n;
int count[N]={0};
int sum=0;
for(int i=0;i<n;i++)
{
	int x;
	cin>>x;
	count[x]++;
	sum+=x;
	
}
int q;
cin>>q;
while(q--)
{
	int a,b;
	cin>>a>>b;
	sum+=(b-a)*count[a];
	count[b]+=count[a];
	count[a]=0;
	cout<<sum<<" ";
	
	
	

}


printclock;
}




Measured memory_bytes: 4440
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int m[] = new int[N];
		for(int i = 0;i < N;i++) {
			m[i] = sc.nextInt();
			X = X - m[i];
		}
		int min;
		for(int i = 0;i < N;i++) {
			for(int j = 1;j < N;j++) {
				if(m[i] > m[j]) {
					min = m[i];
					m[i] = m[j];
					m[j] = min;
				}
			}
		}
		X = X/m[0];
		System.out.println(X + N);
		sc.close();
	}
}

Measured memory_bytes: 22868
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 1000000007
	n,m = readline() |> split |> parseMap
	a = Array{Int}(m)
	for i in 1:m
		a[i] = readline() |> parseInt
	end
	push!(a,n+1)
	now = shift!(a)
	dp = zeros(Int,n+1)
	dp[1] = 1
	if now==1
		dp[2] = 0
		now = shift!(a)
	else
		dp[2] = 1
	end
	for i in 3:n+1
		if i-1 == now
			dp[i] = 0
			now = shift!(a)
		else
			dp[i] = (dp[i-1]+dp[i-2])%mod
		end
	end
	println(dp[n+1])
end

main()

Measured memory_bytes: 167580
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var a = one[0];
  var b = one[1];
  for(var i = 0; i < 10000; i++){
    var tmpa = Math.floor(i * 0.08);
    var tmpb = Math.floor(i * 0.1);
    if(tmpa == a && tmpb == b){
       myout(i);
      return;
    }
  }
  myout(-1);
}

Measured memory_bytes: 11468
#include <cstdio>
using namespace std;
int main() {
    int H, W; scanf("%d %d", &H, &W);
    char a[W];
    for(int i = 0; i < H+2; i++) {
        if(i>0&&i<H+1) scanf("%s", a);
        for(int j = 0; j < W+2; j++) {
            if(i==0||i==H+1||j==0||j==W+1) {
                printf("#");
                continue;
            }
            printf("%c", a[j-1]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll func(ll b,ll n)
{
	if(n == 0)return 0;
	return func(b,n/b) + (n % b);
}

int main()
{
	ll n,s;cin >> n >> s;
	
	if(s > n)
	{
		cout << -1 << endl;
		return 0;
	}
	if(s == n)
	{
		cout << n+1 << endl;
		return 0;
	}
	
	for(ll i = 2;i*i <= n;i++)
	{
		if(func(i,n) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	ll ans = 100000000000000LL;
	for(ll i = 1;i*i <= n;i++)
	{
		if((n-s)%i==0 && (n-s)/i!=0)
		{
			ll tmp = (n-s)/i + 1;
			if(func(tmp,n) == s)ans = min(ans,tmp);
		}
	}
	
	if(ans == 100000000000000LL)
	{
		cout << -1 << endl;
		return 0;
	}
	else
	{
		cout << ans << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int a,b,c,d;
    readf("%d\n%d\n%d\n%d\n", &a, &b, &c, &d);
    writeln(min(a,b) + min(c,d));
    auto _ = readln(); // dbg
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    double n, t, a, m=inf;
    int ans;
    cin >> n >> t >> a;
    vector<double> h(n);
    rep(i, n)cin >> h.at(i);
    rep(i, n){
        if(abs(a - (t-h.at(i)*0.006)) < m){
            m = abs(a - (t-h.at(i)*0.006));
            ans = i+1;
        }
    }
    cout << ans;
}

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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<int> V;
typedef vector<V> VV;
const LL INF=1e8;
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    VV dp(401,V(401,INF));
    dp[0][0]=0;
    REP(latte,N){
        int a,b,c;
        cin>>a>>b>>c;
        auto nxt=dp;
        for(int i=a;i<=400;i++)
            for(int j=b;j<=400;j++)
                chmin(nxt[i][j],dp[i-a][j-b]+c);
        swap(dp,nxt);
    }
    int M=A,K=B,res=INF;
    for(;M<=400&&K<=400;M+=A,K+=B)
        chmin(res,dp[M][K]);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  vector<int> freqs(N, 0);
  int a = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    ++freqs[a];
  }

  bool ok = true;
  if (N % 2 == 0 and freqs[0] != 0) { ok = false; }
  if (N % 2 == 1 and freqs[0] != 1) { ok = false; }

  if (N % 2 == 0) {
    for (int i = 1; ok and i < N; ++i) {
      if (i % 2 == 1 and freqs[i] != 2) { ok = false; }
      if (i % 2 == 0 and freqs[i] != 0) { ok = false; }
    }
  }
  else {
    for (int i = 1; ok and i < N; ++i) {
      if (i % 2 == 1 and freqs[i] != 0) { ok = false; }
      if (i % 2 == 0 and freqs[i] != 2) { ok = false; }
    }
  }

  ll ans = 1;
  if (not ok) { ans = 0; }
  else {
    for (int i = 0; i < N / 2; ++i) {
      ans = (ans * 2) % MOD;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;



int main() {
    ll d, g;
    cin >> d >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    for (int i = 0; i < d; ++i) {
        cin >> p[i];
        cin >> c[i];
    }
    ll res = 999999999999;
    vector<bool> f(d);
    for (ull i = 0; ((i >> d) & 1) != 1; ++i) {
        ll sum = 0;
        ll mon = 0;
        for (ull j = 0; j < d; ++j) f[j] = (((i >> j) & 1) == 1);
        for (int j = 0; j < d; ++j) {
            if (f[j]) {
                sum += 100 * (j + 1) * p[j];
                sum += c[j];
                mon += p[j];
            }
        }
        for (int j = d - 1; j >= 0 && sum < g; --j) {
            if (f[j]) continue;
            ll point = (100 * (j + 1));
            ll needmon = (g - sum + point - 1) / point;
            if (needmon >= p[j]) {
                sum += point * (p[j] - 1);
                mon += p[j] - 1;
            }
            else {
                sum += point * needmon;
                mon += needmon;
                break;
            }
        }
        if(sum >= g) res = min(res, mon);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger res = new BigInteger("0");

        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            res = res.add(BigInteger.valueOf(i));
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 44872