akhauriyash/Code-Regression huggingface dataset:
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
class Main {
    static class Pair{
        long x;
        long cnt;
        public Pair(long x,long cnt){
            this.x=x;
            this.cnt=cnt;
        }
    }
    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static void solve() throws IOException {
        //	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        char c[]=sc.next().toCharArray();
        if(c.length>=4){
            if(c[0]=='Y' && c[1]=='A' && c[2]=='K' && c[3]=='I') pw.println("Yes");
            else pw.println("No");
        }else pw.println("No");
        pw.close();
    }


    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}

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

  
int main() {
  vector<int> A(9);
  for(int i=0;i<9;i++){
	cin >> A[i];
  }
  int N ;
  cin >> N;
  vector<int> B(N);
  for(int i=0;i<N;i++){
	cin >> B[i];
    
  }
  vector<int> q(9,-1) ;
  for(int i=0;i<N;i++){
    for(int j=0;j<9;j++){
	if(B[i] == A[j]) q[j+1] = j+1;
    }
  }
  if((q[1]==1&&q[4]==4&&q[7]==7)||(q[2]==2&&q[5]==5&&q[8]==8)||(q[3]==3&&q[6]==6&&q[9]==9)||(q[1]==1&&q[2]==2&&q[3]==3)||(q[5]==5&&q[4]==4&&q[6]==6)||(q[8]==8&&q[9]==9&&q[7]==7)||(q[1]==1&&q[5]==5&&q[9]==9)||(q[3]==3&&q[5]==5&&q[7]==7)){
   puts("Yes"); 
  }
     else 
     {
       puts("No");
     }
     cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b;
	if (a < b)
	{
		c = a;
		a = b;
		b = c;
	}
	while (b != 0)
	{
		c = a%b;
		a = b;
		b = c;
	}
	cout << a << endl;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string s;
int main() {
    while(std::getline(std::cin, s)) {
        if(s == ".") break;
        
        std::stack<char> stack;
        bool f = true;
        for(auto c: s) {
            if(c == '(' || c == '[') {
                stack.push(c);
            } else if(c == ')' || c == ']') {
                if(stack.empty()) {
                    f = false;
                    break;
                }

                char left = stack.top();
                stack.pop();
                if( (left == '(' && c == ')') || (left == '[' && c == ']') ) {
                    continue;
                } else {
                    f = false;
                    break;
                }
            }
        }

        std::cout << ( (f && stack.empty()) ? "yes" : "no") << std::endl;
    }
}


Measured memory_bytes: 3152
def dijkstra_heap(n,s,edge):
    # 始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n  # True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heappush(edgelist, e)
    while len(edgelist):
        minedge = heappop(edgelist)
        # まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])
    return d
def examD():
    H, W = LI()
    c = [LI() for _ in range(10)]
    A = [LI() for _ in range(H)]
    edge = [[] for i in range(10)]
    # edge[i] : iから出る道の[重み,行先]の配列
    for i in range(10):
        for j in range(10):
            x, y, z = i, j, c[i][j]
            edge[x].append([z, y])
    res = []
    for i in range(10):
        res.append(dijkstra_heap(10, i, edge))
#    print(res)
    d = defaultdict(int)
    for l in A:
        for j in l:
            d[j] +=1
    ans = 0
    for i in range(10):
        ans += d[i]*res[i][1]
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 3952
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    for (f in 0..25) {
        for (s in 0..13) {
            if (f == 0 && s == 0) {
                continue
            }
            if (N % (f * 4 + s * 7) == 0) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

Measured memory_bytes: 33664
import sys
sys.setrecursionlimit(10**7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n = int(input())
xy = [list(map(int, input().split()))+[i] for i in range(n)]
G = []

xy.sort()
for j in range(1, n):
    sx, sy, si = xy[j-1]
    tx, ty, ti = xy[j]
    G.append((min(abs(sx-tx), abs(sy-ty)), si, ti))

xy.sort(key=lambda x: x[1])
for j in range(1, n):
    sx, sy, si = xy[j-1]
    tx, ty, ti = xy[j]
    G.append((min(abs(sx-tx), abs(sy-ty)), si, ti))

uf = UnionFind(n)
ans = 0
G.sort()
for c, x, y in G:
    if uf.same(x, y):
        continue
    uf.union(x, y)
    ans += c
print(ans)


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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int area=a*b;
	int perimeter=2*a+2*b;
	cout<<area<<" "<<perimeter<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 3008
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;


// The author implemented this solution after he read the editorial.
int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, 0, n) {
    cin >> s[i];
  }
  int c = 0;
  int bc = 0;
  REP(i, 0, n) {
    bool all_black = true;
    bool all_white = true;
    REP(j, 0, n) {
      if (s[j][i] == '.') {
	all_black = false;
      }
      if (s[j][i] == '#') {
	all_white = false;
      }
    }
    c += all_black ? 0 : 1;
    bc += all_white ? 0 : 1;
  }
  if (bc == 0) {
    cout << -1 << endl;
    return 0;
  }
  int mi = 1e8;
  REP(i, 0, n) {
    bool all_white = true;
    REP(j, 0, n) {
      if (s[j][i] == '#') {
	all_white = false;
	break;
      }
    }
    int x = 0;
    REP(j, 0, n) {
      x += s[i][j] == '.' ? 1 : 0;
    }
    if (all_white) {
      x += 1;
    }
    mi = min(mi, x);
  }
  cout << mi + c << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;


int main(){
    ll c=0,d=0,k=0,n,h,q,w,m,ans=0;
    string s,s2;
    cin >> n >> m;
    VI a(n);

    rep(i,n){
       cin >> a[i];
    }
    PQ p;
    rep(i,n){
    p.push(a[i]);
    }
    rep(i,m){
        int top=p.top();
        p.pop();
        p.push(top/2);
    }
    while(p.size()){
        ans += p.top();
        p.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9;
const int N = 1e5+10;
/*=======================================================================*/

int n, m;
int dp[N], in[N];
vector<int>G[N];
queue<int>q;
int ans = 0;

int main() {
   int a, b;
   scanf("%d%d", &n, &m);
   forn(i, m) {
      scanf("%d%d", &a, &b);
      in[b]++;
      G[a].push_back(b);
   }
   for1(i, n) {
      if(!in[i]) q.push(i);
   }
   while(!q.empty()) {
      int now = q.front();
      q.pop();
      int sz = G[now].size();
      forn(i, sz) {
         dp[G[now][i]] = max(dp[G[now][i]], dp[now] + 1);
         in[G[now][i]]--;
         if(in[G[now][i]] == 0) q.push(G[now][i]);
      }
   }
   for1(i, n) {
      ans = max(ans, dp[i]);
   }
   cout << ans << endl;
}

Measured memory_bytes: 6528
n, x, y = map(int, input().split())

ans = [0] * (n + 1)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        sub = min(abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))
        ans[sub] += 1

for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    string S;cin>>S;
    int N=int(S.size());
    ll dp[N+2][13];
    for(int i=0;i<N+2;i++){
        for(int j=0;j<13;j++){
            dp[i][j]=0;
        }
    }
    dp[N+1][0]=1;
    
    vector<int> amari={1,10,9,12,3,4};
    
    for(int i=N;i>=1;i--){
        for(int j=0;j<13;j++){
            if(S[i-1]=='?'){
                int when=(N-i)%6;
                for(int k=0;k<10;k++){
                    dp[i][(j+amari[when]*k)%13]+=dp[i+1][j];
                    dp[i][(j+amari[when]*k)%13]=dp[i][(j+amari[when]*k)%13]%mod;
                }
            }else{
                int when=(N-i)%6;
                dp[i][(j+amari[when]*(S[i-1]-'0'))%13]+=dp[i+1][j];
                dp[i][(j+amari[when]*(S[i-1]-'0'))%13]=dp[i][(j+amari[when]*(S[i-1]-'0'))%13]%mod;
            }
        }
    }
    
    cout<<dp[1][5]<<endl;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int dp[110000];
int main()
{
	int N;
	vec(H)
		cin >> N;
	fx(N) {
		vecp(H)
	}



	fx(N+1) {
		dp[x] = INT_MAX;
	}
	dp[0] = 0;

	fx(N+1) {
		if (x+1<N) {
			dp[x + 1] = min(dp[x + 1], dp[x] + abs(H[x] - H[x + 1]));
		}
		if (x+2<N) {
			dp[x + 2] = min(dp[x + 2], dp[x] + abs(H[x] - H[x + 2]));
		}

	}
	ce(dp[N-1])
    return 0;
}



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

const int MOD = (int)1e9 + 7;

int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}

const long long INV9 = Pow(9, -1);

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

  int n, q; cin >> n >> q;
  vector<pair<int, int>> interv(q);
  vector<int> v(2 * q);
  int min_l = (int)1e9 + 5, max_r = -1;
  for (int i = 0; i < q; ++i) {
    int l, r; cin >> l >> r; --l;
    interv[i] = {l, r};
    min_l = min(min_l, l);
    max_r = max(max_r, r);
    v[i] = l;
    v[i + q] = r;
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());

  auto Norm = [&](int x) {
    int pos = lower_bound(v.begin(), v.end(), x) - v.begin();
    assert(v[pos] == x);
    return pos;
  };

  vector<vector<int>> adj(v.size());
  for (auto &p : interv) {
    int x = Norm(p.first), y = Norm(p.second);
    adj[x].emplace_back(y);
    adj[y].emplace_back(x);
  }

  vector<bool> vis(v.size());
  function<void(int, int&)> DFS = [&](int node, int &mask) {
    mask |= 1 << node;
    vis[node] = true;
    for (int &x : adj[node]) {
      if (!vis[x]) {
        DFS(x, mask);
      }
    }
  };

  auto Calc = [&](int len) {
    return 1LL * (Pow(10, len) - 1 + MOD) * INV9 % MOD;
  };

  vector<int> groups;
  for (int i = 0; i < (int)v.size(); ++i) {
    if (!vis[i]) {
      groups.emplace_back();
      DFS(i, groups.back());
    }
  }

  auto GetCoef = [&](int mask) {
    vector<int> pos;
    for (int i = 0; (1 << i) <= mask; ++i) {
      if (mask & (1 << i)) {
        pos.emplace_back(i);
      }
    }
    int coef = 1;
    for (int i = 1; i < (int)pos.size(); ++i) {
      int x = pos[i - 1], y = pos[i];
      if (x + 1 != y) continue;
      int den = Calc(v[y] - v[x]);
      coef = 1LL * coef * Pow(den, -1) % MOD;
      coef = 1LL * coef * (den + 1) % MOD;
    }
    return coef;
  };
  
  int m = groups.size();
  vector<int> coef(1 << m), meta_mask(1 << m);
  for (int meta = 1; meta < (1 << m); ++meta) {
    int &mask = meta_mask[meta];
    for (int i = 0; i < m; ++i) {
      if (meta & (1 << i)) {
        mask |= groups[i];
      }
    }
    coef[meta] = GetCoef(mask);
  }
  
  auto dp = coef;
  for (int color = 1; color < 9; ++color) {
    for (int meta = (1 << m) - 1; meta > 0; --meta) {
      for (int sub = (meta - 1) & meta; sub > 0; sub = (sub - 1) & meta) {
        int oth = meta ^ sub;
        if (oth & 1) continue;
        (dp[meta] += 1LL * dp[sub] * coef[oth] % MOD) %= MOD;
      }
    }
  }
  int ans = 1LL * Pow(10, v[0]) * Pow(10, n - v.back()) % MOD;
  for (int i = 1; i < (int)v.size(); ++i) {
    ans = 1LL * ans * Calc(v[i] - v[i - 1]) % MOD;
  }
  ans = 1LL * ans * dp[(1 << m) - 1] % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 2e5 + 10;

int n;
int a[MAXN];

stack <int> s;

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);

  for (int i = n - 1; i >= 0; i -= 2)
    printf("%d ", a[i]);

  for (int i = n - 2; i >= 0; i -= 2)
    s.push(a[i]);

  while (!s.empty()) {
    printf("%d ", s.top());
    s.pop();
  }
  printf("\n");

  return 0;
}



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

int main() {
  int A;
  cin >> A;
  int B = A / 100;
  int C = (A - B * 100) / 10;
  int D = (A - B * 100 - C * 10);
  cout << B + C + D  << endl;
}

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

int main() {
#ifdef LOCAL_DEFINE
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "w", stdout);
	long long _begin_time = clock();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans << '\n';

#ifdef LOCAL_DEFINE
	long long _end_time = clock();
	cerr << "time = " << _end_time - _begin_time << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))[::-1]
