akhauriyash/Code-Regression huggingface dataset:
//Hello Wolrd
//There is Special Pig Jiong in the world. 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
const double pi = acos(-1.0);
#define pc putchar
#define RG register
#define gc getchar
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;c<'0'||c>'9';c=gc())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');
	if(x>=10)write(x/10);
	putchar(x%10+'0');
}
void writeln(ll x){
	write(x);puts("");
}
const int Mod = 1e9+7;
int Pow(int a,int b){int ans=1;for(;b;b>>=1,a=1ll*a*a%Mod)if(b&1)ans=1ll*ans*a%Mod;return ans;}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Down(i,a,b) for(RG int i=(a);i>=(b);--i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".out","w",stdout);}
#define y1 ________y1
#define x first
#define y second

ll n,k,ans;
int main(){
	n = rd(),k = rd();
	if(k==0){
		printf("%lld\n",n*n);
		return 0;
	}
//	printf("%lld %lld\n")
	for(ll b=k+1;b<=n;b++){
		ll Lun = (n+1)/b;//Lun = 2
		ans+=Lun*(b-k);   //1*2 = 2
		ll LL = b*Lun + k;//
		if(LL<=n)ans+=(n-LL+1);    //
//		printf("%lld %lld\n",ans,b);
	}
	printf("%lld\n",ans);
	return 0;
}


/*
934285914
287927211
*/

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int N;
    scanf("%d",&N);
    int d[N];
    int x;
    for(x=0;x<N;x++){
      scanf("%d",&d[x]);
    }
    int i,j,sum;
    sum = 0;
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            sum += d[i]*d[j];
        }
    }
    printf("%d",sum);
}

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

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "-") {
      break;
    }
    int m;
    cin >> m;
    vector<int> h(m);
    rep(i, m) {
      cin >> h.at(i);
    }
    rep(i, m) {
      string sl = s.substr(0, h.at(i));
      string sr = s.substr(h.at(i), s.size());
      s = sr + sl;
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3172
// Problem : E - Two Currencies
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n,m,s;
    cin>>n>>m>>s;
    s=min(s,(int)2500);
    vector<vector<PIPI>>adj(n+1);
    set<PPII>se;
    VI cr(n+5),dr(n+5);
    int dp[n+5][2505];bool vis[n+5][2505];
    for(int i=0;i<=n;i++)
    {
    	for(int j=0;j<=2500;j++){dp[i][j]=INF;vis[i][j]=false;}
    }
    for(int i=0;i<m;i++)
    {
    	int x,y;
    	cin>>x>>y;
    	int a,b;
    	cin>>a>>b;
    	adj[x].pb({y,{a,b}});
    	adj[y].pb({x,{a,b}});
    	
    }
    for(int i=1;i<=n;i++)
    {
    	cin>>cr[i]>>dr[i];
    }
    se.insert({{0,s},1});
    while(se.size()!=0)
    {
    	auto p=*se.begin();
    	se.erase(se.begin());
    	int v=p.SE;int tim=p.FI.FI;int cur=p.FI.SE;
    	if(vis[v][cur]==true)continue;
    	vis[v][cur]=true;
    	if(cur+cr[v]<=2500)se.insert({{tim+dr[v],cur+cr[v]},v});
    	for(auto it:adj[v])
    	{
    		if(cur>=it.SE.FI)
    		{
    			if(dp[it.FI][cur-it.SE.FI]>tim+it.SE.SE)
    			{
    				dp[it.FI][cur-it.SE.FI]=tim+it.SE.SE;
    				se.insert({{tim+it.SE.SE,cur-it.SE.FI},it.FI});
    			}
    		}
    	}
    }
    for(int i=2;i<=n;i++)
    {
    	int min1=INF;
    	for(int i1=0;i1<=2500;i1++)
    	{
    		min1=min(min1,dp[i][i1]);
    	}
    	cout<<min1<<endl;
    }
}


return 0;
}





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

