akhauriyash/Code-Regression huggingface dataset:
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e3 + 6;

int n, m, Q, pref[N][N], d1[N][N], d2[N][N];
char a[N][N];

int main() {
	ios_base     :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("in", "r", stdin);

    cin >> n >> m >> Q;
    forn(i, 1, n) {
        forn(j, 1, m) {
            cin >> a[i][j];
            pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + (a[i][j] == '1');
            d1[i][j] = d1[i - 1][j] + d1[i][j - 1] - d1[i - 1][j - 1] + (a[i][j] == '1' && a[i - 1][j] == '1');
            d2[i][j] = d2[i - 1][j] + d2[i][j - 1] - d2[i - 1][j - 1] + (a[i][j] == '1' && a[i][j - 1] == '1');
        }
    }

    forn(i, 1, Q) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << (pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1]) - (d1[x2][y2] - d1[x1][y2] - d1[x2][y1 - 1] + d1[x1][y1 - 1]) - (d2[x2][y2] - d2[x1 - 1][y2] - d2[x2][y1] + d2[x1 - 1][y1]) << "\n";
    }

	return 0;
}


Measured memory_bytes: 52864
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
ll x;
vector<ll> A;
void input(){
    fast_io();
    cin >> N >> x;
    A = fetch_vec<ll>(N);
}

int WAsolve(){
    vector<ll> P = A;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j >= i-N; j--)
        {
            P[i] = min(P[i],P[(N+j)%N]+x*(i-j));
        }
    }
    DBG(P)
    ll ans = accumulate(P.begin(),P.end(),0LL);
    cout << ans << endl;
    return 0;
}   

int solve(){
    vector<ll> P = A;
    ll ans = accumulate(P.begin(),P.end(),0LL);
    for (int xtimes = 1; xtimes < N; xtimes++)
    {
        ll tmp = P[0];
        for (int i = 0; i < N-1; i++)
        {
            P[i] = min(P[i],P[i+1]);
        }
        P[N-1] = min(P[N-1],tmp);
        
        ans = min(ans,x*xtimes+accumulate(P.begin(),P.end(),0LL));
    }
    cout << ans << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 2000005;

/* ...o(^-^)o... */

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

    vector<lint> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    rep(i, n-1) a[i+1] += a[i];
    rep(i, m-1) b[i+1] += b[i];

    int ans = 0;
    rep(i, n+1){
        // aからi冊読むとき
        lint x = 0;
        if(i > 0) x = a[i-1];

        x = k - x; // 猶予
        if(x < 0) continue;
        auto itr = upper_bound(all(b), x); // はじめて x より大きくなる要素
        int j = itr - b.begin(); // b からは j 冊読める

        ans = max(ans, i+j);
    }
    out(ans);
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int t=5,x,counter=0,ans=0;
	while(t--){
		cin>>x;
		counter++;
		if(x==0){
			ans=counter;
		}
	}
	cout<<ans;
	return 0;
}

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

#define ll long long



int main() {
	ll n, m;
	ll a, b;
	ll i,j;
	ll count = 0;
	cin >> n >> m;
	vector<ll>h(n+1);
	vector<ll>chk(n + 1); 
	for (i = 1; i <= n; i++) {
		cin >> h[i];
	}
	vector<vector<int>>vc(n+1, vector<int>(1));
	for (i = 1; i <= m; i++) {
		cin >> a >> b;
		if (a < b) {
			vc[a].push_back(b);
		}
		else {
			vc[b].push_back(a);
		}
		if (h[a] > h[b])chk[b]++;
		else chk[a]++;
		if (h[a] == h[b])chk[b]++;
	}
	for (i = 1; i <= n; i++) {
		sort(vc[i].begin(), vc[i].end());
	}
	for (i = 1; i <= n; i++) {
		for (j = 0; j < vc[i].size() - 1; j++) {
			if (vc[i][j] == vc[i][j + 1]) {
				if(h[i] > h[vc[i][j]])chk[vc[i][j]]--;
					else chk[i]--;
				if (h[i] == h[vc[i][j]])chk[vc[i][j]]--;
			}
		}
	}

	for (i = 1; i <= n; i++) {
		if (chk[i] == 0)count++;
	}
	
	
	if (count < 0)count = 0;
	cout << count;
	return 0;
}

Measured memory_bytes: 10768
n = gets.to_i
a = gets.split.map(&:to_i)

