akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(vector<bool>::reference b) {
  return to_string(bool(b));
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const ll INF = 1e9+7;
const int MAXN = 1e5;
int N,M;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  // debug(N,M);
  vector<ll> dp(N+2);
  vector<bool> a(N+2);
  debug(a);
  REP(i,M) {
    int idx;
    cin >> idx;
    a[idx+1] = true;  // 1段目->idx=2
  }
  // debug(a);
  dp[0] = 0;
  dp[1] = 1; // 0段目
  REP(i,N) {
    if (!a[i+1]) dp[i+2] += dp[i+1];
    if (!a[i]) dp[i+2] += dp[i];
    dp[i+2] %= INF;
  }
  debug(dp);
  cout << dp[N+1] << endl;
}


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

ll gcd(ll a,ll b){
  while(a%b!=0){
    ll tmp=a%b;
    a=b;
    b=tmp;
  }
  return b;
}

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;

  ll E=C/gcd(C,D)*D;
  vector<ll> divC(2),divD(2),divCD(2);
  A--;
  divC.at(0)=A/C;
  divC.at(1)=B/C;
  divD.at(0)=A/D;
  divD.at(1)=B/D;
  divCD.at(0)=A/E;
  divCD.at(1)=B/E;

  ll x=A-divC.at(0)-divD.at(0)+divCD.at(0);
  ll y=B-divC.at(1)-divD.at(1)+divCD.at(1);
  cout<<y-x<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
    #include <stdlib.h>
     
    int main() {
      
      int import = 0;
      
      scanf("%d", &import);
      
      int ten = import / 10;
      
      
      if( (import - 90) >= 0) {
        printf("Yes");
       } else if( (import - (ten*10)) == 9) {
         printf("Yes");
       } else {
         printf("No");
       }
      
      return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,minj,counter=0;
cin>>n;
vector<int> vec(n);

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

for(int i =0;i<n;i++){
	minj =i;
	for(int j=i;j<n;j++){
		if(vec[j]<vec[minj]){
		minj =j;
		}
	}
  if(i != minj) counter++;
  	int temp = vec[i];
	vec[i]=vec[minj];
	vec[minj]=temp;
}

for(int i=0;i<n;i++){
	cout<<vec[i];
	if(i!=n-1) cout<<" ";
}
cout<<endl;
cout<<counter<<endl;

}


Measured memory_bytes: 3120
#include <set>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end(), greater<int>());
	int Alice_sum = 0, Bob_sum = 0;
	for (int i = 0; i < N; i++) {
		if (i%2 == 0) Alice_sum += a[i];
		else Bob_sum += a[i];
	}
	cout << Alice_sum - Bob_sum << endl;
	return 0;
}

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

int main() {
  string S , T ; 
 
  
  cin >> S >> T ;
 

 
  
  T.pop_back() ; 
    
  if (S != T){
    cout << "No" << endl ; 

    
      }
  else{
  
    cout << "Yes" << endl ; 
  }
  
  
}


Measured memory_bytes: 3536
k,n=gets.split.map &:to_i
if k%2==0
  puts ([k/2]+[k]*(n-1))*' '
  exit
end
ans=[(k+1)/2]*n
rem=n/2
while rem>0
  ans[-1]-=1
  if ans[-1]==0
    ans.pop
  else
    while ans.size<n
      ans.push(k)
    end
  end
  rem-=1
end
puts ans*' '

Measured memory_bytes: 11516
import numpy as np

# S = list(input())
n, l = list(map(int, input().split()))

RINGO = list(np.array(list(range(1, n+1))) + l - 1)
AJI = list(map(abs, RINGO))

