akhauriyash/Code-Regression huggingface dataset:
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a, b, n, m, k;

int get(int x)
{
     int ans = (a * x) / b, sub = x / b;
     ans -= a * sub;
     return ans;
}

void solve()
{
     cin >> a >> b >> n;
     cout << get(min(b - 1, n));

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int ret = 0;
  for(int i=a; i<=b; i++){
    if((c % i) == 0) ret++;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using modint = ModInt<mod>;

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

    int n, k;
    cin >> n >> k;

    vector<int> v;
    for(int i = 1; i * i <= n; i++) {
        v.push_back(i);
        if(n / i > i) v.push_back(n / i);
    }

    sort(ALL(v));

    for(int i = v.size() - 1; i; i--)
        v[i] -= v[i - 1];

    modint dp[70000];

    rep(i, v.size()) dp[i] = v[i];

    rep(i, k - 1) {
        modint sum[70000];
        rep(j, v.size()) sum[j + 1] = dp[j] + sum[j];
        rep(j, v.size()) dp[j] = sum[v.size() - j] * v[j];
    }

    modint ans(0);
    rep(i, v.size() + 1) ans += dp[i];

    cout << ans << endl;

    return 0;
}

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

const int N = 5005;
const int M = 205;

int n, m, lg[N];
long long a[N];
int b[N][M];
pair<int, int> rmq[N][14];
long long ans;
long long f[N][N];

pair<int, int> get(int l, int r) {
	int k = lg[r - l + 1];
	return max(rmq[l][k], rmq[r - (1 << k) + 1][k]);
}

void upd(int x, int y, int u, int v, int val) {
	++u; ++v;
	f[x][y] += val; f[x][v] -= val;
	f[u][y] -= val; f[u][v] += val;
}

void solve(int l, int r) {
	if (l > r) return;
	pair<int, int> g = get(l, r);
	int opt = g.second, val = g.first;
	upd(l, opt, opt, r, val);
	solve(l, opt - 1); solve(opt + 1, r);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	// prepare
	for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;

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

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) cin >> b[i][j];
	}
	
	for (int j = 1; j <= m; ++j) {
		for (int i = 1; i <= n; ++i) rmq[i][0] = make_pair(b[i][j], i);
		for (int k = 1; k < 14; ++k) {
			for (int i = 1; i <= n - (1 << k) + 1; ++i) {
				rmq[i][k] = max(rmq[i][k-1], rmq[i + (1 << k-1)][k-1]);
			}
		}
		solve(1, n);
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			f[i][j] = f[i-1][j] + f[i][j-1] - f[i-1][j-1] + f[i][j];
			if(j >= i) ans = max(ans, f[i][j] - a[j - 1] + a[i - 1]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 200576
unittest
{
	assert( [ "2 3 2", "..#", "###" ].solve == 5 );
	assert( [ "2 3 4", "..#", "###" ].solve == 1 );
	assert( [ "2 2 3", "##", "##" ].solve == 0 );
	assert( [ "6 6 8", "..##..", ".#..#.", "#....#", "######", "#....#", "#....#" ].solve == 208 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = 0L;
	auto w = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s"( h, w, k );
	auto css = new dchar[][]( h, w );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front.to!( dchar[] );
	}
	
	auto ans = 0L;
	foreach( hb; 0L .. 1L << h )
	{
		foreach( wb; 0L .. 1L << w )
		{
			auto t = 0L;
			foreach( y; 0L .. h )
			{
				foreach( x; 0L .. w )
				{
					t += ( ( hb & ( 1L << y ) ) != 0 && ( wb & ( 1L << x ) ) != 0 && css[ y ][ x ] == '#' );
				}
			}
			ans += ( t == k );
		}
	}
	return ans;
}


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

typedef struct{
	int jun;
	string tango;
	vector<int> page;
}sakuin;

int main(){
	vector<string> words;
	sakuin pages[100];
	string word;
	int num;
	int all;
	bool flag;

	cin >> word >> num;
	words.push_back(word);
	pages[0].jun = 0;
	pages[0].tango = word;
	pages[0].page.push_back(num);
	all = 1;

	while(cin >> word >> num){
		flag = true;
		for(int j=0;j<all;j++){
			if(pages[j].tango == word){
				pages[j].page.push_back(num);
				sort(pages[j].page.begin(),pages[j].page.end());
				flag = false;
				break;
			}
		}
		if(flag){
			words.push_back(word);
			sort(words.begin(),words.end());
			all++;
			for(int i=0;i<all;i++){
				if(words[i] == word){
					pages[all-1].jun = i;
					pages[all-1].tango = word;
					pages[all-1].page.push_back(num);

					for(int j=i+1;j<all;j++){
						for(int k=0;k<all;k++){
							if(words[j] == pages[k].tango)
								pages[k].jun += 1;
						}
					}
					break;
				}
			}
		}
	}

	for(int i=0;i<all;i++){
		for(int j=0;j<all;j++){
			if(pages[j].jun == i){
				cout << pages[j].tango << endl;
				for(unsigned int k=0;k<pages[j].page.size();k++){
					cout << pages[j].page[k];
					if(k+1<pages[j].page.size()) cout << ' ';
				}
				cout << endl;
				break;
			}
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define all(x) x.begin(), x.end()
#define NDEBUG
//#define assert(ignore) ((void)0)
#define reg(i,x) for(ll i=0;i<x;i++)
#define regi(i,a,x) for(ll i=a;i<x;i++)
#define rev(i,n) for(ll i=n-1;i>0;i--)
#define MP make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
 ll INF=1e9;
//bool sortbysec(const std::pair<int,int> &a, const std::pair<int,int> &b) return (a.second < b.second);
// sort(v.begin(),v.end(),sortbysec);
//vector<vector<char>>v(n,vector<char>(m));
/*vi adj[1000];
bool vis[1000];
void initialise()
{
    reg(i,10) vis[i]=false;
}*/
/*void dfs(int s)
{
    vis[s]=true;
    reg(i,adj[i].size())
    {
        if(!vis[adj[s][i]]) dfs(adj[s][i]);
    }
}*/

ll m=1e9+7;
vi l(1e5+1);
/*int leader(int v)
{
    if(l[v]!=v) l[v]=leader(l[v]);
    return l[v];
}
int unite(int v1,int v2)
{
    v1=leader(v1);
    v2=leader(v2);
    l[v1]=v2;
}*/
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll a1,a2,a3,a4;
    a1=a*c;
    a2=a*d;
    a3=b*c;
    a4=b*d;
    ll ans=max(max(a1,a2),max(a3,a4));
    cout<<ans;
}


Measured memory_bytes: 3720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int my_min(int a,int b)
{
	return a<b ?a:b;
}
int main()
{
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	printf("%d\n",my_min(N*A,B));
	return 0;
}

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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int sum;
    int cnt = 0;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                sum = 500 * i + 100 * j + 50 * k;
                if (sum == X) cnt += 1;
            }
            
        }
        
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <initializer_list>
#include <string>
#include <thread>
#include <unistd.h>
#include <chrono>
#include <algorithm>
#include <vector>
#include <mutex>
#include <queue>
#include <numeric>
#include <iterator>
#include <fstream>
#include <map>
using namespace std;

class Obj1 {
public:
    Obj1() {
      cout << "Obj1()" << endl;
    }
    Obj1(const Obj1&) {
      cout << "Obj1(const Obj1&)" << endl;
    }
    Obj1(Obj1&&) {
      cout << "Obj1(Obj1&&)" << endl;
    }
};


/*
template<typename Iterator,typename T>
struct accumulate_block
{
    void operator()(Iterator first,Iterator last,T& result)
    {
      result=std::accumulate(first,last,result);
    }
};

template<typename Iterator,typename T>
T parallel_accumulate(Iterator first,Iterator last,T init) {
  unsigned long const length=std::distance(first,last);
  if(!length) // 1
    return init;

  unsigned long const min_per_thread=25;
  unsigned long const max_threads=
          (length+min_per_thread-1)/min_per_thread; // 2

  unsigned long const hardware_threads=
          std::thread::hardware_concurrency();

  unsigned long const num_threads=  // 3
          std::min(hardware_threads != 0 ? hardware_threads : 2, max_threads);

  unsigned long const block_size=length/num_threads; // 4

  std::vector<T> results(num_threads);
  std::vector<std::thread> threads(num_threads-1);  // 5

  Iterator block_start=first;
  for(unsigned long i=0; i < (num_threads-1); ++i) {
    Iterator block_end=block_start;
    std::advance(block_end,block_size);  // 6
    threads[i]=std::thread(     // 7
            accumulate_block<Iterator,T>(),
            block_start,block_end,std::ref(results[i]));
    block_start=block_end;  // 8
  }
  accumulate_block<Iterator,T>()(
          block_start,last,results[num_threads-1]); // 9
  std::for_each(threads.begin(),threads.end(),
                std::mem_fn(&std::thread::join));  // 10

  return std::accumulate(results.begin(),results.end(),init); // 11
}

class Sta {
public:
      static Sta& get_instance() {
        static Sta sta;
        return sta;
      }
      Sta() {
        cout << "hello world" << endl;
      }
};

int main() {
  std::mutex()
  cout << "666" << endl;
  auto sta = Sta::get_instance();
  return 0;
}

*/

int main() {
  map<string, int> mp;
  int n, mxvote = -1;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    mp[tmp]++;
    mxvote = max(mxvote, mp[tmp]);
  }
  vector<string> ans;
  for(auto & it : mp) {
    if(it.second == mxvote) {
      ans.push_back(it.first);
    }
  }
  sort(ans.begin(), ans.end());

  for(const auto &str : ans) {
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 23660
#include<iostream>

using namespace std;

int main() {
	int N;
	int K;
	int h = 0;
	int ans = 0;

	cin >> N >> K;


	for (int i = 0; i < N; ++i) {
		cin >> h;
		if (h >= K) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    string ans;
    for(int i = 0; i < N; i++){
    ans += S[i];
    ans += T[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()


N = d_in()
a_list = ds_in()

ans = 0
for i, a in enumerate(a_list):
	if i == a_list[a-1] - 1:
		ans += 1

print(ans // 2)


Measured memory_bytes: 13876
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> mid = new ArrayList<Integer>();
		ArrayList<Integer> fin = new ArrayList<Integer>();
		ArrayList<Integer> rex = new ArrayList<Integer>();
//		int n =scan.nextInt();
//		int m =scan.nextInt();
		int m=0;
		int f=0;
		int r=0;
		int score =0;
		while(m != -1 || f!= -1 || r != -1){
			m =scan.nextInt();
			f =scan.nextInt();
			r =scan.nextInt();
			mid.add(m);
			fin.add(f);
			rex.add(r);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<mid.size()-1;i++){
			score = mid.get(i) + fin.get(i);
			if (mid.get(i) == -1 ||fin.get(i) == -1){	//??????????¨??????????????¨????????????????????¬????????????´???????????? F???
				System.out.println("F");
			}
			else if(score >= 80){	//??????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A ???
				System.out.println("A");
			}
			else if(score >= 65){	//??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B???
				System.out.println("B");
			}
			else if(score >= 50){	//??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C???
				System.out.println("C");
			}
			else if(rex.get(i) >=50){	//???????¨?????????°??? 50 ??\???????????°????????? C???
				System.out.println("C");
			}
			else if(score >= 30){	//??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D
				System.out.println("D");
			}
			else{	//??????????¨???¨??????????¨????????¨??????°??? 30 ??????????????°????????? F???
				System.out.println("F");
			}
		}
	}
}

Measured memory_bytes: 26192
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int n[100];

  for (int i = 0; i < 100; i++) {
    n[i] = 0;
  }

  for (int i = a; i < b; i++) {
    n[i]++;
  }

  for (int i = c; i < d; i++) {
    n[i]++;
  }

  int ans = 0;
  for (int i = 0; i < 100; i++) {
    if (n[i] == 2) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var k = nextInt()

        var q = ArrayDeque<Long>((1L..9L).toList())
        var cnt = 0

        while (cnt <= k){
            var cur = q.pollFirst()
//            println(cur)
            cnt++

            if (cnt == k){
                print(cur)
                break
            }

            var lastDigit = cur%10
            if(lastDigit != 0L) q.addLast(cur*10 + lastDigit - 1)
            q.addLast(cur*10 + lastDigit)
            if(lastDigit != 9L)q.addLast(cur*10 + lastDigit + 1)

        }


    }

    writer.solve()
    writer.flush()


}




Measured memory_bytes: 45744
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cout<<fixed<<setprecision(30);
    ll n; cin>>n;
    ll c_xl=INF,c_xr=-INF,c_yl=INF,c_yr=-INF;
    vector<pair<ll,ll>> U,D,L,R;
    rep(i,n){
        ll x,y; cin>>x>>y;
        string d; cin>>d;
        if(d=="U"){
            U.push_back(mk(y,x));
            c_xl=min(c_xl,x);
            c_xr=max(c_xr,x);
        }
        if(d=="D"){
            D.push_back(mk(y,x));
            c_xl=min(c_xl,x);
            c_xr=max(c_xr,x);
        }
        if(d=="L"){
            L.push_back(mk(x,y));
            c_yl=min(c_yl,y);
            c_yr=max(c_yr,y);
        }
        if(d=="R"){
            R.push_back(mk(x,y));
            c_yl=min(c_yl,y);
            c_yr=max(c_yr,y);
        }
    }
    ll un,dn,ln,rn;
    un=U.size(); dn=D.size();
    ln=L.size(); rn=R.size();
    ll u_yl,u_yr,d_yl,d_yr,l_xl,l_xr,r_xl,r_xr;
    if(un>0){
        sort(al(U));
        u_yl=U[0].first;
        u_yr=U.back().first;
    }
    if(dn>0){
        sort(al(D));
        d_yl=D[0].first;
        d_yr=D.back().first;
    }
    if(ln>0){
        sort(al(L));
        l_xl=L[0].first;
        l_xr=L.back().first;
    }
    if(rn>0){
        sort(al(R));
        r_xl=R[0].first;
        r_xr=R.back().first;
    }
    ld l=0.0,r=(ld)1e9;
    rep(i,200){
        ld pl=(2*l+r)/3,pr=(l+2*r)/3;
        //cout<<pl<<" "<<pr<<endl;
        ld f_pl,f_pr;
        ld xl=c_xl,xr=c_xr,yl=c_yl,yr=c_yr;
        //cout<<xl<<" "<<xr<<endl;
        if(un>0){
            yl=min(yl,(ld)u_yl+pl);
            yr=max(yr,(ld)u_yr+pl);
        }
        if(dn>0){
            yl=min(yl,(ld)d_yl-pl);
            yr=max(yr,(ld)d_yr-pl);
        }
        if(ln>0){
            xl=min(xl,(ld)l_xl-pl);
            xr=max(xr,(ld)l_xr-pl);
        }
        if(rn>0){
            xl=min(xl,(ld)r_xl+pl);
            xr=max(xr,(ld)r_xr+pl);
        }
        f_pl=(xr-xl)*(yr-yl);
        //cout<<xl<<" "<<xr<<endl;

        xl=c_xl,xr=c_xr,yl=c_yl,yr=c_yr;
        if(un>0){
            yl=min(yl,(ld)u_yl+pr);
            yr=max(yr,(ld)u_yr+pr);
        }
        if(dn>0){
            yl=min(yl,(ld)d_yl-pr);
            yr=max(yr,(ld)d_yr-pr);
        }
        if(ln>0){
            xl=min(xl,(ld)l_xl-pr);
            xr=max(xr,(ld)l_xr-pr);
        }
        if(rn>0){
            xl=min(xl,(ld)r_xl+pr);
            xr=max(xr,(ld)r_xr+pr);
        }
        f_pr=(xr-xl)*(yr-yl);

        if(f_pl>f_pr) l=pl;
        else r=pr;
        //cout<<pl<<" "<<pr<<endl;
        if(i==199) cout<<f_pr<<endl;
    }
}

Measured memory_bytes: 5104
#include <iostream>
using namespace std;
int n,a,b;
int f(int x,int y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    return f(y,x%y);
}
int main(void){
    cin>>n>>a;
    for(int i=1;i<n;i++){
        cin>>b;
        a=f(a,b);
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll pow_mod(ll n,ll p,ll m){
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

ll inv_mod(ll n,ll mod){
    return pow_mod(n,mod-2,mod);
}

ll factrial_mod(ll n,ll k,ll mod){
    ll x=1,y=1;
    rep(i,k){
        x = (x*(n-i)) % mod;
        y = (y*(i+1)) % mod;
    }
    return x*inv_mod(y,mod)%mod;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll ans = (pow_mod(2,n,MOD) - factrial_mod(n,a,MOD) - factrial_mod(n,b,MOD) - 1 + 2*MOD)%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.util.function.*;
import java.util.stream.Collectors.*;
public class Main {
    public static void main(String[] args) {
        new Main().solve();
    }
    IO io = new IO();

    /// ********** 本体 ********** ///

    void solve() {
        long X = io.Long();
        long Y = io.Long();
        String ans = "";
        if(X+Y<=1){
            ans="Brown";
        }else if(Math.abs(X-Y)<=1){
            ans="Brown";
        }else{
            ans="Alice";
        }
        System.out.println(ans);
    }

    /// ********** 本体 ********** ///

    void FOR(int a, int b, Consumer<Integer>act) { for(int i = a; i < b; ++i) act.accept(i); }
    void REP(int a, Consumer<Integer>act) { FOR(0, a, act); }
}
class IO{
    String[] nextBuff;
    int      buffCnt;
    Scanner  sc = new Scanner(System.in);
    public IO(){
        nextBuff = new String[0];
        buffCnt = 0;
    }
    String next() {
        if (buffCnt < nextBuff.length) return nextBuff[buffCnt++];
        String line = sc.nextLine();
        while (line == "") line = sc.nextLine();
        nextBuff = line.split(" ");
        buffCnt = 0;
        return nextBuff[buffCnt++];
    }
    public String String() { return next(); }
    public char   Char()   { return next().charAt(0);}
    public int    Int()    { return Integer.parseInt(next());}
    public long   Long()   { return Long.parseLong(next());}
    public double Double() { return Double.parseDouble(next());}
}

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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 ///   freopen("testcase.txt","r",stdin);

 string s;
 cin>>s;

 if(s=="Sunny")
 {
     cout<<"Cloudy"<<endl;
 }
 else if (s=="Cloudy")
 {
     cout<<"Rainy"<<endl;
 }
 else if(s=="Rainy")
 {
     cout<<"Sunny"<<endl;
 }

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void roll(vector<int> &saikoro,char houkou){
    //配列番号は固定：上が１、下が６、手前が２、奥が５、右が３、左が４
    int x,y;
    x = saikoro.at(6);
    y = saikoro.at(1);
    if(houkou == 'N') {//北に転がす
        saikoro.at(6) = saikoro.at(5);
        saikoro.at(1) = saikoro.at(2);
        saikoro.at(2) = x;
        saikoro.at(5) = y;
    }
    else if(houkou == 'S') {//南に転がす
        saikoro.at(6) = saikoro.at(2);
        saikoro.at(1) = saikoro.at(5);
        saikoro.at(5) = x;
        saikoro.at(2) = y;
    }
    else if(houkou == 'E') {//東に転がす
        saikoro.at(6) = saikoro.at(3);
        saikoro.at(1) = saikoro.at(4);
        saikoro.at(4) = x;
        saikoro.at(3) = y;
    }
    else if(houkou == 'W') {//西に転がす
        saikoro.at(6) = saikoro.at(4);
        saikoro.at(1) = saikoro.at(3);
        saikoro.at(3) = x;
        saikoro.at(4) = y;
    }
    else if(houkou == 'T') {//上下を保ったまま上から見て時計回りに回転
        int u,v;
        u = saikoro.at(2);
        v = saikoro.at(5);
        saikoro.at(2) = saikoro.at(3);
        saikoro.at(5) = saikoro.at(4);
        saikoro.at(3) = v;
        saikoro.at(4) = u;
    }
}

int main() {
    vector<int> sai(7);
    for(int i = 1; i <= 6; i++) {
        cin >> sai.at(i);
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        //上の面にaがくるように回転
        if(a == sai.at(2)) roll(sai,'N');
        else if(a == sai.at(3)) roll(sai,'W');
        else if(a == sai.at(4)) roll(sai,'E');
        else if(a == sai.at(5)) roll(sai,'S');
        else if(a == sai.at(6)) {
            roll(sai,'N');
            roll(sai,'N');
        }
        //手前の面にbがくるように回転
        while(b != sai.at(2)) {
            roll(sai,'T');
        }
        
        //右側の数字を出力
        cout << sai.at(3) << endl;
    }
}


Measured memory_bytes: 3052
# https://atcoder.jp/contests/abc152/submissions/9600286
N = int(input())
P = list(map(int, input().split()))
c = 10**9
count = 0
for i in P:
    #リストの始めから探索
    #minを保持していく
    if i < c:
        c=i
        count+=1
print(count)

Measured memory_bytes: 24744
while
x = gets()
x = x.split
    if x[1] == "?";break
end
    a = x[0].to_i
    b = x[2].to_i
    op = x[1]
    if op == "+"
        puts a + b
    elsif op == "-"
    puts a - b
    elsif op == "*"
    puts a * b
    elsif op == "/"
    puts  a / b
    end
end



Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 1001001001;
  rep(i, s.size()-t.size()+1){
    int add = 0;
    rep(j, t.size()){
      if(t.at(j) != s.at(j+i)) add++;
    }
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long 

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;

const int  M    =  998244353;
const int  maxn =  100001   ;
const int  inf  =  1e16     ;

int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      int n ; 
      cin >> n ;
      cout << a[n-1];

   
return 0;
}  


Measured memory_bytes: 256
let is_palindrome lst = lst = List.rev lst
  
let rec loop cnt =
  try
    let sl = Str.split (Str.regexp "") (read_line ()) in
    if is_palindrome sl then loop (cnt + 1) else loop cnt
  with
    End_of_file -> Printf.printf "%d\n" cnt

let _ = loop 0

Measured memory_bytes: 2332
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int A,P;
    cin >> A >> P;
    A*=3;
    A+=P;
    cout << A/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      data;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    data.push(make_pair(x - y, x + y));
  }
  int ans = 0;

  while (data.size() > 1) {
    pair<int, int> p1 = data.top();
    data.pop();
    pair<int, int> p2 = data.top();
    data.pop();
    if (p2.first < p1.second) {
      if (p2.second <= p1.second) {
        data.push(p2);
        ans++;
      } else {
        data.push(p1);
        ans++;
      }
    } else {
      data.push(p2);
      continue;
    }
  }
  cout << n - ans << endl;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[] as = new long[N + 1];
			long sum = 0;
			for(int i = 0; i <= N; i++) {
				as[i] = sc.nextLong();
				sum += as[i];
			}
			
			long current_nodes = 1;
			long answer = 1;
			for(int i = 0; i <= N; i++) {
				//System.out.println(free + " " + as[i]);

				current_nodes -= as[i];
				sum -= as[i];
				if(current_nodes < 0) {
					System.out.println(-1);
					return;
				}
				
				final long next_nodes = Math.min(current_nodes * 2, sum);
				//System.out.println(free + "- next -> " + next_free);
				current_nodes = next_nodes;
				answer += current_nodes;
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 44600
//2020-05-16 04:22:54
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;
using ll = long long;
const int SIZE = 100000;
const int white = 0, gray = 1, black = 2;
vector<int> G[SIZE];
int out[SIZE], color[SIZE];
vector<pair<int, int>> ans;
int n, m; 
void dfs(int x = 0, int p = -1){
    if (color[x] == gray || color[x] == black)return;
    color[x] = gray;
    for (auto &&i : G[x]){
        if (i == p)continue;
        dfs(i, x);
        if (color[i] == gray){
            ans.push_back(make_pair(x, i));
            out[x]++;
            continue;
        }
    }
    color[x] = black;
    if (p == -1)return;
    if (out[x] % 2){
        out[x]++;
        ans.push_back(make_pair(x, p));
        return;
    }
    else{
        out[p]++;
        ans.push_back(make_pair(p, x));
        return;
    }
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m){
        int a, b; cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (m % 2){
        cout << -1 << endl;
        return 0;
    }
    dfs();
    // rep(i, n) cout << out[i] << " ";
    rep(i, m){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
}

Measured memory_bytes: 14836
#include <iostream>
#include <cmath>
#include <iomanip>

double distanceBetweenPoints(double x1, double y1, double x2, double y2) {
  return std::sqrt(std::pow((x2 - x1), 2) + std::pow((y2 - y1), 2));
}

int main() {

  double x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  std::cout << std::setprecision(12) << std::fixed << distanceBetweenPoints(x1, y1, x2, y2) << std::endl;

}


Measured memory_bytes: 3276
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

string p;
//a0, b1, w2, x3, y4, z5
int amat[6][2] = {	{3, 4},
					{4, 3},
					{1, 4},
					{-1, 5},
					{3, -1},
					{2, 1}};

int main(){
	
	while(cin >> p, p[0] != '#'){
		
		int now = 0;
		
		for(int i=0; i<p.size(); ++i){
			
			int d = amat[now][p[i] - '0'];
			
			if(d < 0){
				cout << "No" << endl;
				break;
			}
			
			if( i==p.size()-1){
				cout << ( d == 1 ? "Yes" : "No" ) << endl;
				break;
			}
			
			now = d;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1180
import itertools
import math

N = int(input())
x = [list(map(int,input().split())) for _ in range(N)]

d = 0
for root in itertools.permutations(range(N)):
  for i in range(N-1):
    d_x = x[root[i+1]][0] - x[root[i]][0]
    d_y = x[root[i+1]][1] - x[root[i]][1]
    d   += math.sqrt(d_x**2 + d_y**2)

print(d / math.factorial(N))

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{
    public static final long MOD = 1_000_000_007;
    public static void main(String[] args) throws IOException {
//        BufferedReader in = new BufferedReader(new FileReader("pathsonagrid.txt"));
        Scanner in = new Scanner(System.in);

//        StringTokenizer line = new StringTokenizer(in.readLine());
        StringTokenizer line = new StringTokenizer(in.nextLine());

        int n = Integer.parseInt(line.nextToken());
        int m = Integer.parseInt(line.nextToken());
        
        char[][] grid = new char[n][m];
        for (int i = 0; i < n; i++)
//            grid[i] = in.readLine().trim().toCharArray();
            grid[i] = in.nextLine().trim().toCharArray();
        
        long[][] paths = new long[n][m];
        paths[0][0] = 1;
        for (int r = 0; r < n; r++) {
            for (int c = 0; c < m; c++) {
                if (grid[r][c] == '#')
                    continue;
                try { //look above
                    paths[r][c] += paths[r-1][c] % MOD;
                } catch (Exception e) {}
                try { //look left
                    paths[r][c] += paths[r][c-1] % MOD;
                } catch (Exception e) {}
            }
        }
        
        System.out.println(paths[n-1][m-1] % MOD);
    }
}

Measured memory_bytes: 62604
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A[3],K;
int main(){
    rep(i,3) cin >> A[i];
    cin >> K;
    sort(A,A+3);
    rep(i,K) A[2] *= 2;
    cout << A[0]+A[1]+A[2] << '\n';
}

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

using namespace std;
using i64 = int64_t;

signed main(){
    
    vector<int> a(10);
    for(auto& c : a)
        cin >> c;
    cout << accumulate(a.begin(), a.end(), 0) << endl;
    
    
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

ll dp[N],prefix[N],a[N];
int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
		int n;
		Int(n);

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

		prefix[1]=a[1];

		for(int i=3;i<=n;i+=2){
			prefix[i]=prefix[i-2]+a[i];
		}

		dp[1]=0;
		for(int i=2;i<=n;++i){
			if(i%2==0){
				dp[i]=max(prefix[i-1],dp[i-2]+a[i]);
			}
			else{
				dp[i]=max(dp[i-1],dp[i-2]+a[i]);
			}
		}
		printf("%lld\n", dp[n]);


        //printf("Case %d: ",++te);
    }
    return 0;
}



Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <queue>

using namespace std;

#define FOR( i, k, n ) for ( int i = ( k ); i <= ( int )( n ); ++i )
#define REP( i, n ) FOR( i, 1, n )

typedef pair< string, int > P;  // 名前：時間

int main() {
	int n, q, t = 0;
	queue< P > que;
	cin >> n >> q;
	REP( i, n ) {
		string name;
		int time;
		cin >> name >> time;
		que.push( P( name, time ) );
	}
	while( !que.empty() ) {
		P p = que.front();  que.pop();
		int time = p.second;
		string name = p.first;
		if( time > q ) {
			t += q;
			time -= q;
			que.push( P( name, time ) );
		} else {
			t += time;
			cout << name << " " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4404
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    h, n = map(int, input().split())
    a = [int(ai) for ai in input().split()]
    if sum(a) >= h:
        print('Yes')
    else:
        print('No')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 60196
#include <stdio.h>

int main(){
	
	int bawah, atas, angka;
	scanf("%d %d %d", &bawah, &atas, &angka);
	int hasil =0;
		for(int j = 1; j <= atas; j++){
			if(angka * j >= bawah && angka * j <= atas){
				hasil++;
			}
		}
	printf("%d\n", hasil);
	
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> road(2*M);
  for (int i=0; i<2*M; i++){
    cin >> road[i];
  }
  int sum=0;
  for (int i=1; i<N+1; i++){
    cout << count(road.begin(),road.end(),i) <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    try:
        alist = []
        while True:
            try:
                a = int(input())
                alist.append(a)
                
            except:
                break
    
        m = min(alist)
        M = max(alist)
        
        if m<1:
            break

        clist = [0]
        saihin = [0]
        for i in range(m,M+1,1):
            c = alist.count(i)
            if c>clist[0]:
                del(clist[0])
                clist.append(c)
                del(saihin[0])
            if c==clist[0]:
                saihin.append(i)

        l = len(saihin)
        for i in range(l):
            if saihin==[]:
                break
            print(saihin[0])
            del(saihin[0])
    
    except:
        break


Measured memory_bytes: 5600