akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, m, q;
    cin >> n >> m >> q;

    vector<vector<ll>> p(n + 2, vector<ll>(n + 2, 0));

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

        p[l][r]++;
    }

    vector<vector<ll>> sum(n + 2, vector<ll>(n + 2, 0));

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            sum[i][j + 1] = sum[i][j] + p[i][j];
        }
    }

        cout << endl;

    // for(int i = 0; i <= n + 1; i++){
    //     for(int j = 0; j <= n + 1; j++){
    //         cout << sum[i][j];
    //     }
    //     cout << endl;
    // }


    for(int i = 0; i <= n + 1; i++){
        for(int j = 0; j <= n; j++){
            sum[j + 1][i] += sum[j][i];
        }
    }

    // cout << endl;

    // for(int i = 0; i <= n + 1; i++){
    //     for(int j = 0; j <= n + 1; j++){
    //         cout << sum[i][j];
    //     }
    //     cout << endl;
    // }

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

        // cout << sum[r + 1][r + 1] << endl;
        // cout << sum[l - 1][r + 1] << endl;
        // cout << sum[r + 1][l - 1] << endl;
        // cout << sum[l - 1][l - 1] << endl;

        cout << sum[r + 1][r + 1] - sum[l - 1][r + 1] - sum[r + 1][l - 1] + sum[l - 1][l - 1] << endl;

    }

    
}

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

int main(){

  int N;
  long long M=0,A=0,R=0,C=0,H=0,cnt=0;
  string tmp;

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(tmp[0] == 'M') M++;
    else if(tmp[0] == 'A') A++;
    else if(tmp[0] == 'R') R++;
    else if(tmp[0] == 'C') C++;
    else if(tmp[0] == 'H') H++;
  }
  cnt += M*A*R;
  cnt += M*A*C;
  cnt += M*A*H;
  cnt += M*R*C;
  cnt += M*R*H;
  cnt += M*C*H;
  cnt += A*R*C;
  cnt += A*R*H;
  cnt += A*C*H;
  cnt += R*C*H;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  int k = max(0, n * (n - 1) / 2);
  int t = max(0, m * (m - 1) / 2);

  cout << k + t << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
template<typename T, typename C>
using PQ = priority_queue<T, vector<T>, C>;
using Complex = complex<double>;


int N, A, B, C;
int l[10];


