akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

int dp[100000+10][3];
int abc[100000+10][3];
signed main(){
	int N;cin>>N;
	for(int i=0;i<N;i++){
		cin>>abc[i][0]>>abc[i][1]>>abc[i][2];
	}
	dp[0][0]=abc[0][0];
	dp[0][1]=abc[0][1];
	dp[0][2]=abc[0][2];
	for(int i=1;i<N;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(k==j)continue;
				dp[i][j]=max(dp[i][j],abc[i][j]+dp[i-1][k]);
			}
		}
	}
	int ans=max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string S;
  cin >> S;
  
  stack<char> ans;
  for( int i = 0; i < S.size(); i++ ){
    if( S.at(i) == 'S' ){
      ans.push('S');
    }else{
      if( ans.empty() ) ans.push('T');
      else if( ans.top() == 'T' ) ans.push('T');
      else if( ans.top() == 'S' ) ans.pop();
    }
  }
  cout << ans.size() << endl;
}


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

int main(void){
	string s;
	cin >> s;
	int n[2] = {0, 0};
	for(int i = 0; i < s.size(); ++i){
		n[s[i]-'0']++;
	}
	cout << 2 * min(n[0],n[1]) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int x,a=0,t=0;
    scanf("%d",&x);
    if(x<500) printf("%d\n",x-x%5);
    else
    {
        a=x/500;
        t=a*500+x-x%5;
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 256
int main(void){
  int L,R,d,n,i;
  n=0;
  scanf("%d %d %d",&L,&R,&d);
  if(L<0||L>R||R>100||d<0||d>100){
    return 0;
  }
  
  for(i=L;i<=R;i++){
    if(i%d==0){
      n++;
    }
  }
  printf("%d",n);
  
  return 0;
}


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


/**
 * AIZU ONLINE JUDGE
 * 2522
 *  2020/5/6
 */
public class Main {

    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        String s = sc.nextLine();
        
        boolean valid = false;
        
        if (s.length() < 6) {
            valid = false;
        }
        else {
            boolean num = false;
            boolean small = false;
            boolean big = false;
            for(int i = 0; i < s.length(); i++) {
                int c = s.charAt(i);
                if ('0' <= c && c <= '9') {
                    num = true;
                }
                else if ('a' <= c && c <= 'z') {
                    small = true;
                }
                else if ('A' <= c && c <= 'Z') {
                    big = true;
                }
            }
            if (num && small && big)
                valid = true;
        }
        
        result.printf("%s\n", valid ? "VALID" : "INVALID");

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 26476
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
long long modpow(long long a, long long n, long long MOD1) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
         if (n & 1) res = res * a % MOD1;
         a= a * a % MOD1;//次の準備
         n >>= 1;
      }
 return res;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string L;cin>>L;
    ll ans=0;
    ll dp[100010];
    memset(dp, 0, sizeof(dp));
    dp[0]=1;
    for(ll i=0;i<L.length();i++){
        if(L[i]=='1'){
            dp[i+1]=2*dp[i];
            ans+=modpow(3, L.length()-i-1, MOD)*dp[i];
            ans%=MOD;
        }
        else
            dp[i+1]=dp[i];
        dp[i+1]%=MOD;
    }
    ans+=dp[L.length()];
    

    
    cout<<ans%MOD<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N;
    cin >> N;
    ll sum  = 0;
    FOR(i,1,N+1) {
        bool cond1 = i%3 == 0;
        bool cond2 = i%5 == 0;
        if (cond1 || cond2) continue;
        else sum+=i;
    }

    cout << sum << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int h, w;
	cin >> h >> w;
	vvi a(h + 2, vi(w + 2, 0));
	string s;
	int cou = 0;
	rep(i, 0, h) {
		cin >> s;
		rep(j, 0, w) {
			if (s[j] == '.') {
				cou++;
				a[i + 1][j + 1] = 1;
			}
		}
	}

	int dx[] = { 0,1,0,-1 };
	int dy[] = { 1,0,-1,0 };
	queue<pi> que;
	que.push({ 1,1 });
	vvi dist(h + 2, vi(w + 2, 1e9));
	dist[1][1] = 1;
	while (!que.empty()) {
		pi p = que.front();
		que.pop();
		int x = p.first;
		int y = p.second;
		rep(i, 0, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (a[ny][nx] && dist[y][x] + 1 < dist[ny][nx]) {
				dist[ny][nx] = dist[y][x] + 1;
				que.push({ nx,ny });
			}
		}
	}
	if (dist[h][w] == 1e9) {
		cout << -1 << endl;
	}
	else {
		cout << cou - dist[h][w] << endl;
	}
	return 0;
}

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

#define sc(a) scanf("%d",&a)
#define scm(a,b) scanf("%d%d",&a,&b)
#define fl(c,i,n) for(int i=c;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long int
#define ull unsigned long long int
#define inf INT_MAX
#define linf LLONG_MAX
#define pb push_back
#define pp pop_back()
#define aov(a) a.begin(),a.end()
//#define mp make_pair
#define nl printf("\n")
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)
#define xx first
#define yy second
#define mxv(a) *max_element(aov(a))
#define mnv(a) *min_element(aov(a))
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
#define to_c_string(a) a.c_str()
#define strtoint(c) atoi(&c[0])
#define pii pair<int,int>
#define MAXN 500005
#define MOD 1000000007

