akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key )
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key )
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 26748
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int H_MAX = 410;
const int W_MAX = 410;
int H, W;
string S[H_MAX];

int b, w;
bool visited[H_MAX][W_MAX];
const int di[4] = {0, 0, -1, 1};
const int dj[4] = {-1, 1, 0, 0};

bool valid(int i, int j) { return (0 <= i && i < H && 0 <= j && j < W); }

void dfs(int i, int j)
{
    visited[i][j] = true;

    if (S[i][j] == '#') {
        b++;
    } else {
        w++;
    }

    for (int d = 0; d < 4; d++) {

        int ni = i + di[d];
        int nj = j + dj[d];
        if (!valid(ni, nj) || visited[ni][nj] || S[i][j] == S[ni][nj]) {
            continue;
        }

        dfs(ni, nj);
    }
}

int main()
{
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }

    long result = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (visited[i][j]) {
                continue;
            }

            b = w = 0;
            dfs(i, j);
            result += b * w;
        }
    }
    cout << result << '\n';

    return 0;
}


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

int main() {
  int n;ll k;
  cin >> n >> k;
  vector<P>d(n);
  rep(i,n) cin >> d[i].first >> d[i].second;
  sort(d.begin(),d.end());
  ll sum = 0;
  rep(i,n){
    sum += d[i].second;
    if(sum >= k){
      cout << d[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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



int main() {

	ll A, B;
	cin >> A >> B;
	ll a=gcd(A, B);

	cout << (A*B)/a << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            primes = new Dictionary<long, long>();
            for (var i = 2; i <= N; ++i)
                primefactorize(i);
            var _75 = primes.Count(p => p.Value >= 74);
            var _25 = primes.Count(p => p.Value >= 24);
            var _15 = primes.Count(p => p.Value >= 14);
            var _5 = primes.Count(p => p.Value >= 4);
            var _3 = primes.Count(p => p.Value >= 2);
            var _25x3 = Max(0, _25 * (_3 - 1));
            var _15x5 =Max(0, _15 * (_5 - 1));
            var _5x5x3 = Max(0, _5 * (_5 - 1) / 2 * (_3 - 2));
            var ans = _75 + _25x3 + _15x5 + _5x5x3;
            WriteLine(ans);
            //Out.Flush();
        }
        static Dictionary<long, long> primes;
        static void primefactorize(long n)
        {
            for (long i = 2; i * i <= n; ++i)
            {
                while (n % i == 0)
                {
                    if (!primes.ContainsKey(i)) primes[i] = 0;
                    ++primes[i];
                    n /= i;
                }
            }
            if (n != 1)
            {
                if (!primes.ContainsKey(n)) primes[n] = 0;
                ++primes[n];
            }
        }
    }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int x;
    cin >> x;
    int ans = 0;
    if(x == 1) cout << 1 << endl;
    else{
        for(int i = 2; i*i <= x; i++){
            int v = i;
            while(v * i <= x){
                v *= i;
            }
            if(ans < v) ans = v;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(5):
    a.append(int(input()))
k = int(input())

flg = 0
for i in range(5):
    for j in range(5):
        if abs(a[i] -a[j]) > k:
            flg = 1
            break
if flg:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321



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

	for(ll i = 2 ; i/2 <= max(X,Y) + 10; i += 2 ){
		ll tmp = i * C;
		ans = min(ans, tmp + A * max((X-i/2),0LL) + B * max(0LL,(Y-i/2)) );
	}

	cout << ans << endl;

}


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

int main() {
  
  int N, sum, y0, y1;
  cin >> N;
  sum = 0;
  y0 = 0;
  y1 = 0;
  vector<int> x(N);
  
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    sum += x.at(i);
  }
  
  int ave0, ave1;
  ave0 = sum / N ;
  ave1 = sum / N + 1;
  
  for (int i = 0; i < N; i++) {
    y0 += (x.at(i) - ave0) * (x.at(i) - ave0);
    y1 += (x.at(i) - ave1) * (x.at(i) - ave1);
  }
  
  if (y0 <= y1) {
    cout << y0 << endl;
  }
  
  else {
    cout << y1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n=2;
	vector<int> p[2];
	int ans[2];
	for(int i=0;i<n;++i){
		for(int j=0,point;j<10;++j){
			cin>>point;
			p[i].push_back(point);
		}
		sort(p[i].begin(),p[i].end(),greater<int>());
		ans[i]=p[i][0]+p[i][1]+p[i][2];
	}
	for(int i=0;i<n;++i)cout<<ans[i]<<((i==n-1)?"\n":" ");
	return 0;
}

Measured memory_bytes: 0
N=int(input())

a = input().split()

center=a[0]


tail = ""
head = ""
if N>=2:
    tail =a[2:][::2]
    head = a[1:][::2]

if N==1:
    print(center)
elif N==2:
    print(" ".join(a))
elif N%2==0:
    print(" ".join(head[::-1])+" "+ center +" "+" ".join(tail))
else:
    print(" ".join(tail[::-1])+" "+ center +" "+" ".join(head))


Measured memory_bytes: 26900
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		for(int j=0;j<i;j++){
		  int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if((a*a + b*b == c*c) || (b*b + c*c == a*a) || (c*c + a*a == b*b)){
    	  System.out.println("YES");
      }else{
    	  System.out.println("NO");
      }
		}
	}
}


Measured memory_bytes: 32120
while 1:
  m,n=map(int,input().split())
  if m+n==0: break
  
  us=["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"]
  
  res=""
  for i in range(0,len(str(m**n)),4):
    x=m**n//(10**i)%10000
    if x>0: res=str(x)+us[i//4]+res
  print(res)

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
int n,ans,nn,ans1;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n&&(i*j)<n;j++)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL INF=300000000;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    string a,b;
    cin>>a>>b;
    int ans=0;
    if(a.size()>b.size()){
        ans=1;
        cout<<"GREATER"<<endl;

    }
    else if(a.size()<b.size()){
        ans=2;
        cout<<"LESS"<<endl;
    }
    else for(int i=0;i<a.size();i++){
        if(a[i]>b[i]) {
         cout<<"GREATER"<<endl;
         ans=1;
         break;
        }else if(a[i]<b[i]){
            ans=2;
            cout<<"LESS"<<endl;
        break;
        }

    }
        if(ans==0)cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
# Technique often used
# enumerate: for i, a in enumerate(a_list):
# Functional Programming: filter, map, reduce

# naming conventions
# if [s_1, s_2, s_3, ..., s_k] then I name this list sk
# if [[s_11, s_12, ..., s_1k], ..,[s_j1, s_j2, ..., s_jk] then I name this list sjk
# if something strange in list then I add _ to list's name (ex:sjk_)

# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same words: Ctrl+Shift+l

from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html#itertools.combinations
# https://docs.python.org/ja/3/library/itertools.html#itertools.permutations
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
import heapq
import copy
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
def gcds(a):
    if len(a)==1:
        return a[0]
    else:
        element = gcd(a[0], a[1])
        if len(a)==2:return(element)
        else:
            for i in range(2,n):
                element=gcd(element,a[i])
            return(element)

is_test = False
def debug_print(a,comments="",is_test=is_test):
    # debug_print([]) => []
    # debug_print("") => 
    # debug_print(a, "a is") => "a is:" print(a)
    if not is_test:
        pass
    elif not comments and a is None:
        print("")
    elif not comments:
        print(a)
    else:
        print(comments,":",a)

# setting the inputs
if is_test:
    n,k = [6, 8]
    vn = [-6, -100, 50, -2, -5, -3]
    # vn = [-10, 8, 2, 1, 2, 6]
else:        
    n,k = map(int,input().split())
    vn = [int(i) for i in input().split()]

hp = []
ans = 0
for i in range(min(k,n)+1):
    if i == 0:
        pass
    else:
        heapq.heappush(hp,vn[i-1])
    hpj = copy.deepcopy(hp)
    for j in range(min(k,n)-i+1):
        if j == 0:
            pass
        else:
            heapq.heappush(hpj,vn[n-j])
        hpjj = copy.deepcopy(hpj)
        debug_print(hpjj)
        counter = 0
        if i==0 and j==0:
            pass
        else:            
            while hpjj[0] < 0 and counter < k-i-j:
                counter += 1
                heapq.heappop(hpjj)
                if len(hpjj)==0:
                    break
        ans = max(ans, sum(hpjj))

print(ans)


Measured memory_bytes: 3564
#include<stdio.h>
#include<stdlib.h>
int MONTH[]={31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
	int i;
	int month,date,days,Wday;
	while(scanf("%d %d",&month,&date)){
		if(month==0) break;
		days=0;
		for(i=0;i<month-1;i++){
			days+=MONTH[i];
		}
		days+=date;
		Wday=days%7;
		if(Wday==0) printf("Wednesday\n");
		else if(Wday==1) printf("Thursday\n");
		else if(Wday==2) printf("Friday\n");
		else if(Wday==3) printf("Saturday\n");
		else if(Wday==4) printf("Sunday\n");
		else if(Wday==5) printf("Monday\n");
		else printf("Tuesday\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

const int iNumberOfRooms = 10;
const int iNumberOfFloors = 3;
const int iNumberOfBuildings = 4;

class info {
public:
	int mb, mf, mr, mv;
	info(int b, int f, int r, int v)
	{
		mb = b;
		mf = f;
		mr = r;
		mv = v;
	}
};

class house {
private:
	int npeople[iNumberOfBuildings][iNumberOfFloors][iNumberOfRooms];
public:

	house()
	{
		memset(npeople, 0, sizeof(npeople));
	}

	void regInout(int b, int f, int r, int v)
	{
		npeople[b - 1][f -1][r - 1] += v;
	}

	void regInout(info &inf)
	{
		npeople[inf.mb - 1][inf.mf - 1][inf.mr - 1] += inf.mv;
	}

	int getPplInARoom(int b, int f, int r)
	{
		return npeople[b][f][r];
	}
};



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

	house h;

	vector<info> vInfo;

	for (int i = 0; i < n; i++)
	{
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		info inf(b, f, r, v);
		vInfo.push_back(inf);
	}

	for (int i = 0; i < vInfo.size(); i++)
	{
		h.regInout(vInfo.at(i));
	}

	for (int i = 0; i < iNumberOfBuildings; i++)
	{
		for (int j = 0; j < iNumberOfFloors; j++)
		{
			for (int k = 0; k < iNumberOfRooms; k++)
			{
				cout << " " << h.getPplInARoom(i, j, k);
			}
			cout << endl;
		}
		if ( i != iNumberOfBuildings - 1)
			cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
vector<vector<ll>> multiply(vector<vector<ll>>A,vector<vector<ll>>B)
{
    int n = A.size();
    vector<vector<ll>> res(n,vector<ll>(n,0));

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            for(int x=0;x<n;x++)
                res[i][j] = (res[i][j]+ A[i][x]*B[x][j])%(1000000007);
        }
    
    return res;

}
vector<vector<ll>>power(vector<vector<ll>>mat,ll exp)
{
    if(exp == 1)
        return mat;
    
    vector<vector<ll>> res = power(mat,exp/2);
    if(exp&1)
        return multiply(multiply(mat,res),res);
    return multiply(res,res);
}
ll solve(vector<vector<ll>>&adj,ll k,int n)
{
    vector<vector<ll>>ak = power(adj,k);
    ll ans =0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
         ans = (ans+ak[i][j])%((ll)1000000007);
    
    return ans;

}
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>>adj(n,vector<ll>(n));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>adj[i][j];
    
    cout<<solve(adj,k,n);

    return 0;
}

Measured memory_bytes: 4904
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextLong())
                .collect(Collectors.toList());

        if (n % 2 == 0) {
            final long[][] dpTable = new long[n][2];
            dpTable[0][0] = list.get(0);
            dpTable[1][1] = list.get(1);
            for (int i = 2; i < n; i++) {
                final long tmp = list.get(i);
                dpTable[i][0] = dpTable[i - 2][0] + tmp;
                if (i >= 3) {
                    dpTable[i][1] = max(dpTable[i - 2][1], dpTable[i - 3][0]) + tmp;
                }
            }

            System.out.println(max(dpTable[n - 1][1], dpTable[n - 2][0]));
            return;
        }

        final long[][] dpTable = new long[n][3];
        dpTable[0][0] = list.get(0);
        dpTable[1][1] = list.get(1);
        dpTable[2][2] = list.get(2);
        for (int i = 2; i < n; i++) {
            final long tmp = list.get(i);
            dpTable[i][0] = dpTable[i - 2][0] + tmp;
            if (i >= 3) {
                dpTable[i][1] = max(dpTable[i - 2][1], dpTable[i - 3][0]) + tmp;
            }
            if (i >= 4) {
                dpTable[i][2] = max(dpTable[i - 2][2], dpTable[i - 3][1], dpTable[i - 4][0]) + tmp;
            }
        }

        System.out.println(max(dpTable[n - 1][2], dpTable[n - 2][1], dpTable[n - 3][0]));
    }

    private static long max(long... numbers) {
        return Arrays.stream(numbers).max().orElseThrow();
    }
}


Measured memory_bytes: 77772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int a[5][205], dp[5][105];

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

Measured memory_bytes: 3632
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;
//int input........
template <typename T> inline void readline(T &n) {n = 0; int f = 1; register int ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
// long long input........
template <typename T> inline void readlinel(T &n) {n = 0; long long f = 1; register long long ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readlinel(T &n, TT &m) { readlinel(n); readlinel(m); }
template <typename T, typename TT, typename TTT> inline void readlinel(T &n, TT &m, TTT &l) { readlinel(n, m); readlinel(l);}
//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
int dx[8]= {1,0,-1,0,-1,-1,1,1};int dy[8]= {0,1,0,-1,-1,1,-1,1}; int tc = 1;
#define pb  push_back
#define mp make_pair
#define ll  long long int
#define endl  '\n';
#define happy cin.tie(0);
#define coding ios::sync_with_stdio(false);
#define Test printf("Case %d: ",tc++);
void print(int n){printf("%d\n", n);}
void print(int n,int m){printf("%d ",n);printf("%d ",m);}
void print(int n,int m,int k){printf("%d ",n);printf("%d ",m);printf("%d ",k);}
void print(ll n){printf("%I64d ", n);}
void print(ll n,ll m){printf("%I64d ",n);printf("%I64d ",m);}
void print(ll n,ll m,ll k){printf("%I64d ",n);printf("%I64d ",m);printf("%I64d ",k);}
#define   pr 	pair<int, int> 
#define   vpr 	vector<pr> 
#define   vi   	std::vector<int>
#define   vll  	std::vector<ll>
#define   map   std::map<string, int>
#define   all(n) n.begin(),n.end()
const int mod           = 1e9 + 7;
const int Inf           = (int)2e9 + 5;
const ll  Lnf           = (ll)2e18 + 5;
const int N             =2e5 + 5;
const int N1            = 1e5 + 5;
int dp[N][4];


int solve() 
{
	//happy coding
	int n;
	readline(n);
	int a,b,c;
	readline(a,b,c);
	dp[1][1] =a; dp[1][2] = b;dp[1][3] = c;
	for(int i=2;i<=n;i++){
		readline(a,b,c);
		dp[i][1] += a+max(dp[i-1][2],dp[i-1][3]);
		dp[i][2] += b+max(dp[i-1][1],dp[i-1][3]);
		dp[i][3] += c+max(dp[i-1][1],dp[i-1][2]);
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
	//print(n);endl;

	return 0;
	//error();
}
int main(){
	int test = 1;
	//readline(test);//(void)getchar();
	while (test--)solve();return 0;
}

Measured memory_bytes: 1792
/**
 *    author:  math2do
 *    created: 28.03.2020 17:40:15
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  vector <int> arr(n);
  for (int &val : arr) {
    cin >> val;
  }
  int up = k - arr[n - 1] + arr[0];
  int ans = up;
  for (int i = 0; i < n - 1; i++) {
    int gap = arr[i + 1] - arr[i];
    ans = max(ans, gap);
  }
  cout << k - ans << endl; 
  return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int h,w; cin >> h >> w;
  string s[100];
  for(int i = 0; i < h; ++i)cin >> s[i];
  bitset<100> bsh,bsw;
  for(int i = 0; i < h; ++i){
    bool f = true;
    for(int j = 0; j < w; ++j)f &= s[i][j] == '.';
    bsh[i] = f;
  }
  for(int i = 0; i < w; ++i){
    bool f = true;
    for(int j = 0; j < h; ++j)f &= s[j][i] == '.';
    bsw[i] = f;
  }
  for(int i = 0; i < h; ++i){
    if(bsh[i])continue;
    for(int j = 0; j < w; ++j){
      if(bsw[j])continue;
      cout << s[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		int m=Integer.valueOf(cmd[1]);
		int x=Integer.valueOf(cmd[2]);
		int[][] arr=new int[n][m];
		int[] cost=new int[n];
		for(int i=0;i<n;i++)
		{
			cmd=br.readLine().split(" ");
			cost[i]=Integer.valueOf(cmd[0]);
			for(int j=1;j<=m;j++)
			{
				arr[i][j-1]=Integer.valueOf(cmd[j]);
			}
		}
		int min=1000000000;
		for(int i=1;i<=Math.pow(2,n);i++)
		{
			int cnt=0;
			int cos=0;
			for(int j=0;j<n;j++)
			{
				if(((1<<j)&i)!=0)
					cos=cos+cost[j];
			}
			for(int j=0;j<m;j++)
			{
				int d=0;
				for(int k=0;k<n;k++)
				{
					if(((1<<k)&i)!=0)
						d+=arr[k][j];
				}
				if(d>=x)
					cnt++;
			}
			if(cnt==m && min>cos)
				min=cos;
		}
		if(min==1000000000)
			System.out.println(-1);
		else
		System.out.println(min);
	}

}


Measured memory_bytes: 33340
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll x,a; cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > stores(n);
  for(int i=0; i<n; ++i){
   long long a, b;
   cin >> a >> b;
   stores[i] = {a, b};
  } 
  sort(stores.begin(), stores.end(),[](const pair<long long, long long> &a, const pair<long long, long long> &b){
    return a.first < b.first;
  }
  );
  long long res = 0;
  int k = 0;
  while(m > 0){
   long long remove = min((long long)m, stores[k].second);
   m -= remove;
   res += stores[k].first*remove;
   ++k;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main()
{
  int n; 
  double x1,y1,x2,y2,x3,y3,a,b,c,ss,a2,b2,c2,s,qx,qy;
  scanf("%d",&n);
  for(;n--;)
    {
      scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
      a2=fabs((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
      b2=fabs((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
      c2=fabs((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
      a=sqrt(a2);
      b=sqrt(b2);
      c=sqrt(c2);
      ss=(a+b+c)/2;
      s=sqrt(ss*(ss-a)*(ss-b)*(ss-c));
      qx=(a2*(b2+c2-a2)*x1+b2*(c2+a2-b2)*x2+c2*(a2+b2-c2)*x3)/(16*s*s);
      qy=(a2*(b2+c2-a2)*y1+b2*(c2+a2-b2)*y2+c2*(a2+b2-c2)*y3)/(16*s*s);
      printf("%.3f %.3f %.3f\n",qx,qy,(a*b*c/(4*s)));
      

    }
  return 0;
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, K;
    scan(N, K);
    auto S = readln.chomp;

    int ans = N - 1;
    int t;

    foreach (i ; 1 .. N) {
        if (S[i] != S[i - 1]) t++;
    }

    t = max(0, t - 2 * K);
    ans -= t;

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 508
from collections import defaultdict

def twosum(n):
  now = 1
  while n >= now:
    now *= 2
  return now - n
n = int(input())
a = sorted(list(map(int, input().split())))
d = defaultdict(int)
for i in a:
  d[i] += 1
ans = 0
for i in a[::-1]:
  d[i] -= 1
  find = twosum(i)
  if d[find] > 0 and d[i] >= 0:
    ans += 1
    d[find] -= 1
  else:
    d[i] += 1
print(ans)


Measured memory_bytes: 113492
#include <stdio.h>
typedef long long ll;
int H,W;

char board[52][52]; //0とH,Wの列はsentinel
int main(void){
    // Your code here!
    scanf("%d %d",&H,&W);
    char line[53];
    
    for(int y = 0; y <= H+1; y++){
        board[0][y] = board[W+1][y] = '.';
    }
    for(int x = 0; x <= W+1; x++){
        board[x][0] = board[x][H+1] = '.';
    }
    for(int y = 1; y <= H; y++){
        scanf("%s",line);
        for(int x = 1; x <= W; x++){
            board[x][y] = line[x-1];
        }
    }
    /*
    for(int y = 0; y <= H+1; y++){
        for(int x = 0; x <= W+1; x++){
            printf("%c",board[x][y]);
        }
        puts("");
    }*/
    for(int x = 1; x <= W; x++){
        for(int y = 1; y <= H; y++){
            if( board[x][y] == '#' &&
                board[x+1][y] == '.' && board[x-1][y] == '.'
             && board[x][y+1] == '.' && board[x][y-1] == '.'){
                puts("No");     
                             
                return 0;
             }
        }
    }
    puts("Yes");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int d;

int main(){
    vector<int> v;
    for(int i = 0; i < 3; i++){
        cin >> d;
        v.push_back(d);
    }

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

    cout << v[2]*10 + v[0] + v[1];


}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
i=61,c,f[],y,s,m;main(){for(;s?++f[y*12+*f+"=>?2J13IK<@V&"[--s]]:~scanf("%d,%d,%d",f,&y,&s)?s=s*4+1:++i<180?i%12>1?m=fmax(m,y=f[i]),y||++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
cnt = [0 for i in range(26)]
letters = "abcdefghijklmnopqrstuvwxyz"
str = open(0).read()
for c in str:
  for j in range(len(letters)):
    if c == letters[j] or c == letters[j].upper():
      cnt[j] += 1
      break
for i in range(26):
  print(letters[i], ":", cnt[i])


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int k; cin>>k;
	set<string> st;
	for(int i = 0; i < s.size(); i++){
		string t = "";
		for(int j = 0; j < k; j++){
			if(i + j >= s.size())break;
			t += s[i + j];
			st.insert(t);
		}
	}
	string ans;
	while(k--){
		ans = *st.begin();
		st.erase(ans);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N,T,A; cin>>N>>T>>A;
  int ans=-1;
  double min=1e9;
  for(int i=0;i<N;i++){
    int temp; cin>>temp;
    if(min>abs(A-(T-temp*0.006))){
      min=abs(A-(T-temp*0.006));
      ans=i+1;
    }
  }

  cout<<ans<<endl;

  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s[0]=='R') ans++;
  if(s[1]=='R') ans++;
  else if(s[2]=='R') max(ans,1);
  if(s[1]=='R'&&s[2]=='R') ans++;
  if(s=="SSR")ans=1;
  cout<<ans;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Chain Disappearance Puzzle
 */
public class Main {

	public static int W = 5;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int H = parseInt(line);
			if (H == 0) break;

			// init
			@SuppressWarnings("unchecked")
			List<Integer>[] board = new ArrayList[W];

			for (int i = 0; i < W; i++) {
				board[i] = new ArrayList<>();
			}

			for (int i = 0; i < H; i++) {
				String[] words = br.readLine().split(" ");
				for (int j = 0; j < W; j++) {
					board[j].add(0, parseInt(words[j]));
				}
			}

			// solve
			int point = 0;
			int height = H;
			boolean hasNext = true;

			while (hasNext) {

				hasNext = false;

				// chain
				for (int i = 0; i < height; i++) {
					int left = W, right = -1, stone = 0;
					for (int j = 1; j <= 3; j++) {
						if (board[j].get(i) != 0
								&& board[j].get(i) == board[j - 1].get(i)
								&& board[j].get(i) == board[j + 1].get(i)) {
							left = Math.min(left, j - 1);
							right = Math.max(right, j + 1);
							stone = board[j].get(i);
							hasNext = true;
						}
					}
					if (right - left >= 2) point += stone * (right - left + 1);
					for (int j = left; j <= right; j++) board[j].set(i, 0);
				}
				// drop down
				for (int i = 0; i < W; i++) {
					board[i].removeIf(x -> x == 0);
					height = Math.max(height, board[i].size());
				}
				for (int i = 0; i < W; i++) {
					while (board[i].size() < height) board[i].add(0);
				}
			}

			System.out.println(point);

		} //end while
	} //end main
}

Measured memory_bytes: 38020
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1144&lang=jp

#include <algorithm>
#include <queue>
#include <iostream>
using namespace std;

struct Point {
  int x,y;
};

void PrintP(Point P) {
  cerr << "(" << P.x << "," << P.y << ")";
}

struct Scene { // 「これから投球です」という局面
  Point now;
  int hit; // ヒット回数。hitの過去分詞はhit。
  Point broken[10]; // 壊れた壁
};

int W, H;
int c;
bool field[20][20];
Point start, goal;

const int d[4][2] = { {1,0}, {0,1}, {-1,0}, {0,-1} };

void init() {
  fill(&field[0][0], &field[0][0]+20*20, 0);
}

void make_field() {
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      scanf("%d", &c);
      if (c == 0) {
	field[j][i] = true;
      } else if (c == 2) {
	field[j][i] = true;
	start = { j , i };
      } else if (c == 3) {
	field[j][i] = true;
	goal = { j , i };
      }
    }
  }
}

bool in_field(Point p) {
  return ( 0 <= p.x & p.x < W && 0 <= p.y && p.y < H );
}

bool is_ice(Point p) {
  return field[p.x][p.y];
}

bool is_broken(Point p, Scene s) {
  bool ans = false;
  for(int i=0; i<s.hit; i++) {
    if (p.x == s.broken[i].x && p.y == s.broken[i].y) {
      ans = true;
      break;
    }
  }
  return ans;
}

bool valid(Point p, Scene s) {
  return (is_ice(p) || is_broken(p,s));
}

int run(Scene& s, int dir) { // 途中でゴール：0、壁にぶつかる：1、枠外：2。
  Point p;
  p = s.now;
  //PrintP(p);
  //cerr << "から" << dir << "方向に走る。" << endl;
  while (in_field(p) && valid(p, s)) {
    p = { p.x + d[dir][0], p.y + d[dir][1] };
    if (p.x == goal.x && p.y == goal.y) {
      //PrintP(p);
      //cerr << "にゴール。" << endl;
      return 0;
    }
  }
  // ゴールに到達しないで止まったら
  if (in_field(p)) { // フィールド内なら壁にぶつかった。
    s.broken[s.hit] = p;
    //PrintP(p);
    //cerr << "に当たった。" << endl;
    s.now = { p.x - d[dir][0], p.y - d[dir][1] };
    s.hit++;
    // cerr << s.hit;
    return 1;
  } else { // 外に出た。
    //cerr << "外に出た。" << endl;
    return 2;
  }
}

bool can_run(Scene s, int dir) { // dir方向に押し出せるか？ を判定する
  Point temp_point = { s.now.x + d[dir][0], s.now.y + d[dir][1] };
  return !in_field(temp_point) || valid(temp_point, s); // ここでin_fieldとvalidを分けておく必要がある。
}

void bfs() {
  queue<Scene> Q;
  Scene cur;
  int answer = -1;
  cur = { start, 0, {} };
  Q.push(cur);
  while (!Q.empty()) {
    cur = Q.front();
    // cerr << cur.hit;
    Q.pop();
    //cerr << "ヒット数" << cur.hit << endl;
    for (int i=0; i<4; i++) {
      Scene temp = cur; // curはfor内で使いまわすので破壊されると困る。
      if (can_run(temp,i)) {
	// cerr << temp.hit;
	int status = run(temp,i);
	switch (status) {
	case 0: // ゴール到達
	  answer = temp.hit+1;
	  goto stop;
	case 1: // 壁にぶつかったら
	  // cerr << temp.hit;
	  if (temp.hit < 10) { // 投球回数10回未満なら
	    Q.push(temp); // 投球し直すQueue行き
	  }
	  break;
	default:
	  break;
	}
      }
    }
  }
 stop:
  printf("%d\n", answer);
}

int main() {
  while (scanf("%d%d", &W, &H) != EOF && W && H) {
    init();
    make_field();
    bfs();
  }
}

Measured memory_bytes: 3424
#include<cstdio>
#define maxn 45
#define maxm 131072
#define mod 1000000007
int n,x,y,z,dp[maxn][maxm+5],ans;
int powmod(int a,int n)
{
	int res=1;
	while(n)
	{
		if(n&1) res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		n>>=1;
	}
	return res;
}
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	dp[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<maxm;j++)
			if(dp[i][j])
				for(int k=1;k<=10;k++)
				{
					int j1=((j<<k)+(1<<(k-1)))%maxm;
					if((j1&(1<<(x+y+z-1)))&&(j1&(1<<(y+z-1)))&&(j1&(1<<(z-1))))
						ans=1ll*(ans+1ll*dp[i][j]*powmod(10,n-i-1))%mod;
					else dp[i+1][j1]=(dp[i+1][j1]+dp[i][j])%mod;
				}
	printf("%d\n",ans);
}

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

int main(){
  int x,y,z;
  while(1){
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if( x > y ){
      z = x;
      x = y;
      y = z;
    }
 cout << x << " " << y << endl;
  }
}



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

int main() {
  double l;
  cin >> l;
  double x = l/3;
  double ans = pow(x,3);
  printf("%.10f\n", ans);
  return 0;
}

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

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

    for (int i=1; i<=n; i++) {
        ll ans = 0;
        for (int x=1; x<101; x++) {
            for (int y=1; y<101; y++) {
                ll p = 4*i-3*x*x-3*y*y-2*x*y;
                if (p > 0 && ((ll) sqrt(p))*((ll) sqrt(p)) == p && sqrt(p)-x-y > 1 && (((ll) sqrt(p))-x-y)%2 == 0) {
                    ans++;
                    // cout << i << " : " << x << " " << y << " " << (sqrt(p)-x-y)/2 << endl;
                }
            }
        }
        cout << ans << endl;
    }
        
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;
    if(A1+A2+A3>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	static int yono;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> al = new ArrayList<Integer>();
		int N = Integer.parseInt(sc.next());
		yono = N - 1;
		int M = sc.nextInt();
		tree = new int[N];
		Arrays.fill(tree, -1);
		for (int i = 0; i < M; i++)union(Integer.parseInt(sc.next()) - 1, Integer.parseInt(sc.next()) - 1);
		System.out.println(yono);
	}
	
	static int[] tree;
	static void union(int x, int y) {
		x = root(x);
		y = root(y);
		if(x != y) {
			yono--;
			if(tree[x] < tree[y]) {
				x ^= y; y ^= x; x^= y;
			}
			tree[x] += tree[y];
			tree[y] = x;
		}
	}
	static boolean find(int x, int y) {
		return root(x) == root(y);
	}
	static int root(int x) {
		return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
	}
}

