akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    int N;
    cin >> N;
    
    vector<int> B(N-1);
    vector<int> A(N);
    
    for (int i=0;i<N-1;i++){
        cin >> B[i];
    }
    
    A[0] = B[0];
    A[N-1] = B[N-2];
    for (int i=1;i<N-1;i++){
        A[i] = min(B[i],B[i-1]);
        
    }

    
    int answer = accumulate(A.begin(), A.end(), 0);
    cout << answer;
    }
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n; 
	cin>>n;
	map<string, int> m;
	for(int i = 0; i < n; i++){
		string s;
		cin>>s;
		m[s]++;
	}
	vector<pair<int, string>> v;
	for(auto p : m){
		v.push_back({p.second, p.first});
	}
	sort(v.rbegin(), v.rend());
	int ma = v[0].first;
	vector<string> p;
	for(int i = 0; i < v.size() && v[i].first == ma; i++){
		p.push_back(v[i].second);
	}
	sort(p.begin(), p.end());
	for(auto s : p)
		cout<<s<<"\n";
}


Measured memory_bytes: 32492
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	char tmp;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[100005] = {};
	ll z[100005] = {};
	string s;

	//IntStack yStack;
	//charStack Stack;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	sort(x, x + n);
	
	for (int i = 0; i < n; i++)
	{
		a = x[i];
		b = 0;
		c = i;
		while (-a+x[c]<3&&c<n)
		{
			b++;
			c++;
		}
		ans = max(ans, b);
		while (a==x[i])
		{
			i++;
		}
		i--;
	}
	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;
	
	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int length[3];
    for(int i = 0; i < 3; i++){
        cin >> length[i];
    }
    sort(length, length + 3);
    cout << length[0] * length[1] / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 1e6+1;

int dp[101][100001];
// dp[i][k] ~ num ways to dist k candies among first i children
int pp[101][100001];
// pp ~ prefix sum of dp along dimension K

int32_t main(){
	fast_io();

	int n, K; cin >> n >> K;
	vi a(n); get(a,n);

	dp[0][0] = 1;
	for (int i = 0; i <= K; ++i) {
		pp[0][i] = 1;
	}

	for (int i = 1; i <= n; ++i) {
		int ai = a[i-1];
		for (int k = 0; k <= K; ++k) {
			pp[i][k] = k>0 ? pp[i][k-1] : 0;
			// dp[i][k] = dp[i-1][k-0] + dp[i-1][k-1] + ... + dp[i-1][k-ai]
			//          = pp[i-1][k] - pp[i-1][k-ai-1]
			dp[i][k] =  pp[i-1][k] - ((k-ai-1>=0) ? pp[i-1][k-ai-1] : 0);
			pp[i][k] += pp[i-1][k] - ((k-ai-1>=0) ? pp[i-1][k-ai-1] : 0);
			dp[i][k] += mod; dp[i][k] %= mod; pp[i][k] += mod; pp[i][k] %= mod;
			// for (int c = 0; c <= min(k,ai); ++c) {
			// 	dp[i][k] += dp[i-1][k-c];
			// 	pp[i][k] += dp[i-1][k-c];
			// }
		}
		debug(i, arr(dp[i], K+1));
		debug(i, arr(pp[i], K+1));
	}


	print(dp[n][K]);
	
	return 0;
}


Measured memory_bytes: 158080
import java.util.*;
public class Main {

	static int N, M, Q;
	static List<Integer> A = new ArrayList<>();
	static int[] a, b, c, d;
	static int ans = 0;
	