sum = 0
min = 10**9
mcnt = 0
zero = false
a.each{|x|
  sum += x.abs
  min = x.abs if min > x.abs
  mcnt += 1 if x<0
  zero = true if x==0
}

if mcnt%2==0 || zero
  p sum
else
  p sum-min*2
end

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    vector<i64> v(5);
    cin >> N;
    rep(i,0,5) cin >> v[i];

    i64 mi=*min_element(begin(v),end(v));
    cout << (N-1)/mi+5 << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

    #define ll long long
    #define pb push_back
    

    int main() {


      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      
      
     ll n;
     cin>>n;
     ll arr[n],i,j;
     for(i=0;i<n;i++)
      cin>>arr[i];

    i=0;j=n-1;
    ll s1=arr[i],s2=arr[j];

    ll c=2;
    while(i<=j&&c<n)
     {
       if(s1<=s2)
       {
        i++;
        s1+=arr[i];
       }
       else{
        j--;
        s2+=arr[j];
       }
       c++;
       

     }

     cout<<abs(s1-s2);
     


     
     
      return 0;
    } 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std; 
int main(){
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      cout<<i<<'x'<<j<<'='<<i*j<<endl;
    }
  }

return 0;
}

Measured memory_bytes: 2924
#include<iostream>
#include<vector>
using namespace std;
int main() {
	string S;
	cin >> S;
	vector<int> a(1000);
	for (int i = 0; i < S.length(); i++) {
		a[S[i] - 'a']++;
	}
	bool check = true;
	for (int i = 0; i < 1000; i++) {
		if (a[i] > 1) {
			check = false;
		}
	}
	if (check) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}

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

int main()
{
	double a, b, c, degc, radc;
	double s, r, l, h;
	double pi = 4 * atan( 1.0 );

	cin >> a >> b >> degc;
	radc = degc * pi / 180.0;
	s = b * a * sin( radc ) / 2.0;
	c = sqrt( a*a + b*b - 2*a*b*cos( radc ) );
	r = c / ( 2.0 * sin( radc ) );
	l = 2.0 * r * pi; /* circumference */

	l = a + b + c;
	h = b * sin( radc );

	cout << fixed << s << endl << l << endl << h << endl;
	return 0;
}

