akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int n, s, t;
  vector<int> vec;

  while(cin>>n && n){
    for(int i = 0; i < n; ++i){
      s = 0;
      for(int j = 0; j < 5; ++j){
	cin >> t;
	s += t;
      }
      vec.push_back(s);
    }
    sort(vec.begin(), vec.end());

    cout << vec.back() << " " << vec.front() << endl;
    vec.clear();
  }

  return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;
vector<P>xy[16];

int check(int x){
	int cnt = 0;
	vector<int> temp(n);
	while(x != 0){
		if(x % 2 == 0){
			temp[cnt] = 0;
		}else{
			temp[cnt] = 1;
		}
		x /= 2;
		cnt++;
	}
	// for(int i = 0; i < temp.size(); i++){
	// 	cout << temp[i] << " ";
	// }
	// cout << endl;
	for(int i = 0; i < temp.size(); i++){
		if(temp[i] == 0)continue;
		for(auto a: xy[i]){
			// cout << a.first << " " << a.second << endl;
			if(temp[a.first] != a.second)return 0;
		}
	}
	// cout << "Yes: " << accumulate(all(temp), 0)<<endl;
	return accumulate(all(temp), 0);
}

int main(){
	cin >> n;
	
	for(int i = 0; i<n; i++){
		int a;
		cin >> a;
		for(int j = 0; j < a; j++){
			int x, y;
			cin >> x >> y;
			xy[i].push_back(P(x-1,y));
		}
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++){
		ans = max(ans, check(i));
	}
	cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

struct edge
{
    int to;
    int change;
    int time;
    edge(int to, int c, int t): to(to), change(c), time(t) {}

};

struct data_t
{
    int v;       // 今の頂点
    int change;  // 今の銀貨の枚数
    long long time;    // 今のかかった時間

    data_t(int v, int change, long long time): v(v), change(change), time(time) {}

    bool operator < (const data_t& right) const {
        return time > right.time;
    }
};

int main()
{
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<edge>> G(N);
    REP(i, M){
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        --U, --V;
        G[U].emplace_back(V, A, B);
        G[V].emplace_back(U, A, B);
    }
    vector<int> C(N), D(N);
    REP(i, N) cin >> C[i] >> D[i];


    int mx = 50*(N-1);  // 高々 50*(N-1) 枚の銀貨があれば十分

    // dp[i][j] = i まで銀貨 j 枚で行ける最短の時間
    vector<vector<long long>> dp(N, vector<long long>(mx+1, 1e+18));
    priority_queue<data_t> q;
    q.emplace(0, min(S, mx), 0);
    while(!q.empty()){
        auto top = q.top(); q.pop();
        int v = top.v;
        int c = top.change;
        long long t = top.time;
        if(c < 0 or dp[v][c] <= t) continue;
        dp[v][c] = t;
        q.emplace(v, min(c+C[v], mx), t+D[v]);
        for(auto e: G[v]){
            q.emplace(e.to, min(c-e.change, mx), t+e.time);
        }
        // cout << v << " " << c << " " << t << " " <<  endl;
    }

    FOR(i, 1, N) cout << *min_element(dp[i].begin(), dp[i].end()) << endl;

    return 0;
}

Measured memory_bytes: 8436
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int gcd(int a, int b)
{
    if (a == 0) {
        return b;
    } else {
        return gcd(b % a, a);
    }
}

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

    int result = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        result = gcd(result, a);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;
const long long MOD = 1000000007;
std::string S;

long long M[MAX_N], C[MAX_N], BC[MAX_N], ABC[MAX_N];

int main(int argc, char **argv) {
    std::cin >> S;

    M[0] = 1;
    C[0] = 0;
    BC[0] = 0;
    ABC[0] = 0;

    for (int i = 1; i <= S.size(); i++) {
        if (S[S.size() - i] == 'C') {
            M[i] = M[i-1];
            C[i] = C[i-1] + M[i-1];
            BC[i] = BC[i-1];
            ABC[i] = ABC[i-1];
        } else if (S[S.size() - i] == 'B') {
            M[i] = M[i-1];
            C[i] = C[i-1];
            BC[i] = BC[i-1] + C[i-1];
            ABC[i] = ABC[i-1];
        } else if (S[S.size() - i] == 'A') {
            M[i] = M[i-1];
            C[i] = C[i-1];
            BC[i] = BC[i-1];
            ABC[i] = ABC[i-1] + BC[i-1];
        } else if (S[S.size() - i] == '?') {
            M[i] = M[i-1] * 3;
            C[i] = C[i-1] * 3 + M[i-1];
            BC[i] = BC[i-1] * 3 + C[i-1];
            ABC[i] = ABC[i-1] * 3 + BC[i-1];
        }
        M[i] = M[i] % MOD;
        C[i] = C[i] % MOD;
        BC[i] = BC[i] % MOD;
        ABC[i] = ABC[i] % MOD;
        //std::cout << ABC[i] << " " << BC[i] << " " << C[i] << std::endl;
    }
    
    std::cout << ABC[S.size()] << std::endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 H, W, K, i, j;
  cin >> H >> W >> K;
  getchar();
  vector<string> S(H);
  vvi ans(H, vi(W, 0));
  vi C(H, 0);
  REP(0, H, i) {
    getline(cin, S[i]);
    REP(0, W, j) {
      if(S[i][j] == '#')
	C[i]++;
    }
  }

  i64 next = 0;
  i64 k = 1;
  REP(0, H, i) {
    if(C[i] != 0) {
      vi a(W, 0);
      i64 c = k;
      i64 kk = k + C[i];
      REP(0, W, j) {
	a[j] = c;
	if(S[i][j] == '#' && k < kk - 1) {
	  ++k;
	  ++c;
	}
      }
      ++k;

      while(next <= i) {
	ans[next] = a;
	++next;
      }
    }
    else if(k > K) {
      ans[i] = ans[i-1];
    }
  }

  REP(0, H, i) {
    REP(0, W, j) {
      if(j != 0)
	cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mn = min(a) + min(b)
for _ in range(m):
  xi,yi,ci = map(int,input().split())
  d = a[xi-1] + b[yi-1] - ci 
  if d < mn:
    mn = d
print(mn)

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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<int> L(N);
  REP(i, N) cin >> L[i];

  sort(L.begin(), L.end());

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (!(L[i] + L[j] > L[k])) break;
        if (!(L[i] + L[k] > L[j])) continue;
        if (!(L[j] + L[k] > L[i])) continue;
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX_N = 101010;
int f[MAX_N];

int Bin(int x, int l, int r){
    if(x<=f[r]){
        return r+1;
    }
    if(f[l]<x){
        return l;
    }
    int mid = (l+r+1)/2;
    if(l+1==r){
        return r;
    }
    if(f[mid]<x){
        return Bin(x,l,mid);
    }else{
        return Bin(x,mid,r);
    }
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }

    int ans = 0;

    rep(i,n){
        f[i] = -1;
    }

    rep(i,n){
        //cout << i << ans << endl;
        if(ans==0){
            f[ans] = a[i];
            ans++;
        }else{
            int j = Bin(a[i],0,ans-1);
            if(j==ans){
                f[ans] = a[i];
                ans++;
            }else{
                f[j] = a[i];
            }
        }
    }

    

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =1 ;i<n;i++)
typedef long long int lli;
lli lcm(lli x,lli y);

int main (){
	lli a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<(b-a+1-b/c-b/d+b/lcm(c,d)+(a-1)/c+(a-1)/d-(a-1)/lcm(c,d))<<"\n";
	return 0;
}

lli lcm(lli x,lli y){
	return x*y/__gcd(x,y);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    REP(i, n) cin >> t[i] >> a[i];

    FOR(i, 1, n){
        int p=t[i-1]/t[i];
        int q=a[i-1]/a[i];
        if(t[i-1]%t[i]) p++;
        if(a[i-1]%a[i]) q++;
        int cnt=max(p, q);

        t[i]*=cnt;
        a[i]*=cnt;
    }
    
    cout << t[n-1]+a[n-1] << endl;
}

Measured memory_bytes: 256
import copy

def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2)

n,m = map(int,input().split())
ans = []
tmp = [0]
dfs(0,tmp)
#print(ans)
s = []
k = []
for i in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int,input().split()))
#print(k)
#print(s)
#print(p)
cnt = 0
for i in range(len(ans)):
    cnt_i = 0
    for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
    if cnt_i==m:
        cnt += 1
