akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deq(100001,0);
    deq[2]=1;
    for (int i=3;i<=100000;i+=2) {
        double sqrtNum=sqrt(i);
        int flag=0;
        for (int j=3;j<=sqrtNum;j+=2) {
            if (i%j==0) {
                flag=1;
                break;
            }
        }
        if (flag==0) {
            deq[i]=1;
        }
    }
    std::deque<int> nums(100001,0);
    for (int i=3;i<=100000;i+=2) {
        if (deq[i]==1) {
            if (deq[(i+1)/2]==0) {
                nums[i]=0;
            } else {
                nums[i]=1;
            }
        }
    }
    std::deque<int> s(100002,0);
    for (int i=0;i<=100000;i++) {
        s[i+1]=s[i]+nums[i+1];
    }
    int q,l,r;
    cin>>q;
    for (int i=0;i<q;i++) {
        cin>>l>>r;
        cout<<s[r]-s[l-1]<<endl;
    }
}

Measured memory_bytes: 1920
<?php
list($a, $v) = explode(' ', trim(fgets(STDIN)));
list($b, $w) = explode(' ', trim(fgets(STDIN)));
$t = trim(fgets(STDIN));

if ($v <= $w) {
	echo "NO\n";
	exit;
}
echo (abs($a - $b) / ($v - $w)) <= $t ? "YES\n" : "NO\n";


Measured memory_bytes: 16152
#include<bits/stdc++.h>
using namespace std;
vector<int>A;
int check(int x){
  if(x==1)return is_sorted(A.begin(),A.end());
  map<int,int>m;
  for(int i=1;i<A.size();i++){
    if(A[i-1]<A[i])continue;
    if(m.upper_bound(A[i])!=m.end())
    m.erase(m.upper_bound(A[i]));
    int k=A[i];
    m[k]++;
    while(k>0&&m[k]==x)m.erase(k),m[--k]++;
    if(k==0)return false;
  }
  return true;
}
int main(void){
  int N;cin>>N;
  A.resize(N);
  for(int &a:A)cin>>a;
  int l=0,h=N;
  while(h-l>1){
    int m=(l+h)/2;
    if(check(m))h=m;
    else l=m;
  }
  cout<<h<<endl;
}


Measured memory_bytes: 1152
#import<bits/stdc++.h>
double k,i,n,p,q,s;
main()
{
scanf("%lf%lf",&n,&k);
for(i=1;i<=n;i++)
{
for(p=i,q=1;p<k;p*=2)q/=2;
s+=q;
}
printf("%.9lf",s/n);
}

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

using namespace std;
// Used "rom"'s solution
vector<pair<int, int> > graph[100001]; // value and connecting node
vector<int> res;
int n, m;
int supposed;
bool bad = false;
int nodes[100001];
void dfs(int curr, bool visited[], int acc){
  nodes[curr] = acc;
  visited[curr] = true;
  for (int i=0; i<graph[curr].size(); i++){
    if (!visited[graph[curr][i].second])
      dfs(graph[curr][i].second, visited, acc+graph[curr][i].first);
  }
}

