akhauriyash/Code-Regression huggingface dataset:
# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

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

int a[N], n;
bool u[N];
int cnt[N][2];
vector < pair < int, int > > v[2];

int main () {
    cin >> n;
    For (i, 1, n) {
        cin >> a[i];
        cnt[a[i]][i & 1] ++;
    }
    
    For (i, 1, n) {
        if(!u[a[i]]) {
            u[a[i]] = 1;
            v[i & 1].pb(mp(cnt[a[i]][i & 1], a[i]));
            v[(i + 1) & 1].pb(mp(cnt[a[i]][(i + 1) & 1], a[i]));
        }
    }
    
    sort(every(v[0]));
    sort(every(v[1]));
    reverse(every(v[0]));
    reverse(every(v[1]));
    
    while (v[0].size() > 2) v[0].pop_back();
    while (v[1].size() > 2) v[1].pop_back();
    int ans = n;
    bool check = 1;
    for (auto l : v[0]) {
        for (auto r : v[1]) {
            if (l.S == r.S) continue;
            check = 0;
            ans = min(ans, n - (l.F + r.F));
        }
    }
    if (check) ans /= 2;
    
    cout << ans;
    
    return Accepted;
}

// Coded By OB

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

int r, ans = 0, p[10];

void ps(int n, int k)
{
	if (r < n) return;
	if (p[3] && p[5] && p[7]) ans++;
	if (k == 9) return;
	for (int i = 3; i <= 7; i += 2) {
		p[i]++;
		ps(n * 10 + i, k + 1);
		p[i]--;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> r;
	ps(0, 0);
	cout << ans << '\n';
	return 0;
}

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

int main() {

  int k, n, l;
  int max = 0;
  cin >> k >> n;
  vector<int> arr(210000);
  for (int i = 0; i < n; i++) {
    cin >> arr.at(i);
  }

  for (int i = 1; i < n; i++) {
    l = arr.at(i) - arr.at(i-1);
    if (l > max) max = l;
  }
  l = arr.at(0) + k - arr.at(n-1);
  if (l > max) max = l;

  cout << k - max;

}


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

typedef pair<int, int> P;

static const int MAX_H = 50;
static const int MAX_W = 50;

int H, W;
int sh = -1, sw = -1, gh = -1, gw = -1;
char grid[MAX_H][MAX_W + 1];
int count[MAX_H][MAX_W];

//#define OCTAS
#ifdef OCTAS
static const int dh[] = {-1, -1, -1, 0, 0, +1, +1, +1};
static const int dw[] = {-1, 0, +1, -1, +1, -1, 0, +1};
#else
static const int dh[] = {-1, 0, 0, +1};
static const int dw[] = {0, -1, +1, 0};
#endif

void initialize() {
  // memset(::count, -1, sizeof(::count));
  fill_n(::count[0], MAX_H * MAX_W, -1);
}

int bfs(int h, int w) {
  queue<P> que;
  ::count[h][w] = 0;
  que.push(P(h, w));

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int cnt = ::count[p.first][p.second];
    if (p.first == gh && p.second == gw) {
      return cnt;
    }
    ++cnt;
    for (int i = 0; i < sizeof(dh) / sizeof(int); ++i) {
      int nh = p.first + dh[i];
      int nw = p.second + dw[i];
      if (nh < 0 || nh >= H ||
          nw < 0 || nw >= W ||
          ::count[nh][nw] >= 0 ||
          grid[nh][nw] == '#')
        continue;
      ::count[nh][nw] = cnt;
      que.push(P(nh, nw));
    }
  }

  return -1;
}