print(cnt)

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

using namespace std;

typedef long long ll;

const int maxn=2e5+10;


int main()
{
	string s1;
	string s2;
	cin>>s1>>s2;
	int n=s1.size(),m=s2.size();
	int res=m;
	for( int i=0;i+m<=n;i++ )
	{
		int ans=0;
		for( int j=i;j<i+m;j++ )
		{
			if( s1[j]==s2[j-i] )
			{
				ans++;
			}
			
		}res=min(res,m-ans);
	}
	cout<<res;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,1,N)if(P[i]==P[i-1])sum++;
  if(sum%2==1)Out(N-sum-1);
  else Out(N-sum);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int N,M;
    cin>>N;
    int T[N];
    for(int i=1;i<=N;i++)
        cin>>T[i];
    cin>>M;
    int b=M,j=1;
    int a[M];
    while(M--)
    {
        int sum=0;
        int p,x;
        cin>>p>>x;
        int e;
        e=T[p];
        T[p]=x;
        for(int i=1;i<=N;i++)
            sum+=T[i];
        a[j]=sum;
        j++;
        T[p]=e;
    }
    for(int j=1;j<=b;j++)
        cout<<a[j]<<endl;
    return 0;
}

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

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double aw, bw, w; //H時間M分の角度

    aw = h * 30 + m/60 * 30;
    bw = 6 * m;
    w = min(abs(aw - bw ), 360 - abs(aw - bw ));
    double d;
    d = sqrt(a*a + b*b - 2*a*b* cos(w/180 * M_PI));
    cout << fixed << setprecision(15) << d << endl;
}