template <class T> inline T bigmod(T p,T e,T M){
    ll ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
/*int fact[MAXN];
int invfact[MAXN];
int inv(int a, int b){
    if(b==0)
        return 1;
    if(b&1)
        return (long long)a*inv(a, b-1)%MOD;
    else{
        int res = inv(a, b>>1);
        return (long long)res*res%MOD;
    }
}
void init(){
    fact[0] = 1;
    for(int i=1;i<MAXN;i++){
        fact[i] = (long long)fact[i-1]*i%MOD;
    }
    invfact[MAXN-1] = inv(fact[MAXN-1], MOD-2);
    for(int i=MAXN-1;i>0;i--){
        invfact[i-1] = (long long)invfact[i]*i%MOD;
    }
}
int C(int n, int r){
    if(r>n || r<0)
        return 0;
    return (long long)((long long)fact[n]*invfact[r]%MOD)*invfact[n-r]%MOD;
}*/
int n, arr[400005];
void solve(){
    sc(n);
    f(i, 3*n)   sc(arr[i]);
    sort(arr, arr+(3*n));
    int inc = 3*n - 2;
    ll ans = 0;
    f(i, n){
        ans+=arr[inc];
        inc-=2;
    }
    cout<<ans;
}
int main(){
    /*FILE *fin = freopen("C-small-attempt0.in", "r", stdin);
	assert( fin!=NULL );
	FILE *fout = freopen("C-small.out", "w", stdout);*/
	//init();
    solve();
    return 0;
}


Measured memory_bytes: 1408
n,x=map(int,input().split())
l=list(map(int,input().split()))
cnt=1
d=[0 for _ in range(n+1)]
d[0]=0
for i in range(1,n+1):
    d[i]=d[i-1]+l[i-1]
    if d[i]<=x:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
def judge(li, lj, lk):
    return li != lj and lj != lk and li != lk and li + lj > lk and lj + lk > li and li + lk > lj


if __name__ == "__main__":
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if judge(L[i], L[j], L[k]):
                    ans += 1
    print(ans)


Measured memory_bytes: 9080
# code-festival-2016-qualaC - 次のアルファベット / Next Letter
def main():
    S = input().rstrip()
    K = int(input())
    abc = "abcdefghijklmnopqrstuvwxyz"
    # dist[c] := distance to "a" through "z"
    dist = {c: 26 - i for i, c in enumerate(abc)}
    dist["a"] = 0
    A = [dist[i] for i in S]
    ans = ""
    for i, s in zip(A[:-1], S[:-1]):
        if 0 < i <= K:  # change s to "a" if possible
            ans += "a"
            K -= i
        else:
            ans += s
    # use the remaining K on A[-1] and combine with ans
    ans += chr((ord(S[-1]) + K - ord("a")) % 26 + ord("a"))
    print(ans)


if __name__ == "__main__":
    main()

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

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll a,b,c; cin >> a >> b >> c;
  
  if(a == b and b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3584
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
 
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	string s;
	cin >> s;
	int cnt = 0;
	int mx = 0;
	for(int i = 0;i<sz(s);i++)
	{
		if(s[i]=='R')
		{
			cnt++;
			mx = max(mx,cnt);
		}else{
			mx = max(mx,cnt);
			cnt = 0;
		}
	}
	cout << mx << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;



int main() {
	ll n;
	cin>>n;
	ll a[n][3];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	ll a1=a[0][0],b1=a[0][1],c1=a[0][2];
	ll a2,b2,c2;
	for(ll i=1;i<n;i++){
		a2=max(b1+a[i][0],c1+a[i][0]);
		b2=max(a1+a[i][1],c1+a[i][1]);
		c2=max(a1+a[i][2],b1+a[i][2]);
		a1=a2,b1=b2,c1=c2;
	}
	cout<<max(a1,max(b1,c1))<<endl;
}









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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

char str[N];

int main() {

	File();

	scanf ("%s", str + 1);
	int ans = 0;

	For (i, 1, strlen(str + 1) - 1)
		if (str[i] != str[i + 1]) ++ ans;
	printf ("%d\n", ans);

    return 0;

}


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

int main() {
  int N, l, r, sum;
  
  cin >> N;
  sum = 0;
  
  for(int i; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final DecimalFormat fmt = new DecimalFormat("0.########");
    public static void main(String[] Args) throws IOException{
        final double x1 = Double.parseDouble(sc.next());
        final double y1 = Double.parseDouble(sc.next());
        final double x2 = Double.parseDouble(sc.next());
        final double y2 = Double.parseDouble(sc.next());
        System.out.println(fmt.format(Math.hypot(x2-x1, y2-y1)));
    }
}

Measured memory_bytes: 26188
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations_with_replacement, compress
import sys
import math
import bisect
 
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
 
 
def I(): return int(sys.stdin.readline())
 
 
def LS(): return [list(x) for x in sys.stdin.readline().split()]
 
 
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
 
 
def IR(n):
    return [I() for i in range(n)]
 
 
def LIR(n):
    return [LI() for i in range(n)]
 
 
def SR(n):
    return [S() for i in range(n)]
 
 
def LSR(n):
    return [LS() for i in range(n)]
 
 
sys.setrecursionlimit(1000000)
 
 
def main():
    N, M, Q = LI()
    abcd = [LI() for _ in range(Q)]
    ans = 0
 
    for A in combinations_with_replacement(range(1, M + 1), N):
        tmp = 0
        for (a, b, c, d) in abcd:
            tmp += d if (A[b-1] - A[a-1] == c) else 0
        ans = max(ans, tmp)
    print(ans)
 
 
main()

Measured memory_bytes: 9492
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());
#define usort(a) sort(a.rbegin(),a.rend());

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

ll int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  ll int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
ll  int lcm(ll int c,ll int d){//最小公倍数
  ll int p=(c*d)/(gcd(c,d));
  return p;
}


int main(){
  ll int A,B,C;
  string S,T,U;
  cin>>A>>B;
  cout<<lcm(A,B);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート
//  sort(変数名.rbegin(),変数名.rend());//降順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 256
fun main(args: Array<String>) {
    edpc()
}

fun edpc() {
    val n = readLine()!!.toInt()
    val vacations = (1..n).map { readLine()!!.split(" ").map { it.toLong() } }

    // 海、山、家を選んだときの累計幸福度
    val totalHappiness = Array(3) { LongArray(vacations.size) }

    totalHappiness[0][0] = vacations[0][0]
    totalHappiness[1][0] = vacations[0][1]
    totalHappiness[2][0] = vacations[0][2]

    (1 until vacations.size).forEach {
        val beforeTotal0 = totalHappiness[0][it - 1]
        val beforeTotal1 = totalHappiness[1][it - 1]
        val beforeTotal2 = totalHappiness[2][it - 1]

        val today0 = vacations[it][0]
        val today1 = vacations[it][1]
        val today2 = vacations[it][2]

        totalHappiness[0][it] = today0 + Math.max(beforeTotal1, beforeTotal2)
        totalHappiness[1][it] = today1 + Math.max(beforeTotal0, beforeTotal2)
        totalHappiness[2][it] = today2 + Math.max(beforeTotal0, beforeTotal1)
    }

    val answer = totalHappiness.maxBy { it[n - 1] }!!

    println(answer[n - 1])
}


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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;



int main()
{
    SAM;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(c>b && b>a)
    {
        cout<<"Yes";
        return 0;
    }
    
    int count=0;
    while(b<=a)
    {
        b*=2;
        count++;
    }
    while(c<=b)
    {
        c*=2;
        count++;
    }
    
    if(count<=k)
        cout<<"Yes";
    else
        cout<<"No";
    
    
    return 0;
}




Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
  int a,b,d;
  while(cin >> a >> b >> d,a||b||d){
    int x=1,y=0;
    int ox=1<<20,oy=1<<20;
    while(a*x<d) x++;
    while((a*x-d)%b!=0) x++;
    y=(a*x-d)/b;
    //cout << x <<":"<<y<<endl;
    if(x+y<ox+oy){
      ox=x;oy=y;
    }else if(x+y==ox+oy){
      if(a*x+b*y<a*ox+b*oy){
	ox=x;oy=y;
      }
    }
    x=0;y=1;
    while(b*y<d) y++;
    while((b*y-d)%a!=0) y++;
    x=(b*y-d)/a;
    //cout << x <<":"<<y<<endl;
    if(x+y<ox+oy){
      ox=x;oy=y;
    }else if(x+y==ox+oy){
      if(a*x+b*y<a*ox+b*oy){
	ox=x;oy=y;
      }
    }
    x=1;y=0;
    while((d-a*x)%b!=0&&d>=a*x) x++;
    if(d>=a*x){
      y=(d-a*x)/b;
      //cout << x <<":"<<y<<endl;
      if(x+y<ox+oy){
	ox=x;oy=y;
      }else if(x+y==ox+oy){
	if(a*x+b*y<a*ox+b*oy){
	  ox=x;oy=y;
	}
      }
    }
    x=0;y=1;
    while((d-b*y)%a!=0&&d>=b*y) y++;
    if(d>=b*y){
      x=(d-b*y)/a;
      //cout << x <<":"<<y<<endl;
      if(x+y<ox+oy){
	ox=x;oy=y;
      }else if(x+y==ox+oy){
	if(a*x+b*y<a*ox+b*oy){
	  ox=x;oy=y;
	}
      }
    }
    cout << ox << " " << oy << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    char c = s[n-1];
    if(c == '3')cout << "bon" << endl;
    else if(c == '0' ||c=='1'||c=='6' || c =='8')cout << "pon" << endl;
    else cout << "hon" << endl;
    //cout << c << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<ll> G[200010];
int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        ll a,b;
        cin >> a >> b;
        if (a > b) swap(a,b);
        G[b].push_back(a);
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += (1 + i) * i / 2;
    }
    for (ll i = 1; i <= n; i++) {
        ll mul = n - i + 1;
        ll pre = 0;
        ll sum = 0;
        for (int j = 0; j < G[i].size(); j++) {
            sum += (G[i].size() - j) * (G[i][j] - pre);
            pre = G[i][j];
        }
        ans -= sum * mul;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14472
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    const int MAXN = 100010;
    vector<int> seg(MAXN+5);
    seg[0] = 1;
    for(int i=0; i<N; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        seg[a]++, seg[b+1]--;
    }

    for(int i=1; i<=MAXN+3; i++) seg[i] += seg[i-1];

    int ans = -1;
    for(int i=1; i<=MAXN; i++) {
        if(seg[i] >= i) {
            chmax(ans, i-1);
        }
    }
    printf("%d\n", ans);
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

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

  string s;
  cin >> s;

  for (ll i = 0; i < s.size(); ++i) {
    s[i] += n;
    if (s[i] > 90) s[i] = 64+s[i]-90;
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
use proconio::{input};

fn main() {
    input! {
        n: i32,
        x: i32,
        t: i32,
    }

    let ans;
    if n % x == 0 {
        ans = t * (n / x)
    } else {
        ans = t * (n / x + 1)
    }

    println!("{}", ans);
}

Measured memory_bytes: 2132
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
    vector<ll> vans,v;
    if(n%2==0){
        REP(i,0,n/2){
            REP(j,0,2) vans.push_back(i*2+1);
        }
    }else{
        vans.push_back(0);
        REP(i,0,(n-1)/2){
            REP(j,0,2) vans.push_back(2*i+2);
        }
    }
    
    REP(i,0,n){
        ll tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    SRT(v);
    bool ans=true;
    
    //処理
    REP(i,0,n){
        if(vans[i]!=v[i]){
            ans = false;
            break;
        }
    }
    
    ll ansnum = 1;
    REP(i,0,n/2){
        ansnum *= 2;
        ansnum %= MOD;
    }
    
    //出力
    if(ans) cout << ansnum << ENT;
    else cout << 0 << ENT;
    
    return 0;
}

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


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	int n;
	cin>>n;
	int a[n];
	int s1=0,s2=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(i%2==0){
			s1 +=a[i];
		}
		else{
			s2 +=a[i];
		}
	}
	cout<<abs(s2-s1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,k,c; cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> ssum(n+1);
    vector<int> swhere(n+1);
    ssum[0]=0;
    swhere[0]=-1;
    rep(i,n){
        if(s[i]=='o'){
            ssum[i+1]=ssum[i]+1;
            swhere[i+1]=i+1;
        }
        else{
            ssum[i+1]=ssum[i];
            swhere[i+1]=swhere[i];
        }
    }

    vector<int> donyoku;
    int now=0;
    while(now<n && donyoku.size()<k){
        if(s[now]=='x'){
            now++;
            continue;
        }
        donyoku.push_back(now+1);
        now+=c+1;
    }
    
    reverse(all(donyoku));

    vector<int> ans;

    int after=-1;
    rep(i,donyoku.size()){
        int cu=donyoku[i];
        int r=n;
        if(after!=-1) r=max(1,after-c-1);
        if(ssum[r]==ssum[cu]){
            ans.push_back(cu);
            after=cu;
        }
        else{
            after=swhere[r];
        }
    }

    reverse(all(ans));
    rep(i,ans.size()) cout << ans[i] << endl;
    return 0;
}


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

int main() {
    int A,B;
    cin >> A >>B;
    if(A==1 && B==2 || A==2 && B==1){
        cout << 3 <<endl;
    }
    else if(A==1 && B==3 || A==3 && B==1){
        cout << 2 <<endl;
    }
    else cout << 1 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll a[n], ans = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (ans != -1)
		{
			if (1000000000000000000 / ans >= a[i])
			{
				ans *= a[i];
			}
			else
			{
				ans = -1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4392
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);

		long K = scanner.nextLong();
		long ans=0;

		for(int a=1;a<=K;a++) {
			for(int b=1;b<=K;b++) {
				for(int c=1;c<=K;c++) {
					ans+=gcd(a, gcd(b, c));
				}
			}
		}

		System.out.println(ans);
	}



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


}


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

int main(){
  int a, b, c, d, e ,sum;
  cin >> a >> b >> c>> d >> e;
  if(a<40) a= 40;
  if(b<40) b= 40;
  if(c<40) c=40;
  if(d<40) d=40;
  if(e<40) e=40;

  sum = (a + b + c + d + e) / 5;

  cout << sum << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	int sum=0;
	REP(i,n) sum^=a[i];
	
	REP(i,n) cout<<(sum^a[i])<<endl;
}

Measured memory_bytes: 3872
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef bool bl;
typedef vector<ll> vl;
typedef vector<bl> vb;
typedef string st;
typedef pair<ll,ll> pll;

#define INF LONG_LONG_MAX / 4;
#define SORT(x) sort(x.begin(), x.end());
#define Mod % 1000000007
#define HERE cout<<"HERE"<<endl;

void re_curse() {
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll type = 0;
    while (a > 0 && c > 0) {
        if (!type) {
            c -= b;
            type = !type;
        } else {
            type = !type;
            a -= d;
        }
    }
    if (a <= 0) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n,t;
  cin >> n >> t;
  vector<vector<int>> dp(n+1,vector<int>(t+1,0));
  vector<pp> ab(n);
  rep(i,n){ cin >> ab.at(i).first; cin >> ab.at(i).second;}
  sort(ab.begin(),ab.end());
  
  for(int i=1;i<=n;i++){
    rep(j,t+1){
      if(j < ab.at(i-1).first) dp.at(i).at(j) = dp.at(i-1).at(j);
      else dp.at(i).at(j) = max(dp.at(i-1).at(j),dp.at(i-1).at(j-ab.at(i-1).first) + ab.at(i-1).second);
    }
  }

  
  int ans = 0;
  rep(k,n){
    ans = max(ans,dp.at(k).at(t-1) + ab.at(k).second);
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 35584
import java.util.Scanner;

// *** at 2018/**/**

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        if ((X - A) < 0) {
            System.out.println("NO");
        } else if (B < (X - A)) {
            System.out.println("NO");
        } else if ((A + B) < X) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 23252
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
ans = 0
while n > 0:
    n = n // k
    ans += 1

print(ans)

Measured memory_bytes: 31272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var d = new string[N];
		for (int i = 0; i < N; i++)
		{
			d[i] = Console.ReadLine();
		}
		Console.WriteLine(d.Distinct().Count());
	}
}

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

int main(){
  ll a,v,b,w,c;
  cin>>a>>v>>b>>w>>c;
  if(w>=v){
    cout<<"NO"<<endl;
    return 0;
  }
  ll x=abs(a-b);
  ll y=(x+v-w-1)/(v-w);
  if(y<=c){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<int> a(n);
    for(auto &x:a)
        cin >> x;

    int ans=0;
    for(int i=0;i<n;i++){
        if((i+1)%2==1 && a.at(i)%2==1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3576
import fractions
import numpy as np

A, B = map(int, open(0).read().split())
G = fractions.gcd(A, B)
upper_limit = int(np.sqrt(G))
ans = 1
for i in range(upper_limit):
    if G % (i + 2) == 0:
        ans += 1
        #print(i + 2)
        while G % (i + 2) == 0:
            G /= (i + 2)
            #print(G)
if G != 1:
    ans += 1
print(ans)


Measured memory_bytes: 13668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  sort(all(s));
  for (ll i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
def solve(field, h, w)
  res = Array.new(h).map {Array.new(w, -1)}
  field.each.with_index do |row, i|
    row.each.with_index do |c, j|
      res[i][j] = res[i][j-1] + 1 if j >= 1 and res[i][j-1] >= 0 and c == "."
      res[i][j] = 0 if c == "c"
    end
  end
  res.map {|row| row.join(" ")}.join("\n")
end

h, w = gets.split(" ").map(&:to_i)
field = []
h.times { field << gets.strip.chars }
puts solve(field, h, w)

Measured memory_bytes: 8968
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int const MAX_N = 256*1024;
int s[MAX_N];

int main() {
	int n;
	scanf("%d",&n);
	for (int i=0; i<n; i++) scanf("%d",&s[i]);
    sort(s,s+n);
	double mn_abs = 1e50;
	int ans_j = -1;
	for (int i=0; i<n-1; i++) {
		double d = fabs((double) s[i]-(s[n-1]/2.0));
		if (d < mn_abs) {
			mn_abs = d;
			ans_j = i;
		}
	}
	printf("%d %d",s[n-1],s[ans_j]);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>


#define ll long long
#define ull unsigned long long

int main()
{
    double a, b;
    std::cin >> a >> b;


    for (ll i = 0; i != 1300; ++i)
    {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b)
        {
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    double s = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        double a;
        cin >> a;
        s += 1/a;
    }
    s = 1/s;
    cout << fixed << setprecision(16) << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int n;
 cin >> n;
 if(n < 1200)cout << "ABC" << endl;
 else if(n < 2800)cout << "ARC" << endl;
 else cout << "AGC" << endl;
}

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

int main() {
  string s; cin >> s;
  rep(i, s.size()-1) {
    if (s.at(i) == 'A' && s.at(i+1) == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
    return 0;
}

Measured memory_bytes: 256
button = input().split()
A = button[0]
B = button[1]
full = []
A = int(A)
B = int(B)
if A >=3 and B <= 20:
    if A + A -1 >= A + B and A + A -1 >= B + B -1:
        full.append(A + A -1)
    elif A + B >= A + A -1 and A + B >= B + B -1 :
        full.append(A + B)
    else:
        full.append(B + B - 1)
else:
    full.append(0)
print(max(full))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0;
  cin>>n;
  int a;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    cin>>a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  for(pair<int,int> p:mp){
    m=max(m,p.second);
  }
  cout<<m;
}

Measured memory_bytes: 4736
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=4e6+10;
const int M=4e6;
const int mod7=1e9+7;
const int mod=998244353;
const double pi=3.1415926535898;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0') if(ch=='-') d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0') if(ch=='-') d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    double t=fabs(30*c+d/2-6*d);
    t=min(t,360-t);t/=180;
    printf("%.9f\n",sqrt(a*a+b*b-2*a*b*cos(t*pi)));
    return 0;
}

Measured memory_bytes: 4200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[8] = { 0,0,1,-1, 1,1,-1,-1 };// 前４つで４近傍
const int c_Dy[8] = { 1,-1,0,0 ,1,-1,1,-1};// 全部で８近傍
const int c_div = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846;



void  bubbleSort(int number[],int length);

int main() {

	int N, K, L[100];
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}

	bubbleSort(L,N);

	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += L[i];

	}

	printf("%d", ans);
	





}



//---配列を降順ソート（だんだん小さくなる）----
void  bubbleSort(int number[], int length) {
	for (int i = 0; i < length; i++)
		for (int j = i + 1; j < length; j++)
			if (number[i] < number[j]) {
				int tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

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

void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> tab(n+100, 0);
    vector<int> dp(n+100, 10000000);

    for(int i = 0; i < n; ++i) cin>>tab[i];
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        for(int j = 1; j <= min(i,k);++j){
            if(j==1) dp[i] = abs(tab[i]-tab[i-j]) + dp[i-j];
            else dp[i] = min(dp[i], dp[i-j] + abs(tab[i]-tab[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
    //for(int i = 0; i < n;++i) cout<<dp[i]<<" ";

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int n, p[100], ans;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	ans = 0;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> p[i];
	for(int i = 1; i < n-1; ++i) {
		if ((p[i] < p[i+1] && p[i] > p[i-1]) || (p[i] > p[i+1] && p[i] < p[i-1])) {
			++ans;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3640
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  ll k;
  cin >> s >> k;
   
  ll n = s.size();
  set<string> st;

  rep(i, 5){
    rep(j, n - i){
      st.insert(s.substr(j, i+1));
    }
  }
  auto itr = st.begin();
  rep(i, k-1) itr++;

  cout << *itr << endl;

  return 0;
}


Measured memory_bytes: 4740
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  let digits_l = digits 10 n [] in

  let rec aux prev cnt = function
      [] -> "No" 
    | hd :: tl -> 
      if prev = hd then
        let cnt = cnt + 1 in
        if cnt = 3 then
          "Yes"
        else
          aux hd (cnt+1) tl
      else 
        aux hd 0 tl
  in

  Printf.printf "%s\n" @@
  aux (-1) 0 digits_l


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

int main()
{
	int64_t S;
	scanf("%lld", &S);
	int64_t ans[3][2]{};
	ans[2][1] = ans[1][0] = 1'000'000'000;
	int64_t left{};
	while (ans[2][1] - left > 1)
	{
		int64_t mid{(ans[2][1] + left) >> 1};
		if (mid * ans[1][0] < S) left = mid;
		else ans[2][1] = mid;
	}
	ans[1][1] = 1;
	ans[2][0] = ans[2][1] * ans[1][0] - S;
	for (int i{}; i < 3; i++)
		for (int j{}; j < 2; j++)
			printf("%lld%c", ans[i][j], i * j == 2? '\n': ' ');

	return 0;
}

Measured memory_bytes: 256