Measured memory_bytes: 3560
/*input
3 4
1 2 3

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;

int32_t main() {
    IOS;
	int n,k;cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++)cin>>arr[i];
	int dp[n+1][k+1];
	//for(int i)
	for(int i=0;i<=k;i++){
		dp[0][i] = 0;
	}
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
		int sum[k+1];
		sum[0] = dp[i-1][0];
		for(int j=1;j<=k;j++){
			
			sum[j] = (sum[j-1]+dp[i-1][j])%mod;
		}
		for(int j=0;j<=k;j++){
			int tr=sum[j];
			int unreachable=j-arr[i]-1;
			if(unreachable>=0){
				tr = (tr-sum[unreachable]+mod)%mod;
			}
			dp[i][j]=tr;
		}
	}
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=k;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n][k]<<endl;
	return 0;
}






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

 
#include <vector>
#include <utility>


#include <algorithm>


int go(int n, int d) {
	int ans = 0;

	for (int bit = 64; bit > 0; bit >>= 1) {
		int least_odd = n;
		int least_even = n;

		if (n % 2 == 1) least_even--;
		else least_odd--;
		
		if (d & bit) ans += bit * least_odd;
		else ans += bit * least_even;
	}

	return ans;
}

void solve() {
	int t;
	for (scanf("%d", &t); t; t--) {
		int n, d;
		scanf("%d %d", &n, &d);
		printf("%d\n", go(n,d));
	}
}


int main() {
    solve();
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#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 MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, m;
typedef bitset<704> maskt;
maskt G[704];

//too lazy to write a 1/64 constant... QWQ
int first1(maskt cur)
{
	rep1(i, n) if(cur[i]) return i;
	return -1;
}
int popcnt(maskt cur)
{
	int tot = 0;
	rep1(i, n) if(cur[i]) tot ++;
	return tot;
}
maskt rev(maskt cur, int l)
{
	maskt ret;
	for(int i = 0; i <= l; i ++)
	if(cur[i]) ret[l - i] = true;
	return ret;
}
maskt ori()
{
	maskt ret;
	rep1(i, n) ret[i] = true;
	return ret;
}

maskt solve(maskt lft, maskt s1, maskt s2)
{
	if(popcnt(lft) == 0) return 1;
	if(((s1 | s2) & lft) != lft) return 0;
	if(s1 == s2) {
		int cv = first1(lft);
		lft[cv] = false;
		s1[cv] = false;
		s2[cv] = false;
		bitset<704> ca = solve(lft, s1 & G[cv], s2);
		return (ca << 1) | rev(ca, popcnt(lft));
	} else {
		int cv = first1(s1 ^ s2);
		lft[cv] = false;
		if(s1[cv]) {
			s1[cv] = false;
			return solve(lft, s1 & G[cv], s2) << 1;
		} else {
			s2[cv] = false;
			return solve(lft, s1, s2 & G[cv]);
		}
	}
}

int egcnt(int k)
{
	return k * (k - 1) / 2;
}

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u][v] = G[v][u] = true;
	}
	maskt ret = solve(ori(), ori(), ori());
	int ans = INF;
	for(int i = 0; i <= n; i ++)
	if(ret[i]) ans = min(ans, egcnt(i) + egcnt(n - i));
	printf("%d\n", ans == INF ? -1 : ans);
	return 0;
}

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

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

    ll num = H, count = 0;
    while(num > 1){
        num = num/2;
        count++;
    }

    ll a = 1, r = 2, n = count + 1;

    cout << ll((1-pow(r, n))/(1-r)) << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, m, i;
  int a[51], b[51], sum[51]={0};

  scanf("%d %d", &n, &m);

  for(i=0;i<m;i++){
    scanf("%d %d", &a[i], &b[i]);
    sum[a[i]]+=1;
    sum[b[i]]+=1;
  }

  for(i=1;i<=n;i++){
    printf("%d\n", sum[i]);
  }

  return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e4 + 3;

int n;
int c[T];
int in[T];
int ans[T];
ll r;

vector<int> g[T];
vii v;

void bfs(int at) {
    queue<int> fila;
    fila.push(at);
    int p = 0;

    while(!fila.empty()) {
        at = fila.front();
        fila.pop();
        ans[at] = c[p++];
        r += (ll)ans[at];
        vii tmp;

        for(int nxt : g[at]) {
            if(ans[nxt]) continue;
            tmp.eb(in[nxt],nxt);
        }

        sort(tmp.begin(), tmp.end());
        for(auto x : tmp) fila.push(x.se);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n-1; i++) {
        int a,b; cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
        in[a]++, in[b]++;
    }

    for(int i = 1; i <= n; i++) v.eb(in[i],i);
    for(int i = 0; i < n; i++) cin >> c[i];
    sort(c,c+n,greater<int>());
    bfs(v[0].se);

    cout << r - c[0] << endl;
    for(int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <iostream>

using namespace std;
typedef long long ll;

void calc(int ds){
    int ans=0,n,m,k,d;
    vector<int> s;
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<n-1;i++){
        scanf("%d",&d);
        s.push_back(d);
    }
    
    s.push_back(0);
    s.push_back(ds);
    
    sort(s.begin(),s.end());
    
    for(int i=0;i<m;i++){
        scanf("%d",&k);
        vector<int>::iterator ita = upper_bound(s.begin(),s.end(),k);
        ans+=min((*ita)-k,k-(*(ita-1)));
    }
    
    printf("%d\n",ans);
    
    return;
}

int main(){
    int d;
    
    while(1){
        scanf("%d",&d);
        
        if(d==0) break;
        
        calc(d);
    }
}

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

int main() {
  int N, M, X;
  scanf("%d%d%d", &N, &M, &X);

  int left = 0;
  int right = 0;
  for (int i = 0; i < M; i++) {
    int A = 0;
    scanf("%d", &A);
    if (A < X) {
      left++;
    } else {
      right++;
    }
  }

  printf("%d", min(left, right));
  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;

  while(1){
    C -= B;
    if( C <= 0 ){
      cout << "Yes" << endl;
      break;
    }

    A -= D;
    if( A <= 0 ){
      cout << "No" << endl;
      break;
    }
  }

}

Measured memory_bytes: 3640
import java.util.*;

public class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int num = sc.nextInt();
      String str = sc.next();
      if(str.length() > num){
        str = str.substring(0, num) + "...";
      }
      System.out.println(str);
    }
}

Measured memory_bytes: 38656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] nums = new int[n];
		int sum = 0;
		int min = 10000;
		for(int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
			sum += nums[i];

			min = min > nums[i] ? nums[i] : min;
		}

		int cnt = 0;
		x -= sum;
		cnt += n;
		cnt += (x / min);

		System.out.print(cnt);
	}
}


Measured memory_bytes: 22996
import sys
import math
from collections import deque

if __name__ == "__main__":
    S = input()
    Q = int(input())
    mode = 0
    d = deque()
    for s in S:
        d.append(s)
    
    for i in range(Q):
        arr = list(input().split())
        if len(arr) == 1:
            mode ^= 1
        else:
            if arr[1] == '1':
                if mode == 0:
                    # print(i)
                    d.appendleft(arr[2])
                else:
                    d.append(arr[2])
            else:
                if mode == 0:
                    d.append(arr[2])
                else:
                    d.appendleft(arr[2])
        # print(mode, d);
    ans = ""
    while len(d):
        if mode == 0:
            ans += d.popleft()
        else:
            ans += d.pop()
    print(ans)







Measured memory_bytes: 6640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	string S;
	cin >> S;
	int count = 10000;
	vector<int> a(S.length());
	for (int i = 0; i < S.length(); i++) {
		a[i] = S[i] - '0';
	}
	for (int i = 0; i < S.length() - 2; i++) {
		count = min(count,abs(753 - (a[i]*100+a[i+1]*10+a[i+2])));
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , 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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll r;
    cin>>r;
    if(r<1200) cout<<"ABC"<<endl;
    else if(r<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<1723<<" "<<42<<endl;
    int n=1723,k=42;
    rep(i,0,k){
        cout<<1<<" ";
        rep(j,i*(k-1)+2,i*(k-1)+2+k-1)cout<<j<<" ";
        cout<<endl;
    }
    rep(i,k+1,n+1){
        int s=(i-2)/(k-1)+1;
        int r=(i-2)%(k-1)+1;
        cout<<s<<" ";
        s-=2;
        rep(j,0,k-1){
            cout<<r+(k-1)*j+k<<" ";
            r+=s;
            r%=(k-1);
            if(r==0)r=k-1;
        }
        cout<<endl;
    }
}




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


int main()
{
	int h, m, s;

	cin >> s;
	h = s / 3600;
	m = (s % 3600) / 60;
	s -= h * 3600 + m * 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<int> G[N];
    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> seen(N, 0);
    vector<int> par(N, -1);
    queue<int> que;
    que.push(0);
    while (!que.empty())
    {
        int v = que.front(); que.pop();
        for (auto next_v : G[v])
        {
            if(seen[next_v]) continue;
            seen[next_v] = 1;
            par[next_v] = v+1;
            que.push(next_v);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) cout << par[i] << endl;
    return 0;
}

Measured memory_bytes: 10652
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int x,n;
int p[101];
bool flag[102];

int main(void){
	scanf("%d%d",&x,&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		flag[p[i]]=true;
	}
	int res=-1000;
	for(int i=0;i<=101;i++){
		if(!flag[i]){
			if(abs(x-i)<abs(x-res)){
				res=i;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll dp[200000]={0};
ll h[200000],h1[200000],b[200000];
ll str[2000000]={0};
void update(int ci, int st, int end, int qp, ll val){
    if(qp<st || qp>end) return ;
    if(st==end){
        str[ci]=val; return ;
    }
    int mid=(st+end)/2;
    update(2*ci+1,st,mid,qp,val);
    update(2*ci+2,mid+1,end,qp,val);
    str[ci]=max(str[2*ci+1],str[2*ci+2]);
}
ll query(int ci, int st, int end, int qs, int qe){
    if(qs>end || qe<st){
        return (ll)0;
    }
    if(qs<=st && qe>=end) return str[ci];
    int mid=(st+end)/2;
    return max(query(2*ci+1,st,mid,qs,qe),query(2*ci+2,mid+1,end,qs,qe));
}
int main() {
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
   //cout << std::fixed;
    //cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    unordered_map<int,int> m;
    for(int i=0;i<n;i++){
        cin>>h[i]; h1[i]=h[i];
    }
    for(int  i=0;i<n;i++){
        cin>>b[i];
    }
    sort(h1,h1+n); 
    for(int i=0;i<n;i++){
        m[h1[i]]=i;
    }
  //  cout<<query(0,0,n-1,2,5)<<"\n";
    for(int i=0;i<n;i++){
       // cout<<m[h[i]]<<" ";
        ll x=query(0,0,n-1,0,m[h[i]]-1);
       // cout<<x<<" ";
        dp[i]=b[i]+x; 
        update(0,0,n-1,m[h[i]],dp[i]);
    }
    ///cout<<"\n";
   //for(auto x : m) cout<<x.first<<" "<<x.second<<"\n";
    ll ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<string> s = new List<string>();

            for(int i = 0; i < N; i++)
            {
                string gacha = Console.ReadLine();
                s.Add(gacha);
            }

            Console.WriteLine(s.Distinct().Count());
        }
    }
}

Measured memory_bytes: 48164
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
constexpr int inf = 1 << 30;

int main() {
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int ans = 0;

    if (2 * C < (A + B)) {
        ans += 2 * C * min(X, Y);
        if (X < Y) {
            ans += min(2 * C, B) * (Y - X);
        }
        else if (X > Y) {
            ans += min(2 * C, A) * (X - Y);
        }
    }
    else {
        ans = A * X + B * Y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
 
point = sum(B)
for i in range(N-1):
  if A[i]==A[i+1]-1:
    point +=C[A[i]-1]
print(point)

Measured memory_bytes: 3064
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/



int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		vll a(n);
		rep(i,n)
		{
			cin>>m>>k;
			a[i]=m+k;
			cs+=k;
		}
		sort(all(a),greater<ll>());
		for(i=0;i<n;i+=2)
		{
			c+=a[i];
		}
		cout<<c-cs;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1024
def read_inputs
  inputs = []
  loop do
    input = gets.split(" ").map(&:to_i)
    case input
      when [0, 0] then break
      else inputs << input
    end
  end
  inputs
end

def countWays(n, x)
  (1..n).map {|a|
    sb = a + 1
    next 0 if sb > n
    [*sb..n].map {|b|
      sc = b + 1
      next 0 if sc > n
      [*sc..n].map {|c|
        next 0 if a == b || b == c || a == c
        next 1 if a + b + c == x
        0
      }.inject(:+)
    }.inject(:+)
  }.inject(:+)
end

inputs = read_inputs
puts inputs.map {|i| countWays(*i)}.join("\n")

Measured memory_bytes: 11776
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int X = input[0];
            int A = input[1];
            int B = input[2];

            if (B<=A)
            {
                Console.WriteLine("delicious");
            }
            else if (B > A && B <= (A + X))
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("dangerous");
            }
        }
    }
}

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

const int N = 100010;

int a[N];
int n, l, t;

int main(){
	scanf("%d%d%d", &n, &l, &t);
	long long cnt = 0;
	for (int i = 0, w; i < n; ++ i){
		scanf("%d%d", &a[i], &w);
		if (w == 1){
			a[i] += t;
			cnt += a[i] / l;
			a[i] %= l;
		}
		else{
			a[i] -= t;
			cnt += a[i] / l;
			a[i] %= l;
			if (a[i] < 0){
				a[i] += l;
				-- cnt;
			}
		}
	}
	std::sort(a, a + n);
	cnt %= n;
	cnt = (cnt + n) % n;
	for (int i = 0; i < n; ++ i){
		printf("%d\n", a[(i + cnt) % n]);
	}
	return 0;
}

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

int main()
{
    ll N, M; cin >> N >> M;
    vector<ll> A(3,-1);
    rep(i,M) {
        ll tmp, tmp2; cin >> tmp >> tmp2;
        if (A[tmp-1] != -1 && A[tmp-1] != tmp2) {
            cout << -1 << endl;
            exit(0);
        }
        else{
            A[tmp-1] = tmp2;
        }
    }
    bool ng = false;
    if (N == 1) {
        if (A[0] == -1) A[0] = 0;
    }
    else if (N == 2) {
        if (A[0] == -1) A[0] = 1;
        else if (A[0] == 0) ng = true;
    }
    else {
        if (A[0] == -1) A[0] = 1;
        else if (A[0] == 0) ng = true;
    }
    if (ng) {
        cout << -1;
    }
    else {
        rep(i,N) {
            if (A[i] == -1) A[i] = 0;
            cout << A[i];
        }
    }
    cout << endl;
        



}


Measured memory_bytes: 3592
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

cnt = 0

for i in 0..n-1
	minj = i
	for j in i..n-1
		if a[j] < a[minj]
			minj = j
		end
	end
	a[i],a[minj] = a[minj],a[i]
	if a[i]!=a[minj]
		cnt+=1
	end
end

puts a.join(" ")
puts cnt

Measured memory_bytes: 8712
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(i,a,b) for (int i = a; i <= (b); ++i) 
#define MOD 10e9 + 7
#define INF 2147483646
#define INFLL 9223372036854775807
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
		　　　  　 ,ﾍ／L──- 、
		　　　   　Lﾆ)r_」=＝= ｲ
		　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
		　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
		　　 .i　　 >〈(つ,i!と)　　i
		　　  vﾍγk´_/___i,ゝﾍノ
		　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
	*/
	string s;
	cin >> s;
	int counta = 0;
	int countb = 0;
	rep0(i, (int)s.size() - 1) {
		if (s[i] == '0') {
			counta++;
		}
		else {
			countb++;
		}
	}
	cout << 2 * min(counta, countb) << endl;
	return 0;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
  }
  vector<bool> dead(n);
  int i = 0;
  int ans = 0;
  while (true) {
    if (i == 1) {
      cout << ans << "\n";
      return 0;
    }
    if (dead[i]) {
      break;
    }
    dead[i] = true;
    i = a[i];
    ans++;
  }
  cout << -1 << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    vector<lint> A(N);
    vector<lint> B(N);
    REP(i, N) cin >> A[i] >> B[i];
    sort(ALL(A));
    lint l = 0;
    if(N%2 != 0) {
        l = A[N/2];
    } else {
        l = A[N/2-1] + A[N/2];
    }
    sort(ALL(B));
    lint r = 0;
    if(N%2 != 0) {
        r = B[N/2];
    } else {
        r = B[N/2-1] + B[N/2];
    }
    cout << (r-l+1) << endl;
}

