akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
char grid[501][501];
char red1[501][501];
char red[501][501];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int h,w;cin >> h >> w;
    FOR(i, h)FOR(j, w)cin >> grid[i][j];
    FOR(i, w)cout << '#';cout << endl;
    FOR(j, h -2){FOR(i, w)cout << ((i % 2) && !(grid[j+1][i] == '#') ? '.' : '#'); cout << endl;}
    FOR(i, w)cout << '.';cout << endl;
    cout << endl;

    FOR(i, w)cout << '.';cout << endl;
    FOR(j, h -2){FOR(i, w)cout << ((i % 2) == 0 && !(grid[j+1][i] == '#') ? '.' : '#'); cout << endl;}
    FOR(i, w)cout << '#';cout << endl;

}




Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,q;
	int m,d;
	int max;
	int maxd;

	while(1){
		cin>>n>>q;
		if(n+q==0) break;

		map<int,int> meeting;

		for(int i1=0;i1<n;i1++){
			cin>>m;

			for(int i2=0;i2<m;i2++){
				cin>>d;
				meeting[d]++;
			}
		}

		max=0;
		for(map<int,int>::iterator it=meeting.begin();it!=meeting.end();it++){
			if(max<(*it).second) {
				max=(*it).second;
				maxd=(*it).first;
			}
		}

		if(max<q) cout<<0<<endl;
		else cout<<maxd<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int main() {
	int n, max = 0, sum = 0, p;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> p;
		if(p > max){
			sum += max/2;
			max = p;
			sum += p/2;
		}
		else	sum += p;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#動的計画法
#E - Knapsack 2
N, W = list(map(int,input().split()))
item = [list(map(int,input().split())) for i in range(N)]
V = 0
for i in range(N):
    V += item[i][1]
dp = [float("INF")]*(V+1)
dp[0] = 0
for i in range(N):
    v = item[i][1]
    w = item[i][0]
    for j in range(V-v,-1,-1):
        if dp[j] != float("INF"):
            if dp[j] + w < dp[j+v]:
                dp[j+v] = dp[j] + w
for i in range(len(dp)-1,-1,-1):
    if dp[i] <= W:
        print(i)
        break
#print(max(dp.index(i for i in dp if i <= W)))
#print(dp)
#i for i in ans if i >= w

Measured memory_bytes: 58708
#include <cstdio>
using namespace std;
int N, K, num;
int k[10];

int main()
{
  scanf("%d%d", &N, &K);
  for (int i = 0; i < K; ++i) {
    scanf("%d", &num);
    k[num] = 1;
  }
  for (int ans = N; ans <= N * 10; ++ans) {
    int now = ans;
    bool isCorrect = true;
    while (now) {
      int ones = now % 10;
      if (k[ones]) {
        isCorrect = false;
      }
      now /= 10;
    }
    if (isCorrect) {
      printf("%d", ans);
      break;
    }
  }
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    PRINT(H * W - h * W - w * H + w * h);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????

int ss[1000000];

int main() {
	int n, m;
	string s;
	while (cin >> n && n != 0) {
		cin >> m >> s;

		//?????????S???(I=1),(O=0)???????????????
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] == 'I') { ss[i] = 1; }
			else { ss[i] = 0; }
		}

		int cnt = 0;
		for (int i = 0; i < m - (n * 2 + 1); ++i) {
			if (ss[i] == 1) {
				int temp = i;
				int k = i + 1;
				bool flg = true;
				while (k - temp < (n * 2 + 1)) {
					if (ss[k] != 0) {
						flg = false;
						break;
					}
					else if (ss[++k] != 1) {
						flg = false;
						break;
					}
					++k;
				}
				if (flg) { ++cnt; }
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

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

int main()
{
    int N, K;
    long int ans = 0;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    for (int i = 0; i < N - K; i++)
    {
        ans += H.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
var
	N,x,w,i:Longint;
begin
	read(N,x);
	w:=2*N-1;
	if x mod w>1 then begin
		writeln('Yes');
		for i:=1 to w do writeln(w-(N-x-i+w*2)mod w);
	end else writeln('No');
end.


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	const double PI = acos( -1 );

	void solve() {
		double A, B, X;
		cin >> A >> B >> X;

		double l = PI/2;
		double r = 0;

		for( int i = 0; i < 10000; ++i ) {
			double m = (l+r) / 2;
			if( f( A, B, m ) < X ) {
				l = m;
			}
			else {
				r = m;
			}
		}

		cout << l/PI * 180 << endl;
	}

	double f( double a, double b, double theta ) {
		if( theta >= PI/2 ) { return 0; }

		double ret;
		double t = tan( theta );
		if( a*t <= b ) {
			ret = a*a*b - a*a*a*t/2;
		}
		else {
			ret = b*b/t*a/2;
		}

		return ret;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 4132
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);
  
  ll N,D; cin>>N>>D;
  vector<ll> x(N),y(N); rep(i,N) cin>>x[i]>>y[i];
  
  two_sat ts(N);
  rep(i,N){
    for(int j=i+1;j<N;j++){
      if(abs(x[i]-x[j])<D) ts.add_clause(i,0,j,0);
      if(abs(y[i]-y[j])<D) ts.add_clause(i,1,j,1);
      if(abs(x[i]-y[j])<D) ts.add_clause(i,0,j,1);
      if(abs(y[i]-x[j])<D) ts.add_clause(i,1,j,0);
    }
  }
  
  if(!ts.satisfiable()) {cout<<"No"<<'\n'; return 0;}
  else cout<<"Yes"<<'\n';
  
  auto ans_vec=ts.answer();
  
  rep(i,N) cout<<(ans_vec[i]?x[i]:y[i])<<'\n';
  
  return 0;
}

Measured memory_bytes: 3804
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string S; cin >> S;
    int ansL = 0, ansR = 0;
    int lenR = 0, lenL = 0;
    vector<int> L,R;
    rep(i, N) {
        if (S[i] == 'L') lenL++;
        if ((S[i] == 'R' || i == N  - 1) && lenL != 0) {
            ansL += lenL - 1;
            if (L.size() == 0 && S[0] == 'L') {
                lenL--;
            } else if (i == N - 1 && S[N - 1] == 'L') {
                lenL--;
            }
            L.push_back(lenL);
            lenL = 0;
        }
    }
    rrep(i, N - 1) {
        if (S[i] == 'R') lenR++;
        if ((S[i] == 'L' || i == 0) && lenR != 0) {
            ansR += max(0, lenR - 1);
            if (R.size() == 0 && S[N - 1] == 'R') {
                lenR--;
            }else if (i == 0 && S[0] == 'R') {
                lenR--;
            }
            R.push_back(lenR);
            lenR = 0;
        }
    }
    sort(L.begin(), L.end(), greater<int>());
    sort(R.begin(), R.end(), greater<int>());
    //cout << ansL << " " <<ansR << endl;
    int prevL = ansL, prevR = ansR;
    rep(i, min(K, (int)R.size())) {
        ansL += R[i] + 1;
        ansR -= R[i] - 1;
    }
    int ans = ansL + ansR;
    ansL = prevL; ansR = prevR;
    rep(i, min(K, (int)L.size())) {
        ansR += L[i] + 1;
        ansL -= L[i] - 1;
    }
    ans = max(ans, ansL + ansR);
    cout << min(N - 1, ans)<< endl;

    return 0;
}


Measured memory_bytes: 972
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

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

const int N = 2e5 + 5;
void tc(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> q; // max heap
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        q.push(x);
    }
    while(m > 0){
        int top = q.top();
        q.pop();
        top /= 2;
        q.push(top);
        m--;
    }
    ll cost = 0;
    while(SZ(q)){
        cost += q.top();
        q.pop();
    }
    cout << cost;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 892
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//change
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

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

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

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

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

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

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

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

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i)
    {
        cin >> A[i];
        N -= A[i];
    }
    if (N >= 0)
    {
        cout << N << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3612
import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
# import bisect      # bisect_left(insert位置), bisect_right(slice用)
# import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5
# --------------------------------------------------------------

n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7

lis = list(itertools.accumulate(a))

total = 0

for i in range(n-1):
    total += (a[i] * (lis[n-1]-lis[i])) % MOD

print(total % MOD)


Measured memory_bytes: 31260
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include "boost/multiprecision/cpp_int.hpp"
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int N, K; std::cin >> N >> K;

	int distance = 0;

	for (int i = 0; i < N; i++) {

		int x; std::cin >> x;

		if (std::min(x, abs(K - x)) == x) {
			distance += 2 * x;
		}
		else {
			distance += abs(K - x) * 2;
		}

	}

	std::cout << distance;


	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    ll L;
    cin >> L;
    vector<int> B(N);
    rep(i, N){
        int l = i + 1, r = N;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(X[mid] - X[i] <= L) l = mid;
            else r = mid;
        }
        B[i] = l;
    }
    
    // doubling
    int n = N;
    int logN = 1;
    while(n > 0) {
        n >>= 1;
        logN++;
    }
    vector<vector<int>> D(logN, vector<int>(N));
    D[0] = B;
    
    repd(i, 1, logN){
        rep(j, N){
            if (D[i - 1][j] == N) D[i][j] = N;
            else D[i][j] = D[i - 1][D[i - 1][j]];
        }
    }
    
    
    int Q;
    cin >> Q;
    vector<pair<int, int>> A(Q);
    rep(i, Q){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        a--, b--;
        
        int ret = 1;
        for(int j = logN - 1; j >= 0; j--){
            if(D[j][a] < b){
                ret += 1 << j;
                a = D[j][a];
            }
        }
        output(ret, 0);
    }

    
    return 0;
}

Measured memory_bytes: 9848
import java.util.Scanner;

/**
 * C
 */
public class Main {
    static long ans = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.nextLine();
        calc(S, "");

        System.out.println(ans);
        sc.close();
    }
    
    static void calc(String s, String rest) {
        long n1 = Long.parseLong(s);
        long n2 = 0;
        if (rest.length() != 0) {
            n2 = Long.parseLong(rest);
        }
        
        ans += n1 + n2;
        ans += (Math.pow(2, s.length() - 1) - 1) * n2;

        for (int i = 1; i < s.length(); i++) {
            calc(s.substring(0, i), s.substring(i, s.length()));
        }
    }
}

Measured memory_bytes: 23248
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a, b;
int main(void){
    // Your code here!
    cin >> n >> a >> b;
    if (a > b || (n == 1 && a < b)) cout << 0 << endl;
    else cout << (n - 2) * (b - a) + 1 << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    lr = [list(map(int, input().split())) for i in range(N)]

    ans = 0
    for i in range(N):
        l, r = lr[i]
        ans += r- l + 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll A, B;
    cin >> A >> B;
    if((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

vector<vector<int>> edge(MAX);
int used[MAX];
//
int main(){
	int N;cin>>N;
	REP(i,N-1){
		int a,b;
		cin>>a>>b;--a;--b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	queue<int> fe[2];
	fe[0].push(0),fe[0].push(-1);
	fe[1].push(N-1),fe[1].push(-1);
	used[0]=1;used[N-1]=2;

	while(!fe[0].empty() || !fe[1].empty()){
		REP(i,2){
			if(fe[i].empty())continue;
			int f = fe[i].front();fe[i].pop();
			while(f != -1){
				for(int itr : edge[f]){
					if(used[itr]!=0)continue;
					fe[i].push(itr);
					used[itr]=i+1;
				}
				f = fe[i].front();fe[i].pop();
			}
			if(!fe[i].empty())fe[i].push(-1);
		}
	}

	int FenCnt=0;
	REP(i,N)if(used[i]==1)FenCnt++;

	cout << ((N/2)<FenCnt ? "Fennec" : "Snuke") << endl;


	return 0;
}




Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	cin >> s;
	
	if( n == 1 ){
		cout << 3 << endl;
		ret 0;
	}

	stack<char> st;
	vector<short> v;

	rep(i,0,n){
		if( st.size() == 0 ) st.push(s[i]);
		else{
			if( s[i] == st.top() ){
				v.push_back(2);
				st.pop();
			}
			else{
				v.push_back(1);
				st.pop();
				st.push(s[i]);
			}
		}
	}

	if( st.size() > 0 ) v.push_back(1);
	
	//rep(i,0,v.size()) cout << v[i];
	//cout << endl;

	ll ans;
	if( v[0] == 1 ) ans = 3;
	else ans = 6;
	
	short bef = v[0];

	rep(i,1,v.size()){
		if( bef == 1 ) ans *= 2;
		else{
			if( v[i] == 2 ) ans *= 3;
		}
		bef = v[i];
		ans %= mod;
	}
	
	cout << ans << endl;
	ret 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string sa, sb, sc; 
  cin >> sa >> sb >> sc; 

  int i = 0, j = 0, k = 0;
  char x = 'a';

  while (true) {
    if (x == 'a') {
      i++;
      if (i > sa.size()) {
        x = 'A';
        break;
      }   
      x = sa[i - 1]; 
    }   

    if (x == 'b') {
      j++;
      if (j > sb.size()) {
        x = 'B';
        break;
      }   
      x = sb[j - 1]; 
    }   
    if (x == 'c') {
      k++;
      if (k > sc.size()) {
        x = 'C';
        break;
      }   
      x = sc[k - 1]; 
    }   
  }
  cout << x << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long N;
  cin >> N;
  N *= 3;
  vector<long> A(N);
  priority_queue<long, vector<long>, greater<long>> LQ;
  priority_queue<long> RQ;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i < N / 3) LQ.push(A.at(i));
    if (i >= N / 3 * 2) RQ.push(A.at(i));
  }
  long l = accumulate(A.begin(), A.begin() + N / 3, 0L);
  long r = accumulate(A.end() - N / 3, A.end(), 0L);
  long ans = l - r;
  vector<long> L, R;
  L.push_back(l);
  R.push_back(r);
  for (int i = N / 3; i < N / 3 * 2; i++) {
    long tmp = LQ.top();
    if (tmp >= A.at(i)) {
      L.push_back(l);
      continue;
    }
    l += A.at(i) - tmp;
    L.push_back(l);
    LQ.pop();
    LQ.push(A.at(i));
  }
  for (int i = N / 3 * 2 - 1; i >= N / 3; i--) {
    long tmp = RQ.top();
    if (tmp <= A.at(i)) {
      R.push_back(r);
      continue;
    }
    r -= tmp - A.at(i);
    R.push_back(r);
    RQ.pop();
    RQ.push(A.at(i));
  }
  reverse(R.begin(), R.end());
  for (int i = 0; i < (long) L.size(); i++) {
    ans = max(ans, L.at(i) - R.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 9440
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, h, w;

signed main() {
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 892
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.
   PREFER CODING RATHER THAN MEDITATION !!!*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long
#define ld long double
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define T ll t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define F first
#define S second
#define I insert
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())
#define pb push_back
#define ppb pop_back
 
const ll maxs = 1e6+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
ll fastpow(ll x,ll y)
{ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
ll inv(ll x){ return fastpow(x , mod - 2);}


bool vis[maxs];
vector<ll>graph[maxs];
//ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN



//using lli = cpp_int;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin >> a >> b;
    if(b == 1 || a == 1)
        cout << 1;
    
    else if(b & 1)
    {
        ll v1 = b / 2;
        ll v2 = v1 + 1;
        if(a & 1)
        {
            a--;
            ll ans =( (a / 2) * (v1 + v2)) + v2;
            cout << ans;
        }
        else
        {
            ll ans =( (a / 2) * (v1 + v2));
            cout << ans;
        }      
    }
    else
    {
        ll v1 = b / 2;
        //ll v2 = v1 + 1;
        ll ans = v1 * a;
        cout << ans;
    }
   
    // lli a,b,c;
    // cin >> a >>  b >> c;
    // // ll left = sqrtl(a) + sqrtl(b);
    // // ll right = sqrtl(c);
    // lli right = (c - a - b);
    // lli left = 4 * a * b;
    // right = right * right;
    // // cout << right << " " << left;
    // // return 0;
    // if(right > left)
    //     cout << "Yes";
    // else
    //     cout << "No";
    
}
    



Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 88;

int n;
int a[N];

void solv()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    ll ans = 1000;
    for (int i = 1; i < n; ++i)
    {
        if (a[i] < a[i + 1])
        {
            ll q = (ans / a[i]);
            ans -= q * a[i];
            ans += q * a[i + 1];
        }
    }
    printf("%lld\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


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

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector< pair <long , long> > pair(n);

	for(int i = 0; i < n; i++){
		cin >> pair[i].first >> pair[i].second;
	}

	long long ans = 0;
	sort(pair.begin(), pair.end());

	int j = 0;
	while(m != 0){
		if(pair[j].second <= m){
			ans += pair[j].first * pair[j].second;
			m -= pair[j].second;
		}else{
			ans += pair[j].first * m;
			m -= m;
		}
		j++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var result = new int[n];
        result[0] = 0;
        for (int i = 0; i < n - 1; i++)
            result[i + 1] = vals[i + 1] <= vals[i] ? result[i] + 1 : 0;
        Console.WriteLine(result.Max());
    }
}

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

int main(){
  int a, b, c, d, e;
  cin >> a >> b;
  c = a % 500;
  d = b % 500;
  if(c <= b)
    cout << "Yes" << endl;
  if(c > b)
    cout << "No" << endl;
}

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

int main() {
  string s;
  cin >> s;
  string ans = "";
  rep(i,s.size()){
    if(s[i] == '0') ans += "0";
    else if(s[i] == '1')ans += "1";
    else {
      if(ans.size() == 0) continue;
      ans.erase(ans.size() - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
    S = input()
    counter = defaultdict(int)

    for ch in S:
        counter[ch] += 1
    
    vals = sorted([counter["a"],counter["b"],counter["c"]])

    if vals[1] - vals[0] <= 1 and vals[2] - vals[0] <= 1:
        print('YES')
    else:
        print('NO')
        
if __name__ == '__main__':
    solve()


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

int main() {
  string n="";

  for (int i=0; i<4; i++) {
    string t;
    cin >> t;

    n+=t;
  }

  sort(n.begin(), n.end());

  cout << (n=="1479" ? "YES": "NO") << endl;
}

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

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

    if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {cout << "Yes" << endl;}
    else {cout << "No" << endl;} 
}


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

int main() {
  int32_t x, a, b;
  (void)scanf("%d%d%d", &x, &a, &b);
  if ((x - a) * (x - a) < (x - b) * (x - b))
    puts("A");
  else
    puts("B");
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int& i : a) cin >> i;
	if (all_of(a.begin(), a.end(), [](int& a) { return a % 2 == 0; })) cout << "second";
	else cout << "first";
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

int main()
{
  int a,b,c,d;
  std::string result;
  
  std::cin>>a>>b>>c>>d;
  
  for(;;)
  {
    c-=b;
    if(c<=0)
    {
      result="Yes";
      break;
    }
    
    a-=d;
    if(a<=0)
    {
      result="No";
      break;
    }
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto N(cin2var<size_t>());
    const auto K(cin2var<int64_t>());
    const auto Ns(cin2vec<int64_t>(N));
    int64_t ans = 0;
    for (const auto& n : Ns) {
        if (n >= K) ++ans;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

typedef long long ll;
const int MAXN = 1e5+10;
const double inf = 1e18+10;

using  namespace std;

double dis[1010][1010];

double x[MAXN],y[MAXN],r[MAXN];
int vis[1100];
double dds[MAXN];
double dist(double x,double y)
{
    return sqrt(x*x+y*y);
}
int main()
{
    int n;
    double sx,sy,px,py;
    cin>>sx>>sy>>px>>py;
    cin>>n;
    for(int i = 1;i<=n;i++)
    {
        cin>>x[i]>>y[i]>>r[i];
    }
    int st = n+1;
    int ed = n+2;
    dis[st][ed] = dist(sx-px,sy-py);
    for(int i = 1;i<=n;i++)
    {
        dis[i][st] = dis[st][i] = max(0.0, dist(x[i]-sx,y[i]-sy)-r[i]);
        dis[i][ed] = dis[ed][i] = max(0.0, dist(x[i]-px,y[i]-py)-r[i]);
        for(int j = 1;j<=n;j++)
        {
            dis[i][j]  = max(0.0, dist( (x[i]-x[j]),(y[i]-y[j]) )-r[i]-r[j]);
        }
    }
    memset(vis,0,sizeof(vis));
    for(int i = 1; i<= n+2;i++)
    {
        dds[i] = inf;
    }
    dds[st] = 0;
    int u = -1;

	for (int i = 1; i <= n+2; i++)
    {
        u = -1;
		for(int j = 1; j <= n+2; j++)
        {
			if (!vis[j] && ( u == -1 || dds[u] > dds[j]))
                u = j;
		}
		vis[u] = 1;
		for (int j = 1; j <= n+2; j++)
        {
            dds[j] = min(dds[j], dds[u] + dis[u][j]);
        }

	}
    printf("%.10f\n",dds[ed]);
    return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include<string>
using namespace std;
int main(void){

    int A,B,N;

    
    cin>>N>>A>>B;
    
    if(A*N >B)
    {
        cout<<B<<endl;
    }
    else cout<<A*N<<endl;
    
   
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
// #include <cmath>
// #include <string>
// #include <map>
// #include <set>

// #define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
// typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

vector<vector<ull>> calc_comb(int n, int r) {
    vector<vector<ull>> ret(n+1, vector<ull>(n+1, 0));
    for (int i = 0; i <= n; ++i) {
        ret[i][0] = 1;
        ret[i][i] = 1;
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 1; j < i; ++j) {
            ret[i][j] = ret[i-1][j] + ret[i-1][j-1];
        }
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int N, A, B;
    cin >> N >> A >> B;
    vector<ull> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ull>());
    // cout << v << endl;

    ull sum = 0;
    for (int i = 0; i < A; ++i) {
        sum += v[i];
    }
    cout << fixed << setprecision(10) << (double)sum / A << endl;

    int start = 0;
    for (int i = A-1; i > 0; --i) {
        if (v[i] < v[i-1]) {
            start = i;
            break;
        }
    }
    int end = N-1;
    for (int i = A-1; i < N-1; ++i) {
        if (v[i] > v[i+1]) {
            end = i;
            break;
        }
    }

    int n = end - start + 1;
    // p("start", start, " end", end);
    int r_min, r_max;
    r_min = A - start;
    if (start == 0) {
        r_max = min(n, B - start);
    } else {
        r_max = r_min;
    }
    // p("n", n, " r_min", r_min, " r_max", r_max);
    auto comb = calc_comb(n, r_max);
    ull count = 0;
    for (int r = r_min; r <= r_max; ++r) {
        count += comb[n][r];
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
def b_rgb_boxes(R, G, B, N):
    """Rr+Gg+Bb=N となる非負整数(r, g, b)の組はいくつか。"""
    # dp[i]: Rr+Gg+Bb=i となる非負整数(r, g, b)の組はいくつか
    dp = [0] * (N + 1)
    dp[0] = 1
    for c in (R, G, B):
        for i in range(N + 1):
            if i + c <= N:
                # Rr+Gg+Bb=i を達成する組のそれぞれに対して、
                # R,G,Bのどれかを足すと Rr+Gg+Bb=i+c を達成できる
                dp[i + c] += dp[i]
    return dp[N]

R, G, B, N = [int(i) for i in input().split()]
print(b_rgb_boxes(R, G, B, N))

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL A[2];
VL sum1, sum2;

int main() {
    cin >> N;
    REP(i, N) A[0].emplace_back(IN());
    REP(i, N) A[1].emplace_back(IN());
    sum1.resize(N + 2);
    sum2.resize(N + 2);
    REP(i, N) {
        sum1[i + 1] = sum1[i] + A[0][i];
        sum2[N - i] = sum2[N - i + 1] + A[1][N - i - 1];
    }
    ll ans = 0;
    FOR(i, 1, N + 1) { ans = max(ans, sum1[i] + sum2[i]); }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
const double PI = acos(-1);

int N;
double X[111], Y[111];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	int x, y;
	scanf("%d%d", &x, &y);
	X[i] = x;
	Y[i] = y;
    }

    REP (i, N) {
	double ret = 0;
	double mi = 0, ma = PI;
	REP (j, N) if (i != j) {
	    if (X[i] == X[j] && Y[i] < Y[j]) {
		mi = PI;
		ma = 0;
		break;
	    }
	    double a = atan2(Y[j] - Y[i], X[j] - X[i]) + PI/2;
	    if (a > PI) a -= 2*PI;
	    if (0 <= a) amax(mi, a);
	    if (a <= 0) amin(ma, PI + a);
	}
	if (mi < ma) ret += ma - mi;
//	eprintf("%f %f %f\n", mi, ma, (ma-mi)/(2*PI));


	mi = -PI; ma = 0;
	REP (j, N) if (i != j) {
	    if (X[i] == X[j] && Y[i] > Y[j]) {
		mi = 0;
		ma = -PI;
		break;
	    }
	    double a = atan2(Y[j] - Y[i], X[j] - X[i]) - PI/2;
	    if (a < -PI) a += 2*PI;
	    if (0 <= a) amax(mi, -PI + a);
	    if (a <= 0) amin(ma, a);
	}
	if (mi < ma) ret += ma - mi;
//	eprintf("%f %f %f\n", mi, ma, (ma-mi)/(2*PI));

	printf("%.20f\n", ret / (2*PI));
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
#include <functional>
#include <map>
#include <cstdio>
#include <stack>
using namespace std;
typedef long long ll;

#define reps(i, s, n) for (int(i) = (s); (i) < (n); (i)++)
#define rep(i, n) reps(i, 0, n)

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b == 15){
        cout << "*" << endl;
    }else if(a+b == 15){
        cout << "+" << endl;
    }else{
        cout << "x" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100006
using namespace std;
char s[MAXN];
int n,ans,sum;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='g')
		{
			if(i/2>sum)
			{
				ans++;
				sum++;
			}
		}
		else
		{
			if(i/2>sum) sum++;
			else ans--;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

void solve(){
	ll a,b,c,d ;
	cin >> a >> b >> c >> d ;
	if(d<b||a<b){
		yorn(0) ;
		return  ;
	}
	if(c>=b-1){
		yorn(1) ;
		return  ;
	}
	if(d%b==0){
		a %= b ;
		yorn(a<=c) ;
		return  ;
	}
	ll g = gcd(b,d) ;
	if(b-1-c>=g){
		yorn(0) ;
		return ;
	}
	g = d%b ;
	ll s = a%b ;
	ll t = (b-1)%g ;
	ll u = (c+1)%g ;
	if(t>=u) yorn(!(u<=s&&s<=t)) ;
	else yorn(t<s&&s<u) ;
}

int main(){
	ll t ; cin >> t ;
	while(t--){
		solve() ;
	}
}


Measured memory_bytes: 3560
import sys
readline = sys.stdin.readline
 
import heapq
T = int(readline())
from collections import deque
for t in range(T):
  N,A,B,C,D = map(int,readline().split())
  q = [(0, N)]
  heapq.heapify(q)
  seen = set()
  while q:
    cost,n = heapq.heappop(q)
    if n in seen:
      continue
    seen.add(n)
    if n == 0:
      print(cost)
      break
      
    heapq.heappush(q, (cost + n * D, 0))
    if n % 2 == 0:
      heapq.heappush(q, (cost + A, n // 2))
    else:
      heapq.heappush(q, (cost + D + A, (n + 1) // 2))
      heapq.heappush(q, (cost + D + A, (n - 1) // 2))
      
    if n % 3 == 0:
      heapq.heappush(q, (cost + B, n // 3))
    else:
      rest = n % 3
      heapq.heappush(q, (cost + rest * D + B, (n - rest) // 3))
      heapq.heappush(q, (cost + (3 - rest) * D + B, (n - rest + 3) // 3))
      
    if n % 5 == 0:
      heapq.heappush(q, (cost + C, n // 5))
    else:
      rest = n % 5
      heapq.heappush(q, (cost + rest * D + C, (n - rest) // 5))
      heapq.heappush(q, (cost + (5 - rest) * D + C, (n - rest + 5) // 5))

Measured memory_bytes: 12860
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

bool check(string s){
    int l = s.length();
    for(int i = 0; i < l; i++){
        if(s[i] != s[l-i-1])
            return 0;
    }
    return 1;
}
 
signed main() {
    IOS;
    string s;
    cin >> s;
    int n = s.length();
    bool f = (check(s) & check(s.substr(0, (n-1)/2)) & check(s.substr((n+3)/2 - 1, n - (n+3)/2 + 1)));
    if(f)   cout << "Yes";
    else    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,d;
    long long count=0;
    cin>>m>>d;
    int o=d/10;
    int s=d%10;
    for(int i=1;i<=m;i++)
    {
        for(int j=2;j<=o;j++)
        {
            if(i%j==0 && i/j<10 && i/j>=2)
             {
                 count++;
                 if(j==o && i/j>s)
                    count--;
                //cout<<i<<' '<<j<<' '<< count<<endl;
             }
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int N;
  scanf("%d",&N);
  int i;
  int x[1001],y[1001];
  for(i=1;i<=N;i++){
    scanf("%d %d",&x[i],&y[i]);
  }
  int a,b,j;
  double c,d;
  d=0.0;
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      a=x[j]-x[i];
      b=y[i]-y[j];
      c=sqrt(a*a+b*b);
      d=d+c;
    }
  }
  double m;
  m=d/N;
  printf("%lf",m);
  return 0;
}



Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i=1; i<=N; i++)
			if(String.valueOf(i).length()%2!=0)
				ans++;
		
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 28628
#include <algorithm>
#include <iostream>

using namespace std;

int board[4][102] = {{0}};
int dp[4][102] = {{0}};

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

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

  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= N; ++j) {
      dp[i][j] = board[i][j] + max(dp[i-1][j], dp[i][j-1]);
    }
  }

  cout << dp[2][N] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b,c,d;std::cin>>a>>b>>c>>d;
    std::cout<<(std::abs(a-c)<=d||std::abs(a-b)<=d&&std::abs(b-c)<=d?"Yes":"No")<<std::endl;
}

Measured memory_bytes: 256