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

using namespace std;

typedef long long ll;

#define REP(i, a, b) for (i = a; i < b; i++)
#define REP_ITER(it, v) for (it = v.begin(); it != v.end(); it++)

#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(0)

#define TEST(test) \
    int test;      \
    cin >> test;   \
    while (test--)

#define cll(a, b) cin >> a >> b
#define YES cout << "YES\n"
#define NO cout << "NO\n"

#define vi vector<int>
#define vi_iterator vector<int>::iterator

#define si set<int>
#define si_iterator set<int>::iterator

double pi = 2 * acos(0.0);
int i, j;
int main()
{
    FASTIO;
    ll n;
    cin >> n;
    ll arr[n][3];
    REP(i, 0, n)
    {
        REP(j, 0, 3)
        {
            cin >> arr[i][j];
        }
    }
    ll dp[n][3];
    REP(i, 0, 3)
    {
        dp[0][i] = arr[0][i];
        //cout << dp[0][i] << " upore ";
    }
    //cout << endl;
    REP(i, 1, n)
    {
        REP(j, 0, 3)
        {
            dp[i][j] = arr[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(3 + (j - 1)) % 3]);
            //cout << " FOr  i and j = " << i << " " << j << endl;
            //cout << i - 1 << " " << (j + 1) % 3 << " ";
            //cout << i - 1 << " " << (j - 1) % 3 << " ";
        }
        //cout << endl;
    }
    ll ans = INT_MIN;
    REP(i, 0, 3)
    {
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8320
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int gcd(int, int);
int main() {
	int x,y,tmp;
	scanf("%d%d", &x,&y);
	/*
	while (x%y) {
		if (x < y) { tmp = x; x = y; y = tmp; }
		 x %= y;
	}
	*/
	printf("%d\n", gcd(x,y));
	return 0;
}

int gcd(int x, int y) {
	int tmp;
	if (x < y) { tmp = x; x = y; y = tmp; }
	if (x%y==0) return y;
	if (x%y) gcd(x%y,y);
}

Measured memory_bytes: 592
a = []
p = []

def dfs (x,i,depth):

    if i <= 1:
        #print(x)
        if x == 0:
            return 0
        elif x == 1:
            return 1
        elif x == 2:
            return 2
        elif x >= 3:
            return 3
    else:
        #print(a[i],a[i]//2,x)
        if a[i]//2 < x  :
            x = x - a[i]//2 - 1
            #print("right>>>",p[i-1] + 1,x)
            return (p[i-1] + 1) + dfs(x,i-1,depth)
        elif a[i]//2 == x :
            #print("<<<mid>>>",1,x)
            return (1 + dfs(x-1,i-1,depth))
        else:
            #print("left<<<",0,x)
            if x - 1 <= 0:
                return 0
            else:
                return dfs(x-1,i-1,depth)

def ddff (i,depth):
    if i >= depth-1:
        return 'bpppb'
    else:
        return 'b' + ddff(i+1,depth) + 'p' + ddff(i+1,depth) + 'b'
 
n,x = map(int,input().split())

for i in range(n+1):
    p.append(2**(i+1)-1)
    b = 2**(i+1)-2
    a.append(p[i] + b)
#print(a,p)

r = dfs(x-1,n,n)
print(r)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[2 * n] = {}, b[] = {}, c[] = {};
        vll v;
        rep(i, 2 * n){
            cin >> a[i];
        }
        sort(a, a + 2 * n);
        rep(i, 2 * n){
            ans += a[i], i++;
        }
        print(ans);
    }
}


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

int main()
{
	vector<int>v1,v2;
	int n;
	string s;
	cin >> n >> s;
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			v1.push_back(i+1);
		}
		else{
			v2.push_back(i+1);
		}
	}
	int cnt1 = 0,cnt2 = 0;
	for(auto it:v1){
		if(it<n-v1.size()+1)cnt1++;
	}
	for(auto it:v2){
		if(it>v2.size())cnt2++;
	}
	cout << min(cnt1,cnt2)<< "\n";
}


