akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int getKetaSum(int num){
   int res=0;

   while(num){
      res += num%10;
      num/=10;
   }
   return res;
}

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

   int res=0;
   for(int i=1;i<=n;i++){
      int tmp = getKetaSum(i);
      if(a <= tmp && tmp <= b){
         res += i;
      }
   }
   p(res)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

//a:残り
//b:１回に使っていい最大数
//c:今までの結果
void dfs(ll a,ll b,string c){
	if(a==0){
		cout<<c<<endl;
		return;
	}
	ireg(i,1,min(b,a)){
		dfs(a-i,i,(c==""?to_string(i):c+" "+to_string(i)));
	}
}

ll n;

int main(void){
	while(1){
		cin>>n;
		if(n==0)break;
		dfs(n,n,"");
	}
	return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, m;
	cin >> n >> m;
	
	cout << (n*(n-1)/2) + (m*(m-1)/2);

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL cnt = 0;
LL k;
bool dfs(LL d, LL n, char* s){
    if(d == n){
        cnt++;
        return cnt == k;
    }

    bool end = false;
    if(s[d] != '0'){
        s[d+1] = s[d] - 1;
        end = dfs(d + 1, n, s);
        if(end) return true;
    }

    s[d+1] = s[d];
    end = dfs(d + 1, n, s);
    if(end) return true;

    if(s[d] != '9'){
        s[d+1] = s[d] + 1;
        end = dfs(d + 1, n, s);
        if(end) return true;
    }
    return false;
}

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

    cin>>k;
    char s[20] = {0};
    REP(i, 15){
        FOR(x, 1, 10){
            s[0] = '0' + x;
            if(dfs(0, i, s))goto END;
        }
    }
END:
    printf("%s\n", s);
}


Measured memory_bytes: 256
import java.io.*;
 
class Main {
     public static void main(String[] args) {
 
        int intNum1 = 0;
        int intNum2 = 0;
        int intNum3 = 0;
        int intAnswer = 0;
 
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String strLine = br.readLine();
            String[] strLineAry = strLine.split(" ");
 
            intNum1 = Integer.parseInt(strLineAry[0]);
            intNum2 = Integer.parseInt(strLineAry[1]);
            intNum3 = Integer.parseInt(strLineAry[2]);
 
            for(int i = intNum1; i <= intNum2; i++) {
                if(intNum3 % i == 0) {
                    intAnswer++;
                }
            }
            System.out.println(intAnswer);
        }

        catch(IOException e) {
            System.out.println(e);
        }
        catch(NumberFormatException e) {
            System.out.println("??°?????§??\??????????????????");
        }
    }
}

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


bool isedge[51][51] = {};  // 隣接行列で edge を管理