int main(){
  int n;
  long long int cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    char s;
    long long int a;
    cin>>s>>a;
    if(s=='('){
      cnt+=a;
    }else{
      cnt-=a;
    }
    if(cnt<0){
      break;
    }
  }
  if(cnt==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, var, i, j, x, y;
	cin >> n;
	ll a[n], mask, ub = (1 << n), ans = 0;
	bool tag;
	vec<pair<ll, ll> > inp[n];
	for(i = 0; i < n; i++) {
		cin >> a[i];
		for(j = 0; j < a[i]; j++) {
			cin >> x >> y;
			inp[i].psb({x, y});
		}
	}
	for(mask = 0; mask < ub; mask++) {
		var = mask;
		j = 0;
		tag = true;
		while(var) {
			if(var & 1) {
				for(i = 0; i < a[j]; i++) {//varifying all testimonies
					if(((mask >> (inp[j][i].fst - 1)) & 1) ^ inp[j][i].scd) {
						/*Is inp[j][i]th person honest/unkind assumed by us
						: ((mask >> (inp[j][i].fst - 1)) & 1)
						What this jth person (honest) says about inp[j][i]th person:
						inp[j][i].scd
						*/
						tag = false;
						break;
					}
				}
			}
			j++;
			var >>= 1;
			if(!tag)
				break;
		}
		if(tag) {
			ans = max(ans, (ll)__builtin_popcountll(mask));
		}
	}
	cout << ans;
	return 0;
}


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

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

    vector<int> vec(i);
    for (int j=0;j<i;++j){
        cin>>vec.at(j);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int b = 101, n=0;
    for (int j=0;j<i;++j){
        if (vec[j]<b){
            n+=1;
            b=vec[j];
        }
    }

    cout << n <<endl;
     
} 

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/UOA/PCKWU/1041

#include <bits/stdc++.h>

using namespace std;

bool solve() {
    int n;
    cin >> n;

    if (n == 0) return false;

    n /= 4;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        res += a;
    }

    cout << res << endl;
    return true;
}

int main() {
    while (solve());
}

/*
 *
 */


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		String plusminus = sc.next();
		int m = Integer.parseInt(sc.next());
		
		if (plusminus.equals("+")) {
			System.out.println(n + m);
		}else if (plusminus.equals("-")) {
			System.out.println(n - m);
		}
	}
}


Measured memory_bytes: 21844
package main

import (
	"strconv"
	"bufio"
	"os"
	"strings"
	"fmt"
)

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_B>
 */

func init() {

}

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	cnt := 1
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan(){
		x,_ := strconv.Atoi(stdin.Text())

		if x == 0 {
			break
		}
		fmt.Fprintf(wtr, "Case %d: %d\n", cnt, x)
		cnt++
	}
	wtr.Flush()
}

// ????????????1?????????
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// ??´??°???1?????????
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// ?????????????????????????????????????????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// ??????????????§??????????????????????????????????????????
func SplitStrStdin(delim string) (stringReturned []string) {
	// ???????????§1?????????
	stringInput := StrStdin()

	// ????????§??????
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// ??????????????§??????????????´??°????????????????????????
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// ??????????????????????????????
	stringSplited := SplitStrStdin(" ")

	// ??´??°?????????????????????
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<double>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  double S;
  for(int i=0;i<N;i++){
    S+=1/A.at(i);
  }
  cout<<1/S<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
D,T,S = map(int,input().split())
if T*S >= D:
    print("Yes")
else:
    print("No")








Measured memory_bytes: 10516
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	ll n;
	cin >> n;
	vl a(n);
	vl b(n);

	REP(i, n) {
		cin >> a[i] >> b[i];
	}

	ll ans = 0;

	for (int i = n - 1; i >= 0; i--) {
		ll p = ceil((double)a[i] / (double)b[i])*b[i] - a[i];
		ans += p;
		if (i > 0) {
			a[i - 1] += ans;
		}
	}

	cout << ans << endl;
}

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

bool culc_distance(int d, int a[],int b[]) {
    int res = 0;
    for(int i = 0;i < d;i++) {
        int num = abs(a[i]-b[i]);
        res += pow(num, 2);
    }
    double x = pow(res, 0.5);
    return floor(x) == x;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    int a[n][d];
    
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < d;j++) {
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }
    

    int count = 0;
    for(int i = 0;i < n-1;i++) {
        for(int j = i+1;j < n;j++) {
            if(culc_distance(d, a[i], a[j])) count++;
        }
    }
    cout << count << endl;  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

void dfs(vvl change, ll depth, ll tot, vl &used, ll &ans){
  if(depth == 3){
    ans = min(ans, tot);
    return;
  }

  rep(i, change[depth].size()){
    if(used[i] == 1) continue;

    used[i] = 1;
    dfs(change, depth + 1, tot + change[depth][i], used, ans);
    used[i] = 0;
  }
}