Measured memory_bytes: 6368
#include<iostream>
#include<sstream>
using namespace std;

int main(){
    int a[4];
    int tmp;
    cin >> tmp;
    a[0] = tmp / 1000;
    tmp -= a[0]*1000;
    a[1] = tmp / 100;
    tmp -= a[1]*100;
    a[2] = tmp / 10;
    a[3] = tmp % 10;

    for(int i=0;i<8;i++){
        string func;
        func.clear();
        int tmp2 = i;
        int ans = a[0];
        stringstream ss;
        ss << a[0];
        func += ss.str();
        if(tmp2>=4){
            ans += a[1];
            func += '+';
            tmp2 -= 4;
        }else{
            ans -= a[1];
            func += '-';
        }
        ss.str("");
        ss << a[1];
        func += ss.str();
        if(tmp2>=2){
            ans += a[2];
            func += '+';
            tmp2 -= 2;
        }else{
            ans -= a[2];
            func += '-';
        }
        ss.str("");
        ss << a[2];
        func += ss.str();
        if(tmp2==1){
            ans += a[3];
            func += '+';
        }else{
            ans -= a[3];
            func += '-';
        }
        ss.str("");
        ss << a[3];
        func += ss.str();
        if(ans==7){
            func += "=7";
            cout << func;
            return 0;
        }
    }
}


