akhauriyash/Code-Regression huggingface dataset:
import itertools
import math

N = int(input())
xylis = []
for _ in range(N):
    xylis.append(list(map(int, input().split())))

all_total_rl = []
for route in itertools.permutations(xylis,N):
    total_rl = 0
    for i in range(N-1):
        nakami = (route[i][0]-route[i+1][0])**2 + (route[i][1]-route[i+1][1])**2
        route_length = math.sqrt(nakami)
        total_rl += route_length
    all_total_rl.append(total_rl)

ans = sum(all_total_rl) / len(all_total_rl)
print(ans)

Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	ll n;
	cin>>n;

	for(int i=1;i<=9;i++)
	{
		if(n%i==0)
		{
			int x = n/i;
			if(x>=1&&x<=9)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
 
	return 0;	
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readLine.toInt
  val a = in.readLine.split(" ").map(_.toInt)

  var cnt = 1
  var break = 0;
  for(i <- 0 until n) {
    if(a(i) == cnt) {
      cnt += 1
    }
    else {
      break += 1
    }
  }

  val ans = if(cnt == 1) -1 else break
  println(ans)
}

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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

vector<int> G[55];

int to_num(char a){
	if('a' <= a && a <= 'z')
		return a-'a';
	return a-'A'+26;
}

const ll mod = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i, 26)
		s += (char)('a'+i);
	reverse(all(s));
	pair<int, char> nxt[214514]; // nxt[i] := s[i]を使用したときの次の文字とその添字
	PII c[26] = {}; // c[i] := 次のiの位置とそれを使った時の存在しない部分文字列の長さ
	REP(i, 26){
		c[i] = {-1, 0};
	}
	REP(i, s.size()){
		PII a = {0, INF};
		int ch = 0;
		REP(i, 26){
			if(c[i].second < a.second){
				a = c[i];
				ch = i;
			}
		}
		nxt[i] = {a.first, (char)(ch+'a')};
		c[s[i]-'a'] = {i, a.second+1};
	}
	PII r = {0, INF};
	int ch = 0;
	REP(i, 26){
		if(r.second > c[i].second){
			r = c[i];
			ch = i;
		}
	}
	string res = "";
	res += (char)(ch+'a');
	int now = r.first;
	while(nxt[now].first != -1){
		res += nxt[now].second;
		now = nxt[now].first;
	}
	cout << res << endl;
}


Measured memory_bytes: 2324
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d",&a,&b);

	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
ary1 = gets.chomp.split(" ").map(&:to_i)
a = ary1[0]
b = ary1[1]
k = ary1[2]
taka = [a-k,0].max
if k-a >0
  aoki = [b-(k-a),0].max 
else
  aoki = b
end
puts "#{taka} #{aoki}"


Measured memory_bytes: 1788
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

s = arr_data[0][0]

if s=="a" or s=="i" or s=="u" or s=="e" or s=="o":
    
    print("vowel")

else:
    
    
    print("consonant")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int d, n;
  cin >> d >> n;
  if(d==0){
    if(n==100){
      cout << 101 << endl;
    }else{
      cout << n << endl;
    }
  }
  else if(d==1){
    int sum = 100;
    if(n==100){
      cout << 10100 << endl;
    }else{
      cout << n * 100 << endl;
    }
  }
  else if(d==2){
    if(n==100){
      cout << 1010000 << endl;
    }
    else{
      cout << n * 10000 << endl;
    }
  }
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

struct UF {
  vi par, siz;
  UF(int n) : par(n), siz(n, 1) {
    rep(i,0,n) par[i] = i;
  }

  int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  int size(int x) {
    return siz[find(x)];
  }

  void join(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (siz[x] > siz[y]) swap(x, y);
    par[x] = y;
    siz[y] += siz[x];
  }
};

