akhauriyash/Code-Regression huggingface dataset:
# coding: UTF-8
#@document_it
from collections import deque
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function
###########################

#@document_it
#O(1)のはず
def nb(i,j,H,W):
    ans = []
    a = i+1
    b = i-1
    c = j+1
    d = j-1
    if a >= 0 and a <= H-1:
        ans.append((a,j))
    if b >= 0 and b <= H-1:
        ans.append((b,j))
    if c >= 0 and c <= W-1:
        ans.append((i,c))
    if d >= 0 and d <= W-1:
        ans.append((i,d))
    return ans
        

def e():
    #入力データ整理
    dist={}
    white = {}
    wtotal = 0
    H,W = map(int,input().split())
    for i in range(H):
        row = input()
        for j in range(W):
            dist[(i,j)] = -1
            if row[j] == '.':
                white[(i,j)] = True
                wtotal += 1
            else:
                white[(i,j)] = False
    #リンク作成
    #tuple -> [tuple]
    #リンクの数は最大でも頂点の4倍なのでO(HW)
    link = {}
    for i in range(H):
        for j in range(W):
            link[(i,j)] = []
            if not white[(i,j)]:
                continue
            else:
                nlist = nb(i,j,H,W)
                for p in nlist:
                    if white[p]:
                        link[(i,j)].append(p)
    
    q = deque()
    dist[(0,0)] = 1
    q.append((0,0))
    while q:
        v = q.popleft()
        for w in link[v]:
            if dist[w] == -1:
                dist[w] = dist[v] + 1
                q.append(w)
                #print(w,dist[w])
    if dist[(H-1,W-1)] != -1:
        ans = wtotal - dist[(H-1,W-1)]
    else:
        ans = -1
    #print(wtotal)
    #print(dist[(H-1,W-1)])
                    
    print(ans)

###########################
if __name__ == '__main__':
    e()

