akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll H,W;
    cin >>H>>W;
    ll ans=INF;
    if(H>=3){
        if(H%3==0){
            ans=0;
        }else{
            chmin(ans,W);
        }
    }

    if(W>=3){
        if(W%3==0){
            ans=0;
        }else{
            chmin(ans,H);
        }
    }


    rep2(i,H-1){
        if(W%2==0){
            chmin(ans,abs(i*W-(H-i)*W/2));
        }else{
            chmin(ans,max(abs(i*W-(H-i)*(W/2)),  abs(i*W-(H-i)*(W/2+1) )));
        }
    }

    rep2(i,W-1){
        if(H%2==0){
            chmin(ans,abs(i*H-(W-i)*H/2));
        }else{
            chmin(ans,max(abs(i*H-(W-i)*(H/2)),  abs(i*H-(W-i)*(H/2+1) )));
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int A, B, C, K;
    read(A, B, C, K);
    int ans = 0;
    if(A > K){
        ans = K;
    }
    else{
        ans = A;
        if(A + B < K) {
            ans -= K - A - B;
        }
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3636
#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>;

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

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

int main() {
  int n, m;
  cin >> n >> m;
  int room[100000 + 1];
  vector<int> roomConnect[n + 1];
  rep(i, n + 1) {
    room[i] = -1;
    vector<int> v;
    roomConnect[i] = v;
  }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    roomConnect[a].push_back(b);
    roomConnect[b].push_back(a);
  }

  queue<int> q;
  q.push(1);
  room[1] = 0;
  while (!q.empty()) {
    int roomNo = q.front();
    q.pop();
    vector<int> vec = roomConnect[roomNo];
    for (int no : vec) {
      if (room[no] == -1) {
        q.push(no);
        room[no] = roomNo;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (room[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) {
    cout << room[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 10348
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, X;
    cin >> N >> X;
    int m[N];
    for (int i = 0; i < N; i++)
    {
        cin >> m[i];
    }
    int sum = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        sum += m[i];
    }
    X = X - sum;
    cnt += N;
    sort(m, m + N);
    while (X >= m[0])
    {
        X -= m[0];
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3608
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5e5;

int n, a[N];

vector<bool> Prime(N+10, 1);
void sieve(int N) {
   Prime[0] = Prime[1] = false;
   for(int i = 2; i <= N; ++i) {
      if(Prime[i]) {
         // Mark all the multiples of i as composite numbers
         for(int j = i * i; j <= N ;j += i)
            Prime[j] = false;
      }
   }
}

int32_t main(){_
   
   sieve(N);

   int x;
   cin >> x;

   for (int i = x; ; ++i)
   {
      if(Prime[i]){
         cout<<i;
         exit(0);
      }
   }

   return 0;
}

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

#define f first
#define s second

#define pb push_back
#define mp make_pair

#define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;

const int MAXN = (int) 2e5 + 10;
const int INF = (int) 2e9 + 7;

int n, k, q;
int cnt[MAXN];
bool dead[MAXN];

int main() {
    #ifdef sony
        freopen("input.txt", "r", stdin);
    #endif // sony
    cin >> n >> k >> q;
    for (int i = 1, a; i <= q; i++) {
        cin >> a;
        cnt[a]++;
        if (i - cnt[a] >= k) dead[a] = 1;
    }
    for (int i = 1; i <= n; i++) {
        if (q - cnt[i] >= k) dead[i] = 1;
        cout << (dead[i] ? "No" : "Yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
 int h, w;

 cin >> h >> w;

 while(h != 0 || w != 0) {
  for(int i = 0;i < w;i++) {
   cout << "#";
  }

  cout << endl;

  for(int i = 0;i < h - 2;i++) {
   for(int j = 0;j < w;j++) {
    if(j == 0 || j == w - 1) {
     cout << "#";
    } else {
     cout << ".";
    }
   }
   cout << endl;
  }
  
  for(int i = 0;i < w;i++) {
      cout << "#";
  }
  
  cout << endl;

  cin >> h >> w;
  cout << endl;
 }

 return 0;
}

Measured memory_bytes: 3080
#define DBG 1 //submit 0
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    if(a+b<c+d) cout<<"Right"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	int x, a, b; cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int a[114514];
int ans[114514];
bool p(int x){
	if(x==1)return false;
	rep(2,i,x){
		if(x%i==0)return false;
	}
	return true;
}		
signed main(){
    ic(n)
    rep(0,i,n)cin>>a[i];
    int renzoku,ans=0;
    rep(0,i,n){
        if(a[i]==a[i+1])renzoku++;
        else{
            ans+=(renzoku+1)/2;
            renzoku=0;
        }
    }
    c(ans)
}
            

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
r = Array.new(n + 1, 0)
1.upto(n) do |i|
  r[i] = r[i - 1] + a[i - 1]
end
h = Hash.new(0)
r.each do |x|
  h[x] += 1
end
cnt = 0
h.values.each do |v|
  next if v == 1
  cnt += v * (v - 1) / 2
end
puts cnt

Measured memory_bytes: 32132
#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 eb emplace_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
// #define ll int
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[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,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; }




void solve(){
    ll h;
    cin>>h;
    ll ans[50]={};
    ans[0]=1;
    rep(i,45){
        ans[i+1]=ans[i]*2+1;
    }
    ll cnt=0;
    while(h/2!=0){
        h/=2;
        cnt++;
    }
    cout<<ans[cnt]<<endl;


}

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

    solve(); 


    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <sstream>
using namespace std;


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

	if (n % 2 == 1) {
		ans = n / 2 + 1;
	}
	else {
		ans = n / 2;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){

	map<char,char> t;
	t['D']='A';
	t['E']='B';
	t['F']='C';
	t['G']='D';
	t['H']='E';
	t['I']='F';
	t['J']='G';
	t['K']='H';
	t['L']='I';
	t['M']='J';
	t['N']='K';
	t['O']='L';
	t['P']='M';
	t['Q']='N';
	t['R']='O';
	t['S']='P';
	t['T']='Q';
	t['U']='R';
	t['V']='S';
	t['W']='T';
	t['X']='U';
	t['Y']='V';
	t['Z']='W';
	t['A']='X';
	t['B']='Y';
	t['C']='Z';
	
	string s;
	string a="";
	cin>>s;
	
	for(int i=0;i<s.size();i++){
		a=a+t[s[i]];
	}
	
	cout<<a<<endl;
	

}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		char[] c = s.toCharArray();
		int a = 0;
		int b = 0;
		for (int i=1;i<N;i++) {
			if (c[i]==c[i-1]) {
				System.out.println(i + " " + (i+1));
				return;
			}
		}

		for (int i=2;i<N;i++) {
			if (c[i]==c[i-2]) {
				System.out.println((i-1) + " " + (i+1));
				return;
			}
		}

		System.out.println(-1 + " " + -1);
	}
}

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

using namespace std;

const int t[10][10] = {
	{3, 2, 6, 1, 5, 4},
	{4, 2, 1, 6, 5, 3},
	{2, 6, 3, 4, 1, 5},
	{5, 1, 3, 4, 6, 2}

};

int main()
{
	int d[10], a[10], k[200];
	string s;
	k['W'] = 0, k['E'] = 1, k['N'] = 2, k['S'] = 3;
	
	for(int i = 0; i<6; i++)
	{
		cin >> d[i];	
	}
	cin >> s;
	
		for(int i = 0; i< s.size(); i++)
	{
		for(int j = 0; j < 6; j++)	
		{
			a[j] = d[t[k[s[i]]][j]-1];
		}
		for(int j = 0; j < 6; j++)	
		{
			d[j] = a[j];
		}		
	}
	cout << d[0] << endl;
	return 0;


	


	
 } 


Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
int main(){
  char s[11],t[11],u[11];
  int a,b;
  scanf("%s %s",s,t);
  scanf("%d%d",&a,&b);
  scanf("%s",u);
  if(strcmp(s,u)==0)
    a-=1;
  else if(strcmp(t,u)==0)
    b-=1;
  printf("%d %d\n",a,b);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
using namespace std;
queue<int> q;
int t[59049];
int INF=100000;
int encode(vector<int> vc){
	int p=0;
	for(int i=0;i<vc.size();i++){
		p=p*3+vc[i];
	}
	return p;
}
vector<int> decode(int p,int n){
	vector<int> vc(n);
	for(int i=0;i<n;i++){
		vc[n-i-1]=p%3;
		p/=3;
	}
	return vc;
}
int main(){
	while(true){
		for(int i=0;i<59049;i++) t[i]=INF;
		string s;
		cin >> s;
		if(s=="0") break;
		int n=s.size(),start=0,goal=1;
		for(int i=0;i<n;i++) goal*=3;
		goal-=1;
		for(int i=0;i<n;i++){
			if(s[i]=='r') start=start*3+2;
			if(s[i]=='g') start=start*3+1;
			if(s[i]=='b') start=start*3;
		}
		q.push(start);
		t[start]=0;
		int ok=-1;
		while(q.size()){
			int p=q.front();
			if(p==0 || p==goal/2 || p==goal){
				ok=p;
				while(q.size()) q.pop(); 
				break;
			}
			q.pop();
			vector<int> vc=decode(p,n);
			for(int i=0;i<n-1;i++){
				if(vc[i]==vc[i+1]) continue;
				vector<int> vc_c=vc;
				vc_c[i]=vc_c[i+1]=((vc[i]+vc[i+1])*2)%3;
				int hoge=encode(vc_c);
				if(t[hoge]!=INF) continue;
				q.push(hoge);
				t[hoge]=t[p]+1;
			}
		}
		if(ok==-1) cout << "NA" << endl;
		else cout << t[ok] << endl;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int black = 0;
	int white = 0;
	
	rep(i,n){
		if(s[i] == '.') white++;
	}
	
	int ans = white;
	
	rep(i,n){
		if(s[i] == '.'){
			white--;
		}
		if(s[i] == '#'){
			black++;
		}
		ans = min(ans ,black + white);
	}
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

count = 0

for i in range(N):
    if a[i] <= x and i != (N-1):
        count += 1
        x -= a[i]
    elif a[i] == x and i == (N-1):
        count += 1

print(count)

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string s;
    cin >> s;
    int max = 0;
    string front;
    string end;
    rep(i, (s.size() / 2))
    {
        front = s.substr(0, i);
        end = s.substr(i, i);
        if (front == end)
        {
            max = i;
        }
    }
    cout << max * 2 << endl;
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);

    REP(i,N+1){
        cin >> A[i];
        // cout << A[i] << endl;
    }
    REP(i,N){
        cin >> B[i];
        // cout << B[i] << endl;
    }

    ll count = 0;
    ll next = 0;

    REP(i,N){
        // 最初だけの処理
        if(i == 0){
            count += min(A[i], B[i]);
            if(B[i] > A[i]){
                next = B[i] - A[i];
            }
            continue;
        }
        
        if(B[i] + next > A[i]){
            count += A[i];
            next = min(B[i], B[i] + next - A[i]);
        }
        else{
            count += B[i] + next;
            next = 0;
        }
    }

    // 最後のN+1番目の街
    count += min(next, A[N]);

    cout << count << endl;
    return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	deque<int> q;
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		if (i & 1)q.push_back(t);
		else q.push_front(t);
	}
	if (!(n & 1))while (!q.empty()){
		printf("%d", q.back());
		q.pop_back();
		if (!q.empty())printf(" ");
	}else while (!q.empty()){
		printf("%d", q.front());
		q.pop_front();
		if (!q.empty())printf(" ");
	}
}

Measured memory_bytes: 2944
N=int(input())
H=[int(i) for i in input().split()]
num=[]
ans=0

for i in range(N-1):
  if H[i] >= H[i+1]:
    ans +=1
    continue
    
  if H[i] < H[i+1]:
    num.append(ans)
    ans=0
    continue
    
num.append(ans)

num.sort()
print(num[-1])
  

Measured memory_bytes: 14252
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n)
        cin >> d[i];
    int sumx = 0;
    REP(i, n){
        FOR(j, i+1, n){
            sumx += d[i] * d[j];
        }
    }
    cout << sumx << endl;
    return 0;
}

Measured memory_bytes: 256
//#######################     Starting_with_name_of_ALLAH     ##############################
//#######################     Bismillahir_rahmair_raheem      ##############################
 
//                      coded in 2020
//
//                   Shamim Ahammad Rasel
//                  Begum Rokeya University
//                 shamim.brur.cse@gmail.com
//                    I love your thinking 


#include<bits/stdc++.h>
#include<bitset>
#include<iostream>
#define tc()         int tc;cin>>tc;while(tc--)

using namespace std;


bitset<1000001> prime;


void shomoy();

void seive(){
    // o prime
    // 1 not prime
    prime[1] = 1;
    prime[2] = 0;
    for(int i=3;i*i<1000009;i+=2){
        if(prime[i]==0){
            for(int j=i+i;j<1000009;j+=i){
                prime[j] = 1;
            }
        }
    }
}

long long fact(int n){
    long long mul = 1;
    for(int i=1;i<=n;i++){
        mul *= i;
    }
    return mul;
}



int npr(int n,int r){
    int mul=1;
    int temp =0;
    for(int i=0;i<r;i++){
        mul *= (n-i);
    }
    return mul;
}

int main(){
	ios::sync_with_stdio();
	cin.tie();
    int  i,j,k,x,y,a,b,n,s,p,total=0,index,count,sum,temp,len,t,temp1,count1,count2,mn;
    
    cin>>n;
    int dice1[n],dice2[n];
    bool ok = false;
    for(i=0;i<n;i++){
    	cin>>dice1[i]>>dice2[i];
    }
    for(i=0;i<n-2;i++){
    	if(dice1[i]==dice2[i] && dice1[i+1]==dice2[i+1] && dice1[i+2]==dice2[i+2]){
    		ok = true;
    		break;
    	}
    }
    if(ok){
    	printf("Yes\n");
    }
    else{
    	printf("No\n");
    }
	    

    

   


shomoy();
return 0;
}




void shomoy(){
    #ifndef ONLINE_JUDGE
        cerr<<"---------END OF OUTPUT---------------\n";
        cerr<<"---------Time  :"<<1.0*clock()/CLOCKS_PER_SEC<<"s------------\n";
        
    #endif
 
}


Measured memory_bytes: 3636
n,a,b=list(map(int, input().strip().split()))
s=input().strip()
x=0
y=0
for i in range(n):
    if s[i]=='a':
        if x<a+b:
            print("Yes")
            x=x+1
        else:
            print("No")
    elif s[i]=='b':
        if x<a+b and y<b:
            print("Yes")
            x=x+1
            y=y+1
        else:
            print("No")
    else:
        print("No")

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

class DSU{
private:
    vector<int> parent;
    vector<int> size;
    int n;
    void make_set(int v){
        parent[v] = v;
        size[v] = 1;
    }
    int find_set(int v){
        if(v==parent[v]) return v;
        return parent[v]=find_set(parent[v]);
    }
    void union_set(int a, int b){
        a = find_set(a);
        b = find_set(b);
        if(a!=b){
            if(size[a]<size[b]) swap(a,b);
            parent[b]=a;
            size[a]+=size[b];
        }
    }
public:
    DSU(int N){
        n=N;
        parent.resize(n,0);
        size.resize(n,0);
        for(int i=0; i<n; ++i) make_set(i);
    }
    int solve(int M){
        for(int i=0; i<M; ++i){
            int x,y;
            cin>>x>>y;
            --x;--y;
            union_set(x,y);
        }
        int ans=0;
        for(int i=0; i<n; ++i){
            if(parent[i]==i) ans = max(ans,size[i]);
        }
        return ans;
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    DSU solution(n);
    int ans = solution.solve(m);
    cout<<ans<<"\n";
}

Measured memory_bytes: 4804
#include <stdio.h>
#pragma warning(disable : 4996)
int n, q, a[16][16], b[16][16], com, r, c, s, z;
void rec(int r_, int c_) {
	a[r_][c_] ^= 1;
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			if (i * j == 0 && i + j && 0 <= r_ + i && r_ + i < n && 0 <= c_ + j && c_ + j < n && a[r_ + i][c_ + j] != a[r_][c_]) rec(r_ + i, c_ + j);
		}
	}
}
int main() {
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &com, &r), r--;
		switch (com) {
		case 0:
			scanf("%d%d%d", &c, &s, &z), c--;
			for (int i = 0; i < z / 90; i++) {
				for (int j = r; j < r + s; j++) {
					for (int k = c; k < c + s; k++) b[j][k] = a[s + c + r - k - 1][j + c - r];
				}
				for (int j = r; j < r + s; j++) {
					for (int k = c; k < c + s; k++) a[j][k] = b[j][k];
				}
			}
			break;
		case 1:
			scanf("%d%d", &c, &s), c--;
			for (int i = r; i < r + s; i++) {
				for (int j = c; j < c + s; j++) a[i][j] ^= 1;
			}
			break;
		case 2:
			for (int i = 0; i < n; i++) b[r][i] = a[r][(i + 1) % n];
			for (int i = 0; i < n; i++) a[r][i] = b[r][i];
			break;
		case 3:
			for (int i = 0; i < n; i++) b[r][(i + 1) % n] = a[r][i];
			for (int i = 0; i < n; i++) a[r][i] = b[r][i];
			break;
		case 4:
			scanf("%d", &c), c--; rec(r, c);
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) printf(j ? " %d" : "%d", a[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 2760
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define N 200005
#define mod 1000000007
ll powmod(ll a, ll b){
	ll res = 1;
	a %= mod;
	while(b) {
		if(b & 1) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res % mod;
}
ll fac[N], inv[N];
void init() {
	fac[0] = 1;
	for(int i = 1; i < N; i++) {
		fac[i] = fac[i - 1] * i % mod;
	}
	inv[N - 1] = powmod(fac[N - 1], mod - 2);
	for(int i = N - 2; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll c(ll n, ll m) {
	if(m > n) {
		return 0;
	}
	if(m == 0) return 1;
	if(n < N) return fac[n] * inv[m] % mod * inv[n - m] % mod;
	//c(m,k) = m!/(k! * (m - k))= m-k+1~m/(k!)
	ll res = inv[m];
	for(int i = n - m + 1; i <= n; i++) {
		res = res * i % mod;
	}
	return res;
}
ll a[200005];
int main() {
	init();
	int n,k;
	scanf("%d%d",&n,&k);
	if(k >= n - 1) {
		printf("%lld\n",c(2 * n - 1, n) % mod);
		return 0;
	}
	ll res = c(2 * n - 1, n);
	for(int i = 1; i <= n - k - 1;i++) {
		res = (res - c(n, n - i) * c(n - 1, i - 1) % mod +mod) % mod;
	}
	cout<<res<<endl;
}


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

int main() {
	
	int n, k; cin >> n >> k;
	vector<ll> num(k, 0);
	for (int i = 1; i <= n; i++) {
		num[i % k]++; // 1 ～ n を mod k の世界に変換
	}
	ll ans = 0;
	for (int a = 0; a < k; a++) {
		int b = (k - a) % k;
		int c = (k - a) % k;
		if ((b + c) % k == 0) {
			ans += num[a] * num[b] * num[c];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4828
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int A, B;
  unused = scanf("%d %d", &A, &B);

  if(A%3==0 || B%3==0 || (A+B)%3==0) printf("Possible");
  else printf("Impossible");
  return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
from collections import deque,defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    branch[a-1]|={b-1}
    branch[b-1]|={a-1}
path=deque([0])
for x in branch[0]:
    path.append(x)
    break
used=set(path)
while True:
    A,B=False,False
    if len(branch[path[0]]-used)==0:
        A=True
    else:
        for x in branch[path[0]]:
            if x in used:
                continue
            path.appendleft(x)
            used|={x}
            break
    if len(branch[path[-1]]-used)==0:
        B=True
    else:
        for x in branch[path[-1]]:
            if x in used:
                continue
            path.append(x)
            used|={x}
            break
    if A and B:
        break
path=[p+1 for p in path]
print(len(path))
print(" ".join(map(str,path)))

Measured memory_bytes: 52884
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif   
    int a,b,c;
    cin>>a>>b>>c;
    // cout<<1<<endl;
    for(int i=0;i<=500;i++)
    {
        if(a%2 || b%2 || c%2)
        {
            cout<<i<<endl;
            return 0;
        }
        int d,e,f;
        d = a+b;
        d/=2;
        e = b+c;
        e/=2;
        f = a+c;
        f/=2;
        a=e;
        b=f;
        c=d;
    }
    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,E,i,s,j;
  int a[4][14];
  char e,moji[4];
  
  scanf("%d",&n);

  for(i=0;i<4;i++){
    for(j=1;j<=13;j++){
      a[i][j]=0;
    }
  }
 
  
  for(i=0;i<4;i++){
    if(i==0) moji[i]='S';
    if(i==1) moji[i]='H';
    if(i==2) moji[i]='C';
    if(i==3) moji[i]='D';
  }
  
  for(i=0;i<n;i++){
    scanf("%s %d",&e,&s);
    if(e=='S'){
      E=0;
    }
    if(e=='H'){
      E=1;
    }
    if(e=='C'){
      E=2;
    }
    if(e=='D'){
      E=3;
    }
    
    a[E][s]=1;
  }
  for(j=0;j<4;j++){
  for(i=1;i<=13;i++){
    if(a[j][i]!=1){
      printf("%c %d\n",moji[j],i);
    }
  }
  }
  


    
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int max(int n,int s[100]){
	int p=s[0];
	for(int i=1;i<n;i++){
		if(p<s[i]) {
			int k;
			k=p; p=s[i]; s[i]=k;
		}
		}
	return p;
}

int min(int n,int s[100]){
	int q=s[0];
	for(int i=1;i<n;i++){
		if(q>s[i]) {
			int k;
			k=q; q=s[i]; s[i]=k;
		}
		}
	return q;
}

int main(void){   
	while(1){   
		int n;
		scanf("%d",&n);   
		if(n==0) break;   
		int s[100],sum=0;   
		for(int i=0;i<n;i++){       
			scanf("%d",&s[i]);       
			sum+=s[i];
		}
		sum=sum-max(n,s)-min(n,s);
		int x;
		x=sum/(n-2);
		printf("%d\n",x);
		}
  	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(){
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1; --x2; --y1; --y2;
    vector<string> c(H);
    for(auto& s : c) cin >> s;
    vector dist = vector(H, vector(W, -1));
    queue<pair<int, int>> qu; qu.emplace(x1, y1);
    dist[x1][y1] = 0;
    while(!qu.empty()){
        auto p = qu.front(); qu.pop();
        int dx[] = {-1, 0, 1, 0};
        int dy[] = {0, -1, 0, 1};
        for(int d=0;d<4;d++){
            for(int i=1;i<=K;i++){
                int nx = p.first + i * dx[d];
                int ny = p.second + i * dy[d];
                if(nx < 0 || H <= nx || ny < 0 || W <= ny || c[nx][ny] == '@') break;
                if(dist[nx][ny] != -1 && dist[nx][ny] < dist[p.first][p.second] + 1) break;
                if(dist[nx][ny] == -1){
                    dist[nx][ny] = dist[p.first][p.second] + 1;
                    qu.emplace(nx, ny);
                }
            }
        }
    }
    cout << dist[x2][y2] << endl;
}

Measured memory_bytes: 12132
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,p;
  cin >> N;
  int sum = 0;
  int M = 0;
  for (int i = 0; i < N; i++){
    cin >> p;
    sum += p;
    M = max(M,p);
  }
  cout << sum - M / 2;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    print(YES) if S.count('AC') >= 1 else print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    map<char, ll> mp;
    REP(i, s.size()){
        mp[s[i]]++;
    }
    bool flag = true;
    for(auto x : mp){
        if(x.se%2 != 0) flag = false;
    }
    if(flag) Yes();
    else No();
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  if (n % 2 == 1) {
    cout << 0 << endl;
  } else {
    cout << (a[n/2] - a[n/2-1]) << endl;
  }
}


Measured memory_bytes: 640
N = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

count = 1
n = 26
while n < N:
    count += 1
    n = (n + 1) * 26

# (count-1)桁までの個数
minues = 0
for i in range(count):
    minues += 26**i

# count桁で何番目か
answer_index = []
N -= minues
while count>0:
    answer_index.append(N%26)
    count -=1
    N //= 26

answer_list = []
for idx in reversed(answer_index):
    answer_list.append(alphabet[idx])

print("".join(answer_list))

Measured memory_bytes: 9200
n,m=map(int,input().split())
mod=10**9+7

    
dp=[0]*(n+1)
dp[0]=1

a=set(int(input()) for i in range(m))

for i in range(1,n+1):
    if i in a:
        continue
    x=dp[i-1]
    if i>1:
        x+=dp[i-2]
    dp[i]=x%mod
print(dp[-1])


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

int main() {
    int N, x, ans=0;
    int a[110];
    cin >> N >> x;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N);
    for (int i = 0; i < N; ++i){
      if(x >= a[i]){
        ++ans;
        x = x - a[i];
      }
    }
    
    if (ans == N && x > 0) --ans;
    
    cout << ans << endl;
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n; std::cin >> n;
  int d[n]; REP(i,n) std::cin >> d[i];
  int ans = 0;
  REP(i,n) REP(j,n) {
    if (i == j) continue;
    ans += d[i]*d[j];
  }
  std::cout << ans/2 << '\n';
  return 0;
}


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

int main() {
	long long a,b,c=0;
	cin>>a>>b;
	long long t;
	t=b;
	while(b>0)
	{
		b=b/10;
		c++;
	}
	long long d;
	d=a*pow(10,c)+t;
	if(floor(sqrt(d))==ceil(sqrt(d)))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int n = int.Parse(input);

            
            string[] input_b = Console.ReadLine().Split(' ');
            double[] b = new double[n];
            for(int i = 0;i < n;i++)
                b[i] = double.Parse(input_b[i]);

            Array.Sort(b);

            for(int i = 1;i < n;i++)
            {
                double temp = (b[i -1] + b[i]) / 2.0;
                b[i] = temp;
            }

            double ans = b[n - 1];

            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(a, b, c, i) for (int i = a; i < b; i += c)
#define MAX_INT 1000000007
#define ll long long
#define p(t1, t2, x) pair<t1, t2> x
#define v(t, x) vector<t> x
#define newl "\n"

using namespace std;

class JudgeStatusSummary {
public:
	vector<int> status(vector<string> s){
		vector<int> stats = {0, 0, 0, 0};
		for (int i = 0; i < s.size(); i++){
			if (s[i] == "AC") stats[0]++;
			else if (s[i] == "WA") stats[1]++;
			else if (s[i] == "TLE") stats[2]++;
			else stats[3]++;
		}
		return stats;
	}
};

int main(){
	ll t;
	cin >> t;
	JudgeStatusSummary jss;
	vector<string> st;
	while (t--){
		string s;
		cin >> s;
		st.push_back(s);
	}
	vector<int> stats = jss.status(st);
	printf("AC x %d\n", stats[0]);
	printf("WA x %d\n", stats[1]);
	printf("TLE x %d\n", stats[2]);
	printf("RE x %d\n", stats[3]);
}


Measured memory_bytes: 9528
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	vi dp(3);
	for(int days=1;days<=n;days++){
		vi a(3);
		vi new_dp(3,0);
		fo0(i,3){
			cin>>a[i];
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j]=max(new_dp[j],dp[i]+a[j]);
				}
			}
		}
		dp=new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if((0<=a)&&(c<=100))
    {
        if((a<b)&&(b<c))
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int n; cin>>n;
  int p[n],q[n];
  rep(i,0,n) cin>>p[i];
  rep(i,0,n) cin>>q[i];

  int r[n];
  rep(i,0,n) r[i]=i+1;
  sort(r,r+n);

  int a,b;
  int cnt=1;
  do{
    bool pr=true,qr=true;
    rep(i,0,n){
      if(p[i]!=r[i]) pr=false;
      if(q[i]!=r[i]) qr=false;
    }
    if(pr) a=cnt;
    if(qr) b=cnt;
    cnt++;
    //cout<<a<<" "<<b<<" "<<cnt<<endl;
  }while(next_permutation(r,r+n));

  cout<<abs(a-b)<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
long long a,b,s;

bool check(long long x){
    
    if(x*x < s) return true;
    return false;
}

int main(int argc, const char * argv[]) {
   
    int q;
    
    scanf("%d",&q);
    
    for(int i=0;i<q;i++){
        
        scanf("%lld %lld",&a,&b);
        
        s = a*b;
        long long ans = 0;
        if(a<b){ //a가 작은경우
            ans += 2*(a-1);
        }else if(a==b){
            printf("%lld\n",2*(b-1));
            continue;
        }else{
            ans += 2*(b-1);
            long long tmp = a;
            a=b;
            b=tmp;
        }
        
        if(a+1 != b){
            
            long long l = a+1;
            long long r = b-1;
            long long val = 0;
            while(l<=r){
                
                long long mid = (l+r)/2;
                
                if(check(mid)){
                    l = mid+1;
                    val = mid;
                }else{
                    r = mid-1;
                }
            }
            
            if(val!=0){
                if(val *(val+1) < s) ans += 2*(val-a);
                else ans += 2*(val-a) - 1 ;
            }
            ans++;
            
        }
        printf("%lld\n",ans);
    }
    
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<long> a(N);
    int max_divide_operate = 0;
    bool divided_flag;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    for (int i = 0; i < N; i++){
        while (a[i] % 2 == 0){
            a[i] = a[i] / 2;
            max_divide_operate++;
        }
    }
    cout << max_divide_operate << endl;
}


Measured memory_bytes: 384
//cod2016_qualB_a.cpp
//Sat Oct 20 22:23:28 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	string ans = "CODEFESTIVAL2016";
	int count = 0;
	for (int i=0;i<s.size();i++){
		if (s[i] != ans[i]){
			count++;
		}
	}

	cout << count << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int d=0;
    int newA,newB,newC;

    while (a%2==0&&b%2==0&&c%2==0)
    {
        newA=(b/2)+(c/2);
        newB=(a/2)+(c/2);
        newC=(b/2)+(a/2);
        if (newA==a&&newB==b&&newC==c)
        {
            cout<<"-1"<<endl;
            return 0;
        }
        a=newA;
        b=newB;
        c=newC;

        d++;

    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0;
  cin >> N;
  vector<int> h(N);
  vector<int> cost(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  cost.at(0)=0;
  cost.at(1)=abs(h.at(0)-h.at(1));
  for(int i=2;i<N;i++){
    cost.at(i)=min(cost.at(i-1)+abs(h.at(i)-h.at(i-1)),cost.at(i-2)+abs(h.at(i)-h.at(i-2)));
  }
  
  cout << cost.at(N-1) << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=100010;
int n;
LL a[maxn];

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        LL ans=0;
        for (int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            a[i]--;
            ans+=a[i];
        }

        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007


signed main(){
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
    //     freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    // #endif
    int n, a, b;
    cin>>n>>a>>b;
    cout<<min(a, b)<<" "<<max(0LL, a+b-n);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    ll b[25]={0};
    rep(i,0,25)
    {
    	ll p=a[i];
    	while(n/p)
    	{
    		b[i]+=n/p;
    		p*=a[i];
    	}
    }
    ll ans=0;
    rep(i,0,25)
    {
    	if(b[i]>=74)
    		ans++;
    }
    rep(i,0,25)
    {
    	rep(j,0,25)
    	{
    		if(i==j)
    			continue;
    		if(b[i]>=24&&b[j]>=2)
    			ans++;
    		if(b[i]>=14&&b[j]>=4)
    			ans++;
    	}
    }
    rep(i,0,25)
    {
    	rep(j,i+1,25)
    	{
    		rep(k,0,25)
    		{
    			if(k==i||k==j)
    				continue;
    			if(b[i]>=4&&b[j]>=4&&b[k]>=2)
    				ans++;
    		}
    	}
    }
    cout<<ans;
}


Measured memory_bytes: 256