ans = "Yes"

for i in range(1, n):
    if h[i] == h[i - 1] + 1:
        h[i] -= 1
    elif h[i] - h[i - 1] > 1:
        ans = "No"


print(ans)


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

const int INF = 0x7f7f7f7f;

bool all_ok(vector< int > &v, int k)
{
    for(int x : v)
    {
        if(x>=k) continue;

        return false;
    }

    return true;
}

int knapsack(vector< int > &temp, int i, int k, vector< vector< int > > &v, int m)
{

    if(all_ok(temp,k)) return 0;

    if(i==v.size()) return INF;


    vector< int > t = temp;

    for(int it=0;it<m;it++)
        temp[it]+=v[i][it+1];

    return min(v[i][0]+knapsack(temp,i+1,k,v,m),knapsack(t,i+1,k,v,m));
}
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan

    int n,m,x;
    cin >> n >> m >> x;

    vector< vector< int > > v;

    for(int i=0; i<n; i++)
    {
        vector< int > temp_i;
        for(int i=0;i<=m;i++)
        {
            int temp; cin >> temp;
            temp_i.push_back(temp);
        }
        v.push_back(temp_i);
    }


    vector< int > temp;
    for(int i=0; i<m; i++)
        temp.push_back(0);

    int ans = knapsack(temp,0,x,v,m);

    ans>=INF ? cout << "-1\n" : cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3656
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-14 12:03:49
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , x[MAXN] , L , q , nxt[LOG][MAXN];

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

    cin >> n;
    for(int i = 1 ; i <= n ; i++)   cin >> x[i];
    cin >> L;
    for(int i = 1 ; i <= n ; i++)   nxt[0][i] = upper_bound(x + 1 , x + n + 1 , x[i] + L) - x - 1;
    for(int i = 1 ; i < LOG ; i++)  for(int j = 1 ; j <= n ; j++)   nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
    cin >> q;
    while(q--){
        int l , r;
        cin >> l >> r;
        if(l > r)   swap(l , r);
        int ans = 0;
        for(int i = LOG - 1 ; i >= 0 ; i--) if(nxt[i][l] < r)   l = nxt[i][l] , ans += (1 << i);
        cout << ans + 1 << endl;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 9856
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f s = read (sortBy (flip compare) s) - read (sort s)

main = getInt >>= flip replicateM getLine >>= mapM_ (print . f)

Measured memory_bytes: 3732
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 998244353
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0ll)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1ll);