Measured memory_bytes: 4972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
map<ll, ll> mp;
vector<PLL> v;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		ll x;
		cin >>x;
		mp[x]++;
	}
	for (map<ll, ll>::iterator it=mp.begin();it!=mp.end();it++)
	    if (it->second>1) v.push_back(*it);
	reverse(v.begin(),v.end()); 
	if (v.empty())
	{
		cout <<"0";
		return 0;
	} 
	if (v.size()==1 && v[0].second<4)
	{
		cout <<"0";
		return 0;
	}
	if (v[0].second>=4)
	{
		cout <<v[0].first*v[0].first;
		return 0;
	}
	cout <<v[0].first*v[1].first;
	return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
   //freopen("input.txt","r",stdin);
    FastIO;

    int n;
    while(cin>>n){

        int a[n+1];
        vector<int>dp(n+5,0);

        for(int i=1; i<=n; i++){
            cin>>a[i];
            dp[a[i]] = dp[a[i]-1] + 1;
        }
        int mx = 0;
        for(int i=1; i<=n; i++){
            mx = max(dp[i],mx);
        }
        cout<<(n-mx)<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


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

typedef long long ll;

int n, m;
string a, b;

int gcd(int x, int y) { return x? gcd(y % x, x): y; }

int main()
{
    cin >> n >> m;
    cin >> a >> b;
    int g = gcd(n, m);
    ll res = ll(n) / g * m;
    int delta = m / g, deltb = n / g;
    ll i = 0, j = 0;
    while (i < n || j < m)
        if (i * delta < j * deltb) i++;
        else if (i * delta > j * deltb) j++;
        else if (a[i] != b[j]) { printf("-1\n"); return 0; }
             else i++, j++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt
import java.util.Scanner
import java.util.ArrayList

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  val M = sc.nextInt()
  val h = new Array[Int](N)
  for(i <- 1 to N)h(i-1) = sc.nextInt()
  var l = new Array[Boolean](N)
  for(i <- 1 to M){
    val a = sc.nextInt()
    val b = sc.nextInt()
    if(h(a-1) >= h(b-1))l(b-1) = true
    if(h(b-1) >= h(a-1))l(a-1) = true
  }
  println(l.count(a=>a==false))




}

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

int dfs(int s, int arr[], vector<int> gra[]){
    int coun=1;
    arr[s]=1;
    for(int i:gra[s]){
        if(arr[i]==0){
            coun+=dfs(i,arr, gra);
        }
    }
    // cout<<"in dfs "<<s<<" "<<coun<<endl;
    return coun;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> graph[n+1];
    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int vis[n+1];
    for(int i=0; i<=n; i++)
        vis[i]=0;
    int max=0; 
    for(int i=1; i<n+1; i++){
        if(vis[i]==0){
            int t=dfs(i,vis,graph);
            // cout<<i<<" "<<t<<" "<<max<<endl;
            if(t>max)
                max=t;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 24648
#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cfloat>
#include<cmath>
#include<algorithm>


using namespace std;

double EPS = 1e-10;


double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

bool Binary_search(vector<point>N, point x){
  int l=0,r=N.size(),mid=(l+r)/2;

  while(r-l>1){
    if(N[mid]==x)return true;

    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;

    mid=(l+r)/2;
  } 
  if(N[mid]==x)return true;
  
  return false;
}

point solve(vector<point> M, vector<point> N){

  for(int i=0; i< N.size(); i++){
    int fg=1;
    for(int j=1; j< M.size(); j++){
      point t=N[i]+M[j]-M[0];
      if(Binary_search(N,t))fg++;
      if(fg==M.size())return N[i]-M[0];
    }
  }
  return M[0];
}

int main(void){
  int n,m;
  point in;
  vector<point>M,N;

  while(cin >> m,m){
    M.clear();
    N.clear();    

    for(int i=0; i< m; i++){
      cin >> in.x >> in.y;
      M.push_back(in);
    }
    
    cin >> n;

    for(int i=0; i< n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }

    sort(N.begin(),N.end(),cmp_x);

    point res=solve(M,N);

    cout << res.x <<" "<< res.y << endl;

  } 

  return 0;
}

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

#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=(m);i<(n);i++)
#define sz(x) ((x).size())

typedef vector<long long> vi;
typedef vector<vi> mat;

int N,M,A,B,C,T,S[55];

mat mul(mat& A,mat& B){
	int n=sz(A);
	mat C(n,vi(n));
	rep(i,n)rep(k,n)rep(j,n){
		C[i][j]=(C[i][j]+A[i][k]*B[k][j])%M;
	}
	return C;
}

mat pow(mat A,int e){
	int n=sz(A);
	mat B(n,vi(n));
	rep(i,n)B[i][i]=1;
	while(e){
		if(e&1)B=mul(B,A);
		A=mul(A,A);
		e>>=1;
	}
	return B;
}

int main2(){
	mat a(N,vi(N));
	rep(i,N){
		if(i>0)a[i][i-1]=A;
		a[i][i]=B;
		if(i<N-1)a[i][i+1]=C;
	}
	a=pow(a,T);
	rep(i,N){
		long long res=0;
		rep(j,N)res+=S[j]*a[i][j];
		cout<<res%M<<(i==N-1?"\n":" ");
	}
}

int main(){
	while(cin>>N>>M>>A>>B>>C>>T && N){
		rep(i,N)cin>>S[i];
		main2();
	}
}

Measured memory_bytes: 1296
#include <stdio.h>
#include <stdlib.h>

int task_C (const unsigned int* len_sequence, unsigned int val_sequence[])
{
	// variables for this function
	register unsigned int maxval_1st;
	register unsigned int maxval_2nd;
	register unsigned int maxval_answer;

	// support variables for this function
	register size_t itr;

	// STEP.01
	// initialize the variables to store the maximum values of given sequence
	maxval_1st = 0U;
	maxval_2nd = 0U;

	// STEP.02
	// search the maximum values of given sequence
	for (itr = 0; itr < *len_sequence; itr++)
	{
		if (maxval_1st < val_sequence[itr])
		{ 
			maxval_2nd = maxval_1st;
			maxval_1st = val_sequence[itr];
		}
		else if (maxval_2nd < val_sequence[itr])
		{
			maxval_2nd = val_sequence[itr];
		}
		else
		{
			continue;
		}
	}

	// STEP.03
	// output the answer of this task
	for (itr = 0; itr < *len_sequence; itr++)
	{
		if ( val_sequence[itr] != maxval_1st ) { maxval_answer = maxval_1st; }
		else                                   { maxval_answer = maxval_2nd; }
		
		printf("%d\n", maxval_answer);
	}

	// STEP.END
	return EXIT_SUCCESS;
}

#define len_sequence_max 200000U

int main (void)
{
	// variables for main process
	unsigned int N;
	unsigned int A[len_sequence_max];

	// support variables for main process
	int rtvl;

	// STEP.01
	// read out the given data
	// (the length of the given sequence)
	rtvl = scanf("%d", &N);

	// STEP.02
	// read out the given data
	// (the values of the given sequence)
	for (register size_t itr = 0; itr < N; itr++) { rtvl = scanf("%d", &A[itr]); }

	// STEP.03
	// calculate & output the answer of the task
	rtvl = task_C(&N, A);

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;

signed main(){
	
	int n,a[111111];
	cin>>n;
	int co=0,min=INF,sum=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]<0)co++;
		min=std::min(abs(a[i]),min);
		sum+=abs(a[i]);
	}
	if(co%2==0)cout<<sum<<endl;
	else cout<<sum-min*2<<endl;
	
}

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;
  cin >> n;

  cout << (n%2==0 ? n*n/4 : (n/2) * (n/2+1)) << endl;
}



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

int n, pt, px, py;
bool f = true;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int t, x, y;
		cin >> t >> x >> y;
		int d = abs(x - px) + abs(y - py);
		if(t - pt - d < 0 || (t - pt - d) % 2 != 0) f = false;
		pt = t;
		px = x;
		py = y;
	}
	cout << (f ? "Yes\n" : "No\n");
}

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