// i を出発して行ける場所を深さ優先探索
void dfs( int i, vector<bool>& isVisited )
{
    isVisited[i] = true;
    for( int j = 1; j < isVisited.size(); ++j ){
        if( isedge[i][j] && !isVisited[j] ) dfs( j, isVisited );
    }
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for( int i = 0; i < M; ++i ) cin >> a[i] >> b[i];


    for( int i = 0; i < M; ++i ){
        isedge[a[i]][b[i]] = isedge[b[i]][a[i]] = true;
    }

    int ans = 0;
    for( int i = 1; i <= N; ++i ){
        for( int j = 1; j < i; ++j ){
            if( isedge[i][j] ){
                isedge[i][j] = isedge[j][i] = false;
                vector<bool> isVisited(N+1, false);
                dfs( i, isVisited );
                if( !isVisited[j] ) ++ans;
                isedge[i][j] = isedge[j][i] = true;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  char c;
  cin >> c;

  if(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define N 100007
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

long gcd(long a,long b){
  if (a<b) return gcd(b,a);
  else {
  if (b==1) return 1;
  else if (b==0) return a;
  else return gcd(b,a%b);
  }
}

long lcm(long a,long b){
    return a/gcd(a,b)*b;
}

int main() {
    long a,b;cin >> a >> b;cout << lcm(a,b) << endl;
}



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

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

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

signed main(void)
{
	string s, t;
	long long ans, cnt;
	cin >> s;
	rep(i, s.size() - 1)
	{
		if (s.substr(i, 2) == "BC")
		{
			t += 'D';
			i++;
		}
		else
			t += s[i]; 
	}
	ans = cnt = 0;
	for(int i = t.size(); i >= 0; i--)
	{
		if (t[i] == 'A') 
			ans += cnt;
		else if (t[i] == 'D')
			cnt++;
		else
			cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int a[111111];
long b[111111], o[111111];
int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		b[i + 1] = b[i] + a[i];
		o[i + 1] = o[i] + (i % 2 ? a[i] : 0);
	}
	a[n] = 1e9 + 1;
	for (int i = 0; i < q; i++) {
		int x;
		scanf("%d", &x);
		int l = 0, r = n;
		while (l + 1 < r) {
			int m = (l + r) / 2;
			if (n - m <= m || x - a[n - m - m - 1] > a[n - m - 1] - x)
				r = m;
			else l = m;
		}
		if (n - l <= l || x - a[n - l - l - 1] > a[n - l - 1] - x)
			r = 0;
		else r = 1, l++;
		cout << b[n] - b[n - l] + (n % 2 ? b[n - l - l + r] - o[n - l - l + r] : o[n - l - l + r]) << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int N,M;
int A[1<<17];
bool used[2<<17];
int cnt[1<<17];
int take[1<<17],rgt[1<<17];
main()
{
	cin>>N>>M;
	vector<pair<int,int> >AB(N);
	for(int i=0;i<N;i++)
	{
		cin>>AB[i].first>>AB[i].second;
	}
	sort(AB.begin(),AB.end());
	for(int i=0;i<N;i++)A[i]=AB[i].first;
	vector<vector<pair<int,int> > >E(N);
	for(int i=0;i<M;i++)
	{
		int L,R;cin>>L>>R;
		L=lower_bound(A,A+N,L)-A;
		R=upper_bound(A,A+N,R)-A;
		if(L<R)
		{
			E[L].push_back(make_pair(R,i));
		}
	}
	vector<pair<int,int> >calc;
	for(int i=0;i<N;i++)
	{
		sort(E[i].begin(),E[i].end());
		if(!E[i].empty())
		{
			take[i]=E[i][0].second;
			rgt[i]=E[i][0].first;
		}
		else
		{
			take[i]=-1;
		}
		for(int j=(int)E[i].size()-1;j>=1;j--)
		{
			int L=E[i][j-1].first,R=E[i][j].first;
			if(L<R)
			{
				E[L].push_back(make_pair(R,E[i][j].second));
				calc.push_back(make_pair(E[i][j-1].second,E[i][j].second));
			}
		}
	}
	int cum=0;
	for(int i=0;i<N;i++)
	{
		cum+=AB[i].second+cnt[i];
		cnt[i+1]+=cnt[i];
		cnt[i+1]%=2;
		cum%=2;
		if(cum==1)
		{
			if(take[i]<0)
			{
				cout<<-1<<endl;
				return 0;
			}
			used[take[i]]=!used[take[i]];
			cum++;
			cnt[i+1]++;
			cnt[rgt[i]]++;
		}
	}
	reverse(calc.begin(),calc.end());
	for(pair<int,int>p:calc)
	{
		int i=p.first,j=p.second;
		used[i]=used[i]!=used[j];
	}
	int anscnt=0;
	for(int i=0;i<M;i++)anscnt+=used[i];
	cout<<anscnt<<endl;
	for(int i=0;i<M;i++)
	{
		if(used[i])
		{
			anscnt--;
			cout<<i+1<<(anscnt==0?"\n":" ");
		}
	}
}


Measured memory_bytes: 37608
#include<stdio.h>
#include <ctype.h>

int main(void)
{
	char Chr[1200];
	char a[1200];
	int n, i;
	n = 0;
	while(1)
	{
		scanf("%c",&Chr[n]);
		if (Chr[n] == '\n')
		{
			break;
		}
		a[n] = Chr[n];
		if ('A' <= Chr[n] && Chr[n] <='Z')
		{
			a[n] = Chr[n] + 32;
		}
		else if(Chr[n] >= 'a' && Chr[n]<='z')
		{
			a[n] = Chr[n] - 32;
		}
		n = n + 1;
	}
	for (i= 0; i < n; i++)
	{
		printf("%c", a[i]);
	}
	printf("\n");
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  double d;
  int n,b;
  cin >> d >> n >> b;
  vector<double> p(n),h(n);
  rep(i,n) cin >> p[i] >> h[i];
  double ans=IINF;
  repp(t,1,b+2){
    double l = d/t;
    double m = 0;
    rep(i,n){
      double pos=p[i]-floor(p[i]/l)*l;
      double hh=pos*(l-pos);
      m = max(m,h[i]/hh);
    }
    double vx2 = min(l/2,1.0/2/m);
    ans=min(ans,vx2+l*l/4/vx2);
  }
  cout << fixed << setprecision(10) << sqrt(ans) << endl;
  return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int u,k,v;
  int dp[n][n];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++) dp[i][j]=0;
  }

  for(int i=0;i<n;i++)
  {
    cin>>u>>k;
    for(int l=0;l<k;l++)
    {
      cin>>v;
      dp[i][v-1]=1;
    }
  }

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(j) cout<<" ";
      cout<<dp[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3140
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<set> 
using namespace std;
long long a[500];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0];
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
	const int m = 18680908;
	const int t = 19120730;
	const int s = 19261225;
	const int h = 19890108;

	int a, b, c;

	while(scanf("%d %d %d", &a, &b, &c) != EOF) {
		int tmp = a * 10000 + b * 100 + c;
		char* era;
		int year;
		int flag = 0;

		if(tmp < m) {
			era = "pre-meiji";
			flag = 1;
		}
		else if(tmp < t) {
			era = "meiji";
			year = a - m / 10000 + 1;
		}
		else if(tmp < s) {
			era = "taisho";
			year = a - t / 10000 + 1;
		}
		else if(tmp < h) {
			era = "showa";
			year = a - s / 10000 + 1;
		}
		else {
			era = "heisei";
			year = a - h / 10000 + 1;
		}

		if(flag)
			printf("%s\n", era);
		else
			printf("%s %d %d %d\n", era, year, b, c);
	}

	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int n,a[N];

int main(){
	scanf("%d",&n);
	int mx=0,cnt=0;
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),mx=max(a[i],mx);
	for (int i=1;i<=n;i++){
		if (a[i]<mx-1){
			puts("No");
			return 0;
		}
		cnt+=mx-a[i];
	}
	if (cnt==0){
		if ((n/mx>1) || mx==n-1)
			puts("Yes");
		else
			puts("No");
		return 0;
	}
	if ((mx>cnt) && ((n-cnt)/(mx-cnt)>1))
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<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 MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

ll power(ll a, ll b){
  ll ans = 1;
  if(b%2==0){
    REP(i, b/2){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans;
  }else{
    b = b/2;
    REP(i, b){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans* a;
  }
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(void){

   ll n;
   cin>>n;
   vector<ll> v(n);

   REP(i, n){
     ll x;
     cin>>x;
     v[i] = x;
   }
   sort(v.rbegin(), v.rend());
   
   ll count = 1;
   ll ans = v[0];
   ll i = 1;
   ll piv = 0;

   while(count < n-1){
     if(piv == 0 || piv ==1){ ans += v[i]; piv++; }
     if(piv==2) {piv = 0; i++;}
     count++;
   }

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

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int A, B;
    cin >> A >> B;
    if( A >= 13){
        cout << B << endl;
    }else if(6 <= A){
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }

}

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


Measured memory_bytes: 256
import sys
n,x=map(int,input().split())
if x==1 or x==n*2-1:
  print('No')
  sys.exit()
print('Yes')
if n==2:
  for i in range(1,4):
    print(i)
  sys.exit()
if x==2:
  l=[x+1,x,x-1,x+2]
else:
  l=[x-1,x,x+1,x-2]
L=[]
for i in range(1,n*2):
  if i not in l:
    L.append(i)
for i in range(n-2):
  print(L[i])
for i in range(4):
  print(l[i])
for i in range(n-3):
  print(L[i+n-2])

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],Dpos[2*N-1],Dneg[2*N-1];

bool X[N][N];

void initia(){
  for(int i=0; i<N; i++){
    row[i]=FREE,col[i]=FREE;
  }
  for(int i=0; i<2*N-1; i++){
    Dpos[i]=FREE; Dneg[i]=FREE;
  }
}
  void print(){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        if(X[i][j]){
          if(row[i]!=j)return;
        }
      }
    }
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        cout << ((row[i]==j)?"Q" : ".");
      }
      cout << endl;
    }
}

  void recursive(int i){
    if(i==N){
      print(); return;
    }

    for(int j=0; j<N; j++){
      if(NOT_FREE == col[j] ||
         NOT_FREE == Dpos[i+j] ||
         NOT_FREE == Dneg[i-j+N-1]) continue;

      row[i]=j; col[j]=Dpos[i+j]=Dneg[i-j+N-1]=NOT_FREE;

      recursive(i+1);

      row[i]=col[j]=Dpos[i+j]=Dneg[i-j+N-1]=FREE;
    }
    
  }

  int main(){
    initia();
      for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
          X[i][j]=false;
        }
      }

     int k; cin >> k;
    for(int i=0;i<k;i++){
      int r,c; cin >> r>> c;
      X[r][c]=true;
    }

    recursive(0);

    return 0;
  }



Measured memory_bytes: 3108
#include<stdio.h>
#include<string.h>
int main(){
  char s[201];
  int i,ans;
  scanf("%s",s);
  int len=strlen(s);
  for(i=len-2; i>0; i-=2){
    if(strncmp(s,s+i/2,i/2)==0){
      ans=i;
      break;
    }
  }

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdlib.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define INF 1e17
#define pi 3.1415926535897932384626433832795028841971

#define MAX 1000005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,sum=0,ans=0,temp,t;
    cin >> a >> b;
    ans=a*(a-1)/2;
    ans+=(b*(b-1))/2;
    cout << ans;
    
    
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string S, T="CODEFESTIVAL2016";
  ll ans=0;
  cin >> S;
  rep(i, 16) if(S[i]!=T[i]) ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 256
/*
 *
 * Author: Hamkor
 *
 */

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(1), cin.tie(0), cout.tie(0);
	int a,b; cin>>a>>b;
	if (a>=13)cout<<b;
	else if (a>=6)cout<<b/2;
	else cout<<0;
	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
const int mod = 1000000007;
long long fat[maxn], ifat[maxn], tri[maxn];
long long bin(long long x){
  return x * (x + 1) / 2;
}
long long xp(long long a, long long b){
  a %= mod;
  long long r = 1;
  for(; b ; b >>= 1, a = (a * a) % mod) if(b & 1) r = r * a % mod;
  return r;
}
long long a[maxn];
int main(){
  fat[0] = 1;
  for(int e = 1; e < maxn; e++) fat[e] = e * fat[e - 1] % mod;
  ifat[maxn - 1] = xp(fat[maxn - 1], mod - 2);
  for(int e = maxn - 2; e >= 0; e--) ifat[e] = (e + 1) * ifat[e + 1] % mod;
  int n;
  cin >> n;
  for(int e = 0; e < n; e++){
    cin >> a[e];
  }
  for(int e = 0; e <= n; e++) tri[e] = fat[n] * xp(bin(e), mod - 2) % mod;
  long long ans = 0;
  long long sum = 0;
  for(int e = 0; e < n - 1; e++){
    sum += a[e];
    sum %= mod;
    long long cof = sum * fat[n] % mod;
    cof *= xp(e + 2, mod - 2);
    cof %= mod;
    ans += cof;
    ans %= mod;
  }
  sum = 0;
  for(int e = n - 1; e > 0; e--){
    sum += a[e];
    sum %= mod;
    long long cof = sum * fat[n] % mod;
    cof *= xp(n - e + 1, mod - 2);
    cof %= mod;
    ans += cof;
    ans %= mod;
  }
  // cout << ans << endl;

  int l = 1, r = n - 2;
  long long trit = 0;
  for(int e = l; e <= r; e++){
    trit += tri[e + 1];
    trit %= mod;
  }
  long long big = trit;
  for(int e = 1; e < n - 1; e++){
    long long cof = a[e] * trit % mod;
    ans += cof;
    ans %= mod;
    big += mod - tri[r + 1];
    big %= mod;
    big += mod - tri[l + 1];
    big %= mod;
    trit += big;
    trit %= mod;
    l++;
    r--;
  }
  for(int e = 0; e < n; e++){
    long long cof = a[e] * fat[n] % mod;
    ans += cof;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
//                    #include <ext/pb_ds/assoc_container.hpp>
//                    #include <ext/pb_ds/tree_policy.hpp>

                    using ll = long long;
                    using ld = long double;
                    #define rep(i, a, n) for(ll i = (a); i < (n); i++)
                    #define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
                    #define F first
                    #define S second
                    #define maxx(a, b) a = max(a, b)
                    #define minn(a, b) a = min(a, b)
                    #define db(x) cerr << #x << " = " << x << endl
                    #define N 1111111
                    #define mod 1000000007
                    #define rt return
                    #define inf 1234567891123456789ll

                    using namespace std;
                    random_device rd;
                    mt19937 mt(rd());
//                    using namespace __gnu_pbds;
//
//                    typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

                    ll modlaber(ll a, ll m = mod)
                    {
                        rt ((a+m)%m+m)%m;
                    }

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

                        int n; cin>>n;
                        string s; cin>>s;
                        rep(i,0,min(n,int(s.length())))
                            cout<<s[i];

                        if(s.length() > n)
                            cout<<"...";

                        rt 0;
                    }























Measured memory_bytes: 3660
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int n = s[0];

	bool ans = false;

	switch (n) {
	case(1):
		ans = true;
		break;

	case(10):
		ans = true;
		break;

	case(12):
		ans = true;
		break;

	case(14):
		ans = true;
		break;

	case(15):
		ans = true;
		break;

	case(16):
		ans = true;
		break;

	case(18):
		ans = true;
		break;

	case(2):
		ans = true;
		break;

	case(20):
		ans = true;
		break;

	case(21):
		ans = true;
		break;

	case(24):
		ans = true;
		break;

	case(25):
		ans = true;
		break;

	case(27):
		ans = true;
		break;

	case(28):
		ans = true;
		break;

	case(3):
		ans = true;
		break;

	case(30):
		ans = true;
		break;

	case(32):
		ans = true;
		break;

	case(35):
		ans = true;
		break;

	case(36):
		ans = true;
		break;

	case(4):
		ans = true;
		break;

	case(40):
		ans = true;
		break;

	case(42):
		ans = true;
		break;

	case(45):
		ans = true;
		break;

	case(48):
		ans = true;
		break;

	case(49):
		ans = true;
		break;

	case(5):
		ans = true;
		break;

	case(54):
		ans = true;
		break;

	case(56):
		ans = true;
		break;

	case(6):
		ans = true;
		break;

	case(63):
		ans = true;
		break;

	case(64):
		ans = true;
		break;

	case(7):
		ans = true;
		break;

	case(72):
		ans = true;
		break;

	case(8):
		ans = true;
		break;

	case(81):
		ans = true;
		break;

	case(9):
		ans = true;
		break;

	default:
		ans = false;
		break;
	}

	if (ans) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  constexpr ll SIZE=1ll<<10;
  constexpr ll MAXN=1ll<<18;
  constexpr ll MAXW=100010;

  std::vector<ll> v(MAXN-1,0),w(MAXN-1,0);
  rep(i,0,n)std::cin>>v[i]>>w[i];

  std::vector<std::vector<ll>> dp(SIZE-1,std::vector<ll>(MAXW,0));

  rep(i,w[0],MAXW)dp[0][i]=v[0];

  rep(i,1,SIZE-1){
    rep(j,0,w[i])dp[i][j]=dp[(i-1)/2][j];
    rep(j,w[i],MAXW)dp[i][j]=std::max(dp[(i-1)/2][j],dp[(i-1)/2][j-w[i]]+v[i]);
  }

  ll q;
  std::cin>>q;

  using P=std::pair<ll,ll>;

  while(q--){
    ll a,l;
    std::cin>>a>>l;
    a--;

    if(a<SIZE-1){
      std::cout<<dp[a][l]<<"\n";
      continue;
    }

    std::vector<P> tmp(1,{0,0});
    while(a>=SIZE-1){
      ll m=tmp.size();
      rep(i,0,m){
        if(tmp[i].first+w[a]<=l)tmp.emplace_back(tmp[i].first+w[a],tmp[i].second+v[a]);
      }
      a=(a-1)/2;
    }

    ll ans=0;
    for(const auto& e:tmp){
      chmax(ans,e.second+dp[a][l-e.first]);
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}


Measured memory_bytes: 810256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

int main() {

	int A, B;
	cin >> A >> B;

	if (A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double N;cin>>N;
  int ans=0;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  double ave=accumulate(a.begin(),a.end(),0)/N;
  for(int i=0;i<N;i++)
    if(abs(a.at(ans)-ave)>abs(a.at(i)-ave)) ans=i;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	m := map[string]bool{}
	for _, c := range s {
		m[string(c)] = true
	}
	if m["N"] == m["S"] && m["E"] == m["W"] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1852
#include "bits/stdc++.h"

using namespace std;
int N, Q;
vector<int> c;

static void solve()
{
  cin >> N >> Q;
  c.resize(N);
  for(int i = 0; i < N; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  while(Q--) {
    int q;
    cin >> q;
    int ans = 0;
    auto s = c.begin();
    int now = 0;
    while (s != c.end()) {
      now += q;
      if (c[0] == now) continue;
      s = lower_bound(s, c.end(), now);
      ans = max(ans, *(s - 1) % q);
    }
    cout << ans << "\n";
  }
}

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

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

int main(){
	int n;
	cin >> n;
	
	int ans=1e9;
	for(int i=0; i<n; i++){
		int a, count=0;
		cin >> a;
		while(a%2==0){
			a /= 2;
			count++;
		}
		ans = min(ans, count);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
<>=~$";@a=map[glob],<>;for$b(0..7){$s=0;$s+=$_ for(sort{$b<=>$a}map{$t=0;$t+=$b>>$i++%3&1?$_:-$_ for@$_;$t}@a)[0..$'-1];$s<$\or$\=$s}print

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

int result(int a[], int n){  
  
    sort(a, a+n);   
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( a[l] + a[r] > a[i]){ 

                count += r - l ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    return count;
} 

int main(){
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int res = result(a, n);
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll,ll>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

const int mod = INF+7;
int main(){
    int n,m;cin>>n>>m;
    VEC(ll,a,n);
    sort(ALL(a));
    priority_queue<P>pq;
    rep(i,m){
        ll b,c;cin>>b>>c;
        pq.emplace(c,b);
    }
    rep(i,n){
        if(pq.empty())break;
        P p = pq.top();pq.pop();
        if(p.first>a[i]){
            a[i] = p.first;
            p.second--;
        }
        else break;
        if(p.second>0)pq.emplace(p.first,p.second);
    }
    ll res = 0;
    rep(i,n)res += a[i];
    cout<<res<<endl;
}



Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  ll n,c;
  sl(n); sl(c);
  ll color[c+1][c+1];
  for(ll i=1;i<=c;i++){
    for(ll j=1;j<=c;j++){
      sl(color[i][j]);
    }
  }
  std::vector<ll> v[3];
  ll arr[n+1][n+1];
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      sl(arr[i][j]);
      v[(i+j)%3].push_back(arr[i][j]);
    }
  }
  ll dp[3][c+1];
  for(ll j=1;j<=c;j++){
    ll t = 0;
    for(ll k=0;k<v[0].size();k++){
      if(j!=v[0][k]){
        t+=color[v[0][k]][j];
      }
    }
    dp[0][j]=t;
  }
  for(ll j=1;j<=c;j++){
    ll t = 0;
    for(ll k=0;k<v[1].size();k++){
      if(j!=v[1][k]){
        t+=color[v[1][k]][j];
      }
    }
    dp[1][j]=t;
  }
  for(ll j=1;j<=c;j++){
    ll t = 0;
    for(ll k=0;k<v[2].size();k++){
      if(j!=v[2][k]){
        t+=color[v[2][k]][j];
      }
    }
    dp[2][j]=t;
  }
  // for(ll i=0;i<3;i++){
  //   for(ll j=1;j<=c;j++){
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  ll ans = 1e18;

  for(ll i=1;i<=c;i++){
    ll t1 = dp[0][i];
    // cout << "i is " << i << t1 << endl;
    for(ll j=1;j<=c;j++){
      if(i==j){
        continue;
      }
      else{
        ll t2 = t1+dp[1][j];
        // cout << "j is " << j << t2 << endl;
        for(ll k=1;k<=c;k++){
          if(j==k || k==i){
            continue;
          }
          else{
            ll t3=t2+dp[2][k];
            // cout << "k is " << k << t2 << endl;
            ans = min(ans,t3);
          }
        }
      }
    }
  }
  printf("%lld\n",ans);

}


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

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

typedef long long int ll;


int main(void) {
	
	char S[51];
	int N;
	
	sca(N);
	scanf("%s", S);
	int count = 0;
	rep(i, strlen(S)-2) {
		if (S[i] == 'A'&&S[i + 1] == 'B'&&S[i + 2] == 'C') {
			count++;
		}
	}
	v_pri(count);

	return 0;
}


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


int main(){
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	//freopen("input.txt","r",stdin);

	int n,m;
	cin>>n>>m;
	int arr[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum += arr[i];
	}

	int value = ceil(sum  / (4.0*m));
	
	int count = 0;
	for(int i=0;i<n;i++)
		if(arr[i] >= value)
			count++;

	if(count >= m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <limits.h>

int main(void){
    
    char ch,i;
    int n[26] = {0};
    int k = 0;
    
    while(scanf("%c",&ch) != EOF){
        ch = tolower(ch);
        for(i = 'a'; i <= 'z'; i++){
            if(ch == i){
                n[ch - 'a'] += 1;
                break;
            }
        }
    }
    for(k = 0; k < 26; k++) printf("%c : %d\n",'a'+k,n[k]);
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	int n;cin>>n;
	
	int a[n][3];
	int dp[n][3];
	
	for(int i=0;i<n;i++)
	for(int j=0;j<3;j++)
	cin>>a[i][j];
	
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
		}
	}
	
	cout << max({ dp[n-1][0] , dp[n-1][1] , dp[n-1][2] }) << endl;
	
	
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string x;
	while(getline(cin,x))
	{
		sort(x.begin(),x.end());
		int flag=1;
		for(int i=0;i<x.size();i++)
		{
			if(x[i]==x[i+1])
			{
			flag=0;
			break;
			}
		}
		if(flag)
		{
			cout<<"yes\n";
		}
		else
		cout<<"no"<<endl;
	}
}


Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]

hs = [int(x) for x in input().split()]

dp = [0] * n

for i in range(1, min(k,n)):
	dp[i] = min([dpj + abs(hs[i] - hj) for dpj, hj in zip(dp[:i], hs[:i])])

if k < n:
	for i in range(k, n):
		dp[i] = min([dpj + abs(hs[i] - hj) for dpj, hj in zip(dp[i-k:i], hs[i-k:i])])

print(dp[-1])

Measured memory_bytes: 14052
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by Harry on 5/10/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for(int i=0; i<n; i++){
            nums[i] = scanner.nextInt();
        }
        Set<Integer> set = new HashSet<>();
        boolean isPair = true;
        boolean isSet = false;
        int gcd = nums[0];
        for(int i=0; i<n; i++){
            if(!isSet){
                gcd = gcd(gcd, nums[i]);
                if(gcd==1){
                    isSet = true;
                }
            }
            if(isPair){
                for(int j=1; j*j<=nums[i]; j++){
                    if(nums[i]%j==0){
                        int o = nums[i]/j;
                        if(j!=1 && set.contains(j)){
                            isPair = false;
                            break;
                        }
                        if(o!=1 && set.contains(o)){
                            isPair = false;
                            break;
                        }
                        if(j!=1) set.add(j);
                        if(o!=1) set.add(o);
                    }
                }
            }
        }

        if(isPair){
            System.out.println("pairwise coprime");
        }
        else if(isSet){
            System.out.println("setwise coprime");
        }
        else{
            System.out.println("not coprime");
        }
    }

    private static int gcd(int a, int b){
        int min = Math.min(a, b);
        int max = Math.max(a, b);
        if(min==0){
            return max;
        }
        return gcd(max%min, min);
    }
}


Measured memory_bytes: 63620
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a,b,c,d;
	cin >> a >> b >> c;
	if (c>=a && c<=b)
	cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll min(ll a, ll b) {
  return a < b ? a : b;
}

ll max(ll a, ll b) {
  return a > b ? a : b;
}

int main(void) {
  ll i, j, k, h, w, ans;
  scanf("%ld%lld", &h, &w);
  if(!(h % 3) || !(w % 3)) {
    printf("0");
    return 0;
  }
  ans = min(h, w);
  for(i = 1; i < w; ++i) {
    ans = min(ans, max(i * h, (w - i) * ((h + 1) / 2)) - min(i * h, (w - i) * (h / 2)));
  }
  for(i = 1; i < h; ++i) {
    ans = min(ans, max(i * w, (h - i) * ((w + 1) / 2)) - min(i * w, (h - i) * (w / 2)));
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
// 179

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>
#include <utility>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    int n, buf1, buf2;
    bool a1 = false, a2 = false, a3 = false, ans = false;
    cin >> n;
    vector<bool> v(n);
    for(int i=0; i<n; i++){
        cin >> buf1 >> buf2;
        if(buf1 == buf2) v.at(i) = true;
        else v.at(i) = false;
    }
    for(int i=2; i<n; i++){
        if(v.at(i-2) && v.at(i-1) && v.at(i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
# solution
import io

n = int(input())
m = [input() for _ in range(n)]

report = 'Yes'
if n!=len(set(m)):
  report ='No'
else:
  for i in range(n-1):
    if m[i][-1]!=m[i+1][0]:      
      report='No'
      break
print(report)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
double f(ll n) {
    ll s = 0;
    for (ll n_ = n; n_; n_ /= 10) s += n_ % 10;
    return s / (1.0 * n);
}

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

    ll a = 1;
    ll b = 0;
    
    for (int i = 1; K; ) {
        cout << b + a * i << endl;
        K--;

        if (f(b + a * (i + 1)) >= f(b * 10 + 9 + a * 10 * (i / 10 + 1))) {
            i++;
        }
        else {
            b = b * 10 + 9;
            a = a * 10;
            i = i / 10 + 1;
        }
    }
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
int a[100050];
//17//42
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int pre=a[0];
    int ans=0,tt=1;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            tt++;
        }
        else{
            ans+=tt/2;
            tt=1;
        }
    }
    ans+=tt/2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
#define MOD 1000000007

void Fast_IO(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	freopen("debug.out","w",stderr);
	#endif
}

int main(){
	Fast_IO();
	ll n,m,k,i,x,c=0,y,ans=0,lim1,lim2;
	cin>>n>>m>>k;
	ll a[n],b[m];
	vector <ll> temp1,temp2;

	queue <ll> q1;
	queue <ll> q2;

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

	for(i=0;i<m;i++)
		cin>>b[i];

	for(i=0;i<m;i++){
		if(c+b[i]<=k){
			c=c+b[i];
		}
		else{
			lim2=i;
			break;
		}
	}
	c=0;
	for(i=0;i<n;i++){
		if(c+a[i]<=k){
			temp1.pb(a[i]);
			c=c+a[i];
		}
		else{
			lim1=i;
			break;
		}
	}

	reverse(temp1.begin(),temp1.end());

	for(i=0;i<(ll)temp1.size();i++)
		q1.push(temp1[i]);

	x=temp1.size();
	ans=x;
	if(x>0){
		for(i=0;i<lim2;i++){
			if(c+b[i]<=k){
				q1.push(b[i]);
				c+=b[i];
				x++;
			}
			else{
				while(c+b[i]>k){
					y=q1.front();
					q1.pop();
					c-=y;
					x--;
				}
				q1.push(b[i]);
				c+=b[i];
				x++;
			}
			if(ans<x)
				ans=x;
		}
	}
	c=0;
	for(i=0;i<m;i++){
		if(c+b[i]<=k){
			temp2.pb(b[i]);
			c=c+b[i];
		}
		else
			break;
	}

	reverse(temp2.begin(),temp2.end());

	for(i=0;i<(ll)temp2.size();i++)
		q2.push(temp2[i]);

	x=temp2.size();
	if(ans<x)
		ans=x;
	if(x>0){
		for(i=0;i<lim1;i++){
			if(c+a[i]<=k){
				q2.push(a[i]);
				c+=a[i];
				x++;
			}
			else{
				while(c+a[i]>k){
					y=q2.front();
					q2.pop();
					c-=y;
					x--;
				}
				q2.push(a[i]);
				c+=a[i];
				x++;
			}
			if(ans<x)
				ans=x;
		}
	}

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

Measured memory_bytes: 14248
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <algorithm>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s<t){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256