akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

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

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int in(){
	int t;
	cin >> t;
	return t;
}

int main()
{
	int n,m;
	while(cin >> n >> m,(n&&m)){
        int d[2][100][100];
        for(int i=0;i<2;i++){
            for(int j=0;j<100;j++){
                for(int k=0;k<100;k++){
                	if(j==k){
                        d[i][j][k]=0;
                	}else{
                		d[i][j][k]=inf;
                	}
                }
            }
        }
        for(int i=0;i<n;i++){
            int a,b,cost,time;
            cin >> a >> b >> cost >> time;
            a--;
            b--;
            d[0][a][b]=cost;
            d[0][b][a]=cost;
            d[1][a][b]=time;
            d[1][b][a]=time;
        }
        for(int i=0;i<m;i++){
            for(int j=0;j<m;j++){
                for(int k=0;k<m;k++){
                    for(int o=0;o<2;o++){
                        d[o][j][k] = min(d[o][j][k],d[o][i][j]+d[o][i][k]);
                    }
                }
            }
        }
        int k;
        cin >> k;
        for(int i=0;i<k;i++){
            int p,q,r;
            cin >> p >> q >> r;
            p--;q--;
            cout << d[r][p][q] << endl;
        }
	}
	return 0;
}

Measured memory_bytes: 1236
n = int(input())
H = list(map(int, input().split())) + [0]
c = 0
while True:
  flag = True
  for i in range(n):
    if H[i] > 0:
      flag = False
      H[i] -= 1
      if H[i+1] == 0:
        c += 1
  if flag:
    break
print(c)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 20000000000000
#define PI 3.14159265359
#define ull unsigned long long

int main(){
    char t[200002]={};
    int num=0;
    scanf("%s",t);
    while (t[num]!='\0'){
        if (t[num]=='?') t[num]='D';
        num++;
    }
    printf("%s",t);
    return 0;
}



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