Measured memory_bytes: 4740
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut x: [u32; 12] = [0; 12];

    let r: u32 = read();
    let D: u32 = read();
    x[0] = read();

    for i in 0..10 {
        x[i + 1] = r * x[i] - D;
        println!("{}", x[i + 1]);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

#include<atcoder/segtree>

ll op(ll a, ll b){
    return max(a, b);
}
ll e(){
    return 0;
}
int main() {
    int N, K;
    cin >> N >> K;
    atcoder::segtree<ll, op, e> S(300010);
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; i++){
        int l = max(0, A[i] - K);
        int r = min(300001, A[i]+K+1);
        ll prod = S.prod(l, r);
        S.set(A[i], prod+1);
        chmax(ans, prod+1);
    }
    cout << ans << endl;
}


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

using ll = long long;

int main() {
string s;
  cin >> s;
  int k=s.size();
  vector<char> pattern_a(k);
  vector<char> pattern_b(k);
  for(int i=0;i<k;i++){
  if(i%2 ==0)pattern_a[i]='1';
    else pattern_a[i]='0';
  
  }
    for(int i=0;i<k;i++){
  if(i%2 ==0)pattern_b[i]='0';
    else pattern_b[i]='1';
  
  }
  int cnt_a=0,cnt_b=0;
  for(int i=0;i<k;i++){
  if(s[i] != pattern_a[i])cnt_a++;
      if(s[i] != pattern_b[i])cnt_b++;
  
  }
  cout << min(cnt_a,cnt_b) <<endl;
}



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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>n;
    n.push_back(a);
    n.push_back(b);
    n.push_back(c);
    n.push_back(d);
    bool ok=true;
    if(count(n.begin(),n.end(),1)==0)ok=false;
    if(count(n.begin(),n.end(),9)==0)ok=false;
    if(count(n.begin(),n.end(),7)==0)ok=false;
    if(count(n.begin(),n.end(),4)==0)ok=false;
    cout<<(ok?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll int
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=205;

ll dp[205][205][205];
ll a[205],b[205],c[205];
int main() {
	char c;
	int cnt=0;
	int ans=0;
	for(int i=0;i<3;i++) {
		cin>>c;
		if(c=='R') {
			cnt++;
			ans=max(ans,cnt);
		}
		else cnt=0;
	} 
	cout<<ans<<endl;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  vector<string> s = {"0", "SAT","FRI","THU","WED","TUE","MON","SUN" };
  string d; cin >> d; 
  rep(i, s.size()+1){
    if(d == s[i])
      cout << i << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n+1]={0};
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i)
            a[j]++;
    }
    int sum=0;
    for(int i=1;i<=n;i++)
        sum+=i*a[i];
    cout << sum;
}

Measured memory_bytes: 81744
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

