akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    int dp[100010][3];
    int h[100010][3];
    rep(i,n) cin >> h[i][0] >> h[i][1] >> h[i][2];
    
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i+1][0] = max(dp[i][1],dp[i][2]) + h[i+1][0];
            dp[i+1][1] = max(dp[i][2],dp[i][0]) + h[i+1][1];
            dp[i+1][2] = max(dp[i][0],dp[i][1]) + h[i+1][2];
        }
    }
    
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
    
    
}



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



Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	cout<<((a-1)*(b-1));
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
mod = 2019

cnt = [0 for _ in range(2019)]
S = S[::-1]
wk = 0
cnt[0] = 1

for i in range(0,N):
  wk = (wk + int(S[i]) * pow(10,i,mod)) % mod
  #print(i,wk)
  cnt[wk] += 1
  
ans = 0
for i in range(2019):
  m = cnt[i]
  ans += m * (m-1) // 2
  
print(ans)

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)998244353;
const int MX = 998244353;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
ll f[Sz];

ll n;

ll A, B, K;
              
ll binpow (ll a, ll b) {
  ll res = 1;
  while (b) { 
    if (b & 1)
      res = (res * a) % Mod;
    a = (a * a) % Mod;
    b >>= 1;
  }
  return res;
}
ll inv (ll a) {
  return binpow (a, Mod - 2);
}                       
ll C (int n, int k) {
  if (n < k) {
    cout << n << ' ' << k << endl;
    exit (0);
  }    

  return (f[n] * inv (f[n - k] * f[k] % Mod)) % Mod;
}

ll calc (int x, int y) {     
  ll res = 0;
  for (int g = 0; g <= min (x, y); g++) {
    if ((x-g) + (y - g) + g > n)  continue;
    ll val = C(n - g, x - g) * C(n - x, y - g) % Mod;
    //cout << x-g << ' ' << y-g << endl;
    val = val * C(n, g) % Mod;
    res = (res + val) % Mod;
  }
  return res;
}
//# include <windows.h>
                    
int main()
{                                  
  # ifdef Local
    //localInput();                   
  # endif
  //Read_rap();
  

  cin >> n >> A >> B >> K;

  f[0] = 1;
  for (int i = 1; i <= n; i++)
    f[i] = (f[i - 1] * i) % Mod;
    
  ll ans = 0;   
  for (ll x = 0; A*x <= K && x <= n; x++) {
    ll y = K - A*x;      
    if (y % B == 0 && y/B <= n) {
      y /= B;

      ans = (ans + C (n, x) * C(n, y) % Mod) % Mod;
    }
  }           
  cout << ans;
      

  return 0;
}






// Coded by Z..



Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int i, j, k, n, m, l;
	vi d, e;
	bool carry;

	rep(i, 10) {
		d.push_back(i);
	}

	cin >> n >> k;

	rep(i, k) {
		cin >> j;
		d[j] = -1;
	}
	rep(i, 10) {
		if (d[i] >= 0)
			e.push_back(d[i]);
	}
	d.clear();
	d = e;
	e.clear();

	m = d.size();
	i = n;
	while (i > 0) {
		e.push_back(0);
		i /= 10;
	}

	i = e.size();
	while (1) {
		j = 0;
		rep(l,i) {
			j = j * 10 + d[e[l]];
		}
		if (j >= n)
			break;
		carry = true;
		l = 0;
		while (carry) {
			carry = false;
			e[l]++;
			if (e[l] >= m) {
				carry = true;
				e[l] = 0;
				l++;
			}
			if (l >= i) {
				e.push_back(0);
				i++;
				carry=false;
			}
		}
	}

	cout << j;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    string s,t;cin>>s>>t;
    int n = s.size();
    int flag=1;
    for(int i=0;i<n;i++){
        if(s[i]!= t[i]){
            flag = 0;
            break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int[] input = new int[n];
		
		String[] tmpArray = br.readLine().split(" ");
		
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		int[] inputClone = Arrays.copyOf(input, n);
		
		Arrays.sort(inputClone);
		
		int med = n/2;
		
		for(int i = 0; i < n; i++){
			if(input[i] < inputClone[med]){
				System.out.println(inputClone[med]);
			}
			else {
				System.out.println(inputClone[med - 1]);
			}
		}
	}

}

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