RINGO.pop(AJI.index(min(AJI)))
print(sum(RINGO))

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N){
    i64 ans = 0;
    rep(i, 1, N + 1){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3688
def main():
    n = int(input())
    z = [[], []]
    for i in range(n):
        x, y = map(int, input().split())
        z[0].append(x + y)
        z[1].append(x - y)
    z[0] = sorted(z[0])
    z[1] = sorted(z[1])
    print(max(z[0][-1] - z[0][0], z[1][-1] - z[1][0]))



if __name__ == '__main__':
    main()


Measured memory_bytes: 27132
#include<iostream>
using namespace std;
int main(){
  int h[10]={1,2,4,8,16,32,64,128,256,512};
  int o,hk;
  while(cin>>o){
    hk = true;
    int w[1023][10]={0};
    for(int i=0;i<10;i++){
      if(h[i]>o) break;
      for(int j=o;j>=0;j--){
	if(j==0) w[h[i]][0] = h[i];
	else if(w[j][0]!=0&&j+h[i]<=o){
	  for(int n=0;n<10;n++){
	    if(w[j][n]==0){
	      for(int m=0;m<n;m++) w[j+h[i]][m] = w[j][m];
	      w[j+h[i]][n] = h[i];
	      break;
	    }
	  }
	}
	if(j==0) w[h[i]][0] = h[i];
      }
    }
      for(int i=0;i<10;i++){
	if(w[o][i]==0) break;
	if(hk!=true) cout << ' ';
	cout << w[o][i];
	if(hk==true) hk = false;
      }
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    int N,M;
    cin >> N>>M;
    int A[50];
    int B[50];
    int C[50];
    int D[50];
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
    }
    for(int i = 0;i < M ;i++){
        cin >> C[i] >> D[i];
    }
    for(int i = 0;i < N;i++){
        int ans = 1234567890; int num = 0;
        for(int j = 0;j < M;j++){
            
            if(ans > abs(A[i] - C[j]) + abs(B[i] - D[j])){
            ans = abs(A[i] - C[j]) + abs(B[i] - D[j]);
            num = j + 1;
            }
        }
        cout << num << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	int ans=n/x;
	if(n%x!=0)
	{
		ans++;
	}
	cout<<ans*t<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1)a+=100;
	if(b==1)b+=100;
	
	if(a==b)cout<<"Draw"<<endl;
	if(a<b)cout<<"Bob"<<endl;
	if(a>b)cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
import math

n, m = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))))
bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True)

csl = 0
for cnt, point in bcL:
    for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1

print(sum(aL))
exit()

Measured memory_bytes: 33804
import sys
input = sys.stdin.readline
N = int(input())
a = []
l = []
r = []
lr = []
u = []
d = []
ud = []
for _ in range(N):
  x, y, w = input().split()
  x, y = map(int, (x, y))
  a.append((x, y, w))

  if w == "L":
    l.append(x)
    ud.append(y)
  if w == "R":
    r.append(x)
    ud.append(y)
  if w == "U":
    u.append(y)
    lr.append(x)
  if w == "D":
    d.append(y)
    lr.append(x)

l.sort()
r.sort()
lr.sort()
u.sort()
d.sort()
ud.sort()

t = [0]
if len(l):
  if len(r): t.append((l[-1] - r[-1]) / 2)
  if len(lr):
    t.append(l[-1] - lr[-1])
    t.append(l[0] - lr[0])
if len(r):
  if len(l): t.append((l[0] - r[0]) / 2)
  if len(lr):
    t.append(lr[0] - r[0])
    t.append(lr[-1] - r[-1])
if len(d):
  if len(u): t.append((d[-1] - u[-1]) / 2)
  if len(ud):
    t.append(d[-1] - ud[-1])
    t.append(d[0] - ud[0])
if len(u):
  if len(d): t.append((d[0] - u[0]) / 2)
  if len(ud):
    t.append(ud[0] - u[0])
    t.append(ud[-1] - u[-1])

t = sorted(set(t), reverse = True)
while t[-1] < 0: t.pop()

def solve(tt):
  ll = float("inf")
  rr = -float("inf")
  uu = -float("inf")
  dd = float("inf")
  for x, y, w in a:
    xx = x
    yy = y
    if w == "L": xx -= tt
    if w == "R": xx += tt
    if w == "U": yy += tt
    if w == "D": yy -= tt
    ll = min(ll, xx)
    rr = max(rr, xx)
    uu = max(uu, yy)
    dd = min(dd, yy)
  return (rr - ll) * (uu - dd)

res = float("inf")
for tt in t: res = min(res, solve(tt))
print(res)

Measured memory_bytes: 85084
#include <iostream>

struct vector2 {
    double x, y;
};