Measured memory_bytes: 256
# include "algorithm"
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

char S[maxm];

int main(){
	scanf("%s",S+1);
	sort(S+1,S+4);
	puts((S[1]=='a' && S[2]=='b' && S[3]=='c')?"Yes":"No");
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> v(n, vector<int>(3));
	vector<vector<int>> dp(n, vector<int>(3));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> v[i][j];
	dp[0][0] = v[0][0]; dp[0][1] = v[0][1]; dp[0][2] = v[0][2];
	for (int i = 1; i < n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + v[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + v[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + v[i][2];
	}
	cout << max({ dp[n - 1][0],dp[n - 1][1], dp[n - 1][2] });
}


Measured memory_bytes: 11264
#include<iostream>

using namespace std;

int powerOfTwo(int n){
	int res = 0;
	while(n%2==0){
		n = n/2;
		res++;
	}
	return res;
}

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

	int n;
	cin >> n;
	int a[n];
	int ans = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		ans += powerOfTwo(a[i]);
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3620
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var num1 = Convert.ToInt32(input[0]);
        var num2 = Convert.ToInt32(input[1]);

        var result = num1 % 3 == 0 || num2 % 3 == 0 || (num1 + num2) % 3 == 0 ? "Possible" : "Impossible";
        Console.WriteLine(result);
    }
}


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