const ll mod = 1e9+7;
ll modpow(ll b, ll e) {
  ll ans = 1;
  while (e) {
    if (e&1) ans *= b;
    ans %= mod;
    b *= b;
    b %= mod;
    e >>= 1;
  }
  return ans;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  vl fac(5123);
  fac[0] = 1;
  rep(i,1,sz(fac)) fac[i] = fac[i-1] * i % mod;

  int n;
  cin >> n;

  vi p(n);
  rep(i,0,n) {
    cin >> p[i];
    if (p[i] > 0) --p[i];
  }

  UF uf(n);
  vi has(n);
  rep(i,0,n) {
    if (p[i] >= 0) uf.join(i,p[i]); 
    else has[i] = 1;
  }

  rep(i,0,n) {
    if (has[i]) has[uf.find(i)] = 1;
  }

  set<int> comps;
  rep(i,0,n) comps.insert(uf.find(i));
  vector<int> reps;
  for (auto x: comps) reps.pb(x);
  ll k = 0, cyc = 0;
  int m = sz(reps);

  rep(i,0,m) {
    if (has[reps[i]]) ++k;
    else ++cyc;
  }

  vvl dp(m+1, vl(m));
  rep(i,0,m) {
    rep(j,i+1,m) {
      if (has[reps[i]] and has[reps[j]]) {
        dp[2][j] += uf.size(reps[i]) * uf.size(reps[j]);
        dp[2][j] %= mod;
      }
    }
  }

  rep(i,1,m) dp[2][i] += dp[2][i-1];

  rep(i,3,m+1) if (i <= k) {
    rep(j,i-1,m) {
      if (has[reps[j]]) dp[i][j] = dp[i-1][j-1] * uf.size(reps[j]) % mod;
      dp[i][j] += dp[i][j-1] % mod;
      dp[i][j] %= mod;
    }
  }

  ll ans = 0;
  rep(i,2,m+1) if (i <= k) {
    ans += (dp[i][m-1] * fac[i-1] % mod) * modpow(n-1, k-i) % mod;
    ans %= mod;
  }

  rep(i,0,m) if (has[reps[i]]) {
    ans += (uf.size(reps[i])-1) * modpow(n-1, k-1) % mod;
  }

  ans += modpow(n-1, k)*cyc%mod;
  ans = -ans;
  ans += n*modpow(n-1, k)%mod;
  ans %= mod; ans += mod; ans %= mod;

  cout << ans << '\n';
}

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

long gongyueshu(long a,long b);
int  main()
{
	long  a,b,c,d;
	 while(scanf("%d %d",&a,&b)!=EOF)
	 

	{
	

	c=gongyueshu(a,b);
	d=a/c*b;
	
	cout<<c<<" "<<d<<endl;

}
	return 0;
	
	
} 
long gongyueshu(long a,long b)   
{
	if(a%b==0)
  return b;
 return gongyueshu(b,a%b);
} 

Measured memory_bytes: 3036
import sys
S = input()

if len(S)%2!=0:
    print("No")
    sys.exit()

for i in range(len(S)):
    if i%2 == 0 and S[i] == "h":
        pass
    elif i%2 == 1 and S[i] == "i":
        pass
    else:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 38448
#-*- coding: utf-8 -*-


def insertion_sort(A):
    print ' '.join(map(str, A))
    for i in xrange(1, N, 1):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print ' '.join(map(str, A))
    return A