Measured memory_bytes: 58888
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUIntListFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO ()
main = do

    [aN,aM] <- getIntList
    aA <- getIntList
    let sortedA = reverse $ sort aA
    let sumA = sum aA
    if aM <= length aA 
        then     let takedA = take aM sortedA
                 in if ((last takedA) * 4 * aM) < sumA 
                     then putStrLn "No"
                     else putStrLn "Yes"
        else    putStrLn "No"



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=55,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
int C[N][N];
map <int,int> dp[N];
int main(){
	n=read();
	For(i,0,n)
		C[i][0]=C[i][i]=1;
	For(i,1,n)
		For(j,1,i-1)
			C[i][j]=Add(C[i-1][j-1]+C[i-1][j]);
	dp[1][0]=dp[1][-1]=1;
	For(i,1,n-1)
		For(j,-i,i)
			For(k,max(1,abs(j)),n-i){
				if ((j+k)%2)
					continue;
				For(t,0,k){
					int v=(j+t-(k-t))/2;
					Add(dp[i+k][v],(LL)dp[i][j]*C[k][t]%mod
											   *C[i+k][k]%mod);
				}
			}
	cout<<dp[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <ctime>
#include <cstdlib> 
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
const int L = 100010;
const int N = 27;
char s[L],t[L];
int lens,lent,ans;
int p[N][L];
int cnt[N];
int id(char s){
	return s-'a'+1;
}
signed main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	lens=strlen(s+1);
	lent=strlen(t+1);
	for(int i=1; i<=lens; i++){
		p[id(s[i])][++cnt[id(s[i])]]=i;
	}
	int last=0;
	for(int i=1; i<=lent; i++){
		if(cnt[id(t[i])]==0){
			puts("-1");
			return 0;
		}
		int pos=upper_bound(p[id(t[i])]+1, p[id(t[i])]+1+cnt[id(t[i])], last)-p[id(t[i])];
		int d=p[id(t[i])][pos];
		if(pos==cnt[id(t[i])]+1){
			ans+=lens-last;
			ans+=p[id(t[i])][1];
			last=p[id(t[i])][1];
		}
		else{
			ans+=d-last;
			last=d;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  char a;
  cin >> a;
  char b = a + 1;
  cout << b << "\n";
}

Measured memory_bytes: 3572
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = sc.nextInt();
        int ans = 0;

        for(int i = 0; i < n; i++){
            String ts = sc.next();
            ts += ts;

            if(ts.contains(s)){
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    vector<string> N(3);
    rep(i, 0, 3) cin >> N.at(i);
    vector<int> n(3, -1);
    int st = 0;
    while (true){
        n.at(st)++;
        if (n.at(st) == N.at(st).size()){
            char ans = 'A' + st;
            cout << ans << endl;
            break;
        }
        rep(i, 0, 3){
            char x = 'a' + i;
            if ((N.at(st).at(n.at(st))) == x){
                st = i;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
in_str = input()
str_num = in_str.split()
num = []
for i in range(3):
    num.append(int(str_num[i]))

bis = 0
i = 1

while True:
    if num[0] * i > num[2] + 0.5:
        break
    bis += num[1]
    i += 1

print(bis)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N+1];
  for(int i=1;i<=N;i++) cin >> a[i];

  int now = 1;
  int cnt = 0;
  while(true){
    if(cnt >= N+100){
      cout << -1 << endl;
      return 0;
    }
    now = a[now];
    cnt++;
    if(now == 2) break;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int ans=1e9;
  for(int i=-100;i<=100;++i){
    int sum=0;
    rep(j,n){
      sum+=(a[j]-i)*(a[j]-i);
    }
    chmin(ans,sum);
  }
  cout<<ans;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    set<char>ss;
    string s;
    cin>>s;
    f1(i,4) {
        ss.insert(s[i]);
    }
    int n=ss.size();
    (n==2)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3628