int n, m;
vector<int> a;
vector<int> b;

int main(){
while(1){


    cin >> n >> m;
    if(n == 0 and m == 0) break;
    int asum = 0, bsum = 0;


    for(int i=0; i < n; i++){
        int tmp;
        cin >> tmp;
        asum += tmp;
        a.push_back(tmp);
    }

    for(int i=0; i < m; i++){
        int tmp;
        cin >> tmp;
        bsum += tmp;
        b.push_back(tmp);
    }
    int flag = 1;
    int ares = 10000000, bres = 1000000;
    for(int i=0; i < n; i++){
        for(int j=0; j < m; j++){
            if(asum - a[i] + b[j] == bsum - b[j] + a[i]){
                if(ares + bres > a[i] + b[j]){
                    ares = a[i];
                    bres = b[j];
                    flag = 0;
                }
            }
        }
    }
    
    if(flag) cout << -1 << endl;
    else cout << ares << " " << bres << endl;

    a.clear();
    b.clear();
}

    return 0;
}



Measured memory_bytes: 3140
N,M = gets.split.map(&:to_i)
presents = []
results = {}
ac_counts = 0
penalty_counts = 0
M.times do |idx|
  tmp = gets.split
  q_num = tmp[0].to_i
  if tmp[1] == "AC"
    if results[q_num].nil?
      ac_counts += 1
      results[q_num] = {status: :AC, penalty: 0}
    else
      if results[q_num][:status] == :WA
        ac_counts += 1
        penalty_counts += results[q_num][:penalty]
        results[q_num][:status]= :AC
      end
    end
  else
    if results[q_num].nil?
      results[q_num] = {status: :WA, penalty: 1}
    else
      results[q_num][:penalty] += 1
    end
  end
end
puts "#{ac_counts} #{penalty_counts}"


Measured memory_bytes: 37116
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は log(N);
 */
