akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    ld m;
    cin>>n>>m;
    ld a[n];
    ld sum =0;
    loop(i,0,n){
        cin>>a[i];
        sum += a[i];
    }
    ll cnt = 0;
    for(ll i=0; i<n; i++){
        if(a[i] < sum/(4*m)){
            cnt++;
        }
    }
    cnt = n-cnt;
    if(cnt >= m){
        print("Yes");
    }
    else print("No");

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

 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


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

import static java.lang.System.in;

public class Main {
    static long ans=0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
        if(!check(n,A,B)){
            System.out.println(-1);
            System.exit(0);
        }
        int[] ans = new int[n+1];
        int lowerBound = 0;
        int start = 1;
        for(int cnt=1;cnt<=A;cnt++){
            int len = Math.min(B,n-start-A+cnt+1);
            for(int j=0;j<len;j++){
                ans[start++] = lowerBound+len-j;
            }
            lowerBound += len;
        }
        PrintWriter out = new PrintWriter(System.out);
        for(int i=1;i<=n;i++) out.print(Integer.toString(ans[i])+" ");
        out.flush();
    }
    static boolean check(int n, int a, int b){
        if(a>n||b>n||b>n-a+1) return false;
        int shortest = n%a==0? n/a:(n/a+1);
        return b>=shortest;
    }
}


Measured memory_bytes: 49056
# D - Maze Master
def bfs(source: int):
    queue = [source]
    dist = {source: 0}
    while queue:
        x = queue.pop(0)
        for nx in (x + 1, x - 1, x + W, x - W):
            if maze[nx] == "." and nx not in dist:
                dist[nx] = dist[x] + 1
                queue.append(nx)
    return max(dist.values())


def main():
    global W, maze
    H, W = map(int, input().split())
    H, W = H + 2, W + 2
    maze = "#" * W
    for _ in range(H - 2):
        maze += "#" + input().rstrip() + "#"
    maze += "#" * W
    ans = max(bfs(i) for i, c in enumerate(maze) if c == ".")
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int

int p[100100];
int r[100100];
int w[100100];

void init(int n){
  REP(i, n){
    p[i] = i;
    r[i] = 0;
  }
}

int find(int n){
	return (p[n] == n ? n : p[n] = find(p[n]));
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(r[x] < r[y]){
		p[x] = y;
		w[y] += w[x];
	}
  else{
    p[y] = x;
		w[x] += w[y];
    if(r[x] == r[y]) r[x]++;
  }
}

bool same(int x, int y){
  return (find(x) == find(y));
}

struct edge{int to, cost;};

ll POW(ll a, ll b){
	if(b == 0) return 1LL;
	if(b == 1) return a;
	if(b %2 == 1) return (a*POW(a, b-1))%INF;
	return POW(a*a%INF, b/2);
}

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

int main(){
	int m, k;
	cin >> m >> k;
	if(m == 0){
		if(k == 0){
			cout << "0 0" << endl;
		}
		else cout << -1 << endl;
		return 0;
	}
	if(m == 1){
		if(k == 0) cout << "0 0 1 1" << endl;
		else cout << -1 << endl;
		return 0;
	}
	int mx = (1<<m) - 1;
	if(mx < k){
		cout << -1 << endl;
		return 0;
	}
	cout << k << " ";
	REP(i, mx+1){
		if(i != k) cout << i << " ";
	}
	cout << k << " ";
	for(int i = mx; i >= 0; i--){
		if(i != k) cout << i;
		if(i == 0 || (k == 0 && i == 1)) cout << endl;
		else if(i != k) cout << " ";
	}
	return 0;
} 


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <set>

int main() {
    int n;
    std::cin >> n;
    std::set<int> set_a{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        set_a.insert(a);
    }

    int m;
    std::cin >> m;
    std::set<int> set_b{};
    for (int j = 0; j < m; ++j) {
        int b;
        std::cin >> b;
        set_b.insert(b);
    }

    std::set<int> result{};
    std::set_union(set_a.begin(), set_a.end(), set_b.begin(), set_b.end(),
                   std::inserter(result, std::end(result)));

    for (auto iter = result.begin(); iter != result.end(); ++iter)
        std::cout << *iter << std::endl;
}


Measured memory_bytes: 40568
#include<iostream>
#include<algorithm>

