akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mod=1e9+7;
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   int zz[10][10]={};
   int cnt=0;
   for(int i=0;i<=n;i++)
   {
      string a=to_string(i);
      zz[a[0]-'0'][a[a.length()-1]-'0']++;
   }   
   // for(int i=1;i<=9;i++)
   // {
   //    if(i<=n)
   //       zz[i][i]++;
   // }
   // for(int i=1;i<=9;i++)
   // {
   //    for(int j=1;j<=9;j++)
   //    {
   //       if(10*i+j<=n)
   //          zz[i][j]++;
   //    }
   // }
   // cout<<zz[1][1]<<'\n';
   int ans=0;
   for(int i=1;i<=9;i++)
   {
      for(int j=1;j<=9;j++)
      {
         ans+=zz[i][j]*zz[j][i];
      }
   }
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 200000;
const int MaxM = 4000000;

struct Graph {
  int cnte;
  int Head[MaxN + 5], To[MaxN * 2 + 5], Next[MaxN * 2 + 5], Val[MaxN * 2 + 5];

  inline void addEdge(int from, int to, int val) {
    cnte++; To[cnte] = to; Val[cnte] = val;
    Next[cnte] = Head[from]; Head[from] = cnte;
  }
};

struct edge_t {
  int u, v;
  long long w;
  edge_t(int _u = 0, int _v = 0, long long _w = 0) { u = _u, v = _v, w = _w; }
  inline friend bool operator<(const edge_t &a, const edge_t &b) { return a.w < b.w; }
};

int N, M;
int X[MaxN + 5];
bool Vis[MaxN + 5];
int Rt, Siz[MaxN + 5], Mxs[MaxN + 5];
int Stk[MaxN + 5], Tp;
long long Weight[MaxN + 5];
int Par[MaxN + 5];
edge_t E[MaxM + 5];
Graph Gr;

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &X[i]);
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    Gr.addEdge(u, v, w);
    Gr.addEdge(v, u, w);
  }
}

void getRoot(int u, int f, int sz) {
  Siz[u] = 1;
  Mxs[u] = 0;
  for (int i = Gr.Head[u]; i; i = Gr.Next[i]) {
    int v = Gr.To[i];
    if (v == f || Vis[v] == true) continue;
    getRoot(v, u, sz);
    Siz[u] += Siz[v];
    if (Siz[v] > Mxs[u]) Mxs[u] = Siz[v];
  }
  if (sz - Siz[u] > Mxs[u]) Mxs[u] = sz - Siz[u];
  if (Mxs[u] < Mxs[Rt]) Rt = u;
}

void dfs2(int u, int f, long long len) {
  Weight[u] = len + X[u];
  Stk[++Tp] = u;
  for (int i = Gr.Head[u]; i; i = Gr.Next[i]) {
    int v = Gr.To[i], w = Gr.Val[i];
    if (Vis[v] == true || v == f) continue;
    dfs2(v, u, len + w);
  }
}

void dfs(int u) {
  Vis[u] = true;
  Tp = 0;
  dfs2(u, 0, 0);
  int mn = Stk[1];
  for (int i = 1; i <= Tp; ++i) if (Weight[Stk[i]] < Weight[mn]) mn = Stk[i];
  for (int i = 1; i <= Tp; ++i) E[++M] = edge_t(Stk[i], mn, Weight[Stk[i]] + Weight[mn]);
  for (int i = Gr.Head[u]; i; i = Gr.Next[i]) {
    int v = Gr.To[i];
    if (Vis[v] == true) continue;
    Mxs[Rt = 0] = N;
    getRoot(v, u, Siz[v]);
    dfs(Rt);
  }
}

int find(int x) { return x == Par[x] ? x : Par[x] = find(Par[x]); }