int main(){
    int N;
    cin >> N;
    rep(i,N){
        int k,p;
        cin >> k >> p;
        int x = k%p;
        if(x==0) x = p;
        cout << x << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b;
    char c;
    cin >> a >> c >> b;
    cout << ((c == '+') ? a + b : a - b) << endl;
}

Measured memory_bytes: 256
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <utility>
#include <iostream>

using namespace std;

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

int BFS(vector<string> v)
{
	map<vector<string>, int> d; d[v] = 1;

	queue<pair<vector<string>, int> > que; que.push(make_pair(v, 1));

	for (int i = 0; i < 15; i++)
	{
		if (v[18][i] == 'O')
		{
			return 0;
		}
	}

	while (!que.empty())
	{
		vector<string> v1 = que.front().first;

		int dist = que.front().second; que.pop();

		int sx = -1, sy = -1;

		for (int i = 0; i < 19; i++)
		{
			for (int j = 0; j < 15; j++)
			{
				if (v1[i][j] == 'O')
				{
					sx = j; sy = i;
				}
			}
		}

		for (int dir = 0; dir < 8; dir++)
		{
			if (0 <= sx + dx[dir] && sx + dx[dir] < 15 && 0 <= sy + dy[dir] && sy + dy[dir] < 19)
			{
				if (v1[sy + dy[dir]][sx + dx[dir]] == 'X')
				{
					if (sx == 3 && sy == 8)
					{
						int a = 3;
					}
					int x = sx + dx[dir] * 2;
					int y = sy + dy[dir] * 2;

					while (true)
					{
						if (y > 18) { return dist; }

						if (x < 0 || 15 <= x || y < 0) { break; }

						if (y > 17) { return dist; }

						if (v1[y][x] == '.')
						{
							vector<string> v2 = v1;

							int rx = sx, ry = sy;

							for (; x != rx || y != ry;)
							{
								v2[ry][rx] = '.';

								rx += dx[dir];
								ry += dy[dir];
							}

							v2[y][x] = 'O';

							if (d[v2] == 0)
							{
								d[v2] = dist + 1;

								que.push(make_pair(v2, dist + 1));
							}

							goto Exit;
						}

						x += dx[dir];
						y += dy[dir];
					}
				}
			}

		Exit:;
		}
	}

	return -1;
}

int main()
{
	vector<string> v(19);

	for (int i = 0; i < 19; i++) { cin >> v[i]; }

	bool ok = false;

	for (int i = 17; i < 19; i++)
	{
		for (int j = 0; j < 15; j++)
		{
			if (v[i][j] == 'X')
			{
				ok = true;
			}
		}
	}

	if (ok)
	{
		cout << BFS(v) << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3312
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
#include <queue>

using namespace std;
using namespace std::chrono;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 0; i < k; ++i)
	{
		ans += a[i];
	}
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();
	
	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXCYCLEN=200000;
const int MAXSLEN=200000;
const int MOD=1000000007;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }

int cyclen,slen;
char s[MAXSLEN+1];

int dp[MAXCYCLEN+1];
int dpsum[MAXCYCLEN+1];

int calcunlim() {
	memset(dp,0,sizeof(dp));
	dp[0]=dpsum[0]=1;
	FORE(i,1,cyclen) {
		if(i>=2) inc(dp[i],dpsum[i-2]);
		dpsum[i]=dp[i]; if(i-1>=0) inc(dpsum[i],dpsum[i-1]);
	}
	int ret=1;
	inc(ret,dp[cyclen]);
	for(int j=1;j+1<=cyclen;++j) inc(ret,(ll)j*dp[cyclen-(j+1)]%MOD);
	return ret;
}

int calclim(int lim) {
	//printf("lim=%d\n",lim);
	memset(dp,0,sizeof(dp));
	dp[0]=dpsum[0]=1;
	FORE(i,1,cyclen) {
		if(i%2==0) {
			// dp[i]+=dp[i-2]+dp[i-4]...+dp[i-(lim+1)]
			inc(dp[i],dpsum[i-2]);
			if(i-(lim+1)-2>=0) inc(dp[i],MOD-dpsum[i-(lim+1)-2]);
			//for(int j=1;j<=lim;j+=2) if(j+1<=i) inc(dp[i],dp[i-(j+1)]);
		}
		dpsum[i]=dp[i]; if(i-2>=0) inc(dpsum[i],dpsum[i-2]);
	}
	//printf("dp:"); REPE(i,cyclen) printf(" %d",dp[i]); puts("");
	int ret=dp[cyclen];

	for(int j=1;j<=lim&&j+1<=cyclen;j+=2) inc(ret,(ll)j*dp[cyclen-(j+1)]%MOD);
	//FORE(k,1,lim) FORE(j,k,lim) if(j+1<=cyclen&&j%2==1) inc(ret,dp[cyclen-(j+1)]);
	return ret;
}

int solve() {
	if(s[0]=='B') REP(i,slen) s[i]=s[i]=='B'?'R':'B';
	vector<int> seglen;
	for(int l=0,r=l;l<slen;l=r) {
		while(r<slen&&s[r]==s[l]) ++r;
		if(s[l]=='R'&&r<slen) seglen.PB(r-l);
	}
	//printf("seglen:"); REPSZ(i,seglen) printf(" %d",seglen[i]); puts("");
	if(SZ(seglen)==0) return calcunlim();
	int lim=INT_MAX;
	if(seglen[0]%2==0) lim=min(lim,seglen[0]+1); else lim=min(lim,seglen[0]);
	FORSZ(i,1,seglen) if(seglen[i]%2==1) lim=min(lim,seglen[i]);
	return calclim(lim);
}

void run() {
	scanf("%d%d",&cyclen,&slen);
	scanf("%s",s);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 2300
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n,m=map(int, input().split())
s = []
c = []
if m!=0:
    for i in range(m):
        a, b = map(int, input().split())
        s.append(a)
        c.append(b)

    if n==1:
        if c[0]==0:
            print(0)
            sys.exit()
    def ok(num,m,s,c):
        for i in range(m):
            if str(num)[s[i]-1] != str(c[i]):
                return False
        return True
        
    for num in range(10**(n-1),10**n):
        if ok(num,m,s,c):
            print(num)
            sys.exit()

    print(-1)
else:
    if n==1:
        print(0)
    else:
        print(10**(n-1))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int INF = 0x3f3f3f3f;
const int N = (1 << 16) + 50;
const int M = 20;

ll dp[N], cost[N];
int a[M][M], n;

ll f(int msk){
    if(msk == 0) return 0;
    if(dp[msk] != -1) return dp[msk];
    ll ret = 0;
    for(int x = msk; x ; x = (x - 1) & msk){
        ret = max(ret, f(msk ^ x) + cost[x]);
    }
    return dp[msk] = ret;
}

int main(){
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        for(int j = 0;j<n;j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int msk = 0;msk<(1 << n);msk++){
        for(int i = 0;i<n;i++){
            for(int j = i + 1;j<n;j++){
                if(((1 << i) & msk) && ((1 << j) & msk)) cost[msk] += a[i][j];
            }
        }
    }
    printf("%lld\n", f((1 << n) - 1));
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[][] say = new int[n+1][];
            long ans = 0;

            for (int i = 0; i < n; i++)
            {
                int a= int.Parse(Console.ReadLine());
                say[i + 1] = new int[n+1];
                for (int j = 0; j < a; j++)
                {
                    int[] data = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    int x = data[0];
                    int y = data[1];
                    say[i + 1][x] = y+1;
                }
            }
            
            for(int k = 0; k < (1 << n); k++)
            {
                int[] katei = new int[n + 1];
                bool judge = true;
                for(int l = 1; l <= n; l++)
                {
                    if (((k >> l - 1) & 1) == 1) katei[l] = 2;
                    else katei[l] = 1;
                }
                for(int m = 1; m <= n; m++)
                {
                    if (katei[m]==2)
                    {
                        for(int ii=1;ii<=n;ii++)
                        {
                            if (say[m][ii] != 0&&katei[ii]!=say[m][ii])
                            {
                                judge = false;
                                break;
                            }
                        }
                    }
                    if (!judge) break;
                }
                if (judge)
                {
                    int max = 0;
                    foreach (var chara in katei)
                    {
                        if (chara == 2) max++;
                        ans = Math.Max(ans, max);
                    }
                }
            }

            Console.WriteLine(ans);



            

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


Measured memory_bytes: 15444
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public static void Main()
    {
        string input = Console.ReadLine();
        string output = "";
        int len = input.Length - 1;
        int num = 1;
        long sum = 0;
        if (len == 0)
        {
            Console.WriteLine(input);
        }
        else
        {
            for (int i = 1; i <= len; ++i)
            {
                num = num * 2;
            }
            for(int i = 0; i < num; i++)
            {
                output = input;
                string bit = Convert.ToString(i, 2).PadLeft(len,'0');
                for(int j = bit.Length-1; j >= 0; j--)
                {
                    if(bit[j] == '1')
                    {
                        output = output.Insert(j+1, " ");
                    }
                }
                var arr = output.Split();
                for(int j = 0; j < arr.Length; j++)
                {
                    sum += long.Parse(arr[j]);
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11348
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;


/*
puts("aa");
//*/
int main(void) {
	
	int N;
	sca(N);
	int t[50];
	char s[50][101];
	char X[101];
	rep(i, N) {
		scanf("%s", &s[i]);
		sca(t[i]);
	}
	scanf("%s", X);
	int sum = 0;
	int a;
	rep(i, N) {
		if(strcmp(s[i],X)==0) {
			a = i;
		}
	}
	FOR(i,a+1, N) {
		sum += t[i];
	}
	v_pri(sum);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

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

    ll N; cin >> N;
    vector<P> G[100005];
    

    for (int i = 0;i < N-1;i++){
        ll a,b,c; cin >> a >> b >> c;
        G[a].push_back(P(b,c));
        G[b].push_back(P(a,c));
    }

    ll Q,K; cin >> Q >> K;

    queue<P> que; // node, const

    que.push(P(K,0));
    ll dist[100005]; fill(dist,dist+N+1,LLONG_MAX);
    dist[K] = 0;
    
    while(que.size()){
        P p = que.front(); que.pop();
        ll node = p.first; ll d = p.second;
        for (int i = 0;i < G[node].size();i++){
            ll to = G[node][i].first, cost = G[node][i].second;
            if(dist[to] == LLONG_MAX){
                dist[to] = d+cost;
                que.push(P(to,dist[to]));
            }
        }
    }

    for (int i = 0;i < Q;i++){
        int x,y; cin >> x >> y;
        cout << dist[x]+dist[y] << endl;
    }

    return 0;

}

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector <int>
#define vvi         vector <vi>
#define pii         pair <int,int>
#define vii         vector <pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007

signed main()
{
        int k;
        cin >> k;
        if (k % 2 == 0) {
            cout << -1;
            return 0;
        }
        int p10 = 1, sum = 7, ans = 1;
        for (int i = 1; i <= (int) 1e7; i++) {
            if (sum % k == 0) {
                cout << ans;
                return 0;
            }
            p10 *= 10, p10 %= k;
            sum += (7 * p10), sum %= k;
            ans++;
        }
        cout << -1;
}


Measured memory_bytes: 3628
import sys
INF = float("inf")


def Bellmanford(n, edges, r):  # rは始点
    d = [INF] * n
    d[r] = 0

    for i in range(n):
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n - 1 and v == n - 1:
                    return "inf"
    return -d[n-1]


N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M
for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai - 1, bi - 1, -ci)

ans = Bellmanford(N, Edges, 0)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP0(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define X first
#define Y second
#define pb push_back
#define ALL(arr) arr.begin(), arr.end()
#define MMST(arr, val) memset(arr, val, sizeof(arr))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
const ll INF = 4e18;
const double PI = acos(-1);
ll n;
ll arr[100005];
ll cnt[200005];
bool check(ll k) {
    ll now = 0;
    ll pls = 0;
    ll ans = 0;
    MMST(cnt, 0);
    cnt[100000] = 1;
    REP1(i, n) {
        if (arr[i] <= k) {
            now++;
            pls += cnt[100000+now-1];
            ans += pls;
            cnt[100000+now]++;
        }
        else {
            now--;
            pls -= cnt[100000+now];
            ans += pls;
            cnt[100000+now]++;
        }
//        cout << pls << '\n';
    }
//    cout << k << ' ' << ans << '\n';
    return ans * 2 - 1 >= n * (n+1) / 2;
}
int main() {
    IOS;
    cin >> n;
    REP1(i, n) {
        cin >> arr[i];
    }
    ll bot = 0, top = 1000000005, mid;
    while (top > bot+1) {
        mid = (top + bot) / 2;
        if (check(mid)) {
            top = mid;
        }
        else {
            bot = mid;
        }
    }
    cout << top << '\n';
    return 0;
}
/*
4 5 1
1 2 20
1 4 10
2 3 5
2 4 6
3 4 5
2 7
*/


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,q,i,l,r;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> a;
    vector<int>::iterator lpos,rpos;
    int lidx,ridx;
    for(i=0;i<n-1;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='C'){
            a.push_back(i+1);
        }
    }
    for(i=0;i<q;i++){
        cin >> l >> r;
        lpos=lower_bound(a.begin(),a.end(),l);
        rpos=lower_bound(a.begin(),a.end(),r);
        lidx=distance(a.begin(),lpos);
        ridx=distance(a.begin(),rpos);
        cout << ridx-lidx << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int X = s.nextInt();
			final int[] L = IntStream.generate(s::nextInt).limit(N).toArray();

			boolean fin = false;
			int d = 0;
			for (int i = 0; i < N; i++) {
				d += L[i];
				if (d > X) {
					System.out.println(i + 1);
					fin = true;
					break;
				}
			}
			if (!fin) {
				System.out.println(N + 1);
			}
		}
	}
}


Measured memory_bytes: 28244
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;in(n);
	vector<pi> v(n);
	for(int i=0;i<n;i++) {
		in2(v[i].X, v[i].Y);
	}
	
	for(int i=2;i<n;i++) {
		if(v[i].X == v[i].Y && v[i-1].X == v[i-1].Y && v[i-2].X == v[i-2].Y) finish("Yes");
	}
	finish("No");
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n,l; cin >> n >> l;
    vector< int > t;
    int sum1 =0;

    for(int i = 0; i < n; i++){
        t.push_back(abs(l + (i + 1) - 1));
        sum1 += l + (i + 1) - 1;
    }

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


    if(n + l <= 0) cout << sum1 + t[0] << endl;
    else cout << sum1 - t[0] << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    x = int(input())
    i = 1
    m_prev = 100
    while True:
        m_now = int(m_prev * (1.01))
        if m_now >= x:
            print(i)
            break
        m_prev = m_now
        i+=1


if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<climits>
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
//4611686018427387903
using namespace std;
//magic lines for ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
/*
	fuctions :

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).


*/
const int64_t mod = 998244353.;
void solve(int cnum){
    int mod9 = 0;
    string s;
    cin >> s;
    for(char a : s){
        mod9+=(a-'0');
        mod9%=9;
    }
   if(mod9)
    cout << "No\n";
   else
    cout << "Yes\n";
}
int main(){

	//ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);
	//initprime();
	cout << setprecision(12);
	cout << fixed;
	int t;
	int count = 1;
	for(  t = 1;t--; solve(count),count++);
	return 0;
}


Measured memory_bytes: 3748
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val S = sc.next()
  val steps = (0 until S.length - 2).map(i => Array(S(i), S(i + 1), S(i + 2)))
  println(steps.map(i => math.abs(753 - new String(i).toInt)).min)
}


Measured memory_bytes: 55460
/*
@Author
   Sujeet Kushwaha
*/
 
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(a,b) for(int a=0;a<b;a++)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
#define ordered_set tree<pa, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
// ll powmod(ll a, ll b)
// {
//     ll res = 1;
//     while (b) {
//         if (b&1) {
//             res *= a;
//             res %= mod;
//         }
//         b >>= 1;
//         a = (a * a) % mod;
//     }
 
//     return res;
// }
 
// ll modInv(ll a)
// {
//     return powmod(a, mod - 2);
// }
// int fastread(){
//     int x=0;
//     int c = getchar_unlocked();
//     while(c<48)
//         c = getchar_unlocked();
//     while(c>=48){
//         x = x*10 + (c - 48);
//         c = getchar_unlocked();
//     }
//     return x;
// }
void solve()
{
   ll n;
   cin>>n;
  string s,t;
  cin>>s>>t;
  int i=0;
  int j=0;
  int k=0;
  while(k<n)
  {
    if(i%2==0)
      cout<<s[j++];
    else
    {
        cout<<t[k++];
    }
    i++;
  }
  
}
int main() {
	fast;
	fast_input;
	fast_output;
	
	  solve();
	
	return 0;
}

Measured memory_bytes: 256
def io_tmp():
    global input
    import io
    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.zeros((N, N), dtype=np.int64)
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s-1, t-1] = graph[t-1, s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = dist <= L
#np.fill_diagonal(graph, 0)
#graph[dist > L] = 0
dist = floyd_warshall(graph, directed=False)
dist[np.isinf(dist)] = 0
dist = dist.astype(int)

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(dist[s-1][t-1] - 1)
print(*ans, sep='\n')


Measured memory_bytes: 26008
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define IL inline
#define reg register
#define LL long long
#define N 200010
#define INF 0x3f3f3f3f
using namespace std;

int n,i;
LL t;
LL p[4];
LL Ans;

struct Data{
	LL x,y;
}a[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

IL void Insert(LL x,LL y){
	LL t=0;
	t=-(x+y);	p[0]=Max(p[0],t);
	t=-(x-y);	p[1]=Max(p[1],t);
	t=-(-x+y);	p[2]=Max(p[2],t);
	t=-(-x-y);	p[3]=Max(p[3],t);
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i].x=read(),a[i].y=read();
	p[0]=p[1]=p[2]=p[3]=-INF;
	Insert(a[1].x,a[1].y);
	Ans=-INF;
	for (i=2;i<=n;i++){
		t=(a[i].x+a[i].y);	Ans=Max(Ans,t+p[0]);
		t=(a[i].x-a[i].y);	Ans=Max(Ans,t+p[1]);
		t=(-a[i].x+a[i].y);	Ans=Max(Ans,t+p[2]);
		t=(-a[i].x-a[i].y);	Ans=Max(Ans,t+p[3]);
		Insert(a[i].x,a[i].y);
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 6716
mi = lambda: map(int, input().split())
n, k = mi()
sushis = [list(mi()) for _ in range(n)]
types = set()
sushis.sort(key = lambda x: x[1], reverse = True)
bp = tp = sp = 0
exts = []
for t, d in sushis[:k]:
    bp += d
    if t in types:
        exts += d,
    else:
        types.add(t)
        tp += 1
sp = bp+tp**2
for t, d in sushis[k:]:
    if not exts: break
    if t not in types:
        types.add(t)
        bp += d-exts.pop()
        tp += 1
        sp = max(sp, bp+tp**2)
print(sp)

Measured memory_bytes: 30872
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String n = sc.next();
    String a = n.substring(0, 1);
    String b = n.substring(1, 2);
    String c = n.substring(2, 3);
    String d = n.substring(3, 4);
    
    if (a.equals(b) && b.equals(c)) {
      System.out.println("Yes");
    } else if (b.equals(c) && c.equals(d)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

const int MAXN = 105;
const int MAXM = 55;


int N, M, L;
int P[MAXN], T[MAXN], V[MAXN];
long long C[MAXM][MAXM];
void init() {
    C[0][0] = 1;
    for(int i = 1; i < MAXM; i++) {
        C[i][0] = 1;
        for(int j = 1; j <= i; j++)
            C[i][j] = C[i][j - 1] * (i - j + 1) / j;
    }
}

double ans[MAXN];
void calc(int cur_id) {
    if(V[cur_id] == 0) {
        ans[cur_id] = 0;
        return ;
    }
    double res = 0;
    for(int k = 0; k <= M; k++) {
        double ts = 1.0 * L / V[cur_id] + T[cur_id] * k;
        double pk = pow(1.0 * P[cur_id] / 100, k) * pow(1 - 1.0 * P[cur_id] / 100, M - k) * C[M][k];
        double res1 = 1;
        for(int i = 0; i < N; i++) if(i != cur_id) {
            if(V[i] == 0) continue;
            double ti = 1.0 * L / V[i];
            if(T[i] == 0) {
                res1 *= ts < ti ? 1 : 0;
                continue;
            }
            int k = (int)((ts - ti) / T[i] + 1.00000001);
            if(k < 0) continue;
            //k++;
            double pi = 0;
            for(int j = k; j <= M; j++) {
                pi += pow(1.0 * P[i] / 100, j) * pow(1 - 1.0 * P[i] / 100, M - j) * C[M][j];
            }
            res1 *= pi;
        }
        res += res1 * pk;
    }

    ans[cur_id] = res;
}
int main() {
  //  freopen("in.txt", "r", stdin);
    init();
    while(scanf("%d%d%d", &N, &M, &L) != EOF) {
        for(int i = 0; i < N; i++)
            scanf("%d%d%d", &P[i], &T[i], &V[i]);
        for(int i = 0; i < N; i++) {
            calc(i);
        }
        for(int i = 0; i < N; i++)
            printf("%.10f\n", ans[i]);
    }
    return 0;
}

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

int main(){
  int n, d, x;
  cin >> n >> d >> x;
  int a[100];
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  int sum = 0;
  for(int day = 1; day <= d; ++day){
    for(int num = 1; num <= n; ++num){
     if(day%a[num-1] == 1|| a[num-1] == 1){
       ++sum;
     }
    }
  }
  sum += x;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

        System.out.println(((fiveHapyy*5)+(fiveHumHappy*1000)));
    }
}


Measured memory_bytes: 21716
/*
 *ver3
 *可変長配列を使わない
 */

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	int n = scan.nextInt();
	int[] a = new int[n];

	long sum = 0;
	int count = 0;
	for(int i = 0; i < n; i++){
	    a[i] = scan.nextInt();
	    if(a[i] < 0){
		count++;
		a[i] = Math.abs(a[i]);
	    }
	    sum += a[i];
	}

	Arrays.sort(a);

	if(count % 2 == 0){
	    System.out.println(sum);
	}else{
	    System.out.println(sum - a[0]*2);
	}
    }
}


Measured memory_bytes: 52664
using System;

namespace ABC079
{
    class C
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int A = (char)input[0] - '0';
            int B = (char)input[1] - '0';
            int C = (char)input[2] - '0';
            int D = (char)input[3] - '0';

            if (A + B + C + D == 7) { Console.WriteLine(A.ToString() + "+" + B.ToString() + "+" + C.ToString() + "+" + D.ToString() + "=7"); }
            else if (A + B + C - D == 7) { Console.WriteLine(A.ToString() + "+" + B.ToString() + "+" + C.ToString() + "-" + D.ToString() + "=7"); }
            else if (A + B - C - D == 7) { Console.WriteLine(A.ToString() + "+" + B.ToString() + "-" + C.ToString() + "-" + D.ToString() + "=7"); }
            else if (A + B - C + D == 7) { Console.WriteLine(A.ToString() + "+" + B.ToString() + "-" + C.ToString() + "+" + D.ToString() + "=7"); }
            else if (A - B + C + D == 7) { Console.WriteLine(A.ToString() + "-" + B.ToString() + "+" + C.ToString() + "+" + D.ToString() + "=7"); }
            else if (A - B + C - D == 7) { Console.WriteLine(A.ToString() + "-" + B.ToString() + "+" + C.ToString() + "-" + D.ToString() + "=7"); }
            else if (A - B - C - D == 7) { Console.WriteLine(A.ToString() + "-" + B.ToString() + "-" + C.ToString() + "-" + D.ToString() + "=7"); }
            else if (A - B - C + D == 7) { Console.WriteLine(A.ToString() + "-" + B.ToString() + "-" + C.ToString() + "+" + D.ToString() + "=7"); }
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main(void)
{
	int N[15];
	int a=0,b=0,temp=0;
	int i,x;

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



	for(a=0; a < 10; a++)
	{
		for(b=10-1; b>a; b--)
		{
			if(N[b-1] < N[b])
			{
				temp = N[b];
				N[b] = N[b-1];
        		N[b-1] = temp;
      		}
      	}
    }


    for(x=0;x<3;x++)
    {
    	printf("%d\n", N[x]);
    }
    return 0;
}

Measured memory_bytes: 600
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B = map(int, read().split())

for i in range(1001):
    a = (i * 0.08) // 1
    b = (i * .1) // 1

    if (a == A) & (b == B):
        print(i)
        sys.exit()

print("-1")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
	
	return (0);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
int main() {
	int N;
	cin>>N;
	cout<<N*N*N<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ull N;

int main(){
  cin>>N;
  ll minrate = 1.1e15; int minidx = 0;
  vector<ull> v;
  for(int i=0;i<5;i++){
    ull a; cin>>a; v.push_back(a);
    if(minrate>a){
      minrate = a;
      minidx = i;
    }
  }
  ull ans = (N+minrate-1)/minrate + 4;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    cin>>n;

    ll dp[n][3];
    cin>>dp[0][0]>>dp[0][1]>>dp[0][2];

    loop(i,1,n)
    {
        ll x, y, z;
        cin>>x>>y>>z;
        dp[i][0] = x + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = y + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = z + max(dp[i-1][0], dp[i-1][1]);
    }

    ll ans = max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
    cout<<ans<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(Case,1,t+1)
    {
        cerr<<"Case #"<<Case<<'\n';
        solve(Case);
    }
    return 0;
}

Measured memory_bytes: 2560