akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){
        cin >> v.at(i);
    }
    int sum = 0;
    for(int i = 0; i < n-1 ; i++){
        for(int j=i+1;j<=n-1;j++){
            sum += v.at(i) * v.at(j);
        }
    }
        cout << sum << endl;
    return 0;
}




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

int main(){
  
  int s,s1,s2,s3;
  cin >> s;
  s1 = s/100;
  s2 = (s - s1*100)/10;
  s3 = s - (s1*100) - (s2*10);
  cout << s1 + s2 + s3 << endl;
}  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>
#include <cmath>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    (void)scanf("%d", &i);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    (void)scanf("%lld", &i);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    (void)printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    (void)printf("%lld", i);
    return my;
}

constexpr char BR = '\n';

///////////////////////////////////////////////////

ll sn(ll n)
{
    return (ll)n * (n+1) / 2;
}

int main()
{
    int N;
    io >> N;

    ll ans = 0;
    int sqN = (int)sqrt(N);
    for (int k = 1; k <= sqN; ++k)
        ans += (sn(N/k) - sn(k)) * k * 2 + k * k;
    io << ans << BR;
}


Measured memory_bytes: 3752
X, Y = [int(_) for _ in input().split()]

#        1  2  3  4  5  6  7  8  9 10 11 12
gs = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]

if gs[X] == gs[Y]:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 2940
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  std::string str;
  std::cin >> str;
  auto A = std::count(str.begin(), str.end(), 'A');
  auto B = std::count(str.begin(), str.end(), 'B');
  std::cout << (A == 3 || B == 3 ? "No" : "Yes") << std::endl;
  return 0;
}