Measured memory_bytes: 4212
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);

		sa = br.readLine().split(" ");
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = Integer.parseInt(sa[i]) - 1;
		}
		br.close();

		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[p[i]] = i;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(20000 * (i + 1) + d[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());

		sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(400000000 - 20000 * i).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


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

using namespace std;
typedef long long ll;

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

	int n; cin >> n;

	vector<int> h(n, 0);
	for(int i = 0; i < n; i++) cin >> h[i];

	ll l1 = 0, l2 = 0;
	for(int i = 1; i < n; i++) {
		ll t = l1;
		l1 = l1 + abs(h[i] - h[i - 1]);
		if(i > 1) l1 = min(l1, l2 + abs(h[i] - h[i - 2]));
		l2 = t;
	}
	cout << l1 << endl;
}

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

int main (int argc, char *argv[])
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    
    transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
    transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
    transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
    
    string answer;
    answer += s1[0];
    answer += s2[0];
    answer += s3[0];
    
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define INF 1e+9
int dp[N+1];

int main(){
  int n;
  cin >> n;
  for(int i=0;i<N+1;i++)
    dp[i] = INF;
  dp[0] = 0;
  for(int i=0;i<=n;i++){
    dp[i+1] = min(dp[i] + 1, dp[i+1]);
    int p = 6;
    while(i+p<=n){
      dp[i+p] = min(dp[i] + 1, dp[i+p]);
      p *= 6;
    }
    p = 9;
    while(i+p<=n){
      dp[i+p] = min(dp[i] + 1, dp[i+p]);
      p *= 9;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int L,b[50],bt,n,x[90],y[90],z[90],m,now;//!!! x[50] y[50] z[50]
int main(){
    scanf("%d",&L);
    while (L){
        b[++bt]=L&1;
        L>>=1;
    }
    n=1;now=1;
    fd(i,bt-1,1){
        now<<=1;
        fo(j,1,m) z[j]<<=1;
        x[++m]=++n;y[m]=n-1;z[m]=0;
        x[++m]=n;y[m]=n-1;z[m]=1;
        if (b[i]){
            x[++m]=n;y[m]=1;z[m]=now;
            now^=1;
        }
    }
    printf("%d %d\n",n,m);
    fo(i,1,m) printf("%d %d %d\n",n-x[i]+1,n-y[i]+1,z[i]);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();

        String s = sc.next();
        if (s.charAt(0) >= 'A' && s.charAt(0) <= 'Z') System.out.println("A");
        else System.out.println("a");

    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        
        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine()  {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

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

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

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

    }
}

Measured memory_bytes: 32572
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;i++)cin>>v[i].second>>v[i].first;
    sort(v.begin(),v.end());
    int ans=0,pre=-1;
    for(int i=0;i<m;i++){
        if(pre<v[i].second){
            ans++;
            pre=v[i].first-1;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long  
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

int a[10000];
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int sum = 0;
	cin >> n;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	int maxv = 0;
	sort(a,a+n,greater<int>());
	int x = n;
	int v;
	int s = 0;
	if(sum % 10 != 0){
		cout << sum << '\n';
		return 0;
	}
	rep(j,x){
		if(sum < 0){
			break;
		}
		for(int i = s;i < n;++i){
			if((sum - a[i]) % 10 != 0){
				maxv = max(maxv,sum - a[i]);
			}
			v = i;
		}
		++s;
		sum -= a[v];
	}
	cout << maxv << '\n';	
	return 0;
}


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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


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

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};

P pLL(CR<L> l, CR<L> m) {
	ld a = cross(l[1] - l[0], m[1] - m[0]);
	ld b = cross(l[1] - l[0], l[1] - m[0]);
	assert(sgn(a)); // parallel or same line
	return m[0] + b / a * (m[1] - m[0]);
}


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

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;
	while (n--) {
		ld x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
		P p = pLL(L{ p0, p1 }, L{ p2, p3 });
		cout << p.real() << " " << p.imag() << endl;
	}

	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int b=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1)b++;
  }
  if(b%2==0)cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	long h,w;
	char town[100][100];
	long cloud[100][100];
	memset(cloud,-1,sizeof(cloud));
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int u=0;u<w;u++){
			cin>>town[i][u];
		}
	}
	for(int i=0;i<h;i++){
		for(int u=0;u<w;u++){
			if(u==0&&town[i][u]=='.'){
				cloud[i][u]=-1;
			}
			else if(town[i][u]=='.'&&cloud[i][u-1]!=-1){
				cloud[i][u]=cloud[i][u-1]+1;
			}
			if(town[i][u]=='c'){
				cloud[i][u]=0;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int u=0;u<w;u++){
			if(u!=w-1){
				cout<<cloud[i][u]<<' ';
			}
			else{
				cout<<cloud[i][u];
			}
		}
		cout<<endl;
	}
}

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