/*======================================================================*/

void solve(){
    string s;
    cin >> s;
    rep(i, 1, s.length()-1){
        if(1){
            cout << s[i-1] << s[i] << s[i+1];
            return; 
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

#define INF 100000000

#define White 0
#define Gray 1
#define Black 2

//重み付き隣接行列
int Tree[100][100];

//ダイクストラ

void dijkstra(int n){
  int u,minv; 

  //d = 最短コスト
  //p = 頂点vの親
  int d[100], p[100], color[100];

  //初期化

  for(int i = 0 ; i < n ; i++){
    d[i] = INF;
    color[i] = White;
  }

  d[0] = 0;
  p[0] = -1;
  color[0] = Gray;

  while(1){
    u = -1;
    minv = INF;

    for(int i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != Black){
	u = i;
	minv = d[i];
      }
    }

    if(u == -1){
      break;
    }

    color[u] = Black;

    //地点の更新

    for(int v = 0 ; v < n ; v++){
      if(color[v] != Black && Tree[u][v] != INF){
	if(d[v] > d[u] + Tree[u][v]){
	  d[v] = d[u] + Tree[u][v];
	  color[v] = Gray;
	}
      }
    }
  }
  for(int i = 0 ; i < n ; i++){
    cout << i << " ";
    if(d[i] == INF){
      cout << -1;
    }else{
      cout << d[i];
    }

    cout << endl;
  }
}

int main(){
  int n;
  int k, c, u, v;
  cin >> n;

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      Tree[i][j] = INF;
    }
  }

  for(int i = 0 ; i < n ; i++){
    cin >> u >> k;
    for(int j = 0 ; j < k ; j++){
      cin >> v >> c;
      Tree[u][v] =c;
    }
  }

  dijkstra(n);

  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int a,b,k;
int cnt=0;
signed main(){
    cin>>a>>b>>k;
    int sks=gcd(a,b);
    for(int i=sks;i>0;i--){
        if(sks%i==0)cnt++;
        if(cnt==k){
            cout<<i<<endl;
            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
    #from itertools import 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

    n = int(input())
    b = list(map(int, input().split()))
    res = b[0] + b[-1]
    for i in range(n-2):
        res += min(b[i], b[i+1])
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
using namespace std;
 
int main(){
long int carpan =1,carpan2,sonuc;
long int N;
cin >> N;
long int c = sqrt(N);

for(int i=c;i>0;i--){
	if(N%i ==0){
		carpan = i;
		break;
	}
}
carpan2 = N / carpan;
sonuc = carpan2 + carpan - 2;
cout << sonuc;
return 0;

	
}

Measured memory_bytes: 256
n = gets.to_i
arr = (1..9).to_a
mal_arr = []

arr.each{ |num|
mal_arr << num *1.to_i
mal_arr << num *2
mal_arr << num *3
mal_arr << num *4
mal_arr << num *5
mal_arr << num *6
mal_arr << num *7
mal_arr << num *8
mal_arr << num *9
  }

if mal_arr.include?(n) == true
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
L =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(L[k-1])

Measured memory_bytes: 3060
import * as fs from 'fs';

namespace AtCoder.abc104 {

    class ProgramA {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *  1199
         * out
         * ABC
         */
        main(): void {
            const r: number = parseInt(this.args[0], 10);
            if (r < 1200) {
                console.log('ABC');
            } else if (r < 2800) {
                console.log('ARC');
            } else {
                console.log('AGC');
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramA(args);
    prg.main();
}


Measured memory_bytes: 7372
from itertools import permutations
 
def floyd_warshall():
            for k in range(N):
                for i in range(N):
                    for j in range(N):
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
 
            
N, M, R = list(map(int, input().split()))
r = (int(i)-1 for i in input().split())
res = float('inf')
dist = [[float("inf")] * N for i in range(N)]
for i in range(N):
        dist[i][i] = 0
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    dist[a][b] = dist[b][a] = c
 
floyd_warshall()
for p in permutations(r):
        s = 0
        for i in range(R - 1):
            s += dist[p[i]][p[i + 1]]
        if s < res:
            res = s
print(res)

Measured memory_bytes: 59096
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
from itertools import combinations
from math import hypot
input = sys.stdin.readline
sx,sy,gx,gy = map(int,input().split())
n = int(input())
barrier = [list(map(int,input().split())) for i in range(n)]
evv = [(n,n+1,hypot(gx-sx,gy-sy))]
for i in range(n):
  for x1,y1,k in (sx,sy,n),(gx,gy,n+1):
    b1 = barrier[i]
    x2,y2,r = b1[0],b1[1],b1[2]
    dist = max(hypot(x2-x1,y2-y1)-r,0)
    evv.append((i,k,dist))
for i,j in combinations(range(n),2):
  b1 = barrier[i]
  b2 = barrier[j]
  x1,y1,r1 = b1[0],b1[1],b1[2]
  x2,y2,r2 = b2[0],b2[1],b2[2]
  dist = max(hypot(x2-x1,y2-y1)-(r1+r2),0)
  evv.append((i,j,dist))
v1,v2,edge = zip(*evv)
csr = csr_matrix((edge,(v1,v2)),shape = (n+2,n+2))
print(dijkstra(csr, directed = False,indices = n)[n+1])

Measured memory_bytes: 113172
#include <stdio.h>
#define MAX 250
int main(){
  int i,n;
  int heap[MAX];
  for(i = 0;i<MAX;i++){
    heap[i]=0;
  }
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }
  for(i = 1;i<=n;i++){
    if(i ==1) {
      printf("node %d: key = %d, left key = %d, right key = %d, \n",i,heap[i],heap[2*i],heap[2*i+1]);
    }
    else if(heap[2*i] != 0 && heap[2*i+1]!=0 && 2*i+1<MAX ){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,heap[i],heap[i/2],heap[2*i],heap[2*i+1]);
    }
    else if(heap[2*i] != 0  && 2*i+1<MAX){
       printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,heap[i],heap[i/2],heap[2*i]);
    }
    else if(heap[2*i+1] != 0 && 2*i+1<MAX) {
       printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,heap[i],heap[i/2],heap[2*i+1]);
    }
    else {
      printf("node %d: key = %d, parent key = %d, \n",i,heap[i],heap[i/2]);
}
  }
  return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> mp(N);
    for (int i = 0; i < N; i++) {
        cin >> mp[i];
    }
    sort(mp.begin(), mp.end());
    string ans = "";
    for (auto &e : mp) {
        ans += e;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>

int main()
{
    long long N, X;
    std::cin >> N >> X;

    long long L = X;
    long long a = X;
    long long b = N - X;
    while (1){
        long long r = a % b;
        L += 2 * a + b - r;
        if(r == 0){
            L -= b; std::cout << L << std::endl; return 0;
        }
        a = b - r;
        b = r;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
 
int main(){
    long long int a,v,b,w,t;
 
    cin >>a>>v>>b>>w>>t;
    
    if(w >= v){
        cout << "NO" << endl;         
    }else{
        if(abs(a-b) <= t*(v-w)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;
const int inf = 99999999;

using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == b[i]){
			cnt++;
			if(cnt >= 3){
				cout << "Yes" << endl;
				return 0;
			}
		}else{
			cnt = 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}
 


Measured memory_bytes: 3580
MOD=10**9+7
def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)#階乗テーブル、逆元テーブル、逆元
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        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,inv


def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD
        
n,k=map(int,input().split())
fac,finv,inv=facinv(2*n)

if k>=n-1:
    print(COM(2*n-1,n-1))
else:
    ans=COM(2*n-1,n-1)
    for i in range(1,n-k):
        ans=(ans-COM(n,i)*COM(n-1,i-1)%MOD+MOD)%MOD
    print(ans%MOD)

Measured memory_bytes: 48880
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void sol(void)
{
ll d,s,t;
cin>>d>>t>>s;
cout<<((d<=t*s)?"Yes":"No");
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod=1e9+7;

string x;
int dp[10005][101][2];
int d;

int dfs(int i,int sum, bool smaller){
    if(i==(int)x.size()){
        return (sum%d == 0);
    }
    if(dp[i][sum][smaller] != -1){
        return dp[i][sum][smaller];
    }

    int upper_limit = 9;
    if(!smaller) upper_limit=x[i]-'0';

    int ans=0;
    for(int digit=0; digit<=upper_limit; ++digit){
        int t=x[i]-'0';
        bool f=smaller;
        if(digit < t){
            f|=1;
        }
        ans=(ans+dfs(i+1,(sum+digit)%d,f))%mod;
    }
    return dp[i][sum][smaller]=ans;
}

int main() {
    IOS
    cin>>x>>d;
    memset(dp, -1, sizeof(dp));
    cout<<(dfs(0,0,0)-1+mod)%mod;
    return 0;
}

Measured memory_bytes: 12296
N = int(input())
A = [0]*5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
nekku = min(A)
ans = N//nekku + 4
if N%nekku != 0:
    ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

struct edge{
    int to, cap, rev;
    bool deleted, isrev;
};

int V, E, Q, F;
vector<vector<edge> > G;
vector<bool> used;

void add_edge(int from, int to, int cap){
    G[from].emplace_back((edge){to, cap, int(G[to].size()), false, false});
    G[to].emplace_back((edge){from, 0, int(G[from].size())-1, false, true});
}

// 増加路の探索
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(auto &e : G[v]){
        if(!used[e.to] && e.cap > 0 && !e.deleted){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int flow(int s, int t, int lim){
    int fl = 0;
    while(1){
        fill(used.begin(), used.end(), false);
        int f = dfs(s, t, lim);
        if(f==0) break;
        fl += f;
        lim -= f;
    }
    return fl;
}

void delete_edge(int from, int to){
    bool ft = false, tf = false;
    for(auto &e : G[from]){
        if(e.to == to && !e.deleted){
            if(e.isrev && e.cap > 0){
                ft = true;
            }
        }
    }
    for(auto &e : G[to]){
        if(e.to == from && !e.deleted){
            if(e.isrev && e.cap > 0){
                tf = true;
            }
        }
    }
    if(ft && !tf){
        if(flow(to, from, 1)==0){
            flow(V-1, 0, 1);
            flow(to, from, 1);
            F--;
        }
    }
    if(tf && !ft){
        if(flow(from, to, 1)==0){
            flow(V-1, 0, 1);
            flow(from, to, 1);
            F--;
        }
    }
    for(auto &e : G[from]){
        if(e.to == to && !e.deleted){
            e.deleted = true;
        }
    }
    for(auto &e : G[to]){
        if(e.to == from && !e.deleted){
            e.deleted = true;
        }
    }
}

int main() {
    cin >> V >> E >> Q;
    G.resize(V);
    used.resize(V);
    for(int i=0;i<E;i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        add_edge(u, v, 1);
        add_edge(v, u, 1);
    }
    F = 0;
    for(int i=0;i<Q;i++){
        int m, a, b;
        cin >> m >> a >> b;
        a--; b--;
        if(m == 1){
            add_edge(a, b, 1);
            add_edge(b, a, 1);
        }
        else{
            delete_edge(a, b);
        }
        F += flow(0, V-1, IINF);
        cout << F << endl;
    }
    return 0;
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << in() + in() / 2 << "\n";
}

Measured memory_bytes: 256
n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [p-1 for p in P]

D = [[-10**18]*(n+1) for _ in range(n)]
for i in range(n):
    D[i][0] = 0
Q = [0]*n
A = [0]*n
for i in range(n):
    pos = i
    for j in range(n):
        D[i][j+1] = C[P[pos]]+D[i][j]
        pos = P[pos]
        if pos == i:
            break
    Q[i] = D[i][j+1]
    A[i] = j+1
#print(D)
#print(Q)
#/Users/kobarishigetaka/Dropbox/kyopro/atcoder/abc175/d.pyprint(A)


ans = -10**18

for i in range(n):
    if k < A[i]:
        for j in range(k):
            ans = max(D[i][j+1], ans)
    else:
        if D[i][0] > Q[i]:
            for j in range(A[i]):
                ans = max(D[i][j+1], ans)
        else:
            q, r = divmod(k, A[i])
            temp = (q-1)*Q[i]
            if q-1 != 0:
                ans = max(temp, ans)
            for j in range(A[i]):
                ans = max(D[i][j+1]+temp, ans)
            temp = q*Q[i]
            ans = max(temp, ans)
            for j in range(r+1):
                ans = max(D[i][j]+temp, ans)

print(ans)


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

using namespace std;

const int MAX_N = 2e5 + 10;

int N, pa[MAX_N], k_pa[MAX_N], cnt1[MAX_N], cnt2[MAX_N], ans[MAX_N];
bool is_kp[MAX_N];
vector<int> edge[MAX_N];

void dfs1(int x, int y, int z) {
    pa[x] = y;
    if (x > z) {
        is_kp[x] = true;
        k_pa[x] = z;
        z = x;
    }
    for (int i : edge[x]) {
        if (i == y) continue;
        dfs1(i, x, z);
    }
}

void dfs2(int x, int req, int cnt[]) {
    cnt[x] = 1;
    for (int i : edge[x]) {
        if (i == pa[x] || i > req) continue;
        dfs2(i, req, cnt);
        cnt[x] += cnt[i];
    }
}

void dfs3(int x) {
    if (x != 1) {
        if (is_kp[x]) ans[x] += cnt2[x];
        else if (is_kp[pa[x]]) ans[x] += cnt1[x] - cnt2[x];
    }
    for (int i : edge[x]) {
        if (i == pa[x]) continue;
        ans[i] = ans[x];
        dfs3(i);
    }
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i < N; i++) {
        int a, b; scanf("%d%d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs1(1, 0, 0);
    for (int i = 1; i <= N; i++) {
        if (is_kp[i]) {
            dfs2(i, i, cnt1);
            dfs2(i, k_pa[i], cnt2);
        }
    }
    dfs3(1);
    for (int i = 2; i <= N; i++) printf("%d ", ans[i]);
    printf("\n");
}

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

int main() {
    cout << fixed << setprecision(15);
    int W , H , x , y , cx=0  , cy=0 ;
    double S ;
    cin >> W >> H >> x >> y;
    long long a= (long long)H*W;
    S = (double)a/2;
    if(W%2==0 && H%2==0){
        cx = W/2;
        cy = H/2;
        if(cx == x && cy == y){
            cout << S << ' ' << 1 << endl;
       }
        else{
            cout << S << ' ' << 0 << endl;
    }
    }
    if(W%2==1 || H%2==1){
        cout << S << ' ' << 0 << endl;
}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int i, mountain[10],x,y;
	int n = 0;
	int l = 0;
	int m = 0;
	for (i = 0;i < 10;i++) {
		scanf("%d", &mountain[i]);
	}
	for (i = 0;i < 10;i++) {
		if (mountain[i] > m) {
			m = mountain[i];
			x = i;
		}
	}
	printf("%d\n", m);
	for (i = 0;i < 10;i++) {
		if (i == x) {}
		else {
			if (mountain[i] > n) {
				n = mountain[i];
				y = i;
			}
			
		}
	}
	printf("%d\n", n);
	for (i = 0;i < 10; i++) {
		if (i == y || i == x) {}
		else {
			if (mountain[i] > l) {
				l = mountain[i];
			}
		}
	}
	printf("%d\n", l);

	return 0;
}

Measured memory_bytes: 2756
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}


Measured memory_bytes: 888
n = int(input())

SN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
HN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
DN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
CN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])

for i in range(n):
    M, N = input().split()

    if M == "S":
        SN.remove(int(N))
    elif M == "H":
        HN.remove(int(N))
    elif M == "C":
        CN.remove(int(N))
    elif M == "D":
        DN.remove(int(N))

for i in SN:
    print('S {0}'.format(i))
for i in HN:
    print('H {0}'.format(i))
for i in CN:
    print('C {0}'.format(i))
for i in DN:
    print('D {0}'.format(i))


Measured memory_bytes: 5612