void solve() {
  Mxs[Rt = 0] = N;
  getRoot(1, 0, N);
  dfs(Rt);
  std::sort(E + 1, E + 1 + M);
  long long s = 0;
  for (int i = 1; i <= N; ++i) Par[i] = i;
  for (int i = 1; i <= M; ++i) {
    int u = E[i].u, v = E[i].v;
    long long w = E[i].w;
    int p = find(u), q = find(v);
    if (p == q) continue;
    Par[p] = q;
    s += w;
  }
  printf("%lld\n", s);
}

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

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; return os;
}
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  V x(n), y(n);
  map<int, V> xid, yid;
  rep(i, n) {
    cin >> x[i] >> y[i];
    xid[x[i]].push_back(i);
    yid[y[i]].push_back(i);
  }

  VV G(n);
  for (auto e : xid) {
    auto v = e.snd;
    rep(i, v.size()-1) {
      G[v[i]].push_back(v[i+1]);
      G[v[i+1]].push_back(v[i]);
    }
  }
  for (auto e : yid) {
    auto v = e.snd;
    rep(i, v.size()-1) {
      G[v[i]].push_back(v[i+1]);
      G[v[i+1]].push_back(v[i]);
    }
  }

  vector<bool> seen(n, false);
  ll ans = 0;

  rep(s, n) {
    if (seen[s]) continue;
    set<int> X, Y;
    int cnt = 0;
    queue<int> que;
    seen[s] = true;
    que.push(s);
    X.insert(x[s]);
    Y.insert(y[s]);
    ++cnt;

    while (!que.empty()) {
      int u = que.front(); que.pop();
      for (auto v : G[u]) {
        if (seen[v]) continue;
        seen[v] = true;
        que.push(v);
        X.insert(x[v]);
        Y.insert(y[v]);
        ++cnt;
      }
    }

    ans += X.size() * Y.size() - cnt;
  }

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


Measured memory_bytes: 22144
package main

import "fmt"

