akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b,c,ans=0;
int main()
{
	cin>>n>>a>>b;
	for (int i=1;i<=n;i++)
	{
		int x=i;
		int tmp=0;
		while (x)
		{
			tmp+=x % 10;
			x/=10;
		}
		if (tmp>=a && tmp<=b) ans+=i;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>//"M_PI"→円周率(小数点以下5桁)
#include<iomanip>//fixed<<setprecision(15)<<
#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long
#define E "\n"
#define PI 3.141592653589793


int main(){
  char C;
  cin>>C;
  
  if(isupper(C))
    cout<<"A"<<E;
  else
    cout<<"a"<<E;
}

Measured memory_bytes: 3564
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n;
   
    int i;

    int max = 0;
   
      
    scanf("%lld", &n);
       

    for( i = 1 ; i * i <= n ; i = i + 1 ){

         max = i * i;

         }


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


    return 0;
                                                          
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;

    for(int i=0;i<s.size();i+=2){
        cout << s[i];
    }
    cout << endl;

}


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

ll solve() {
    ll M = 401;
    ll N, C;
    cin >> N >> C;
    vector<ll> A(N), B(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    for ( int i = 0; i < N; i++ ) cin >> B[i];
    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x * y % MOD ) % MOD; };
    auto Pow = [&](ll x, ll n) -> ll {
        ll t = x % MOD, r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) Mul(r, t);
        Mul(t, t);
        n >>= 1;
        }
        return r;
    };
    auto Inv = [&](ll a) -> ll {
        return Pow(a, MOD - 2);
    };
    
    vector<vector<ll>> ka(M, vector<ll>(M)); // ka[k][a] = k^a
    vector<vector<ll>> ska(M, vector<ll>(M)); // ska[k][a] = sum_{k} k^a
    vector<vector<ll>> sxa(N, vector<ll>(M)); // cxa[i][a] = sum_{x=A[i]}^{B[i]} x^a
    vector<vector<ll>> dp(M, vector<ll>(M)); // dp[n][c]

    ll t;
    for ( ll k = 0; k < M; k++ ) {
        t = 1;
        ka[k][0] = t;
        for ( ll a = 1; a < M; a++ ) {
            Mul(t, k);
            ka[k][a] = t;
        }
    }
    for ( ll a = 0; a < M; a++ ) {
        t = 0;
        for ( ll k = 0; k < M; k++ ) {
            Add(t, ka[k][a]);
            ska[k][a] = t;
        }
    }
    for ( int n = 0; n < N; n++ ) {
        for ( ll a = 0; a < M; a++ ) {
            t = ska[B[n]][a];
            Add(t, MOD - ska[A[n]-1][a]);
            sxa[n][a] = t;
        }
    }
    dp[0][0] = 1;
    for ( int n = 1; n <= N; n++ ) {
        for ( ll c = 0; c <= C; c++ ) {
            for ( ll a = 0; a <= c; a++ ) {
                t = dp[n-1][c-a];
                Mul(t, sxa[n-1][a]);
                Add(dp[n][c], t);
            }
        }
    }
    ll ans = dp[N][C];
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int msprime[20000],size;

bool isMSPrime(int x){
	for(int i=0;i<size && msprime[i]<=sqrt(x);i++){
		if(x % msprime[i] == 0) return false;
	}
	return true;
}

void mkMSPrime(void){
	int i,j;

	msprime[0] = 6;
	size = 1;

	for(i=8,j=0;i<=150100;j++){
		if(isMSPrime(i)) msprime[size++] = i;
		if(j%2==0) i+=5;
		else i+=2;
	}
}