signed main(){
    cin >> N >> A >> B >> C;
    rep(i, 0, N) cin >> l[i];

    sort(RNG(l, 0, N));

    int ans = INF;
    do {
        rep(i, 0, N){
            rep(j, i+1, N){
                rep(k, j+1, N){
                    int mp = 0;
                    int a = 0, b = 0, c = 0;
                    repe(m, 0, i) a += l[m];
                    repe(m, i+1, j) b += l[m];
                    repe(m, j+1, k) c += l[m];
                    mp += (k-2)*10+abs(A-a)+abs(B-b)+abs(C-c);
                    chmin(ans, mp);
                }
            }
        }
    } while(next_permutation(RNG(l, 0, N)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
A,B=[0]*M,[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
lst=[1]*N
for i in range(M):
  if H[A[i]-1]<=H[B[i]-1]:
    lst[A[i]-1]=0
  if H[A[i]-1]>=H[B[i]-1]:
    lst[B[i]-1]=0
print(sum(lst))

Measured memory_bytes: 85032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,sum=0,x=0;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        sum=sum+x;
    }
   if(sum>n)
    cout<<"-1"<<endl;
   else
    cout<<abs(sum-n)<<endl;
}


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

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> v(h);
  for(auto &i:v)
    cin>>i;

  for(auto i:v)
    cout<<i<<"\n"<<i<<"\n";  
    
  


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int money = 100000;
    for(int i = 0; i < n; i++){
        money = money * 105 / 100;
        if(money % 1000 > 0){
            money -= money % 1000;
            money += 1000;
        }
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 1156
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k, q;
  cin >> n >> k >> q;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  vll b = a;
  sort(ALL(b));
  ll ans = b[q-1]-b[0];
  rep(i, n){
    vvll lst;
    vll tmp;
    rep(j, n){
      if(a[j] <= b[i]){
        lst.emplace_back(tmp);
        tmp.clear();
      }else{
        tmp.emplace_back(a[j]);
      }
    }
    lst.emplace_back(tmp);
    tmp.clear();
    vll c;
    for(auto&& e: lst){
      sort(ALL(e));
      rep(kk, SZ(e)-k+1){
        c.emplace_back(e[kk]);
      }
    }
    sort(ALL(c));
    
    if(q-1 < SZ(c)) chmin(ans, c[q-1]-c[0]);
  }
  print(ans);
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, M;
    cin >> N >> M;
    map<int, int> m;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        m[a]++;
        m[b]++;
    }

    for (auto&& a : m) {
        if (a.second % 2 == 1)             {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> sum(N+1);
    rep(i,N) sum[i+1] = sum[i]+A[i];
    ll ans = LINF;
    ll k = sum[N];
    rep(i,N){
        ll now = sum[i+1];
        if(2*now <= k){
            ll b = k-2*now;
            if(b >= 0 && (k+b) % 2 == 0) ans = min(ans,b);
        }
        else{
            ll b = 2*now-k;
            if(b >= 0 && (k-b) % 2 == 0) ans = min(ans,b);
        }
    }
    cout << ans << endl;
}



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

s = 0

for i in range(len(a)):
    s = s ^ a[i]

ans = ""

for i in range(len(a)):
    tmp = s ^ a[i]
    ans += str(tmp)
    if i != len(a) - 1:
        ans += " "

print(ans)

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string S; cin >> S;
    set<char> s;
    rep(i, S.size()) {
        s.insert(S[i]);
    }
    // for (auto itr = s.begin(); itr != s.end(); itr++) {
    //     cout << *itr << endl;
    // }
    bool flag = true;
    for (char i = 0x61; i <= 0x7a; i++) {
        if (s.count(i) == 0) {
            cout << i << endl;
            flag = false;
            break;
        }
    }
    if (flag)
        cout << "None" << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

#define PI (M_PI)

int main(void) {
    double a, b, c;
    double s, l, h;

    scanf("%lf %lf %lf", &a, &b, &c);
    s = a*b*sin(c*PI/180.0)/2.0;
    l = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(c*PI/180.0));
    h = s*2.0/a;
    printf("%.4f\n%.4f\n%.4f\n", s, l, h);

    return 0;
}



Measured memory_bytes: 2116
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,m;
  int i;
  int a[10000];
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    n=n-a[i];
  }
  if(n>=0)printf("%d",n);
  else printf("-1");
  return 0;
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    if (s[n - 1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int x, m;
    vector<int>check(200001,0);
    vector<long long>store(200001,0);

    cin >> n >> x >> m;
    check[x] = 1;
    store[1] = x;
    long long next = x;
    long long ans = x;
    for(long long i=2; i<=n; i++){
        next = (next * next) % m;
        if(check[next]){
            long long sum = 0;
            for(long long j=check[next]; j<i; j++){
                sum += store[j];
            }
            long long length = i - check[next];
            long long togo = n - i + 1;
            ans += (togo/length)*sum;
            for(long long j=check[next]; j<check[next]+togo%length; j++){
                ans += store[j];
            }
            break;
        }
        else{
            ans += next;
            check[next] = i;
            store[i] = next;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-9,inf=1e50;
bool eq(D a,D b){return abs(a-b)<eps;}
D dot(P x,P y){return real(conj(x)*y);}
bool iSP(L s,P p){return eq(abs(s.fs-p)+abs(p-s.sc),abs(s.fs-s.sc));}
P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
D dSP(L s,P p){
	P q=perp(s,p);
	return iSP(s,q)?abs(p-q):min(abs(p-s.fs),abs(p-s.sc));
}
D fix(D x){
	if(abs(x)<eps) return 0;
	return x;
}
int N;
P s,t;
D r[100],l[100][11];
int K[100];
Pol pol[100];
bool is[102][102];
int main(){
	cin>>N;
	{
		int x,y;
		cin>>x>>y;
		s=P(x,y);
		cin>>x>>y;
		t=P(x,y);
	}
	rep(i,N){
		cin>>r[i]>>K[i];
		rep(j,K[i]){
			int x,y;
			cin>>x>>y;
			pol[i].pb(P(x,y));
		}
		pol[i].pb(pol[i][0]);
	}
	rep(i,N){
		rep(j,K[i]) l[i][j+1]=l[i][j]+abs(pol[i][j]-pol[i][j+1]);
		D lx=l[i][K[i]];
		rep(j,K[i]+1) l[i][j]/=lx;
	}
	rep(i,N+2) is[i][i]=1;
	rep(tt,2){
		int S=N+tt;
		P p=(tt==0?s:t);
		rep(i,N){
			rep(j,K[i]){
				if(dSP(L(pol[i][j],pol[i][j+1]),p)<r[i]) is[i][S]=is[S][i]=1;
			}
		}
	}
	rep(a,N) rep(b,a){
		D mn=inf;
		rep(i,K[a]) rep(j,K[b]){
			D la=l[a][i],ra=l[a][i+1];
			D lb=l[b][j],rb=l[b][j+1];
			D le=max(la,lb),ri=min(ra,rb);
			if(le>ri) continue;
			P d=(pol[a][i]-la/(ra-la)*(pol[a][i+1]-pol[a][i]))-(pol[b][j]-lb/(rb-lb)*(pol[b][j+1]-pol[b][j]));
			P dt=(pol[a][i+1]-pol[a][i])/(ra-la)-(pol[b][j+1]-pol[b][j])/(rb-lb);
			D A=fix(norm(dt)),B=2.0*dot(d,dt),C=norm(d);
			if(A==0){
				chmin(mn,C);
				continue;
			}
			chmin(mn,A*le*le+B*le+C);
			chmin(mn,A*ri*ri+B*ri+C);
			D m=-B/2.0/A;
			if(le<m&&m<ri) chmin(mn,A*m*m+B*m+C);
		}
		if(sqrt(mn)<r[a]+r[b]) is[a][b]=is[b][a]=1;
	}
	rep(i,N+2) rep(j,N+2) rep(k,N+2) if(is[j][i]&&is[i][k]) is[j][k]=1;
	if(is[N][N+1]) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
string s,t;int k,lst,n,cilen,fis;ll ans,s1,s2,len[10005];
map<string,int> m;
int main()
{
    fastio;
    cin>>s>>k;t=s;n=s.size();
    rep(j,1,k) {
        rap(i,lst,s.size()){
            if(s[i]==s[i-1]){
                ans++;
                rep(j,0,2)
                if(j+97!=s[i-1] && ((i+1==s.size()&&s[0]!=j+97)||(i+1<s.size()&&j+97!=s[i+1]))) {s[i]=j+97;break;}
            }
        }
        lst=s.size();
        string nw=s.substr(lst-n);
        if(m[nw]!=0){
            int t=m[nw];
            fis=t;
            cilen=j-t;
            len[j]=ans;
            break;
        }
        m[nw]=j;
        s+=t;
        len[j]=ans;
    }
    if(cilen==0){cout<<len[k];return 0;}
    s=t;
    ans=0;int whole=cilen+fis;
    ans=len[fis-1];
    rep(i,1,cilen){
        ll count=(k-fis+1)/cilen;if((k-fis+1)%cilen>=i) count++;
        ans+=count*(len[i+fis-1]-len[i+fis-2]); 
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int f(int x,int y)
{
    return x<y?y-x:x-y;
}
int main()
{
    int n,a[200],sum=0,ans=1000000009;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        sum+=x;
        a[i]=sum;
    }
    for(int i=1;i<=n;i++)
        ans=min(ans,f(a[i],a[n]-a[i]));
    printf("%d",ans);
    return 0;
}


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

#define int long long

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int ans;
	cin >> ans;
	ans /= 2;
	bool f = 0, g = 0;
	for (int i = 1; i < n; i++) {
		int tmp;
		cin >> tmp;
		tmp /= 2;
		ans = ans / __gcd(ans, tmp) * tmp;
		if (ans > 2 * m) {
			cout << 0;
			return 0;
		}
		if (__builtin_ctz(tmp) % 2)
			f = 1;
		else
			g = 1;
	}
	if (f && g) {
		cout << 0;
	}
	else
		cout << (m / ans + 1) / 2;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ll long long

int main(void){
    int S;
    cin>>S;
    int a=S/100;
    int b=S%100;
    if(a==0) {
        if(1<=b && b<=12) cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
        return 0;
    }
    else if(a<=12){
        if(0<b &&b<13) cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
        return 0;
    }
    else{
        if(0<b &&b<13) cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define input1  freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); 
const ll nax =1e9+7;



void solve()
{
    char a;
   cin>>a;
   if(a<=122 && a>=97)
        cout<<"a"; 
  else
  {
      
      cout<<"A";
  }
  
    
}

int main()
{
    //input1;

    solve();
    return 0;
}

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

int main()
{
    int n, T, ans = 0, time;
    cin >> n >> T;
    vector<int> t(n);
    for(int i = 0;i < n;i++) cin >> t[i];

    if(n == 1){
        cout << T;

        return 0;
    }

    time = ans = T;
    for(int i = 1;i < n - 1;i++){
        if(t[i] >= time){
            ans += T;
        }
        else{
            ans += T - (T - (t[i] - t[i - 1]));
        }
        time = t[i] + T;
    }

    if(time > t[n - 1]){
        ans += T - (T - (t[n - 1] - t[n - 2]));
    }
    else{
        ans += T;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = input()

YesNo("7" in N)


Measured memory_bytes: 65532
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
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; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    


}


Measured memory_bytes: 256
#import math

def up(a):
    m = a//1000*1000
    if a%1000 > 0:
        return  int(m + 1000)
    else:
        return int(a)

n = int(input())
m = 100000

for i in range(n):
    m = m * 1.05
    m = up(m)

print(m)


Measured memory_bytes: 5616
#include <stdio.h>
#include <string.h>

int main(){
    char indata[1000001],load[10001];
    int i,j,in,ln,state;
    
    scanf("%s",indata);
    scanf("%s",load);
    in=strlen(indata);
    ln=strlen(load);
    
    //printf("in = %d , ln = %d\n",in,ln);
    for(i=0;i<in;i++){
        if(strncmp(&indata[i],load,ln)==0)printf("%d\n",i);
    }
    
    
    return 0;
    
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	Fastest
	int a,b,c;
	cin >> a >> b >> c;
	int left = c-(a-b);
	
	if(left < 0) cout << 0 << endl;
	else cout << left << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/
/*cin.tie(0);
    ios::sync_with_stdio(false);
*/
int N, K;
int tag[11];
vector<vector<int>> v(10);
ll dp[2010]; //i番目までみてj個取っているときの最小値
int main()
{
    cin >> N >> K;

    for (int i = 0; i < N; ++i)
    {
        int C, G;
        cin >> C >> G;
        v[G - 1].push_back(C);
    }
    for (int i = 0; i < 2010; ++i)
    {
        dp[i] = -1;
    }
    dp[0] = 0;
    for (int i = 0; i < 10; ++i)
    {
        sort(v[i].rbegin(), v[i].rend());
        for (int j = K - 1; j >= 0; --j)
        {
            if (dp[j] == -1)
                continue;
            ll sum = 0;
            for (int k = 0; k < (int)v[i].size() && k + j + 1 <= K; k++)
            {
                sum += v[i][k];
                dp[j + k + 1] = max(dp[j + k + 1], dp[j] + sum + k * (k + 1));
            }
        }
    }
    cout << dp[K] << endl;
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int M;
  cin >> M;

  ll total_d = 0;
  ll total_S = 0;
  
  ll d, c;
  rep(i, M){
    cin >> d >> c;
    total_d += c;
    total_S += c * d;
  }

  cout << (total_d-1) + (total_S-1)/9 << endl;



  return 0;
}


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

int main()
{
	int n,year,month,day,count=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>year>>month>>day;
		
		if(year%3==0)//誕生年が３の倍数(全部大の月)
			count+=(21-day)+20*(10-month);
		else
		{
			count+=(20-day)+39*((10-month)/2);
			if(month%2!=0)//誕生月が大の月(奇数)の時
				count+=1+19;//大の月の最終日＋誕生月の翌月
		}

		year++;

		for(int i=year;i<1000;i++)
			if(i%3==0)
				count+=200;
			else
				count+=195;

		cout<<count<<endl;
		count=0;
	}
}

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

int main(){
  vector <int> result;
  int i,j,n,p,k,data[110000],primenum[100000];
  for(i = 0; i < 100001; i++){
    data[i]=0;
  }

  for(i = 0; i < 100000; i++){
    primenum[i]=0;
  }


  for(i = 2; i*i < 110000; i++){
    if(data[i]==0){
      for(j = 2*i; j < 110000; j+=i){
	data[j]=1;
      }
    }
  }
  data[0]=1;
  data[1]=1;
 
  while(1){
    result.clear();
    cin >> n >> p;
    if(n==-1 && p==-1)break;
    j = 0;
    for(i = n+1; i < 110000; i++){
      if(data[i]==0){
	primenum[j]=i;
	j++;
	if(j==1000)break;
      }
    }

    //for(i = 0; i < 30; i++){
    // cout <<"primenum[" << i << "]" << primenum[i] << endl;
    // }
      for(i = 0;i < 100; i++){
	for(k = i; k < 100; k++){
	result.push_back(primenum[i]+primenum[k]);
	//	cout << "primenum[i]" <<primenum[i] <<"primenum[k]" << primenum[k] << endl;
	}
      }

     
      
      sort(result.begin(),result.end());
      // for(i = 0; i < 100; i++){
      //	cout << "result[" <<i<< "]"<<result[i] << endl;
      // }
      cout << result[p-1] << endl;
      
    }
   return 0;
}

Measured memory_bytes: 2092
n, m = map(int, input().split())
ps = [int(p)-1 for p in input().split()]
xys = [tuple(int(x)-1 for x in input().split()) for _ in range(m)]

nodes = range(n)
union = {node:node for node in nodes}

def root(node, previouss=None):
    if not previouss:
        previouss = []

    if union[node] == node:
        for previous in previouss:
            union[previous] = node
        return node
    else:
        previouss.append(node)
        return root(union[node], previouss)

for x, y in xys:
    rx = root(x)
    ry = root(y)
    union[rx] = ry

groups = {node:{node} for node, rootn in union.items() if node==rootn} 
for node in nodes:
    if node in groups:
        continue
    group = groups[root(node)]
    group.add(node)
    groups[node] = group

print(sum(p in groups[i] for i, p in enumerate(ps)))

Measured memory_bytes: 61488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    vector<int> sa(N);
    sa[0] = K-A[N-1]+A[0];
    int mx=sa[0];
    int mxIdx=0;
    for(int i=1;i<N;++i)
    {
        sa[i] = A[i] - A[i-1];
        if(mx<sa[i])
        {
            mx=sa[i];
            mxIdx=i;
        }
        //cout << "sa:" << sa[i] << endl;
    }

    //cout << mx << endl;
    //cout << mxIdx << endl;


    int ans=0;
    for(int i=mxIdx+1;i<N;++i)
    {
        ans+=sa[i];
        //cout << "1:" << i << endl;
    }
    for(int i=0;i<mxIdx;++i)
    {
        ans+=sa[i];
        //out << "2:" << i << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long ch(string s, int i, int j) {
	long long res = 0;
	for (int k = 0; k < i; k++) {
		res = res * 10 + s[j + k] - '0';
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	long long ans = 0;
	vector<long long> f(11, 1);
	for (int i = 2; i < 11; i++) f[i] = f[i - 1] << 1;
	int n = (int)s.size();
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - i + 1; j++) {
			ans += f[j] * f[n - j - i] * ch(s, i, j);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, a[200010], ans, cnt[1000010], num[1000010];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		num[a[i]]++;
	}
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++) {
		if (num[a[i]] > 1) {
			cnt[a[i]]++;
			continue;
		}
		bool flag = 1;
		for (int j = 1; j * j <= a[i]; j++) {
			if (a[i] % j) continue;
			if (cnt[j]) {
				flag = 0;
				break;
			}
			if (cnt[a[i] / j]) {
				flag = 0;
				break;
			}
		}
		ans += flag;
		cnt[a[i]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 12116
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int N;
ll d[200010],cnt[200010];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N;
    for(int i=0;i<N;i++){
    	cin>>d[i];
    	cnt[d[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=N;i++) ans+=max(0LL,(cnt[i]*(cnt[i]-1))/2);
    for(int i=0;i<N;i++){
    	cout<<max(0LL,ans-(cnt[d[i]]-1))<<endl;
    }
    return 0;
}

Measured memory_bytes: 4736
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]
# BC = [list(input()) for _ in range(Q)]

# print(A)
# print(BC)
d = defaultdict(int)
sumv = sum(A)
for a in A:
    d[a] += 1
for bc in BC:
    b, c = bc
    sumv -= b * d[b]
    sumv += c * d[b]
    d[c] += d[b]
    d[b] = 0
    print(sumv)

# res = 0
# for iv in d.items():
#     i, v = iv
#     res += i*v
# print(res)

Measured memory_bytes: 103424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		for (int i = 0; i < 3; i++) {
			if (s[i]==s[i+1]) {
				System.out.println("Bad");
				return;
			}
		}
		System.out.println("Good");
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;
    if(a==0)
        cout << 1 << endl;
    if(b==0)
        cout << 2 << endl;
    if(c==0)
        cout << 3 << endl;
    if(d==0)
        cout << 4 << endl;
    if(e==0)
        cout << 5 << endl;

    return 0;
}


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

int main() {
  int cnt5 = 0, cnt7 = 0;
  rep(i, 3) {
    int n;
    cin >> n;
    if (n == 5) cnt5++;
    else if (n == 7) cnt7++;
  }

  if (cnt5 == 2 && cnt7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main(int argc, char** argv)
{
	unsigned char numList[1000000];
	int i, j, cnt, num, max, result[30];

	cnt = 0;
	memset(result, 0, sizeof(result));
	while (scanf("%d", &num) != EOF) {
		memset(numList, 0, sizeof(numList));

		for (i = 2; i <= sqrt((double)num); i++){
			if (!numList[i]) {
				for (j = 0; i * (j + 2) <= num; j++){
					numList[i *(j + 2)] = 1;
				}
			}
		}

		for (i = 2; i <= num; i++){
			if (!numList[i]){
				result[cnt]++;
			}
		}
		cnt++;
	}
	max = cnt;

	for (i = 0; i < max; i++) {
		printf("%d\n", result[i]);
	}
	return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  for(int i=0;i<b.size();i++){
    cout << a.at(i) << b.at(i);
  }
  if(a.size()>b.size()){
    cout << a.at(a.size()-1) ;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[110][100010];

int main(){
  int n,W;
  cin>>n>>W;
  ll w[n+1]={},v[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }

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

  for(int i=1;i<=n;i++){
    for(int j=0;j<=100000;j++){
      if(j+v[i]<=100000) dp[i][j+v[i]]=min(dp[i][j+v[i]],dp[i-1][j]+w[i]);
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }

  ll ans=0;
  for(int i=0;i<=100000;i++){
    if(dp[n][i]<=W) ans=max(ans,(ll)i);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;


	scanf("%d%d", &a, &b);

	c = a * b;
	d = 2 * (a + b);

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


	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll k, S;
	cin >> n>>k>>S;
	vector<ll> a(n);
	rep(i, k) {
		a[i] = S;
	}
	for (ll i = k; i < n; i++) {
		if (S != 1000000000) {
			a[i] = S + 1;
		}
		else {
			a[i] = S - 1;
		}
	}
	rep(i, n-1) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
}



Measured memory_bytes: 2048
n=int(input())
l=[]
for i in range(n):
    lo=input().split()
    l.append((int(lo[0]),int(lo[1]),int(lo[2])))
dp=[[0 for i in range(3)]for i in range(n)]
dp[0][0]=l[0][0]
dp[0][1]=l[0][1]
dp[0][2]=l[0][2]
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+l[i][0]
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+l[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+l[i][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))


Measured memory_bytes: 102748
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

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

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

#define data etokek

//#define int lll

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 2.5e5 + 32;
//const int M = 1e9 + 7;
const int mod = 998244353;
const int rx[4] = {-1, -1, 1, 1};
const int ry[4] = {-1, 1, -1, 1};
const lld eps = 1e-11;
const double pi = acos(-1.0);
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("mushrooms.in", "r", stdin);
//    freopen("mushrooms.out", "w", stdout);
#endif
    lld r;
    cin >> r;
    cout << fixed << setprecision(2) << 2.0 * pi * r;
    return 0;
}


Measured memory_bytes: 3816
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string a;
int lz;
int main() {
	cin>>a;
	int l=a.size();
	if(l==1) {
		cout<<a<<'\n';
		return 0;
	}
	int u=0;
	for(int i=0; i<l; i++) {
		if(a[i]!='9')
			u=1;
		int t=(int)(a[i])-48;
		lz+=t;
	}
	if(u==0) {
		cout<<l*9<<'\n';
		return 0;
	}
	if(a[0]!='1') {
		int e=(int)(a[0])-48;
		if(e-1+(l-1)*9>lz)
			cout<<e-1+(l-1)*9<<'\n';
		else
			cout<<lz<<'\n';
		return 0;
	}
	if((l-1)*9>lz)
		cout<<(l-1)*9<<'\n';
	else
		cout<<lz<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265359
int main(){
  double a,b,S,L,h,si,C;
  scanf("%lf%lf%lf",&a,&b,&C);
  si=sin(C*PI/180.0);
  
  S=a*b*si*1/2;
  
  L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*PI/180.0));

  h=S/a*2;

  printf("%f\n%f\n%f\n",S,L,h);

  return 0;
}
  

Measured memory_bytes: 648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int H = Integer.parseInt(ss0[0]);
		int W = Integer.parseInt(ss0[1]);

		String[][] ss2 = new String[H][W];
		for(int h = 0; h < H; h++){
			ss0 = br.readLine().trim().split("", 0);
			for(int w = 0; w < W; w++){
				ss2[h][w] = new String(ss0[w]);
			}
		}


					////入力値確認
					//for(int m = 0; m < H; m++){
					//	for(int n = 0; n < W; n++){
					//		//System.out.print("[" + ss2[m][n] + "]");
					//	}
					//	System.out.println("");
					//}


		//進んだ後に、戻った跡があるとアウト
		int x = 0;
		int y = 0;
		boolean b = true;
		for(int h = 0; h < H; h++){
			for(int w = 0; w < W; w++){
				if (ss2[h][w].equals("#")){
					if(w < y){ 
						b = false;
					}else{
						y = w;
					}
					if(h < x){
						b = false;
					}else{
						x = h;
					}
				}
				if(b){}else{ break; }
			}
			if(b){}else{ break; }
		}

		if (b) {
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}
        //System.out.println(iCount + " " + s);
        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  if (a > b) cout << "a > b\n";
  else if (a < b) cout << "a < b\n";
  else cout << "a == b\n";
}


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

int main() {

  int N;
  cin >> N;
  vector<int> number(N);
  for(int i=0; i<N; i++){ cin >> number.at(i);}
  
  sort(number.begin(), number.end());
  reverse(number.begin(), number.end());
  
  int Alice = 0;
  int Bob = 0;
  int k = 0;
  for(int j=0; j<N; j++){
  if(j%2==0){Alice = Alice + number.at(j);}
  if(j%2==1){Bob = Bob + number.at(j);}
  }
  
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256