func main() {
	var n, r int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	for i := 1; i < n-1; i++ {
		if p[i-1] < p[i] || p[i+1] < p[i] {
			if p[i-1] < p[i] && p[i+1] < p[i] {
				continue
			} else {
				r++
			}
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
import numpy as np
h,w = map(int,input().split())
out_space = [["." for _ in range(w)] for _ in range(h*2)]
in_space = [ list(input()) for _ in range(h)]
for i in range(h*2):
    for j in range(w):
        out_space[i][j] = in_space[i//2][j]
for line in out_space:
    print("".join(line))

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

int main()
{
    ios_base::sync_with_stdio(0);

    int x;
    cin >> x;
    long long l=0,r=1e9;
    while(l<=r){
        long long mid = (l+r)>>1;
        if(mid*(mid+1)>=2*x)
            r=mid-1;

        else
            l=mid+1;
    }
    cout << l  << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();
		
		Map<Character, Integer> map = new HashMap<>();
		for(int i = 0;i < w.length();++i) {
			if(map.containsKey(w.charAt(i))) {
				Integer cap = map.get(w.charAt(i));
				map.remove(w.charAt(i));
				map.put(w.charAt(i), cap+1);
			} else {
				map.put(w.charAt(i), 1);
			}
		}
		boolean flag = true;
		for(Character c : map.keySet()) {
			if(map.get(c) % 2 != 0) {
				flag = false;
				break;
			}
		}
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,m,v,p;
int a[100010];
bool isOK(int mid){//n log 10^9
    if(mid<=p)return true;
    int to=a[mid]+m;
    int sum=0;
    for(int i=p;i<=mid-1;i++){
        if(to<a[i])return false;
        sum+=to-a[i];
    }
    return sum>=m*(v-(n-(mid-p)));
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1,greater<int>());
    int ok=p,ng=n+1;
    while(ng-ok>1){//log n
        int mid=(ok+ng)/2;
        if(isOK(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
#define lcm(a,b) (a/__gcd(a,b)*b)
long long get(int a,int m){
	int n = 1;
	for(int i = 1 ;  ; i++){	
		n = (n*a) % m;
		if(n==1) return i;
	}
}
int main(){
	long long a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f && f){
		cout << lcm(get(e,f),lcm(get(a,b),get(c,d))) << endl;
	}
}

Measured memory_bytes: 868
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,t = LI()
    k = t//a
    print(k*b)
    return

#B
def B():
    n = I()
    return

#C
def C():
    n = I()
    return

#D
def D():
    n = I()
    return


#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
#include <stdio.h>

int main(int argc, char const *argv[])
{
	double left, right;
	int cntleft[4] = {0};
	int cntright[4] = {0};
	// A:0, B:1, C:2, D:3
	int i;
	while(scanf("%lf %lf", &left, &right) != EOF) {
		if(left >= 1.1)
			cntleft[0]++;
		else if(left >= 0.6)
			cntleft[1]++;
		else if(left >= 0.2)
			cntleft[2]++;
		else
			cntleft[3]++;
		if(right >= 1.1)
			cntright[0]++;
		else if(right >= 0.6)
			cntright[1]++;
		else if(right >= 0.2)
			cntright[2]++;
		else
			cntright[3]++;
	}
	for(i = 0; i < 4; ++i) {
		printf("%d %d\n", cntleft[i], cntright[i]);
	}
	return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int INFTY = int.MaxValue / 2;
        static int n, all;
        static int[,] map, dp;
        static int[] bitIdx;

        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int V = input[0];
            int E = input[1];

            n = V;
            map = new int[n, n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    map[i, j] = INFTY;
                }
            }

            for (int i = 0; i < E; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                map[input[0], input[1]] = input[2];
            }

            bitIdx = new int[n];
            bitIdx[1] = 1;
            for (int i = 2; i < n; i++) bitIdx[i] = bitIdx[i - 1] << 1;

            all = (bitIdx[n - 1] << 1) - 1;

            dp = new int[n, all + 1];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= all; j++)
                {
                    dp[i, j] = INFTY;
                }
            }

            int res = TSP(0, 0);
            Console.WriteLine(res != INFTY ? res : -1);
        }

        static int TSP(int s, int mask)
        {
            if (mask == all) return map[s, 0];
            if (dp[s, mask] < INFTY) return dp[s, mask];

            int min = INFTY;
            for (int i = 1; i < n; i++)
            {
                if ((mask & bitIdx[i]) != 0 || map[s, i] == INFTY) continue;

                int d = TSP(i, (mask | bitIdx[i]));

                if (d == INFTY) continue;

                d += map[s, i];

                if (d < min) min = d;
            }
            dp[s, mask] = min;
            return min;
        }
    }
}

Measured memory_bytes: 10132
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
C = {chr(i):0 for i in range(97,123)}
for i in range(H):
    for j in range(W):
        C[A[i][j]] += 1
if H%2==0 and W%2==0:
    flag = 0
    for a in C:
        if C[a]%4!=0:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
elif (H%2==0 and W%2==1) or (H%2==1 and W%2==0):
    n = (H//2)*(W//2)
    for a in C:
        if C[a]>=4:
            n -= C[a]//4
            C[a] = C[a]%4
    if n>0:
        print("No")
    else:
        flag = 0
        for a in C:
            if C[a]%2==1:
                flag=1
                break
        if flag==0:
            print("Yes")
        else:
            print("No")
else:
    n = (H//2)*(W//2)
    for a in C:
        if C[a]>=4:
            n -= C[a]//4
            C[a] = C[a]%4
    if n>0:
        print("No")
    else:
        cnt = 0
        for a in C:
            cnt += C[a]%2
        if cnt==1:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 65460
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define All(a) a.begin(), a.end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  Sort(a);
  Reverse(a);
  ll ans = 0;
  for (ll i = 0; i < n-2; i++) {
    for (ll j = i+1; j < n-1; j++) {
      ll l = j;
      ll r = n;
      while (r-l > 1) {
        ll m = (l+r)/2;
        if (a[i]-a[j] < a[m]) {
          l = m;
        }
        else {
          r = m;
        }
      }
      ans += l-j;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int n,i;
unsigned long long now1,now2;
 
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n;
	for (i=1; i<=n; ++i){
		unsigned long long t,a;
		cin>>t>>a;
		if (i==1) {
			now1=a; now2=t; continue;
		}
		if (now1*t==now2*a) continue;
		if (now1>=now2/t*a)
			if (now1%a==0) now2=now1/a*t;
			else {
				now2=(now1/a+1)*t; now1=now2/t*a;
			}
		if (now1<=now2/t*a)
			if (now2%t==0) now1=now2/t*a;
			else{
				now1=(now2/t+1)*a; now2=now1/a*t;
			}
	} 
	cout<<now1+now2;
}

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

int X, Y;
bool exist = false;

main(){

    cin >> X >> Y;

    for (int i = 0;i <= X ;i++){
            int j = X - i;
            if (2 * i + 4 * j == Y) exist = true;
    }

    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll n, i, j, k, x = 0, y = 0;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  sort(a, a + n, greater<int>());
  for(i = 1; i < n; ++i) {
    if(a[i] == a[i - 1]) {
      if(!x) x = a[i];
      else {
        y = a[i];
        break;
       }
       ++i;
    }
  }
  printf("%lld", x * y);
  return 0;
}

Measured memory_bytes: 896
n=int(input())
x=list(map(int,input().split()))

import fractions
from functools import reduce

def lcm_base(a,b):
	return (a*b)//fractions.gcd(a,b)

def lcm(x):
	return reduce(lcm_base,x)

y=lcm(x)-1

res=0

for j in range(n):
	res+=y%x[j]

print(res)

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

int main(){
  int a,b,c;
  int x[3];
  int max = 0;
  int max_pos;
  cin >> a >> b >> c;

  x[0] = a;
  x[1] = b;
  x[2] = c;

  a = 0;
  for(int i = 0;i < 3;i++){
    if(x[i] >= max){
      max_pos = i;
      max = x[i];
    }
  }
  x[max_pos] = 0;
  cout << 10*max + x[0]+x[1]+x[2] << endl;

}

Measured memory_bytes: 256
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
A.sort()
bucket=[0*i for i in range(N+1)]
count=1
types=1
for i in range(1,N):
    if A[i]==A[i-1]:
        if i!=N-1:
            count+=1
        else:
            count+=1
            bucket[count]+=1
            break
    else:
        types+=1
        if i!=N-1:
            bucket[count]+=1
            count=1
        else:
            bucket[count]+=1
            bucket[1]+=1
            break

i=1
number_of_changes=0
while True:
    if types<=K:
        print(0)
        quit()
    elif types-bucket[i]<=K:
        print((types-K)*i+number_of_changes)
        quit()
    else:
        types-=bucket[i]
        number_of_changes+=bucket[i]*i
    i+=1

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int arr[MAXN], dp[MAXN];

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N)
	{
		cin >> arr[i];
	}
	FOR(i, 1, N) dp[i] = INF;
	FOR(i, 0, N)
	{
		ckmin(dp[i + 2], dp[i] + abs(arr[i] - arr[i + 2]));
		ckmin(dp[i + 1], dp[i] + abs(arr[i] - arr[i + 1]));
	}
	cout << dp[N - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc132/tasks/abc132_d

# 同じ色のボールは区別が不可能なので、赤と青の塊をどう作るかである。
# 青の塊が1個の場合は、1回で回収できる。
# 分割数な気がする。

from math import factorial
n, k = map(int, input().split())
mod = 10 ** 9 + 7
MAX = 2 * (10 ** 5) + 1 # これは変動するので注意。せいぜい10 ** 6くらいまでがTLEの限界

def com_init(MAX, mod):
    fac = [0] * MAX
    finv = [0] * MAX
    inv = [0] * MAX
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv

fac, finv = com_init(MAX, mod)

def nCr(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

for i in range(1, k + 1):
    ans = nCr(n - k + 1, i) * nCr(k - 1, i - 1) % mod
    print(ans)

Measured memory_bytes: 78464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int temp = 0;
		int j = i;
		while (j > 0) {
			temp += j % 10;
			j /= 10;
		}
		if (temp <= b && temp >= a) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
s = input()
t = input()

is_short = len(s) < len(t)

sd = sorted(s)
td = sorted(t)

for v in td:
    if ord(sd[0]) < ord(v):
        print('Yes')
        sys.exit()

if len(set(sd)) == 1 and len(set(td)) == 1 and is_short:
    print('Yes')
    sys.exit()

print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define lli unsigned long long int
using namespace std;

int main() {
	// your code goes here
    string n;
    cin>>n;
    lli sum=0;
    while(n.length()>0)
    {
        sum+=((n[n.length()-1]-'0')%10);
        n.pop_back();
       // cout<<n<<" "<<sum<<endl;
    }
   // cout<<sum;
    if(sum%9==0)
    cout<<"Yes\n";
    else
    cout<<"No\n";
	return 0;
}


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

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

    int r;
    cin >> r;

    string m = "";
    if(r < 1200) m = "ABC";
    else if(r < 2800) m = "ARC";
    else m = "AGC";

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
int n,k;
int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >>  n >> k;
    vector<int> v;
    FOR(i,1,n) {
        int a; cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    FOR(i,0,k-1) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
a,b = gets.split.map(&:to_i)
ctr = 0
(a..b).to_a.each do |n|
  if n.to_s[0] == n.to_s[-1]
    if n.to_s[1] == n.to_s[-2]
      ctr += 1
    end
  else
    next 
  end
end

puts ctr


Measured memory_bytes: 2556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    int index = 0;
    vector<int> history_vec;
    history_vec.reserve(1e6);
    set<int> history_set;
    ll loop_begin_index, loop_end_index;
    bool flag_break = false;
    for (ll i = 0; i < min(K, ll(N)); ++i){
        if (history_set.find(index) != history_set.end()){
            for (ll j = history_vec.size() - 1; j >= 0; --j){
                if (index == history_vec[j]) {
                    loop_begin_index = j;
                    loop_end_index = i;
                    flag_break = true;
                    break;
                }
            }
        }
        history_vec.push_back(index);
        history_set.insert(index);
        index = A[index] - 1;  //next
        if (flag_break)
            break;
    }

    if (K <= N){
        cout << index + 1 << endl;
    } else{
        if (loop_begin_index == loop_end_index){
            cout << history_vec[loop_begin_index] << endl;
        } else{
            cout << history_vec[loop_begin_index + (K - loop_begin_index) % (loop_end_index - loop_begin_index)] + 1 << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 12156
#include<bits/stdc++.h>
using namespace std;
int b[100];

int main()
{
    int n,k,x,i;
    cin>>n>>k;

    for(i=0;i<k;i++)
    {
        cin>>x;
        b[x]++;
    }

    for(i=n;;i++)
    {
        int temp=i;
        int flag=0;
        while(temp){
            if(b[temp%10]){
                    flag=1;
                break;
            }
            temp/=10;
        }

        if(flag==0)
        {
            cout<<i;
            return 0;
        }

    }




}


Measured memory_bytes: 256
#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>;

bool consist(int &bit, int &N, vector<int> &A, vector<vector<int>> &x, vector<vector<int>> &y) {
    rep(j,N) {//j+1人目の証言を検証
        if (bit & (1<<j)) {
            rep(k,A.at(j)) {//k+1番目の証言
                if (bit & (1<<x.at(j).at(k)-1)) {
                    if (y.at(j).at(k) == 0) return false;
                } else {
                    if (y.at(j).at(k) == 1) return false;
                }
            }
        }
    }
    return true;
}

int main() {
    int N, X;
    int ans = 0;
    bool Y;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    rep(i,N) {
        cin >> A.at(i);
        rep(j,A.at(i)) {
            cin >> X >> Y;
            x.at(i).push_back(X);
            y.at(i).push_back(Y);
        }
    }

    for (int bit = 0; bit < (1<<N); bit++) {
        int ok = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) ++ok;
        }
        if (consist(bit,N,A,x,y)) ans = max(ans, ok);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    //最後にa-b
    ll res = 0;
    //やってみる
    ll cnt = 0;
    //while(cnt < k)
    //{
    //    ll tmp_a, tmp_b;
    //    tmp_a = a;
    //    tmp_b = b;
    //    
    //    a = b + c;
    //    b = tmp_a + c;
    //    c = tmp_a + tmp_b;
    //    if(a-b > INF)
    //    {
    //        cout << "Unfair" << endl;
    //        return 0;
    //    }
//
    //    ++cnt;
    //}

    if(k % 2 == 0)
    {
        res = a-b;
    }
    else
    {
        res = b-a;
    }
    


    cout << res << endl;

    return 0;
}





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

"""
1からのループだけを考えれば良い
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1
count = 1

if A[0] == 1:
    print(1)
    exit()

while ok:
    count += 1
    seen[i-1] += count
    R.append(i)
    i = A[i-1]
    # 訪れたことがあれば
    if seen[i-1] != 0:
        k = seen[i-1]
        loop = R[k-1:]
        remain = R[:k-1]
        ok = False

L = len(loop)

if K < len(remain):
    print(remain[K])
else:
    print(loop[(K - len(remain)) % L])


Measured memory_bytes: 32380
import java.time.Instant;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for(int i=0; i<M; i++){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}

		int min=0;
		int max=N;
		for(int i=0; i<M; i++){
			if(min<L[i]){
				min=L[i];
			}

			if(max>R[i]){
				max=R[i];
			}
		}

		if(max>=min){
			System.out.println(max-min+1);
		}else{
			System.out.println(0);
		}


	}
}

Measured memory_bytes: 64044
#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)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>

int main(){
    int a,b,c,d;
    {
        string s;cin>>s;
        a=s[0]-'0';
        b=s[1]-'0';
        c=s[2]-'0';
        d=s[3]-'0';
    }
    if      (a+b+c+d==7)printf("%d+%d+%d+%d=7",a,b,c,d);
    else if (a+b+c-d==7)printf("%d+%d+%d-%d=7",a,b,c,d);
    else if (a+b-c+d==7)printf("%d+%d-%d+%d=7",a,b,c,d);
    else if (a+b-c-d==7)printf("%d+%d-%d-%d=7",a,b,c,d);
    else if (a-b+c+d==7)printf("%d-%d+%d+%d=7",a,b,c,d);
    else if (a-b+c-d==7)printf("%d-%d+%d-%d=7",a,b,c,d);
    else if (a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
    else if (a-b-c-d==7)printf("%d-%d-%d-%d=7",a,b,c,d);
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	string s;
	cin >> s;

	if (s[2] == '7' || s[1] == '7' || s[0] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}






	return 0;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    int cnt = 0;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<d; ++j) {
            cin >> x.at(i).at(j);
        }
    }
    for (int k=1; k<n; ++k) {
        for (int i=0; i<k; ++i) {
            double ddd = 0;
            for (int j=0; j<d; ++j) {
                ddd += pow(x.at(i).at(j)-x.at(k).at(j),2);
            }
            double dd = sqrt(ddd);
                if (ceil(dd) == floor(dd)) {
                    cnt++;
            }
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>

#define dbg if(0)
using namespace std;
#define ll long long

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

int main(){
    int n,m;
    int map[20][20];
    string ans;
    cin >> n>>m;
    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++){
            map[i][j]=151919;
        }
    }
    for(int i=0;i<m;i++){
        int a[4];
        string mojir;
        cin >> mojir;
        int l=0;
        for (const std::string& s : split(mojir, ',')) {
            dbg std::cout << s << std::endl;
            a[l]=stoi(s);
            l++;
        }
        map[a[0]-1][a[1]-1]=a[2];
        map[a[1]-1][a[0]-1]=a[3];
//        map[a-1][b-1]=c;
//        map[b-1][a-1]=d;
    }
    int s,g,V,P;
    int a[4];
    string mojir;
    cin >> mojir;
    int l=0;
    for (const std::string& s : split(mojir, ',')) {
        dbg std::cout << s << std::endl;
        a[l]=stoi(s);
        l++;
    }
    s=a[0];
    g=a[1];
    V=a[2];
    P=a[3];
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if (map[i][j]>map[i][k]+map[k][j]){
                    map[i][j]=map[i][k]+map[k][j];
                }
            }
        }
    }
    dbg{
        for(int i=0;i<20;i++){
            cout <<"Debug"<<i<<endl;;
            for(int j=0;j<20;j++){
                cout << map[i][j]<<" ";
            }
            cout <<endl;
        }
    }

    cout<<(V-P)-(map[s-1][g-1]+map[g-1][s-1])<<endl;
    

    return 0;
}


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

using namespace std;

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

unsigned long long int lcm(unsigned long long int a,unsigned long long int b){
  return (a/gcd(a,b))*b;
}

int main(){
  long long int n;
  vector<unsigned long long int> t;
  unsigned long long  int temp;
  unsigned long long int ans;

  cin >> n;
  for( int i = 0; i < n ; ++i){
    cin >> temp;
    t.push_back(temp);
  }
  ans = t[0];
  for(auto i : t ){
    ans = lcm( ans, i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt() 
    val s = read()

    var count = 0
    for(i in 0 until n-1) {
        val j = i+1
        val s1 = s.slice(0..i).toList().distinct()
        val s2 = s.slice(j until n).toList().distinct()
        val tmpCount = s1.count { s2.contains(it) }
        count = Math.max(count, tmpCount)
    }
    println(count)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 31992
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  string a,b;
  cin >> a >> b;

  int num = stoi(a+b);
  bool flag = 0;
  for(int i = 1; i <= 1000; i++) {
    if(i*i == num) flag = 1;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  int ans = 0;
  rep(i, N) {
    cin >> h.at(i);
    if (h.at(i) >= K) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)==2){
        if(n%k==0){
            printf("0\n");
        }
        else{
            printf("1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

// そのノードを通る確率
map<long, double> existance;

// そのノードを起点としたときのゴールまでの期待値
map<long, double> to_goal;

// 接続
map<long, set<long>> joint;

void solve() {
  long N, M;
  cin >> N >> M;
  rep (i, M) {
    long s, t;
    cin >> s >> t;
    joint[s].insert(t);
  }

  // そのノードを通る確率
  existance[1] = 1;
  for (long i = 1; i < N; i++) {
    double tmp = existance[i];
    tmp /= joint[i].size();
    for (long it: joint[i]) existance[it] += tmp;
  }

  // そのノードを起点としたときのゴールまでの期待値
  to_goal[N] = 0;
  for (long i = N - 1; i >= 1; i--) {
    double sum = 0;
    for (long it: joint[i]) sum += to_goal[it] + 1;
    sum /= joint[i].size();
    to_goal[i] = sum;
  }

  double ans_without_aoki = to_goal[1];
  double aoki = 0;
  for (long node = 1; node < N; node++) {
    // 枝の本数
    long edge_count = joint[node].size();

    // 塞げないケースで早期return
    if (joint[node].size() < 2) continue;

    double tmp_max = 0;
    for (auto it: joint[node]) tmp_max = max(tmp_max, to_goal[it]);
    tmp_max++;

    double current_to_goal = to_goal[node];
    double enhanced_to_goal = (current_to_goal * edge_count - tmp_max) / (edge_count - 1);
    double diff = current_to_goal - enhanced_to_goal;
    double tmp_result = diff * existance[node];
    aoki = max(aoki, tmp_result);

/*
    cout << "----------" << endl;
    cout << "node: " << node << endl;
    cout << "tmp_max: " << tmp_max << endl;
    cout << "edge_count: " << edge_count << endl;
    cout << "current_to_goal: " << current_to_goal << endl;
    cout << "enhanced_to_goal: " << enhanced_to_goal << endl;
    cout << "diff: " << diff << endl;
    cout << "tmp_result: " << tmp_result << endl;
*/
  }

//  cout << "aoki: " << aoki << endl;

  double ans = ans_without_aoki - aoki;
  cout << ans << endl;
}

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


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

int main()
{
  string str;
  cin>>str;

  int a[26];
  for(int i = 0 ; i<26; i++)
  a[i] = 0;

  for(int i = 0; i<str.size(); i++)
  {
    a[str[i]-'a'] += 1;
  }
  int flag = 0;
  for(int  i = 0; i<26; i++)
  {
    if(a[i]%2 != 0)
    {flag = 1;
    break;
    }
  }

  if(flag == 1)
  cout<<"No\n";
  else
  cout<<"Yes\n";
  return 0;
}


Measured memory_bytes: 256
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# inputb = input().split()
# inputbint = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input().split()
#     inputNum = [int(x) for x in inputNum]
#     inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

min = min([a, b])
cnt = 0

for i in range(min, 0, -1):
    checka = a % i
    checkb = b % i
    if checka == 0 and checkb == 0:
        cnt += 1
        if cnt == c:
            print(i)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
long long n,i,now,maxi,vala,valb;
long long a[10],b[10],curr[10];
bool ok;
long long fact(long long n)
{
    if(n==1)
        return 1;
    return n*fact(n-1);
}
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        cin>>b[i];

    maxi=fact(n);
    for(now=1;now<=maxi;now++)
    {
        if(now==1)
        {
            for(i=1;i<=n;i++)
            curr[i]=i;
        }
        else
            next_permutation(curr+1, curr+n+1);

        ok=true;
        for(i=1;i<=n;i++)
        {
            if(curr[i]!=a[i])
            {
                ok=false;
                break;
            }
        }
        if(ok)
            vala=now;

        ok=true;
        for(i=1;i<=n;i++)
        {
            if(curr[i]!=b[i])
            {
                ok=false;
                break;
            }
        }
        if(ok)
            valb=now;
    }
    cout<<abs(vala-valb);
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = list(input().rstrip())
    b = list(input().rstrip())
    c = list(input().rstrip())
    turn = 'a'
    while True:
        if turn == 'a':
            if len(a)==0:
                print('A')
                break
            turn = a.pop(0)
        elif turn == 'b':
            if len(b)==0:
                print('B')
                break
            turn = b.pop(0)
        else:
            if len(c)==0:
                print('C')
                break
            turn = c.pop(0)

if __name__ == '__main__':
    main()

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

int main() {
  string s1;
  cin >> s1;
  string s2;
  cin >> s2;
  string s3;
  cin >> s3;

  string ans;
  ans += s1.at(0);
  ans += s2.at(0);
  ans += s3.at(0);
  transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
  cout << ans << endl;
}

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

int main(){
    long double a,b,n;
    cin >> a >> b >> n;

    if(n < b-1){
        cout << floor(a * n / b) << endl;
    }
    else{
        cout << floor(a * (b-1) / b) << endl;
    }
    return 0;
}


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

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
}

Measured memory_bytes: 62856
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int N,T;
int c[10001],t[10001];
int main (){
      cin>>N>>T;
      rep0(i,N){
            cin>>c[i]>>t[i];
      }
      int ans=inf;
      rep0(i,N){
            if(t[i]<=T){
                  ans=min(ans,c[i]);
            }
      }
      if(ans==inf){
            cout<<"TLE"<<endl;
      }
      else{
            cout<<ans<<endl;
      }
      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vi v(n + 1);
	while (m--)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		if (a > b) swap(a, b);
		v[a]++; v[b]--;
	}
	REP(i, n) v[i + 1] += v[i];
	REP(i, n + 1)
	{
		if (v[i] % 2 == 1)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640