const int MAX=1000000;
int N;
vector<int>ip(1000001,1);
int ans=0;




int main(){
	for(int i=2;i<1000;i++){
		if(ip[i]){
			for(int j=0;i*(j+2)<1000000;j++){
				ip[i*(j+2)]=0;
			}
		}
	}
	ip[0]=0;
	ip[1]=0;


	while(cin>>N){

		for(int i=0;i<=N;i++){
			if(ip[i])ans++;
		}
	

		cout<<ans<<endl;
		ans=0;

	}


	
}



Measured memory_bytes: 6596
#include<stdio.h>
int main(void)
{
    int i,takasa[10],itiban,niban,sanban;
    itiban=0;niban=0;sanban=0;
    for(i=0;i<10;i++){
        scanf("%d",&takasa[i]);
        if(itiban<=takasa[i]){
            sanban=niban;
            niban=itiban;
            itiban=takasa[i];
        }
        else if(niban<=takasa[i]){
            sanban=niban;
            niban=takasa[i];
        }
        else if(sanban<=takasa[i]){
            sanban=takasa[i];
        }
    }
    printf("%d\n%d\n%d\n",itiban,niban,sanban);
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>

using namespace std;

int main() {
	string S;
	int w;
	string ans = "";

	cin >> S >> w;
	for (int i = 0; i < S.size(); i++) {
		if (i % w == 0) {
			ans += S[i];
		}
	}

	cout << ans << endl;

	cin >> w;

	return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<ll> solve(int N, const vector<ll>& xs)
{
    map<ll, ll> hs;

    for (auto x : xs)
        ++hs[x];

    ll ways = 0;
    
    for (auto p : hs)
    {
        auto c = p.second;

        ways += c*(c - 1)/2;
    }

    vector<ll> ans(N);

    for (int i = 0; i < N; ++i)
    {
        auto c = hs[xs[i]];

        ans[i] = ways - (c*(c - 1)/2) + (c - 1)*(c - 2)/2;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    for (auto x : ans)
        cout << x << endl;

    return 0;
}


Measured memory_bytes: 14300
#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <stack>
#include <map>
#define maxn 100000 + 5
#define INF 0x3f3f3f3f
#define xin(a) scanf("%d", &a)
#define ffr(i,m, n) for (i = m; i < n; i++)
#define clr(a, b) memset(a, b, sizeof(a));
#define pi acos(-1,0)
typedef double db;
typedef long long ll;
using namespace std;
void t(void)
{
    int t, n;
    xin(t);
    while (t--)
    {

    }
}
void n(void)
{
    int n, i,d,sum=0;
    ll x,y;
    xin(n);
    xin(d);
    ffr(i,0,n)
    {
        scanf("%lld %lld",&x,&y);
        if(sqrt(x*x+y*y)<=d)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
}
int main(void)
{
    #ifndef ONLINE_JUDGE
    long _begin_time = clock();
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    n();
    #ifndef ONLINE_JUDGE
    long _end_time = clock();
    printf("time = %ld ms\n", _end_time - _begin_time);
    fclose(stdin);
    fclose(stdout);
    #endif
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define prique priority_queue
#define inf 1145141919364364
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[114];
ll n,ans=0;
signed main(){
	cin>>n;
	rep(i,n-1)cin>>a[i];
	for(int i=0;i<n-2;i++){
		ans+=min(a[i],a[i+1]);
	}
	cout<<ans+a[0]+a[n-2]<<endl;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}


int32_t main()
{
	c_p_c();

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

	int a[n];

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

	bool twins[k+1];

	twins[0] = 0;

	for (int i = 1; i < k+1; ++i)
	{
		twins[i] = 0;

		for (int j = 0; j < n; ++j)
		{
			if(i-a[j] >= 0 && twins[i-a[j]] == 0)
			{
				twins[i] = 1;
				break;
			}
		}
	}

	if(twins[k])
		cout << "First";
	else
		cout << "Second";
	
	return 0;
}

Measured memory_bytes: 3764
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll solve(long long A, long long B, long long C, long long K) {
  if (K <= A) {
    return K;
  }
  K -= A;
  if (K <= B) {
    return A;
  }
  K -= B;
  return A - K;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long K;
  scanf("%lld", &K);
  cout << solve(A, B, C, K) << endl;
  return 0;
}


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


int main() {
    long double a, b, c;
    cin >> a >> b >> c;
    if (a + b + 2 * sqrt(a*b) < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3784