int main(){
  ll N, C;
  cin >> N >> C;
  vvl D(C, vl(C));
  rep(i, C){
    rep(j, C){
      cin >> D[i][j];
    }
  }
  vvl c(N, vl(N));
  rep(i, N){
    rep(j, N){
      cin >> c[i][j];
    }
  }

  vvl change(3, vl(C, 0));
  rep(i, N){
    rep(j, N){
      rep(k, C) change[(i + j) % 3][k] += D[c[i][j] - 1][k];
    }
  }

  /*
  cout << endl;
  
  rep(j, C){
    rep(i, 3){
      cout << change[i][j] << ' ';
    }
    cout << endl;
  }
  */

  vl used(C, 0);
  ll ans = (ll)pow(10, 18);
  dfs(change, 0, 0, used, ans);

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


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int N = int.Parse(str);
        int[] a = new int[N+1];
        bool[] b = new bool[N+1];
        int current;
        int cnt = 1;

        for(int i = 1; i < N+1; i++){
            str = Console.ReadLine();
            a[i] = int.Parse(str);
        }

        current = a[1];
        b[1] = true;
        for(int i = 1; i < N; i++){
            if(!b[current]){
                if(current == 2){
                    Console.WriteLine(cnt);
                    return;
                }
                cnt++;
                current = a[current];
            }else{
                Console.WriteLine(-1);
                break;
            }
        }
        if(cnt == N){
            Console.WriteLine(-1);
        }
    }
}



Measured memory_bytes: 15200
#include <bits/stdc++.h>
#define for_bitset(variable, bitset) for (variable = bitset._Find_first(); variable != N; variable = bitset._Find_next(variable))

const int N = 1054, M = 200054;
typedef std::bitset <N> bitset;

int V, E, tag, root;
int from[N], _u[M], _v[M], que[N];
bitset G[N], single[N];
bitset saturated, connected[N], reversible[N];

void bfs(int si) {
	int x, y, h, t = 1; bitset remain; *que = si; 
	from[si] ? saturated.set(si) : (from[si] = tag, single[tag].set(si));
	for (h = 0; h < t; ++h) {
		x = que[h];
		remain = G[x] & ~saturated & ~single[tag];
		for_bitset(y, remain)
			que[t++] = y, from[y] ? saturated.set(y) : (from[y] = tag, single[tag].set(y));
	}
}

void solve() {
	int i;
	memset(from, 0, (V + 1) << 2);
	saturated.reset(), saturated.set(root);
	for_bitset(tag, G[root]) if (!saturated.test(tag)) bfs(tag);
	connected[root] = reversible[root] = saturated;
	for (i = 1; i <= V; ++i)
		connected[root].set(i, connected[root].test(i) || from[i]),
		reversible[root].set(i, reversible[root].test(i) || (from[i] && from[i] != i));
	for (i = 1; i <= V; ++i) single[from[i]].reset(i);
}