	static void dfs(List<Integer> A) {
		if(A.size() == N) {
			int temp = 0;
			for(int i = 0; i < Q; i++) {
				if(A.get(b[i]-1)-A.get(a[i]-1) == c[i])
					temp += d[i];
			}
			ans = Math.max(ans, temp);
			return;
		}
		int x = A.get(A.size()-1);
		for(int i = x; i <= M; i++){
			A.add(i);
			dfs(A);
			A.remove(A.size()-1);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		Q = sc.nextInt();
		a = new int[Q];
		b = new int[Q];
		c = new int[Q];
		d = new int[Q];
		for(int i = 0; i < Q; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		A.add(1);
		dfs(A);
		System.out.println(ans);
	}

}


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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int a[2][n];
  for(int i=0; i<2; i++){
    for(int j=0; j<n; j++){
      cin >> a[i][j];
      if(j>0) a[i][j] += a[i][j-1];
    }
  }
  int ma= a[0][0] + a[1][n-1];
  for(int i=1; i<n; i++){
    ma = max(ma, a[0][i] + a[1][n-1] - a[1][i-1]);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = Array.new(N){0}
N.times do |i|
a[i] = gets.to_i
end
a.sort
prime = Array.new
jd = true
count=0
prime.unshift(2)
2.upto(10000) do |i|
	jd = true
prime.each do |n|
	if i%n== 0
		jd=false
		break
	end
end
if jd ==true
	prime.unshift(i)
end
end

N.times do |i|
	jd = true
prime.each do |n|
	if(n==a[i])
		count+=1
		prime.unshift(a[i])
		jd = false
		break
	end
end
if jd==false
	next
end

prime.each do |n|
if(a[i] % n==0)
	jd = false
	break
end
end
if jd == true 
	prime.unshift(a[i])
	count+=1
	end
end

puts count

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

vp prime_factorize(int n){
    vp ret;
    for(int p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        ret.PB(MP(p,num));
    }
    if(n!=1) ret.PB(MP(n,1));
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,p; cin >> n >> p;
    vp prime=prime_factorize(p);
    int res=1;
    // for(auto pr:prime){
    //     cout<<pr.F<<':'<<pr.S<<endl;
    // }
    for(auto pr:prime){
        if(pr.S/n>0){
            //res*=(pr.F*floor(pr.S/n));
            res*=pow(pr.F,pr.S/n);
            //cout<<pr.F<<':'<<pr.S/n<<endl;
            //cout<<pr.F*floor(pr.S/n)<<endl;
        }
    }
    //cout<<4*6*19<<endl;
    cout<<res<<endl;
}

Measured memory_bytes: 3996
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define pf push_front
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
using namespace std;

const int maxn=1e3+10;
const int maxe=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

inline int read(){
    int x=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
    if(flag) return x;
    return ~(x-1);
}
inline void write(int x){
    if(x<0) {x=~(x-1); putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

main(){
    fastio;
    int d,t,s;
    d=read(),t=read(),s=read();
    if(s*t>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
h, w = map(int, input().split())
rb = [['#'] * (w + 2)]
a = rb + [list('#' + input() + '#') for _ in range(h)] + rb
p = [(i, j) for i in range(1, h + 1) for j in range(1, w + 1) if a[i][j] == '#']
d = (-1, 0), (1, 0), (0, -1), (0, 1)
r = -1
while p:
    r += 1
    s = []
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if a[di][dj] == '.':
                a[di][dj] = '#'
                s.append((di, dj))
    p = s
print(r)

Measured memory_bytes: 132688
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1;i<n;i++){
    if(i!= n-i)ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int X = N;
  int count = 0;
  while(true){
    if(X<K){
      count+=1;
      break;
    }
    X/=K;
    count+=1;

  }
  cout << count << endl;
}


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

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A - B >= C) {
		printf("%d\n", 0);
	} else {
		printf("%d\n", C - (A - B));
	}
	return 0;
}


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

ll count(ll i,ll j, vector<string>& m)
{
	return 0;     
}



int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	ll n,x;
	vector<ll> l;
	cin >> n>> x;
	rep(i,n){
		ll tmp;
		cin >> tmp;
		l.emplace_back(tmp);
	}	

	vector<ll> d(n+1,0);
	
	ll cnt=1;
	repd(i,1,n+1){
		d[i]=d[i-1]+l[i-1];
		if(d[i] <= x)cnt++;
	}
	cout << cnt << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(LL i=0;i<(LL)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>
#define pll pair<LL,LL>
 
using namespace std;
 
vector<LL> edge[100001];
bool used[100001];
pii pairg={0,0};
bool isPair=true;
bool color[100001];
 
void dfs(LL v,bool col){
    used[v]=true;
    color[v]=col;
    if(col)pairg.first++;
    else pairg.second++;
    for(LL u:edge[v]){
        if(!used[u])dfs(u,!col);
        else if(color[u]==col)isPair=false;
    }
}
 
 
int main(){
 
    LL N,M;cin>>N>>M;
    REP(i,M){
        LL a,b;cin>>a>>b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }
    fill_n(used,N,false);
    dfs(0,true);
 
    LL ans=0;
    if(isPair){
        ans = pairg.first*pairg.second - M;
    }else{
        ans = N*(N-1)/2 -M;
    }
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 7424
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long k = long.Parse(input[1]);
	  Console.WriteLine(DivideMod(k,n,1000000007));
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    for(long i = a; i > a-b; i--)
    {
      answer *= i;
      answer %= p;
    }
    answer *= DivideModFactorial(b, p);
    answer %= p;
    return answer;
  }
  
}



Measured memory_bytes: 18024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif
 
	int n;
	ll d;
	cin>>n>>d;
 
	int ans=0;
 
	while(n--)
	{
		ll x,y;
		cin>>x>>y;
 
		if(x*x + y*y <= d*d) ans++;
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int a[5],c=0,k;

	for(int i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(int i=0;i<5;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(abs(a[i]-a[j])>k)
            {
                c++;
            }
        }
    }
    if(c!=0)
    {
       printf(":(");
    }
    else{
        printf("Yay!");
    }
	return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int h,w;
    cin>>h>>w;
    vector<Vs> s(h,Vs(w));
    REP(i,0,h){
        REP(j,0,w){
            cin>>s[i][j];
            if(s[i][j]=="snuke"){cout<<(char)('A'+j)<<i+1;return 0;}
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N;
int a[100010], b[100010], c[100010];
int dp[100010][3];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) cin >> a[i] >> b[i] >> c[i];
  REP(i, N) {
    chmax(dp[i+1][0], dp[i][1]+a[i]);
    chmax(dp[i+1][0], dp[i][2]+a[i]);
    chmax(dp[i+1][1], dp[i][2]+b[i]);
    chmax(dp[i+1][1], dp[i][0]+b[i]);
    chmax(dp[i+1][2], dp[i][0]+c[i]);
    chmax(dp[i+1][2], dp[i][1]+c[i]);
  }
  int ans = 0;
  REP(i, 3) chmax(ans, dp[N][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		
		int hour = (a / 3600);
		int minute = (a % 3600) / 60;
		int second = a % 60;
		
		System.out.println(hour + ":" + minute + ":" + second);
	}
}

Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mat[25][25];
ll visited[25][25];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    for(ll i=1;i<=h;i++)
    {
        string s;
        cin>>s;
        for(ll j=0;j<s.length();j++)
        {
            if(s[j]=='#')
            {
                mat[i][j+1]=1;
                visited[i][j+1]=1;
            }
        }
    }
    for(ll i=0;i<=h+1;i++)
    {
        visited[i][0]=1;
        visited[i][w+1]=1;
    }
    for(ll i=0;i<=w+1;i++)
    {
        visited[0][i]=1;
        visited[h+1][i]=1;
    }
    ll maxi=0;
    for(ll i=1;i<=h;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(mat[i][j]==0)
            {
                ll tempvis[25][25];
                for(ll x=0;x<=24;x++)
                {
                    for(ll y=0;y<=24;y++)
                    {
                        tempvis[x][y]=visited[x][y];
                    }
                }
                queue<tuple<ll,ll,ll>>q;
                q.push(make_tuple(i,j,0));
                tempvis[i][j]=1;
                while(!q.empty())
                {
                    tuple<ll,ll,ll>temp=q.front();
                    q.pop();
                    maxi=max(maxi,get<2>(temp));
                    ll i1=get<0>(temp);
                    ll j1=get<1>(temp);
                    if(tempvis[i1+1][j1]==0)
                    {
                        tempvis[i1+1][j1]=1;
                        q.push(make_tuple(i1+1,j1,get<2>(temp)+1));
                    }
                    if(tempvis[i1-1][j1]==0)
                    {
                        tempvis[i1-1][j1]=1;
                        q.push(make_tuple(i1-1,j1,get<2>(temp)+1));
                    }
                    if(tempvis[i1][j1+1]==0)
                    {
                        tempvis[i1][j1+1]=1;
                        q.push(make_tuple(i1,j1+1,get<2>(temp)+1));
                    }
                    if(tempvis[i1][j1-1]==0)
                    {
                        tempvis[i1][j1-1]=1;
                        q.push(make_tuple(i1,j1-1,get<2>(temp)+1));
                    }
                }
            }
        }
    }
    cout<<maxi<<endl;
	return 0;
}


Measured memory_bytes: 256
def csort(a, k)
  b = Array.new(a.length)
  c = Array.new(k + 1, 0)
  a.each{|i|c[i] += 1}
  sum = 0
  c.map!{|i|sum += i}
  for i in 1..a.length
    b[c[a[a.length - i]] - 1] = a[a.length - i]
    c[a[a.length - i]] -= 1
  end
  return b
end
gets
puts csort(gets.split(" ").map(&:to_i), 10000).join(" ")

Measured memory_bytes: 317776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <iostream>
using namespace std;
long long a[100];

int main()
{
	int n;
	cin >>n;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i <= 86; i++)
		a[i] = a[i - 1] + a[i - 2];
	cout <<a[n] <<endl;
}

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

using namespace std;

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

ll mod = 1e9 + 7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if(a+b+c<22){
		cout << "win" << endl;
	}else{
		cout << "bust" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char s[1001],t[1001];
int main()
{
	cin>>s>>t;
	int ns=strlen(s),nt=strlen(t);
	int ans=nt;
	for(int i=0;i<ns-nt+1;i++)
	{
		int sum=0;
		for(int j=0;j<nt;j++)
			if(s[i+j]!=t[j])sum++;
		if(sum<ans)ans=sum;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3600
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=501;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int deg[N];
signed main()
{
    int n=read(), m=read();
    for(ri int i=1;i<=m;i++)
    {
        int x,y;
        x=read(), y=read();
        deg[x]++, deg[y]++;
    }
    for(ri int i=1;i<=n;i++) printf("%lld\n",deg[i]);
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;

	int ans = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans += x >= k;
	}
	cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L.at(i);
    int cnt = 0;
    if(N>=3){
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1;j++){
            for(int k=j+1; k<N; k++){
                if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)){
                    vector<int> M;
                    M.push_back(L.at(i));
                    M.push_back(L.at(j));
                    M.push_back(L.at(k));
                    sort(M.begin(), M.end());
                    if(M.at(2) < M.at(0) + M.at(1)) cnt++;
                }
            }
        }
    }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n, m, a[100][100], b[100];
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> a[i][j];
	for (int i = 0; i < m; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i) {
		int sum = 0;
		for (int j = 0; j < m; ++j) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> xs(m);
  vector<int> ds(m - 1);

  rep(i, m) cin >> xs[i];
  if (m <= n) {
    cout << 0 << endl;
  } else {
    sort(xs.begin(), xs.end());
    ll ans = 0;
    rep(i, m - 1) {
      ds[i] = xs[i + 1] - xs[i];
      ans += ds[i];
    }
    sort(ds.begin(), ds.end(), greater<int>());
    int cnt = 0;
    while (cnt < n - 1) {
      ans -= ds[cnt];
      cnt++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4004
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int N,C,K;
  cin>>N>>C>>K;
  VI T(N);
  rep(i,N) cin>>T[i];
  int cnt=1;
  int ans=1;
  sort(all(T));
  int tmp=T[0];
  rep(i,N){
    if(tmp+K<T[i]||cnt>C){
      ans++;
      tmp=T[i];
      cnt=1;
    }
    cnt++;
  }
  cout<<ans<<endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3576
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int A, B, C;
        intReadLine(out A, out B, out C);
        if(A == B && B == C)
        {
            WriteLine("No");
        }
        else if(A != B && B != C && C != A)
        {
            WriteLine("No");
        }
        else
        {
            WriteLine("Yes");
        }
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

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

void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v)
{
    const ll V = 100 * 1000;
    vector<vec> dp(N + 1, vec(V + 1, 1e+18));
    dp[0][0] = 0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <= V; j++)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j + v[i] <= V)
                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= V; i++)
    {
        if (dp[N][i] <= W)
            ans = max(ans, i);
    }
    cout << ans << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    long long W;
    scanf("%lld", &W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &w[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


Measured memory_bytes: 83220
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename Int>
class LazySegmentTree {
private:
    int N;
public:
    vector<Int> base, lazy;
    // sz: size of array size
    LazySegmentTree(int sz) {
        N = 1;
        while (N < sz) N *= 2;
        base.resize(2 * N - 1, 0);
        lazy.resize(2 * N - 1, 0);
    }
    
    // propagate k-th lazy node [l, r)
    // inner state does not change if repeating this >= 1 times
    void propagate(int k, int l, int r) {
        base[k] += lazy[k];
        if(r - l > 1) {
            lazy[2 * k + 1] += lazy[k] / 2;
            lazy[2 * k + 2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
    
    // update
    void add(int a, int b, Int x, int k=0, int l=0, int r=-1) {
        if(r == -1) r = N;
        propagate(k, l, r);
        
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            propagate(k, l, r);
        }
        else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            base[k] = base[2 * k + 1] + base[2 * k + 2];
        }
    }
    
    // query
    ll get_sum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r == -1) r = N;
        propagate(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return base[k];
        Int vl = get_sum(a, b, 2 * k + 1, l, (l + r) / 2);
        Int vr = get_sum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, Q;
    cin >> N >> Q;
    LazySegmentTree<ll> lst(N);
    
    rep(i, Q) {
        int q;
        cin >> q;
        if(q == 0) { // add
            int s, t, x;
            cin >> s >> t >> x;
            s--;
            lst.add(s, t, x);
        }
        else { // getsum
            int s, t;
            cin >> s >> t;
            s--;
            cout << lst.get_sum(s, t) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 6988
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

const int N = 200'009;

int a[N];
vector<pair<long long, long long>> f[2][N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int ro = 0; ro < 2; ++ro) {
    for (int i = 0; i < n; ++i) {
      f[ro][i].clear();
    }
    long long sum = a[0], pref = 0;
    for (int i = 1, j = 0; i < n; ++i) {
      sum += a[i];
      while (pref + a[j] <= sum - pref - a[j]) {
        pref += a[j];
        ++j;
      }
      if (j > 0) {
        f[ro][i].emplace_back(pref, sum - pref);
      }
      if (j < i) {
        f[ro][i].emplace_back(sum - pref - a[j], pref + a[j]);
      }
    }
    reverse(a, a + n);
  }
  long long ans = 1'000'000'000'000'000'000;
  for (int i = 1; i < n - 2; ++i) {
    for (auto &e1 : f[0][i]) {
      for (auto &e2 : f[1][n - (i + 1) - 1]) {
        ans = min(ans, max(e1.second, e2.second) - min(e1.first, e2.first));
      }
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 29184
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int w,h;
string map[40];
int vec[4][2]={{0,1},{0,-1},{-1,0},{1,0}};

struct pos{
	pos(int X,int Y){
		x=X,y=Y;
	}
	int x,y;
};

int move(int x,int y){
	int ans=0;
	map[x][y]='#';
	stack<pos> bfs;
	bfs.push(pos(x,y));
	while(!bfs.empty()){
		pos n=bfs.top();bfs.pop();
		ans++;
		for(int i=0;i<4;i++){
			if((n.x+vec[i][0]>=0)&&(n.y+vec[i][1]>=0)&&(n.x+vec[i][0]<h)&&(n.y+vec[i][1]<w)){
				if(map[n.x+vec[i][0]][n.y+vec[i][1]]=='.'){
					map[n.x+vec[i][0]][n.y+vec[i][1]]='#';
					bfs.push(pos(n.x+vec[i][0],n.y+vec[i][1]));
				}
			}
		}
		
	}
	
	
	return ans;
}

int main(){
	while(cin>>w>>h,w){
		int fx,fy;
		for(int i=0;i<h;i++){
			cin>>map[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='@'){
					fx=i;
					fy=j;
					break;
				}
			}
		}
		int ans=move(fx,fy);
		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 1212
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	cin >> n >> k;
	double ans = 0.0;
	for(int i = 1; i <= n; i++){
		int neednum = 0;
		int tmp = i;
		while(tmp < k){
			neednum++;
			tmp = (tmp << 1);
		}
		ans += 1.0 / ((n + 0.0) * pow(2.0, neednum));
	}
	printf("%.15f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
int a[N],val[N];
vi v[N];
void dfs(int u,int par=-1,int add=0)
{
  val[u]+=add+a[u];
  for(int v1:v[u])
    {
      if(v1==par) continue;
      dfs(v1,u,add+a[u]);
    }
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,q;
  cin>>n>>q;
  rep(i,1,n)
    {
      int x,y;
      cin>>x>>y;
      v[x].pb(y); v[y].pb(x);
    }
  rep(i,1,q+1)
    {
      int a,b;
      cin>>a>>b;
      ::a[a]+=b;
    }
  dfs(1);
  rep(i,1,n+1) cout<<val[i]<<" "; cout<<endl;
  return 0 ;
}


Measured memory_bytes: 27264
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;
typedef long long ll;
int n,x;
int ans[200005],v[200005];
int main(void){
   scanf("%d%d",&n,&x);
   if(x==1||x==n*2-1)printf("No\n");
   else{
       printf("Yes\n");
       if(n==2)printf("1\n2\n3\n");
       else if(x==2){
           ans[n]=2;
           ans[n-1]=3;
           ans[n+1]=1;
           ans[n+2]=4;
           v[1]=1;
           v[2]=1;
           v[3]=1;
           v[4]=1;
           int q=1;
           for(int i=1;i<n*2;i++){
               if(ans[i]==0){
                   while(v[q]==1)q++;
                   ans[i]=q;
                   v[q]=1;
               }
               printf("%d\n",ans[i]);
           }
       }else{
           ans[n]=x;
           ans[n-1]=x-1;
           ans[n+1]=x+1;
           ans[n+2]=x-2;
           v[x]=1;
           v[x-1]=1;
           v[x-2]=1;
           v[x+1]=1;
           int q=1;
           for(int i=1;i<n*2;i++){
               if(ans[i]==0){
                   while(v[q]==1)q++;
                   ans[i]=q;
                   v[q]=1;
               }
               printf("%d\n",ans[i]);
           }
       }
   }
}

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

int main() {
  string S;
  cin >> S;
  bool b = false;
  if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3)) {
    b = true;
  }
  if(b == true) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
  
}


Measured memory_bytes: 256
sa = input()
sb = input()
sc = input()

def func(x) :
    global sa, sb, sc
    if x == "a" :
        if sa :
            k = sa[0]
            sa = sa[1:]
            return func(k)
        else :
            return "A"
    elif x == "b" :
        if sb :
            k = sb[0]
            sb = sb[1:]
            return func(k)
        else :
            return "B"
    else :
        if sc :
            k = sc[0]
            sc = sc[1:]
            return func(k)
        else :
            return "C"

print(func("a"))

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int x, a, b;
	cin >> x >> a >> b;
	if (b <= a)cout << "delicious" << endl;
	else if (b <= a + x)cout << "safe" << endl;
	else cout << "dangerous" << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a[5],k;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  cin>>k;
  if(a[4]-a[0]<=k){cout<<"Yay!";}
  else {cout<<":(";}
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

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

  if(A > B){
    cout << A*2 - 1 << endl;
  }else if(A < B){
    cout << B*2 - 1 << endl;
  }else{
    cout << A + B << endl;
  }
  return 0;
}


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

constexpr int MAX_N = 1e5;

int N;
int A[MAX_N];

int main() {
  cin >> N;

  for (int i{}; i < N; ++i)
    cin >> A[i];

  deque<int> d;
  for (int i{}; i < N; ++i) {
    int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin();
    if (p == 0) {
      d.push_front(A[i]);
    } else {
      d[p-1] = A[i];
    }
  }
  int ans = d.size();

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


Measured memory_bytes: 1024
#include<stdio.h>

int F[50];

int fibonacci(int n){
  if(n==0||n==1){
    return F[n]=1;
  }
  if(F[n]!=-1)return F[n];
  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}

int main(){
  int n,i;
  for(i=0;i<50;i++)F[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

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

ll min(ll a, ll b){
    if(a > b) return b;
    else return a;
} 

int main(){
    ll L, R;
    cin >> L >> R;

    ll ans = 2018;
    for(ll i = L; i <= R-1; i++){
        for(ll j = i+1; j <= R; j++){
            ans = min(ans, (i*j)%2019);
            if(ans == 0){
                cout << 0 << "\n";
                return 0;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[100010][3];

int main(){
	int n;
	cin >> n;
	int abc[n+10][3];
	rep(i,n) rep(j,3) cin >> abc[i][j];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j == k) continue;
				chmax(dp[i+1][j],dp[i][k]+abc[i][j]);
			}
		}
	}
	int ans = 0;
	for(int j = 0; j < 3; j++) ans = max(ans,dp[n][j]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.io.*;
import java.util.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();

        long ans = Math.max(a+b, Math.max(a-b, a * b));

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long x[n],sum[1000]={0};
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=1;i<=100;i++)
	{
		for(int j=0;j<n;j++)
		{
			sum[i]+=((x[j]-i)*(x[j]-i));	
		}
		//cout<<sum[i]<<endl;
	}
	sort(sum+1,sum+101);
	cout<<sum[1];
}

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

#define int long long

int N, M, K;
int f[200010] = {1};
int r[200010];
int m[200010] = {1};
int mod = 998244353;

int pow_mod(int a, int b)
{
    if(b == 0)return 1;
    int ret = pow_mod(a * a % mod, b / 2);;
    if(b % 2 == 1)ret = ret * a % mod;
    return ret;
}

int C(int n, int m)
{
    return f[n] * r[m] % mod * r[n - m] % mod;
}

signed main()
{
    cin >> N >> M >> K;

    for(int i = 1; i < 200010; i++)f[i] = (f[i - 1] * i) % mod;
    for(int i = 0; i < 200010; i++)r[i] = pow_mod(f[i], mod - 2);
    for(int i = 1; i < 200010; i++)m[i] = (m[i - 1] * (M - 1)) % mod;

    int ans = 0;
    for(int i = 0; i <= K; i++)
    {
        ans += C(N - 1, i) * (M * m[N - i - 1] % mod) % mod;
        ans %= mod;
    }

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


Measured memory_bytes: 8332
const inp = require('fs').readFileSync('/dev/stdin', 'utf8'); const l = inp.trim().split('\n'); var n = null; var ind = 0; while (li = l.shift()) { const isN = ind % 2 === 0; const nAr = li.split(' '); if(isN){ n = nAr[0]; } else { var sSc = null; for(var i = 0; i < nAr.length; i++){ for(var j = 0; j < nAr.length; j++){ if (i!==j) { let sDi = Math.abs(nAr[i] - nAr[j]); if(sSc === null){ sSc = sDi; } else { if(sDi < sSc){ sSc = sDi; } } } } } n = null; console.log(sSc); } ind ++; }


Measured memory_bytes: 18180