bool is_inner_triangle(const vector2 &p, const vector2 &t1, const vector2 &t2, const vector2 &t3)
{
    vector2 p1 = { t1.x - p.x, t1.y - p.y }, p2 = { t2.x - p.x, t2.y - p.y }, p3 = { t3.x - p.x, t3.y - p.y };
    return (p1.x * p2.y - p1.y * p2.x < 0 && p2.x * p3.y - p2.y * p3.x < 0 && p3.x * p1.y - p3.y * p1.x < 0)
        || (p1.x * p2.y - p1.y * p2.x > 0 && p2.x * p3.y - p2.y * p3.x > 0 && p3.x * p1.y - p3.y * p1.x > 0);
}

int main()
{
    while (true) {
        vector2 p[4];
        char comma;
        std::cin >> p[0].x >> comma >> p[0].y;
        for (int i = 1; i < 4; ++i) std::cin >> comma >> p[i].x >> comma >> p[i].y;
        if (std::cin.eof()) break;

        if (is_inner_triangle(p[0], p[1], p[2], p[3]) || is_inner_triangle(p[1], p[2], p[3], p[0])
                || is_inner_triangle(p[2], p[3], p[0], p[1]) || is_inner_triangle(p[3], p[0], p[1], p[2]))
            std::cout << "NO" << std::endl;
        else
            std::cout << "YES" << std::endl;
    }
}

Measured memory_bytes: 1216
n = int(input())
s = {}
for _ in range(n):
    s_i = input()
    if s_i not in s:
        s[s_i] = 0
    s[s_i] += 1
s = sorted(s.items(), key=lambda x:x[1])
m = s[-1][1]
ans = []
for i in reversed(range(len(s))):
    if s[i][1] == m: ans.append(s[i][0])
    else: break
ans.sort()
for i in range(len(ans)): print(ans[i])


Measured memory_bytes: 43224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << 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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  if (n%1000 == 0) {
    cout << 0 << endl;
  } else {
    cout << 1000-(n%1000) << endl;
  }
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define SORT(n)         (n.begin(), n.end(), greater<lint>())       
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             10000000000000000
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    vector<char>v;
    stack<char>st;
    string s;
    cin>>s;

    REP(i, 0, s.size() - 1){
        if(s[i] == '0' || s[i] == '1') st.push(s[i]);
        else if(s[i] == 'B' && !st.empty()) st.pop();
    }
    while(!st.empty()){
        v.pb(st.top());
        st.pop();
    }
    reverse ALL(v);
    REP(i, 0, v.size() - 1) cout<<v[i];
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[105],b[105],c[105];
int k=1, x, y, z;
int main() {
    scanf("%s %s %s",a,b,c);
    while (true) {
        if (k==1) {
            if (x==strlen(a)) {
                printf("A\n");
                return 0;
            }
            if (a[x]=='a') k=1;
            else if (a[x]=='b') k=2;    
            else k=3;
            x++;
        }
        if (k==2) {
            if (y==strlen(b)) {
                printf("B\n");
                return 0;
            } 
            if (b[y]=='a') k=1;
            else if (b[y]=='b') k=2;
            else k=3;
            y++;
        }
        if (k==3) {
            if (z==strlen(c)) {
                printf("C\n");
                return 0;
            }
            if (c[z]=='a') k=1;
            else if (c[z]=='b') k=2;
            else k=3;
            z++;
        }
    }
}

Measured memory_bytes: 256
/*************************************************************************
    > File Name: aoj0005.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???19??\ ????????? 16??¶44???39?§?
 ************************************************************************/

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

#define ll long long
ll gcd(ll a,ll b){
	return b == 0 ? a : gcd(b,a%b);
}
int main(){
	ll a , b;
	while(~scanf("%lld%lld",&a,&b)){
		ll ret = gcd(a,b);
		printf("%lld %lld\n",ret,a*b/ret);
	}
	return 0;
}

Measured memory_bytes: 3132
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(m)]
ans=min(a)+min(b)
for i in range(m):
    ans=min(ans,a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2])
print(ans)