const int INF = 1e9 + 5;

int main(){
    int a;

    scanf("%d", &a);

    
    set<string> s;

    while(a--){
        string b;
        cin >> b;
        s.insert(b);
    }

    int res = s.size();
   

    printf("%d", res);


    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d.at(i);

	sort(d.begin(), d.end());

	int diff = d.at(n/2) - d.at(n/2-1);
	cout << diff << endl;

	return 0;
}

Measured memory_bytes: 640
from itertools import accumulate
MOD = 10 ** 9 + 7
N = int(input())
As = list(map(int, input().split()))

acc = [As[0]]
for i in range(1, N):
    tmp = acc[-1] + As[i]
    acc.append(tmp % MOD)

ans = 0
for i in range(N-1):
    tmp = As[i] * (acc[N-1] - acc[i])
    tmp %= MOD
    ans += tmp
    ans %= MOD
print(ans)


Measured memory_bytes: 31184
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

const int INF = 1001001001;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> c(n);
  rep(i, n){
    int cc;
    cin >> cc;
    c.at(i) = cc;
    rep(j, m){
      int aa;
      cin >> aa;
      a.at(i).at(j) = aa;
    }
  }

  int ans = INF;
  rep(bit, 1 << n){
    int add = 0;
    vector<int> sk(m, 0);
    rep(j, n){
      if((bit & (1 << j)) != 0){
        add += c.at(j);
        rep(k, m){
          sk.at(k) += a.at(j).at(k);
        }
      }
    }
    bool f = true;
    rep(i, m){
      if(sk.at(i) < x) f = false;
    }
    if(f == true){
      ans = min(add, ans);
    }
    // cerr << ans << endl;
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n-1) ans += i+1;
  cout << ans << endl;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(ll hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x) memset(x,0,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


int main()
{
	fastio;
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b)
		cout<<min(a,k);
	else
		cout<<2*a+b-k;
	return 0;
}


Measured memory_bytes: 3640
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3);
}


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