int main(void){
	int i,x,count;

	mkMSPrime();

	while(cin>>x && x!=1){
		cout<<x<<":";
		for(i=count=0;msprime[i]<=x/2;i++){
			if(x % msprime[i] == 0){
				cout<<" "<<msprime[i];
				count++;
			}
		}
		if(count==0) cout<<" "<<x;
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 940
// https://atcoder.jp/contests/abc145/tasks/abc145_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n * n << endl;

    return 0;
}


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

using namespace std;

const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 256
# d
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = list(input())
point = 0
for i in range(k):
    if t[i] == 'r':
        point += p
    elif t[i] == 's':
        point += r
    else:
        point += s

for i in range(k, n):
    if t[i] != t[i-k]:
        if t[i] == 'r':
            point += p
        elif t[i] == 's':
            point += r
        else:
            point += s
    else:
        t[i] = ''

print(point)

Measured memory_bytes: 4084
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
info = []
for _ in range(m):
    b, c = map(int, input().split())
    info.append([b, c])
info.sort(key=lambda x: x[1], reverse=True)
# print(info, A)
index = 0
for i in range(m):
    if index == n:
        break
    for j in range(info[i][0]):
        if index == n:
            break
        if A[index] < info[i][1]:
            A[index] = info[i][1]
            index += 1
        else:
            break

ans = sum(A)
print(ans)

Measured memory_bytes: 25664
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int a[m];
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	int maks=0,count1=0,count2=0;
	for(int i=0;i<m;i++){
		if(a[i]<x){
			count1++;
		}
		if(a[i]>x){
			count2++;
		}
	}
	maks=min(count1,count2);
	cout<<maks;
}



Measured memory_bytes: 3568
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author bhatti
 */
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String [] arr = new String[N];
        for(int i =0 ; i < N ; ++i){
            arr[i] = sc.next();
        }
        Arrays.sort(arr);
        System.out.println(String.join("", arr));
    }
    
    
}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans =0;
    int p = 0;
    for (int i=0; i<n; i++) {
        if (s[i] == 'g') {
            if (p > 0) ans++,p--;
            else p++;
        } else {
            if (p > 0) p--;
            else ans--,p++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll t;cin >> t;while(t--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	vector <ll> h(n);
	for0(i,n){
		cin >> h[i];
	}	
	vector <ll> ans(n,0);
	ans[1] = abs(h[0]- h[1]);
	forc(i,2,n-1){
		ans[i] = min(abs(h[i]-h[i-2]) + ans[i-2],abs(h[i] -h[i-1]) + ans[i-1]);
	}
	cout << ans[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<functional>
#include<vector>

using namespace std;

int N;

int main() {
	cin >> N;
	priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > que;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		que.push(make_pair(a, i + 1));
	}
	for (int i = 0; i < N; i++) {
		int a;
		a = que.top().second; que.pop();
		cout << a << " " << flush;
	}
	cout << endl;
}

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

using namespace std;
//using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

//template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

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

void debug_out() { cerr << endl; }

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

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

#define X first
#define Y second

using ll = long long;
using ld = long double;

ll a, b, c, d;

ll __gcd(ll x, ll y) {
	if (x == 0) return y;
	return __gcd(y % x, x);
}

ll get(ll a, ll c, ll g) {
	ll p = c / g;
	ll q = c % g;
	if (q < a % g) {
		return p * g + a % g;
	} else {
		return p * g + a % g + g;
	}
}

bool solve(ll a, ll b, ll c, ll d) {
	if (b > d) return 0;
	if (a < b) return 0;
	ll g = __gcd(b, d);
	ll mn = get(a, c, g);
	return mn >= b;
}

void run() {
	int t;
	cin >> t;
	while (t--) {
		cin >> a >> b >> c >> d;
		puts(solve(a, b, c, d) ? "Yes" : "No");
	}
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000010
using namespace std;
struct data
{
	int x,w;
}a[N];
bool cmp(data a,data b)
{
	return a.x<b.x;
}
int n,l,t,sum;
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].w);
		a[i].w--;
	}
	for(int i=1;i<=n;i++)
	{
		if(!a[i].w)
		{
			a[i].x+=t;
		}else{
			a[i].x-=t;
		}
		sum+=a[i].x/l;
		if(a[i].x%l<0)
		{
			sum--;
		}
		a[i].x=(a[i].x%l+l)%l;
	}
	sort(a+1,a+n+1,cmp);
	sum=(sum%n+n)%n;
	for(int i=sum+1;i<=n;i++)
	{
		printf("%d\n",a[i].x);
	}
	for(int i=1;i<=sum;i++)
	{
		printf("%d\n",a[i].x);
	}
	return 0;
}