int main(){
    
    size_t n;
    std::cin >> n;

    size_t max, min;
    for(size_t i = 0; i < n; i++){
        if(i == 0){
            std::cin >> max;
            min = max;
        }else{
            size_t a;
            std::cin >> a;
            max = std::max(max, a);
            min = std::min(min, a);
        }
    }

    std::cout << max - min << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;



int main()
{
	int a,b,t,ans=0;
	cin >> a >> b >> t;
	for (int i = 1; i <= t+0.5; i++)
	{
		if(i%a == 0)ans += b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
# handler.setLevel(WARNING)
# logger.setLevel(WARNING)
logger.addHandler(handler)



# class SegTree():
#     def __init__(self, n):
#         self.value = [0 for i in range(n*2)]

# MOD = 10 ** 9 + 7

# def getinvmod(n):
#     return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(a1, a2, a3, nums):
    b1 = nums[0][0] - a1
    b2 = nums[0][1] - a1
    b3 = nums[0][2] - a1
    if a2 + b1 == nums[1][0] and a2 + b2 == nums[1][1] and a2 + b3 == nums[1][2]:
        if a3 + b1 == nums[2][0] and a3 + b2 == nums[2][1] and a3 + b3 == nums[2][2]:
            return True

    return False

def main():
    nums = [getList() for _ in range(3)]
    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                if judge(a1, a2, a3, nums):
                    print("Yes")
                    return

    print("No")

if __name__ == "__main__":
    main()

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

int main(){
  string s;
  cin>>s;
  
  for (int i = 0; i < s.size(); i++){
    int count = 0;
    for ( int j = 0; j < s.size(); j++){
      if ( s[i] == s[j] ){
        count++;
      }
    }
    if ( count % 2 != 0 ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;  
  
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b;
            cin>>a>>b;
            if(a==b)
            {
                cout<<0<<endl;
            }
            else
            {
                if((a+b)%2==1)
                    cout<<"IMPOSSIBLE"<<endl;
                else
                    cout<<(a+b)/2<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 256
using System;


    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');

            int a, b;
            a = int.Parse(x[0]);
            b = int.Parse(x[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }else if (a > b)
            {
                Console.WriteLine("a > b");
            }else
            {
                Console.WriteLine("a == b");
            }
        }
    }




Measured memory_bytes: 8844
#include<iostream>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
  	lli i,x,c=0,n;
  	cin>>n;
  	set<lli>s;
  	lli a[n];
  	for(i=0;i<n;i++)
  	{
  		cin>>a[i];
  		s.insert(a[i]);
  	}
	if(s.size()!=n)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
     
    int main(void)
    {
      int a=0;
      int b=0;
      
      scanf("%d" , &a);
      scanf("%d" , &b);
      if((a-b)>=0){
      printf("%d" ,a-b+1 );
      }else{
        printf("該当する組み合わせはありません");
      }
      return 0;
    }

Measured memory_bytes: 128
#include<cstdio>
#include<set>
#define M(x,y)std::make_pair(x,y)
typedef std::set<std::pair<int,int> >S;
int n,m,a,b,x,y,X,Y,d,D;main(){for(;scanf("%d",&n),n;printf("%d\n",n)){
S s;S::iterator i,I;
for(;n;n--)scanf("%d%d",&x,&y),s.insert(M(x,y));
for(i=s.begin();i!=s.end();i++)for(x=i->first,y=i->second,I=i;++I!=s.end();)if(X=I->first,Y=I->second,d=X-x,D=Y-y,m=d*d+D*D,m>n&&s.find(M(x-D,y+d))!=s.end()&&s.find(M(X-D,Y+d))!=s.end())n=m;
}}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

vector<string> w_input()
{
	int i, n;
	cin >> n;
	vector<string> word_input(n);

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

	return word_input;
}

int main(int argc, char *argv[])
{
    int i, j, n;
	char input[16];
	vector<string> word;

	word = w_input();
	n = word.size();

	for (i = 0; i < n - 1; i++) {
		if (word[i].back() != word[i + 1].front()) {
			cout << "No" << endl;
			return 0;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (word[i] == word[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  if(N % 10 == 3){
    cout << "bon" << endl;
  }
  else if(N % 10 == 0 || N % 10 == 1){
    cout << "pon" << endl;
  }
  else if(N % 10 == 6 || N % 10 == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001
#define MOD 1000000007
typedef long long ll;

int H, W, A, B;
long long dp[200000], reverser_dp[200000];


ll pow(ll i, ll n){
    if(n == 0) return 1;
    if(n % 2 == 0){
        return pow(i, n / 2) * pow(i, n / 2);
    }else{
        return i * pow(i, n / 2) * pow(i, n / 2);
    }
}

long long mod_pow(ll i, ll n, ll m){
    if(n == 0) return 1;
    if(n % 2 == 0){
        return (pow(i, n / 2) * pow(i, n / 2)) % m;
    }else{
        return (i * pow(i, n / 2) * pow(i, n / 2)) % m;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
long long box(int x, int y){
    return ((dp[x + y] * reverser_dp[x]) % MOD * reverser_dp[y]) % MOD ;
}
int main(){
    long long sum = 0, ssum = 0;
    memset(dp, -1, sizeof(dp));
    dp[0] = dp[1] = 1;
    for(int i = 2;i < 200000;i++){
        dp[i] = dp[i - 1] * i % MOD;
    }
    reverser_dp[199999] = modinv(dp[199999], MOD);
    for(int i = 199998;i >= 0;i--){
        reverser_dp[i] = reverser_dp[i + 1] * (i + 1) % MOD;
        reverser_dp[i] = (reverser_dp[i] + MOD) % MOD;
        if(reverser_dp[i] < 0) {
            printf("out\n");
            return 1;
        }
    }
    cin >> H >> W >> A >> B;
    for(int i = B + 1;i <= W;i++){
        sum = (sum + box(i - 1, H - A - 1) % MOD * box(W - i, A - 1) % MOD) % MOD;
    }

    printf("%lld\n", sum);

    return 0;
}


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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

ll add(ll a, ll b)
{
	a+=b; a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	if(a>MOD) a%=MOD;
	if(b>MOD) b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll inverse(ll a)
{
	return pw(a,MOD-2);
}

const bool DEBUG = 0;
const int MAXN = 100005;

int n;
vi adj[MAXN];
ll dp[MAXN][2];

void dfs(int u, int p)
{
	dp[u][0]=dp[u][1]=1;
	for(int v: adj[u])
	{
		if(v==p) continue;
		dfs(v,u);
		dp[u][0]=mult(dp[u][0], add(dp[v][0], dp[v][1]));
		dp[u][1]=mult(dp[u][1], dp[v][0]);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n-1)
	{
		int u,v; cin>>u>>v; u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	dfs(0,-1);
	
	cout<<add(dp[0][0], dp[0][1])<<'\n';
	
	return 0;
}


Measured memory_bytes: 17612
s = input()

ans = 0
n = len(s) - 1
for bit in range(1 << n):
    siki = s[0]

    for i in range(n):
        if bit & (1 << i):
            siki += "+"
        siki += s[i + 1]

    for i in siki.split("+"):
        ans += int(i)

print(ans)

Measured memory_bytes: 3060
{$goto+}
{$asmmode intel}
label 1,2;
var a:array[0..100000]of longint;
    n,x,i:longint;
    ans:int64;
begin
  readln(n,x);
  i:=-1;
  1:i:=-not i;
  read(a[i]);
  if i<not-n then
    goto 1;
  i:=-1;
  2:i:=-not i;
  if a[i]+a[i+1]>x then
  begin
    inc(ans,a[i]+a[i+1]-x);
    if a[i]<=x then
      a[i+1]:=x-a[i]
    else
    begin
      a[i+1]:=0;
      a[i]:=x;
    end;
  end;
  if i<not-not-n then
    goto 2;
  writeln(ans);
end.

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int visit[8];
int perm[8];
int floyd[201][201];
int main()
{
	int n,m,r;
	scanf("%d%d%d",&n,&m,&r);
	for(int i = 0;i < r;++i) {
		scanf("%d",&visit[i]);
		--visit[i];
		perm[i] = i;
	}
	memset(floyd,-1,sizeof(floyd));
	for(int i = 0;i < m;++i) {
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);--a,--b;
		if(floyd[a][b] == -1 || floyd[a][b] > c) floyd[a][b] = floyd[b][a] = c;
	}
	for(int k = 0;k < n;++k) {
		for(int i = 0;i < n;++i) if(floyd[i][k] != -1) {
			for(int j = 0;j < n;++j) if(floyd[k][j] != -1) {
				if(floyd[i][j] == -1 || floyd[i][j] > floyd[i][k] + floyd[k][j])
					floyd[i][j] = floyd[i][k] + floyd[k][j];
			}
		}
	}
	
	int minans = -1;
	do {
		int ans = 0;
		for(int i = 1;i < r;++i)
			ans += floyd[visit[perm[i-1]]][visit[perm[i]]];
		if(minans == -1 || minans > ans) minans = ans;
	} while(std::next_permutation(perm,perm+r));
	printf("%d\n",minans);
}

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

int main() {
    for (int j = 0; j < 9; ++j) {
        string className;
        int am, pm;
        cin >> className >> am >> pm;
        cout << className << ' ' << (am+pm) << ' ' << (200*am + 300*pm) << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
# /usr/bin/python
# -*- coding: utf-8 -*-
#
# import sys
# import math


An = [[0 for j in range(3)] for i in range(3)]
Bn = [[0 for j in range(3)] for i in range(3)]
for i in range(3):
  a = list(map(int, input().split()))
  for j in range(3):
    An[i][j] = a[j]
    Bn[j][i] = a[j]


def check(cn):
  for i in range(2):
    dif0 = cn[i][0]-cn[i+1][0]
    dif1 = cn[i][1]-cn[i+1][1]
    dif2 = cn[i][2]-cn[i+1][2]
    if dif0 != dif1 or dif1 != dif2:
      return False
  return True

if check(An) and check(Bn):
  print("Yes")
else:
  print("No")



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pll pair <long long,long long>
#define fi first
#define se second
#define ll long long
using namespace std;
ll d[100002],a[100002];
int main () {
	ios;
	ll n,m;
	cin>>n>>m;	
	fill(d+1,d+n+1,1e18);
	for (int k=1;k<=n;k++) cin>>a[k];
	d[1]=0;
	if (n==1) d[1]=a[1];
	for (int k=2;k<=n;k++) {
		for (int j=k-1;j>=k-m&&j>=1;j--) {
			if (d[j]+abs(a[k]-a[j])<d[k]) d[k]=d[j]+abs(a[k]-a[j]);
		}
	}
	cout<<d[n];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

long long x3[50];

int main() {
  long long t;
  while (cin >> t) {
    if (t == 0) { cout << 0 << endl; continue; }
    int cnt = 1;
    long long remain = t;
    int i = 0;
    x3[i] = 1;
    while (x3[i] * 4 <= remain) {
      remain -= x3[i] * 4;
      x3[i+1] = x3[i] * 3;
      ++i;
      cnt += 2;
    }
    // cout << i << " " << cnt << " " << remain << endl;
    for (int j = i; j >= 0; --j) {
      cnt += remain / x3[j];
      remain %= x3[j];
    }
    cout << cnt-1 << endl;
  }
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC101();
}

void ABC101(){
    int n,i,k,sum=0,d=1;
    cin>>n;
    for(i=0;i<10;i++){
        sum+=(n/d)%10;
        d*=10;
    }
    if(n%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int64_t
#define ar array
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (n); ++i) 
using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    for(int crane = 0;crane<=x;crane++){
        if(crane*2+(x-crane)*4==y){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}



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

int main(){
  ll n; cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  ll ans=(n/10),div=100,c=0;
  
  div=50;
  while(n/div!=0){
    ans+=(n/div);
    div*=5;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  ll k;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i, n){
    cin >>a[i];
  }
  ll x=0;
  for(int i=41;i>=0; i--){
    ll tmp=1ll<<i;
    if(x+tmp>k)continue;
    int zero=0, one=0;
    rep(j, n){
      if((a[j]>>i)&1){
        one++;
      } else {
        zero++;
      }
    }
    if(zero>one){
      x+=tmp;
    }
  }
  ll ans=0;
  rep(i, n){
    ans+=a[i]^x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048
import java.io.*
import java.util.*

fun solve(a: Long, b: Long){
    when((a*b)%2){
        0L -> "Even"
        else -> "Odd"
    }.let{println(it)}
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next().toLong()
    val b = sc.next().toLong()
    solve(a, b)
}



Measured memory_bytes: 29720
#include<stdio.h>

int main(){
  int m,f,r;
  int i,j;
  int e[1000];
  for(i=0;i<1000;i++){
    scanf("%d %d %d",&m,&f,&r);
    if(m<0&&f<0&&r<0){
      break;
    }
    else if(m<0||f<0){
      e[i]=0;
    }
    else if(r<0){
      if(m+f>=80){
        e[i]=1;
      }
      else if(m+f>=65){
        e[i]=2;
      }
      else if(m+f>=50){
        e[i]=3;
      }
      else if(m+f>=30){
        e[i]=4;
      }
      else{
        e[i]=0;
      }
    }
    else{
      if(r>=50){
        e[i]=3;
      }
      else if(m+f>=30){
        e[i]=4;
      }
      else{
        e[i]=0;
      }
    }
  }
  for(j=0;j<i;j++){
    switch(e[j]){
      case 0:printf("F\n");break;
      case 1:printf("A\n");break;
      case 2:printf("B\n");break;
      case 3:printf("C\n");break;
      case 4:printf("D\n");break;
    }
  }

  return 0;
}

Measured memory_bytes: 2548
#include<stdio.h>
main()
{
	int a,b,k,i,t=0;
	scanf("%d %d %d",&k,&a,&b);
	for(i=a;i<=b;i++)
	{
		if(i%k==0) 
		{
			t++;
			printf("OK");
			break;
		}
	}
	if(t==0) printf("NG");
}

Measured memory_bytes: 2116
import math
atan = lambda x: math.degrees(math.atan(x))
a, b, x = map(int, input().split())
s = a ** 2 * b
if x >= s / 2:
    theta = atan(2 * (s - x) / (a ** 3))
else:
    theta = atan(a * b ** 2 / 2 / x)
print(theta)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<string>
typedef long long int ll;
using namespace std;

int main(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
	int ans = a-b;
	if(k%2==0){
		cout<<ans<<endl;
	}else{
		cout<<-ans<<endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi t(N),a(N);
  rep(i,N) {
    cin >> t[i];
  }
  rep(i,N) {
    cin >> a[i];
  }
  vi ans(N,-1);
  rep(i,N) {
    if(i == 0){
      ans[i] = t[i];
    } else if(t[i-1] != t[i]) {
      ans[i] = t[i];
    }
  }
  drep(i,N) {
    if(i == N-1) {
      if(ans[i] == -1) {
        ans[i] = a[i];
      } else {
        if(ans[i] > a[i]){
          cout << 0 << endl;
          return 0;
        }
      }
    } else {
      if(a[i] == a[i+1]) continue;
      if(ans[i] == -1) {
        if(t[i] < a[i]) {
          cout << 0 << endl;
          return 0;
        } else {
          ans[i] = a[i];
        }

      } else {
        if(ans[i] < a[i]){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  ll c = 1;
  rep(i,N) {
    if(ans[i] == -1) {
      c *= min(t[i],a[i]);
    }
    c %= MOD;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 1536
// --------------
// Tejas Pandey  |
// 22 - 08 - 20  |
// Atcoder BC 176|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int ot = 0;
  for(int i = 0;i < (int)s.size();i++)
	ot += (s[i] - '0');
  if(ot%9) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (int n; cin >> n&&n;) {
		string s[1001];
		int J[1001]; //.????????°

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

			int j = 0;
			while (j < s[i].size()) {
				if (s[i][j] == '.') {
					s[i][j] = ' ';
					j++;
				}
				else
					break;
			}

			J[i] = j;
			if (J[i])s[i][J[i]-1] = '+';
		}

		//|?????\
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++) {
				if (J[i] > J[j])break;
				if (J[i] == J[j]) {
					for (int k = i + 1; k < j; k++)
						s[k][J[i]-1] = '|';
					break;
				}
			}

		for (int i = 0; i < n; i++)
			cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1992
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;

typedef long long i64;
typedef vector<i64> vx;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<pii> spii;

static const int dI[]={-1, -1, -1, 0, 0, 0, 1, 1, 1};
static const int dJ[]={-1, 0, 1, -1, 0, 1, -1, 0, 1};

void count_black(
        pii &coord, spii &canvas, vx &black, spii &visited, i64 &H, i64 &W
) {
    int k;
    for (k=0; k<9; k++) {
        int I=coord.first+dI[k];
        int J=coord.second+dJ[k];

        if (!(1<=I && I<H-1 && 1<=J && J<W-1)) continue;
        if (visited.count(pii(I, J))) continue;

        int tmp=0;
        int m;
        for (m=0; m<9; m++)
            if (canvas.count(pii(I+dI[m], J+dJ[m])))
                tmp++;

        black[tmp]++;
        visited.insert(pii(I, J));
    }
}

int main(void) {
    i64 H, W, N;
    cin >> H >> W >> N;

    spii canvas;
    int i;
    for (i=0; i<N; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        canvas.insert(pii(a-1, b-1));
    }

    spii visited;
    vx black(12);

    for (pii coord: canvas)
        count_black(coord, canvas, black, visited, H, W);

    i64 white=(H-2)*(W-2);
    for (i=1; i<=9; i++)
        white -= black[i];

    cout << white << endl;
    for (i=1; i<=9; i++)
        cout << black[i] << endl;

    return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*

左から、1 2 3 4 ...の部分列が存在するかどうか

3 1 4 1 5 9 2 6 5 3

0 1 1 1 1 1 2 2 2 3

*/


int a[200010];
int b[200010];

void solve(){

    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }

    rep(i,n){
        b[i]=-1;
    }

    if(a[0]==1){
        b[0]=1;
    }
    else{
        b[0]=0;
    }
    for(int i = 1; i<n; i++){
        if(b[i-1]+1==a[i]){
            b[i]=a[i];
        }
        else{
            b[i]=b[i-1];
        }
        //cout << i << " " << b[i] << endl;
    }
    if(b[n-1]!=0){
        cout << n-b[n-1] << endl;
    }
    else{
        cout << -1 << endl;
    }

}

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


Measured memory_bytes: 1792
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
key = dict()
for i in range(n):
  if a[i] in key:
    key[a[i]] += 1
  else:
    key[a[i]] = 1
count = []
c = 0
for value in key.values():
  count.append(value)
  c += 1
count.sort()
ans = 0
for i in range(max([0, c-k])):
  ans += count[i]
print(ans)

Measured memory_bytes: 32520
#include <stdio.h>

#define MAX 2000000

void maxHeapify(int *, int);
void buildMaxHeap(int *);
void insert(int *, int);
int extractMax(int *);

int H=0;

int main(void)
{
	int k, Q[MAX+1];
	char com[10];
	
	while (1) {
		scanf("%s",com);
		if (com[0]=='e' && com[1]=='n') break;
		if (com[0]=='i') {
			scanf("%d",&k);
			insert(Q, k);
		} else {
			printf("%d\n", extractMax(Q));
		}
	}
	
	return 0;
}

void maxHeapify(int *A, int i)
{
	int l, r, largest, temp;
	
	l = 2*i;
	r = 2*i + 1;
	if (l<=H && A[l] > A[i]) {
		largest = l;
	} else {
		largest = i;
	}
	if (r<=H && A[r] > A[largest]) {
		largest = r;
	}
	
	if (largest!=i) {
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(A, largest);
	}
}

void insert(int *A, int k)
{
	int i, p, temp;
	
	A[++H] = k;
	i = H;
	p = i/2;
	while (p>=1) {
		if (A[i] > A[p]) {
			temp = A[i];
			A[i] = A[p];
			A[p] = temp;
			i = p;
			p = i/2;
		} else {
			break;
		}
	}
}

int extractMax(int *A)
{
	int max;
	
	max = A[1];
	A[1] = A[H--];
	maxHeapify(A, 1);
	return max;
}

Measured memory_bytes: 6352
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

eof = false

until eof do
	n,x = array_integer(STDIN.gets.split(" "))
	
	if n == 0 && x == 0 then
		eof = true
		break
	end

	if x < 6 then
		print "0\n"
		next
	end

	answer_num = 0
	
	
	1.upto(n-2) {|i|
		if ((i * 3) + 2) > x then
			break
		end
		(i+1).upto(n-1) {|j|
			if (i + (j * 2) + 1) > x then
				break
			end
			(j+1).upto(n) {|k|
				if i + j + k > x then
					break
				elsif i + j + k == x then
					answer_num += 1
				end
			}
		}
	}
	print answer_num, "\n"
end



Measured memory_bytes: 6872
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(int, const char**)
{
    int x, y;
    cin >> x >> y;
    rep(i, x + 1)
    {
        auto a = i;
        auto b = x - i;
        if(a * 2 + 4 * b == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

const int N = 210;
typedef long long LL;

LL dp[N*2][N][N];
int n, m, mat[N][N];

void mv(int x1, int y1, int x2, int y2, LL v){
    int len = x1 + y1;
    if(x1==x2){
        if(x1==n-1 && y1==m-1){
            dp[len][x1][x2] = max(dp[len][x1][x2], v);
        }
        return;
    }
    dp[len][x1][x2] = max(dp[len][x1][x2], v + mat[x1][y1] + mat[x2][y2]);
}

int main(){
    while(~scanf("%d %d", &n, &m)){
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                scanf("%d", &mat[i][j]);
            }
        }
        LL ans = mat[0][0] + mat[n-1][m-1];
        mat[0][0] = mat[n-1][m-1] = 0;
        memset(dp, -1, sizeof(dp));
        dp[0][0][0] = 0;
        int len = n + m - 2;
        int x1, y1, x2, y2;
        for(int i=0; i<len; i++){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    if(dp[i][j][k] == -1)   continue;
                    x1 = j;
                    y1 = i - j;
                    x2 = k;
                    y2 = i - k;
                    mv(x1+1, y1, x2+1, y2, dp[i][j][k]);
                    mv(x1+1, y1, x2, y2+1, dp[i][j][k]);
                    mv(x1, y1+1, x2+1, y2, dp[i][j][k]);
                    mv(x1, y1+1, x2, y2+1, dp[i][j][k]);
                }
            }
        }
        printf("%lld\n", ans + dp[len][n-1][n-1]);
    }
    return 0;
}


Measured memory_bytes: 145152
#include <bits/stdc++.h>
#define fto(i, x, y) for (int i=(x); i <= (y); ++i)
#define fdto(i, x, y) for (int i=(x); i >= (y); --i)
#define forit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define forrit(it, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)
#define pb push_back
#define mp make_pair
#define ii pair<int, int>
#define vi vector<int>
#define fi first
#define se second
#define ll long long
#define oo 1000000007
#define maxN 100005

const double pi = acos(-1);

using namespace std;

int n, k;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k;
    int ans = 1;
    fto(i, 1, n){
        if (ans*2 < ans+k) ans *= 2;
        else ans += k;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next , now)

dfs(0)
print(*point)

Measured memory_bytes: 268440
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)
 
for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

for	i in range(n-1):
	T[i] = s[i] + c[i]
	for j in range(i+1,n-1):
		if T[i] > s[j]:
			T[i] = -((-T[i]//f[j]))*f[j] + c[j]
		else:
			T[i] = s[j] + c[j]
	print(T[i])
print(0)

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

using namespace std;

string s;
set<char> st;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	for(int i = 0; i < s.length(); i++) st.insert(s[i]);
	if ((st.find('E') != st.end() && st.find('W') == st.end()) || (st.find('E') == st.end() && st.find('W') != st.end())) cout << "No" << endl;
	else if ((st.find('S') != st.end() && st.find('N') == st.end()) || (st.find('S') == st.end() && st.find('N') != st.end())) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x == y:
        return 0
    if x<y:x,y=y,x    
    par[x]=y
n,m=map(int,input().split())
par=[i for i in range(n+1)]
for _ in range(m):
    i,j=map(int,input().split())
    unite(i,j)
ans=[0]*(n+1)
for i in range(n+1):
    find(i)
for i in par:
    ans[i]+=1
print(max(ans))

Measured memory_bytes: 18504
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        StringBuilder S = new StringBuilder();
        S.append("i");
        S.append(sc.next());
        long r =0,g=0,b=0;
        for(int i=1;i<=N;i++){
            if(S.charAt(i)=='R') r++;
            else if(S.charAt(i)=='G')g++;
            else if(S.charAt(i)=='B')b++;
        }
        long opt = r*g*b;
        for(int i=1;i<=N-1;i++){
            for(int j=i+1;j<=(N+i)/2;j++){
                int k = 2*j-i;
                if(S.charAt(i)!=S.charAt(j)&&S.charAt(j)!=S.charAt(k)&&S.charAt(i)!=S.charAt(k))opt--;
            }
        }
        if(opt>=0)System.out.println(opt);
        else System.out.println(0);
    }
}

Measured memory_bytes: 36240
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  for(int c = 0; c < 26; ++c) { int a; std::cin >> a; }
  int s[26];
  for(int d = 0; d < D; ++d) {
    for(int c = 0; c < 26; ++c) std::cin >> s[c];
    int t = 1 + std::max_element(s, s+26) - s;
    std::cout << t << "\n";
  }
  return 0;
}


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

int main() {
    
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3,0));
    for(int i=0;i<n;i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    vector<vector<int>> ans(n,vector<int>(3,0));
    ans[0][0]=v[0][0];
    ans[0][1]=v[0][1];
    ans[0][2]=v[0][2];
    for(int i=1;i<n;i++){
        ans[i][0]=max(ans[i-1][1],ans[i-1][2])+v[i][0];
        ans[i][1]=max(ans[i-1][0],ans[i-1][2])+v[i][1];
        ans[i][2]=max(ans[i-1][1],ans[i-1][0])+v[i][2];
    }
    cout<<max({ans[n-1][0],ans[n-1][1],ans[n-1][2]});
    
    return 0;
}

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

int main(){
    long long n, m;
    cin >> n >> m;
    if((n == 1) && (m == 1)){
        cout << 1 << endl;
    }
    else if(n == 1){
        cout << m-2 << endl;
    }
    else if(m == 1){
        cout << n-2 << endl;
    }
    else{
        cout << (n-2) * (m-2) << endl;
    }
}

Measured memory_bytes: 256
L1=input()
n=int(L1)
L=input().split( )

j=1
max=int(L[0])
min=int(L[0])
sum=int(L[0])

while j<=n-1:
    sum=sum+int(L[j])
    if max<int(L[j]):
        max=int(L[j])
    if min>int(L[j]):
        min=int(L[j])
    j+=1

print(f"{min} {max} {sum}")


Measured memory_bytes: 6340
#include"bits/stdc++.h"
using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO;
	int n;
	bool ok=true;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			ok=false;
			break;
		}
	}
	if(ok) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}


Measured memory_bytes: 5216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int[] Boxes = new int[3];
		Boxes[0] = Integer.parseInt(ST.nextToken()); Boxes[1] = Integer.parseInt(ST.nextToken()); Boxes[2] = Integer.parseInt(ST.nextToken());
		int tempA = Boxes[0], tempB = Boxes[1], tempC = Boxes[2];
		Boxes[0] = tempB;
		Boxes[1] = tempA;
		tempA = Boxes[0];
		Boxes[0] = tempC;
		Boxes[2] = tempA;
		System.out.println(Boxes[0] + " " + Boxes[1] + " " + Boxes[2]);
	}
}


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

int main()
{
  int l, r, d;

  cin >> l >> r >> d;

  int count = 0;

  for (int i = l; i <= r; i++)
  {
    if (i % d == 0)
      count++;
  }

  cout << count;

  // vector<int> a(n);

  // rep(i, n)
  // {
  //   cin >> a.at(i);
  // }
}


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

int main (){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; ++i) {
    cin >> vec.at(i);
  }
  vector<int> cost(N);
  cost.at(1) = abs(vec.at(1)-vec.at(0));
  for (int j=2; j<N; ++j) {
    int a = cost.at(j-1)+abs(vec.at(j-1)-vec.at(j));
    int b = cost.at(j-2)+abs(vec.at(j-2)-vec.at(j));
    cost.at(j) = min(a,b);
  }
  cout << cost.at(N-1);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main(){
    initcom();
    int h,w,a,b;cin>>h>>w>>a>>b;
    ll ans=0;
    for(int i=1;i<=h-a;++i){
        ans=(ans+com(h-a+b-1,i-1)*com(w+a-b-1,h-i)%MOD)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26620
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n;
double a[55],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	ans=a[1];
	for(int i=2;i<=n;i++)
		ans+=a[i],ans/=2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let p = parse_vec!(u32);
    let mut i = 1;
    let mut ans = 0;
    for x in &p {
        if *x != i {
            ans = ans + 1;
        }
        i = i + 1;
    }
    if ans == 0 || ans == 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) (int)(a.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;












#define int long long

const int INF = 1e14;

signed main(){
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 0; i < n + 1; i++) cin >> a[i];
    int now = 1;
    int b[n + 1];
    for (int i = 0; i < n + 1; i++){
        if (now < a[i]){
            cout << "-1";
            return 0;
        }
        now -= a[i];
        b[i] = now;
        now *= 2;
        now = min(now, INF);
    }
    int coun = a[n];
    int lastr = a[n];
    //cout << lastr << endl;
    for (int i = n - 1; i >= 0; i--){
        int ro = a[i] + lastr;
        coun += min(ro, b[i] + a[i]);
        lastr = min(ro, b[i] + a[i]);
     //   cout << lastr << endl;
    }
    cout << coun;
}


Measured memory_bytes: 5148