akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
abc = N.times.map {gets.split.map &:to_i}
dp = Array.new(N+1).map{Array.new(3,0)}

N.times do |i|
  3.times do |j|
    3.times do |k|
        dp[i + 1][k] = [dp[i + 1][k], dp[i][j] + abc[i][k]].max if j != k
    end
  end
end


puts dp[N].max
##　備忘録として他の方のコードを提出させていただきます


Measured memory_bytes: 17020
n,k=[int(input())for i in range(2)]
tile=[[int(s)for s in input().split(" ")]for i in range(k)]
c=1+n
for t in tile:
    d=max((abs(2*t[0]-c),abs(2*t[1]-c)))
    if d%3==(c-2)%3:print('1')
    elif d%3==(c-4)%3:print('2')
    elif d%3==c%3:print('3')

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

vector<int> v;
int n,k;
string s;

int32_t main()
{
    IOS
    cin>>n>>k>>s;
    int cnt=0;
    char last='*';
    if (s[0]=='0') v.pb(0);
    for (char c:s)
    {
        if (c!=last)
        {
            if (last!='*') v.pb(cnt);
            last=c;
            cnt=1;
        }
        else
        {
            cnt++;
        }
    }
    v.pb(cnt);
    if (s[n-1]=='0') v.pb(0);
    k=2*k+1;
    if (sz(v)<=k)
    {
        cout<<n<<endl;
        return 0;
    }
    int ans=0,tmp=0;
    for (int i=0;i<k;i++)
    {
        tmp+=v[i];
    }
    ans=tmp;
    for (int i=k+2;i<=sz(v);i+=2)
    {
        tmp+=(v[i-1]+v[i-2]-v[i-k-2]-v[i-k-1]);
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int r,D,x0;
int main(){
  cin>>r>>D>>x0;
  rep(i,10){
    x0=r*x0-D;
    prin(x0);
  }
  return 0;
}


Measured memory_bytes: 256
def get_prime(n):
    prime = []
    while n % 2 == 0:
        prime.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime.append(n)
    return prime

A, B = map(int, input().split())
prime1 = get_prime(A)
prime2 = get_prime(B)
ans_prime = set(prime1) & set(prime2)
print(len(ans_prime) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif
int n;
cin>>n;
double p[n];
rep(i,n){
	cin>>p[i];
}
double dp[n+1][n+1];
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
for(int i = 1;i<=n;i++){
	dp[i][0] = (i==1)?(1-p[i-1]):dp[i-1][0]*(1-p[i-1]);
}
for(int i = 1;i<=n;i++){
    for(int j = 1;j<=i;j++){
    	if(i>j)
    		dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
    	else
    		dp[i][j] = dp[i-1][j-1]*p[i-1];
    }
}
// for(int i = 0;i<=n;i++){
//     for(int j = 0;j<=n;j++){

//     		cout<<dp[i][j]<<" ";
//     }
//     cout<<endl;
// }


double ans = 0.00;
for(int i = n/2+1;i<=n;i++){
	ans+=dp[n][i];
}
cout<<setprecision(10)<<ans;







#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

return 0;
}

Measured memory_bytes: 74076
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 998244353;
const int N = 700005;
const int K = 1000000;
int s1[N], a[N], s2[N], l, n;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    cin >> l >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        s1[i] = s1[i - 1] + a[i];
    }
    for (int i = n; i >= 1; i--){
        s2[n - i + 1] = s2[n - i] + l - a[i];
    }
    int ans = max(l - a[1], a[n]);
    for (int i = 1; i < n; i++){
        int n2 = n - i;
        int n1 = i;
        int d;
        if (n1 > n2){
            d = 2 * s1[n1 - n2];
        } else{
            d = 2 * s2[n2 - n1];
        }
        int res = 2 * (s1[n1] + s2[n2]) - d - min(a[n1], l - a[i + 1]);
        if (n1 > n2){
            res = max(res, 2 * (s1[n1] + s2[n2]) - a[n1] - 2 * s1[n1 - n2 - 1]);
        } else
        if (n2 > n1){
            res = max(res, 2 * (s1[n1] + s2[n2]) - (l - a[i + 1]) - 2 * s2[n2 - n1 - 1]);
        }
       // cout << s1[n1] << " " << s2[n2] << " " << d << " " << min(a[n1], l - a[i + 1]) << " " << i << " " << a[3] << " " << res << endl;
        ans = max(ans, res);
    }
    cout << ans;
}


Measured memory_bytes: 9984
#!python3.7
#-*- coding: utf-8 -*-

def main():
    #a,b = map(int,input().split())
    a,b = (int(x) for x in input().split())
    area = a * b
    perimeter = 2*a + 2*b
    print(area,perimeter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a==0) cout << "1" << endl;
    else if(b==0) cout << "2" << endl;
    else if(c==0) cout << "3" << endl;
    else if(d==0) cout << "4" << endl;
    else cout << "5" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

