akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  string t[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  REP(i,7){
    if(s == t[i]) cout << 7-i << endl;
  }


  return 0;
}

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


void solve() {
  int N,D;
  cin >> N >> D;
  int X[N][D];
  rep(i, N) {
    rep(j, D){
      cin >> X[i][j];
    }
  }
  int ans = 0;
  rep(i, N-1){
    for (int j = i+1; j < N; j++) {
      int norm=0;
      rep(k, D){
        int dif = abs(X[i][k]-X[j][k]);
        norm += dif * dif;
      }
      rep(k, norm+1) {
        if (k*k == norm) {
          ans++;
        }
      }
    }
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;
    Int alice = 0, bob = 0;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<>());
    for (Int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
def kaibunsu(X):
  a = X//10000
  b = (X - a*10000)//1000
  c = (X - a*10000 - b*1000)//100
  d = (X - a*10000 - b*1000 - c*100)//10
  e = X - a*10000 - b*1000 - c*100 - d*10
  x = e*10000 + d*1000 + c*100 + b*10 + a
  return x
count = 0
for i in range(A,B+1):
  if i == kaibunsu(i):
    count += 1
print(count)

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

const int l = 2000001;
ll b[l]{};

ll func(ll n) {
    return n * (n - 1) / 2;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        b[A[i]]++;
    }
    ll sum = 0;
    for (int i = 1; i < l; i++) {
        sum += b[i] * (b[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        cout << sum - func(b[A[i]]) + func(b[A[i]] - 1) << "\n";
    }
    return 0;
}

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


int main()
{
  ll n;
  cin >> n;
  string ans = "";
  while (n > 0)
  {
    n -= 1;
    ans += (n % 26) + 'a';
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

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

int sum[1000][24 * 60 + 10];
bool in[1000];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    memset(sum, 0, sizeof(sum));
    memset(in, 0, sizeof(in));
    for (int i = 0; i < n; i++) {
      int M, D, h, m, p;
      char ch, e;
      cin >> M >> ch >> D >> h >> ch >> m >> e >> p;
      if (p == 0) {
        if (e == 'I') {
          in[p] = true;
          for (int j = 1; j < 1000; j++) {
            if (in[j]) sum[j][h * 60 + m]++;
          }
        } else {
          in[p] = false;
          for (int j = 1; j < 1000; j++) {
            if (in[j]) sum[j][h * 60 + m]--;
          }
        }
      } else {
        if (e == 'I') {
          in[p] = true;
          if (in[0]) sum[p][h * 60 + m]++;
        } else {
          in[p] = false;
          if (in[0]) sum[p][h * 60 + m]--;
        }
      }
    }

    int ans = 0;
    for (int i = 0; i < 1000; i++) {
      int sub = 0;
      for (int j = 0; j < 24 * 60; j++) {
        sum[i][j + 1] += sum[i][j];
        sub += sum[i][j + 1];
      }
      ans = max(ans, sub);
    }
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int n, m;
  cin >> n >> m;
  vector < pair < int, int > > v;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    v.push_back({b, a});
  }
  sort(v.begin(), v.end());
  int ans = 1, broke;
  broke = v[0].first - 1;
  for(int i = 1; i < m; i++){
    if(broke < v[i].first && broke >= v[i].second) continue;
    ans++;
    broke = v[i].first - 1;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> X(N), Y(N);
   int x;
   for(int i=0; i<N; ++i){
      std::cin >> x;
      X[i] = x;
      Y[i] = x;
   }

   std::sort(Y.begin(),Y.end());
   int median = Y[N/2];
   int ans = 0;
   for(int i=0; i<N; ++i){
      if(X[i]<median) ans = Y[N/2];
      else ans = Y[N/2-1];
      std::cout << ans << std::endl;
   }
   return 0;
}


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

typedef long long 			ll;
typedef unsigned long long 	ull;

const int N = 100 + 20;
const int MAXN = 100 * 1000 + 20;

//ll a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll a, b, k;
	cin >> a >> b >> k;
	cout << max(0ll, a - k) << " " << max(0ll, min(b, b - (k - a))) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b;
  cin >> a >> b;
  if(a>b)swap(a,b);

  for(ll i=0;i<b;i++)cout << a;

}

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

// A=0 G=1 C=2 T=3
int dp[101][4][4][4];

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

  int mod = 1000000007;
  int n; cin >> n;
  dp[0][3][3][3] = 1;

  rep(len, n) {
    rep(c1, 4) {
      rep(c2, 4) {
        rep(c3, 4) {
          rep(s, 4) {
            // AG C
            if(c2 == 0 && c1 == 1 && s == 2) continue;
            // GA C
            if(c2 == 1 && c1 == 0 && s == 2) continue;
            // AC G
            if(c2 == 0 && c1 == 2 && s == 1) continue;
            // AG? C
            if(c3 == 0 && c2 == 1 && s == 2) continue;
            // A?G C
            if(c3 == 0 && c1 == 1 && s == 2) continue;

            dp[len + 1][s][c1][c2] += dp[len][c1][c2][c3];
            dp[len + 1][s][c1][c2] %= mod;
          }
        }
      }
    }
  }

  int ans = 0;
  rep(c1, 4) {
    rep(c2, 4) {
      rep(c3, 4) {
        ans += dp[n][c1][c2][c3];
        ans %= mod;
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)n; i++)
constexpr int MOD = 1e9 + 7;
int n;
int a[22][22];
int dp[22][1<<22];

int main() {
    int N; cin >> N;
    REP(i,N) REP(j,N) cin >> a[i][j];

    dp[0][(1<<N)-1] = 1;
    for(int i=1;i<=N;++i){
        for(int bit=(1<<N)-2;bit>=0;--bit){
            if(N-__builtin_popcount(bit)==i){ // num of j who already matched == num of i
                for(int j=0;j<N;++j){ // if i-1 and j are not matched
                    if(!(bit & (1<<j)) && a[i-1][j]) (dp[i][bit] += dp[i-1][bit|(1<<j)])%=MOD;
                }
            }
        }
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 180480
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int a, b;
// main solution goes here:
void execute(int test_number)
{
    cin>>a>>b;
    if ((a+b)%2==0) cout<<(a+b)/2;
    else cout<<"IMPOSSIBLE";
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

dp = []

for i in range(N):
	dp.append(float("inf"))
dp[0] = 0
for i in range(N):
	if not i+1 > N -1:
		dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
	if not i+2 > N -1:
		dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])

Measured memory_bytes: 13928
#include<iostream>
 double v(double x, double a) {
	return x * (a-x)/2.0 * (a - x - (a-x)/2.0);
}
int main() {
	double l;
	std::cin >> l;
	double v_max = 0.0;
	for (double i = 0.0; i <= l / 3.0; i += 0.0001) {
		if (v_max < v(i, l)) {
			v_max = v(i, l);
		}
	}
	printf("%20.11f", v_max);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int less = 0,more = 0;
  for(int i = 0;i<b;i++){
    int d;
    cin >> d;
    if(c<d)
      more++;
    else
      less++;
  }
  cout << min(more,less) << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc167/tasks/abc167_f

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

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

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

//------------------------------------------------------------------------------
const int N_MAX = 1e6;

struct piece {
  int b;
  int h;
  bool operator > (const piece &p) const {
    if (b != p.b) return b > p.b;
    return h > p.h;
  }
};

int N;
vector<string> S;

vector<piece> ls;
vector<int> ms;
vector<piece> rs;

int make_seq(vector<piece> &ps) {
  multiset<int> st;
  sort(ps.begin(), ps.end(), greater<piece>());

  // for (auto p : ps) cout << "(" << p.b << "," << p.h << ") ";
  // cout << endl;

  int h = 0;
  int i = 0;
  while (true) {
    for (; i < ps.size(); i++) {
      if (h + ps[i].b < 0) break;
      st.insert(ps[i].h);
    }
    if (st.empty()) break;
    // cout << "h += " << *st.rbegin() << endl;
    h += *st.rbegin();
    st.erase(--st.end());
  }

  if (i < ps.size()) return -1;
  return h;
}

int main() {
  cin >> N;
  S = vector<string>(N);
  REP(i, N) cin >> S[i];

  REP(i, N) {
    int h = 0;
    int b = 0;
    REP(j, S[i].size()) {
      if (S[i][j] == '(') h++;
      else h--;
      chmin(b, h);
    }
    if (h > 0) ls.push_back({b, h});
    else if (h < 0) rs.push_back({b - h, -h});
    else ms.push_back(b);
  }

  int h = make_seq(ls);
  if (h < 0) {
    cout << "No" << endl;
    return 0;
  }

  int h2 = make_seq(rs);
  if (h2 < 0) {
    cout << "No" << endl;
    return 0;
  }

  if (h != h2) {
    cout << "No" << endl;
    return 0;
  }

  for (auto b : ms) {
    if (h + b < 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

using namespace std;

int mumujun(string s, string temp, int k, int n){
	if (s[k] == 'o'){
		if (temp[k] == 'S' && temp[(k-1+n)%n] == temp[(k+1)%n]){
			return 1;
		}
		if (temp[k] == 'W' && temp[(k-1+n)%n] != temp[(k+1)%n]){
			return 1;
		}
	}
	if (s[k] == 'x'){
		if (temp[k] == 'W' && temp[(k-1+n)%n] == temp[(k+1)%n]){
			return 1;
		}
		if (temp[k] == 'S' && temp[(k-1+n)%n] != temp[(k+1)%n]){
			return 1;
		}
	}

	return 0;

}

int main(void){
	int n;
	string s;

	char zero[2] = {'S', 'W'}, one[2] = {'S', 'W'};


	cin >> n >> s;

	int ok = 0;

	string temp, res;

	for (int i = 0; i < 2; i++){
		for (int j = 0; j < 2; j++){
			temp = "";
			for (int k = 0; k < n; k++){
				if (k == 0){
					temp += zero[i];
				}
				else if (k == 1)
					temp += one[j];
				else {
					if (s[k-1] == 'o'){
						if (temp[k-1] == 'S')
							temp += temp[k-2];
						else {
							if (temp[k-2] == 'S')
								temp += "W";
							else
								temp += "S";
						}
					}
					else {
						if (temp[k-1] == 'W')
							temp += temp[k-2];
						else {
							if (temp[k-2] == 'S')
								temp += "W";
							else
								temp += "S";
						}
					}
				}

				if (k == n - 1 && ok == 0){
					if (mumujun(s, temp, k, n) && mumujun(s, temp, 0, n))
						ok = 1;

					if (ok == 1){
						res = temp;
					}
				}
			}
		}
	}

	if (ok)
		cout << res << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

char alpha[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

int main() {
    int n;
    string s;
    cin >> n >> s;

    rep(i, s.size()) {
        rep(j, 26) {
            if(s[i] == alpha[j]) {
                s[i] = alpha[(j+n)%26];
                break;
            }
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	int n; cin>>n;
	string s; cin>>s;
	if(n==1){
		if(s=="0")cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	string t=s;
	reverse(all(t));
	vl memo1(n),memo2(n);
	ll sum1=0,sum2=0;
	if(t[0]=='1')sum1=1,sum2=1;
	ll cnt=0;
	rep(i,0,n)cnt+=(s[i]=='1');
	if(cnt==1){

	}
	memo1[0]=1; memo2[0]=1;
	rep(i,1,n){
		memo1[i]=memo1[i-1]*2%(cnt+1);
		if(cnt-1>0)memo2[i]=memo2[i-1]*2%(cnt-1);
		if(t[i]=='1'){
			sum1+=memo1[i];
			sum1%=(cnt+1);
			sum2+=memo2[i];
			if(cnt-1>0)sum2%=(cnt-1);
		}
	}
	vl ans(n);
	rep(i,0,n){
		ll j;
		if(t[i]=='0'){
			j=sum1;
			j+=memo1[i];
			j%=(cnt+1);
		}
		else{
			j=sum2;
			j-=memo2[i];
			if(j<0)j+=(cnt-1);
			//if(cnt-1>0)j%=(cnt-1);
			if(cnt-1==0){
				ans[i]=0;
				continue;
			}
		}

		ll add=1;
		while(j>0){
			if(__builtin_popcount(j)==0){
				add++;
				break;
			}
			j%=__builtin_popcount(j);
			add++;
		}
		ans[i]=add;
	}
	reverse(all(ans));
	rep(i,0,n)cout<<ans[i]<<endl;


	return 0;
}

Measured memory_bytes: 8328
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> D(N);
    for(int i=0;i<N;i++) cin >> D[i];

    vector<int> cnt(13,0);
    cnt[0] += 1;
    for(int i=0;i<N;i++) cnt[D[i]]++;

    int ans = -1;

    for(int i=0;i<(1<<11);i++){
        vector<bool> used(24,false);
        int s = numeric_limits<int>::max();

        for(int j=0;j<=12;j++){
            if(cnt[j]){
                if(j==0 || j==12){
                    used[j] = true;
                    if(cnt[j]>=2){
                        s = 0;
                    }
                }else{
                    if(cnt[j] == 1){
                        used[((i & (1<<(j-1))) ? j : 24-j)] = true;
                    }else if(cnt[j] == 2){
                        used[j] = used[24-j] = true;
                    }else{
                        s = 0;
                    }
                }
            }
        }
        for(int j=0;j<24;j++){
            if(used[j]){
                for(int k=0;k<j;k++){
                    if(used[k]){
                        s = min(s, min(abs(k-j), 24 - abs(k-j)));
                    }
                }
            }
        }
        ans = max(ans, s);
    }

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

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

int main() {
    int n;
    cin>>n;
    int a,d=0;
    for(int i=1;i<=n;i++){
        a=i*1.08;
        if(a==n){
            cout<<i;
            d=1;
            break;
        }
    }
    if(d==0) cout<<":(";
    return 0;
}



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int r,g; cin >> r >> g;
    out(2*g-r);
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
cnt = 0
old_cnt = 0
ls = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt +=1
    else:
        ls.append(cnt)
        cnt = 0
ls.append(cnt)
print(max(ls))

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int H, W, K; cin>>H>>W>>K;

    vector<string> C(H);
    rep(i,H)cin>>C.at(i);

    //2^(W+H)通りの組み合わせについて調べればよいことになる

    int total = W+H;
    int ans=0;
  for (int tmp = 0; tmp < (1 << total); tmp++) {
    bitset<12> s(tmp);


    int tot = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            //i行j列が黒かどうかをチェックする
            if(s[i]==1)continue;
            if(s[j+H]==1)continue;
            if(C.at(i).at(j)=='#')tot++;
        }
    }
    if(tot==K)ans++;




  }
  cout<<ans<<endl;
 





    return 0;
}

Measured memory_bytes: 3628
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b ,a%b)

def lcm(a,b):
  return a*b / gcd(a,b)

while True:
  try:
    a = map(int,raw_input().split())
    a,b = a[0],a[1]
    print gcd(a,b)
  except EOFError:
    break

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

void solve(int &n, int &l, int &r) {
  int a[51];
  rep(i, 0, n) cin >> a[i];
  int ans = 0;
  rep(i, l, r + 1) {
    bool uruu = (n & 1 ? false : true);
    rep(j, 0, n) {
      if (i % a[j] == 0) {
        uruu = (j & 1 ? false : true);
        break;
      }
    }
    if(uruu) ans++;
  }
  cout << ans << endl;
}

int main() {
  int n, l, r;
  while (cin >> n >> l >> r, n) solve(n, l, r);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int inf = 0x3f3f3f3f;
int N;
int h[maxn];
int dp[maxn];
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &h[i]);
    }
    memset(dp, inf, sizeof(dp));
    dp[1] = 0;
    for(int i = 1; i <= N; i++)
    {
        if(i + 1 <= N) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if(i + 2 <= N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    printf("%d\n", dp[N]);
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  b = 0;
  a = 0;
  in(n);
  vector<ll> c(n);
  rep(i, n){
    in(c[i]);
    if(a <= c[i]){
      a = c[i];
      b++;
    }
  }
  out(b);
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(b));sort(all(c));
  vector<ll>sum(n+1);//先にbからcにかけて真に大きいものを求めておく
  rep(i,n){
    sum[i+1]=sum[i]+(c.end()-upper_bound(all(c),b[i]));
  }
  //rep(i,n+1)cerr<<sum[i]<<"\n";
  ll ans=0;
  rep(i,n){
    int pos=upper_bound(all(b),a[i])-b.begin();
    ans+=sum[n]-sum[pos];
    //cerr<<sum[n]-sum[pos]<<endl;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int n,k,haha;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&haha);
	if(n<=k){
		printf("1");
		return 0;
	}
	else{
		int ans=0;
		n-=k;ans++;
		double p=(double)n/(double)(k-1);
		double r=ceil(p);
		int a2=r;
		printf("%d",a2+ans);
	}
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b && a==c)
 	printf("%d %d %d",a,b,c);
  else
    printf("%d %d %d",c,a,b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    string str;
    cin>>str;
    ll cnt=0,ans=0;
    for(auto c:str){
        if(c=='R') cnt++;
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

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

  string s;
  cin >> s;

  if (s.length() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  int h = (n / 2);
  bool r = true;
  for (int i = 0; i < h; i++) {
    if (s[i] != s[i + h]) {
      r = false;
      break;
    }
  }

  if (r) {
    cout << "Yes" << endl;

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


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

int main(){
	int n,k;
	cin >> n >> k;
	set<int>s;
	while(k--){
		int l;
		cin >> l;
		for(int i = 0; i < l; i++){
			int temp;
			cin >> temp;
			s.insert(temp);
		}
	}
	int count = 0;
	for(int i = 1; i <=n ;i++){
		if(s.find(i) == s.end()){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vpii cons(m);
    rep(i, m) cin >> cons[i].first >> cons[i].second;
    rep(x, 1000) {
        int ni = x;
        vi d;
        do {
            d.push_back(ni % 10);
            ni /= 10;
        } while (ni);
        reverse(d.begin(), d.end());
        if (int(d.size()) != n) continue;
        bool ans = true;
        rep(i, m) {
            if (d[cons[i].first-1] != cons[i].second) ans = false;
        }
        if (ans) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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


int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(A.begin(), A.end()); sort(C.begin(), C.end());
    long long b_element, A_dist, C_dist;
    long long ans = 0;
    vector<int>::iterator A_pos, C_pos;
    for (int i = 0 ; i < N; i++) {
        b_element = B[i];
        A_pos = lower_bound(A.begin(), A.end(), b_element);
        C_pos = upper_bound(C.begin(), C.end(), b_element);
        A_dist = distance(A.begin(), A_pos);
        C_dist = N - distance(C.begin(), C_pos);
        ans += A_dist * C_dist;
    }
    cout << ans << '\n';
}


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

int main(int argc, const char * argv[]) {
    int i;
    int N = 0;
    int A = 0;
    int B = 0;
    
    scanf("%d %d %d", &N, &A, &B);
    
        if((N * A) < B){printf("%d\n", N * A);}
        else if((N * A) >= B){printf("%d\n", B);}
    
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c>=a && c<=b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc130_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll W, H;
  cin >> W >> H;

  ll x, y;
  cin >> x >> y;

  printf("%Lf %d", (long double)W * H / 2, 2 * x == W && 2 * y == H);
}

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

map<string, int> memo;

int main() {
	int n;
	cin >> n;
	rep(i,n) {
		string s;
		cin >> s;
		memo[s] += 1;
	}

	int maxv = 0;
	for (const auto& x : memo) {
		int v = x.second;
		if (v > maxv) maxv = v;
	}
	for (auto it = memo.begin(); it != memo.end(); it++) {
		if (it->second == maxv) {
			cout << it->first << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 25216
# include <bits/stdc++.h>
# define ll long long 
using namespace std;
const ll N = 2e5 + 10, mod = 1e9 + 7;
int a[N], b[N], c[N], d[N], p[N], s[N], n, m, k;
vector < int > fr[N], bl[N];
int find_set(int x){
    return x == p[x] ? x : p[x] = find_set(p[x]);
}
void union_sets(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a == b)return;
    p[a] = b;
    s[b] += s[a];
    s[a] = 0; 
}
void make_set(int x){
    p[x] = x;
    s[x] = 1;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)make_set(i);
    for(int i = 1; i <= m; i++){
        cin >> a[i] >> b[i];
        fr[a[i]].push_back(b[i]);
        fr[b[i]].push_back(a[i]);
        union_sets(a[i], b[i]);
    }
    for(int i = 1; i <= k; i++){
        cin >> c[i] >> d[i]; 
        bl[c[i]].push_back(d[i]);
        bl[d[i]].push_back(c[i]);
    }
    for(int i = 1; i <= n; i++){
        int x = s[find_set(i)] - fr[i].size() - 1;
        for(int j = 0; j < bl[i].size(); j++){
            if(find_set(i) == find_set(bl[i][j]))x --;
        }
        cout << x << ' ';
    }
}

Measured memory_bytes: 20856
#include<stdio.h>
#define N 1000000007

typedef long long int lli;

lli memo[220001];

void inittable(lli n){
  lli i;

  memo[1]=1;

  for(i=2;i<=n;i++){
    memo[(int)i]=(i*memo[(int)(i-1)])%N;
  }
}

lli extgcd(lli a,lli b,lli *x,lli *y){
  lli d=a;

  if(b!=0){
    d=extgcd(b,a%b,y,x);

    *y-=(a/b)*(*x);
  }
  else{
    *x=1;
    *y=0;
  }

  return d;
}

lli mod_inv(lli a,lli m){
  lli x,y;

  extgcd(a,m,&x,&y);

  return (m+x%m)%m;
}

lli mod_cmb(lli n,lli r,lli m){
  lli a1,a2,a3;

  if((n<0)||(r<0)||(n<r)){
    return 0;
  }

  a1=memo[n];
  a2=memo[r];
  a3=memo[n-r];

  return a1*mod_inv(a2*a3%m,m)%m;
}

int main(){
  int x,y,k;
  int i,j;
  lli ans;
  lli xgr,ygr;

  scanf("%d %d %d",&x,&y,&k);

  inittable(x+y+2*k);
  memo[0]=1;
  ans=0;

  for(i=0;i<=k;i++){
    xgr=(mod_cmb(x+2*(k-i),k-i,N)-mod_cmb(x+2*(k-i),k-i-1,N)+N)%N;
    ygr=(mod_cmb(y+2*i,i,N)-mod_cmb(y+2*i,i-1,N)+N)%N;

    ans=(ans+((xgr*ygr)%N)*mod_cmb(x+y+2*k,y+2*i,N))%N;
  }
  printf("%d\n",(ans+N)%N);

  return 0; 
}

Measured memory_bytes: 2308
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


int aa[200000],bb[200000],cc[2000000];
 
void t(){
  aa[0]=aa[1]=1;
  bb[0]=bb[1]=1;
  cc[1]=1;
  repi(i,2,200000){
    aa[i]=aa[i-1]*i%MOD;
    cc[i]=MOD-cc[MOD%i]*(MOD/i)%MOD;
    bb[i]=bb[i-1]*cc[i]%MOD;
  }
}
 
int calc(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return aa[n]*(bb[k]*bb[n-k]%MOD)%MOD;
}
 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  t();
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
 
  int ansa=0;
  int ansb=0;
  repi(i,k-1,n){
    int num;
    num=calc(max(i,(int)0),k-1);
    num=num*a[i]%MOD;
    ansa+=num;
    if(ansa<0){
      ansa*=(-1);
      ansa%=MOD;
      ansa=MOD-ansa;
    }
    ansa%=MOD;
  }
  rep(i,n-k+1){
    int num;
    num=calc(max(n-i-1,(int)0),k-1);
    num=num*a[i]%MOD;
    num%=MOD;
    ansb+=num;
     if(ansb<0){
      ansb*=(-1);
      ansb%=MOD;
      ansb=MOD-ansb;
    }
    ansb%=MOD;
  }
  int ans=ansa-ansb;
  if(ans<0){
    ans*=(-1);
      ans%=MOD;
      ans=MOD-ans;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = n; i >= 0; i--)
#define For(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
template <class T = int> T in(){T x; cin >> x; return (x);}

int main(void){
    ll a, b;
    cin >> a >> b;
    ll result;
    ll max = std::max(a,b);
    result = max * 2;
    if( a != b){
        result --;
    }
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod = 1e9+7;

ll mp(ll a,ll b,ll m) {
    ll res = 1;
    while(b) {
        if(b&1LL)
            res = (res * a)%m , res %= m;
        b>>=1LL;
        a = (a * a)%m;
    }
    return res;
}

void solve(){
    ll n;
    cin >> n;
    ll ans = 0;
    ans += mp(10LL,n,mod);
    ans %= mod;
    ans -= mp(9LL,n,mod);
    if(ans < 0)
        ans += mod;
    ans -= mp(9LL,n,mod);
    if(ans < 0)
        ans += mod;
    ans += mp(8LL,n,mod);
    ans %= mod;
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3640
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 200 * 1001;
const ll mod = 998244353;

ll n , m , k;
ll a[maxn], t[4*maxn], la[4*maxn];

void build(ll v, ll tl, ll tr)
{
    if(tl == tr)
        t[v] = 0;
    else
    {
        ll tm = (tl+tr)/2;
        build(2*v, tl, tm);
        build(2*v+1, tm+1, tr);
        t[v] = min(t[2*v], t[2*v+1]);
    }
}

ll qu(ll v, ll tl, ll tr, ll l, ll r)
{
    if(l > r) return 0;
    if(l == tl && r == tr) return t[v];

    ll tm = (tl+tr)/2;
    return max(qu(2*v, tl, tm, l, min(tm,r)),
                qu(2*v+1, tm+1, tr, max(l,tm+1), r));
}

void up(ll v, ll tl, ll tr, ll pos, ll val)
{
    if(tl > pos || tr < pos) return;
    if(tl == tr){
        t[v] = val;
        return;
    }

    ll tm = (tl+tr)/2;
    up(2*v, tl, tm, pos, val);
    up(2*v+1, tm+1, tr, pos, val);
    t[v] = max(t[2*v], t[2*v+1]);
}

ll h[maxn];
ll idx[maxn];
ll dp[maxn];

int main()
{
    cin>> n;
    for(ll i = 0; i < n; i++){
        cin>> h[i];
        idx[h[i]] = i;
    }
    for(ll i = 0; i < n; i++) cin>> a[i];
    build(1, 0, n-1);

    ll ans = 0;
    for(ll i = 1; i <= n; i++)
    {
        dp[idx[i]] = qu(1, 0, n-1, 0, idx[i]-1) + a[idx[i]];
        up(1, 0, n-1, idx[i], dp[idx[i]]);
        ans = max(ans, dp[idx[i]]);
    }

    cout<< ans;
}










Measured memory_bytes: 14976
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]

a = sorted(a)
que1 = deque([a[0]])
for i in range(1, n):
    if i%4 == 1:
        que1.appendleft(a[-(2*(i//4)+1)])
    elif i%4 == 2:
        que1.append(a[-(2*(i//4)+2)])
    elif i%4 == 3:
        que1.appendleft(a[2*(i//4)+1])
    else:
        que1.append(a[i//2])

que2 = deque([a[-1]])
for i in range(n-1):
    if i%4 == 0:
        que2.appendleft(a[i//2])
    elif i%4 == 1:
        que2.append(a[2*(i//4)+1])
    elif i%4 == 2:
        que2.appendleft(a[-(i//2+1)])
    else:
        que2.append(a[-(i//2+2)])

sum1 = 0
i = que1.popleft()
while len(que1) > 0:
    j = que1.popleft()
    sum1 += abs(i - j)
    i = j

sum2 = 0
i = que2.popleft()
while len(que2) > 0:
    j = que2.popleft()
    sum2 += abs(i-j)
    i = j
    
print(max(sum1, sum2))


Measured memory_bytes: 10996
import bisect
inf = 10**18
a, b, q = map(int, input().split())
s = []
t = []
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
s = [-1*inf] + s + [inf]
t = [-1*inf] + t + [inf]
for i in range(q):
  x = int(input())
  index_s = bisect.bisect_left(s, x)
  index_t = bisect.bisect_right(t, x)
  s1 = abs(s[index_s]-x)#xより右側で一番近い神社までの距離
  s2 = abs(s[index_s-1]-x)#xより左側で~
  t1 = abs(t[index_t]-x)#xより右側で~寺~
  t2 = abs(t[index_t-1]-x)#xより左側で~
  print(min([max(s1, t1), max(s2, t2), 2*s1+t2, 2*t2+s1, 2*s2+t1, 2*t1+s2]))

Measured memory_bytes: 12784
local n,a,b=io.read("n","n","n")
local x={}
for i=1,n do
    x[i]=io.read("n")
end

local cost=0
for i=1,n-1 do
    cost=cost+math.min(a*(x[i+1]-x[i]),b)
end
print(cost)

Measured memory_bytes: 4240
#include<iostream>
#include<string>
using namespace std;
# define maxn 100 

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  // for (int i(0);i < m; i++){
  //   cin >> a[i];
  //   sum += a[i];
  // }
  cout << t / a * b;
  // int kouho_1 = sum / n, kouho_2 = sum / n + 1, kouho_3 = sum / n - 1;
  // int sum_1(0),sum_2(0),sum_3(0);

  // for (int i(0);i < n; i++){
  //   sum_1 += (kouho_1 - a[i]) * (kouho_1 - a[i]);
  //   sum_2 += (kouho_2 - a[i]) * (kouho_2 - a[i]);
  //   sum_3 += (kouho_3 - a[i]) * (kouho_3 - a[i]);
  // }
  // cout << min(sum_1,min(sum_2,sum_3));
  return 0;
}


Measured memory_bytes: 888
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--) 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    ll n,s,t,k=0;
    cin>>n>>t>>s;
    k=n/s;
    if(n%s!=0)
    k++;
    if(k<=t)
    cout<<"Yes";
    else
    cout<<"No";
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sort(v) sort(all(v))



/* constant */
const int inf = 100100100100100100;
const int mod = 1000000007;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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


/* math_library */
int ceil(int a, int b){if(a % b == 0){return a/b;}else{return a/b + 1;}}


/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

  
    int n = input();

    vector<pair<int, int> > arr;

    rep(i,0,n){
        int t = input();
        arr.push_back(make_pair(t, i));
    }

    sort(arr);

    int ans = 0;
    int i = 1;
    int cnt = 1;
    while(i < n){
        if(arr[i -1].second < arr[i].second){
            cnt++;
        }else{
            chmax(ans, cnt);
            cnt = 1;
        }
        i++;
    }
    chmax(ans, cnt);

    print(n - ans);




   




}   


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
  int n;
  cin>>n;
  set<int> S;
  int cnt8 = 0;
  REP(i,n){
    int a;
    cin>>a;
    CHMIN(a,3200);
    a /= 400;
    S.insert(a);
    if(a==8)cnt8++;
  }
  int mn = S.size() - (cnt8>0);
  if(mn==0)mn=1;
  int mx = S.size() - (cnt8>0) + cnt8;
  printf("%d %d\n",mn,mx);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(2):
    a.append(list(map(int, input().split(" "))))

ans_l = []
for i in range(n):
    ans = 0
    f = False
    for j in range(n):
        if j == 0:
            ans += a[0][0]
        elif f:
            ans += a[1][j]
        else:
            ans += a[0][j]

        if i == j:
            ans += a[1][j]
            f = True

    ans_l.append(ans)
print(max(ans_l))


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

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

using namespace std;

int main(){
  int s;
  cin>>s;
  
  if(s<1200){
    cout<<"ABC";
  }else if(s<2800){
    cout<<"ARC";
  }else{
    cout<<"AGC";
  }
  
  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() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    if (n <= k) cout << 0 << endl;
    else {
        int count;
        ll ans = 0;
        sort(h.begin(), h.end(),greater<int>());
        for (int i = k; i < n; i++) ans += h[i];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1024