Measured memory_bytes: 256
l,r=map(int,input().split())
n=(l//2019)
l-=2019*n;r-=2019*n
if 2019<=r:print(0);exit()
ans=2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
  string s;cin>>s;
  sort(s.begin(),s.end());
  if(s=="abc") cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 

using namespace std;
int dp[1001][1001];
void print(int h, int w){
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << dp[i][j] <<" ";
		}cout <<endl;
	}
}
int main(){
	int h, w;
	cin >> h >> w;
	//vector<vector<int>> a(h, vector<int>(w));
	memset(dp, 0, sizeof(dp));
	dp[h-1][w-1] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char x;
			cin >> x;
			// a[i][j] = x == '.' ? 0: 1;
			if(x == '#')dp[i][j] = -1;
		}
	}
	//print(h, w);
	for(int j = w-2; j >= 0; j--){
		if(dp[h-1][j] == -1)continue;
		if(dp[h-1][j+1] != -1)dp[h-1][j] = dp[h-1][j+1];
		else dp[h-1][j] = -1;
	}
	//print(h, w);
	for(int i = h-2; i >= 0; i--){
		if(dp[i][w-1] == -1)continue;
		if(dp[i+1][w-1] != -1)dp[i][w-1] = dp[i+1][w-1];
		else dp[i][w-1] = -1;
	}
	//print(h, w);
	for(int i = h-2; i >= 0; i--){
		for(int j = w-2; j >= 0; j--){
			if(dp[i][j] == -1)continue;
			if(dp[i+1][j] == -1 && dp[i][j+1] == -1){
				dp[i][j] = -1;
			}
			else if(dp[i+1][j] == -1){
				dp[i][j] = dp[i][j+1];
			}
			else if(dp[i][j+1] == -1){
				dp[i][j] = dp[i+1][j];
			}
			else {
				dp[i][j] = (dp[i+1][j]%mod + dp[i][j+1]%mod)%mod;
			}
		}
	}
	if(dp[0][0] != -1){
		cout << dp[0][0] << endl;
	}
	else cout << 0 << endl;
	//print(h, w);

}

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long X,Y,N,ans;
  cin>>X>>Y;
  N=Y/X;
  ans=1;
  while(N>=2){
    N/=2;
    ans+=1;
  }
  cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a=0,b,c,n;
    cin>>n;
    l(i,1,n+1)
    {
        if(i%3==0||i%5==0)
        {
         //   a=a+i;
        }
        else{a=a+i;}
    }
    cout<<a<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a[100002];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (n * (n + 1) / 2) != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll lar[100002] {0};
    ll sumlar = 0;
    ll t = sum / (n * (n + 1) / 2);
    for(int i = 0; i < n; i++){
        if((a[i] + t - a[(i + 1) % n]) % n != 0){
            cout << "NO" << endl;
            return 0;
        }
        lar[i] = (a[i] + t - a[(i + 1) % n]) / n;
        sumlar += lar[i];
    }
    if((t - sumlar) % n != 0){
        cout << "NO" << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        lar[i] += (t - sumlar) % n;
        if(lar[i] < 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1792
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int a[N] = { };
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	ll n, ans = 1;
	cin >> n;
	lp(i,1,n)
		a[i] = i;
	lp(i,2,n)
	{
		ll cnt = 1;
		lp(j,1,n)
		{
			while (a[j] % i == 0)
				a[j] /= i, cnt++;
		}
		ans *= cnt;
		ans %= mod;
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n, x, y;
	cin >> n >> x >> y;
	vector<ll>dist(n + 1);
	for (ll i = 1; i <= n; i++) {
		for (ll j = i + 1; j <= n; j++) {
			if (i == x && j == y)
				dist[1]++;
			else if (x <= i && j <= y) {
				dist[min(j - i, i - x + 1 + y - j)]++;
			}
			else if((i <= x && j <= x) || (i >= y && j >= y)) {
				dist[j - i]++;
			}
			else if(i<=x && j>=y) {
				dist[x - i + 1 + j - y]++;
			}
			else if(i<=x && j<=y && j>=x) {
				dist[x - i + min(y- j + 1,j-x)]++;
			}
			else if (i <= y && i>=x && j >= y) {
				dist[j - y + min(y - i, i - x + 1)]++;
			}
		}
	}
	for (int i = 1; i < n; i++)
		cout << dist[i] << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;

const int MAX = 3e5 + 10;


int main()
{
	int n; cin>>n;
	int l=0,r=n-1;
	cout<<0<<endl;
	string L; cin>>L;
	if(L=="Vacant") return 0;

	while(r-l>1) {
		int mid = (l+r)/2;
		string M;
		cout<<mid<<endl;
		cin>>M;

		if(M=="Vacant") return 0;

		int left=mid-l+1;

		if(left%2==1 and L==M){
			L=M;
			l=mid;
		} //move right

		else if(left%2==0 and L!=M){
			L=M;
			l=mid;
		} //move right	

		else {
			r=mid;
		} //move left	
	}
	cout<<r<<endl;
	cin>>L;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a=0;
    int b=0;
    int c=0;
    for(int i=0;i<3;i++){
        if(s[i]=='a')a++;
        else if(s[i]=='b')b++;
        else c++;
    }
    if(a==0 || b==0 || c==0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    
    ll alice,bob;cin>>alice>>bob;
    if(alice==1)alice+=100;if(bob==1)bob+=100;
    ll a=1000000000000;
    for(long long int i=1;i<=a;i++){
        alice++;
        bob++;
    }
    if(alice==bob)printf("Draw");
    else if(alice<bob)printf("Bob");
    else printf("Alice");
    
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	if( n == 1 ){
          n = 0;
        }else{
          n = 1;
        }
      	System.out.println(n);
	}
}

Measured memory_bytes: 27080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		HashMap<Integer, Integer> hmNbrs = new HashMap<Integer, Integer>();
		ArrayList<Integer> alNotAddNbrs = new ArrayList<Integer>();

		//get
		for(int i = 0; i < 28; i++) {
			hmNbrs.put(Integer.parseInt(bufferedReader.readLine()), 1);
		}

		//pull
		for(int i = 0; i < 30; i++) {
			if(hmNbrs.get(i + 1) == null) alNotAddNbrs.add(i + 1);
		}

		//sort
		int[] arrResult = new int[alNotAddNbrs.size()];

		if(alNotAddNbrs.get(0) < alNotAddNbrs.get(1)) {
			arrResult[0] = alNotAddNbrs.get(0);
			arrResult[1] = alNotAddNbrs.get(1);
		} else {
			arrResult[1] = alNotAddNbrs.get(0);
			arrResult[0] = alNotAddNbrs.get(1);
		}

		for(int i = 0; i < arrResult.length; i++) System.out.println(arrResult[i]);
	}






}


Measured memory_bytes: 24200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
const int N=1e5+5;

int n;
int a[N];

int dp[N];




int main()
{
  int i;
  int mx=0;

  cin>>n;
  for(i=1;i<=n;i++)
  {
      scanf("%d",&a[i]);
  }

  for(i=1;i<=n;i++)
  {
      dp[a[i]]++;
      dp[a[i]+1]++;
      dp[a[i]-1]++;
  }

  for(i=0;i<=N-3;i++)
  {
      mx=max(mx,dp[i]);
  }

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


  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;

struct choice
{
    ll x, y, z;
    ll v;
    choice(ll _x, ll _y, ll _z, ll _v)
    {
        x = _x;
        y = _y;
        z = _z;
        v = _v;
    }
};

bool operator< (const choice& l, const choice& r)
{
    return l.v < r.v;
}

ll hash_choice(const choice& c)
{
    return c.x * 1000000 + c.y * 1000 + c.z;
}

void add_cand(const choice& c, priority_queue<choice>& que)
{
    static set<ll> mark;
    if (mark.find(hash_choice(c)) != mark.end()) return;
    que.push(c);
    mark.insert(hash_choice(c));
}

int main()
{
    ll X, Y, Z, K;
    vector<ll> A, B, C;
    cin >> X >> Y >> Z >> K;
    ll temp;
    for (ll x = 0; x < X; x++) {
        cin >> temp;
        A.push_back(temp);
    }
    for (ll y = 0; y < Y; y++) {
        cin >> temp;
        B.push_back(temp);
    }
    for (ll z = 0; z < Z; z++) {
        cin >> temp;
        C.push_back(temp);
    }

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    priority_queue<choice> que;
    set<ll> mark;
    que.push(choice(0, 0, 0, A[0] + B[0] + C[0]));
    for (ll i = 0; i < K; i++) {
        choice c = que.top();
        cout << c.v << endl;
        que.pop();
        if (c.x < X - 1) {
            add_cand(choice(c.x + 1, c.y, c.z, A[c.x + 1] + B[c.y] + C[c.z]), que);
        }
        if (c.y < Y - 1) {
            add_cand(choice(c.x, c.y + 1, c.z, A[c.x] + B[c.y + 1] + C[c.z]), que);
        }
        if (c.z < Z - 1) {
            add_cand(choice(c.x, c.y, c.z + 1, A[c.x] + B[c.y] + C[c.z + 1]), que);
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int *a, *b;
    cin >> n;
    a = new int[n + 1];
    b = new int[n + 1];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        ++c[a[i]];
    }
    int i;
    for (i = 0; i <= MAX; ++i)
    {
        if (c[i])
        {
            --c[i];
            cout << i;
            break;
        }
    }
    for (;i <= MAX; ++i)
    {
        while (c[i])
        {
            --c[i];
            cout << ' ' << i;
        }
    }
    cout << endl;
    return 0;
}
 

Measured memory_bytes: 10960
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N, K; cin >> N >> K;
    vec t(N), d(N);
    REP(i, N){
        cin >> t[i] >> d[i];
        t[i]--;
    }
    vector<Pii> p(N);
    REP(i, N) p[i] = Pii(d[i], t[i]);
    Sort(p); Reverse(p);
    
    int tmp = 0;
    vec cnt(N, 0);
    int v = 0;
    priority_queue<int, vector<int>, greater<int>> que;
    REP(i, K){
        tmp += p[i].first;
        cnt[p[i].second]++;
        if(cnt[p[i].second] >= 2) que.push(p[i].first);
        else v++;
    }
    int ans = tmp + v * v;

    FOR(i, K, N){
        if(que.empty()) break;
        if(cnt[p[i].second] >= 1) continue;
        cnt[p[i].second]++;
        int a = que.top(); que.pop();
        tmp -= a;
        tmp += p[i].first;
        v++;
        Max(ans, tmp + v * v);
    }
    cout << ans;

    return 0;
}

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


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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    ll i,n,m,k,c=0,sum=0;
    c_p_c();

    cin>>n;
    ll ans = 1;
   	for (int i = 1; i <=n; ++i)
   	{
   		/* code */
   		ans=(ans*i)%MOD;
   	}
   	cout<<ans<<endl;

 	return 0;

   }

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

using namespace std;

main(){
	int a,b,c,d,A;
	cin >> a >> b >> c >> d;
	A=a+b+c+d;
	int e,f,g,h,B;
	cin >> e >> f >> g >> h;
	B=e+f+g+h;
	if(A > B){
		printf("%d\n",A);
	}
		else if(A < B){
			printf("%d\n",B);
		}
		else{
			printf("%d\n",A);
		}
}


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

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

int weekToInt(string x){
    int num;
    if(x == "SUN"){
        num = 1;
    }else if(x == "MON"){
        num = 2;
    }else if(x == "TUE"){
        num = 3;
    }else if(x == "WED"){
        num = 4;
    }else if(x == "THU"){
        num = 5;
    }else if(x == "FRI"){
        num = 6;
    }else if(x == "SAT"){
        num = 7;
    }else{
        num = 0;
    }

    return num;
}

int main(){
    int A, B;
    cin >> A >> B;

    if(A > B*2){
        cout << A - B*2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    long long ans = 0;
    ans += min(k, n) * x;
    ans += max(0, n-k) * y;
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    int n, k;
    vector<int> a;

    cin >> n >> k;
    a.resize(n);
    for (int &elem : a) {
        cin >> elem;
    }

    vector<int> dp(n + 1);
    dp[0] = dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        int cur = dp[i - 1] + abs(a[i - 1] - a[i - 2]);
        for (int j = i - 1; j >= max(1, i - k); --j) {
            cur = min(cur, dp[j] + abs(a[i - 1] - a[j - 1]));
        }
        dp[i] = cur;
    }

    cout << dp[n] << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

	vvi point(N, vi(2));
	REP(i, N) {
		point[i][1] = i;
	}

	int a, b, c, d;
	REP(i, N*(N-1)/2) {
		cin >> a >> b >> c >> d;
		if(c < d) {
			point[b-1][0] += 3;
		} else if(c > d) {
			point[a-1][0] += 3;
		} else {
			point[a-1][0]++;
			point[b-1][0]++;
		}
	}

	sort(RALL(point));

	int prev = -1, t = 0;
	vi rank(N);
	REP(i, N) {
		if(point[i][0] == prev) {
			t++;
			rank[point[i][1]] = i+1-t;
		} else {
			t = 0;
			rank[point[i][1]] = i+1;
		}
		prev = point[i][0];
	}

	REP(i, N) {
		cout << rank[i] << endl;
	}
}

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

int N;
bool visited[1005];
char a[1005][1005];
int cnt=0,k=0,cc,t[2];

void dfs(int pos){
  if(visited[pos])return;
  visited[pos]=true;
  cc++;
  for(int i=0;i<N;i++)
    if(a[pos][i]=='Y')
      dfs(i);
}

int main(){ 
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%s",a[i]);
    for(int j=0;j<i;j++)
      if(a[i][j]=='Y')cnt++;
  }
  for(int i=0;i<N;i++){
    if(visited[i])continue;
    k++;
    cc=0;
    dfs(i);
    t[cc%2]++;    
  }
  int total=N*(N-1)/2;
  if(t[0]==1&&t[1]==2){
    cout<<"Taro"<<endl;
    return 0;
  }
  int f=(t[0]==0&&t[1]==2?0:1);
  if((total-cnt)%2==f)cout<<"Taro"<<endl;
  else cout<<"Hanako"<<endl;
  return 0;
}