int main() {
  int N,D,count = 0;
  double dist;
  cin >> N >> D;
  vector<double> x(N),y(N);
  rep(i,N) cin >> x[i] >> y[i];
  rep(i,N) {
    if(x[i] > D || y[i] > D) continue;
    dist = sqrt(x[i] * x[i] + y[i] * y[i]);
    if(dist <= D) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 6492
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;

void ARC060C()
{
	int N, A;
	cin >> N >> A;
	vector<int> vals(N);
	for (auto& x : vals)
	{
		cin >> x;
	}

	vector<vector<vector<long long> > > dp(N + 1, vector<vector<long long> >(N + 1, vector<long long>(2501)));
	dp[1][1][vals.front()] = 1;
	for (int i = 1; i < N; ++i)
	{
		dp[i][0][0] = 1;
		for (int j = 1; j <= i + 1; ++j)
		{
			for (int k = 1; k <= 2500; ++k)
			{
				int res = k - vals[i];
				dp[i + 1][j][k] = dp[i][j][k];
				if(res >= 0 && res < 2501)
					dp[i+1][j][k] += dp[i][j - 1][res];
			}
		}

	}
	long long sum = 0;
	for (int i = 1; i <= N; ++i)
	{
		sum += dp[N][i][A*i];
	}
	cout << sum << endl;
}
int main()
{
	ARC060C();
	return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <string>
#include <numeric>
 
using namespace std;
long long gcd(long long m, long long n){
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}
long long lcm(long long m, long long n){
	return ((m / gcd(m, n)) * n);
}

int main(void) {
    long long n;
    long long m;
    cin >> n >> m;
    string s, t;
    cin >> s;
    cin >> t;
    long long l;
    l = lcm(n, m);
    long long c;
    c = gcd(n, m);
    int flag = 0;
    for(int i = 0; i < c; i++){
        long long sx = i * (n / c);
        long long tx = i * (m / c);
        if(s[sx] != t[tx]){
            flag++;
            break;
        }
    }
    if(flag == 0){
        cout << l << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int area = 0;
            int d = sc.nextInt();
            for(int i=0 ; i<600 ;i+=d)
                area += i*i*d;
            System.out.println(area);
        }
    }
}

Measured memory_bytes: 25880
import java.awt.Robot;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    Set<Integer> set = new HashSet<>();
    public void solve() {
    	int N = ni();
    	int a;
    	for (int i = 0; i < N; i++) {
			a = ni();
			set.add(a);
		}
    	if(set.size() == N)		out.println("YES");
    	else					out.println("NO");
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 101140
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int m,r=0,s=0;
  cin>>m;
  for(int i=0;i<m;++i){
    int d,c;
    cin>>d>>c;
    s+=d*c;
    r+=c;
  }
  cout<<r-1+(s-1)/9;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints
S = gets.chomp

sx = S.split('')

count = 0
sx.each_cons(2) do |a, b|
  count += 1 if a == b
end

count += 2 * K

if count > N - 1
  puts N - 1
else
  puts count
end


Measured memory_bytes: 19408
#include <iostream>                                        
using namespace std;                                       
                                                           
int main(){                                                
  int a,b,c;                                               
  int counter=0;                                           
  int i;                                                   
                                                           
  cin >> a >> b >> c;                                      
                                                           
  for(i=a;i<=b;i++){                                       
    if(c%i==0)                                             
      counter++;                                           
  }                                                        
                                                           
  cout << counter << endl;                                 
                                                           
  return 0;                                                
                                                           
} 

Measured memory_bytes: 3104
a = {1, 3, 5, 7, 8, 10, 12}
b = {4, 6, 9, 11}
c = {2}
x, y = map(int, input().split())
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
	public static int gcd(int m, int n) {
		if(n ==0){
			return m;
		}else{
			return gcd(n,m%n);
		}
	}
	public static long lcm(int m, int n){
		return (m / gcd(m, n)) * n; 
	}
    public static void main(String[] a){
    	
    	Scanner scan = new Scanner(System.in);
    	while (scan.hasNext()){ 
    	int n = 0;
    	int m = 0;
    	m = scan.nextInt();
    	n = scan.nextInt();
    	System.out.print(gcd(m,n) + " ");
    	System.out.println(lcm(m,n));
    	
    	}
 }
}

Measured memory_bytes: 26052
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 0) {
            System.out.println(n / 2);
        } else {
            System.out.println((n / 2) + 1);
        }
    }
}


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

vector<long long>F1;
vector<long long>F2;

long long n,m;
long long a[10000];
long long maxn;
long long l,r,M;

int main(){
	while(true){
		maxn=0;
		cin>>n>>m;
		if(n==0 && m==0){break;}
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		F1.clear();
		F2.clear();
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				F1.push_back(a[i]+a[j]);
			}
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				F2.push_back(a[i]+a[j]);
			}
		}
		sort(F2.begin(),F2.end());
		for(int i=0;i<F1.size();i++){
			if(F1[i]<=m){
				l=0;r=F2.size();
				for(int j=0;j<21;j++){
					M=(l+r)/2;
					if(F1[i]+F2[M]>m){
						r=M;
					}
					else if(M==F1.size()-1){
						l=M;
					}
					else if(F1[i]+F2[M+1]<=m){
						l=M;
					}
				}
				if(F1[i]+F2[M]<=m){
				maxn=max(maxn,F1[i]+F2[M]);
				}
			}
		}
		cout<<maxn<<endl;
	}
	return 0;
}