const int mod = 1e9 + 7;
// pie = M_PI
//ここから書き始める
int main(){
	cout << setprecision(10);
	ll n ; cin >> n;
	//要素数nの配列を作るテンプレート
	vector<int> A(n);
	for(int i = 0 ; i < n; i ++){
		cin>>A[i];
	}

	ll ans = 0;
	rep(i,n){
		if(i+1==A[i]){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 //#define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


const int Mxn = 2e5+2;
int a[Mxn];

void solve()
{
  
  int n;
  cin >> n ;
  int an = 0;
  for(int i=0;i<n;i++) cin >> a[i];
  int mx = a[0];

  for(int i=1;i<n;i++)
  {
    an += max((int)0,mx - a[i]);
    mx = max(mx,a[i]);
  }
  
  cout<<an;

}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 5196
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

vector< vector<pair<int,int>> > graph(1, vector<pair<int,int> > () ) ;
int main()
{
	ios_base::sync_with_stdio(false);
	int n ; cin >> n;
	graph = vector< vector<pair<int,int> > > (n+1,vector<pair<int,int> > ()) ;

	vector<int> indegree(n+1) , extra(n+1) ;

	for(int i = 1 ; i < n; i++){
		int x , y ; cin >> x >> y ;
		indegree[x] ++;
		indegree[y] ++;
		graph[x].emplace_back(y,i) ;
		graph[y].emplace_back(x,i) ;

	}
	vector<int> color(n+1 , -1) ;

	for(int i = 1 ; i <= n ; i ++){
		if(indegree[i] == extra[i]) continue ;
		bool ase[n+1] = {} ;
		int point = 1 ;
		vector<int> t_point ;
		for(auto x : graph[i]){
			int t = x.second ;
			if(color[t] != -1){
				ase[color[t]] = true ;  
			}
			else t_point.emplace_back(t) , extra[x.first]++;
		}
		for(auto x : t_point){

			while(ase[point]){
				point ++ ;
			}
			color[x] = point ++ ;

		}
	}

	cout << *max_element(color.begin() , color.end() ) << endl ;
	for(int i = 1; i < n ; i++){
		cout << color[i] << endl ;
	}


    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
 
int main(void){
 
    int n,i,a;
    long min,max,sum;
    scanf("%d\n",&n);
 
    max = -1000000;
    min = 1000000;
    sum = 0;
 
    for(i=0; i<n; i++){
        scanf("%d\n",&a);
        if(max<a) max = a;
        if(min>a) min = a;
        sum += a;
    }
 
    printf("%ld %ld %ld\n",min,max,sum);
 
    return 0;
}

Measured memory_bytes: 604
# -*- coding: utf-8 -*-
import heapq
import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
INF = 2**62-1


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


def read_str_n():
    return list(map(str, input().split()))


def Dijkstra(g, s):
    d = defaultdict(lambda: INF)
    d[s] = 0
    q = []
    heapq.heappush(q, (d[s], s))

    prev = {}
    done = set()
    while q:
        c, u = heapq.heappop(q)
        if u in done:
            continue
        done.add(u)
        for v in g[u]:
            alt = g[u][v] + d[u]
            if d[v] > alt:
                d[v] = alt
                prev[v] = u
                heapq.heappush(q, (d[v], v))
    return d

def slv(N, M, S, UVAB, CD):
    g = defaultdict(dict)
    V = {}
    for u, v, a, b in UVAB:
        g[u][v] = (a, b)
        g[v][u] = (a, b)

    for i, (c, d) in enumerate(CD, 1):
        V[i] = (c, d)

    MA = (N-1)*max(a for u, v, a, b in UVAB)
    S = min(S, MA)
    d = [[INF] * (MA+1) for _ in range(N+1)]
    d[1][S] = 0
    q = []

    def p(q, u, m, alt):
        if m >= 0 and d[u][m] > alt:
            d[u][m] = alt
            heapq.heappush(q, (d[u][m], (u, m)))

    heapq.heappush(q, (d[1][S], (1, S)))
    while q:
        c, (u, s) = heapq.heappop(q)
        if d[u][s] < c:
            continue
        c, dd = V[u]
        if s != MA:
            p(q, u, min(MA, s+c), d[u][s] + dd)

        for v in g[u]:
            a, b = g[u][v]
            p(q, v, s-a, b + d[u][s])

    for i in range(2, N+1):
        print(min(d[i]))


def main():
    N, M, S = read_int_n()
    UVAB = [read_int_n() for _ in range(M)]
    CD = [read_int_n() for _ in range(N)]
    (slv(N, M, S, UVAB, CD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 95552
#include <cstdio>
#include <queue>
#include <utility>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

struct comp {
    bool operator()(const pair<ll, ll> a, const pair<ll, ll> b) {
        return a.second < b.second;
    }
};

int main()
{
    ll N, A;

    scanf("%lld", &N);

    priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, comp> data;
    map<ll, ll> m;
    map<ll, ll>::iterator mIt;

    ll n = 0;
    ll total = 0;
    ll mod = 2;

    while (N--) {
        scanf("%lld", &A);

        if (m.find(A) == m.end()) {
            m[A] = 1;
        } else {
            m[A]++;
        }

        total++;
    }

    for (mIt = m.begin(); mIt != m.end(); mIt++) data.push(make_pair(mIt->first, mIt->second));

    while (!data.empty()) {
        pair<ll, ll> p = data.top();

        if (2 <= p.second) n += p.second - 1;
        else break;

        data.pop();
    }

    if (n % mod == 1) printf("%lld\n", total - n - 1);
    else printf("%lld\n", total - n);

    return 0;
}


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

int main()
{

        int N;
        cin >> N;
        int a[N];
        int c1 = 0;
        int c2 = 0;
        int c4 = 0;
        for (int i = 0; i < N; ++i) {
                int tmp;
                cin >> tmp;
                if (tmp % 4 == 0) {
                        c4++;
                }
                else if (tmp % 2 == 0) {
                        c2++;
                }
                else {
                        c1++;
                }
        }

        if (c2 == 1) {
                c2 = 0;
                c1++;
        }

        if (c1 > 0 && c4 == 0) {
                cout << "No" << endl;
        }
        else if (c1 > c4+1) {
                cout << "No" << endl;
        }
        else if (c2 > 0 && c1 > c4) {
                cout << "No" << endl;
        }
        else {
                cout << "Yes" << endl;
        }

}


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

int main() {
    int N, a;
    cin >> N;
    map<int, int> mp;
    rep(i,N) {
        cin >> a;
        ++mp[a];
    }
    bool ok = true;
    if (N % 3 == 0 && mp[0] == N / 3) {
        for (auto x : mp) {
            if (x.first != 0 && x.second % 2 != 0) ok = false;
        }
    } else if (mp[0] != N && mp[0] > 0) ok = false;
    else if (mp[0] == 0) {
        if (mp.size()-1 != 3) ok = false;
        else {
            vector<int> num(4),cnt(4);
            int i = 0;
            for (auto x : mp) {
                num.at(i) = x.first;
                cnt.at(i) = x.second;
                ++i;
            }
            rep(i,3) if ((num.at(i%3+1) ^ num.at((i+1)%3+1)) != num.at((i+2)%3+1)) ok = false;
            rep(i,3) if (cnt.at(i%3+1) != cnt.at((i+1)%3+1)) ok = false;
        } 
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 7112
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS=1e-10;




int main(){
    LL A,B,C,K;
    cin>>A>>B>>C>>K;
    if(A!=B){
        if(K%2==0){
            cout<<A-B<<endl;
        }else{
            cout<<B-A<<endl;
        }
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace::std;
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}

int main(){
    string s;
    int k;
    cin>>s>>k;
    //dp[s.size()][2][k+1]の三次元配列を作る
    auto dp=make_vector<int>(-1,s.size(),2,k+1);
    //d:見た桁
    //b:今まで見た桁で超えてるかどうか
    //t:0以外を何個とったか
    auto f=[&](auto f,int d,bool b,int t)->int{
        //k個以上取ったら無条件で消す
        if(t>k)return 0;
        //すべての桁を見終わって条件を満たすなら1を返す
        if(d==(int)s.size()){
            return k==t;
        }
        //以前に呼んだのをもう一回呼ぶ際はメモっておいたやつを呼ぶ
        if(dp[d][b][t]!=-1)return dp[d][b][t];
        //取れる最大の桁をmxに入れる
        int mx=b?9:s[d]-'0';
        int ans=0;
        //取れる桁を回す
        for(int i=0;i<=mx;++i){
            ans+=f(f,d+1,b||(i!=mx),t+(i!=0));
        }
        return dp[d][b][t]=ans;
    };
    cout<<f(f,0,0,0)<<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	vi a,b,c;
	scanf("%d",&n);
	int bil;
	for(i=0;i<n;i++){scanf("%d",&bil); a.pb(bil);}
	for(i=0;i<n;i++){scanf("%d",&bil); b.pb(bil);}
	for(i=0;i<n;i++){scanf("%d",&bil); c.pb(bil);}
	sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(c.begin(),c.end());
	vi listIdxB,listBanyakCaraC;
	for(i=0;i<n;i++){
		// if(i){printf(" ");}
		// printf("i: %d\n",i);
		int idxB = lower_bound(b.begin(),b.end(), a[i]+1) - b.begin();
		if(idxB!=n){
			if(b[idxB]==a[i]){
				//cari sampe ketemu lebih besar
				int j = lower_bound(b.begin(),b.end(),a[i]+1) - b.begin();
				
				listIdxB.pb(j);
			}else{
				listIdxB.pb(idxB);
			}
		}else{
			listIdxB.pb(idxB);
	//		printf("masuk idxB: %d\n",idxB);
		}
		//printf("%d(idxB: %d)",a[i],idxB);

	}
	
	for(i=0;i<n;i++){
		//if(i){printf(" ");}
		int idxC = lower_bound(c.begin(),c.end(), b[i]+1) - c.begin();
		if(idxC!=n){
			if(c[idxC]==b[i]){
				int j = lower_bound(c.begin(),c.end(),b[i]+1) - c.begin();
				listBanyakCaraC.pb((ll)n-((ll)j));
			}
			else{listBanyakCaraC.pb((ll)n-idxC);}
		}else{
			listBanyakCaraC.pb((ll)n-idxC);
		}
		//printf("%d(idxC: %d banyakCara: %d)",b[i],idxC,n-idxC);
	}
	// printf("\n");
	// printf("listIdxB\n");
	// for(i=0;i<n;i++){
	// 	if(i){printf(" ");}
	// 	printf("%d",listIdxB[i]);
	// }
	// printf("\n");
	// printf("listBanyakCaraC size: %d\n",listBanyakCaraC.size());
	// for(i=0;i<n;i++){
	// 	if(i){printf(" ");}
	// 	printf("%d",listBanyakCaraC[i]);
	// }
	// printf("\n");
	vector<ll> listPrefixSum;
	listPrefixSum.assign(n+1,0);
	for(i=0;i<n;i++){
		if(i==0){listPrefixSum[i] = (ll)listBanyakCaraC[i];}
		else{listPrefixSum[i] = (ll)listBanyakCaraC[i] + (ll)listPrefixSum[i-1];}
	}
	ll sum = listPrefixSum[n-1];
	ll ans = 0;
	for(i=0;i<n;i++){
		int idx = listIdxB[i];
		if(idx-1<0){ans+=sum;}
		else{ans+=(sum-listPrefixSum[idx-1]);}
	}
	printf("%lld\n",ans);
	
	return 0;
};

Measured memory_bytes: 5108
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<int,int> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((b-a)==(c-b))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;

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

Measured memory_bytes: 3632
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSArray *arr = [s componentsSeparatedByString:@" "];
        NSInteger a = [[arr objectAtIndex:0] integerValue];
        NSInteger b = [[arr objectAtIndex:1] integerValue];
        NSInteger c = [[arr objectAtIndex:2] integerValue];
        
        NSString *answer = [NSString stringWithFormat:@"%ld",MIN(a+b,MIN(a+c,b+c))];
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    
    return 0;
}


Measured memory_bytes: 2404
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int N;
long long int S[500005];

multiset<long long int, greater<long long int> >  G, R;
int M;


long long int INF = 99999999999;
int main(void) {

	cin >> N;

	for (int i = 1; i <= (1 << N); i++) {
		cin>>S[i];
	}

	M = 1 << N;
	for (int i = 1; i <= M; i++) {
		R.insert(S[i]);
	}

	auto it = R.begin();
	G.insert(*it);
	R.erase(it);

	R.insert(-INF);
	vector<long long int >V;

	for (int i = 1; i <= N; i++) {
		V.clear();
		auto it = R.begin();
		for (auto y : G) {
			while (y <= (*it)) { it++; }
			if (*it == -INF) { cout << "No" << endl; return 0; }
			V.push_back(*it);
			it = R.erase(it);
		}
		for (auto h : V) { G.insert(h); }
		//cout << " --- G: "; for (auto y : G) { cout << " " << y; }cout << endl;
		//cout << " --- R: "; for (auto y : R) { cout << " " << y; }cout << endl;

	}



	//cout << " --- G: "; for (auto y : G) {cout <<" " <<  y;}cout << endl;
	//cout << " --- R: "; for (auto y : R) {cout <<" " << y; }cout << endl;

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 15740
/**Which of the favors of your Lord will you deny ?**/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second
#define INF INT_MAX

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>
using indexed_set = tree<
                    TIn, null_type, less<TIn>,
                    rb_tree_tag, tree_order_statistics_node_update>;

/*
PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

*/

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

string to_str(LL x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int main()
{
    optimizeIO();


    double r;
    cin>>r;

    cout<<2*acos(-1)*r<<endl;

    return 0;
}




Measured memory_bytes: 3832
#include<stdio.h>

int main(){
	int a,b=200000,i,c,sum=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&c);
		if(i==1){
			sum=c-b;
			if(b>c)b=c;
			continue;
		}
		if(i==0){
			b=c;
			continue;
		}
		if(sum<c-b){
			sum=c-b;
		}
		if(b>c)b=c;
	}
	printf("%d\n",sum);
	return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<int> d(3, -1);
	rep (i, m) {
	  int s, c;
	  cin >> s >> c;
	  if (d[s - 1] != -1 && d[s - 1] != c) {
		cout << -1 << endl;
		return 0;
	  }
	  d[s - 1] = c;
	}
	rep (i, 1000) {
	  string s = to_string(i);
	  if (s.size() != n) continue;
	  bool ok = true;
	  rep (j, n) {
		if (d[j] == -1) continue;
		if (s[j] != ('0' + d[j])) ok = false;
	  }
	  if (ok) {
		cout << i << endl;
		return 0;
	  }
	}
	cout << -1 << endl;
    
    return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;


struct node
{
  LL S,W;
};


bool comp(node a,node b)
{
  return a.S - b.W > b.S - a.W; 
}


int main()
{
  
      LL n;
      cin>>n;
      vector<node> stones(n);

      

      for(LL i=0;i<n;i++)
      {
        cin>>stones[i].S>>stones[i].W;
      }

      sort(stones.begin(), stones.end(), comp);


      vector<LL> dp(n+1,-1e18);

      
      for(int j=0;j<n;j++)
      {

        for(int i = n;i>=0;i--)
        {
          if(i!=1 && dp[i-1]>=stones[j].W)
          {
            dp[i] = max(dp[i],min(stones[j].S,dp[i-1]-stones[j].W));
          }
          else if(i==1)
            dp[i] = max(dp[i],stones[j].S);
        }
      }


      
      LL ans = 0;
      for(int i=1;i<=n;i++)
      {
        if(dp[i]<0) break;
        ans++;
      }

    



      cout<<ans<<endl;
 
}

  


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys

N, M, *AB = map(int, sys.stdin.buffer.read().split())

list_path = [[] for _ in range(N+1)]

for i in range(M):
  A,B = AB[2*i:2*i+2]
  list_path[A].append(B)
  list_path[B].append(A)

list_bfs = [1]
list_flg = [0 for _ in range(N+1)]
list_flg[1] = 1

while len(list_bfs)>0:
  list_tmp = []
  for i in list_bfs:
    for j in list_path[i]:
      if list_flg[j]==0:
        list_tmp.append(j)
        list_flg[j] = i
  list_bfs = list_tmp

print('Yes')
for i in list_flg[2:]:
  print(i)


Measured memory_bytes: 46016
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

n,a,b=rl()

print(min(a*n,b))

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

vector<int> adj[1 << 20];
int chk[1 << 20][2];

void dfs(int u, int dis) {
	for (int v : adj[u]) {
		if (chk[v][dis ^ 1]) continue;
		chk[v][dis ^ 1] = 1;
		dfs(v, dis ^ 1);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	chk[1][0] = 1;
	dfs(1, 0);
	long long ans = (long long)n * (n - 1) / 2 - m;
	int cnt = 0;
	for (int i = 1; i <= n; i++) if (chk[i][0] && !chk[i][1]) cnt++;
	ans = ans - (long long)cnt * (cnt - 1) / 2;
	cnt = 0;
	for (int i = 1; i <= n; i++) if (!chk[i][0] && chk[i][1]) cnt++;
	ans = ans - (long long)cnt * (cnt - 1) / 2;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 33956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll N=400;
string S;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(false);
	map<char,ll> cnt;
	cin>>N>>S;
	ll ans=0;
	REP(i,N){
		cnt[S[i]]++;
	}
	ans=cnt['R']*cnt['G']*cnt['B'];
	REP(i,N){
		FOR(j,i+1,N){
			ll k=2*j-i;
			if(S[i]==S[j])continue;
			if(k<N && S[k]!=S[i]&&S[k]!=S[j]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
int INF=1e9;
int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
double EPS = 1e-10;
const int mod=1e9+7;
const double pai=3.14159265358979;
int main(){
	int n;
	cin>>n;
	cout<<n*800-(n/15)*200<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string n;
    cin >> n;
    if (n.at(0) == '7'||n.at(1) == '7'||n.at(2) == '7') {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 3580
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-02-22 19:02:57
                2020-03-09 22:42:07
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007
#define cout_precision(x) cout << fixed << setprecision(x)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n+1, 0.0);
    for (int i = 1; i <= n; i++)
        cin >> p[i];

    vector<double> e(n+1, 0.0);
    for (int i = 1; i <= n; i++)
        e[i] = (0.5)*(p[i] + 1);

    vector<double> t(n+1, 0.0);
    for (int i = 1; i <= n; i++)
        t[i] = t[i-1] + e[i];

    double ans = 0.0;
    for (int i = k; i <= n; i++) {
        double sum = t[i] - t[i-k];
        if (ans < sum) ans = sum;
    }

    printf("%.12f\n", ans);
    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, k, c;
    cin >> n >> k >> c;

    string s;
    cin >> s;

    vector<int> pf, sf;
    int d = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o')pf.push_back(i + 1), d++, i += c;
        if (d == k + 1)break;
    }
//    for(auto x: pf)cout << x << endl;
    d = k;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o')sf.push_back(i + 1), d--, i -= c;
        if (d == 0)break;
    }
//    for(auto x: sf)cout << x << endl;

    reverse(sf.begin(), sf.end());
    for (int i = 0; i < sf.size(); i++) {
        if (sf[i] == pf[i])cout << sf[i] << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 8096
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

dp1=[0]*N
dp2=[0]*N

for i in range(N):
    if i == 0:
        dp1[0] = A1[0]
        continue
    dp1[i] = dp1[i-1]+A1[i]
for i in range(N):
    if i == 0:
        dp2[0] = dp1[0]+A2[0]
        continue
    dp2[i] = max(dp2[i-1]+A2[i],dp1[i]+A2[i])
print(dp2[N-1]) 

Measured memory_bytes: 38256
// inputに入力データ全体が入る
function Main(input) {
  var input = input.split('\n');
  var answer;

  var nums = input[0].split(' ');
  nums = nums.map((e) => parseInt(e));

  answer = nums[0] + nums[1] >= nums[2];

  // 出力
  console.log(answer ? 'Yes' : 'No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<pair<int, int>> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i].first;
    b[i].second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < a.size(); i++) {
    if (a[i].first > b[i].first) {
      cout << "No";
      return 0;
    }
  }
  /*
  for (int i = 0; i < a.size(); i++) {
    if (a[i].second == b[i].second) {
      cout << "Yes";
      return 0;
    }
  }*/
  for (int i = 0; i < a.size() - 1; i++) {
    if (a[i+1].first <= b[i].first) {
      cout << "Yes";
      return 0;
    }
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[a[i].second] = b[i].second;
  }
  int cur = p[0];
  int len = 1;
  while (cur != 0) {
    len++;
    cur = p[cur];
  }
  if (len < n) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 2176
# ABC160a


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int N, M;
int A[111111];

int main(void) {
	int i;
	int hoge = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		hoge += A[i];
	}
	printf("%d\n", N >= hoge ? N - hoge : -1);
	return 0;
}


Measured memory_bytes: 1772
n = input()

for i in range(0, 0b1000):
    num = int(n[0])
    op = []
    for j in range(3):
        if (i & 1 << j):
            num += int(n[j+1])
            op.append("+")
        else:
            num -= int(n[j+1])
            op.append("-")
    if num == 7:
        for k in range(3):
            print("{0}{1}".format(n[k], op[k]), end="")
        print("{0}=7".format(n[3]))
        break

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    int ans = inf;
    rep(i, n) {
        int cnt = 0, a; std::cin >> a;
        while (a%2 == 0) a /= 2, cnt++;
        chmin(ans, cnt);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  if(x % 11 == 0) cout << ans << endl;
  else if(x % 11 >= 7) cout << ans + 2 << endl;
  else cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#define lli long long int
#define fl(i, a, b) for(int i = a; i < b; ++i)
#define fl2(i, a, b) for(int i = a; i <= b; ++i)
#define rfl(i, a, b) for(int i = a; i > b; --i)
#define rfl2(i, a, b) for(int i = a; i >= b; ++i)
#define all(v) ((v).begin(), (v).end())
#define all2(v) ((a) + 0, (a) + n);
#define sz(s) (s).size()
#define OO (lli)1e18
#define MIN INT_MIN
#define f first
#define s second		
#define mp make_pair
#define pb puch_back
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
using namespace std;

lli power(lli x, lli y) {
	lli i, power = 1;
	if (y == 0)
		return 1;
	for (i = 1; i <= y; i++)
		power = power * x;
	return power;
}

int32_t main() {

	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	//freopen("overcode.in","r",stdin);
	//freopen("output.txt", "w", stdout);

	clock_t z = clock();

	double a[51];
	int n;
	cin >> n;
	fl(i, 0, n)cin >> a[i];
	sort(a + 0, a + n);
	int sum = 0;
	fl(i, 1, n) {
		a[i] = (a[i - 1] + a[i]) * 1.0 / 2;
	}
	cout << a[n - 1] << '\n';
	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer;

public class Main {
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main(String[] args){
        IO fs = new IO();
        int [] a = new int[3];
        for(int i = 0; i<3; i++){
            a[i] = fs.nextInt();
        }
        Arrays.sort(a);
        if(a[0] ==5 && a[1] ==5 && a[2] ==7)System.out.println("YES");
        else System.out.println("NO");
    }
}


Measured memory_bytes: 24864