if __name__ == "__main__":
    N = input()
    A = map(int, raw_input().split())
    result = insertion_sort(A)

Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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 main(){
    int N,X,Y; cin >> N >> X >> Y;
    X--; Y--;
    vector <int> ans(N);
    
    rep(i,N){
        vector <int> dist(N,INF);
        queue <int> Q;
        Q.push(i);
        dist[i]=0;
        
        while(!Q.empty()){
            int a=Q.front(); Q.pop();
            if (a==X && dist[Y]==INF){
                dist[Y]=dist[a]+1;
                Q.push(Y);
            }
            if (a==Y && dist[X]==INF){
                dist[X]=dist[a]+1;
                Q.push(X);
            }
            
            if (0<=a-1 && dist[a-1]==INF){
                dist[a-1]=dist[a]+1;
                Q.push(a-1);
            }
            
            if (a+1<=N-1 && dist[a+1]==INF){
                dist[a+1]=dist[a]+1;
                Q.push(a+1);
            }
        }
        rep(i,N) ans[dist[i]]++;
    }
    rep(i,N) ans[i]/=2;
    for (int i=1; i<=N-1; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define int long long
using namespace std;

const int INF = 1e18;
int n, m, s;
int cost[55][55], tim[55][55];
int silver[55], lost[55];
vector<int> ed[200005];
int ans[55][5505];
bool done[55][5505];
int lim;

void bfs()
{
    for (int i = 1; i <= n; i++)
       for (int j = 0; j <= 5005; j++)
        ans[i][j] = INF;

    ans[1][s] = 0;

    priority_queue<iii, vector<iii>, greater<iii> > q;
    q.push(iii(0, 1, s));

    while(!q.empty())
    {
        int u = get<1>(q.top());
        int cur = get<2>(q.top());
        q.pop();
        int save = cur;

        if (done[u][cur])
            continue;
        done[u][cur] = 1;

        for (auto v : ed[u])
        {
            int cnt = 0;
            while (cur - cost[u][v] <= lim)
            {
                if (cur - cost[u][v] >= 0 && ans[v][cur - cost[u][v]] > ans[u][save] + cnt * lost[u] + tim[u][v]) {
                    ans[v][cur - cost[u][v]] = ans[u][save] + cnt * lost[u] + tim[u][v];
                    q.push(iii(ans[v][cur - cost[u][v]], v, cur - cost[u][v]));
                }

                cnt++;
                cur += silver[u];
            }
            cur = save;
        }
    }
}

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

//    freopen("depart.inp", "r", stdin);
//    freopen("depart.out", "w", stdout);

    cin >> n >> m >> s;
    for (int i = 1; i <= m; i++)
    {
        int a, b, c, t;
        cin >> a >> b >> c >> t;
        c = min(5000LL, c);
        lim = max(lim, c);
        cost[a][b] = c;
        cost[b][a] = c;
        tim[b][a] = t;
        tim[a][b] = t;
        ed[a].push_back(b);
        ed[b].push_back(a);
    }

    lim *= m;
    s = min(s, lim);
    for (int i = 1; i <= n; i++)
    {
        int a, b;
        cin >> a >> b;
        silver[i] = a;
        lost[i] = b;
    }

    bfs();

    for (int i = 2; i <= n; i++)
    {
        int res = INF;
        for (int j = 0; j <= 5000; j++)
            res = min(res, ans[i][j]);
        cout << res << "\n";
    }

}


Measured memory_bytes: 206880
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int s;
	cin>>s;
	int ym=0;
	if(s/100>0&&s/100<13){
		ym=1;
	}
	if(s%100>0&&s%100<13){
		if(ym==1){
			cout<<"AMBIGUOUS"<<endl;
		}else{
			cout<<"YYMM"<<endl;
		}
	}else{
		if(ym==1){
			cout<<"MMYY"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

int main() {
    char a[10], b[10], c[10];
    scanf("%s %s %s", a, b, c);
    printf("%c%c%c\n", (a[0] - 32), (b[0] - 32), (c[0] - 32));
    return 0;
}


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

int main() {
    string S;
    cin >> S;

    string Sr=S;

    int N=S.size(), countr=0, countl=0;
    if(N==1){
        cout << 0 << endl;
        return 0;
    }

    for(int i=1; i<N; i++){
        if(Sr.at(i)==Sr.at(i-1)){
            if(Sr.at(i)=='0'){
                Sr.at(i)='1';
            }else if(Sr.at(i)=='1'){
                Sr.at(i)='0';
            }
            countr++;
        }
    }
    Sr=S;
    for(int i=N-2; i>-1; i--){
        if(Sr.at(i)==Sr.at(i+1)){
            if(Sr.at(i)=='0'){
                Sr.at(i)='1';
            }else if(Sr.at(i)=='1'){
                Sr.at(i)='0';
            }
            countl++;
        }
    }
    if(countr<countl){
        cout << countr << endl;
    }else{
        cout << countl << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,K;
    cin >> N >> K;
    VI h(N);
    REP(i,N)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int min = MOD;

    REP(i,N-K+1)
    {
        if(h[i+K-1] - h[i] < min) min = h[i+K-1] - h[i];
    }
    cout << min << endl;
}


Measured memory_bytes: 640
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

a,p = m()

print((3*a+p)//2)

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> tab(h);
  rep(i,h) cin >> tab[i];
  vector<vector<bool>> skip(h,vector<bool>(w,0));
  rep(i,h){
    rep(j,w){
      if(tab[i][j] == '#'){
        skip[i][j] = 1;
        continue;
      }
      bool check1 = 0;
      bool check2 = 0;
      rep(m,w) check1 |= tab[i][m] == '#';
      rep(m,h) check2 |= tab[m][j] == '#';
      if(check1 && check2) skip[i][j] = 1;
    }
  } 
  rep(i,h){
    rep(j,w){
      if(!skip[i][j]) continue;
      cout << tab[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    x, a, b = map(int, input().split())

    if -a + b <= x:
        if -a + b <= 0:
            print('delicious')
        else:
            print('safe')
    else:
        print('dangerous')


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#pragma region Template
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

#pragma endregion

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int H, W;
	char C[100][100];
	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> C[i][j];
		}
	}

	for (int i = 0; i < 2 * H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << C[i / 2][j];
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,m;cin>>n>>m;
    vector<ll> x(n), y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];

    ll X = 0; ll Y = 0;

    rep(i,n) {
        ll dec = x[i]*(n-1-i);
        ll inc = x[i]*i;
        X += (inc-dec);
        X%=MOD;
    }

    rep(i,m) {
        ll dec = y[i]*(m-1-i);
        ll inc = y[i]*i;
        Y += (inc-dec);
        Y%=MOD;
    }

    ll ans = X*Y%MOD;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  double x,y,a,b,c,d,e,f;
  while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){
    x=(f-c*e/b)/(d-a*e/b);
    y=(f-c*d/a)/(e-b*d/a);
    if(x==-0.000)
      x=0.000;
    if(y==-0.000)
      y=0.000;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 652
#include<iostream>
using namespace std;
main(){
  int n;
  int p[10000]={0};
  int l;
  int num[10000][3];
  int only[10000][3];
  cin>>n;
  for(int i=0;i<10000;i++){
    for(int j=0;j<3;j++){
      only[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>num[i][j];
      only[num[i][j]][j]++;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      if(only[num[i][j]][j]==1){
	p[i]+=num[i][j];
      }
    }
    cout<<p[i]<<endl;
  }
}

Measured memory_bytes: 1328
package main

import (
	"fmt"
)

func main() {
	//fmt.Println("Hello World")

	var n int
	fmt.Scanf("%d", &n)
	ans := 1000 - (n % 1000)
	if ans == 1000 {
		ans = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LONG_LONG_MIN
#define     INF         LONG_LONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<pair<ll,ll> > vp;
    ll x=n;
    for(ll i=2;i<=sqrt(n);i++){
        if(x%i==0){
            ll cnt=0;
            while(x%i==0){
                x=x/i;
                cnt++;
            }
            vp.pb(mk(i,cnt));
        }
    }
    if(x>1) vp.pb(mk(x,1));
    ll cnt=0;
    for(ll i=0;i<vp.size();i++){
        ll x=vp[i].second;
        //debug;
        ll sum=0,c=0;
        for(ll j=1;sum<=x;j++){
            sum+=j;
            if(sum<=x) c++;
            else break;
        }
        cnt+=c;
    }
    cout<<cnt<<endl;
    return 0;
}



















Measured memory_bytes: 3656
S = input()
n = len(S)

def dfs(i, f):
    # iがindex番号, fが文字列. 再帰関数なのでiがループの代わり
    # fに探索結果を格納していく
    if i == n-1: # Sの最後まで行ったら合計をとる
        l = list(map(int, f.split('+')))
        return sum(l)

    return dfs(i + 1, f + S[i + 1]) + dfs(i + 1, f + '+' + S[i + 1]) # なのもしないパターンと'+'を追加するパターン

print(dfs(0, S[0]))

Measured memory_bytes: 38896
N,Q=gets.split.map &:to_i
edges=Array.new(N+1){Array.new}
(N-1).times do
    i,j=gets.split.map(&:to_i)
    edges[i] << j
    edges[j] << i
end
value=Array.new(N+1,0)
Q.times do
    i,j=gets.split.map(&:to_i)
    value[i]+=j
end

ans=Array.new(N+1,false)
ans[0]=0
check=[[0,1]]

until check.empty?
    parent,node=check.pop
    ans[node]=ans[parent]+value[node]
    edges[node].each do |i|
        next if ans[i]
        check << [node,i]
    end
end
puts ans[1..-1].join(" ")


Measured memory_bytes: 34544
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    vector <vector<ll>> graph(n+1);
    vector <ll> height(n+1);
    for (int z=1;z<=n;z++){
        cin >> height[z];
    }
    for (int z=0;z<m;z++){
        ll u,v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    ll ans = 0;
    for (int z=1;z<=n;z++){
        ll maxi = 0;
        for (ll v :graph[z]){
            maxi = max(maxi,height[v]);
        }
        if (height[z] > maxi) ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 9780
import java.util.Scanner;

public class Main {

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

		String b = scanner.next();

		scanner.close();

		switch (b) {
		case "A":
			System.out.println("T");
			break;
		case "T":
			System.out.println("A");
			break;
		case "C":
			System.out.println("G");
			break;
		case "G":
			System.out.println("C");
			break;
		}

	}
}


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

using namespace std;



#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 int n;
  cin >> n;
  
  bool flag=false;

  for(int i=1;i<=9;i++){
   for(int j=1;j<=9;j++) if(i*j==n) flag=true;
}
 if(flag) cout << "Yes" << endl; 
 else cout << "No" << endl; 
  
  
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		log.Fatal(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	x := getInt()
	tmp := 100
	cnt := 0
	for {
		tmp += tmp / 100
		cnt++
		if tmp >= x {
			out(cnt)
			os.Exit(0)
		}
	}
}


Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;
const int N = 1234567;
int minCost[N];
int cost[N];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
	}
	minCost[0] = 0;
	minCost[1] = abs(cost[1] - cost[0]);
	for(int i=2;i<n;i++)
	{
		minCost[i] = min(minCost[i-1]+abs(cost[i]-cost[i-1]), minCost[i-2]+abs(cost[i]-cost[i-2]));
	}
	cout<<minCost[n-1]<<endl;
}


Measured memory_bytes: 2688
def func(ABCD, n, acc, output):
    if n == 0:
        if int(ABCD) + acc == 7:
            print(ABCD + output + '=7')
            exit()
    else:
        func(ABCD[:-1], n-1, acc + int(ABCD[-1]), '+' + ABCD[-1] + output)
        func(ABCD[:-1], n-1, acc - int(ABCD[-1]), '-' + ABCD[-1] + output)
S = input()
func(S, len(S)-1, 0, '')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Map<Integer, Integer> tmpMap = new HashMap<>();
        for (int i = 1; i <= count; i++) {
            tmpMap.put(sc.nextInt(), i);
        }
        sc.close();
        String order[] = new String[count];
        for (int i = 1; i <= count; i++) {
            order[i - 1] = tmpMap.get(i).toString();
        }

        System.out.println(String.join(" ", order));
    }
}

Measured memory_bytes: 75444
n = int(input())
a = list(map(int,input().split()))
b = list(a[i]-i-1 for i in range(n))
b.sort()

def sadness(x,y):
  s = 0
  for i in range(len(y)):
    s += abs(y[i]-x)
  return s

if n%2 == 0:
  print(sadness(b[int(n/2)],b))
else:
  print(sadness(b[int((n-1)/2)],b))


  
  
  

Measured memory_bytes: 25200
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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



long long power(long long a, unsigned long long b, long long m){
    long long ret(1);
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
        if(ret < 0) ret += m;
        if(a < 0) a += m;
    }
    return ret;
}


int main(){
    int N; std::cin >> N;
    int cnt(0);
    std::map<std::pair<long long, long long>, int> mp;
    {
        long long A, B, g;
        for(int i(0); i < N; ++i){
            std::cin >> A >> B;
            g = std::gcd(A, B);
            if(!g){
                ++cnt; continue;
            }
            if(!A){
                B = 1;
            }else if(!B){
                A = 1;
            }else{
                A /= g; B /= g;
                if(A < 0){
                    A *= -1; B *= -1;
                }
            }
            ++mp[{A, B}];
        }
    }
    std::map<std::pair<long long, long long>, bool> used;
    long long ans(1);
    for(auto itr(std::begin(mp)); itr != std::end(mp); ++itr){
        long long a(itr->first.first), b(itr->first.second);
        if(used[{a, b}]) continue;
        long long c(power(2, itr->second, MOD) - 1);
        long long d(0);
        long long al(b), bt(-a);
        if(al < 0){
            al *= -1; bt *= -1; 
        }
        if(!al){
            bt = 1;
        }
        if(!bt){
            al = 1;
        }
        if(mp.find({al, bt}) != mp.end()){
            used[{al, bt}] = true;
            d = power(2, mp[{al, bt}], MOD) - 1;
        }
        ans = (ans * (c + d + 1)) % MOD;
        if(ans < 0) ans += MOD;
    }
    ans += cnt;
    --ans;
    ans %= MOD;
    if(ans < 0) ans += MOD;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 28604
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, x, s, ans, a[105];
int main() {
	int i;
	cin>>n>>x;
	for(i=0; i<n; i++) cin>>a[i], s += a[i];
	if(s == x) ans = n;
	else if(s < x) ans = n-1;
	else {
		sort(a, a+n);
		for(i=0; i<n; i++) {
			if(x < a[i]) break;
			x -= a[i];
		}
		ans = i;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    H, W = map(int, readline().split())

    res = ["#" * (W + 2)]

    for _ in range(H):
        res += ["#" + input() + "#"]

    res += ["#" * (W + 2)]

    for row in res:
        print(row)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int ans = 1;
   for(int i = 0; i < n; i++){
      ans = min(2*ans, k+ans);
   }
   cout << ans << endl;

   return 0;
}

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

using namespace std;
using ll = long long;
const ll Inf = 1e18;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n + 1), pre(n + 1);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (i == 1) pre[i] = a[i];
        else pre[i] = pre[i - 1] + a[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll> (n + 1));
    for (int diagonal = 1; diagonal <= n - 1; diagonal++){
        for (int i = 1; i <= n - diagonal; i++){
            int j = i + diagonal;
            dp[i][j] = Inf;
            for (int k = j - 1; k >= i; k--){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + - pre[i - 1] + pre[j]);
            }
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 1536
// 3_abc136_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }

    for(int i = n - 1; i > 0; i--){
        if(h[i] < h[i - 1] - 1){
            cout << "No" << endl;
            exit(0);
        }else if(h[i] == h[i - 1] - 1){
            h[i - 1]--;
            continue;
        }else{
            continue;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;
#define MAX1(a,b) (((a)>(b))?(a):(b))
typedef long long ll;
set<int> s;
int main(){
int a[100010]={0};
int n;
cin>>n;
for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(s.count(x))s.erase(x);
    else s.insert(x);
}
cout<<s.size()<<endl;
}


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

struct DSU{
 int N;
 vector<int> V;
 void init(int n){
  N=n; V.resize(N);
  rep(i,N) V[i]=i;
 }
 int root(int a){
  if(a==V[a]) return a;
  return V[a] = root(V[a]);
 }
 void unite(int a,int b){
  V[root(a)] = root(b);
 }
};

int main(){
 int N,Q; scanf("%d%d",&N,&Q);
 DSU G; G.init(N);
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int x,y; scanf("%d%d",&x,&y);
   G.unite(x,y);
  }
  if(c==1){
   int x,y; scanf("%d%d",&x,&y);
   printf((G.root(x)==G.root(y)) ? "1\n" : "0\n");
  }
 }
 return 0;
}

Measured memory_bytes: 4056
#include <iostream>
 
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n, q, t, count = 0;
    int left, right, center;
    int S[100000];
 
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> S[i];
 
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t;
        left = 0;
        right = n;
        while (left <= right)
        {
            center = (left + right) / 2;
            if (S[center] < t) {
                left = center + 1;
            }
            else if (S[center] > t) {
                right = center - 1;
            }
            else {
                count++;
                break;
            }
        }
    }
 
    cout << count << endl;
 
    return 0;
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

void solve(ll index){
	ll n;
	cin >> n;
	ll a[n];
	ll sum = 0;
	forn(i,n) {
		cin >> a[i];
		if(i%2==0) sum += a[i];
		else sum -= a[i];
	}
	cout << sum << " ";
	forn(i,n-1){
		sum = 2*a[i]-sum; 
		cout << sum << " ";
	}
	cout << ln;
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve(i+1);
    return 0;
}

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

using namespace std;

typedef long long ll;

struct knapsack:vector<vector<ll>>
{
    ll max_value;
    
    knapsack(int n, int W) 
    { 
        vector<int> weight(n), value(n); ll v; 
        
        for(int i = 0; i < n; ++i)
            cin >> weight[i] >> value[i];
      
        int W1 = W+1; resize(n+1), front().resize(W1,0);
            
        for (int i = 0, j = 1; i < n; i = j++) 
        {
            at(j) = at(i);
    
	        for (int w = weight[i], w1 = 0; w < W1; ++w, w1++) 
	            if((max_value = at(i).at(w1)+value[i]) > at(j).at(w))
	               at(j).at(w) = max_value; 
        }
     
        max_value = at(n).at(W); 
    }
};

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    int n, W; cin >> n >> W; cout << knapsack(n,W).max_value; 
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>

int main(){
    int N, C;
    cin >> N >> C;
    
    int s[N], t[N], u[N];
    
    priority_queue<P, vector<P>, greater<P>> end_que;
    
    vector<vector<int>> List;
    
    for(int i = 0; i < N; ++i){
        cin >> s[i] >> t[i] >> u[i];
        List.push_back({s[i], u[i], t[i]});
    }
    
    sort(List.begin(), List.end());
    
    int ans = 0;
    
    
    for(int i = 0; i < N; ++i){
//        cout << i << " ";
        end_que.push(make_pair(List[i][2], List[i][1]));
        while(! end_que.empty()){
            P end = end_que.top();
//            cout << List[i][0] << " " << end.first << " " << end.second << endl;
            if(List[i][0] > end.first){
                end_que.pop();
            } else if(List[i][0] == end.first && List[i][1] == end.second){
                end_que.pop();
            } else {
                ans = max(ans, (int)end_que.size());
                break;
            }
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 7604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  long long sum = 0;
  
  for(int i = 1; i <= N; i++){
    if(i % 5 == 0 || i % 3 == 0){
      continue;
    }
    else
      sum += i;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N];
int n;
int dp[N];
int oo = 1e9;
void iterative_dp(){
    dp[n] = dp[n+1] = 0;
    for(int i=n-2; i>=0; i--){
        dp[i] = min(dp[i+1] + abs(a[i]-a[i+1]) , (i+2<n?dp[i+2] + abs(a[i]-a[i+2]):oo));
    }
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    iterative_dp();
    cout<<dp[0]<<'\n';
}


Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,cnt=0;
    cin>>l>>r;
    for(int i=l; i<=r; i++)
    {
        int n=i;
        int x=0;
        while(n!=0)
        {
            x=n%10+x*10;
            n/=10;
        }
        if(i==x)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else{
   cout << "Right" << endl;
  }
}
  

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

int main() {
  int n, m;
  cin >> n >> m;
  ll sum = 0;
  vector<int> a(n);
  vector<P> bc(m);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i,m){
    int b;
    ll c;
    cin >> b >> c;
    bc[i] = make_pair(c, b);
  }
  sort(bc.begin(), bc.end(), greater<P>());
  int first_point = 0;
  rep(i,m){
    if(first_point >= n) break;
    rep(j,bc[i].second){
      if(a[first_point] < bc[i].first){
        a[first_point] = bc[i].first;
        first_point++;
      }else {
        break;
      }
    }
  }
  rep(i,n){
    sum += a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
typedef long long ll;
using namespace std;

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

    ll ans = 0;

    if(N % 2){
        cout << 0 << endl;
        return 0;
    }else{
        ll t = 10;
        while((N / t)){
            ans += (N / t);
            t *= 5;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    string a;
    vector<string>b;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        b.push_back(a);
    }
    sort(b.begin(),b.end());
    b.erase(unique(b.begin(),b.end()),b.end());

    cout<<b.size()<<endl;
}


Measured memory_bytes: 11660
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        ArrayList<Integer>l=new ArrayList();
        ArrayDeque<Integer>r=new ArrayDeque();
        for(int i=0;i<n;++i)
            l.add(s.nextInt());
        
        while(!l.isEmpty()){
            for(int i=l.size();i>=0;--i){
                if(i==0){
                    System.out.println(-1);
                    return;
                }
                if(i==l.get(i-1)){
                    l.remove(i-1);
                    r.addFirst(i);
                    break;
                }
            }
        }
        r.stream().forEach(System.out::println);
    }
}

Measured memory_bytes: 28884
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    String s=sc.next();
  	String t=sc.next();
  	String[] S=s.split("");
  	String[] T=t.split("");
   	int c=0;
    for(int a=0;a<3;a++){
   	if(S[a].equals(T[a])){
    c++;
    }
    }
    
    System.out.println(c);
    }
}



Measured memory_bytes: 21844
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a,b,c,d = map(int, input().split())

if (a*b > c*d):
    print(a*b)
else:
    print(c*d)



Measured memory_bytes: 9140
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int a, b; cin >> a >> b;
	
	if(a <= 0 && 0 <= b) cout << "Zero" << endl;
	else if(b < 0 && (b - a)%2 == 0) cout << "Negative" << endl;
	else cout << "Positive" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include<algorithm>
using namespace std;
 
long long D[2000001];
long long T[2000001];

long long zet(long long inp){
    if(inp>0){
        return inp;
    }else{
        return -inp;
    }
}

int main(){
    string S;
    cin >> S ;
    bool ok[26]={};
    int t;
    for(int i=0;i<26;i++){
        ok[i]=0;
    }
    for(int i=0;i<S.length();i++){
        t=S[i]-'a';
        if(ok[t]==0){
            ok[t]=1;
        }else{
            cout <<"no"<<endl;
            return 0;
        }
    }
    cout <<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    ll s[n],t[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        t[i]=s[i];
    }
    ll ans1=0;
    sort(s,s+n);
    sort(t,t+n);
    reverse(t,t+n);
    ll a1=s[0],a2=s[0];
    int cnt=0;
    for(int i=0;i<(n-1)/2;i++){
        if(cnt%2==0){
            ans1+=abs(a1-s[n-cnt-1]);
            ans1+=abs(a2-s[n-cnt-2]);
            a1=s[n-cnt-1],a2=s[n-cnt-2];
        }
        else{
            ans1+=abs(a1-s[cnt]);
            ans1+=abs(a2-s[cnt+1]);
            a1=s[cnt],a2=s[cnt+1];
        }
        cnt++;
    }
    if(n%2==0){
        if(n%4==0)n-=2;
        ans1+=max(abs(a1-s[n/2]),abs(a2-s[n/2]));
    }
    
    a1=t[0],a2=t[0];
    ll ans2=0;
    cnt=0;
    for(int i=0;i<(n-1)/2;i++){
        if(cnt%2==0){
            ans2+=abs(a1-t[n-cnt-1]);
            ans2+=abs(a2-t[n-cnt-2]);
            a1=t[n-cnt-1],a2=t[n-cnt-2];
        }
        else{
            ans2+=abs(a1-t[cnt]);
            ans2+=abs(a2-t[cnt+1]);
            a1=t[cnt],a2=t[cnt+1];
        }
        cnt++;
    }
    if(n%2==0){
        if(n%4==0)n-=2;
        ans2+=max(abs(a1-t[n/2]),abs(a2-t[n/2]));
    }
    cout<<max(ans1,ans2)<<endl;
    //cout<<ans1<<ans2<<endl;
    
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3F3F3F3F;
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	set<pair<int,int> > se;
	multiset<int> ans;
	for(int i=1; i<=m; ++i) {
		se.insert({i,i});
		ans.insert(0);
	}
	for(int i=1; i<=n; ++i) {
		int x,y;
		cin>>x>>y;
		if(y==m) y=INF;
		auto it=se.lower_bound({x,0});
		int t=-1;
		while(it!=se.end() && it->first<=y) {
			ans.erase(ans.find(it->first-it->second));
			t=max(t,it->second);
			it=se.erase(it);
		}
		if(t>-1) {
			ans.insert(y+1-t);
			se.insert({y+1,t});
		}
		int r=*ans.begin();
		if(r>m) cout<<"-1\n";
		else cout<<r+i<<endl;
	}
	return 0;
}


Measured memory_bytes: 22380