int main() {
  int black{};
  initialize();
  scanf("%d%d", &H, &W);
  for (int h = 0; h < H; ++h) {
    scanf("%s", &grid[h][0]);
    for (int w = 0; w < W; ++w) {
      if (grid[h][w] == '#')
        ++black;
    }
  }
  sh = 0, sw = 0, gh = H - 1, gw = W - 1;
  int white = bfs(sh, sw);
  int ans = white >= 0 ? (H * W - (white + 1)) - black : white;

  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
int main() {
    int N, M;
    long long A[100001], C[100001];
    long long B[100001];
    cin >> N >> M;
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<M; i++) cin >> B[i] >> C[i];

    sort(A, A+N);
    vector<int> Cidx(M);
    iota(Cidx.begin(), Cidx.end(), 0);
    sort(Cidx.begin(), Cidx.end(), [&C](int i1, int i2){return C[i1] > C[i2];});
    
    int card = 0;
    int idx = N-1;
    long long result = 0;
    auto idx2 = Cidx.begin();
    while (card < N) {
        if (idx2 != Cidx.end() && C[*idx2] >= A[idx]) {
            long long addition = B[*idx2];
            if (card + addition > N) {
                addition = N - card;
            }
            card += addition;
            result += C[*idx2] * addition;
            idx2++;
        } else {
            card++;
            result += A[idx];
            idx--;
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
//#include "rail.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e16;
const long long MOD = 1e9+7;
const int MAX=200015;

int main(){
    int x,y;
    cin>>x>>y;
    if(x<y){
        cout<<x;
        R 0;
    }
    else{
        if(x%y==0){
            cout<<-1;
            R 0;
        }
        cout<<x;
        R 0;
    }
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
//constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

ll dp[110][110][2];

int main(void){
	ll h, w;
	cin >> h >> w;
	VecS s(h);
	rep(i, h) cin >> s[i];

	fill(dp[0][0], dp[110][0], LINF);
	if(s[0][0] == '.'){
		dp[0][0][0] = 0;
		dp[0][0][1] = 0;
	}else{
		dp[0][0][0] = 1;
		dp[0][0][1] = 1;
	}

	rep(i, h){
		rep(j, w){
			if(!i && !j) continue;
			if(!i){
				if(s[i][j] == '#' && s[i][j - 1] == '.') dp[i][j][0] = dp[i][j - 1][0] + 1;
				else dp[i][j][0] = dp[i][j - 1][0];
				continue;
			}
			if(!j){
				if(s[i][j] == '#' && s[i - 1][j] == '.') dp[i][j][1] = dp[i - 1][j][1] + 1;
				else dp[i][j][1] = dp[i - 1][j][1];
				continue;
			}

			if(s[i][j] == '.'){
				dp[i][j][0] = min(dp[i][j - 1][0], dp[i][j - 1][1]);
				dp[i][j][1] = min(dp[i - 1][j][0], dp[i - 1][j][1]);
				continue;
			}

			
			dp[i][j][0] = min(dp[i][j - 1][0], dp[i][j - 1][1]);
			if(s[i][j - 1] == '.') dp[i][j][0]++;
			dp[i][j][1] = min(dp[i - 1][j][0], dp[i - 1][j][1]);
			if(s[i - 1][j] == '.') dp[i][j][1]++;
		}
	}
	co(min(dp[h - 1][w - 1][0], dp[h - 1][w - 1][1]));

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > G[15];
int n,k,x,y;
bool check(int s) {
	for(int i=0;i<n;i++) {
		if((1<<i)&s) {
			for(int j=0;j<G[i].size();j++) {
				if(G[i][j].second) {
					if(!((1<<G[i][j].first)&s)) return false;
				}
				else {
					if((1<<G[i][j].first)&s) return false;
				}
			}
		}
	}
	return true;
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&k);
		for(int j=0;j<k;j++) {
			scanf("%d%d",&x,&y),x--;
			G[i].push_back({x,y});
		}
	}
	int ans=0;
	for(int i=0;i<1<<n;i++) {
		int s=0;
		for(int j=0;j<n;j++) {
			if((1<<j)&i) s++;
		}
		if(check(i)) ans=max(ans,s);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 1e14, MOD = 1e9 + 7;

int N;
vi A;
void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; }
}
void solve() {
  int ans = INF;
  int fugo;
  rep(fg, 0, 1) {
    if (fg == 1) {
      fugo = 1;
    } else
      fugo = 0;

    int prev = 0;
    int s = 0;
    int ans1 = 0;
    rep(i, 0, N - 1) {
      s += A[i];
      if (fugo) {
        if (s > 0) {
          ans1 += 0;
        } else if (s == 0) {
          ans1 += 1;
          s = 1;
        } else {
          ans1 += abs(s) + 1;
          s = 1;
        }
      } else {
        if (s > 0) {
          ans1 += (abs(s) + 1);
          s = -1;
        } else if (s == 0) {
          ans1 += 1;
          s = -1;
        } else {
          ans1 += 0;
        }
      }
      fugo = !fugo;
      debug(fugo);
      debug(s);
    }
    debug(ans1);

    ans = min(ans1, ans);
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1024
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int a,b,c;

  cin>>a>>b>>c;

  if(c>=a&&c<=b){
    cout<<"Yes"<<endl;
  }else {
    cout<<"No"<<endl;
  }
  
  return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, M;
    cin >> N >> M;
    if (N != M){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

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

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

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


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int x, a, b;
    cin >> x >> a >> b;

    if(b <= a)
        cout << "delicious";
    else if(b - a <= x)
        cout << "safe";
    else
        cout << "dangerous";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,c0=0,c1=0,c2=0,c3=0;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        char c;
        c=s[0];
        switch(c)
        {
        case 'A':
            c0++;
            break;
        case 'W':
            c1++;
            break;
        case 'T':
            c2++;
            break;
        case 'R':
            c3++;
            break;
        }
    }
    cout << "AC x " << c0 << "\n";
    cout << "WA x " << c1 << "\n";
    cout << "TLE x " << c2 << "\n";
    cout << "RE x " << c3 << "\n";
}


Measured memory_bytes: 3624
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def inpl_strl(): return list(sys.stdin.readline())

n,m = inpl()
a = [list(map(int, input().split())) for i in range(m)]
ans = -1
for i in range(1000):
    s = str(i)
    if len(s) == n:
        flg = 0
        for (x, y) in a:
            if int(s[x-1]) != y:
                flg = 1
        if flg == 0:
            ans = i
            break
print(ans)

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mod = 998244353;

int32_t main()
{   fastio;

    int n , c;
    cin>>n>>c;

    int d[c+1][c+1];

    for(int i=1; i <= c; i++)
    {
        for(int j=1; j <= c; j++)
        {
            cin>>d[i][j];
        }
    }
    map<int , vector<int>>mp;

    int arr[n+1][n+1];

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++) {
            cin>>arr[i][j];
            mp[(i+j)%3].pb(arr[i][j]);
        }
    }

    int ans=1e13;
    vector<pii>a;
    vector<pii>b;
    vector<pii>l;
    for(int i=1; i <= c; i++)
    {
        int sum=0;
        for(auto x:mp[0])
        {
            sum += d[x][i];
        }
        a.pb({sum , i});
    }
    for(int i=1; i <= c; i++)
    {
        int sum=0;
        for(auto x:mp[1])
        {
            sum += d[x][i];
        }
        b.pb({sum , i});
    }
    for(int i=1; i <= c; i++)
    {
        int sum=0;
        for(auto x:mp[2])
        {
            sum += d[x][i];
        }
        l.pb({sum , i});
    }
    for(int i=0; i<a.size(); i++)
    {
        for(int j=0; j<b.size(); j++)
        {
            for(int k=0; k<l.size(); k++) {
                if(l[k].S != b[j].S && b[j].S != a[i].S && a[i].S != l[k].S)
                {
                    ans=min(ans , l[k].F+a[i].F+b[j].F);
                }
            }
        }
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A<=0&&B>=0) cout<<"Zero"<<endl;
  else if(A<0&&(B-A)%2==0) cout<<"Negative"<<endl;
  else cout<<"Positive"<<endl;
}

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

int main(){
	int n,mi=0,ma=0,ans=0;
	cin>>n;
	vector<int>a(9);
	vector<int>b(10000000);
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(b[i]<3200){
			a[b[i]/400]++;
		}
		else{
			a[8]++;
		}
	}
	for(int i=0;i<8;i++){
		if(a[i]>0){
			mi++;
		}
	}
	ma=mi;
	if(mi==0){
			mi++;
	}
	
	ma+=a[8];
	
	cout<<mi<<" "<<ma<<endl;
	return 0;
	
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, k, m;
  while (cin >> n >> k >> m, n) {
    vector<int> stone(n);
    for (int i = 0; i < n; i++) {
      stone[i] = i + 1;
    }
    m--;
    while (stone.size() > 1) {
      stone.erase(stone.begin() + m);
      m = (m + k - 1) % stone.size();
    }
    cout << stone[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 3128
import java.util.*;

class Main{
	public static void main(String[] args){
		int time;
		int h;
		int min;
		int s;
		
		Scanner cin = new Scanner(System.in);
		time=cin.nextInt();
		
		h=time/3600;
		min=(time-h*3600)/60;
		s=time-h*3600-min*60;
		System.out.println(h+":"+min+":"+s);
	}
}


Measured memory_bytes: 26064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
      int n;
      cin>>n;
      int a[n],b[n];
      read(a,n);
      read(b,n);
      int sum=0,c[n+1000],j=0,s=0;
      for(int i=0;i<n;i++)
      { 
          sum+=a[i];
          for(int j=i;j<n;j++)
          {
              s+=b[j];
          }
          s+=sum;
          c[j]=s;
          j++;
          s=0;
      }
      sort(c,c+j);
      cout<<c[j-1];
    //   for(int i=0;i<j;i++)
    //   cout<<c[i]<<" ";
      
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

void bfs(const Graph &G, vector<int> &dist, int s) {
    dist[s] = 0;
    queue<int> que;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (dist[nv] == -1) {
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b), G[b].push_back(a);
    }
    int res = 0;
    vector<int> dist(N, -1);
    for (int v = 0; v < N; ++v) {
        if (dist[v] != -1) continue;
        bfs(G, dist, v);
        ++res;
    }
    cout << res - 1 << endl;
}

Measured memory_bytes: 8808
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,c;
 cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes";
  } else if(a==c&&b!=c){
    cout<<"Yes";
  } else if(b==c&&a!=b){
    cout<<"Yes";
  } else {
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

ll mod = 1e9 + 7;
ll dp[10005][120][2];
string K;
int D;

int main() {
    cin >> K;
    cin >> D;
    int N = K.length();
    rep(dig,N+1){
        rep(d, D){
            rep(isless, 2){
                dp[dig][d][isless] = 0;
            }
        }
    }

    dp[0][0][0] = 1;
    rep(dig,N){
        rep(d, D){
            rep(isless, 2){
                int c = K[dig] - '0';
                rep(nxt, 10){
                    if (c > nxt) {
                        dp[dig+1][(d+nxt) % D][1] += dp[dig][d][isless];
                        dp[dig+1][(d+nxt) % D][1] %= mod;
                        if (dp[dig+1][(d+nxt) % D][1] < 0) dp[dig+1][(d+nxt) % D][1] += mod;
                    } else if (c == nxt) {
                        dp[dig+1][(d+nxt) % D][isless] += dp[dig][d][isless];
                        dp[dig+1][(d+nxt) % D][isless] %= mod;
                        if (dp[dig+1][(d+nxt) % D][isless] < 0) dp[dig+1][(d+nxt) % D][isless] += mod;
                    } else {
                        if (isless) {
                            dp[dig+1][(d+nxt) % D][isless] += dp[dig][d][isless];
                            dp[dig+1][(d+nxt) % D][isless] %= mod;
                            if (dp[dig+1][(d+nxt) % D][isless] < 0) dp[dig+1][(d+nxt) % D][isless] += mod;
                        }
                    }
                }
            }
        }
    }
    ll ans = (dp[N][0][0] + dp[N][0][1] - 1) % mod;
    if (ans < 0) ans += mod;

    cout << ans << endl;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int cur = 1;
	int dig = -1;
	for(int i=1;i<=9;i++){
		char res;
		cur = cur * 10;
		cout<<"? "<<cur<<endl;
		cin>>res;
		if( res == 'N'){
			dig = i;
			break;
		}
	}
	if( dig == -1){
		ll cur = 1000000000;
		while( cur > 1 ){
			cout<<"? "<<cur-1<<endl;
			char res;
			cin>>res;
			if(res == 'N' ){
				cout<<"! "<<cur<<endl;
				cout<<flush;
				return 0;
			}
			cur = cur/10;
		}
		cout<<"! "<<1<<endl;
		cout<<flush;
		return 0;
	}
	int cv = 0;
	for(int i=1;i<=dig-1;i++){
		int yes = 0, no = 10;
		if( cv == 0 )yes = 1;
		while( no-yes > 1 ){
			int mid = ( yes + no ) / 2;
			int ask = cv + mid;
			cout<<"? "<<ask<<endl;
			char res;
			cin>>res;
			if( res == 'Y' ){
				yes = mid;
			}
			else{
				no = mid;
			}
		}
		cv += yes;
		cv *= 10;
	}
	cv *= 10;
	for(int i=0;i<=9;i++){
		if( cv != 0 ){
			cout<<"? "<<cv<<endl;
			char res;
			cin>>res;
			if( res == 'Y'){
				cout<<"! "<<cv/10<<endl;
				cout<<flush;
				return 0;
			}
		}
		cv += 10;
	}
	return 0;
}

Measured memory_bytes: 596
package main
import "fmt"

func main() {
  var a, b int
  
  fmt.Scan(&a, &b)
  flag := 0
  for i:=1; i<=1009; i++ {
    if int(float64(i)*0.08) == a && int(float64(i)*0.1) == b {
      fmt.Println(i)
      flag = 1
      break
    }
  }
  if flag == 0 {
    fmt.Println(-1)
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;

int main()
{
    int n, i, ans1 = 0, ans, sum = 0;
    // float mean1;
    int mean;
    cin >> n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    mean = sum/n;
    for(i=0;i<n;i++)
    {
        ans1 += (a[i] - mean)*(a[i] - mean);
    }
    ans = ans1;
    mean = mean + 1;
    ans1 = 0;
    for(i=0;i<n;i++)
    {
        ans1 += (a[i] - mean)*(a[i] - mean);
    }
    ans = min(ans1, ans);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    vector<ll> b;
    rep(i, m){ int tmp; cin >> tmp; b.push_back(tmp);}

    vector<ll> asum(n+1, 0);
    vector<ll> bsum(m+1, 0);

    rep(i, n) asum[i+1] = asum[i] + a[i];
    rep(i, m) bsum[i+1] = bsum[i] + b[i];

    ll ans = 0;
    rep(i, n+1){
        ll t = asum[i];
        ll remain = k-t;
        if (remain < 0) continue;
        auto itr = upper_bound(bsum.begin(), bsum.end(), remain) - bsum.begin();
        ll tans = i + itr - 1;
        ans = max(tans, ans);
    }

    cout << ans << endl;
}



Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int alpha[26] = {};
  rep(i, n) {
    string s;
    cin >> s;
    if (i == 0) {
      for (char c : s) alpha[c - 'a']++;
    } else {
      int tmp_alpha[26] = {};
      for (char c : s) tmp_alpha[c - 'a']++;
      rep(i, 26) {
        if (alpha[i] > tmp_alpha[i]) alpha[i] = tmp_alpha[i];
      }
    }
  }
  int sum = 0;
  string ans = {};
  rep(i, 26) sum += alpha[i];
  if (sum == 0) {
    cout << ans << endl;
  } else {
    rep(i, 26) ans += string(alpha[i], 'a' + i);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            int t = sc.nextInt();
            if (T >= t) {
                if (ans > c) {
                    ans = c;
                }
            }
        }
        if (ans == Integer.MAX_VALUE) {
            System.out.println("TLE");
        } else {
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll MAXX = 1e18;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	ll n;
	cin >> n;
	vector<ll> hold(n);
	for (ll i = 0; i < n; i++) {
		cin >> hold[i];
	}
	double res = 0;
	sort(hold.begin(), hold.end());
	ll div = 2;
	for (ll i = hold.size() - 1; i > 1; i--) {
		res += (hold[i] * 1.0) / div;
		div *= 2;
	}
	res += ((hold[0] + hold[1]) * 1.0) / div; 
	cout << setprecision(15) << res << '\n';
	return 0;
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << " " << 2*a+2*b << endl;
    return 0;
}


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


//文字列は一つしかないので最初にそこでAC探索やっとけばよい！

/*int main(){
    int n,q;
    string s;
    cin >> n >> q >> s;

    int l[q],r[q];

    int ans = 0;

    for(int i = 0; i < q; i++){
        cin>> l[i] >> r[i];
    }

    for(int i = 0; i < q; i++){
        ans = 0;
        //文字列の[]のスタートは１からではなく０からなので－１しとく。
        for(int j = l[i]-1; j < r[i]-1; j++ ){
            if(s[j] == 'A' && s[j+1] == 'C'){
                ans++;
            }
        }
        cout << ans << endl;
    }

    
}*/

int main(){
    int n,q;
    cin >> n >> q;
    string str;

    cin >> str;

    vector<int> arr(n,0);

    for(int i = 0; i < n -1; i++){
        //これによって１文字目からi文字目までに出現するACの数をarr[i]が表すようになる。
        if(str[i] == 'A' && str[i+1] == 'C'){
            //わかりにくいが、Cはi+1番目に入っている。
            //つまり、i文字目までに出現するACの数は右端はAのみなのでー１される。
            arr[i+1] = arr[i] + 1;
        }else{
            arr[i+1] = arr[i];
        }
    }

   
    while(q--){
        int l,r;
        cin >> l >>r;

        //arr[l]を含めてしまうとそれ自身も除外されてしまう。
        cout<< arr[r - 1] - arr[l-1] << '\n';
    }
    return 0;

}

Measured memory_bytes: 1408
N = int(input())
d = list(map(int, input().split()))
d.sort()
n2 = N // 2
d1 = d[:n2]
d2 = d[n2:]
if (d1[-1] == d2[0]) or (N % 2 == 1):
    ans = 0
else:
    ans = d2[0] - d1[-1]
print(ans)

Measured memory_bytes: 14396
#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(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> H(N);
	REP(i, N) cin >> H[i];
	
	vector<vector<int>> G(N);
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	
	vector<int> ok(N, 1);
	REP(i, N) {
		for (int v : G[i]) if (H[i] >= H[v]) ok[v] = false;
	}
	
	int ans = 0;
	REP(i, N) ans += ok[i];
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 9136
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
int solve()
{
	int x;
	cin>>x;
	if(x==0)
		cout<<1;
	else
		cout<<0;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 2001001001
using namespace std;
int f(int x) {
	if (x < 0)
		return INF;
	else
		return x;
}
int main() {
	int x, y;
	cin >> x >> y;
	int ans = INF;
	ans = min(ans, f(y - x));
	ans = min(ans, f(y - (-x) + 1));
	ans = min(ans, f(-y - x + 1));
	ans = min(ans, f(-y - (-x) + 2));
	ans = min(ans, f(y - (-x) + 1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define MAX 3003
using namespace std;

int dp[MAX][MAX];
char A[MAX], B[MAX];
void printLCS(int i, int j)
{
    if(i==0 || j==0) return;
    if(A[i]==B[j])
    {
        printLCS(i-1, j-1);
        putchar(A[i]);
    }
    else if(dp[i-1][j] >= dp[i][j-1])
        printLCS(i-1, j);
    else
        printLCS(i, j-1);
}
int main()
{
    scanf("%s", A+1);
    scanf("%s", B+1);
    int n = strlen(A+1);
    int m = strlen(B+1);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(A[i]==B[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
        }
    }
    printLCS(n, m);
    puts("");
    return 0;
}


Measured memory_bytes: 35456
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long N, std::vector<long long> a){
    int count = 1;
    int tmp = a[1];
    bool ans = false;
    REP(i, N) {
        if (tmp == 2) {
            ans = true;
            break ;
        }
        if (tmp == 1) break ;
        tmp = a[tmp];
        count++;
    }
    if (ans) print(count);
    else print(-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N + 1);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
N, A, B, C = map(int, input().split())
from itertools import product
l = [int(input()) for i in range(N)]
ans = []
for i in product(range(4), repeat=N):
  a = 0
  b = 0
  c = 0
  d = 0
  for j in range(N):
    if i[j]:
      d += 1
      if i[j] == 1:
        a += l[j]
      elif i[j] == 2:
        b += l[j]
      else:
        c += l[j]
  if a * b * c:
    ans += [abs(A - a) + abs(B - b) + abs(C - c) + (d - 3) * 10]
print(min(ans))

Measured memory_bytes: 10916
N = int(input())
x_list = [int(i) for i in input().split()]
x_list.sort()
hp = 10 ** 6
for p in range(x_list[0], x_list[len(x_list) - 1] + 1):
  hp_p = 0
  for x in x_list:
    hp_p += (x - p) ** 2
  if hp_p < hp:
    hp = hp_p
print(hp)

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int s = 0;
    vector<int> a;
    for (int i = 0; i < n; ++i) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        s += ai;
    }
    int ave = (s < 0 ? -1 : 1) * (abs(s) + n / 2) / n;
    int c = 0;
    for (int i = 0; i < a.size(); i++) {
        c += (a[i] - ave) * (a[i] - ave);
    }
    cout << c << '\n';
    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();
    int[][] arr = new int[n][2];
    for(int i=0;i<n;i++){
      arr[i][0]=sc.nextInt();
      arr[i][1]=sc.nextInt();
    }
    int max=0;
    int count=0;
    for(int i=0;i<n;i++){
      if(arr[i][1]==arr[i][0]){
        count++;
      }
      else{
        if(max<count){
          max=count;
        }
        count=0;
      }
    }
    if(max<count){
      max=count;
    }
    if(max>=3){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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

using namespace std;

typedef long long ll;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

ll s[1010101];
int a[1010101];

int main(){
	int n=read(),l=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	ll ans=1e18; 
	for(int i=1;i<=n;i++){
		ll res=0;int pos=n;
		for(int j=1;j<=n/i+1;j++){
			res+=1ll*max(5,2*j+1)*(s[pos]-s[max(0,pos-i)]);
			if(res>ans) break;
			pos=max(0,pos-i);
		}
		res+=1ll*(i+n)*l;
		ans=min(ans,res);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    while(n>=1000){
        n-=1000;
    }
    if(n>0)
        cout<<abs(1000-n);
        else
    cout<<abs(n);
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
    long W, H, x, y;
    cin >> W >> H >> x >> y;

    double max_area = (double)(W*H) / 2.0;
    char ways;

    if(W == 2*x && H == 2*y) ways = '1';
    else ways = '0';

    cout << max_area << " " << ways << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

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


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int



int solve( ){
 

int n,m,c;
cin>>n>>m>>c;
int b[m+1];
rep(i,0,m)
cin>>b[i+1];
int k=0;
rep(i,0,n)
{
int sum=c;
  rep(i,0,m)
  {

    int x;
    cin>>x;
   sum+=(x*(b[i+1]));
  }
  if(sum>0)k++;
  sum=0;
}
cout<<k;
 

return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
 
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    int itr = 1;
    rep(i, n){
        if (a[i] == itr){
            itr++;
        }
    }
    int ans = n - itr + 1;
    if (ans == n) puts("-1");
    else cout << ans << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
struct po{
  string str;
  vector <int> page;
};


int main() {
  
  po ls[1001];
  
  int a=0;
  string ch;
  int b;
  while(cin >>ch>> b){
    int flg = 0;

    for(int i=0;i<a;i++) 
      if(ch == ls[i].str){
	ls[i].page.push_back(b);
	flg = 1;
	break;
      }
    
    if(flg == 1) continue;
    ls[a].str = ch;
    ls[a].page.push_back(b);
    a++;
  }


  for(int i=0;i<a-1;i++) 
    for(int j=a-1;j>i;j--)
      if(ls[j].str < ls[j-1].str) {
	po t = ls[j];
	ls[j] = ls[j-1];
	ls[j-1] = t;
      }

  for(int i=0;i<a;i++) {
    cout << ls[i].str << endl;
      sort(ls[i].page.begin(),ls[i].page.end());
    for(int j=0;j<ls[i].page.size();j++){
      cout << ls[i].page[j];
      if(j != ls[i].page.size()-1) cout <<" ";
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 1268
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let _n = i.read::<usize>();
    let s = i.read_line().to_string();
    let q = i.read::<usize>();
    let k = i.read_vec::<usize>(q);
    for k in k {
        writeln!(o, "{}", solve(&s, k)).unwrap();
    }
}
pub fn solve(s: &str, k: usize) -> usize {
    let s = s.as_bytes();
    let mut d = 0;
    let mut m = 0;
    let mut dm = 0;

    let mut result = 0;

    for i in 0..s.len() {
        match s[i] {
            b'D' => {
                d += 1;
            }
            b'M' => {
                m += 1;
                dm += d;
            }
            b'C' => {
                result += dm;
            }
            _ => {}
        }
        if i >= k - 1 {
            match s[i - (k - 1)] {
                b'D' => {
                    d -= 1;
                    dm -= m;
                }
                b'M' => {
                    m -= 1;
                }
                _ => {}
            }
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  double n, d, x; cin >> n >> d >> x;
  double s = 0;
  for (int i = 0; i < n; i++) s += (i + 1) / (n - i);
  cout << fixed << setprecision(15) << (d + (n - 0.5) * x) * s << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i;
	int num;
	int *data;

	scanf("%d", &num);
	
	data = new int[num];
	for (i = 0; i < num; i++) scanf("%d", &data[i]);

	for (i = num - 1; i >= 0; i--) {
		printf("%d", data[i]);
		if (i == 0)break;
		printf(" ");
	}

	printf("\n");



	//\b


	delete[] data;
	return 0;
}

Measured memory_bytes: 2728