Measured memory_bytes: 4140
N = int(input())
b = input().split()
a = list(map((lambda x: int(x)), b))

_max = max(a)
_min = min(a)
result = 20000 * N

for i in range(_min,_max+1,1):
  _result = 0
  for j in a:
    _result += (i - int(j))**2
  if _result <= result:
    result = _result
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int ans;
char s[4],t[4];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s %s",s+1,t+1);
	for (int i=1;i<=3;i++)
		if (s[i]==t[i]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

using namespace std;

const int N = 2001;
const long long INF = 1e9 + 1;

int main()
{
	int n, X;
	cin >> n >> X;
	int al[N];
	long long min = INF;
	int pos;
	for(int i = 0; i != n; ++i){
		cin >> al[i];
	}
	long long ans = 0;
	long minc[N][2];
	for(int i = 0; i != n; ++i){
		minc[i][0] = al[i];
		ans += minc[i][0];
	}
	for(int k = 1; k != n; ++k){
		long long tmp = 0;
		for(int i = 0; i != n; ++i){
			minc[i][1] = MIN(minc[i][0], al[(i - k + n) % n]);
			tmp += minc[i][1];
		}
		tmp += k * X;
		if(tmp < ans){
			ans = tmp;
		}
		for(int i = 0; i != n; ++i){
			minc[i][0] = minc[i][1];
		}
	}
	cout << ans << endl;
}



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

int main(int argc, char const *argv[])
{
  int antenas[5], leng;

  for(int i = 0;i < 5;i++){
    cin >> antenas[i];
  }
  cin >> leng;
  for(int i = 0; i < 5; i++){
    for(int j=i+1; j < 5; j++){
      if(antenas[j] - antenas[i] > leng){
        cout << ":(" << endl;
        goto LABEL;
      }
    }
  }
  
  cout << "Yay!" << endl;
  LABEL:
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// editorial 
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9423616

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    
    vector<ll> j(n);
    j[0] = 1;
    rep3(i, 1, n) (j[i] = modpow(i + 1, inf - 2, inf)) %= inf;
    
    ll sigj = 0;
    rep(i, n - 1) {
        (sigj += j[i]) %= inf;
        (ans += (a[i + 1] - a[i]) * sigj % inf) %= inf;
    }
    
    rep3(i, 2, n) {
        (ans *= i) %= inf;
    }
    
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





Measured memory_bytes: 1792
a = [] 
for i in xrange(0,4):
    b = []
    for j in xrange(0,3):
        b.append([0]*10)
    a.append(b)
n = int(raw_input())
for i in xrange(0,n):
    b,f,r,v = map(int,raw_input().split())
    a[b-1][f-1][r-1] += v
for i,arr in enumerate(a):
    for j in arr:
        print " "+" ".join(map(str,j))
    if i != len(a)-1:
        print "#"*20

Measured memory_bytes: 4228
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


int expr(const char **);
int term(const char **);
int factor(const char **);
int number(const char **);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

signed main() {
  int n;
  scanf("%d", &n);
  char s[101];
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), b(n), cnt(pow(10,5)+1,0);
	rep(i, n)cin >> a[i] >> b[i];
	for (ll i = 0; i < n; i++) {
		cnt[a[i]] += b[i];
	}
	for (ll i = 1; i <= pow(10,5); i++) {
		k -= cnt[i];
		if (k <= 0)return cout << i << endl, 0;
	}
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<int>>s(h,vector<int>(w,0));
    int count=0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            char c;
            cin>>c;
            if(c=='#'){
                ++count;
                s[i][j]=count;
            }
        }
        for(int j=1;j<w;++j){
            if(s[i][j]==0)s[i][j]=s[i][j-1];
        }
        for(int j=w-2;j>=0;--j){
            if(s[i][j]==0)s[i][j]=s[i][j+1];
        }
    }
    for(int i=0;i<w;++i){
        for(int j=1;j<h;++j){
            if(s[j][i]==0)s[j][i]=s[j-1][i];
        }
        for(int j=h-2;j>=0;--j){
            if(s[j][i]==0)s[j][i]=s[j+1][i];
        }
    }
    for(int i=0;i<h;++i){
        for(int  j=0;j<w;++j){
            cout<<s[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int a,b,c,d=0;
  scanf("%d %d %d",&a,&b,&c);
  for(;a<=b;a++){
    if(c % a == 0){
      d++;
    }   
  }
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private final byte MASK_RIGHT = 0x0F;//右4bit数値化用マスク
	private int[][] paper = new int[10][10];//都合の良い方眼紙

	public static void main(String[] args) throws NumberFormatException, IOException {
		new Main().execute();
	}

	private void execute() throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > max) {
					max = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16844
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define nmax
#define pii pair<int,int>
#define inf
using namespace std;

int main() {
    long long a, b;
    cin>>a>>b;
    long long gc = __gcd(a, b);
    long long ans = a * b / gc;
    cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

def calc(n):
    x = 0
    while(1):
        if n%2==0:
            n=n//2
            x+=1
        else:
            return x
        if x>=2:
            return x
x=[]
y=[]
z=[]
for i in range(N):
    b = calc(a[i])
    if b==2:
        x.append(a[i])
    elif b==1:
        y.append(a[i])
    else:
        z.append(a[i])

X=len(x)
Y=len(y)
Z=len(z)

if Y==0:
    if Z<=(X+1):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    if Z<=X:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14480
using System;
using System.Linq;

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            DiceCs sai = new DiceCs();
            var die1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var die2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(sai.AreSame(die1, die2)? "Yes":"No");
        }
    }
}
internal class DiceCs
{
    Random rnd = new Random();
    internal bool AreSame(int[] pips, int[] auth)
    {
        const int MAX_TIME = 500;
        int count = 0;
        while (pips[0] != auth[0] || pips[1] != auth[1] || pips[2] != auth[2] || pips[3] != auth[3] || pips[4] != auth[4] || pips[5] != auth[5])
        {
            RandomShake(pips);
            ++count;
            if (count == MAX_TIME)
            {
                return false;
            }
        }
        return true;
    }

    private void GoNorth(int[] pips)
    {
        int tmp = pips[0];
        pips[0] = pips[1];
        pips[1] = pips[5];
        pips[5] = pips[4];
        pips[4] = tmp;

    }
    private void GoWest(int[] pips)
    {
        int tmp = pips[0];
        pips[0] = pips[2];
        pips[2] = pips[5];
        pips[5] = pips[3];
        pips[3] = tmp;
    }
    private void RandomShake(int[] pips)
    {
        if (rnd.Next(2) == 1)
        {
            GoNorth(pips);
        }
        else
        {
            GoWest(pips);
        }
    }
}


Measured memory_bytes: 18456
#include <bits/stdc++.h>
#define rep(i,n); for(long long i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
int main(){
  ll n; cin >> n;
  ll r = sqrt(n);
  for(ll i = r;i>0;i--){
    if(n%i == 0){
      cout << i + n/i - 2 << endl;
      break;
    }
  }
      
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 101;

int main() {
	int N;
	bool t[MAX] = { false };

	cin >> N;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		t[n] = true;
	}

	int cnt = 0;
	for (int i = 0; i < MAX; i++) {
		if (t[i])cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let k = sc.read();
    let mut a: Vec<i64> = Vec::new();
    for _ in 0..k {
        a.push(sc.read());
    }
    let a = a;

    let mut low = 2;
    let mut high = 2;

    for ai in a.iter().rev() {
        let l = (low + ai - 1) / ai;
        let h = high / ai;
        if l > h {
            println!("-1");
            return;
        }
        low = l * ai;
        high = h * ai + ai - 1;
    }

    // println!("{:?}", a);
    println!("{} {}", low, high);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
# 累積和使おうかと思ったけどせいぜいNなので
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans = max(ans, sum(a[:i+1]) + sum(b[i:]))
print(ans)


Measured memory_bytes: 38384
// finish date: 2018/01/18
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

vector<vector<int>> sv;
vector<ll> salary;

ll dfs(int men) {
    if (salary[men] != -1) return salary[men];
    if (sv[men].empty()) {
        salary[men] = 1;
        return salary[men];
    }
    salary[men] = 0;
    rep(i, sv[men].size()) {
        salary[men] += dfs(sv[men][i]);
    }
    return salary[men];

}


ll totalSalary(vector<string> relations) {
    int N = relations.size();
    sv = vector<vector<int>>(N, vector<int>());
    salary = vector<ll>(N, -1);
    rep(i, N) {
        rep(j, N) {
            if (relations[i][j] == 'Y') {
                sv[i].push_back(j);
            }
        }
    }
    ll sum = 0;
    rep(i, N) dfs(i);
    rep(i, N) sum += salary[i];
    return sum;
}


int main() {
    int N,K;
    cin>>N>>K;
    int in;
    map<int,int> mp;
    rep(i,K){
        cin>>in;
        mp[in] = 0;
    }
    vector<int> ans;
    int checker;
    FOR(i,N,100000){
        checker = i;
        while(checker!=0){
            if(mp.count(checker%10)==0){
                checker/=10;
            }else{
                break;
            }
        }
        if(checker==0){
            cout << i<<endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100001
int n;
int prime[MAX];
int cnt[MAX]={};
void eratos() {
	int j;
	for (int i=0;i<MAX;i++) {
	//全部primeと設定する
	prime[i] = 1;
	}
	prime[0] = prime[1] = 0;

	for (int i=2;i<MAX;i++) {
	j = i+i;
	while(j<MAX) {
	if (prime[j]) prime[j] = 0;
	j += i;
	}
	}
	
}

void like() {
	for (int i=3;i<MAX;i++) 
	{
	if (i%2==1) {	
	if (prime[i] && prime[(i+1)/2]) {
	++cnt[i];
	}
	}
	cnt[i]+=cnt[i-1];
	}
}



int main() {
	int q;
	int l,r;
	cin >> q;
	eratos();
	like();
	for (int i=0;i<q;i++) {
	scanf("%d %d", &l, &r);
	printf("%d\n", cnt[r]-cnt[l-1]);
	}

/*	for (int i=0;i<=11;i++) {
	cout << "p "<<prime[i] << endl;
	cout << "c "<<cnt[i] << endl;
	}
*/
	return 0;
}


Measured memory_bytes: 1408
def measure_ACGT(str):
  elements = ['A','C','G','T']
  length = 0
  for s in str:
    if not(s in elements):
      break
    else:
      length += 1    
  return length

def start_positions():
  return [0,1,2,3,4,5,6,7,8,9]

def find_longest_block(str):
  length = 0
  positions = start_positions()
  for pos in positions:
    s2 = str[pos:]
    ln = measure_ACGT(s2)
    if ln > length:
      length = ln
  return length

S = input()
print(find_longest_block(S))


Measured memory_bytes: 3064
using System;
using System.Linq;

namespace V0043{
    public class Program{
        public static void Main(string[] args){
            string input;
            while((input = Console.ReadLine()) != null){
                var pai = new int[12];
                input.ToList().ForEach(c => pai[c - '0']++);

                Func<int, int[], bool> func = null;
                func = (x, _pai) =>{
                    if(_pai[x] < 0 || _pai[x + 1] < 0 ) return false;
                    if(x > 7) return _pai.Count(i => i == 2) == 1 && _pai.All(i => i == 0 || i == 2 || i == 3);

                    for(var i = 0; i <= _pai[x]; i++) {
                        if(_pai[x] - i == 1) continue;
                        for(var j = 0; j < 3; j++) _pai[x + j] -= i;
                        if(func(x + 1, _pai)) return true;
                        for(var j = 0; j < 3; j++) _pai[x + j] += i;
                    }
                    return false;
                };

                var result = new bool[9 + 1];
                for(var i = 1; i <= 9; i++){
                    var tmp = new int[12];
                    pai.CopyTo(tmp, 0);
                    if(++tmp[i] != 5) result[i] = func(1, tmp);
                }

                var str = string.Empty;
                for(var i = 1; i <= 9; i++) if(result[i]) str += i + " ";
                Console.WriteLine(str == string.Empty ? "0" : str.Trim());
            }
        }
    }
}

Measured memory_bytes: 9328
#include <cstdio>
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  if (n == 1 && m == 1) printf("1");
  else if (n == 1) printf("%d", m - 2);
  else if (m == 1) printf("%d", n - 2);
  else printf("%lld", 1ll * (n - 2) * (m - 2));
}


Measured memory_bytes: 128
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!

using namespace std;


int main() {
	double H, A;
	cin >> H >> A;
	cout << ceil(H / A) << endl;
}

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

using namespace std;

int main(void) {
	int num, i, j, k, sum = 0;
	double a = 0.5, ans = 0.0;
	cin >> num;
	vector<int> s(num, 0), t(num);
	vector<double> v(num);
	for (i = 0; i < num; i++) {
		scanf("%d", &t[i]);
		s[i] = sum;
		sum += t[i];
	}
	for (i = 0; i < num; i++)
		cin >> v[i];
	vector<double> d(sum);
	for (i = 0; i < (sum >> 1); i++) {
		d[i] = a;
		d[sum - i - 1] = a;
		a += 1.0;
	}
	if (sum & 1)
		d[i] = a - 0.25;
	for (i = 0; i < num; i++) {
		for (j = s[i]; j < s[i] + t[i]; j++)
			d[j] = min(d[j], v[i]);
	}
	for (i = 1; i < num; i++) {
		a = min(v[i - 1], v[i]) + 0.5;
		for (j = s[i] - 1; j >= 0; j--) {
			if (d[j] > a)
				d[j] = a;
			else if (d[j] == a) {
				if (d[j - 1] < d[j])
					d[j] -= 0.25;
				break;
			}
			else
				break;
			a += 1.0;
		}
		a = min(v[i - 1], v[i]) + 0.5;
		for (j = s[i]; j < sum; j++) {
			if (d[j] > a)
				d[j] = a;
			else if (d[j] == a) {
				if (d[j] > d[j + 1])
					d[j] -= 0.25;
				break;
			}
			else
				break;
			a += 1.0;
		}
	}
	for (i = 0; i < sum; i++)
		ans += d[i];
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 384