Measured memory_bytes: 1920
// -*- coding: utf-8 -*-
// Last-Updated : <2014/06/19 05:02:03 by samui>

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <bitset>
#include <utility> // std::pair
#define MP(a, b) std::make_pair(a, b)
#define X first
#define Y second
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define rer(i,l,n) for(int (i) = l; (i) <= (int)(n); ++(i))
#define reu(i,l,n) for(int (i) = l; (i) < (int)(n); ++(i))
template<typename T,typename U> inline void amin(T &x,U y){ if(y<x) x = y;}
template<typename T,typename U> inline void amax(T &x,U y){ if(x<y) x = y;}
template<typename TYPE,std::size_t SIZE>
std::size_t len(const TYPE (&array)[SIZE]){return SIZE;}

int main(int argc, char *argv[])
{
  int t,t0;
  int N,W;
  std::cin>>N>>W;
  std::vector<std::pair<int,int>> o(N+1);
  int mat[N+1][W+1];
  rep(i,W+1){
    rep(j,N+1){
      
      mat[j][i] = 0;
    }
  }

  int a = 0;
  rer(i,1,N){
    std::cin>>t>>t0;
    a+=t;
    o[i] = MP(t,t0);
  }
  rer(i,1,N){
    rer(j,1,W){
      if( o[i].Y <= j){
	mat[i][j] = std::max(mat[i-1][j],o[i].X+mat[i-1][j-o[i].Y]);
      }else{
	mat[i][j] = mat[i-1][j];
      }
    }
  }
  int ans = 0;
  rer(i,0,N){
    rer(j,0,W){
      amax(ans,mat[i][j]);
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int k = 0;
	rep(i, S.size()) if (S[i] == 'x') k++;

	if (k >= 8) co("NO");
	else co("YES");

	Would you please return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=''

ans+='R'*dx
ans+='U'*dy
ans+='L'*dx
ans+='D'*dy
ans+='DR'
ans+='R'*dx
ans+='U'*dy
ans+='ULUL'
ans+='L'*dx
ans+='D'*dy
ans+='DR'

print(ans)

Measured memory_bytes: 61856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,M,X; cin>>N>>M>>X;
	int C[N]; int A[N][M];
	rep(i,0,N){
		cin>>C[i];
		rep(j,0,M) cin>>A[i][j];
	}
	int ans = inf;
	rep(i,0,(1<<N)){
		int sum = 0; int res[M] = {};
		rep(j,0,N){
			if(i & (1<<j)){
				sum += C[j];
				rep(k,0,M) res[k] += A[j][k];
			}
		}
		bool flag = true;
		rep(j,0,M){
			if(res[j] < X) flag = false;
		}
		if(flag) ans = min(ans, sum);
	}
	cout<<(ans == inf ? -1 : ans)<<endl;
}

Measured memory_bytes: 3620
#include <iostream>

int main(){
  int a[32] = {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 i;
  std::cin>>i;
  std::cout<<a[--i];
}

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

int main(){
  int N; cin >> N;
  int a,b;
  int amax=0,bmax=0;
  for(int i=0; i<N; i++){
    cin >> a >> b;
    if(a>amax){
      amax=a; bmax=b;
    }
  }
  cout << amax+bmax << endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

    string s;
    cin >> s;

    int n = s.size();

    int ans = n;
    REP(i, 1, n){
        if(s[i - 1] != s[i]){
            chmin(ans, max(i, n - i));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))

Measured memory_bytes: 23244
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll INF = 1LL << 60;

void cycle(bool h, bool v, int dx, int dy){
  if(h) rep(i, dx) cout << 'R';
  else rep(i, dx) cout << 'L';
  if(v) rep(i,dy) cout << 'U';
  else rep(i, dy) cout << 'D';
}

int main(void){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  cycle(dx>0, dy>0, abs(dx), abs(dy));
  cycle(-dx>0, -dy>0, abs(dx), abs(dy));

  if(dy>0){
    if(dx>0){
      cout << 'D';
      cycle(dx>0, dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'L' << 'U';
      cycle(-dx>0, -dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'R';
    }
    else{
      cout << 'D';
      cycle(dx>0, dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'R' << 'U';
      cycle(-dx>0, -dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'L';
    }
  }
  else{
    if(dx>0){
      cout << 'U';
      cycle(dx>0, dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'L' << 'D';
      cycle(-dx>0, -dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'R';
    }
    else{
      cout << 'U';
      cycle(dx>0, dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'R' << 'D';
      cycle(-dx>0, -dy>0, abs(dx)+1, abs(dy)+1);
      cout << 'L';
    } 
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int x, a, b;

    cin >> x >> a >> b;

    int A = abs(x - a);
    int B = abs(x - b);

    if (A > B) {
        cout << "B" << endl;
    } else {
        cout << "A" << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

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

	rep(i, n - 1){
		if(a[i] == a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  rep(i, s.size()) s[i] = 'x';
  std::cout << s << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

string s;
ll n;
ll md = 1000000000+7;

vector<ll> MK_PREF(vector<ll> A) {
    vector<ll> T;
    T.pb(0);
    rep(i,0,A.size()) {
        T.pb((T.back() + A[i]) % md);
    }
    return T;
}

int main() {
    cin.sync_with_stdio(false);
    cin >> n >> s;

    vector<ll> DP(n+1,1);
    vector<ll> PREF;
    for(int i = n-2; i >= 0; i--) {
        PREF = MK_PREF(DP);
        vector<ll> NEWDP(n+1,0);
        for(int j = 1; j <= n; j++) {
            int l,r;
            if(s[i] == '>') {
                l = 1;
                r = j;
            } else {
                l = j+1;
                r = i+2;
            }
            NEWDP[j] = (PREF[r+1] - PREF[l] + md) % md;
        }
        DP = NEWDP;
    }





    cout << DP[1] << endl;
    return 0;
}


Measured memory_bytes: 384
import static java.lang.Math.*;
import static java.util.Arrays.*;
 
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
import static java.math.BigInteger.*;
 
public class Main {
	
	void solve() {
		int n = sc.nextInt();
		int[] a = sc.nextIntArray(n);
		for (int i = 0; i < n; i++) a[i]--;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (i == a[a[i]]) ans++;
		}
		out.println(ans / 2);
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }
 
	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}
 
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
 
	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}
 
	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;
 
		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 22236
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N;
    scanf("%d", &N);

    vector<int> A(N);
    vector<int> B;

    for(auto &e : A)
        scanf("%d", &e);

    auto func = [&](int a) {
        int count = 0;
        for (; a % 2 != 1; a /= 2, count++);
        B.push_back(count);
    };

    for_each(A.begin(), A.end(), func);

    cout << *min_element(B.begin(), B.end()) << endl;
}

Measured memory_bytes: 256
n,a,b=map(int, input().split())
h=[int(input()) for i in range(n)]
r,l=0,10**9
while r<l-1:
    c=(r+l+1)//2
    h2=[i-b*c for i in h if i-b*c>0]
    count=0
    for i in h2:
        count+=-(-i//(a-b))
    if count<=c:l=c
    else:r=c
print(l)

Measured memory_bytes: 15136
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,s=0,s2=0;
    cin>>a;
    if(a==5) s++;
    if(a==7) s2++;
    cin>>b;
    if(b==5) s++;
    if(b==7) s2++;
    cin>>c;
    if(c==5) s++;
    if(c==7) s2++;
    if(s==2&&s2==1)
    cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n == 3:
	print(2, 3, 25)
	exit()
if n == 4:
	print(2, 3, 4, 9)
	exit()
ans = [2, 4, 6, 3, 9]
c = 5
M = 4
while c + 1 < n and M + 6 < 30000:
	c += 2
	ans += [M + 4, M + 6]
	M += 6
c = len(ans)
M = 9
while c + 1 < n and M + 6 < 30000:
	c += 2
	ans += [M + 6, M + 12]
	M += 12
ans += [x * 6 for x in range(2, n - c + 2)]
print(*ans)

Measured memory_bytes: 4560
n = int(input())
a = list(map(int,input().split()))

nm = a[0]
nv = a[0]
for i in range(n):
    if a[i] > nv:
        nv = a[i]
        continue
    
    if a[i] < nm:
        nm = a[i]

print(nv-nm)
        

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

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
		cout << "hon";
	}
	else if(n%10==3){
		cout << "bon";
	}
	else
		cout << "pon";


	
	

	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair <int, int> pr;
priority_queue <pr> qua;
int n;
int a[3005];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++) a[i]--;
	int sum = 0;
	for(int i = 1; i <= n; i++) sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct _point {
	int v;
	int x;
}point;

int point_sort( const void * a , const void * b ) {
	point p1 = *(point*)a;
	point p2 = *(point*)b;
  
	if(p2.x == p1.x)
		return p1.v - p2.v;
	return p2.x - p1.x;
}

int main(void) {
	point A[101];
	int i, a, n;
	
	for(i=0;i<101;i++) {
		A[i].v=0;
		A[i].x=0;
	}
	
	n=0;
	while(scanf("%d\n", &a) == 1) {
		A[a].v = a;
		A[a].x++;
		n++;
	}
	
	qsort((void*)A , 101, sizeof(A[0]), point_sort);	
	
	printf("%d\n", A[0].v);
	for(i=1;i<n;i++) {
		if(A[0].x != A[i].x)
			break;
			
		printf("%d\n", A[i].v);
	}
	
	return 0;
}

Measured memory_bytes: 604
P = 123456789012419
x = 31
ix = pow(x, P-2, P)
N = int(input())
A = [ord(s)-95 for s in input()]

def chk(k):
    D = {}
    s = 0
    for i in range(k):
        s = (s * x) % P
        s += A[i]
    X = [s]
    D[s] = k-1
    for i in range(k, N):
        s = ((s - pow(x, k-1, P) * A[i-k]) * x + A[i]) % P
        X.append(s)
        if s in D:
            if i - D[s] >= k:
                return 1
        else:
            D[s] = i
    return 0

l = 0
r = N//2 + 1
while r - l > 1:
    m = (l+r) // 2
    if chk(m):
        l = m
    else:
        r = m
print(l)


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

int main() {
  int A, B; cin >> A >> B;
  if(A==1) A+=13;
  if(B==1) B+=13;

  if(A == B) {
    cout << "Draw" << endl;
  } else if( A > B ) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
t = C
ans = 0
for i in range(N):
    for j in range(M):
        t += A[i][j] * B[j]
    if t > 0:
        ans += 1
    t = C
print(ans)


Measured memory_bytes: 9152
#include <iostream>
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    long long int arr[n];
    long long int sum = 0;
    long long int m = 1000000007;
    for (long long int i = 0; i < n; i++)
    {
        cin >> arr[i];
        arr[i] = arr[i] % m;
        sum = (sum % m + arr[i]) % m;
    }
    long long int ans = 0;
    for (long long int i = 0; i < n; i++)
    {
        long long int k = (arr[i] * (sum - arr[i] + m) % m) % m;
        ans = (ans % m + k % m) % m;
        sum = (sum - arr[i] + m) % m;
    }
    cout << ans % m << endl;
}

Measured memory_bytes: 5164
#include <iostream>

using namespace std;

int main()
{
    int a,b,add,mi,mul;
    cin>>a>>b;
    add=a+b;
    mi=a-b;
    mul=a*b;
    if(add>mi)
    {
        if(add>mul)
        {
            cout<<add<<endl;
            return 0;
        }
    }
    else
    {
         if(mi>mul)
        {
            cout<<mi<<endl;
            return 0;
        }
    }
    cout<<mul<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    int ans = 0;
    if (n > 9) ans += 9;
    if (n > 999) ans += 900;
    if (n > 99999) ans += 90000;
    if (n >= 1 && n <= 9) ans += n;
    else if (n >= 100 && n <= 999) ans += n - 100 + 1;
    else if (n >= 10000 && n <= 99999) ans += n - 10000 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

ll f(ll b, ll n){
    if(n < b) return n;
    return f(b, n/b) + n % b;
}


signed main(void) {
    int i,j;
    ll n, s;
    cin >> n >> s;

    if(n < s){
        cout << -1 << endl;
        return 0;
    }

    if(s == n){
        cout << n+1 << endl;
        return 0;
    }

    loop(i, 2, sqrt(n)+1){
        if(f(i,n) == s){
            cout << i << endl;
            return 0;
        }
    }

    for(int p = sqrt(n); p > 0; p--){
        if((n-s)%p)continue;
        int b = (n-s+p)/p;
        if(f(b,n) == s){
            cout << b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
AA=[0]
for a in A[1:]:
    AA.append(AA[-1]+a)
f=1 if A[0]==0 or N==0 and A[0]==1 else 0
r=1
b=1
for i,a in enumerate(A[1:]):
    x=min(b*2,AA[-1]-AA[i])
    if i<N-1 and x>a or i==N-1 and x==a:
        b=x-a
        r+=x
    else:
        f=0
print(r if f else -1)

Measured memory_bytes: 20152
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int ans = 0;
  vector<int> vec(1100000);
  for (int i = 0; i < 2 * a; i++) cin >> vec.at(i);
  for (int i = 0; i < 2 * a; i += 2) {
    ans += (vec.at(i + 1) - vec.at(i) + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4608
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
					int i1,N0;
					string S,T;
					int* iarray0;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	~Hoge();
  private:
	
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"S,T?"<<endl;
	cin>>S>>T;
	int iwrong=0;
	int is0=S.length();
	//cout<<"is0="<<is0<<endl;
	
	for(int ic0=0;ic0<is0;ic0++){
		
		//cout<<S[ic0];
		if(S[ic0]!=T[ic0]){iwrong++;};
			
	}
	
	cout<<iwrong<<endl;
	//cout<<endl;

	
	
	
	
	
	//iarray0=new int[N0];
	//int N1=3;int N2=2;
	//int* iarray1=new int[N1];
	//int* iarray2=new int[N1];

	//inputarray(iarray0,N0);
	//printarray(iarray0,N0);
	//inputarray2(iarray1,iarray2,N1);
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}


void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::inputarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
	
	}
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
	//delete [] iarray0;
							}
int main(){
				int N=0;
				//cin>>N;
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	return 0;
	delete hoge;
}//end of main

Measured memory_bytes: 4116
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int n, m;
int msk[100002];

int dp[5002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        int masca = 0;
        for(int j = 1; j <= b; ++j)
        {
            int nr;
            cin >> nr;
            masca ^= (1<<(nr - 1));
        }
        if(msk[masca] == 0)
            msk[masca] = a;
        else
            msk[masca] = min(msk[masca], a);
    }
    for(int i = 1; i < (1<<n); ++i)
        dp[i] = (1<<30);
    for(int i = 0; i < (1<<n); ++i)
    {
        if(msk[i] == 0)
            continue;
        for(int j = 0; j < (1<<n); ++j)
        {
            if(dp[j] == (1<<30))
                continue;
            int new_poz = i | j;
            dp[new_poz] = min(dp[new_poz], dp[j] + msk[i]);
        }
    }
    if(dp[(1<<n) - 1] == (1<<30))
        cout << -1;
    else
        cout << dp[(1<<n) - 1] << '\n';
    return 0;
}


Measured memory_bytes: 256
//Tax Increase

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int A,B;cin >> A>> B;
    bool flag = true;
    rep(i,0,10001){
        if(floor(i*0.08)==A&&floor(i*0.1)==B){
            cout << i << endl;
            flag=false;
            break;
        }
    }
    if(flag)cout << "-1" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int P[100001], Y[100001];
    vector<int> list[100001];
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> Y[i];
        list[P[i]].push_back(Y[i]);
    }
    for (int i = 0; i < N; i++)
    {
        sort(list[i + 1].begin(), list[i + 1].end());
    }
    int temp;
    for (int i = 0; i < M; i++)
    {
        cout << setfill('0') << right << setw(6) << P[i];
        temp = int(lower_bound(list[P[i]].begin(), list[P[i]].end(), Y[i]) - list[P[i]].begin()) + 1;
        cout << setfill('0') << right << setw(6) << temp;
        cout << endl;
    }
    // cin >> N;
}


Measured memory_bytes: 7808
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< vector< int > > dp(N + 1, vector< int >(N + 1, 0));
	rep(d, N + 1) rep(l, N) {
		if (!d)
			break;
		int r = l + d;
		if (r > N)
			break;
		if ((N - d) & 1) {
			dp[l][r] = min(dp[l + 1][r] - A[l], dp[l][r - 1] - A[r - 1]);
		} else {
			dp[l][r] = max(dp[l + 1][r] + A[l], dp[l][r - 1] + A[r - 1]);
		}
	}
	cout << dp[0][N] << endl;
	return 0;
}

Measured memory_bytes: 70784
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

long long fac[100001], finv[100001], inv[100001];

//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;
    
    return res %= MOD;;
}

long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    long long N, A, B; cin >> N >> A >> B;
    long long all = mod_pow(2, N) - 1;
    all %= MOD;
    long long hate1 = nCr(N, A);
    long long hate2 = nCr(N, B);
    hate1 %= MOD, hate2 %= MOD;
    if ((all - hate1 - hate2) % MOD < 0) cout << (all - hate1 - hate2) % MOD + MOD << endl;
    else cout << (all - hate1 - hate2) % MOD << endl;
}


Measured memory_bytes: 5248
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();
        long a = 1;
        long b = 2;
        for (int i = 2; i <= n; i++) {
            long c = a;
            a = a + b;
            b = c;
        }
        System.out.println(a);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 24404
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
long long A[N];
long long B[N];
long long sumB=0;

rep(i,N){
cin>>A[i]>>B[i];
sumB+=B[i];
}
vector<long long>v;
rep(i,N){
    v.push_back(-(A[i]+B[i]));
}
sort(v.begin(),v.end());

long long ans=0;
rep(i,N){
    if(i%2==0){
        ans-=v[i];
    }
}

ans-=sumB;

cout<<ans<<endl;
 return 0;
}
/*
3
10 10
20 20
30 30

20


3
20 10
20 20
20 30

20

6
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

-2999999997

*/

Measured memory_bytes: 2936
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x1, x2, x3;
  ll y1, y2, y3;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> x3 >> y3;
  long double a = SQRT(POW(abs(x1 - x2), 2) + POW(abs(y1 - y2), 2));
  long double b = SQRT(POW(abs(x1 - x3), 2) + POW(abs(y1 - y3), 2));
  long double c = SQRT(POW(abs(x3 - x2), 2) + POW(abs(y3 - y2), 2));
  long double s = (a + b + c) / 2;
  long double S = SQRT(s * (s - a) * (s - b) * (s - c));
  long double r = S / s;
  long double A = max(a, max(b, c));
  cout << SP(20) << A / (2 + (A / r)) << endl;

  return 0;
}


Measured memory_bytes: 256