Measured memory_bytes: 23008
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  map<lli,lli> P;
  rep(i,0,N){
    cin >> A;
    P[A]++;
  }
  flag=1;
  num=N-1;
  if(N%2==1&&P[0]!=1)flag=0;
  rep(i,0,N/2){
    if(P[num]!=2)flag=0;
    num-=2;
  }
  if(flag)Out(repow(2,N/2,mod));
  else Out(0);
}



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

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

    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin>>s[i];
    }

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

    string min;
    for(int i=0; i<n; i++){
        min+=s[i];
    }

    cout<<min<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    int e,y;
    scanf("%d %d",&e,&y);
    if(e==0){
        if(y<=1911&&1868<=y){
            printf("M%d\n",y-1868+1);
        }
        if(y<=1925&&1912<=y){
            printf("T%d\n",y-1912+1);
        }
        if(y<=1988&&1926<=y){
            printf("S%d\n",y-1926+1);
        }
        if(y<=2016&&1989<=y){
            printf("H%d\n",y-1989+1);
        }
    }
        
    else if(e==1){
        printf("%d\n",1867+y);
    }

        
    else if(e==2){
        printf("%d\n",1911+y);
    }
        
    else if(e==3){
         printf("%d\n",1925+y);
    }
        
    else if(e==4){
        printf("%d\n",1988+y);
    }


    
    
    
    
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n ,m;
    cin >> n >> m;
    vector<int> v(m,0);
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int l;
            cin >> l;
            v[l-1]++;
        }
    }
    int ans = 0;
    for(int i=0;i<m;i++) if(v[i] == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  string s;
  cin >> s;

  int ans = 0;
  rrep(i,n-1) {
    string sl = s.substr(0,i);
    string sr = s.substr(i);
    int cnt = 0;
    rep(c,26) {
      if (sl.find(c+'a')!=string::npos && sr.find(c+'a')!=string::npos) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy

# 約数を全列挙する関数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors

N0 = int(input())
ans = 0

# N = K^a (bK + 1) と表現できるので K は N or N-1 の約数であることが必要
K_cand = set(make_divisors(N0) + make_divisors(N0-1))

for K in K_cand:
    N = deepcopy(N0)
    if K == 1:  # K = 1 を除外
        continue
    else:
        while N%K == 0:
            N = N // K  # 割れるだけ割る
        N = N%K  # 引けるだけ引く
        if N == 1:
            ans += 1

print(ans)


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N; cin >> N;
  VV abc(N, V(3));
  rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  VV dp(N+1, V(3));
  rep(i, N) {
    chmax(dp[i+1][0], dp[i][1] + abc[i][0]);
    chmax(dp[i+1][0], dp[i][2] + abc[i][0]);
    chmax(dp[i+1][1], dp[i][2] + abc[i][1]);
    chmax(dp[i+1][1], dp[i][0] + abc[i][1]);
    chmax(dp[i+1][2], dp[i][0] + abc[i][2]);
    chmax(dp[i+1][2], dp[i][1] + abc[i][2]);
  }

  int ans = max({dp[N][0], dp[N][1], dp[N][2]});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

inline int key(int u, int v) {
	return (min(u, v) << 8) | (max(u, v));
}

inline pair<int, int> decomp(int key) {
	return make_pair((key >> 8) & 0xff, key & 0xff);
}

int main(void) {
	int N, K;

	set<int> de;
	set<int> edges;

	cin >> N >> K;
	for (int i = 1; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			de.insert(key(i, j));
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			edges.insert(key(i, j));
		}
	}

	int pair = 0;
	while (de.size() > 0) {
		if (pair == K) break;
		auto head = *de.begin();
		de.erase(head);
		edges.erase(head);
		pair++;
	}

	if (pair == K) {
		cout << edges.size() << endl;
		for (auto e: edges) {
			auto p = decomp(e);
			cout << (p.first + 1) << " " << (p.second + 1) << endl;
		}
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    long long N;
    std::cin >> N;
    std::string result = "";
    while (N > 0) {
        N--;
        result += 'a' + N%26;
        N /= 26;
    }
    std::reverse(result.begin(), result.end());
    std::cout << result << std::endl;
}



Measured memory_bytes: 3632
//https://atcoder.jp/contests/abc136/tasks/abc136_f
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int n,m;
const int N=2e5+100;
struct node
{
	ll x,y;
	bool operator<(const node &a)const 
	{
		return x<a.x;
	}
}p[N];
const int mod=998244353;
int c[N],ld[N],rd[N],lu[N],ru[N];
ll f[N],y[N];
void add(int x)
{
	while(x<=n)
	{
		c[x]+=1;
		x+=x&-x;
	}
}
int query(int x)
{
	int res=0;
	while(x)
	{
		res+=c[x];
		x-=x&-x;
	}
	return res;
}
ll A(ll &x,ll b)
{
	x=(x+b)%mod; 
}
ll D(ll &x,ll b)
{
	x=(x-b+mod)%mod;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	f[0]=1; 
	for(int i=1;i<=n;i++) 
	{
		cin>>p[i].x>>p[i].y;
		y[i]=p[i].y;
		f[i]=(f[i-1]<<1)%mod; 
	}
	sort(p+1,p+1+n);
	sort(y+1,y+n+1);
	for(int i=1;i<=n;i++) p[i].y=lower_bound(y+1,y+1+n,p[i].y)-y;
	for(int i=1;i<=n;i++)
	{
		
		ld[i]=query(p[i].y);
		lu[i]=i-ld[i]-1;
		add(p[i].y);
	} 
	memset(c,0,sizeof c);
	for(int i=n;i>=1;i--)
	{
		rd[i]=query(p[i].y);
		ru[i]=n-i-rd[i];
		add(p[i].y);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		A(ans,f[n-1]);//选i点 
		A(ans,f[n-1]-1);//不选i点
		D(ans,f[lu[i]+ld[i]]);//减去左上左下不合法的
		D(ans,f[ru[i]+rd[i]]);//右上右下
		D(ans,f[ru[i]+lu[i]]);//左上右上
		D(ans,f[ld[i]+rd[i]]);//左下右下
		A(ans,f[lu[i]]);//把多减的加上 
		A(ans,f[ld[i]]);
		A(ans,f[ru[i]]);
		A(ans,f[rd[i]]); 
	}
	cout<<ans<<endl;
	return 0; 
} 

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

int main()
{
    int K, S;
    long long ans = 0;
    scanf("%d%d", &K, &S);
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            if (0 <= S - x - y && S - x - y <= K) ans++;
        }
    }
    printf("%lld\n", ans);
}

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

int doit(int n, int p) {
    std::vector<int> tokens(n);
    int current = p;
    int index = 0;

    while(true) {
        if (current == 1) {
            bool end = true;
            for (int i = 0; i < n; i++) {
                end = end && (index == i || !tokens[i]);
            }
            if (end) {
                return index;
            }
        }
        if (current != 0) {
            tokens[index]++;
            current--;
            index = (index + 1) % n;
        } else {
            current = tokens[index];
            tokens[index] = 0;
            index = (index + 1) % n;
        }
    }
}

int main() {
    int n, p;
    while (std::cin >> n >> p) {
        if (n == 0 && p == 0) {
            break;
        } else {
            std::cout << doit(n, p) << std::endl;
        }
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double h=x/(a*a);
    double deg;
    if(h<b/2){
        deg=180.0/PI*atan2(b,a*h/b*2);
    }else{
        deg=180.0/PI*atan2(a*(b-h)/a*2,a);
    }
    cout<<setprecision(10)<<deg<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 1e20;
int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<ll>x(N), y(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	ll minx, maxx, miny, maxy,ans=INF;
	rep(i, N) {
		minx = x[i];
		rep(j, N) {
			maxx = x[j];
			if (minx >= maxx)continue;
			rep(k, N) {
				miny = y[k];
				rep(l, N) {
					maxy = y[l];
					if (miny >= maxy)continue;
					int cnt = 0;
					rep(s, N) {
						if (x[s] >= minx&&x[s] <= maxx&&y[s] >= miny&&y[s] <= maxy)cnt++;
					}
					if (cnt >= K)ans = min(ans, (maxx - minx)*(maxy - miny));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int h, w;
vector<vector<char>> g;
int tmp=1e+7;

// void dfs(int x, int y, int cnt=0){
//     if(h<=x || w<=y || tmp<=cnt) return;
    
//     if(g[x][y]=='#') cnt += 1;
//     if(x+1==h && y+1==w) tmp = min(cnt, tmp);

//     dfs(x+1, y, cnt);
//     dfs(x, y+1, cnt);

// }


int main(){
    cin >> h >> w;
    g.resize(h, vector<char>(w));

    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)  cin >> g[i][j];

    vector<vector<ll>> dp(h, vector<ll>(w, 1e+15));
    
    int dx[2] = {0, 1}, dy[2]={1, 0};
    
    if(g[0][0]=='#') dp[0][0] = 1;
    else dp[0][0] = 0;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            for(int k=0; k<2; k++){
                int nx=i+dx[k], ny=j+dy[k], br=0;
                if(h<=nx || w<=ny) continue;
                if(g[i][j]=='.' && g[nx][ny]=='#') br = 1;
                dp[nx][ny] = min(dp[nx][ny], dp[i][j]+br);
            }
            //cout << dp[i+1][j+1] << endl;
        }
    }
    cout << dp[h-1][w-1] << endl;


}

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

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

	vector<string> a;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	
	cout << a.size() << endl;
}

Measured memory_bytes: 11604
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Long sum = 0L;
        for(int i=1;i<=n; i++){
            if(i%3!=0 && i%5!=0){
                sum += i;
            }
        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 39576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
string s;
int d;
int dp[10001][2][2][100];	//dp[keta][up-clear?][down-clear?][mod d]

signed main() {
	int i, j, k, l, m;
	
	cin >> s >> d;
	dp[0][0][0][0] = 1;
	
	rep(i, s.length()) {
		rep(j, 2) {
			rep(k, 2) {
				rep(l, d) {
					rep(m, 10) {
						if (j == 0 && m > s[i] - '0') continue;
						dp[i + 1][j || (m < (s[i] - '0'))][k || m != 0][(l + m) % d] += dp[i][j][k][l];
						dp[i + 1][j || (m < (s[i] - '0'))][k || m != 0][(l + m) % d] %= mod;
					}
				}
			}
		}
	}
	
	int ans = 0;
	rep(j, 2) ans += dp[s.length()][j][1][0];
	ans %= mod;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N; 
  for(int i =0; i < N; i++) {
    cin >> S;
    if(S == "Y") {
      cout << "Four" << endl;
      break;
    }
    
  }
    
    if(S != "Y") {
      cout << "Three" << endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

long long h,w,ans=0,black,white;
char temp;
int grid[404][404];
int visit[404][404];

void check(int i, int j, int iswhite){
    if(i<0 || h<=i || j<0 || w<=j);
    else if(visit[i][j]==1);
    else  if(grid[i][j]==iswhite){
        if(iswhite)white++;
        else black++;
        visit[i][j]=1;
        check(i,j+1,!iswhite);
        check(i+1,j,!iswhite);
        check(i,j-1,!iswhite);
        check(i-1,j,!iswhite);
    }
}
int main(void){
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> temp;
            if(temp=='#')grid[i][j]=0;
            else grid[i][j]=1;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            black=0;white=0;
            if(grid[i][j]==0){
                check(i,j,0);
            }
            ans+=black*white;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  vector<string> s(3); rep(i,3) cin >> s[i];
  string ans = "";

  rep(i,3)
    ans+=s[i][0];

  transform(ans.begin(),ans.end(),ans.begin(),::toupper);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int n,c[500],s[500],f[500];
int main(){
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=1;i<=n;i++){
        int t=0;
        for(int j=i;j<n;j++){
            if(t<s[j]) t=s[j];
            else if(t%f[j]) t+=(f[j]-(t%f[j]));
            t+=c[j];
        }
        cout<<t<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, x, y, ans = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> x >> y;
		ans += x - y;
		a[i] = x + y;
	}
	sort(all(a));
	rep(i, n)
		ans += ((n - i) % 2 * 2 - 1) * a[i];
	cout << ans / 2;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n;
  ll c;
  cin >> n >> c;
  vector<ll> x(n);
  vector<ll> v(n);
  REP(i,n) cin>>x[i]>>v[i];

  vector<ll> r(n),l(n);

  ll t = 0;
  REP(i,n){
    if(i==0){ 
      t += v[i] - x[i];
      r[i] = t;
    }else{
      t += v[i] - (x[i]-x[i-1]);
      r[i] = max(t,r[i-1]);
    }
  } 
  t = 0;
  for(int i=n-1;i>=0; i--){
    if(i==n-1){ 
      t += v[i] - (c-x[i]);
      l[i] = t;
    }else{
      t += v[i] - (x[i+1]-x[i]);
      l[i] = max(t,l[i+1]);
    }
  }


  ll ans=0;

  ans = max(r[n-1],ans);
  ans = max(l[0],ans);

  REP(i,n-1){
    ans = max(ans, r[i]+l[i+1]-x[i]);
  }
  FOR(i,1,n){
    ans = max(ans, l[i]+r[i-1]-(c-x[i]));
  }

  cout << ans << endl;
}



Measured memory_bytes: 3328
N = int(input())
total = 0
A = [None] * N
B = [None] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
	
for i in range(N-1,-1,-1):
	b = A[i] + total
	a = b % B[i]
	if a == 0:
		pass
	else:
		total = total + B[i] - a


print (total)
	


Measured memory_bytes: 10868
#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}

vector<pair<long long int,int> > v;
vector<pair<long long int, int> > vv;
vector<pair<long long int, long long int> > V;
bool cmp(pair<long long int, int> a, pair<long long int, int> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	return V[a.second].second > V[b.second].second;
}
bool cmp2(pair<long long int, int> a, pair<long long int, int> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	return V[a.second].first > V[b.second].first;
}
bool cmp3(pair<long long int, long long int> a, pair<long long int, long long int> b) {
	return a.first + a.second > b.first + b.second;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		v.push_back(make_pair(a, i));
		vv.push_back(make_pair(b, i));
		V.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end(), cmp);
	sort(vv.begin(), vv.end(), cmp2);
	sort(V.begin(), V.end(), cmp3);
	int i = 0;
	int j = V.size() - 1;
	bool f = false;
	long long int A = 0;
	long long int B = 0;
	while (i < V.size()) {
		if (f == false) {
			A += V[i].first;
			i++;
			f ^= true;
			continue;
		}
		B += V[i].second;
		i++;
		f ^= true;
	}
	printf("%lld\n", A - B);
	return 0;
}

Measured memory_bytes: 5204
<?php
while ($line = fgets(STDIN)) {
   $array[] = trim($line);
}
$array1 = explode(" ",$array[1]);
rsort($array1);
$alice = 0;
$tom = 0;
for($i = 1;$i<=$array[0];$i++){
 if($i%2!=0 or $i==0){
   $alice = $alice + $array1[$i-1];
 }else
   $tom = $tom + $array1[$i-1];
}
$ans = $alice-$tom;
echo $ans;
?>

Measured memory_bytes: 16268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        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
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    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()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = MAP()
L = [[x-1 for x in LIST()[1:]] for _ in range(N)]
uf = UnionFind(N)
graph = [[] for _ in range(M)]

for i, l in enumerate(L):
	for x in l:
		graph[x].append(i)

for i in range(M):
	if len(graph[i]) <= 1:
		continue
	p = graph[i][0]
	for x in graph[i][1:]:
		uf.union(p, x)

num_group = uf.group_count()
print("YES" if num_group == 1 else "NO")


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    constexpr int INF = 1'000'000'000;
    vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j <= i + K && j < N; ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[N - 1] << "\n";

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int t[210], v[210];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> t[i];
  REP(i, n) cin >> v[i];

  double ret = 0, sp = 0;
  REP(i, n) {
    for(double j=0; j<t[i]; j+=0.5) {
      bool flag1 = true, flag2 = true;
      double ti = t[i]-j-0.5;
      FOR(k, i+1, n) {
        ti += t[k];
        if(sp+0.5-ti > v[k+1]) flag1 = false;
        if(sp-v[k+1] > ti) flag2 = false;
      }
      if(sp+0.5 <= v[i] && flag1 && (sp+0.5-(t[i]-j-0.5)) <= v[i+1]) {
        ret += sp*0.5;
        ret += 0.125;
        sp += 0.5;
      } else if(sp - v[i+1] <= t[i]-j-0.5 && flag2) {
        ret += sp*0.5;
      } else {
        sp -= 0.5;
        ret += sp*0.5;
        ret += 0.125;
      }
      // cout << j << ", " << ret  << ", " << sp << endl;
    }
  }
  cout <<fixed << setprecision(15) << ret << endl;

  return 0;
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
int main(){ 

        ll t=1;
        // cin>>t;
        while(t--){
                ll n;
                cin>>n;
                int arr[n];
                vll vec(21,0);
                rep(i,0,n)
                        cin>>arr[i];
                ll ans=0,l=0;
                rep(i,0,n){
                        ll k=arr[i],p=0;
                        while(k){
                                if(k&1)
                                        vec[p]++;
                                ++p;
                                k>>=1;
                        }
                        rep(j,0,20){
                                if(vec[j]>1){
                                        rep(r,l,i){
                                                k=arr[r],p=0;
                                                while(k){
                                                        if(k&1)
                                                                vec[p]--;
                                                        ++p;
                                                        k>>=1;
                                                }
                                                ++l;
                                                if(vec[j]==1)
                                                        break;
                                        }
                                }
                        }
                        ans+=(i-l+1);
                }
                cout<<ans<<'\n';
        }
}


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

int main() {
    int H, W;
    std::cin >> H >> W;
    
    char a[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) { 
            std::cin >> a[i][j];
        }
    }

    std::cout << std::string(W + 2, '#') << std::endl;
    for (int i = 0; i < H; ++i) {
        std::cout << "#";
        for (int j = 0; j < W; ++j) { 
            std::cout << a[i][j];
        }
        std::cout << "#\n";
    } 
    std::cout << std::string(W + 2, '#') << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
using namespace std;


int main() {
	int a, b, c, d, e,k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)cout << ":("<<endl;
	else cout << "Yay!"<<endl;
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin>>x;
	if(x>=400 && x<600)
	{
		cout<<8;
	}
		if(x>=600 && x<800)
	{
		cout<<7;
	}	if(x>=800 && x<1000)
	{
		cout<<6;
	}
		if(x>=1000 && x<1200)
	{
		cout<<5;
	}
		if(x>=1200 && x<1400)
	{
		cout<<4;
	}
		if(x>=1400 && x<1600)
	{
		cout<<3;
	}
		if(x>=1600 && x<1800)
	{
		cout<<2;
	}
		if(x>=1800 && x<2000)
	{
		cout<<1;
	}
	
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	vi AS (N);
	vi BS (N);
	F0R(i, N) {
		AS[i] = 1 + i * N;
		BS[N-i-1] = 1 + i * N;
	}
	F0R(i, N) AS[arr[i]-1] += i;
	
	for (int x : AS) cout << x << " "; cout << endl;
	for (int x : BS) cout << x << " "; cout << endl;
}

Measured memory_bytes: 896