int main() {
	int i, u, v;
	scanf("%d%d", &V, &E);
	for (i = 1; i <= E; ++i) scanf("%d%d", &u, &v), G[u].set(v), _u[i] = u, _v[i] = v;
	for (root = 1; root <= V; ++root) solve();
	for (i = 1; i <= E; ++i)
		u = _u[i], v = _v[i], puts(connected[v][u] == reversible[u][v] ? "same" : "diff");
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s, t;
	while(cin >> s >> t, s != "."){
		if(s == t){
			cout << "IDENTICAL" << endl;
			continue;
		}
		auto split = [](string s, char d){
			vector<string> ans;
			int p, cnt = 0;
			while((p = s.find(d)) != s.npos){
				ans.pb(s.substr(0, p));
				s = s.substr(p + 1);
			}
			if(s.size()) ans.pb(s);
			return ans;
		};
		vector<string> sv = split(s, '\"');
		vector<string> st = split(t, '\"');
		
		if(sv.size() == st.size()){
			int even = 0, odd = 0;
			rep(i, sv.size()) if(sv[i] != st[i]){
				if(i % 2) odd++;
				else even++;
			}
			if(odd == 1 && even == 0){
				cout << "CLOSE" << endl;
				continue;
			}
		}
		cout << "DIFFERENT" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
       x %= MOD;
       y %= MOD;
       return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
       x %= MOD;
       y %= MOD;
       return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
       x %= MOD;
       if (t == 0) {
               return 1;
       }
       else {
               ll v = mod_pow(x, t / 2);
               if (t % 2 == 0) {
                       return v * v % MOD;
               }
               else {
                       return v * v%MOD * x %MOD;
               }
       }
}

ll mod_inv(ll x) {
       return mod_pow(x, MOD - 2);
}

vll fct(1e6), invfct(1e6), inv2pow(1e6);
void init(){
        fct[0] = invfct[0] = inv2pow[0] = 1;
        ll inv2 = mod_inv(2);
        REP(i,1,1e6-1){
                fct[i] = mod_m(fct[i-1], i);
                invfct[i] = mod_inv(fct[i]);
                inv2pow[i] = mod_m(inv2pow[i-1], inv2);
        }
}

vvll g;
vector<vvll> dp;
void dfs(ll cur, ll bef){
        vvll v(2,vll(2,0));
        v[0][1] = 1;
        for(auto nex:g[cur]){
                if(nex == bef) continue;
                dfs(nex, cur);
                vvll w(2, vll(SIZE(v[0]) + SIZE(dp[nex][0])-1));
                REP(k1,0,1){
                REP(k2,0,1){
                        REP(i,0,SIZE(v[0])-1){
                                REP(j,0,SIZE(dp[nex][0])-1){
                                        w[(k1^k2)][i+j] = mod_p(w[k1^k2][i+j], mod_m(v[k1][i], dp[nex][k2][j]));
                                }
                        }
                }
                }
                swap(v, w);
        }
        REP(k,0,1){
                for(ll j = 1; j * 2 <= SIZE(v[k]) - 1; j++){
                        v[(k+1)%2][0] = mod_p(v[(k+1)%2][0], mod_m(v[k][j*2], mod_m(fct[2*j], mod_m(invfct[j], inv2pow[j]))));
                }
        }
        swap(dp[cur], v);
}

int main(){
        init();
        ll n;
        cin >> n;
        g = vvll(n+1);
        REP(i,1,n-1){
                ll x,y;
                cin >> x >> y;
                g[x].push_back(y);
                g[y].push_back(x);
        }
        dp = vector<vvll> (n+1, vvll(2, vll()));
        dfs(1, 0);
        cout << mod_p(dp[1][1][0], -dp[1][0][0]) << endl;
        // REP(i,1,n){
        //         cout << SIZE(dp[i][1]) << endl;
        // }
        // REP(k,0,1){
        //         REP(i,0,SIZE(dp[2][k])-1){
        //                 cout << dp[2][k][i] << " ";
        //         }
        //         cout << endl;
        // }
}

Measured memory_bytes: 162816
#include<bits/stdc++.h>
using namespace std;
long long a[86];
int main()
{
	
	a[0]=2;
	a[1]=1;
	for(int i=2;i<100;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	int n;
	cin>>n;
	cout<<a[n]<<endl;
	
	
	
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <map>

typedef long long ll;
using namespace std;

int main()
{
  // input & declare
  int result = 0;
  ll n;
  cin >> n;
  ll tmp;
  std::vector<ll> numsA;
  std::map<int, int> mp;
  for(int i = 0; i < n; i++)
  {
    cin >> tmp;
    numsA.push_back(tmp);
    mp[tmp]++;
  }

  // process
  for(auto p : mp)
  {
    int i = p.first;
    int val = p.second;
    // std::cout << mp[i] << '\n';
    if (val < i)
      result += val;
    if (val > i)
      result += (val - i);
  }


  //output
  std::cout << result << '\n';
}


Measured memory_bytes: 5492
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = true;
    for (i, &c) in s.iter().enumerate() {
        if (i+1) % 2 != 0 {
            if c == 'R' || c == 'U' || c == 'D' {
                continue;
            } else {
                ans = false;
                break;
            }
        } else {
            if c == 'L' || c == 'U' || c == 'D' {
                continue;
            } else {
                ans = false;
                break;
            }
        }
    }
    yn(ans);
}


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



int main() {
ll N;
cin >> N;
vector<ll> hito(3*N);
  for(long long i=0;i<3*N;i++) cin>>hito[i];

sort(hito.begin(),hito.end());
reverse(hito.begin(),hito.end());
ll su = 0;
for(ll i = 1, j = 0; j < N; i = i+2, ++j){
su += hito[i];
}
cout << su << endl;

}




Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ALL(x) begin(x),end(x)
#define inf (1LL<64)-1
using namespace std; 

/*
   -------
         |
    **   |
   -------      
   |
   ------------------------------------------------------------------------------------------------------
*/

void solve()
{
    int l;cin>>l;

    float ans=0.0;
    ans=pow(l,3.0)/27;

    cout<<setprecision(12)<<fixed<<ans<<endl;
}

int32_t main()
{   
     f_ip
  
      solve();

     return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int N;
vector<int> l[100010];
template <class T> class Node {
public:
	Node()
		:parent(0), child(0)
	{};
	Node* parent;
	vector<Node*> child;
	T para;
};
Node<int> nodes[100010];
int mL;
void Set(int n, int m) {
	if (n == N) {
		mL = m;
	}
	for (int i = 0; i < l[n].size(); i++) {
		if (nodes[n].parent != &nodes[l[n][i]]) {
			nodes[n].child.push_back(&nodes[l[n][i]]);
			nodes[l[n][i]].parent = &nodes[n];
			Set(l[n][i], m + 1);
		}
	}
}
int c = 1;
void CountChilds(Node<int>* n) {
	if (n->child.size() != 0) {
		for (int i = 0; i < n->child.size(); i++) {
			c++;
			CountChilds(n->child[i]);
		}
	}
};
int main() {
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		l[a].push_back(b);
		l[b].push_back(a);
	}
	Set(1, 0);
	Node<int>* a = &nodes[N];
	for (int i = 0; i < (mL - 1) / 2; i++) {
		a = a->parent;
	}
	CountChilds(a);
	if (c >= N - c) {
		printf("Snuke\n");
	}
	else {
		printf("Fennec\n");
	}
	return 0;
}

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

int main()
{
  ll n,m;
  cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>

using namespace std;

int n,inputed_order[41] = {0};
queue<int> Queue;

struct Node{
	Node(){
		left_child = right_child = -1;
	};
	int left_child,right_child;
};

void postORDER(Node order[],int id){
	if(order[id].left_child != -1) postORDER(order,order[id].left_child );
	if(order[id].right_child != -1) postORDER(order,order[id].right_child );
	Queue.push(id+1);
}

int findRoot(int inorder[],int left,int right){
	int root = inorder[left];
	for(int i = left+1; i <= right; i++){
		if(inputed_order[root] > inputed_order[inorder[i]]){
			root = inorder[i];
		}
	}
	return root;
}

void reconstruct(int inorder[],Node order[],int root,int left,int right){
	int root_index;
	for(root_index = left; inorder[root_index] != root; root_index++);
	if(left < root_index){
		int new_root = findRoot(inorder,left,root_index-1);
		order[root-1].left_child = new_root-1;
		if(left < root_index-1)	reconstruct(inorder,order,new_root,left,root_index-1);
	}
	if(root_index < right){
		int new_root = findRoot(inorder,root_index+1,right);
		order[root-1].right_child = new_root-1;
		if(root_index+1 < right) reconstruct(inorder,order,new_root,root_index+1,right);
	}
}

int main(){
	scanf("%d",&n);
	int preorder[n],inorder[n];
	Node order[n];

	for(int i = 0; i < n; i++){
		scanf("%d",&preorder[i]);
		inputed_order[preorder[i]] = i;
	}
	for(int i = 0; i < n; i++){
		scanf("%d",&inorder[i]);
	}

	if(n == 1){
		printf("%d\n",preorder[0]);
	}else{
		reconstruct(inorder,order,preorder[0],0,n-1);
		postORDER(order,preorder[0]-1);
		while(!Queue.empty()){
			if(Queue.size() != 1){
				printf("%d ",Queue.front());
				Queue.pop();
			}else{
				printf("%d\n",Queue.front());
				Queue.pop();
			}
		}
	}

}



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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

struct FenwickTree{
	int n;
	vector<ll> dat;
	FenwickTree(int _n) :n(_n),dat(_n + 1,0ll){}
	FenwickTree(int _n,ll val) :n(_n),dat(_n + 1,0ll){
		for(int i = 0;i < n;i++) update(i,val);
	}
	void update(int idx,ll val){
		for(idx++;idx <= n;idx += idx & -idx) dat [idx] += val;
	}
	ll query(int l,int r){
		ll res = 0;
		for(;r;r -= r & -r) res += dat [r];
		for(;l;l -= l & -l) res -= dat [l];
		return res;
	}
};

int N,M;

bool comp(const pair<int,int>& a,const pair<int,int>& b)
{
	return a.second - a.first < b.second - b.first;
}

int main()
{
	scanf("%d%d",&N,&M);
	vector< pair<int,int> > A(N);
	FOR(i,0,N){
		scanf("%d%d",&A [i].first,&A [i].second);
	}
	sort(ALL(A),comp);

	FenwickTree ft(M + 1);
	int idx = 0;
	FOR(i,1,M + 1){
		while(idx < N && A [idx].second - A [idx].first < i){
			ft.update(A [idx].first,1);
			ft.update(A [idx].second + 1,-1);
			idx++;
		}
		int ans = N - idx;
		for(int j = 0;j <= M;j += i){
			ans += ft.query(0,j + 1);
		}
		printf("%d\n",ans);
	}

	return 0;
}


Measured memory_bytes: 4096
a,b,c,d=map(int, input().split())
t=0
if a>=d:
    t+=d
    d-=d
else:
    t+=a
    d-=a
if d>0:
    d-=b
if d>0:
    if c>=d:
        t-=d
    else:
        t-=c
print(t)
    
  


Measured memory_bytes: 9172
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

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

void solve()
{
    string s,s1;
    cin >> s;
    cin >> s1;
    int c = 0;
    for(int i=0;i<s.length();i++){
		if(s[i] != s1[i])c++;
    }
    cout << c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  n--;
  string s="";
  ll cu=1;
  while(1){
    s+=(char)('a'+n%26);
    if(n<26) break;
    n/=26;
    n--;
  }
  reverse(all(s));
  COUT(s);
}

Measured memory_bytes: 3580
import collections
def main():

    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = float('-inf')
    if K <= N:
        for i in range(N):
            v = 0
            k = i
            for j in range(K):
                k = P[k]-1
                v += C[k]
                ans = max(ans, v)
        return ans

    for i in range(N):
        visited = dict()
        k = i
        visited[i] = 0
        val = [0]
        v = 0
        for j in range(1, N+1):
            k = P[k] - 1
            if k not in visited:
                visited[k] = j
                val.append(C[k])
                v += C[k]
                ans = max(ans, v)
            else:
                m = visited[k]
                t = j - m
                val.append(C[k])
                v += C[k]
                ans = max(ans, v)
                # print(val, j, visited[k])
                val1 = val[:m+1]
                val2 = val[m+1:]
                period = sum(val2)
                pre = sum(val1)
                n = (K - m) // t
                rem = (K-m) % t
                u = 0
                ans = max(ans, u + pre + period * n)
                for p in range(rem):
                    u += val2[p]
                    ans = max(ans, u + pre + period * n)
                u = 0
                for p in range(t):
                    u += val2[p]
                    ans = max(ans, u + pre + period * (n-1))
                break

    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 169300
def convert1(y, m, d):
    if m <= 2:
        m += 12
        y -= 1
    mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912
    return mjd
def convert2(mjd):
    n = mjd + 678881
    a = 4*n + 3 + 4*(3*(4*(n+1)//146097+1)//4)
    b = 5*((a % 1461)//4) + 2
    y, m, d = a//1461, b//153 + 3, (b % 153)//5 + 1
    if m >= 13:
        y += 1
        m -= 12
    return y, m, d

base = convert1(2012, 12, 21)
while 1:
    s = input()
    if s == '#':
        break
    *vs, = map(int, s.split("."))
    if len(vs) == 5:
        b, ka, t, w, ki = vs
        day = ki + w*20 + t*18*20 + ka*20*18*20 + b*20*20*18*20
        y, m, d = convert2(base + day)
        print("%d.%d.%d" % (y, m, d))
    else:
        y, m, d = vs
        d = convert1(y, m, d) - base
        ki = d % 20; d //= 20
        w = d % 18; d //= 18
        t = d % 20; d //= 20
        ka = d % 20; d //= 20
        b = d % 13
        print("%d.%d.%d.%d.%d" % (b, ka, t, w, ki))



Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define f first
#define se second
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main() {
	ll n,x,i;
	deque<ll> d;
	int st;
	
	cin>>n;
	cin>>x;
	
	d.push_back(x);
	
	if(n==1)
	{
		cout<<x;
		return 0;
	}
	
	st=1;
	
	for(i=2;i<=n;i++)
	{
		cin>>x;
		if(st==1)
		{
			d.push_back(x);
			st=2;
		}
		else
		{
			d.push_front(x);
			st=1;
		}
	}
	
	if(st==1)
	{
		while(!d.empty())
		{
			cout<<d.front()<<' ';
			d.pop_front();
		}
	}
	else
	{
		while(!d.empty())
		{
			cout<<d.back()<<' ';
			d.pop_back();
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3840
N=int(input())
A=list(map(int,input().split()))

d={}

for i in range(len(A)):
  d.setdefault(i-A[i],0)
  d[i-A[i]]+=1
ans=0
for i in range(len(A)):
  if d.get(i+A[i]):
    ans+=d.get(i+A[i])
print(ans)

Measured memory_bytes: 40408
#include<stdio.h>
#include<string.h>
int main(void){
int l,i,n,k,sum=0;
char a[220];
while(1){
scanf("%s",a);
l=strlen(a);
if(a[0]=='-'){break;}
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&k);
sum+=k;
}
for(i=0;i<l;i++){
printf("%c",a[(sum+i)%l]);
}
printf("\n");
sum=0;
}
return 0;
}

Measured memory_bytes: 568
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::cmp;
use std::collections::HashMap;
fn calc(list: &Vec<usize>, memo: &mut HashMap<usize, usize>, n: usize) -> usize {
    let mut ans = 999999999;
    if memo.contains_key(&n) {
        return memo[&n];
    }
    if n <= 5 {
        return n;
    }
    for z in list {
        if n >= *z {
            ans = cmp::min(ans, calc(list, memo, n - z) + 1);
        }
    }
    memo.insert(n, ans);
    return ans;
}

fn main() {
    let n: usize;
    let mut memo = HashMap::new();
    input!(n);
    let mut v = vec![1_usize];
    for z in 1..20 {
        v.push(6_usize.pow(z));
        v.push(9_usize.pow(z));
    }
    v.sort();
    v.reverse();

    p(calc(&v, &mut memo, n));
}

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

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


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

int main(){
    string a;
    cin>>a;
    vector<int> pos;
    vector<int> vec('z'-'a'+1,0);
    int cnt=0;
    for(int i=a.size()-1;i>=0;i--){
        if(vec[a[i]-'a']==0){
            vec[a[i]-'a']++;
            cnt++;
        }
        if(cnt=='z'-'a'+1){
            fill(vec.begin(),vec.end(),0);
            cnt=0;
            pos.push_back(i);
        }
    }
    reverse(pos.begin(),pos.end());
    pos.push_back(a.size());
    fill(vec.begin(),vec.end(),0);
    int inde=0;
    string res;
    for(int i=0;i<pos.size();i++){
        for(int j=inde;j<pos[i];j++){
            vec[a[j]-'a']++;
        }
        for(char x='a';x<='z';x++){
            if(!vec[x-'a']){
                res+=x;
                while(inde<a.size() && a[inde]!=x) inde++;
                inde++;
                break;
            }
        }
        fill(vec.begin(),vec.end(),0);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s_in = line.split(" ");
		System.out.println(Integer.parseInt(s_in[0]) + Integer.parseInt(s_in[1])/2);
	}
}

Measured memory_bytes: 22608
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int dp[N][3];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
	#endif
	IOS;
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c;
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]});
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	n := readInt()
	fmt.Println(n / 3)
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
using namespace std;
using ll=long long;

const ll nmax=500;
const ll cmax=30;
ll c0[cmax+1],c1[cmax+1],c2[cmax+1];
ll d[cmax+1][cmax+1];

int main(){
    ll N,C;
    cin>>N>>C;
    for(ll i=1;i<=C;i++){
        for(ll j=1;j<=C;j++){
            cin>>d[i][j];
        }
    }
    ll ctm;
    for(ll i=1;i<=N;i++){
        for(ll j=1;j<=N;j++){
            cin>>ctm;
            if((i+j)%3==0) c0[ctm]++;
            if((i+j)%3==1) c1[ctm]++;
            if((i+j)%3==2) c2[ctm]++;
        }
    }
//    for(ll i=0;i<ct0;i++)cout<<c0[i]<<" ";
//    cout<<endl;
//    for(ll i=0;i<ct1;i++)cout<<c1[i]<<" ";
//    cout<<endl;
//    for(ll i=0;i<ct2;i++)cout<<c2[i]<<" ";
//    cout<<endl;
    ll ans=10000000000;
    for(ll i=1;i<=C;i++){
        for(ll j=1;j<=C;j++){
            for(ll k=1;k<=C;k++){
                if(i!=j&&j!=k&&i!=k){
                    ll ct=0;
                    for(ll l=1;l<=C;l++){
                        ct+=c0[l]*d[l][i]+c1[l]*d[l][j]+c2[l]*d[l][k];
                    }
                ans=min(ans,ct);
            }
        }
    }
}
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Point{
	double x,y;
};

int main(){

	int n;
	scanf("%d",&n);
	double gaiseki;

	bool FLG = true;

	Point points[n],left,right;

	for(int i=0; i < n; i++){
		scanf("%lf %lf",&points[i].x,&points[i].y);
	}

	for(int i=0; i < n; i++){
		if(i == 0){
			right.x = points[1].x - points[0].x;
			right.y = points[1].y - points[0].y;

			left.x = points[n-1].x - points[0].x;
			left.y = points[n-1].y - points[0].y;

			gaiseki = right.x*left.y - right.y*left.x;
		}else if(i == n-1){
			right.x = points[0].x - points[n-1].x;
			right.y = points[0].y - points[n-1].y;

			left.x = points[n-2].x - points[n-1].x;
			left.y = points[n-2].y - points[n-1].y;

			gaiseki = right.x*left.y - right.y*left.x;
		}else{
			right.x = points[i+1].x - points[i].x;
			right.y = points[i+1].y - points[i].y;

			left.x = points[i-1].x - points[i].x;
			left.y = points[i-1].y - points[i].y;

			gaiseki = right.x*left.y - right.y*left.x;
		}
		if(gaiseki < 0){
			FLG = false;
			break;
		}
	}

	if(FLG)printf("1\n");
	else{
		printf("0\n");
	}

    return 0;
}

Measured memory_bytes: 2744
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] nums = new int[4][13];
		
		for (int i = 0; i < n; i++) {
			String suit = sc.next();
			int num = sc.nextInt();
			
			if ("S".equals(suit)) {
				nums[0][num - 1] = 1;
			} else if ("H".equals(suit)) {
				nums[1][num - 1] = 1;
			} else if ("C".equals(suit)) {
				nums[2][num - 1] = 1;
			} else {
				nums[3][num - 1] = 1;
			}
		}
		
		for (int i = 0; i < 4; i++) {
			String suit = "S";
			
			if (i == 0) {
				suit = "S";
			} else if (i == 1) {
				suit = "H";
			} else if (i == 2) {
				suit = "C";
			} else {
				suit = "D";
			}
			
			for (int j = 0; j < 13; j++) {
				if (nums[i][j] == 0) {
					System.out.println(suit + " " + (j + 1));
				}
			}
		}
	}
}



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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200009;
int n, k, h[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    sort(h, h+n);

    int ans = 0;
    for(int i = 0; i < n-k; ++i) {
        ans += h[i];
    }

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


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
void judge(string s)
{
    unsigned sum = 0;
    unsigned count = 0;
    for(int i = 0; i < s.size(); i++)
    {
        sum += s[i] - '0';
        if(sum >= 10)
        {
            sum -= 9;
            count++;
        }
    }
    if((count + s.size()) % 2)
        cout << "Audrey wins.\n";
    else
        cout << "Fabre wins.\n";
}
 
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        judge(s);
    }
}

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

int main(){
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	if((x<=w-r) && (x>=r) && (y<=h-r) && (y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3116
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	aSlice := make([]int, m)
	for i := range aSlice {
		fmt.Scan(&aSlice[i])
	}

	costL := 0
	costR := 0
	for _, a := range aSlice {
		if a < x {
			costL++
		} else {
			costR++
		}
	}

	fmt.Println(min(costL, costR))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c, d;
    string s, t, u;
    cin >> s;
    replace(ALL(s), ',', ' ');
    P(s);
    return 0;
}



Measured memory_bytes: 256