int main() {
    ll x,k,d;cin>>x>>k>>d;
    x = abs(x);
    ll ans;
    
    if(k*d > x || k*d < 0){
        ll tmp = x%d;
        ll tmp2 = (x-tmp)/d;
        k-=tmp2;
        k%=2;
        tmp-=k*d;
        ans = abs(tmp);
    }
    else{
        ans = x-k*d;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
fun main(args: Array<String>) {
	readLine()
	val list = readLine()!!.split(" ").map(String::toInt)
	
	var num : Int
	var count : Int
	
	var result : Int = 0
	
	for (i in 0..list.size - 1) {
		num = list[i]
		count = 0
		if ( num%2 != 1) {
			do {
				num = num / 2
				count = count + 1
	        } while (num%2 != 1)
			
			if (i == 0) {
				result = count
			}
			
			if (result > count) {
				result = count
			}
			
		} else {
			result = 0
			return println("${result}")
		}
	}
	
	println("${result}")
	
}

Measured memory_bytes: 36156
A, B = map(int, input().split())
S = input()
D = ["0","1","2","3","4","5","6","7","8","9"]

for k in range(A):
    if S[k] not in D:
        print("No")
        exit(0)

if S[A] != "-":
        print("No")
        exit(0)    

for k in range(A+1,A+B+1):
    if S[k] not in D:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int solve(){
	int T,D,L;
	cin >> T >> D >> L;
	if(T+D+L==0)return 1;
	vector<int> x(T);
	vector<int> rui(200100);
	for(int i=0;i<T;i++){
		cin >> x[i];
		if(x[i]>=L){
			rui[i]++;
			rui[i+D]--;
		}
	}
	for(int i=1;i<200100;i++)rui[i]+=rui[i-1];
	//for(int i=0;i<=T;i++)cout << i << ':' << rui[i] << endl;
	int ans = 0;
	for(int i=0;i<T-1;i++)if(rui[i])ans++;
	cout << ans << endl;
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(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(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
template <class T = int> T in(){T x; cin >> x; return (x);}

int main() {
    int result = 0;
    int N;
    int M;
    int C;
    cin >> N;
    cin >> M;
    cin >> C;
    int B[M];
    int A[N][M];
    rep(i, M){
        cin >> B[i];
    }
    rep(i, N){
        rep(j, M){
            cin >> A[i][j];
        }
    }
    rep(i, N){
        int x = C;
        rep(j, M){
            x += B[j]*A[i][j];
        }
        if(x > 0){
            result ++;
        }
    }
    
    cout << result << endl;
    
    return 0;
}


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

#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;

const int mod = 1000000007;
const int max_n = 100011;

ld check(int n, int x[], int y[], char c[], ld t) {
  ld max1 = -mod, max2 = -mod, min1 = mod, min2 = mod;
  for (int i = 0; i < n; ++i) {
    if (c[i] == 'R') {
      max1 = max(max1, x[i] + t);
      min1 = min(min1, x[i] + t);
    }
    if (c[i] == 'L') {
      max1 = max(max1, x[i] - t);
      min1 = min(min1, x[i] - t);
    }
    if (c[i] == 'R' || c[i] == 'L') {
      max2 = max(max2, (ld)y[i]);
      min2 = min(min2, (ld)y[i]);
    }
    if (c[i] == 'U' || c[i] == 'D') {
      max1 = max(max1, (ld)x[i]);
      min1 = min(min1, (ld)x[i]);
    }
    if (c[i] == 'U') {
      max2 = max(max2, y[i] + t);
      min2 = min(min2, y[i] + t);
    }
    if (c[i] == 'D') {
      max2 = max(max2, y[i] - t);
      min2 = min(min2, y[i] - t);
    }
  }
  //cout << "check " << t << " = " << (max1 - min1) * (max2 - min2) << "   " << min1 << " " << max1 << " " << min2 << " " << max2 << endl;
  return (max1 - min1) * (max2 - min2);
}

int main() {
  int n, x[max_n], y[max_n];
  char c[max_n];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%*c%c", &x[i], &y[i], &c[i]);
    //cout << x[i] << " " << y [i] << " " << c[i] << endl;
  }
  ld l = 0, r = 1000000000;
  for (int i = 0; i < 400; ++i) {
    //cout << l << " " << r << endl;
    ld mid1 = (2 * l + r) / 3;
    ld mid2 = (l + 2 * r) / 3;
    if (check(n, x, y, c, mid1) < check(n, x, y, c, mid2)) {
      r = mid2;
    } else {
      l = mid1;
    }
  }
  printf("%.14f", double(check(n, x, y, c, l)));
}


Measured memory_bytes: 1152
n = gets.to_i
xys = []
xys << [0, 0]
n.times do
  xys << gets.split.map(&:to_i)
end
xys.sort_by! { |x| x }

h = Hash.new(0)
(0..n-1).each do |i|
  x1, y1 = xys[i]
  ((i+1)..n).each do |j|
    x2, y2 = xys[j]
    h["#{x2-x1} #{y2-y1}"] += 1
  end
end
h[xys[1].join(" ")] -= 1

ans = n - h.max_by { |k,v| v }[1]
if h.size == 1
  ans += 1
end
if n == 1
  puts 1
else
  puts ans
end

Measured memory_bytes: 1916
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();

            int xDiff = x2 - x1;
            int yDiff = y2 - y1;

            int xDiff2 = -yDiff;
            int yDiff2 = xDiff;

            int x3 = x2 + xDiff2;
            int y3 = y2 + yDiff2;

            int xDiff3 = -yDiff2;
            int yDiff3 = xDiff2;

            int x4 = x3 + xDiff3;
            int y4 = y3 + yDiff3;

            out.println(x3 + " " + y3 + " " + x4 + " " + y4);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i); 
    }

    sort(p.begin(), p.end());

    int sum = 0;

    for(int i = 0; i < k; i++){
        sum += p.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def search(x,col_befedge):
    #print("top", x, count)
    global col

    k=1
    for n in adj[x]:
        
        e=tuple(sorted((n,x)))
        #print(e,k,col_befedge)
        if col[e]>0:
            continue
        if k==col_befedge:
            k+=1
        #if k==col_pa:
        #    k+=1
        
        col[e]=k
        search(n,k)
        k+=1
    
            
        

N=int(input())

adj=[[] for i in range(N+1)]

edges=[]
col={}
for i in range(N-1):
    tmp=acinput()
    adj[tmp[0]].append(tmp[1])
    
    adj[tmp[1]].append(tmp[0])
    col[tuple(sorted(tmp))]=0
    edges.append(tuple(sorted(tmp)))

    
#col=[-1]*(N+1)

#col[1]=1
#print(adj)

search(1,0)
#print(reduce(lambda a,b:max(a,b),col.keys))
#print(col)
print(max(col.values()))
#print(col[max(col)])
for se in edges:
    print(col[se])


Measured memory_bytes: 91232
/**
 * Created by karayuu on 2018/05/22
 */
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() }

    /* #roundToInt()で四捨五入->平均を出す。平均にそろえるのが最もコストが少ない...と思う */
    val average = Math.round(list.average()).toInt()

    val cost = list.sumBy { (it - average).squared() }

    print(cost)
}

fun Int.squared() : Int = this * this

/* kotlin 1.0.0 は#roundToInt()がないので作るしかない... -> Mathクラスを使うのが楽。*/
/*
fun Double.roundToInt() : Int {
    return if (this < 1.5) {
        this.toInt()
    } else {
        this.toInt() + 1
    }
}
*/

Measured memory_bytes: 37840
def pr(f)
  printf "%f\n",f
end
  a,b,c=$stdin.gets.split.map(&:to_f)
  rad=c*Math::PI/180
  pr (1/2.0)*a*b * Math.sin(rad)
  pr a+b + Math.sqrt( a**2+b**2 - 2*a*b * Math.cos(rad) )
  pr b * Math.sin(rad)


Measured memory_bytes: 6964
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const int INF = 1001001001;

int main() {
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<int>> dist(N,vector<int>(N,INF));
    for (int i=0;i<N;i++) dist[i][i] = 0;
    for (int i=0;i<M;i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        dist[A][B] = dist[B][A] = C;
    }
    for (int k=0;k<N;k++){
        for (int i=0;i<N;i++){
            for (int j=0;j<N;j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector<vector<int>> dist2(N,vector<int>(N,INF));
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            if (dist[i][j] <= L) dist2[i][j] = 1;
        }
    }
    for (int k=0;k<N;k++){
        for (int i=0;i<N;i++){
            for (int j=0;j<N;j++){
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    for (int q=0;q<Q;q++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        int ans = dist2[s][t] - 1;
        if (dist2[s][t] == INF) ans = -1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var n int
	var h []int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		h = append(h, tmp)
	}

	sum := h[0]
	max := h[0]
	for i := 0; i < n-1; i++ {
		if h[i+1] > max {
			sum += h[i+1] - max
			max = h[i+1]
		} else {
			max = h[i+1]
		}
	}
	fmt.Println(sum)
}


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

int main(void){
    string str;
    cin >> str;
    int n = str.size();
    int s[MAX];
    for(int i=0;i<n;i++) s[i] = str[i]-'0';
    //なぜ2^n-1回ループ回すか考える。
    //おそらくプラス入れるか入れないかが関係してる
    ll ans = 0;
    for(int i=0;i<(1<<(n-1));i++){
        int cnt = 0;
        ans += s[n-1];
        //ループ回数は桁数に等しい
        for(int j=n-2;j>=0;j--){
            if(i & (1<<j))
                cnt++;
            else 
                cnt = 0;
            ans += s[j]*pow(10,cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	int[][] field;
	boolean[][] visited;
	
	// (x,y)に爆弾があれば爆破する
	void Bomb(int x, int y){
		if(x<0||y<0||x>=8||y>=8||field[x][y]==0){
			return;
		}
		field[x][y] = 0;
		Bomb(x+1,y);
		Bomb(x+2,y);
		Bomb(x+3,y);
		Bomb(x-1,y);
		Bomb(x-2,y);
		Bomb(x-3,y);
		Bomb(x,y+1);
		Bomb(x,y+2);
		Bomb(x,y+3);
		Bomb(x,y-1);
		Bomb(x,y-2);
		Bomb(x,y-3);
	}
	
	void run(){
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		stdIn.nextLine();
		for(int i=0;i<n;i++){
			stdIn.nextLine();
			field = new int[8][8];
			visited = new boolean[8][8];
			for(int j=0;j<8;j++){
				char[] tmp = stdIn.nextLine().toCharArray();
				for(int k=0;k<8;k++){
					if(tmp[k]=='1'){
						field[j][k] = 1;
					}
				}
			}
			int y = Integer.parseInt(stdIn.nextLine());
			int x = Integer.parseInt(stdIn.nextLine());
			Bomb(--x,--y);
			System.out.println("Data "+(i+1)+":");
			for(int j=0;j<8;j++){
				for(int k=0;k<8;k++){
					System.out.print(field[j][k]);
				}
				System.out.println();
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
    int N;
    long long D, x, y;
    int count = 0;
    cin >> N >> D;
    for(int i= 0; i < N; i++){
        cin >> x >> y;
        if (x*x + y*y <= D*D) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3600
from collections import deque

N = int(input())
xs = list(map(int, input().split()))


res = 10**100

avg = sum(xs)//N
mod = sum(xs)%N

for d in range(avg, avg+mod+1):
  r = 0
  for x in xs:
    r += (x-d) ** 2
  res = min(res, r)

print(res)

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k==0) return 1;
	if(n< k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

int main(){
	int k;
	string s; cin>>k>>s;
	int n=s.length();

	mint ans=pow(mint(26),n+k);
	rep(i,n) ans-=choose(n+k,i)*pow(mint(25),n+k-i);
	cout<<ans<<'\n';

	return 0;
}

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

# a = A_1, b = A_2, x = A_3 ^ ... ^ A_N, s = a + b とする
a, b = A[0], A[1]
x = 0
for i in range(2, N):
    x ^= A[i]
s = a + b

M = 42
# dp[桁][繰り上げフラグ][これまでの桁でAより大きいフラグ] := Aとなり得る値の最大値
dp = [[[-1] * 2 for _ in range(2)] for _ in range(M + 1)]
dp[0][0][0] = 0
v = 1
for i in range(M):
    cs = s & 1
    cx = x & 1
    ca = a & 1
    for j in range(2):
        for k in range(2):
            if dp[i][j][k] == -1:
                continue
            for na in range(2):
                for nb in range(2):
                    # 条件1: na ^ nb = x
                    if na ^ nb != cx:
                        continue
                    # 条件2: na + nb = S
                    ns = na + nb + j
                    if ns & 1 != cs:
                        continue
                    
                    # 遷移先のi, j, kを求める
                    ni = i + 1
                    nj = 1 if ns >= 2 else 0
                    if na > ca:
                        nk = 1
                    elif na < ca:
                        nk = 0
                    else:
                        nk = k
                    
                    # 遷移先を最大化
                    dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] + na * v)
    s >>= 1
    x >>= 1
    a >>= 1
    v <<= 1

amax = dp[M][0][0]
if amax <= 0:
    print(-1)
else:
    print(A[0] - amax)


Measured memory_bytes: 9096
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int x=0 ,y=0;
      int sum = 0;
      try {
         Scanner scanner = new Scanner(System.in);
         x = scanner.nextInt();
         y = scanner.nextInt();
         scanner.close();
      } catch (InputMismatchException e) {
         System.out.println("error");
      }
      sum = x-y+1;
      System.out.println(sum);
   }
}


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

const int INF = 1001001001;
const int NV=100100;
const int Nx=100000;

int main() {
  int x,y,r=1;
  cin>>x;
  if(x==2){
    cout<<2<<endl;
    return 0;
  }
  else{
    y=x/2;
    y=y*2-1;
    while(r*r<x){
      r++; 
    }
    r--;
    bool p=true;
    while(p){
      y+=2;
      p=false;
      for(int i=2;i<r;i++){
        if(y%i==0){
          p=true;
        }
      }
    }
    cout<<y<<endl;
  }
}

Measured memory_bytes: 256
//Author- Vaibhav Singh


#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}

       int main()
       {
    fast
    
    precompute();
    ll n,k;
    cin>>n>>k;
    ll a[n],i;
    f(i,n)
    {
        cin>>a[i];
    }
  sort(a,a+n);
  ll mx=0,mn=0,ans=0;
  f(i,n)
  {
      mn=(mn+mod+((ncr(n-i-1,k-1)*a[i])%mod)%mod)%mod;
            mx=(mx+mod+((ncr(i,k-1)*a[i])%mod)%mod)%mod;

  }
  
  ans+=(mx-mn+mod)%mod;
  o(ans)
  

re}

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

int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(10);
    int N;
    long double temp1;
    cin >> N;
    vector<long double> p, q;
    for(int i=0;i<N;i++){
        cin >> temp1;
        p.push_back(temp1);
        q.push_back(1-temp1);
    }
    vector<vector<long double> > dp(N, vector<long double> (N+2, 0.0));
    dp[0][1] = q[0];
    dp[0][2] = p[0];
    for(int i = 1; i< N;i++){
        for(int j=1;j<N+2;j++){
            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * q[i];
        }
    }

    auto it1 = dp[N-1].begin() + (N+3)/2;
    cout << accumulate(it1, dp[N-1].end(), 0.0) << endl;

    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    double avg = sum / N;
    
    double mi = 1e9;
    int mi_i = 0;
    for (int i = 0; i < N; i++) {
        if (mi > abs(A[i] - avg)) {
            mi = abs(A[i] - avg);
            mi_i = i;
        }
    }
    cout << mi_i << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> v(1e5+1, 0);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    v[a] += b;
  }
  ll sum = 0;
  int ans;
  rep(i, 1e5+1) {
    sum += v[i];
    if(sum >= K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{

    int a;
    cin >> a;

    cout << a + a * a + a * a * a << '\n';
    return 0;
}


Measured memory_bytes: 3592
S = input()
T = input()

s_l = len(S)
t_l = len(T)

m =100*100
# SとTの長さの差分を取得しSをずらしながら繰り返しを実施
for i in range(s_l - t_l + 1):
  U = S[i:i + t_l]
  c = 0
  for j in range(t_l):
    if (U[j] != T[j]):
      c += 1
  m = min(c, m)

print(m)

Measured memory_bytes: 9056
# -*- coding: utf-8 -*-
s = input()

res1 = 0
res2 = 0
f1 = "0"
f2 = "1"
for c in s:
    if f1!=c:
        res1 += 1
    if f2!=c:
        res2 += 1

    if f1=="0":
        f1 = "1"
    else:
        f1 = "0"
    if f2=="0":
        f2 = "1"
    else:
        f2 = "0"

print(min(res1,res2))


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

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    int ans = (a + b) * h / 2;
    cout << ans << endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a > 0) {
        cout << "Positive" << endl;
    } else if (a == 0) {
        cout << "Zero" << endl;
    } else {
        if (b >= 0) {
            cout << "Zero" << endl;
        } else {
            if (((b - a) + 1) % 2) {
                cout << "Negative" << endl;
            } else {
                cout << "Positive" << endl;
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
n = input() + 1
for val in range(1,n):
	x = map(float,raw_input().split(' '))
	if x[1]-x[3] == 0 and x[5]-x[7] == 0:
			print 'YES'
	elif x[1]-x[3] != 0 and x[5]-x[7] == 0:
			print 'NO'
	elif x[1]-x[3] == 0 and x[5]-x[7] != 0:
			print 'NO'
	else:
		if (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]):
			print 'YES'
		else:
			print 'NO'

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




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

	if (n==25)cout << "Christmas" << endl;
	else if(n==24) cout << "Christmas Eve" << endl;
	else if (n == 23)cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
	return 0;

}




Measured memory_bytes: 256
from itertools import  product
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
for i in range(1,m+1):
    count=0
    for j in range(n):
        count+=ca[j][i]
    if count<x:
        print(-1)
        exit()

ans=10**9



for z in product((0, 1), repeat=n):#bit全探索のくみあわせを勝手に作ってくれるので使うとよい
    count=0
    count2=[0]*m
    for i in range(n):
        if z[i]==1:
            count+=ca[i][0]
            for j in range(1,m+1):
                count2[j-1]+=ca[i][j]
    
    for i in range(m):
        if count2[i]<x:
            break
    else:
        ans=min(count,ans)
print(ans)
          

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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  for (int &x : a) cin >> x;
  sort(a.begin(), a.end());
  set <int> q;
  for (int x : a) q.insert(x);
  if (q.size() > 3) {
    cout << "No\n";
    return 0;
  } else {
    for (int x : q) {
      for (int y : q) {
        vector <int> b = {x, y};
        while (b.size() < n) {
          b.push_back(b[(int) b.size() - 2] ^ b[(int) b.size() - 1]);
        }
        sort(b.begin(), b.end());
        if (a == b) {
          cout << "Yes\n";
          return 0;
        }
      }
    }
    cout << "No\n";
  }
}


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

vector<int> z_algorithm(const string& S){
    int N = S.size(), c = 0;
    vector<int> ret(N, 0);
    for(int i=1; i<N; i++){
        if(i + ret[i-c] < c + ret[c]){
            ret[i] = ret[i-c];
        }else{
            int j = max(0, c + ret[c] - i);
            while(i+j < N && S[j] == S[i+j]) j++;
            ret[i] = j;
            c = i;
        }
    }
    ret[0] = N;
    return ret;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();

    vector<int> len[2];
    len[0] = z_algorithm(S);
    reverse(S.begin(), S.end());
    len[1] = z_algorithm(S);
    bitset<500001> bad[2];

    int min_period = N;
    for(int k=0; k<2; k++){
        for(int period=1; period<=N; period++){
            for(int s=0; s<N; s+=period){
                if(len[k][s] >= period){
                    if(s > 0) bad[k][s+period] = 1;
                }else{
                    break;
                }
            }
            if(bad[k][N]) min_period = min(min_period, period);
        }
    }

    int opt = 0, num = 0;
    if(min_period == N){
        opt = 1;
        num = 1;
    }else if(min_period == 1){
        opt = N;
        num = 1;
    }else{
        opt = 2;
        for(int i=1; i<N; i++) if(!bad[0][i] && !bad[1][N-i]) num++;
        //else cerr << "NG: " << i << endl;
    }
    cout << opt << endl << num << endl;
    return 0;
}

Measured memory_bytes: 4868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);


int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;

    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int[] idxDiff = new int[n];
        for (int i=0; i<n; i++) idxDiff[i] = arr[i] - i;

        Map<Long, Long> map = new HashMap<>();

        long ans = 0;

        outer:
        for (int i=n-1; 0<=i; i--) {
            long base = (long)(idxDiff[i]);
//            System.out.println(base);
            long wantDiff = (long)(i + arr[i]) * (-1);
            if (map.containsKey(wantDiff)) {
                ans += map.get(wantDiff);
                if (map.containsKey(base)) {
                    long adds = map.get(base);
                    map.put(base, adds + 1L);
                } else {
                    map.put(base, 1L);
                }
            } else {
                if (map.containsKey(base)) {
                    long adds = map.get(base);
                    map.put(base, adds + 1L);
                } else {
                    map.put(base, 1L);
                }
            }
        }

        System.out.print(ans);
//        System.out.print(map);
//        for (int i=0; i<n; i++) System.out.println(idxDiff[i]);
//        System.out.print(map.size());

//        System.out.print(idxDiff[3]);


    }
}


Measured memory_bytes: 68788
from math import sqrt
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        dist = 0
        for k in range(D):
            dist += (X[i][k] - X[j][k])**2
        if sqrt(dist).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)

#define all(c) (c).begin(), (c).end()

typedef long long tint;
typedef pair<tint,tint> ptint;

const tint MOD = 1000000007;
const int MAXN = 210000;


int correspondingNode[MAXN];
vector<int> origTree[MAXN], dpTree[MAXN];
int height[MAXN];

int currentHeight;

const int NO_NODE = -1;

#define isLeaf(node) (height[node] == currentHeight)



// .first  = NO PROPAGAR
// .second = SI PROPAGAR
ptint calcDp(int node)
{
    if (isLeaf(node))
        return {1,1};
    vector<ptint> children(dpTree[node].size());
    forn(i, dpTree[node].size())
        children[i] = calcDp(dpTree[node][i]);
    vector<tint> suffixes(children.size());
    tint aux = 1;
    dforn(i,children.size())
    {
        suffixes[i] = aux;
        aux = (aux * children[i].first) % MOD;
    }
    tint total = 1, yes = 0;
    aux = 1;
    forn(i, children.size())
    {
        total *= children[i].first + children[i].second;
        total %= MOD;
        yes += (((aux * suffixes[i]) % MOD) * children[i].second) % MOD;
        yes %= MOD;
        aux = (aux * children[i].first) % MOD;
    }
    return {((total - yes) % MOD + MOD) % MOD, yes};
}

int cleanTree(int node)
{
    if (isLeaf(node))
    {
        assert(dpTree[node].empty());
        return node;
    }
    vector<int> cleanChildren;
    for (int x : dpTree[node])
    {
        int newChild = cleanTree(x);
        if (newChild != NO_NODE)
            cleanChildren.push_back(newChild);
    }
    if (cleanChildren.empty())
        return NO_NODE;
    else if (cleanChildren.size() == 1)
        return cleanChildren.back();
    else
    {
        cleanChildren.swap(dpTree[node]);
        return node;
    }
}

tint pot2[MAXN];
tint parent[MAXN];

int main()
{
    pot2[0] = 1;
    forn(i,MAXN-1)
        pot2[i+1] = (pot2[i] * 2)%MOD;
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N; cin >> N;
    forn(i,N)
    {
        cin >> parent[i+1];
        origTree[parent[i+1]].push_back(i+1);
    }
    vector<int> leaves = {0};
    height[0] = 0;
    int dpRoot = 0;
    correspondingNode[0] = 0;
    tint ret = 0;
    currentHeight = 0;
    vector<int> newLeaves;
    while (!leaves.empty())
    {
        assert(int(leaves.size()) <= N);
        tint value = (calcDp(dpRoot).second * pot2[N+1 - leaves.size()]) % MOD;
        ret = (ret + value) % MOD;
        newLeaves.clear();
        for (int x : leaves)
            newLeaves.insert(newLeaves.end(), all(origTree[x]));
        newLeaves.swap(leaves);
        currentHeight++;
        for (int x : leaves)
        {
            height[x] = currentHeight;
            dpTree[parent[x]].push_back(x);
        }
        dpRoot = cleanTree(dpRoot);
        assert((dpRoot == NO_NODE) == (leaves.empty()));
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 27008
'''
ITP-1_3-D
 ?´???°?????°
???????????´??° aa???bb???cc ??????????????????aa ?????? bb ?????§?????´??°????????????cc ????´???°?????????????????????????±???????
????????°????????????????????????????????????
???Input
aa ???bb???cc ?????????????????????????????§??????????????????????????????
???Output
?´???°?????°???????????????????????????????????????
'''
# import
import sys

# ?´???°????????????
cnt = 0

# ?????°??????????????????
aa, bb, cc = map(int,input().split())

# input???????????????
for dd in range(aa, bb+1):
    if cc%dd == 0:
        # ?´???°?????????????????????
        cnt += 1

print( cnt )

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a,b;
int main(){
	cin>>a>>b;
	rep(i,100){
		if(1+(a-1)*i >= b){ cout<<i<<endl; return 0; }
	}
}

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

ll dp[10005][100][2];

int main(){
    string k;
    int d;
    cin >> k >> d;

    dp[0][0][0] = 1;

    rep(i, k.size()){
        rep(j, d)rep(m, 2){
            rep(num, 10){
                int ni=i+1, nj = (j+num)%d, nm = m;
                int ki = k[i]-'0';
                if(m==0){
                    if(ki < num) continue;
                    if(ki > num) nm = 1;
                }

                dp[ni][nj][nm] += dp[i][j][m];
                dp[ni][nj][nm] %= MOD;
            }
        }
    }


    cout << (dp[k.size()][0][0] + dp[k.size()][0][1] -1 + MOD )%MOD << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if((x + r <= W) && (y + r <= H) && (x > 0) && (y > 0)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580