int main(){
  
  cin >> n >> m;
  
  vector<pair<int, pair<int, int> > > edges;
  set<int> nod;
  for (int i=0; i<m; i++){
    int l, r, d;
    cin >> l >> r >> d;
    graph[l].push_back(make_pair(d, r));
    graph[r].push_back(make_pair(-d, l));
    edges.push_back(make_pair(d, make_pair(l, r)));
    nod.insert(l);
    nod.insert(r);
  }
  bool vis[n+1] = {false};
  for (int i=1; i<=n; i++){
    if (nod.count(i) > 0){
      if (!vis[i]){
        dfs(i, vis, 0);
      }
    }
  }
  for (int i=0; i<m; i++){
    pair<int, int> edge = edges[i].second;
    if (nodes[edge.second]-nodes[edge.first] != edges[i].first){
      //cout << nodes[edge.first] << " " << nodes[edge.second] << " " << edges[i].first<< endl;
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 19760
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		String n;
		Stack<Double> stack = new Stack<Double>();
		StringTokenizer st;
		double a, b;
		while (sc.hasNext()) {
			st = new StringTokenizer(sc.nextLine());
			while (st.hasMoreTokens()) {
				n = st.nextToken();
				if (n.equals("+")) {
					a = stack.pop();
					b = stack.pop();
					stack.push(b+a);
				} else if (n.equals("-")) {
					a = stack.pop();
					b = stack.pop();
					stack.push(b-a);
				} else if (n.equals("*")) {
					a = stack.pop();
					b = stack.pop();
					stack.push(b*a);
				} else if (n.equals("/")) {
					a = stack.pop();
					b = stack.pop();
					stack.push(b/a);
				} else {
					stack.push(Double.valueOf(n));
				}
			}
			System.out.println(stack.pop());
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 17184
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N;


int main(){
	cin.tie(0);
	cout.tie(0);

	ios::sync_with_stdio(false);
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b<<endl;
	}

	
	return 0;
}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 /*long long int t;
  cin>>t;
  while(t--)
  {
  }*/
  long long int n,m,sum=0;
  long long int c=0;
  cin>>n>>m;
  long long int a[n];
  for(long long int i=0;i<n;i++)
  {
      cin>>a[i];
      sum=sum+a[i];
  }
  /*long long int var=1;
  ceil(sum/(4*m));*/
  for(long long int i=0;i<n;i++)
  {
      if(a[i]*4*m>=sum)
      c++;
  }
  if(c>=m)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  
  //cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
using namespace std;
int main()
{
	int A,B,C,X,Y;
	cin >> A >> B >> C >> X >> Y;

	int answer = INT_MAX;

	for(int i = 0; i <= 100000; i++)
    {
		int now = i * 2 * C + max(0, (X - i)) * A + max(0, Y - i) * B;
		answer = min(answer,now);
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n;
  long long k;
  cin>>n>>k;
  int a,b;
  vector<pair<int,int>> vec;
  REP(i,n){
    cin>>a>>b;
    vec.push_back(make_pair(a,b));
  }
  sort(vec.begin(),vec.end());
  long long cnt=0;
  REP(i,n){
    if(cnt<k && k<=cnt+vec[i].second){
      cout<<vec[i].first<<endl;
      return 0;
    }else{
      cnt += vec[i].second;
    }
  }
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  
  ll l[3]={2, 1, 0};
  if (n==1) {
    cout << 1 << endl;
  } else {
    rep(i,n-1) {
      l[2]=l[0]+l[1];
      l[0]=l[1];
      l[1]=l[2];
    }
    cout << l[2] << endl;
  }

  return 0;
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 1005;

ll dp[N][N];
string s[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    rep(i,0,n)  cin>>s[i];
    dp[0][0]=1;
    rep(i,0,n)  rep(j,0,m){
        if(i+1<n and s[i+1][j]=='.'){
            dp[i+1][j] = (dp[i+1][j] + dp[i][j])%M;
        }
        if(j+1<m and s[i][j+1]=='.'){
            dp[i][j+1] = (dp[i][j+1] + dp[i][j])%M;
        }
    } 
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
const int MAXN = 101;

int main(){
    int N;
    cin >> N;
    int L[MAXN];
    rep(i,N)cin>> L[i];
    int count = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(i<j && j<k){
                    if(L[i]==L[j] || L[j]==L[k] || L[i] == L[k])continue;
                    int ma = max(L[i],max(L[j],L[k]));
                    int mi = min(L[i],min(L[j],L[k]));
                    int mid = L[i] + L[j] + L[k] - ma - mi;
                    if(ma < (mi + mid)) count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<< 29;
const double PI = 3.14159265358979323846;

        

int main(){
        int N,M;
        cin >> N >> M;

        vector<int> broken(N+1);
        for(int i = 0; i < M; i++){
                int a;
                cin >> a;
                broken[a] = 1;
        }

        vector<int> dp(N+2);
        dp[N] = 1;
        for(int i = N-1; i >= 0; i--){
                if(broken[i]){
                        dp[i] = 0;
                        continue;
                }
                dp[i] = (dp[i+1] + dp[i+2]) % mod;
        }

        cout << dp[0] << endl;
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
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 lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


// 素数判定O(√n)----------------------------------------------
bool is_prime(int n){
  for (ll i=2; i*i<=n; i++) if (n%i==0) return false;
  return n != 1;
}

int main() {
  int n; cin >>n;
  // 下一桁が1である素数を55個列挙すれば、どの異なる5個を選んでも和が5の倍数になる
  vector<int> A;
  for (int i=2; i<=55555; i++){
    if (i % 10 != 1) continue;
    if (is_prime(i)){
      A.push_back(i);
      if (A.size() == n) break;
    }
  }
  rep(i, n){
    cout <<A[i];
    if (i == n-1) cout <<endl;
    else cout <<" ";
  }
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s; cin>>s;
    if(stoi(s.substr(5, 2))<5){
        puts("Heisei");
    }else{
        puts("TBD");
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};
int main() {
    int n, m; cin >> n >> m;
    UnionFind uni(n + 1);
    int p[n + 1]; rrep(i, 1, n + 1) cin >> p[i];
    rep(i, m) {
        int x, y; cin >> x >> y;
        uni.connect(x, y);
    }
    int c = 0;
    rrep(i, 1, n + 1) {
        //cout << uni.root(i) << " " << uni.root(p[i]) << endl;
        if (uni.root(p[i]) == uni.root(i)) {
            c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 1024
from collections import defaultdict

n,k = map(int,input().split())
dct = defaultdict(int)
for _ in range(n):
    a,b=map(int,input().split())
    dct[a]+=b
dct = sorted(dct.items())
now=0
for tpl in dct:
    now+=tpl[1]
    if now>=k:
        print(tpl[0])
        break

Measured memory_bytes: 14940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  string s1;
  int n, k, i, j, d, a, has=0;
  cin>>n>>k;
  vector<int>v(n+1, 0);
  for(i=0; i<k; i++){
    cin>>d;
    for(j=0; j<d; j++){
      cin>>a;
      if(v[a]==0){
        v[a]=1;
        has++;
      }
    }
  }
  cout<<n-has;
  
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    double n; cin >> n;
    double s = 0;
    s = n/3.0f;
    printf("%.9f", s*s*s);
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long
#define OUTPUT(x) cout << x << endl;

int main(){
  LINT n, k;
  cin >> n >> k;
  LINT ans=0;
  LINT x, work;

  for(int i=1; i<n+1; ++i){
    x=i%k;
    if((2*x)%k!=0)continue;
    work = (n+x)/k;
    work *= work;
    ans += work;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> b(n);
    cins(all(b));
    rep(i,n){
        if (b[i] > i+1){
            PRINT(-1);
            return 0;
        }
    }
    vector<vector<ll>> ar(n+1);
    vector<ll> ans;
    rep(i,n) ar[0].push_back(b[i]);
    rep(i,n){
        bool f = 1;
        for (ll j = n-i-1;j >= 0;j--){
            if (f && ar[i][j] == j+1){
                f = 0;
                ans.push_back(j+1);
            }
            else{
                ar[i+1].push_back(ar[i][j]);
            }
        }
        reverse(all(ar[i+1]));
    }
    reverse(all(ans));
    rep(i,n) PRINT(ans[i]);
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long double, long double>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(ALL(v));

  long double res = 0;
  do{
    long double fx = v[0].first;
    long double fy = v[0].second;
    for (int i = 1; i < n; i++) {
      long double nx = v[i].first;
      long double ny = v[i].second;
      res += sqrt((nx-fx)*(nx-fx) + (ny-fy)*(ny-fy));
      fx = v[i].first;
      fy = v[i].second;
    }
  }while(next_permutation(ALL(v)));
  for (long double i = 1; i <= n; i++) {
    res /= i;
  }
  cout<<setprecision(15);
  cout << res << endl;
}


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

int main(){
	double a;
	while(cin >> a){
		double s[20]={};
		s[0] = a;
		for(int i = 1 ; i < 10 ; i++)
			if( i % 2 == 1 ) s[i] = s[i-1] * 2;
			else s[i] = s[i-1] / 3;
		double sum = 0;
		for(int i = 0 ; i < 10 ; i++)
			sum += s[i];
		printf("%.10lf\n",sum);
	}
}

Measured memory_bytes: 1236
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 10000000;

int n,t[10003];
int dp[2][5101][2];

int main(){
  
  scanf("%d",&n);
  
  for(int i = 0;i < n-1;i++){
    scanf("%d",&t[i]);
  }
  
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 5100;j++){
      dp[i][j][0] = INF;
      dp[i][j][1] = INF;
    }
  }
  
  dp[0][0][0] = 0;
  for(int i = 0;i < n;i++){
    int m = min(5010,i);
    for(int j = 0;j <= m;j++){
      dp[(i+1)&1][j+1][0]=min(dp[i&1][j][0],dp[i&1][j][1]+t[i]);
			dp[(i+1)&1][j][1]=min(dp[i&1][j][1],dp[i&1][j][0]+t[i]);
		}
		dp[i&1][0][0]=INF;
	}
	printf("%d\n",dp[n%2][n/2][0]);
	return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    cin >> n;
    string tmp;
    map<string, int> ma; //map<Keyの型, Valueの型> 変数名;
    rep(i, n)
    {
        cin >> tmp;
        ma[tmp]++; //keyがstring型のtmpを加算
    }
    int m;
    cin >> m;
    rep(i, m)
    {
        cin >> tmp;
        ma[tmp]--; //keyがstring型のtmpを減算
    }

    int ans = 0; //ansの初期化
    for (auto itr : ma) //配列と一緒の容量で、mapと書かずにautoで型宣言してmaの全部をループする
    {
        ans = max(itr.second, ans); //カウンタが一番多いものを取得
    }

    cout << ans << endl;

    return 0;
}

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

int n,m;
int ans=1;

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=sqrt(m);i++)
	{
		if (m%i) continue;
		if (m/i>=n) ans=max(i,ans);
		if (i>=n) ans=max(m/i,ans);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int n;

int ok(vector<vector<int>> &v, int m)

{
    int d[n];
    int ret = 0;
    rep(i, n)
    {
        d[i] = (m >> i) & 1;
        if (d[i] == 1)
            ret++;
    }
    rep(i, n)
    {
        rep(j, n)
        {
            if (v[i][j] == -1)
                continue;
            if (d[i] == 1 && d[j] != v[i][j])
            {
                return 0;
            }
        }
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n, -1));
    rep(i, n)
    {
        int m;
        cin >> m;
        rep(j, m)
        {
            int x, y;
            cin >> x >> y;
            x--;
            v[i][x] = y;
        }
    }
    cerr << "ok" << pow(2, n) << endl;
    int ans = 0;
    rep(i, pow(2, n))
    {
        cerr << "*" << i << endl;
        ans = max(ans, ok(v, i));
    }
    cout << ans << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    char b; cin >> b;
    if(b=='A') cout << 'T';
    else if(b=='C') cout << 'G';
    else if(b=='G') cout << 'C';
    else cout << 'A';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000005;

char s[N];

signed main() {
    cin>>s;
    int fg=1;
    int len=strlen(s);
    if(len&1) fg=0;
    for(int i=0;i<len;i++) {
        if(i%2) if(s[i]!='i') fg=0;
        if(i%2==0) if(s[i]!='h') fg=0;
    }
    cout<<(fg?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    vector<int> ans;
    int total = 0;
    for (int i = 0; i < N - 1; i++)
    {
        if (H[i] < H[i + 1])
        {
            ans.push_back(total);
            total = 0;
        }
        else
        {
            total++;
        }
    }
    ans.push_back(total);
    cout << *max_element(ans.begin(), ans.end()) << endl;

    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[1]=='B'){s[1]='R'; cout<<s;return 0;}
    else if(s[1]=='R'){s[1]='B';cout<<s;return 0;}
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+107;
const int inf = 1e8;
int h[N];
int mx[N];
void solve(){
    ll x;
    cin>>x;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            for(ll j=-300;j<=300;j++){
                ll b = j;
                ll a = i+j;
                ll trt = a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b;
        //        cout<<i<<" "<<a<<" "<<b<<" "<<a-b<<" "<<trt<<" "<<trt*(a-b)<<endl;
                if(trt==x/i){
                    cout<<a<<" "<<b<<endl;
                    return ;
                }
            }
        }
    }
    exit(-1);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main() {
	string a;
	int sum = 0;
	while (getline(cin, a)) {
		for (int i = 0; i < a.length(); i++) {
			if (a[i] >= '0'&&a[i] <= '9') {
				string h = "";
				while (a[i] >= '0'&&a[i] <= '9') {
					h += a[i];
					i++;
				}
				int s = atoi(h.c_str());
				sum += s;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vi p(a), q(b), r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    // sort(r.rbegin(), r.rend());
    vi s;
    rep(i,x) s.push_back(p[i]);
    rep(i,y) s.push_back(q[i]);
    rep(i,c) s.push_back(r[i]);
    sort(s.rbegin(), s.rend());
    ll ans = 0;
    rep(i, x+y) ans += s[i];
    cout << ans << endl; 
    
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
    int x = 0, fh = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            fh = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar();
    }
    return x * fh;
}
int a, b, c, x, y;
LL ans;
int main() {
	a = read(); b = read(); c = read(); x = read(); y = read();
	if (x < y) { swap(x, y); swap(a, b); }
	if (c * 2 < a + b) ans += y * c * 2;
	else ans += a * y + b * y;
	x -= y;
	if (a < c * 2) ans += x * a;
	else ans += x * c * 2;
	cout << ans;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	
	UnionFind() {}
	UnionFind(int n) {
		init(n);
	}
	
	void init(int n) {
		par.resize(n);
		REP(i, n) par[i] = i;
		rank.resize(n, 0);
	}
	
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		
		if (rank[x] > rank[y]) swap(x, y);
		par[x] = y;
		if (rank[x] == rank[y]) rank[x]++;
	}
};

int main() {
	int h, w;
	
	while (cin >> h >> w, h || w) {
		string str[100];
		REP(i, h) cin >> str[i];
		
		UnionFind uf(h * w);
		REP(i, h) REP(j, w) {
			int dx[4] = {1,0,-1,0};
			int dy[4] = {0,1,0,-1};
			
			REP(k, 4) {
				int nx = j + dx[k], ny = i + dy[k];
				if (!(nx >= 0 && nx < w && ny >= 0 && ny < h)) continue;
				if (str[i][j] != str[ny][nx]) continue;
				uf.unite(i * w + j, ny * w + nx);
			}
		}
		
		set<int> s;
		REP(i, h * w) s.insert(uf.find(i));
		cout << s.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1344
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]

l = 0
r = 10**9+1
while r-l > 1:
    m = (l+r)//2
    k = 0
    for h in H:
        c = max(0, h-m*B)
        k += c // (A-B)
        if c%(A-B) != 0: k += 1
    if k <= m:
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 7072
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;


int main(){
    int a,b;
    cin >> a >> b;
    if(b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int x, y, z; cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int Dice(char dir ,int D[]);

int main(void){
    int i,j,k,D[7];
    char dir[100];
    
    for(i=1;i<=6;i++) scanf("%d",&D[i]);
    i=0;
    while(scanf("%c",&dir[i])!=EOF){
        i++;
    }
    for(j=1;j<i;j++) Dice(dir[j],D);
    printf("%d\n",D[1]);
    
    return 0;
}

int Dice(char dir,int D[]){
    int a;
    if(dir=='S'){
        a=D[1];
        D[1]=D[5];
        D[5]=D[6];
        D[6]=D[2];
        D[2]=a;
    }
    if(dir=='N'){
        a=D[1];
        D[1]=D[2];
        D[2]=D[6];
        D[6]=D[5];
        D[5]=a;
    }
    if(dir=='W'){
        a=D[1];
        D[1]=D[3];
        D[3]=D[6];
        D[6]=D[4];
        D[4]=a;
    }if(dir=='E'){
        a=D[1];
        D[1]=D[4];
        D[4]=D[6];
        D[6]=D[3];
        D[3]=a;
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<string>S(N);
    int A = 0;
    int B = 0;
    int C = 0;
    int D = 0;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
        if(S[i] == "AC") {
            A++;
        }
        if(S[i] == "WA") {
            B++;
        }
        if(S[i] == "TLE") {
            C++;
        }
        if(S[i] == "RE") {
            D++;
        }
    }
    cout << "AC" << " " <<  'x' << " " << A << endl;
    cout << "WA" << " " <<  'x' << " " << B << endl;
    cout << "TLE" << " " <<  'x' << " " << C << endl;
    cout << "RE" << " " <<  'x' << " " << D << endl;
    
}


Measured memory_bytes: 6296
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
//#include "toollib.h"
#pragma warning (disable:4018)
using namespace std;

bool judge_prime_numbers(int n) {
	if (n == 1) return false;
	if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else {
		bool judge = true;
		for (int i = 3; i <= sqrt(n); i = i + 2) {
			if (n%i == 0) {
				judge = false;
				break;
			}
		}
		return judge;
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> ary(n);
	for (int i = 0; i < n; i++) cin >> ary[i];
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (judge_prime_numbers(ary[i])) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String head = S.substring(0, 2);
        String tail = S.substring(2);

        int h = Integer.parseInt(head);
        int t = Integer.parseInt(tail);

        if (1 <= h && h <= 12 && 1 <= t && t <= 12) {
            System.out.println("AMBIGUOUS");
        } else if (1 <= h && h <= 12) {
            System.out.println("MMYY");
        } else if (1 <= t && t <= 12) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }
    }
}

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

int main() {
    int n,l;
    cin>>n>>l;
    int r=l+n-1;
    int sm=n*(l+r)/2;
    int ans;
    if (r<0)
        sm-=r;
    else if (0<l)
        sm-=l;
    cout<<sm<<endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
N=int(input())
listA=list(map(int,input().split()))

hq=[]
for index, val in enumerate(listA):
    key = abs(sum(listA[:index]) - sum(listA[index:]))
    heapq.heappush(hq, (key, index))

min_key, y = heapq.heappop(hq)
print(min_key)

Measured memory_bytes: 3188
n=int(input())
d_list=[list(map(int,input().split())) for _ in range(n)]

count = 0
count_max=0
for i in range(n):
    if d_list[i][0]==d_list[i][1]:
        count += 1
        if count>count_max:
            count_max=count 
    else:
        count = 0

if count_max >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=2e5+10;
const ll mod=1e9+7;
 

int main() {
  	fast;
  	string s,t;
  	cin>>s>>t;
  	t.pop_back();
  	if(s==t)
  		cout<<"Yes";
  	else
  		cout<<"No";
}
  	


Measured memory_bytes: 3652
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>num;
	num.push_back(1);
	long long int box = 1;
	int c = 8;
	int p = 1;
	while (box < N / 100) {
		box *= c;
		box /= p;
		c++;
		p++;
		num.push_back(box);
	}
	reverse(num.begin(), num.end());
	string ans;
	for (int i = 0; i < num.size(); i++) {
		for (int j = 0; j < N / num[i]; j++)ans.push_back('F');
		ans += "ESTIVAL";
		N %= num[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
   int N, M;
   int X, Y;
   cin >> N >> M;
   cin >> X >> Y;
   vector<int> x(N);
   for (int i = 0; i < N; i++){
       cin >> x.at(i);
   }
   vector<int> y(M);
   for (int i = 0; i < M; i++){
       cin >> y.at(i);
   }

    bool ans;

    int z = X + 1;
    while(z <= Y){
        //毎回ループの初めにansをtrueにしておけば毎回trueを入れなくて済む
        //falseになる条件だけを考えれば良くなる
        ans = true;
        for (int i = 0; i < N; i++){
            if (x.at(i) >= z){
                ans = false;
                z++;
                continue;
            }
        }
        for (int i = 0; i < M; i++){
            if (y.at(i) < z){
                ans = false;
                z++;
                continue;
            }
        }
        if(ans) break;
    }

    if (ans){
       cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define N 1000000000
using namespace std;

int L[210][210],S[210][210];
int dp[1100][210];
int n,m;
int x,y,t;
char s;
int r,z[1100];

int main(){
  while(cin >> n >> m ,n||m){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	if(i==j){
	  L[i][j] = 0;
	  S[i][j] = 0;
	}else{
	  L[i][j] = N;
	  S[i][j] = N;
	}
      }
    }

    for(int i=0;i<m;i++){
      cin >> x >> y >> t >> s;
      if(s=='L'){
	L[x][y] = t;
	L[y][x] = t;
      }else{
	S[x][y] = t;
	S[y][x] = t;
      }
    }

    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  L[i][j] = min(L[i][j] , L[i][k] + L[k][j]);

    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  S[i][j] = min(S[i][j] , S[i][k] + S[k][j]);

    cin >> r;
    for(int i=0;i<r;i++)cin >> z[i];

    for(int i=0;i<r;i++){
      for(int j=1;j<=n;j++){
	dp[i][j] = N;
      }
    }
 
    dp[0][z[0]] = 0;

    for(int i=1;i<r;i++){
      for(int j=1;j<=n;j++){
	if(L[z[i-1]][z[i]] != N){
	  dp[i][j] = min(dp[i][j],dp[i-1][j] + L[z[i-1]][z[i]]);
	}
	for(int k=1;k<=n;k++){
	  if(S[j][k] != N && L[k][z[i]] !=N){
	    dp[i][k] = min(dp[i][k],dp[i-1][j] + L[z[i-1]][j] + S[j][k] + L[k][z[i]]);
	  }
	}
      }
    }
    int ans = N;
    for(int i=1;i<=n;i++)ans = min(ans,dp[r-1][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 2032
#include <atcoder/dsu>
#include <iostream>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    while(q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) d.merge(u, v);
        else if(d.same(u, v)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long happiness[100010][3];

// DP テーブル
long long dp[100010][3];

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

    // 初期化 (最大問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i][0] = dp[i][1] = dp[i][2] = 0;

    // 初期条件
    dp[0][0] = happiness[0][0];
    dp[0][1] = happiness[0][1];
    dp[0][2] = happiness[0][2];

    // ループ
    for (int i = 1; i < N; ++i) {
        chmax(dp[i][0], max(dp[i-1][1],dp[i-1][2]) + happiness[i][0]);
        chmax(dp[i][1], max(dp[i-1][0],dp[i-1][2]) + happiness[i][1]);
        chmax(dp[i][2], max(dp[i-1][0],dp[i-1][1]) + happiness[i][2]);
    }

    // 答え
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}

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

int main() {
    string s;
    cin >> s;
    vector<bool> exi(26, false);
    if (s.length() < 26) {
        for (char c : s) {
            exi[c - 'a'] = true;
        }
        for (int i = 0; i < 26; ++i) {
            if (!exi[i]) {
                cout << s << (char)(i + 'a') << "\n";
                return 0;
            }
        }
    }
    for (int i = (int)s.length() - 1; i >= 0; --i) {
        for (int j = s[i] - 'a' + 1; j < 26; ++j) {
            if (exi[j]) {
                s[i] = (char)(j + 'a');
                cout << s.substr(0, i + 1) << "\n";
                return 0;
            }
        }
        exi[s[i] - 'a'] = true;
    }
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[0]+a[1]<<endl;
}
return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

int n;
vector<vector<int> > adjList, id;
vector<int> start, finish, dp;
bool isCycle;

int backtrack(int node){

    if (start[node] != -1 && finish[node] == -1)
        isCycle = true;

    int &ret = dp[node];
    if (ret != -1) return ret;

    ret = 0;
    start[node] = 1;
    for (auto child : adjList[node])
        ret = max(ret, backtrack(child) + 1);

    finish[node] = 1;
    return ret;
}

int mapping(int x, int y){
    if (x>y) swap(x, y);
    return id[x][y];
}

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    int e = n*(n-1); e/=2;
    
    adjList.assign(e, vector<int>());
    id.assign(n, vector<int>(n));
    start.assign(e, -1);
    finish.assign(e, -1);
    dp.assign(e, -1);

    int A[n][n];
    for (int i=0;i<n;++i){
        for (int j=0;j<n-1;++j){
            cin>>A[i][j];
            A[i][j]--;
        }
    }

    int cnt = 0;
    for (int i=0;i<n;++i){
        for (int j=i+1;j<n;++j){
            id[i][j] = cnt++;
        }
    }

    for (int i=0;i<n;++i){
        for (int j=0;j<n-1;++j){
            A[i][j] = mapping(i, A[i][j]);
        }
    }

    for (int i=0;i<n;++i){
        for (int j=0;j<n-2;++j){
            adjList[A[i][j+1]].emplace_back(A[i][j]);
        }
    }

    int ans = 0;
    for (int i=0;i<e;++i){
        ans = max(ans, backtrack(i) + 1);
    }

    if (isCycle) cout<<"-1"<<endl;
    else cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 41472
N, X = gets.chomp.split(' ').map(&:to_i)
L = gets.chomp.split(' ').map(&:to_i)[0..N]

times = 1
L.reduce(0) do |sum, step|
  sum += step
  if sum > X
    break
  end
  times = times + 1
  sum
end

puts times


Measured memory_bytes: 1788
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n,ans=0; std::cin >> n;
  std::string s; std::cin >> s;
  REP(i,n-2) {
    if (s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


#define L first
#define R second

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<int> sum;
	vector<int> sum2;
	vector<pair<int,int>> in;
	
	cin>>N>>K;
	
	sum.resize(N+5);
	sum2.resize(N+5);
	in.resize(K);
	
	for(int i = 0; i < K; i++){
		cin>>in[i].L>>in[i].R;
	}
	
	sum[1] = 1;
	
	for(int i = 1; i <= N; i++){
		
		sum[i] += sum2[i];
		sum[i] %= MOD;
		
		for(int j = 0; j < K; j++ ){
			sum2[min(N+2, i+in[j].L)] += sum[i];
			sum2[min(N+2, i+in[j].L)] %= MOD;
			
			sum2[min(N+2, i+in[j].R+1)] += MOD - sum[i]%MOD;
			sum2[min(N+2, i+in[j].R+1)] %= MOD;;
		}
		sum2[i+1] += sum2[i];
		sum2[i] %= MOD;
	}
	
	cout<<sum[N]%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 6364
function Main(input) {

  var nums = input.split(' ');
  var sum = Math.floor(nums[0]) + Math.floor(nums[1]) + Math.floor(nums[2])
  
  if (sum < 22){
    console.log('win')
  } else {
    console.log('bust')
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064