vector<vector<ll> > v(200001);//木
bool maki[200001];//dfs用

//Union-Find
ll uni[200001];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}
void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}

//dfs(二部グラフ作成)
void dfs(ll n){
	maki[n]=true;
	if(!v[n].size())return;
	ll num=v[n][0];
	for(auto& i:v[n]){
		connect(i,num);
		if(!maki[i])dfs(i);
	}
	return;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    memset(maki,0,sizeof(maki));
    ll n;
    cin>>n;
    ll a,b;
    for(int i=0;i<n-1;i++){
    	cin>>a>>b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    dfs(0LL);
    ll c,d;
    //二部グラフの2つの領域を記録
    for(int i=0;i<n;i++){
    	if(root(i)!=root(0LL)){
    		a=size(i);
    		b=size(0LL);
    		c=root(i);
    		d=root(0LL);
    		break;
    	}
    }
    
    if(a<b){swap(a,b);swap(c,d);}//b,dを小さい方とする。
    bool niko=(b>ll(n/3));
    ll m1=1,m2=2,m3=3;
    ll ans[n];
    if(niko){//rootがdとなる要素数がn/3より大きいとき
    	for(int i=0;i<n;i++){
    		if(root(i)==c){//3m+1と3mで埋める(3m+1の数は3m+2以上)
    			if(m1<=n){
    				ans[i]=m1;
    			    m1+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    		}else{//3m+2と3mで埋める
    			if(m2<=n){
    				ans[i]=m2;
    				m2+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    		}
    	}
    }else{//rootがdとなる要素数がn/3より小さいとき
    	for(int i=0;i<n;i++){
    		if(root(i)==c){//3の倍数以外を優先して適当に埋める
    			if(m1<=n){
    				ans[i]=m1;
    				m1+=3;
    			}else if(m2<=n){
    				ans[i]=m2;
    				m2+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    		}else{//3の倍数で埋める
    			ans[i]=m3;
    			m3+=3;
    		}
    	}
    }

    for(int i=0;i<n;i++){
    	cout << ans[i]<<" ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18408
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define bi_pc __builtin_popcount
#define bi_pcll __builtin_popcountll
#define bi_tz __builtin_ctz
#define bi_tzll __builtin_ctzll
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef TAMREF
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 42
#endif
using namespace std;
using ll = long long; using lf = long double; 
using pii = pair<int,int>; using ppi = pair<int,pii>;
using pll = pair<ll,ll>; using pff = pair<lf,lf>;
using ti = tuple<int,int,int>;
using base = complex<double>;
const lf PI = 3.14159265358979323846264338L;
template <typename T>
inline T umax(T& u, T v){return u = max(u, v);}
template <typename T>
inline T umin(T& u, T v){return u = min(u, v);}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int P[100005], n;
int main(){
    fio;
    cin >> n;
    if((n & (n-1)) == 0){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    vector<pii> E;
    int x = 1;
    for(; x-1 <= n; x <<= 1); x >>= 1;
    debug("x = %d\n",x);
    for(int i = 1; i < x; i++) P[i] = i;
    for(int i = x; i < n; i += 2){
        E.ep(i, i+1);
        E.ep(i+1, 1);
        E.ep(n + i, n + i + 1);
        E.ep(n + i, n + 1);
    }
    if(~n & 1){
        int p = n ^ (n-1) ^ 1;
        debug("p = %d\n",p);
        swap(P[p], P[2]);
        E.ep(n, n-1);
        E.ep(n + p, n + n);
    }
    for(int i = 1; i < x-1; i++){
        E.ep(P[i], P[i+1]);
        E.ep(P[i] + n, P[i+1] + n);
    }
    E.ep(P[x-1], n + P[1]);
    debug("E = %d\n",szz(E));
    for(pii p : E) cout << p.va << ' ' << p.vb << '\n';
    return 0;
}

Measured memory_bytes: 5644
#include<stdio.h>
int main(void)
{
	int a,b,c,n;
	scanf("%d",&n);
	a=n/100;
	n=n%100;
	b=n/10;
	c=n%10;
	if(a==7||b==7||c==7){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}	
	return 0;
}

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

void solve() 
{
    double l;cin>>l;l/=3;
    cout<<setprecision(20)<<(double)pow(l,3)<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int a = s.size(),ans=0;
  for(int i=0; i<(a+1)/2; i++){
    if(s[i]!=s[a-1-i]){ans++;}
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const int NMAX = 2e5;

int fact[NMAX + 5];
int ifact[NMAX + 5];

int sqr_sum(int x){
    if(x <= 0){
        return 0;
    }

    int a = x;
    int b = x + 1;
    int c = 2 * x + 1;

    if(a % 3 == 0)a /= 3;
    else if(b % 3 == 0)b /= 3;
    else if(c % 3 == 0)c /= 3;
    
    if(a % 2 == 0)a /= 2;
    else if(b % 2 == 0)b /= 2;
    else if(c % 2 == 0)c /= 2;

    return 1LL * (1LL * a * b % MOD) * c % MOD;
}

int num_pairs_with_d(int n,int m,int d){
    ///proof of concept

    int ans = 0;

    if(d - n <= 0){
        ans = (ans + 1LL * (m - 0) * (n + 0 - d)) % MOD;
    }

    if(m >= d){
        ans = (ans + 1LL * (m - d) * (n + d - d)) % MOD;
    }

    int st = max(d - n,1);
    int dr = min(m,d - 1);

    int tmp_norm_sum = (1LL * (dr + st) * (dr - st + 1) / 2) % MOD;
    int tmp_sqr_sum = ((sqr_sum(dr) - sqr_sum(st - 1)) % MOD + MOD) % MOD;

    ans = ((ans + 1LL * (2LL * m * (n - d) % MOD) * (dr - st + 1)) % MOD + MOD) % MOD;
    ans = ((ans + 2LL * tmp_norm_sum * (m - n + d)) % MOD + MOD) % MOD;
    ans = ((ans - 2LL * tmp_sqr_sum) % MOD + MOD) % MOD;
    
    return ans;
}

int comb(int n,int m){
    int ans = 1LL * fact[n] * ifact[m] % MOD;
    ans = 1LL * ans * ifact[n - m] % MOD;
    return ans;
}

int solve(int n,int m,int k,int d){
    int ans = 1;
    ans = 1LL * ans * num_pairs_with_d(n,m,d) % MOD;
    ans = 1LL * ans * comb(n * m - 2,k - 2) % MOD;
    return ans;
}

int lgpow(int b,int e){
    int p = 1;
    while(e){
        if(e & 1){
            p = 1LL * p * b % MOD;
        }
        b = 1LL * b * b % MOD;
        e >>= 1;
    }
    return p;
}

int main(){

    fact[0] = 1;
    for(int i = 1;i <= NMAX;i++){
        fact[i] = 1LL * fact[i - 1] * i % MOD;
    }

    ifact[NMAX] = lgpow(fact[NMAX],MOD - 2);
    
    for(int i = NMAX - 1;i >= 0;i--){
        ifact[i] = 1LL * ifact[i + 1] * (i + 1) % MOD;
    }

    int n,m,k;
    int ans = 0;

    scanf("%d %d %d",&n,&m,&k);

    for(int d = 0;d <= n + m;d++){
        ans = (ans + 1LL * d * solve(n,m,k,d)) % MOD;
    }

    printf("%d\n",ans);

    return 0;
}


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

int main()
{
	const string standard_string = "CODEFESTIVAL2016";
	int len = standard_string.size();
	string str;
	while (cin >> str)
	{
		int res = 0;
		for (size_t i = 0; i < len; ++i)
		{
			if (standard_string[i] != str[i])
				++res;
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    ## ><を探す。閉じたところのindex(<)
    S = ">"+S+"<"
    answer = [0]*(len(S)+1)
    between_index = []
    prev = ">"
    for i in range(len(S)):
        if prev == ">" and S[i]=="<":
            between_index.append(i)
        
        prev = S[i]
    if prev == ">":
        between_index.append(len(S))

    for index in between_index:
        for left in range(index-2,-1,-1):
            if S[left]=="<":
                answer[left+1] = max(answer[left+1],answer[left+2]+1)
                break
            else:
                answer[left+1]=answer[left+2]+1
        for right in range(index+1,len(S)):
            if S[right]==">":
                answer[right] = max(answer[right],answer[right-1]+1)
                break
            else:
                answer[right]=answer[right-1]+1
            
    answer = answer[1:len(answer)-1]
    print(sum(answer))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll k, a, b;
  cin >> k >> a >> b;
  ll bis = 1;
  ll money = 0;
  if(b-a<=2){
    print(k + 1);
  }
  else if(k+1<=a){
    print(k + 1);
  }
  else{
    ll c = (k - a + 1 ) / 2;
    bis = a;
    bis += c * (b - a);
    if((k-a+1)%2==1){
      bis++;
    }
    print(bis);
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD =1000000007;
using mint= Fp<MOD>;

int main(){
  ll n;cin>>n;
  vector<mint> e(n);
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    e[i]=tmp;
  }
  mint part1=0;
  mint part2=0;
  for(int i=0;i<n;i++){
    part1+=e[i];
  }
  part1=part1*part1;
  for(int i=0;i<n;i++){
    part2+=e[i]*e[i];
  }
  mint c=2;

  cout<<(part1-part2)/c<<endl;
}

Measured memory_bytes: 4368
#include<iostream>
using namespace std ;
using ll = long long ;

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

int main(){
	ll n ; cin >> n ;
	ll g ; cin >> g ;
	for(int i=1;i<n;i++){
		ll a ; cin >> a ;
		g = gcd(g,a) ;
	}
	cout << g << endl ;
}

Measured memory_bytes: 256
import bisect
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
p=sorted(list(map(int,input().split())))
a=bisect.bisect_left(p,x)
if p[a]!=x or n==0:
  print(x)
  exit()
i=0
while True:
  if not (x-i) in p:
    print(x-i)
    break
  elif not (x+i) in p:
    print(x+i)
    break
  else:
    i+=1

Measured memory_bytes: 62124
#include<stdio.h>
int main()
{
  int N,i;
  char S[200],T[200];
  scanf("%d",&N);
  scanf("%s%s",&S,&T);
  for(i=0;i<N;i++)
 {
   printf("%c%c",S[i],T[i]);
 }
}
  

Measured memory_bytes: 128
using System;

namespace abc97_a_2_
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int index = array.Length - 1;
            int[] inputs = new int[index];
            int distance = int.Parse(array[index]);
            int ab = 0;
            int ac = 0;
            int bc = 0;
            for(int i = 0; i < index; i++)
            {
                inputs[i] = int.Parse(array[i]); //string型の配列をint型の配列に移し替えてる
            }
            ab = inputs[1] - inputs[0]; //ab間の絶対値を求めてる
            ab = System.Math.Abs(ab);
            ac = inputs[2] - inputs[0]; //ac間の絶対値を求めてる
            ac = System.Math.Abs(ac);
            bc = inputs[2] - inputs[1]; //bc間の絶対値を求めてる
            bc = System.Math.Abs(bc);
            if (ab <= distance && bc <= distance)
            {
                Console.WriteLine("Yes");
            }
            else if (ac <= distance)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include<stdlib.h>
#define N 100100
using namespace std;
long long f[N],k[N],ans[N],sum;
int x[N],y[N];
int get(int x)
{
    if(k[x]==x) return x;
    return k[x]=get(k[x]);
}
void ju(int x,int y)
{
    int tx=get(x);
    int ty=get(y);
    k[tx]=ty;
    f[ty]+=f[tx];
}
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++) k[i]=i,f[i]=1;
    for(i=1;i<=m;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
    }
    for(i=m;i>=1;i=i-1)
    {
        int tx=get(x[i]);
        int ty=get(y[i]);
        if(tx!=ty)
        sum=f[tx]*f[ty],
        ju(x[i],y[i]),
        ans[i]=ans[i+1]+sum;
        else ans[i]=ans[i+1];
    }
    for(i=2;i<=m;i++)
    {
        printf("%lld\n",1ll*(n-1)*n/2-ans[i]);
    }
    printf("%lld\n",1ll*(n-1)*n/2);
}


Measured memory_bytes: 4480
from itertools import permutations
N = int(input())
cc = []
dd = []
for i in range(N):
  aa = list(map(int,input().split()))
  cc.append(aa)
  dd.append(i)
ee = []
for i in permutations(dd):
  add = 0
  count = 0
  for j,k in enumerate(i):
    add += ((cc[k][0]-cc[i[j+1]][0])**2 + (cc[k][1]-cc[i[j+1]][1])**2)**0.5
    count += 1
    if count == N-1:
      break
  ee.append(add)
ff = 1
for i in range(1,N+1):
  ff *= i
print(sum(ee)/ff)

Measured memory_bytes: 10924
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		//AC, WA, TLE, RE
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		String str = sc.nextLine();
		for (int i=0; i<a; i++) {
			str = sc.nextLine();
			if (str.compareTo("AC")== 0) ac++;
			if (str.compareTo("WA")== 0) wa++;
			if (str.compareTo("TLE")== 0) tle++;
			if (str.compareTo("RE")== 0) re++;
		}
		sc.close();
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);

	}
}


Measured memory_bytes: 51592
#include <stdio.h>

int main(void) {
	int i, temp = 0;
	char str[1001];
		scanf("%s", str);
		for (i = 0; i < strlen(str); i++){
			if (str[i] <= 'C')
				str[i] = str[i] + ('Z'-'A') + 1;
			temp = str[i] - 3;
			str[i]  = temp;
		}
		printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 524
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)
x1 = X_sort[N // 2 - 1]
x2 = X_sort[N // 2]
for x in X:
    if x <= x1:
        print(x2)
    else:
        print(x1)

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int fa[MAXN],num[MAXN];
int _find(int cur)
{
    return fa[cur]==cur?cur:fa[cur]=_find(fa[cur]);
}

int main()
{
    int n,m,x,y,z,i,j,ans=0;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        fa[i]=i;
    for(i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int u=_find(x);
        int v=_find(y);
        fa[v]=u;
    }
    for(i=1;i<=n;i++)
    {
        //cout<<fa[i]<<" ";
        int u=_find(i);
        if(!num[u])
        ans++;
        num[u]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
const int MAXN=1000;
LL x[2][MAXN*MAXN+10];
void solve(long long n, long long k, vector<long long> a){
	int m[2]={0,0};
	for(int i=0; i<n; ++i) {
		LL s=0;
		for(int j=i; j<n; ++j) {
			s+=a[j];
			x[0][++m[0]]=s;
		}
	}	
	//sort(&x[0][1],&x[0][n]+1);
	LL now=0;
	int ii=0;
	for(int i=60; i>=0; --i) {
		LL l=now+(1LL<<i),r=now+(1LL<<(i+1))-1;	
		int cnt=0;
		for(int j=1; j<=m[ii]; ++j) {
			if ((x[ii][j]&l)==l) ++cnt;
		}
		if (cnt>=k) {
			now=l;
			m[ii^1]=0;
			for(int j=1; j<=m[ii]; ++j) {
				if ((x[ii][j]&l)==l) {
					x[ii^1][++m[ii^1]]=x[ii][j];
				}
			}
			ii^=1;
		}
	}
	cout<<now<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("./in_B_1.txt","r",stdin);
#endif
	long long K;
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, K, a);
	return 0;
}



Measured memory_bytes: 8448
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

int main(){
    int mod=1000000007;
    int c1,c2,c3;
    while (scanf("%d %d %d",&c1,&c2,&c3)!=EOF) {
        bool x[10]={0};
        x[c1-1]=1;
        x[c2-1]=1;
        x[c3-1]=1;
        int cnt=0;
        for (int i=0;i<10;++i) {
            if (x[i]==0 && c1+c2+i<20) cnt++;
        }
        printf((cnt>3)?"YES\n":"NO\n");
    }
    return 0;
}

Measured memory_bytes: 3132
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A >= B:
    if C >= D:
        print(B+D)
    else:
        print(B+C)
else:
    if C >= D:
        print(A+D)
    else:
        print(A+C)
    


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

int main () {
     int a,b,c;
     cin >> a >> b >> c;
     if (a < b && b < c) {
          cout << a << " " << b << " " << c << endl;
     } else if (b <= a && a <= c) {
          cout << b << " " << a << " " << c << endl;
     } else if (c <= b && b <= a) {
          cout << c << " " << b << " " << a << endl;
     } else if (a <= c && c <= b) {
          cout << a << " " << c << " " << b << endl;
     } else if (b <= c && c <= a) {
          cout << b << " " << c << " " << a << endl;
     } else if (c <= a && c <= b) {
          cout << c << " " << a << " " << b << endl;
     }
     return 0;
}



Measured memory_bytes: 3092
N, Q = map(int, raw_input().split())
ans = [0 for i in range(N)]
tree_s = ['' for i in range(N-1)]

for i in range(0, N-1):
    a, b = map(int, raw_input().split())
    tree_s[i] = str(a).zfill(8) + '-' + str(b)

tree_s.sort()

for i in range(0, Q):
    v, p = map(int, raw_input().split())
    ans[v-1] += p

for i in range(0, N-1):
    ab = tree_s[i].split("-")
    ans[int(ab[1])-1] += ans[int(ab[0])-1]


print ' '.join(map(str, ans))


Measured memory_bytes: 41152
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


//atcoder crt but i removed the comments to make shorter and then added a comment for you to read right now. :)
pair<long long, long long> inv_gcd(long long a, long long b) {
    if (a == 0) return { b, 0 };
    long long s = b, t = a;
    long long m0 = 0, m1 = 1;
    while (t) {
        long long u = s / t;
        s -= t * u;
        m0 -= m1 * u;
        swap(s, t);
        swap(m1, m0);
    }
    if (m0 < 0) m0 += b / s;
    return { s, m0 };
}


pair<ll, ll> crt(vector<ll>& r, vector<ll>& m) {
    int n = r.size();
    ll r0 = 0, m0 = 1;
    for (int i = 0; i < n; i++) {
        ll r1 = ((r[i] % m[i]) + m[i]) % m[i];
        ll m1 = m[i];
        if (m0 < m1) {
            swap(r0, r1);
            swap(m0, m1);
        }
        if (m0 % m1 == 0) {
            if (r0 % m1 != r1) return { 0, 0 };
            continue;
        }
        ll g, im;
        std::tie(g, im) = inv_gcd(m0, m1);

        long long u1 = (m1 / g);
        if ((r1 - r0) % g) return { 0, 0 };
        long long x = (r1 - r0) / g % u1 * im % u1;
        r0 += x * m0;
        m0 *= u1;
        if (r0 < 0) r0 += m0;
    }
    return { r0, m0 };
}

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

    ll n;
    cin >> n;
    n *= 2;
    vector<ll> v;
    for (int i = 2; i <= sqrt(n)+1; i++) {
        if (n % i == 0) {
           ll x = 1;
            while (n % i == 0) {
                n /= i;
                x*=i;
            }
            v.push_back(x);
        }
    }
    if (n > 1) {
        v.push_back(n);
    }
    ll mn = 100000000;
    mn *= 100000000;
    for (int i = 0; i < (1 << (v.size())); i++) {
        ll x = 1;
        ll y = 1;
        for (int j = 0; j < v.size(); j++) {
            if (i & (1 << j)) x *= v[j];
            else y *= v[j];
        }
        //find candidate for k+1, 1 mod x, 0 mod y
        vector<ll> a({ 1, 0 });
        vector<ll> b({ x, y });
        auto ans = crt(a, b);
        if (ans.first == 0) ans.first += ans.second;
        if (ans.first == 1) ans.first += ans.second;
        mn = min(mn, ans.first - 1);
    }
    cout << mn << endl;

}


Measured memory_bytes: 3680
#include<iostream>//D
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    const int maxn=1e5+10;
    string str;
    cin >> str;
    int children[maxn],len=str.size();
    memset(children,0,sizeof(children));
    for(int i=1;;i++)
    {
        int a=i-1,sum=1;
        while(str[i]==str[i-1]&&i<len) i++,sum++;
        if(str[i-1]=='R')
        {
            if(sum%2) children[i-1]+=sum/2+1,children[i]+=sum/2;
            else children[i-1]+=sum/2,children[i]+=sum/2;
        }
        if(str[i-1]=='L')
        {
            if(sum%2) children[a]+=sum/2+1,children[a-1]+=sum/2;
            else children[a]+=sum/2,children[a-1]+=sum/2;
        }
        if(i==len) break;
    }
    for(int i=0,k=len-1;i<k;i++) printf("%d ",children[i]);
    printf("%d\n",children[len-1]);
    return 0;
}

Measured memory_bytes: 1024
S = input() + 'R'
N = len(S) - 1

now = 'R'
pos_R = []
pos_L = []
for i, s in enumerate(S):
  if s == 'L' and now == 'R':
    now = 'L'
    pos_R.append(i-1)
  
  if s == 'R' and now == 'L':
    now = 'R'
    pos_L.append(i-1)


ans = [0]*N
pre_l = -1

for r, l in zip(pos_R, pos_L):
  nl1 = (r - pre_l) // 2
  nr1 = (r - pre_l) - nl1
  nr2 = (l - r) // 2
  nl2 = (l - r) - nr2
  ans[r] = nr1 + nr2
  ans[r+1] = nl1 + nl2
  pre_l = l

print(*ans)

Measured memory_bytes: 10268
h,w = map(int, input().split())

ab = [input() for i in range(h)]

dp=[[0 for i in range(w+2)] for j in range(h+2)]



for i in range(h):
    sl =  list(ab[i])
    for j in range(w):
        if sl[j]=="#":
            for k in range(3):
                for l in range(3):
                    dp[i+k][j+l] +=1

for i in range(h):
    sl = list(ab[i])
    res = ""
    for j in range(w):
        
        if sl[j]=="#":
            res += "#"
        else:
            res += str(dp[i+1][j+1])
    print(res)

Measured memory_bytes: 3064
// Problem : C - Marks
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
using namespace std;


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fr(i,x,n) for(int i=x;i<n;i++)
#define frt(it,vb) for(auto it=vb.begin();it!=vb.end();it++)
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 1000003

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

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



int main(){
	
	fastio;
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	
	fr(i,1,n+1)cin>>arr[i];
	
	fr(i,k+1,n+1){
		if(arr[i]>arr[i-k]){
			cout<<"Yes\n";
			
		}
		else cout<<"No\n";
	}
	
	}


	
	
	
	



Measured memory_bytes: 5176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _086
{
    class Program
    {
        static void Main(string[] args)
        {
            ProblemB.Solve();
        }
    }


    class ProblemB
    {
        public static void Solve()
        {

            string[] array = Console.ReadLine().Split(' ');

            int num = int.Parse(array[0] + array[1]);

            double root = Math.Sqrt(num);

            for (int i = 1; i <= 1000; i++)
            {
                if ((i * i) == num)
                {
                    Console.WriteLine("Yes");
                    return;
                }

            }

            Console.WriteLine("No");
        }
    }


    class ProblemA
    {
        public static void Solve()
        {
 
            int[] array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();


            if ( (array[0] * array[1] % 2) == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");

            }           
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

constexpr double eps=1e-9;
constexpr double PI=3.14159265358979323846264338327950;

inline int sgn(double x){
    if(x<-eps) return -1;
    if(x>eps) return 1;
    return 0;
}

inline bool EQ(double x, double y){
    return sgn(x-y)==0;
}

inline bool GE(double x, double y){
    return sgn(x-y)==1;
}

inline bool LE(double x, double y){
    return sgn(x-y)==-1;
}

inline bool GEQ(double x, double y){
    return sgn(x-y)>=0;
}

inline bool LEQ(double x, double y){
    return sgn(x-y)<=0;
}

struct Point{
    double x, y, z;
    Point(double x=0, double y=0, double z=0): x(x), y(y), z(z){}

    Point operator+(const Point &p){
        return {x+p.x, y+p.y, z+p.z};
    }

    Point operator-(const Point &p){
        return {x-p.x, y-p.y, z-p.z};
    }

    Point operator*(const double k){
        return {k*x, k*y, k*z};
    }

    Point operator/(const double k){
        return {x/k, y/k, z/k};
    }

    double operator*(const Point &p){
        return x*p.x+y*p.y+z*p.z;
    }

    bool operator==(const Point &p){
        return EQ(x, p.x) && EQ(y, p.y) && EQ(z, p.z);
    }
};

using Vec=Point;
using Polygon=vector<Point>;

double norm(Point p){
    return p.x*p.x+p.y*p.y+p.z*p.z;
}

double abs(Point p){
    return sqrt(norm(p));
}

double getDistanceLP(Point a, Vec v, Point p){
    double t = v*(p-a) / norm(v);
    return abs(a+v*t - p);
}

double getDistanceSP(Point a, Point b, Point p){
    if(LE((b-a)*(p-a), 0)) return abs(p-a);
    if(LE((a-b)*(p-b), 0)) return abs(p-b);
    return getDistanceLP(a, b-a, p);
}

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    Point p[n];
    double r[n], l[n];
    rep(i, n) scanf("%Lf%Lf%Lf%Lf%Lf", &p[i].x, &p[i].y, &p[i].z, &r[i], &l[i]);

    rep(_, q){
        Point a, b;
        scanf("%Lf%Lf%Lf", &a.x, &a.y, &a.z);
        scanf("%Lf%Lf%Lf", &b.x, &b.y, &b.z);
        double ans = 0;
        rep(i, n){
            if(LEQ(getDistanceSP(a, b, p[i]), r[i])) ans += l[i];
        }
        printf("%lld\n", (lint)(ans + 0.5));
    }
}


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

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
int fact[100005];

int main(){
    int n, m;
    cin >> n >> m;
    fact[0] = 1;
    for(int i = 1; i < 100005; i++)
        fact[i] = (fact[i - 1] * 1ll * (ll)i) % mod;
    if(n == m)
        cout << ((fact[n] * 1ll * fact[m]) % mod * 2ll) % mod;
    else if(abs(n - m) == 1)
        cout << (fact[n] * 1ll * fact[m]) % mod;
    else
        cout << 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int a,b,q,s[120000],t[120000],x[120000],res;

set<long long int> tera,jinjya;
int main() {
	cout << fixed << setprecision(18);
    
    cin>>a>>b>>q;
    for(int i=0;i<a;i++){
        cin>>s[i];
        jinjya.insert(s[i]);
    }
    for(int i=0;i<b;i++){
        cin>>t[i];
        tera.insert(t[i]);
    }
    jinjya.insert(INF);
    tera.insert(INF);
    
    jinjya.insert(-INF);
    tera.insert(-INF);
    
    for(int i=0;i<q;i++){
        cin>>x[i];
        res=INF;
        auto itr1 =jinjya.lower_bound(x[i]);
        auto itr2=tera.lower_bound(x[i]);
        res=min(res,max(*itr1,*itr2)-x[i]);

        itr1--;
        itr2--;
        res=min(res,x[i]-min(*itr1,*itr2));
        
        itr1 =jinjya.lower_bound(x[i]);
        itr2 =tera.upper_bound(x[i]);
        itr2--;
        res=min(res,min(*itr1-x[i],x[i]-*itr2)+(*itr1-*itr2));
        
        itr1 =jinjya.upper_bound(x[i]);
        itr2=tera.lower_bound(x[i]);
        itr1--;
        res=min(res,min(*itr2-x[i],x[i]-*itr1)+(*itr2-*itr1));

        cout<<res<<endl;
    }
} 


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

using namespace std;

long long gcd(long long a, long long b){
    if(!b)  return a;
    return gcd(b, a%b);
}

int main()
{
    long long k,res=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int w=1;w<=k;w++){
                res+=gcd(i,gcd(j,w));
            }
        }
    }
    cout<<res<<endl;

    return 0;
}


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

int main(void) {
    int x, y;
    while(true) {
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3048
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
cl=list(map(int,input().split()))

ans=0
dish=al[0]
ans+=bl[dish-1]
bef_dish=dish
for i in range(1,n):
    dish=al[i]
    ans+=bl[dish-1]
    if dish== bef_dish+1:
        ans+=cl[bef_dish-1]
    bef_dish=dish
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

const int N = 200003;

int cnt = 0, a[N], k, n, bits[N];

ll sum[N], H[N];

void add(int x) {
	for (; x <= cnt; x += (x & -x))
		++bits[x];
}

int query(int x) {
	int ret = 0;
	for (; x; x -= (x & -x))
		ret += bits[x];
	return ret;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	H[++cnt] = 0;
	for (int i = 1; i <= n; ++i) {
		sum[i] = sum[i - 1] + a[i];
		H[++cnt] = sum[i] - 1ll * k * i;
	}
	stable_sort(H + 1, H + cnt + 1);
	cnt = unique(H + 1, H + cnt + 1) - H;
	--cnt;
	
	ll num = 0, ans = 0;
	int tmp = lower_bound(H + 1, H + cnt + 1, num) - H;
	add(tmp);
	for (int i = 1; i <= n; ++i) {
		num = sum[i] - 1ll * k * i;
		tmp = lower_bound(H + 1, H + cnt + 1, num) - H;
		ans += query(tmp);
		add(tmp);
	}
	
	printf("%lld\n", ans);
	return 0;
}

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

#define reg register
typedef long long ll;
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=1e5+10,P=1e9+7;
#define int long long
ll L,R;
ll a[1000],c;
ll dp[1000][2][2][2];

ll dfs(int p,int lim,int fl,int x0){
	if(!p) return x0;
	if(~dp[p][lim][fl][x0]) return dp[p][lim][fl][x0];
	//cout<<p<<' '<<lim<<' '<<fl<<' '<<x0<<endl;
	ll Up=lim?a[p]:1;
	ll res=0;
	rep(i,0,Up) {
		if(i) {
			res+=dfs(p-1,(lim&&i==Up),1,1);//1
			if(fl) res+=dfs(p-1,(lim&&i==Up),1,x0);//0
		} else res+=dfs(p-1,lim&&(i==Up),fl,x0);//0
	}
	res%=P;
	dp[p][lim][fl][x0]=res%P;
	return res%P;
}

namespace dp2{
	ll a[100],c,b[100],c2;
	ll dp[100][2][2][2][2];

	ll dfs(int p,int lim,int lim2,int fl,int x0){
		if(!p) return x0;
		if(~dp[p][lim][lim2][fl][x0]) return dp[p][lim][lim2][fl][x0];
		int Up=lim?a[p]:1;
		ll res=0;
		rep(i,0,lim2?b[p]:1) {
			if(i) {
				if(Up==1) res+=dfs(p-1,lim,lim2&&i==b[p],1,1);
				if(fl) res+=dfs(p-1,lim&&0==a[p],lim2&&i==b[p],1,x0);
			} else res+=dfs(p-1,lim&&0==a[p],lim2&&i==b[p],fl,x0);
		}
		res%=P;
		dp[p][lim][lim2][fl][x0]=res%P;
		return res%P;
	}
	ll Solve(ll L,ll R){
		if(L<=1) return 0;
		memset(dp,-1,sizeof dp);
		L--;
		c=0;
		while(L) a[++c]=L&1,L>>=1;
		if(R>=(1ll<<c)-1 ) rep(i,1,c) b[i]=1;
		else rep(i,1,c) b[++c2]=R&1,R>>=1;
		//rep(i,1,c) cout<<a[i]<<' '<<b[i]<<endl;
		//cout<<c<<endl;
		return dfs(c,1,1,0,0);
	}
}



ll Solve(ll n){
	if(n<=1) return n;
	memset(dp,-1,sizeof dp);
	c=0;
	while(n) a[++c]=n&1,n>>=1;
	//cout<<c<<endl;
	return dfs(c,1,0,0);
}




signed main(){
	memset(dp,-1,sizeof dp);
	scanf("%lld%lld",&L,&R);
	//if(L==R) return puts("1"),0;
	//cout<<Solve(R)<<endl;
	//cout<<Solve(R)<<' '<<Solve(L-1)<<endl;
	ll res=Solve(R)-dp2::Solve(L,R);
	//cout<<Solve(R)<<' '<<dp2::Solve(L,R)<<endl;
	res=(res%P+P)%P;
	res=(res%P+P)%P;
	res=(res%P+P)%P;
	res=(res%P+P)%P;
	printf("%lld\n",res);
}








Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	k := sc.ReadInt()

	total := int64(0)
	for a := 1; a <= k; a++ {
		for b := a; b <= k; b++ {
			for c := b; c <= k; c++ {
				gcd := Gcd(c, Gcd(b, a))
				if a == b && b == c {
					total += int64(gcd)
				} else if a == b || b == c || c == a {
					total += int64(3 * gcd)
				} else {
					total += int64(6 * gcd)
				}
			}
		}
	}

	fmt.Println(total)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Gcd(big int, small int) int {
	rem := big % small
	if rem == 0 {
		return small
	}
	return Gcd(small, rem)
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto &i:a)cin>>i;
  sort(a.begin(),a.end(),greater<>());
  int l=0;
  for(int i=1;i<n;++i){
    if(a[i]==a[i-1]){
      if(!l)l=a[i++];
      else return cout<<l*a[i],0;
    }
  }
  cout<<0;
}


Measured memory_bytes: 1024