Measured memory_bytes: 38584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<int>> a(h, vector<int>(w));
    vector<int> b(h * w), c(h * w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
            a[i][j]--;
            b[a[i][j]] = i * w + j;
        }
    }

    for (int k = 0; k < d; k++) {
        int i0, j0, x = c[k] = 0;
        for (int l = k; l < h * w; l += d) {
            int i = b[l] / w;
            int j = b[l] % w;
            if (l != k) {
                c[l] = x += abs(i - i0) + abs(j - j0);
            }
            i0 = i;
            j0 = j;
        }
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--;

        cout << c[r] - c[l] << '\n';
    }

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        int sum = 0;
        while (tmp != 0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if (sum >= a && b >= sum) {
            cnt++;
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>

int main(int argc, void **argv)
{
	long long n, x;
	long long l[10000+1];
	int i;

	scanf("%lld %lld", &n, &x);
	l[0] = 0;
	for (i = 1; i <= n; i++)
	{
		long long d;
		scanf("%lld", &d);
		l[i] = l[i-1] + d;
	}

	for (i = 1; i <= n; i++)
	{
		if( l[i] > x )
		{
			printf("%d\n", i);
			return 0;
		}
	}

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

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;
  vector<int> canMoveX(16001,0);
  vector<int> canMoveY(16001,0);
  bool mukiX=true;
  int susumu=0,now=0;
  for(susumu=0;1;susumu++){
    now++;
    if(s[now-1]=='T'){
      break;
    }else if(now==s.length()){
      susumu++;
      break;
    }
  }
  mukiX=false;
  canMoveX[susumu+8000]=1;
  canMoveY[8000]=1;
  if(now==s.length()){
    if(canMoveX[x+8000]&&canMoveY[y+8000]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
  }
  while(1){
    for(susumu=0;1;susumu++){
      now++;
      if(s[now-1]=='T'){
        break;
      }else if(now==s.length()){
        susumu++;
        break;
      }
    }
    if(mukiX){
      for(int i=0;i<16001;i++){
        if(canMoveX[i]&1){
          canMoveX[i-susumu]|=2;
          canMoveX[i+susumu]|=2;
        }
      }
      for(int i=0;i<16001;i++){
        canMoveX[i]/=2;
      }
    }else{
      for(int i=0;i<16001;i++){
        if(canMoveY[i]&1){
          canMoveY[i-susumu]|=2;
          canMoveY[i+susumu]|=2;
        }
      }
      for(int i=0;i<16001;i++){
        canMoveY[i]/=2;
      }
    }
    mukiX=(!mukiX);
    if(now==s.length()){
      if(canMoveX[x+8000]&&canMoveY[y+8000]){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[55],b[55];
ll c[55], d[55];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    rep(i, m){
        cin >> c[i] >> d[i];
    }

    rep(i, n){
        ll tmp = LINF;
        rep(j, m) tmp = min(tmp, abs(a[i]-c[j]) + abs(b[i]-d[j]));
        rep(j, m) {
            if (tmp == abs(a[i]-c[j]) + abs(b[i]-d[j])){
                cout << j+1 << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main(){ 
  string s;
  cin >> s;
  int n = s.size();
  vector<int> dp(2, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    vector<int> next(2, INF);
    int d = s[i] - '0';
    next[0] = min(next[0], dp[0] + d);
    next[0] = min(next[0], dp[1] + d);
    next[1] = min(next[1], dp[0] + 11 - d);
    next[1] = min(next[1], dp[1] + 9 - d);
    dp = next;
  }
  cout << min(dp[0], dp[1]) << endl;
  return 0;
} 

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  while(a>0){
    ans++;
    a--;
    k--;
    if(k==0){cout<<ans<<endl;return 0;}
  }
  while(b>0){
    b--;
    k--;
    if(k==0){cout<<ans<<endl;return 0;}
  }
  while(c>0){
    ans--;
    c--;
    k--;
    if(k==0){cout<<ans<<endl;return 0;}
  }
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    int result = 0 ;
    for(int i=0; i < S.length(); i++){
        if (S[i] == '+'){
            result++;
        }
        else if(S[i] == '-'){
            result--;
        }
    }
    cout << result << endl;
}

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

int main(){
    int d;
    cin>>d;
    if(d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(d==23){
        cout << "Christmas Eve Eve" << endl;
    }else if(d==24){
        cout << "Christmas Eve" << endl;
    }else if (d == 25){
        cout << "Christmas" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>

using namespace std;


int main(){
  vector<string> v;
  string s, t;
  cin >> s;
  cin >> t;
  int sl, tl, result;
  sl = s.length();
  tl = t.length();
  result = -1;
  for (int i=0;i<sl-tl+1;i++) {
    for (int j=0;j<tl;j++) {
      if (t[j] != s[i+j] && s[i+j] != '?') {
	break;
      }
      if (j == tl - 1) {
	result = i;
      }
    }
  }
  if (result < 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  } else {
    for (int i=0;i<sl;i++) {
      if (i == result) {
	for (int j=0;j<tl;j++) {
	  s[i+j] = t[j];
	}
	i = i+tl-1;
      } else if (s[i] == '?'){
	s[i] = 'a';
      }
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ll N, D; cin >> N >> D;
  ll t[N], F[N]; FOR(i,0,N) cin >> t[i] >> F[i];
  FOR(i,0,N) F[i]--;
  stack<ll> st;
  ll d = 0;
  ll ans = 0;
  if(t[0] < F[0]) {
    cout << -1 << endl;
    return 0;
  }
  st.push(t[0]);
  d = 1;
  FOR(i, 1, N) {
        // ????????????
        if(t[i] >= t[i-1] + F[i-1] + F[i]) {
          while(!st.empty()) {
            ans += t[i-1] + F[i-1] - st.top();
            st.pop();
          }
          st.push(t[i]);
          d = 1;
        } else if(t[i] >= t[i-1] + abs(F[i] - F[i-1])){
          if(D < d + 1) {
            cout << -1 << endl;
            return 0;
          }
          d++;
          st.push(t[i]);
        } else {
          cout << -1 << endl;
          return 0;
        }
  }
  while(!st.empty()) {
    ans += t[N-1] + F[N-1] - st.top();
    st.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5272
# coding: utf-8

fennec = input().split(" ")
N = int(fennec[0])
K = int(fennec[1])
enemys = input().split(" ")
enemys_int = [int(s) for s in enemys]
enemys_int.sort()
ans = 0
if K < N:
    if K == 0:
        for i in enemys_int:
            ans += int(i)
        print(ans)
    else:
        del enemys_int[-K:]
        for i in enemys_int:
            ans += int(i)
        print(ans)
else:
	print("0")

Measured memory_bytes: 27556
#include<stdio.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head=0, tail=0, n;

void enqueue(P);
P dequeue(void);

void enqueue(P x){
  Q[tail++] = x;
  if(tail == LEN) tail=0;
}

P dequeue(){
  if(head == LEN) head=0;
  return Q[head++];
}

int main(){
  int i, q,dif,q_sum=0;
  P R;
  scanf("%d %d", &n, &q);

  for (i = 0;i < n;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);

    enqueue(Q[i]);
  }

  i=0;
  while(i < n){
    R = dequeue();
    dif = R.t - q;
    if(dif > 0){
      q_sum += q;
      R.t = dif;
      enqueue(R);
    }
    else{
      q_sum += q + dif;
      R.t = q_sum;
      printf("%s %d\n",R.name,R.t);
      i++;
    }
  }
  
  return 0;
}



Measured memory_bytes: 11852
#include <bits/stdc++.h>
#include <inttypes.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      Int res = 0;
      for(Int i = 0; i < n; ++i) {
         Int x, y; scan(x, y);
         res += y - x + 1;
      }
      printf("%ld\n", res);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define INFTY 1000000000

void mergeSort(int S[],int,int);
void merge(int S[],int,int,int);
int left,right,S[N],n,count=0;


int main(){
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  left = 0;
  right = n;
  mergeSort(S,left,right);
  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);
  return 0;
}


void mergeSort(int S[],int left,int right){
  if(left+1<right){
    int mid = (left + right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}

void merge(int S[],int left,int mid,int right){
int n1,n2,i,j,k;
n1 = mid - left;
n2 = right - mid;

 int L[n1],R[n2];
  for(i=0;i<n1;i++){
  L[i] = S[left+i];
 }
for(j=0;j<n2;j++){
  R[j] = S[mid+j];
 }

L[n1] = INFTY;
R[n2] = INFTY;
i = 0;
j = 0;

for (k=left;k<right;k++){
  count++;
  if (L[i] <= R[j]){
    S[k] = L[i];
    i++;
  }
  else{
    S[k] = R[j];
    j++;
  }
 }
}





Measured memory_bytes: 5624
s = int(input())
s_list =[s]
for i in range(2, 10**10):
  if s_list[-1]%2 == 0:
    tmp = int(s_list[-1]/2)
  else:
    tmp = 3*s_list[-1] + 1
  if tmp in s_list:
    ans = i
    break
  else:
    s_list.append(tmp)
print(ans)

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	typedef long long ll;
	vector<ll> a(n), b(n);
	for (ll &p:a) cin>>p;
	for (ll &p:b) cin>>p;
	typedef pair<ll, int> pii;
	priority_queue<pii> Q;
    for (ll i = 0; i < n; i ++) {
		if (b[i] < a[i]) {
			cout<<-1;
			return 0;
		}
		else if (b[i] > a[i]) Q.emplace(b[i], i);
    }
    long long ans = 0;
    while (!Q.empty()) {
        int i = Q.top().second; Q.pop();

		ll to = max(b[(i+1)%n], b[(i+n-1)%n]);

		ll sum = b[(i+1)%n] + b[(i+n-1)%n];

		if (b[i] < sum) {
			cout<<-1;
			return 0;
		}

        if (a[i] >= to) {
			if ((b[i] - a[i]) % sum) {
				cout<<-1;
				return 0;
			}
			ans += (b[i] - a[i]) / sum;
			b[i] = a[i];
        }

        else {
			ll step = (b[i] - to) / sum + 1;
			b[i] -= step * sum;
			if (b[i] < a[i]) {
				cout<<-1;
				return 0;
			}
			ans += step;
			if (b[i] > a[i]) Q.emplace(b[i], i);
        }
    }
    cout<<ans;
	return 0;
}


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

int check(int a,int b,int c){
	if(a*a+b*b==c*c) return 1;
	else return 0;
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b,c;
		int aa,bb,cc;
		cin>>a>>b>>c;
		aa=a<b?a:b;
		bb=a<b?b:a;
		cc=bb<c?c:bb;
		bb=bb<c?bb:c;
		int ans=check(aa,bb,cc);
		if(ans) cout<<"YES"<<endl;
		else    cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 300000 + 10;

int K, N;
int ans[MAXN];

void Work()
{
	scanf("%d%d", &K, &N);
	
	if (K % 2 == 0)
	{
		printf("%d", K / 2);
		for (int i = 0; i < N - 1; i ++)
			printf(" %d", K);
		printf("\n");
		return;
	}
	
	if (K == 1)
	{
		int r = (N + 1) / 2;
		printf("1");
		for (int i = 0; i < r - 1; i ++)
			printf(" 1");
		printf("\n");
		return;
	}


	for (int i = 0; i < N; i ++)
		ans[i] = (K + 1) / 2;
	int cur = N / 2;
	for (int r = 0; r < cur; r ++)
	{
		int j = N - 1;
		while (ans[j] == 0)
			j --;
		ans[j] --;
		if (ans[j] != 0)
		{
			for (int i = j + 1; i < N; i ++)
				ans[i] = K;
		}
	}

	printf("%d", ans[0]);
	for (int i = 1; i < N; i ++)
	{
		if (ans[i] == 0) break;
		printf(" %d", ans[i]);
	}
	printf("\n");
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 3456
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  int n; cin>>n;
  int nmax=0, cnt=0;
  rep (i,n) {
    int num; cin>>num;
    if (nmax <= num) {
      cnt++;
      nmax = num;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
/* 

И пусть меня погубит, то к чему я
Бегу, не жалея ног.
И если мне суждено сгореть на восходе,
Я буду идти вперёд.

*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

const bool dbg_flg = 0;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n' 

const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

int n;
int a[MAXN];

void solve() {
	cin >> n;

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

	for (int i = 1; i <= n; i++) {
		if (a[i] % 2 == 1) continue;

		if (a[i] % 5 == 0 || a[i] % 3 == 0) continue;

		cout << "DENIED";
		return;
	}

	cout << "APPROVED";
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int[] t = new int[n];
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                t[i] = sc.nextInt();
                min = Math.min(min, t[i]);
                max = Math.max(max, t[i]);
            }

            int ans = Integer.MAX_VALUE;
            for (int i = min; i <= max; i++) {
                int sum = 0;
                for (int j = 0; j < n; j++) {
                    int diff = t[j] - i;
                    sum += diff * diff;
                }
                ans = Math.min(ans, sum);
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    int mindiff=inf;
    for(int i=0;i<s.size()-2;i++){
        int num = stoi(s.substr(i,3));
        mindiff=min(mindiff,abs(753-num));
    }

    cout << mindiff << endl;

    return 0;
}


Measured memory_bytes: 3532
class Solver(object):
    def __init__(self):
        self.n = int(input())
        self.heights = []
        for _ in range(self.n):
            self.heights.append(list(map(int, input().split(" "))))

    def solve(self):
        for cx in range(101):  # cx = 0 .. 100
            for cy in range(101):  # cy = 0 .. 100
                ch = 1
                for x, y ,h in self.heights:
                    if h > 0:
                        ch = h + abs(cx - x) + abs(cy - y)
                        break
                isValid = True
                for x, y, h in self.heights:
                    if max(ch - abs(cx - x) - abs(cy - y), 0) != h:
                        isValid = False
                if isValid:
                    print(cx, cy, ch)
                    return

    def debug(self):
        for h in self.heights:
            print(h)


if __name__ == "__main__":
    s = Solver()
    s.solve()

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

int main() {
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << "\n";
    } else if(S == "Cloudy"){
        cout << "Rainy" << "\n";
    } else{
        cout << "Sunny" << "\n";
    }
    return 0;
}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  if(b - a >= 2 * k){
    for(int i = 0; i < k; i++){
      cout << a + i << endl;
    }
    for(int i = k - 1; i >= 0; i--){
      cout << b - i << endl;
    }
  }
  else{
    for(int i = a; i <= b ; i++){
      cout << i << endl;
    }
  }
}

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

int main () {
    char C;
    cin >> C;

    if(C=='a'){
        cout << 'b' << endl;
    }

    if(C=='b'){
        cout << 'c' << endl;
    }

    if(C=='c'){
        cout << 'd' << endl;
    }

    if(C=='d'){
        cout << 'e' << endl;
    }

    if(C=='e'){
        cout << 'f' << endl;
    }

    if(C=='f'){
        cout << 'g' << endl;
    }

    if(C=='g'){
        cout << 'h' << endl;
    }

    if(C=='h'){
        cout << 'i' << endl;
    }

    if(C=='i'){
        cout << 'j' << endl;
    }

    if(C=='j'){
        cout << 'k' << endl;
    }

    if(C=='k'){
        cout << 'l' << endl;
    }

    if(C=='l'){
        cout << 'm' << endl;
    }

    if(C=='m'){
        cout << 'n' << endl;
    }

    if(C=='n'){
        cout << 'o' << endl;
    }

    if(C=='o'){
        cout << 'p' << endl;
    }

    if(C=='p'){
        cout << 'q' << endl;
    }

    if(C=='q'){
        cout << 'r' << endl;
    }

    if(C=='r'){
        cout << 's' << endl;
    }

    if(C=='s'){
        cout << 't' << endl;
    }

    if(C=='t'){
        cout << 'u' << endl;
    }

    if(C=='u'){
        cout << 'v' << endl;
    }

    if(C=='v'){
        cout << 'w' << endl;
    }

    if(C=='w'){
        cout << 'x' << endl;
    }

    if(C=='x'){
        cout << 'y' << endl;
    }

    if(C=='y'){
        cout << 'z' << endl;
    }
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vei A1(N); rep(i,N) cin >> A1[i];
    vei A2(N); rep(i,N) cin >> A2[i];

    int ans = 0;
    rep(i,N) {
        int temp = 0;
        rep(j,N) {
            if(j <= i) temp += A1[j];
            if(j >= i) temp += A2[j];
        }
        ans = max(temp, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
struct edge{
	int to,nxt,d,col;
}e[2*maxn];
struct query{
	int x,col,d,id,w;
}q[4*maxn];
int fir[maxn],fa[maxn],dep[maxn],size[maxn],hson[maxn],top[maxn],id[maxn];
ll dist[maxn];
ll sum[maxn],cnt[maxn],ans[maxn];
int n,m,tot,last;
inline void add_edge(int x,int y,int z,int w){e[tot].to=y; e[tot].col=z; e[tot].d=w; e[tot].nxt=fir[x]; fir[x]=tot++;}
void dfs1(int now)
{
	size[now]=1; hson[now]=0; id[now]=++tot;
	for(int i=fir[now];~i;i=e[i].nxt)
		if(e[i].to!=fa[now]){
			fa[e[i].to]=now; dep[e[i].to]=dep[now]+1;
			dist[e[i].to]=dist[now]+e[i].d;
			dfs1(e[i].to);
			size[now]+=size[e[i].to];
			if(size[e[i].to]>size[hson[now]])hson[now]=e[i].to;
		}
}
void dfs2(int now,int tp)
{
	top[now]=tp;
	if(hson[now])dfs2(hson[now],tp);
	for(int i=fir[now];~i;i=e[i].nxt)
		if(e[i].to!=fa[now]&&e[i].to!=hson[now])dfs2(e[i].to,e[i].to);
}
inline int getlca(int x,int y)
{
	while(top[x]!=top[y]){
		if(dep[top[x]]<dep[top[y]]){int tmp=x; x=y; y=tmp;}
		x=fa[top[x]];
	}
	return dep[x]<dep[y]?x:y;
}
bool cmp(query x,query y){return id[x.x]<id[y.x];}
void solve(int now)
{
	while(last<=tot&&id[q[last].x]==id[now]){
		ans[q[last].id]+=q[last].w*(dist[now]-sum[q[last].col]+(ll)cnt[q[last].col]*q[last].d);
		++last;
	}
	for(int i=fir[now];~i;i=e[i].nxt)
		if(e[i].to!=fa[now]){
			sum[e[i].col]+=e[i].d; ++cnt[e[i].col];
			solve(e[i].to);
			sum[e[i].col]-=e[i].d; --cnt[e[i].col];
		}
}
int main()
{
	n=read(); m=read();
	memset(fir,255,sizeof(fir));
	for(int i=1;i<n;i++){
		int x=read(),y=read(),z=read(),w=read();
		add_edge(x,y,z,w); add_edge(y,x,z,w);
	}
	fa[1]=dep[1]=0; tot=0;
	dfs1(1);
	dfs2(1,1);
	tot=0;
	for(int i=1;i<=m;i++){
		int col=read(),d=read(),x=read(),y=read();
		int lca=getlca(x,y);
		q[++tot]={x,col,d,i,1};
		q[++tot]={y,col,d,i,1};
		q[++tot]={lca,col,d,i,-1};
		q[++tot]={lca,col,d,i,-1};
	}
	std::sort(q+1,q+tot+1,cmp);
	last=1;
	solve(1);
	for(int i=1;i<=m;i++)
		writeln(ans[i]);
	return 0;
}

Measured memory_bytes: 28032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int a,b; cin >> a >> b;


    EFOR(i, 1, 100000) {
        if(floor(i*0.08) == a && floor(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int n,k;cin>>n>>k;
  if(n%k==0)cout<<0<<endl;
  else cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 256
n, m, c = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    a = [int(i) for i in input().split()]
    tmp = c + sum([a[j]*b[j] for j in range(m)])
    if tmp > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3188
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };


int main()
{
	int n;
	while (cin >> n&&n)
	{
		vector< pair<double, string> > x;
		for (int i = 0; i < n; i++)
		{
			string l;
			int p, a, b, c, d, e, f, s,m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			double t = 0,v=0;
			t += a + b + c+(d+e)*m;
			v = s*m*f - p;
			x.push_back(make_pair(-v / t, l));
		}
		sort(x.begin(), x.end());
		for (int i = 0; i < n; i++)
		{
			cout << x[i].second << endl;
		}
		cout << "#" << endl;
	}


}

Measured memory_bytes: 3188
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let n:usize = read!();
    let m:usize = read!();
    let mut a:usize = 0;
    a = n%m;
    if a>m-a {
        a = m-a;
    }
    println!("{}",a);
}

Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=200002;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
ll int power(ll int a,ll int b)
{
	ll int ans=1,f=a;
	while(b)
	{
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	}
	return ans%mod;
}

int main()
{
   ll int a;
  string b;
   cin>>a>>b;
   
   //b=b*100;
   ll int y=0;
   y=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
   a=a*y;
   a=a/100;
  // ll int u=a*b;
   cout<<a<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

int main() 
{
    fastio
    int n;
    cin>>n;
    if(n%10==7) {
        cout<<"Yes"<<endl;
        return 0;
    }
    n /= 10;
    if(n%10==7) {
        cout<<"Yes"<<endl;
        return 0;
    }
    n/=10;
    if(n%10==7) {
        cout<<"Yes"<<endl;
        return 0;
    }

    cout<<"No"<<endl;
}


Measured memory_bytes: 3636