using namespace std;

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans;
  for (int i = 0; i < n; i++) (ans += s[i]) += t[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

void input_vector(long long &x){
    cin >> x;
}

void show(int x){
    cout << x << " ";
}

int main(){
    long int N;
    cin >> N;
    vector <long long> vehicle(5);
    for_each(vehicle.begin(), vehicle.end(), input_vector);
    //for_each(vehicle.begin(), vehicle.end(), show);
    long long minimum = *min_element(vehicle.begin(), vehicle.end());
    long long ans = ((N + minimum - 1) / minimum) + 4;
    cout << ans << endl;

    
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = inpl()

sss = list(itertools.accumulate(A))
ss = sum(A)
s = 0
for i in range(len(A)-1):
    s = (s + ((ss-sss[i]) * A[i])) % mod

print(s)

Measured memory_bytes: 53540
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
B = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    dmin = 10**9
    ind = -1
    for j in range(M):
        if dist(A[i],B[j])<dmin:
            dmin = dist(A[i],B[j])
            ind = j
    print(ind+1)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define int long long
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define mod 1000000007
typedef pair<ll,ll> pll;
#define F first
#define S second
#define printer(v) for(auto f: v) cout<<f<<" "
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define ipair pair<int,int>
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    // cout << setprecision(12) << fixed;

    int n,m; cin>>n>>m;
    vector<int> v(n, 0);
    vector<int> h(n, 0);
    for (int i = 0; i < n; ++i)
    	cin>>h[i];
    
    while(m--){
    	int a,b; cin>>a>>b;
    	a--; b--;
    	v[a] = max(v[a], h[b]);
    	v[b] = max(v[b], h[a]);
    }
    int ans=0;
    for (int i = 0; i < n; ++i)
    	if(v[i] < h[i]) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	int ans = 0;

	bool can = true;

	rep(i, n) {
		can = true;
		for (int j = 0; j < i; j++) {
			if (h[i] < h[j]) {
				can = false;
			}
		}
		if (can) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int Q;
  cin >> Q;
  bool prime[100001];
  fill(prime,prime+100001,true);
  prime[0] = false;
  prime[1] = false;
  for(int i = 2; i*i <= 100000;i++){
    if(prime[i] == false) continue;
    int cnt = 2;
    while(i*cnt <= 100000){
      prime[i*cnt] = false;
      cnt++;
    }
  }
  int prime2017[100001];
  rep(i,100001){
    if(prime[i] && prime[(i+1)/2]) prime2017[i] = 1;
    else prime2017[i] = 0;
  }
  rep(i,100000){
    prime2017[i+1] += prime2017[i];
  }
  rep(i,Q){
    int l,r;
    cin >> l >> r;
    cout << prime2017[r] - prime2017[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  double k,gyakusuu,ans;
  for(int i=0; i<n; i++){
    cin>>k;
    gyakusuu=gyakusuu+double(1)/k;
  }
  ans=(double)1/gyakusuu;
  cout << fixed << setprecision(5);
  cout<<ans;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }

    var m = 1000L
    var t = 0L

    repeat(n-1) {
        if (a[it] > a[it+1]) {
            if (t > 0L) {
                m += t * a[it]
                t = 0L
            }
        } else if (a[it] < a[it+1]) {
            if (m > a[it]) {
                t += m / a[it]
                m -= t * a[it]
            }
        }
    }
    if (t > 0L) m += t*a[n-1]
    println(m)
}

Measured memory_bytes: 36440
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 100010;
struct Node {
    char s[10];
    int v;
};

Node Queue[MAX];
int len;
int head;
int last;

void init() {
    len = head = last = 0;
}

void push(Node node) {
    strcpy(Queue[last].s, node.s);
    Queue[last].v = node.v;
    len++;
    last = (last + 1) % MAX;
}

Node front() {
    return Queue[head];
}

void pop() {
    len--;
    head = (head + 1) % MAX;
}

int n;
int tm;

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d %d", &n, &tm);
    init();
    for (int i = 0; i < n; i++) {
        char s[10];
        Node node;
        scanf("%s %d", node.s, &node.v);
        push(node);
    }
    int tt = 0;
    while (len > 0) {
        Node node = front();
        pop();
        if (node.v <= tm) {
            tt += node.v;
            node.v = 0;
        } else {
            tt += tm;
            node.v -= tm;
        }
        if (node.v <= 0) {
            printf("%s %d\n", node.s, tt);
        } else {
            push(node);
        }
    }
    return 0;
}

Measured memory_bytes: 4736
///*
#include<iostream>
using namespace std;

int main() {

	for (int left = 1; left <= 9; left++) {
		for (int right = 1; right <= 9; right++) {
			cout << left << "x" << right << "=" << left * right << endl;
		}
	}

	return 0;
}

//*/


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int K;
  cin >> K;
  REP(i, K){
    cout << "ACL";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
from math import cos, sin,pi, sqrt
A,B, H, M = [float(_n) for _n in input().split()]

n = pi * (60*H+M)/360
ax = A * cos(n)
ay = A * sin(n)
bx = B * cos(pi*M/30.)
by = B * sin(pi*M/30.)
print(sqrt((bx-ax)**2.0+(by-ay)**2.0))

Measured memory_bytes: 62456
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
using namespace std;

#define ll long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define int long long
#define INF 1e9
#define pii pair<int, int>
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x, n)               \
    cout << "\n"                   \
         << #x << ": ";            \
    rep(i, n) cout << x[i] << " "; \
    cout << endl
#define debug2d(x, m, n)            \
    cout << "\n"                    \
         << #x << " is: \n";        \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }
#define nl cout << endl

#define MOD 1000000007

int N, K, L;
int ans;

const int V = 100005;
vector<vector<int>> v(2*V);
vector<int>visited(2*V,0);
int cnt[2];

void dfs(int n){
    if(visited[n]) return;
    visited[n] = 1;

    if (n < V) cnt[0]++;
    else cnt[1]++;

    for (auto x: v[n])
    {
        dfs(x);
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //==============================================

    ans=0;
    cin>>N;
    int x,y;
    rep(i,N){
        cin>>x>>y;
        y = y + V;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    rep(i,2*V){
        //if(v[i].size() < 1)continue;
        if(visited[i])continue;
        cnt[0] = 0;
        cnt[1] = 0;

        dfs(i);
        ans += cnt[0] * cnt[1];
    }

    ans -= N;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int long long
#define mod 998244353
#define debug(x) cout << #x << " " << x <<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;

int32_t main(){
    fast
    
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];   
   

}

Measured memory_bytes: 3572
/*
luogu AT3672
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int INF = 0x7f7f7f7f;

int n,a[100005],s,t;
int mxf,sum;
int ee=1,h[500005],nex[500005<<1],to[500005<<1],val[500005<<1];
int dep[500005];

void addedge(int x,int y,int z)
{
	nex[++ee] = h[x];
	to[ee] = y;
	val[ee] = z;
	h[x] = ee;
}

bool bfs()
{ 
	memset(dep,0,sizeof(dep));
	queue<int> q;
	dep[s] = 1;
	q.push(s);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=h[x];i;i=nex[i])
			if(val[i] && dep[to[i]]==0)
			{
				dep[to[i]] = dep[x]+1;
				q.push(to[i]);
			}
	}
	return dep[t]!=0;
}

int dfs(int x,int flow)
{
	if(x==t)
		return flow;
	for(int i=h[x];i;i=nex[i])
		if(val[i] && dep[to[i]]==dep[x]+1)
		{
			int d=dfs(to[i],min(flow,val[i]));
			if(d>0)
			{
				val[i] -= d;
				val[i^1] += d;
				return d;
			}
		}
	return 0;
}

void dinic()
{
	mxf = 0;
	while(bfs())
	{
		int x=1;
		while(x!=0)
		{
			x = dfs(s,INF);
			mxf += x;
		}
	}
}

signed main()
{
	cin>>n;
	s = 0, t = n+1;
	for(int i=1;i<=n;cin>>a[i++]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=0)
		{
			sum += a[i];
			addedge(i,t,a[i]), addedge(t,i,0);
		}
		else
			addedge(s,i,-a[i]), addedge(i,s,0);
		for(int j=i+i;j<=n;j+=i)
			addedge(i,j,INF), addedge(j,i,0);
	}
	dinic();
	cout<<sum-mxf<<endl;
	
	return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
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
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
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(){

  ll n;
  cin>>n;
  vstr t(n);
  vll a(n);
  rep(i,n){
    cin>>t[i]>>a[i];
  }
  string w;
  cin>>w;
  ll ans=0;
  ll cu=0;
  rep(i,n){
    if(cu) ans+=a[i];
    if(t[i]==w){
      cu=1;
    }
  }
  COUT(ans);
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
int main(){ 
    LL a,b;    
    scanf("%lld %lld",&a,&b);
    if(a==b){
        printf("1\n");
        return 0;
    }
    for(int i=60;i>=0;i--){
        if((a&(1ll<<i))!=(b&(1ll<<i))){
            LL tmp=b-(1ll<<i);
            tmp++;
            while(__builtin_popcountll(tmp)!=1)tmp+=tmp&-tmp;
            tmp--;
            LL ans=(tmp+(1ll<<i)-a+1)+((1ll<<i)-a)-max(tmp-a+1,0ll);
            printf("%lld\n",ans);
            return 0;
        }
        else{
            if((a&(1ll<<i))&&(b&(1ll<<i))){
                a-=(1ll<<i);
                b-=(1ll<<i);
            }
        }
    }
}
/**/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main ()
{
    char a[102];
    int b;
    while(scanf("%s", a)!=EOF)
    {
        b=strlen(a);
    printf("%c%d%c\n", a[0], b-2, a[b-1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

string s;
vector<int> v(26);
int n;

int main() {

  getline(cin, s);
  n = s.size();

  for (int i = 0; i < n; i++) {
    v[s[i] - 'a']++;
  }

  for (int i = 0; i < 26; i++) {
    if (v[i] % 2) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
  return 0;
}


Measured memory_bytes: 3616
import statistics

N = int(input())
A = list(map(int, input().split()))

B = []
for i in range(N):
    B.append(A[i] - (i + 1))

b = int(statistics.median(B))

sadness = 0
for i in range(N):
    sadness += abs(A[i] - (b + i + 1))

print(sadness)



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

int main() {
  int n;
  cin >> n;
  double a = floor(n/1.08);
  double b = ceil(n/1.08);
  if (n == (int)floor(a*1.08)) {
    cout << a << endl;
  } else if (n == (int)floor(b*1.08)) {
    cout << b << endl;
  } else {
    cout << ":(" << endl;
  }
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;
string s, t;

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

  cin >> N;
  cin >> s >> t;
  string ans = s;
  REP(i, N) {
    string tmp = s.substr(i, N - i + 1);
    // debug(tmp);
    if (tmp == t.substr(0, N - i)) {
      ans += t.substr(N - i, i + 1);
      cout << ans.size() << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;
  
  return 0;
}




Measured memory_bytes: 256
"use strict";
// import bigInt from 'big-integer'

const Main = input => {
  input = input.trim().split("\n");
  const cardsNum = input[0];
  const cards = input[1].split(" ").sort((a, b) => b - a);

  let alice = 0;
  let bob = 0;
  for (let i = 0; i < cardsNum; i++) {
    if (i % 2 === 0) alice += parseInt(cards[i], 10);
    else bob += parseInt(cards[i], 10);
  }

  console.log(alice - bob);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

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

	vec(P);
	fx(N) {
		vecp(P);
	}
	if (P[0]!=0) {
		ce(-1);
		return 0;
	}
	fx(N-1) {
		if (P[x+1]-P[x]>1) {
			ce(-1);
			return 0;
		}
	}

	ll ans = 0;
	int i = 0;
	while (i < N) {
		int j = i;
		map<int, ll> K;
		while (i+1<N&&P[i+1]>=P[i]) {
			K[P[i]]++;
			i++;
		}
		ans += (K[P[i]]+1)* P[i];
		for (int k = P[i]-1; k >= P[j];k--) {
			ans += max(0LL, (K[k]-1)*k);
		}
		i++;
	}
	ce(ans)
    return 0;
}



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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
#define INF 1e18L+5
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

ll dp[404][404];

ll s(int l, int r, ll a[]) {
    ll ans = 0;
    for (int i = l; i <= r; i++) ans += a[i];
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i; j < n; j++) {
            dp[i][j] = INF;
            if (i == j) dp[i][j] = 0;
            else {
                ll sum = s(i, j, a);
                for (int k = i; k < j; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum);
            }
        }
    }
    cout << dp[0][n - 1] << "\n";
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}


Measured memory_bytes: 1536
#include <stdio.h>

int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2112