akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

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

	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		double y = (d * c - a * f) / (d * b - a * e);
		double x = (c - b * y) / a;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    ll X;
    cin >> X;

    int A, B;
    for(int i = -1000; i <= 1000; i++) {
        for(int j = -1000; j < 1000; j++) {
            if(pow(i, 5) - pow(j, 5) == X) {
                A = i;
                B = j;
            }
        }
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 4084
<?php
while (true) {
    list($h, $w) = sscanf(trim(fgets(STDIN)), "%d %d");
    if ($h == 0 && $w == 0) { break; }
    
    for ($i=1; $i<=$h; $i++) {
        if ($i % 2 == 0) {
            for ($j=1; $j<=$w; $j++) {
                if ($j % 2 == 0) {
                    echo "#";
                } else {
                    echo ".";
                }
            }
        } else {
            for ($j=1; $j<=$w; $j++) {
                if ($j % 2 == 0) {
                    echo ".";
                } else {
                    echo "#";
                }
            }
        }
        echo "\n";
    }
    echo "\n";
}



Measured memory_bytes: 9224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const int MAXN = 1005;
const int MAXV = MAXN * MAXN; // The number of vectices is N*(N-1)/2
vector< vector<int> > to; // Adjacency matrix
int id[MAXN][MAXN];
int toId(int i, int j) {
  if (i > j) { swap(i, j); }
  return id[i][j];
}

int dp[MAXV]; // Max length of path from v. Initialized by -1.
int dfs(int v) {
  if (dp[v] >= 0) { return dp[v]; } // Already calculated.
  if (dp[v] == -2) { return -1; } // Loop exists.
  dp[v] = -2; // -2 represents the intermediate state.

  int d = 1;
  for (auto u : to[v]) {
    int res = dfs(u);
    if (res == -1) { return -1; } // Loop exists
    d = max(d, res + 1);
  }
  return dp[v] = d;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  vector< vector<int> > A(N, vector<int>(N-1));
  rep(i, N) {
    rep(j, N-1) {
      cin >> A[i][j];
      --A[i][j];
    }
  }

  int V = 0;
  for (int i = 0; i < N-1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      id[i][j] = V++;
    }
  }

  to.resize(V);
  rep(i, N) {
    for (int j = 0; j < N - 2; ++j) {
      int p = toId(i, A[i][j]);
      int n = toId(i, A[i][j+1]);
      to[p].push_back(n);
    }
  }

  int ans = 0;
  memset(dp, -1, sizeof(dp));
  rep(i, V) {
    int res = dfs(i);
    if (res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }

  cout << ans << endl;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  map<ll,ll> cnt;
  for(auto ai:a)cnt[ai]++;

  map<ll,ll> solve;
  for(auto x:cnt){
    solve[x.first] = x.second*(x.second-1)/2;
  }

  ll sum = 0;
  for(auto x:solve)sum+=x.second;

  for(auto ai:a){
    ll tmp = sum-solve[ai];
    tmp += (cnt[ai]-1)*(cnt[ai]-2)/2;
    cout<<(tmp)<<endl;
  }

}

Measured memory_bytes: 20736
use proconio::input;

fn main() {
    input! {
        mut n: u64,
        m: usize,
        a: [u64; m],
    }

    let mut f = false;
    for aa in a {
        if n >= aa {
            n -= aa;
        } else {
            println!("{}", -1);
            f = true;
            break;
        }
    }
    if !f {
        println!("{}", n);
    }
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string S;
  cin >> n;
  //P, W, Gは必ず存在する
  //Yが含まれているか否かを判別すればよい
  for(int i=0; i<n;i++){
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
n,m = map(int, input().split())

A = [input() for i in range(n)]
B = [input() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,m)):
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <limits>

int main() {
  double x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  int q;
  std::cin >> q;

  std::cout << std::fixed;
  std::cout << std::setprecision(std::numeric_limits<double>::max_digits10);
  for (int i = 0; i < q; ++i) {
      double x, y;
      std::cin >> x >> y;

      double num = -(x2 - x1) * (x1 - x) - (y2 - y1) * (y1 - y);
      double den = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
      double t = num / den;
      
      double u = x1 + t * (x2 - x1);
      double v = y1 + t * (y2 - y1);

      double k = x + 2 * (u - x);
      double l = y + 2 * (v - y);

      std::cout << k << " " << l << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3276
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n;
int ei[105][12];
int p[105][12];

int main(){
  cin >> n;
  REP(i,n){
    REP(j,10){
      cin >> ei[i][j];
    }
  }
  REP(i,n){
    REP(j,11){
      cin >> p[i][j];
    }
  }
  int rieki = -1e9;
  REP(i,pow(2,10)){
    if(i==0) continue;
    int rieki2 = 0;
    REP(l,n){
      int k = i;
      int now;
      int open = 0;
      REP(j,10){
        now = k%2;
        k /= 2;
        if(now==1&&ei[l][j]==1) open ++;
      }
      rieki2 += p[l][open];
    }
    rieki = max(rieki,rieki2);
  }
  cout << rieki << endl;
  return 0;
}


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

using namespace std;

int main()
{
  bool ans = true;
  int a;
  string s;

  cin >> s;

  a = s.length();

  for (int i = 0; i < a / 2; i++)
  {
    if (s[i] == s[a - 1 - i])
    {
      continue;
    }
    else
    {
      cout << "No" << endl;
      ans = false;
      break;
    }
  }

  for (int i = 0; i < a / 2 / 2; i++)
  {
    if (ans == false)
      break;
    if (s[i] == s[a / 2 - 1 - i])
    {
      continue;
    }
    else
    {
      cout << "No" << endl;
      ans = false;
      break;
    }
  }

  if (ans)
  {
    cout << "Yes" << endl;
  }
}

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

int main() {
  long long N, K, M, L, P, s, t,u;
  cin >> N >> K;
  M = N/K;
  L = M -1;
  P = M +1;
  s = abs(N- M*K);
  t = abs(N- L*K);
  u = abs(N- P*K);
  if( K == 1) {
    cout << "0";
  }
  else {
    cout << min(s,min(t,u));
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
ii v[1000050];
ll n, k,x;
int main(){
  scanf("%lld%lld", &n, &k);
  for(int i=0;i<n;i++){
    scanf("%lld%lld", &(v[i].first), &(v[i].second));
  }
  sort(v, v + n);
  for(int i=0;i<n;i++){
    x += v[i].second;
    if(x >= k) {printf("%lld\n", v[i].first); break;}
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};



int main() {
    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    bool ok = true;
    int sum = 0;
    rep(i,3) rep(j,3){
        sum += c[i][j];
    }
    if(sum % 3 != 0){cout << "No" << endl; return 0;}
    sum /= 3;
    if(c[0][0]+c[1][1]+c[2][2]!= sum) ok = false;
    if(c[0][0]+c[2][1]+c[1][2] != sum) ok = false;
    if(c[1][0]+c[0][1]+c[2][2] != sum) ok = false;
    if(c[1][0]+c[2][1]+c[0][2] != sum) ok = false;
    if(c[2][0]+c[1][1]+c[0][2] != sum) ok = false;
    if(c[2][0]+c[0][1]+c[1][2] != sum) ok = false;

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  int N; cin >> N;
  vector<vector<int> > woo(N);
  vector<vector<int> > len(N);
  vector<int> col(N, -1);
  
  for(int i = 0; i < N-1; i++){
    int u, v, w; cin >> u >> v >> w;
    woo[u-1].push_back(v-1);
    woo[v-1].push_back(u-1);
    len[u-1].push_back(w);
    len[v-1].push_back(w);
  }
  queue<int> que;
  que.push(0);
  col[0] = 0;
  while(!que.empty()){
    int now = que.front(); que.pop();
    for(int i = 0; i < woo[now].size(); i++){
      int e = woo[now][i];
      if(col[e] == -1) {
        if(len[now][i] & 1) col[e] = !col[now];
        else col[e] = col[now];
        que.push(e);
      }
    }
  }
  for(int i = 0; i < N; i++){
    cout << col[i] << endl;
  }
}

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


int main(void){
    int ans=0;
    for(int i=0; i < 4; i++){
        char a;
        cin >> a;
        if(a == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 1000010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 30);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

char s[10];

int main(){
    scanf("%s", s);
    int len = strlen(s);
    for(int i = 1; i < len; i++){
        if(s[i - 1] == 'A' && s[i] == 'C'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
//author Eterna
#define xiongziliang nb
#define songwenqi AK
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define eps 1e-15
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
struct point {
	point() = default;
	point(int _id, int _value) {
		id = _id, value = _value;
	}
	int id = 0, value = 0;
};
vector<point> v[4];
stack<int> s;
int r, c, n;
inline void Push_Back(int id, int x, int y) {
	if (x == 0) v[0].push_back(point(id, y));
	else if (y == c) v[1].push_back(point(id, x));
	else if (x == r) v[2].push_back(point(id, y));
	else if (y == 0) v[3].push_back(point(id, x));
}
inline bool cmp1(const point& a, const point& b) { return a.value < b.value; }
inline bool cmp2(const point& a, const point& b) { return a.value > b.value; }
inline bool check(int x, int y) { return x == 0 || x == r || y == 0 || y == c; }
int main()
{
	scanf("%d %d %d", &r, &c, &n);
	int x1, x2, y1, y2;
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		if (check(x1, y1) && check(x2, y2)) {
			Push_Back(i, x1, y1);
			Push_Back(i, x2, y2);
		}
	}
	sort(v[0].begin(), v[0].end(), cmp1);
	sort(v[1].begin(), v[1].end(), cmp1);
	sort(v[2].begin(), v[2].end(), cmp2);
	sort(v[3].begin(), v[3].end(), cmp2);
	for (int j = 0; j < 4; j++)
		for (int i = 0; i < v[j].size(); i++) {
			if (s.empty()) {
				s.push(v[j][i].id);
				continue;
			}
			if (s.top() == v[j][i].id) s.pop();
			else s.push(v[j][i].id);
		}
	if (s.empty())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 2520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < 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 INF 2e9
#define ALL(v) v.begin(), v.end()
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];
  
  sort(ALL(h));

  int MIN = INF;
  REP(i,N-K+1){
    MIN = min(MIN,h.at(i+K-1) - h.at(i));
  }

  cout << MIN << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
vector<pii> v;

rep(i,0,n-1)
{
	int x;
	cin>>x;
	v.pb({x,i+1});
}
sort(all(v));
rep(i,0,n-1)
{
	ol(v[i].ss);os;
}
return 0;
}



Measured memory_bytes: 1780
#include "bits/stdc++.h"
using namespace std;


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int aa = a.size();

    int bb = b.size();

    int cc = c.size();

    if (a.at(aa - 1) == b.at(0) && b.at(bb - 1) == c.at(0)) {
        cout << "YES" << endl;
    }

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

}



Measured memory_bytes: 256
from itertools import accumulate

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

q = [0] * (N+1)
for l, r in LR:
    # print(l, r)
    q[l-1] += 1
    q[r] -= 1

# print(q, list(accumulate(q)))

print(sum(M == m for m in list(accumulate(q))[:-1]))

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

ll calc(ll h,ll w){

  ll ans = min(w,h);
  for(int i=0;i<=h;i++){
    ll a = i*w;
    ll b=(w/2)*(h-i);
    ll c=((w+1)/2)*(h-i);
    
    ll d = max(abs(a-b),max(abs(b-c),abs(c-a)));
    ans = min(ans,d);

    b = ((h-i)/2)*w;
    c = ((h-i+1)/2)*w;
    d = max(abs(a-b),max(abs(b-c),abs(c-a)));
    ans = min(ans,d);
  }
  return ans; 
}

int main(){
  ll h,w;
  cin>>h>>w;
  cout<<min(calc(h,w),calc(w,h))<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_line(&mut self) -> String {
    self.iter.clone().collect::<Vec<String>>().join(" ")
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut scanner = Scanner::new(cin);
  scanner.new_line();
  let s = scanner.get_line();
  scanner.new_line();
  let p = scanner.get_line();
  let s = s.repeat(2);
  println!("{}", if s.contains(&p) { "Yes" } else { "No" });
}



Measured memory_bytes: 5032
# -*- coding: utf-8 -*-
from copy import deepcopy
inf = 10**5
n,m = map(int, input().split())

edge = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    edge[i][i] = 0
for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edge[a][b] = c
    edge[b][a] = c
edge_tmp = deepcopy(edge)

for k in range(n):
    for i in range(n):
        for j in range(n):
            edge[i][j] = min(edge[i][j], edge[i][k]+edge[k][j])

res = 0
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        if edge[i][j]!=edge_tmp[i][j] and edge_tmp[i][j]<inf:
            res += 1
print(res//2)


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;
	const ll z = x - y;
	cout << (-1 <= z && z <= 1 ? "Brown" : "Alice") << endl;
	return 0;
}



Measured memory_bytes: 256
// Aggressive Play

#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int N = 4e3 + 5;
const int k = 3;
int a[N][k];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = "@" + s;
    map<char, int> mp;
    mp['R'] = 0;
    mp['G'] = 1;
    mp['B'] = 2;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < k; j++){
            a[i][j] = a[i - 1][j];
        }
        a[i][mp[s[i]]]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 2; j <= n; j++){
            if(s[i] == s[j]) continue;
            vector<int> h(k, 0);
            for(int kk = 0; kk < k; kk++){
                h[kk] = a[j - 1][kk] - a[i][kk];
            }
            int diff = j - i;
            if(diff % 2 == 0){
                int mid = (i + j) / 2;
                h[mp[s[mid]]]--;
            }
            h[mp[s[i]]] = 0;
            h[mp[s[j]]] = 0;
            for(int kk = 0; kk < k; kk++)
                ans += h[kk];
        }
    }
    cout << ans;
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int q;
    cin >> q;
    while(q--){
        set<string> v;
        string s;
        cin >> s;
        v.insert(s);
        for (int i = 1; i < s.size(); ++i) {
            string t1 = s.substr(0, i), t2 = s.substr(i, s.size());
            v.emplace(t2+t1);
            reverse(t2.begin(), t2.end());
            v.emplace(t1+t2);
            v.emplace(t2+t1);
            reverse(t1.begin(), t1.end());
            v.emplace(t1+t2);
            v.emplace(t2+t1);
            reverse(t2.begin(), t2.end());
            v.emplace(t1+t2);
            v.emplace(t2+t1);
        }
        cout << v.size() << "\n";
    }
    return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>
int main()
{
	int rows, cols, i, j;
	while (1){
		scanf("%d %d", &rows, &cols);
		if (rows == 0 && cols == 0)
		{
			break;
		}
		for (i = 1; i <= rows; i++)
		{
			for (j = 1; j <= cols; j++)
			{
				if ((i + j) % 2 == 0)
				{
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}




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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
}

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

constexpr int mdn=1000000007;
struct mint{
    int v;
    inline operator int()const{return v;}
    inline mint(int v=0):v(v){}
    inline bool operator==(const mint&a)const{return v==a.v;}
    inline bool operator!=(const mint&a)const{return v!=a.v;}
    inline mint operator~ ()const{int r=1,b=v;for(int i=1;i<=(mdn-2);i<<=1){if((mdn-2)&i)r=static_cast<long long>(r)*static_cast<long long>(b)%mdn;b=static_cast<long long>(b)*static_cast<long long>(b)%mdn;}return mint(r);}
    inline mint operator- ()const{return mint(v==0?0:mdn-v);}
    inline mint operator+ (const mint&a)const{mint c(v+a.v);if(c.v>=mdn)c.v-=mdn;return c;}
    inline mint operator- (const mint&a)const{mint c(v-a.v);if(c.v<0)c.v+=mdn;return c;}
    inline mint operator* (const mint&a)const{long long c=static_cast<long long>(v)*static_cast<long long>(a.v);return mint(c%mdn);}
    inline mint operator/ (const mint&a)const{return (*this)*~a;}
    inline mint&operator++(){v++;if(v==mdn)v=0;return*this;}
    inline mint&operator--(){v--;if(v==-1)v=mdn-1;return*this;}
    inline mint&operator+=(const mint&a){v+=a.v;if(v>=mdn)v-=mdn;return*this;}
    inline mint&operator-=(const mint&a){v-=a.v;if(v<0)v+=mdn;return*this;}
    inline mint&operator*=(const mint&a){long long c=static_cast<long long>(v)*static_cast<long long>(a.v);v=c%mdn;return*this;}
    inline mint&operator/=(const mint&a){long long c=static_cast<long long>(v)*static_cast<long long>((~a).v);v=c%mdn;return*this;}
    friend istream&operator>>(istream&s,mint&a){s>>a.v;return s;}
    friend ostream&operator<<(ostream&s,const mint&a){s<<a.v;return s;}
};

const int maxn=1005;
const int maxk=22;

int n,k;
int a[maxn];
mint dp[maxk][maxn];
mint binom[maxn][maxn];

int main(){
    cin>>n>>k;
    for(int i=0;i<=n;i++){
        binom[i][0]=1;
        for(int j=1;j<=i;j++)binom[i][j]=binom[i-1][j-1]+binom[i-1][j];
    }
    for(int i=1;i<=k;i++)cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=k;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=min(j,a[i]);k++){
                mint w=binom[n-j+k][k]*dp[i-1][j-k]*binom[n-k][a[i]-k];
                dp[i][j]+=w;
            }
        }
    }
    cout<<dp[k][n];
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] l= new int[2*n];
		for(int i=0;i<2*n;i++) l[i] = sc.nextInt();
		Arrays.sort(l);
		int ans=0;
		for(int i=0;i<n;i++) {
			ans+=l[2*i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string s;
  map<char,int> mp;
  ll res=0,num[6],N;
  REP(i,6)num[i] = 0;
  cin >> N;
  REP(i,N){
    cin >> s;
    mp[s[0]]++;
  }
  num[0] = mp['M'];
  num[1] = mp['A'];
  num[2] = mp['R'];
  num[3] = mp['C'];
  num[4] = mp['H'];
  REP(i,5)
    for(int j=i+1;j<5;j++)
      for(int k=j+1;k<5;k++){
        res += num[i]*num[j]*num[k];
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
S = input()
ans = True
N = len(S)
twice = (N - 1) // 2
triple = (N + 3) // 2
cnt=0
for i in range(N):
    if S[i] != S[-(i+1)]:
       ans = False
for j in range(twice):
    if S[j] != S[twice - j-1]:
        ans = False
for k in range(triple,N - triple + 1):
    if S[k] != S[N - cnt]:
        ans = False
    cnt += 1
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int a,b,k;
int main()
{
  cin>>a>>b>>k;
  if(b-a+1<=2*k)
  {
    for(int i=a;i<=b;i++)
      cout<<i<<endl;
    return 0;
  }
  for (int i = a; i < k+a;i++)
  {
    cout << i << endl;
  }
  for (int i = b - k+1;i<=b;i++)
  {
    cout << i << endl;
  }
}

Measured memory_bytes: 256
s = [list(map(int,input().split())) for i in range(3)]
num = s[0][0]
ans = "No"

for i in range(num+1):
  a_1 = num - i
  b_1 = i
  
  a_2 = s[1][0] - b_1
  a_3 = s[2][0] - b_1
  b_2 = s[0][1] - a_1
  b_3 = s[0][2] - a_1
  
  if s[1][1] != a_2+b_2:
    continue
  if s[1][2] != a_2+b_3:
    continue
  if s[2][1] != a_3+b_2:
    continue
  if s[2][2] != a_3+b_3:
    continue
    
  ans = "Yes"
  
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
ll n;
ll arr[405],cnt[405];
ll dp[405][405];
ll func(ll i,ll j)
{
    if(j-i==0)
    {
        dp[i][j]=0;
        return 0;
    }
    else if(dp[i][j]!=-1)
        return dp[i][j];
    ll mn=1e18,mn2=1e18;
    for(ll h=i;h<j;h++)
    {
        ll y=cnt[h]-cnt[i-1]+cnt[j]-cnt[h];
        ll z=func(i,h);
        z+=func(h+1,j);
        mn=min(mn,z+y);
    }
    
    return dp[i][j]=mn;
}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            cin>>arr[i];
            cnt[i]=cnt[i-1]+arr[i];
        }
        memset(dp,-1,sizeof(dp));
        cout<<func(1,n);
    }
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string line;
    getline(cin,line);

    for(int i=0;i<(int)line.length();i++){
        char b;
        if(line[i]>=97&&line[i]<=122){
            b=line[i]-32;
            cout << b;
        }
        else if(line[i]>=65&&line[i]<=90){
            b=line[i]+32;
            cout << b;
        }
        else {
            b=line[i];
            cout << b;
        }
    }
    cout << endl;
    return 0;
}



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

int main(){
    int n,h;
    cin>>n>>h;
    int maxa=0;
    vector<int> bn(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>maxa)maxa=a;
        bn[i]=b;
    }
    sort(bn.begin(),bn.end());
    int cnt=0;
    for(int i=n-1;bn[i]>maxa;i--){
        h-=bn[i];
        cnt++;
        if(h<=0){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cnt+=h/maxa;
    if(h%maxa!=0)cnt++;
    cout<<cnt<<endl;
    return 0;

}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007LL

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> v(60,0);
    
    ll res = 0;
    REP(i, N){
        ll tmp; cin >> tmp;
        int idx = 0;
        while(tmp > 0) {
            if(tmp % 2) v[idx]++;
            tmp /= 2; idx++; 
        }
    }
    for(ll i = 0; i < 60 ; i++) {
        res += ((((v[i]%MOD) * ((N - v[i])%MOD))%MOD) * ((1LL << i) % MOD))%MOD;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define fi first
#define se second
#define pb push_back
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
bool ck[2165], ex;
int n, x, ans;
map<ii, int> mp;
vector<ii> primes;
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 2; i <= 2160; i++){
		if(!ck[i]){
			primes.pb({i, i * i * i});
			for(int j = i * i; j <= 2160; j += i) ck[j] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		cin >> x;
		int rem = 1, tmp1 = x, tmp2 = x;
		for(int j = 0; j < primes.size(); j++){
			if(!(tmp1 % primes[j].fi)){
				while(!(tmp1 % primes[j].se)) tmp1 /= primes[j].se;
				if(!(tmp1 % (primes[j].fi * primes[j].fi))) rem *= primes[j].fi;
				else if(!(tmp1 % primes[j].fi)) rem *= (primes[j].fi * primes[j].fi);
				if(rem > 1e10) rem = 1e10 + 1;
				while(!(tmp2 % primes[j].fi)) tmp2 /= primes[j].fi;
			}
		}
		if(tmp1 == 1){
			ex = 1;
			continue;
		}
		int tmpp = sqrt(tmp2);
		if(tmpp * tmpp == tmp2){
			rem *= tmpp;
			if(rem > 1e10){
				ans++;
				continue;
			}
			mp[{tmp1, rem}]++;
			if(mp.find({rem, tmp1}) == mp.end()) mp[{rem, tmp1}] = 0;
			continue;
		}
		if(tmp2 > 1e5){
			ans++;
			continue;
		}
		rem *= tmp2;
		if(rem > 1e10){
			ans++;
			continue;
		}
		rem *= tmp2;
		if(rem > 1e10){
			ans++;
			continue;
		}
		mp[{tmp1, rem}]++;
		if(mp.find({rem, tmp1}) == mp.end()) mp[{rem, tmp1}] = 0;
	}
	int ans2 = 0;
	for(map<ii, int>::iterator it = mp.begin(); it != mp.end(); it++){
		//out << it->fi.fi << " " << it->fi.se << " " << it->se << "\n";
		ans2 += max(it->se, mp[{it->fi.se, it->fi.fi}]);
	}
	//cout << ans << "\n";
	ans += (ans2 / 2);
	ans += ex;
	cout << ans;
}

Measured memory_bytes: 13812
#include <stdio.h>
int main(void){
    int m, f, r;
    char grad;
    
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m==-1 && f==-1 && r==-1) break;
        
        if(m==-1 || f==-1){
            grad='F';
        }
        else if(m+f>=80){
            grad='A';
        }
        else if(m+f>=65 && m+f<80){
            grad='B';
        }
        else if(m+f>=50 && m+f<65){
            grad='C';
        }
        else if(m+f>=30 && m+f<50){
            if(r>=50) grad='C';
            else grad='D';
        }
        else grad='F';
        
        printf("%c\n", grad);
    }
}


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

int x[1000000];
int y[1000000];

int main() {
  int t;
  int all_length;
  int n;
  int k;
  cin >> t;
  for (int j=0; j<t; ++j) {
    cin >> n >> k;
    for (int i=0; i<n; ++i) {
      cin >> x[i];
    }
    if (n<=k) {
      all_length = 0;
    }
    else {
      all_length = x[n-1] - x[0];
      for (int i=0; i<n-1; ++i) {
	y[i] = x[i+1] - x[i];
      }
      sort(y, y+n-1);
      for (int i=0; i<k-1; ++i) {
	all_length = all_length - y[n-2-i];
      }
    }
    cout << all_length;
    cout << endl;
  }
}


Measured memory_bytes: 3844
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int x1, y1;
	int x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3 = x2 - (y2 - y1), y3 = y2 + (x2 - x1);
	int x4 = x3 - (y3 - y2), y4 = y3 + (x3 - x2);
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x;
    cin >> x;
    cout << ((x >= 30) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env ruby

def check(str)
  loop do
    return true if str == ''

    if str.end_with? 'dreamer'
      str = str[0...-7]
    elsif str.end_with? 'dream'
      str = str[0...-5]
    elsif str.end_with? 'eraser'
      str = str[0...-6]
    elsif str.end_with? 'erase'
      str = str[0...-5]
    else
      return false
    end
  end
end

if $0 == __FILE__
  S = gets.chomp
  puts check(S) ? 'YES' : 'NO'
end


Measured memory_bytes: 61712
S = list(input())

C = 0
ans = 0


for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    C += 1
    ans = max(C,ans)
  else:
    C = 0

print(ans)


Measured memory_bytes: 2940
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] x=new int[n];
for (int i = 0; i < n; i++) {x[i]=sc.nextInt();}
int ans=x[n-1]-x[0]+abs(x[0])+abs(x[n-1]);
int temp;
    for (int i = 0; i <= n-k; i++) {
        ans=min( ans , min( x[i+k-1]-x[i]+abs(x[i]) , x[i+k-1]-x[i]+abs(x[i+k-1]) ) );
    }
out.println(ans);
}}

Measured memory_bytes: 51024
n = int(input())
a = [int(input()) for _ in range(n)]

ans, tmp, flag = 0, 0, (a[0] > 0)
for i in range(n - 1, 0, -1):
    if a[i] - a[i - 1] > 1:
        flag = True
    elif tmp != a[i]:
        ans += a[i]
    tmp = max(a[i] - 1, 0)
print(-1 if flag else ans)


Measured memory_bytes: 88072
n,k=map(int,input().split())
s=input()

t=[]
for i in range(1,n):
	if s[i]!=s[i-1]:
		t.append(i)
x=[]
for y in s:
	if y=="L":
		x.append(0)
	else:
		x.append(1)

if len(t)<=2*k:
	print(n-1)
	import sys
	sys.exit()

y=[0 for _ in range(n)]
for i in range(k):
	y[t[i]]+=1
	y[t[-i-1]]-=1
for i in range(1,n):
	y[i]=(y[i]+y[i-1])%2
#print(x)
#print(y)
z=[(x[i]+y[i])%2 for i in range(n)]
#print(z)

res=0
for i in range(1,n):
	if z[i]==0 and z[i-1]==0:
		res+=1
for i in range(n-1):
	if z[i]==1 and z[i+1]==1:
		res+=1
print(res)

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  string S;
  int K;
  cin >> K;
  cin >> S;

  string ans = "";
  if(S.size() <= K){
    ans = S;
  } else { 
    for(int i = 0; i < K; i++){
      ans += S[i];
    }
    ans += "...";
  }
  cout << ans << endl;

}


Measured memory_bytes: 3628
"""
kari1 = '2'
kari2 = '4 8' #8
#kari1 = '3'
#kari2 = '1 1 3' #3
#kari1 = '3'
#kari2 = '4 2 5' #5
#kari1 = '4'
#kari2 = '-100 -100 -100 -100' #0
in1 = kari1
in2 = kari2.split()
"""
in1 = input()
in2 = input().split()

AVEa = 0
RC   = 0
for item in in2:
    AVEa = AVEa + int(item)

AVEa = round(AVEa / len(in2))

for item in in2:
    if int(item) != AVEa:
        RC = RC + ((int(item) - AVEa) ** 2)

print(RC)


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

int n,a[200005],b[200005];
vector<int>v;
int main() {
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%d",&a[i]);
    for(int i=n; i>=1; i--) {
        int temp=0;
        for(int j=i; j<=n; j+=i) {
            temp^=b[j];
        }
        if(temp==1&&a[i]%2==0) {
            b[i]=1;
            v.push_back(i);
        }
        if(temp==0&&a[i]%2==1) {
            b[i]=1;
            v.push_back(i);
        }
    }
    sort(v.begin(),v.end());
    printf("%d\n",v.size());
    for(int i=0; i<v.size(); i++)printf("%d%c",v[i],i==v.size()-1?'\n':' ');
    return 0;
}


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

int main() {
    long long int n, sum=0, i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            continue;
        }
        else
        sum+=i;
    }
    cout<<sum<<endl;
	return 0;
}

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

int combination(int n, int v[], int c[], int count = 0, int XsubY = 0) {
	int a, b;
	if(count == n)
		return XsubY;
	a = combination(n, v, c, count+1, XsubY);
	XsubY = XsubY + v[count] - c[count];
	b = combination(n, v, c, count+1, XsubY);
	if(a > b)
		return a;
	else
		return b;
}

int main(){
	int n, v[50], c[50];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> v[i];
	for(int i = 0; i < n; i++)
		cin >> c[i];
	cout << combination(n, v, c) << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n, k);
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  REP(i, n - k) {
    print(a[i] < a[i + k] ? "Yes" : "No");
  }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll a,b,m,A[300001],B[300001],minim=1e18;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>m;
    for(int i=1;i<=a;i++)
        cin>>A[i];
    for(int i=1;i<=b;i++)
        cin>>B[i];
    for(int i=1;i<=m;i++)
    {
        ll x,y,c;
        cin>>x>>y>>c;
        ll suma=A[x]+B[y]-c;
        minim=min(minim,suma);
    }
    sort(A+1,A+a+1);
    sort(B+1,B+b+1);
    minim=min(minim,A[1]+B[1]);
    cout<<minim;
    return 0;
}


Measured memory_bytes: 5228
N = int(input())
L = [0] * N
s = 0
f = False
m = 10**10
for _ in range(N):
    n = int(input())
    s+=n
    if n % 10 !=0:
        m = min(m,n)
        f = True
if s %10 == 0:
    if f:
        print(s-m)
    else:
        print(0)
else:
    print(s)

Measured memory_bytes: 62268
h,w= map(int,input().split())
n= int(input())
a= list(map(int,input().split()))
st = []
for i in range(1,n+1):
    for c in range(a[i-1]):st.append(i)
ans = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):ans[i][j]= st[i*w+j]
    if i%2==1:ans[i] = ans[i][::-1]
    print(*ans[i])

Measured memory_bytes: 3952
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# word = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(readline())
S = [int(x)-ord('A') for x in read().rstrip()]
S=[(x+N)%26 for x in S]

ans = ''.join(chr(x+ord('A')) for x in S)

print(ans)


Measured memory_bytes: 3188
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Graph{
    struct Node{
        vector<int> inEdges, outEdges;
        vector<int>& edges(bool rev = false){ return rev ? inEdges : outEdges; }
    };
    struct Edge{
        int from, dest;
        ll limit, rem;
        Edge(){ }
        Edge(int from, int dest, ll limit = 1): from(from), dest(dest), limit(limit), rem(limit){ }
        int to(bool rev = false){ return rev ? from : dest; }
        ll remain(bool rev = false){ return rev ? limit - rem : rem; }
        void pour(ll qua, bool rev = false){ rem -= rev ? - qua : qua; }
    };
    vector<Node> nodes;
    vector<Edge> edges;
    Graph(int nn, int en = 10): nodes(nn){
        edges.reserve(en);
    }

    void addEdge(int from, int dest, ll limit){
        nodes[from].outEdges.emplace_back(edges.size());
        nodes[dest].inEdges.emplace_back(edges.size());
        edges.emplace_back(from, dest, limit);
    }
    ll flow(int start, int goal, vector<char>& visited, ll cur){
        if(start == goal){ return cur; }
        auto _flow = [&](bool rev = false){
            for(int eidx : nodes[start].edges(rev)){
                Edge& e = edges[eidx];
                int vidx = e.to(rev);
                if(!e.remain(rev) || visited[vidx]){ continue; }
                visited[vidx] = true;
                ll lim = min(cur, e.remain(rev));
                if((lim = flow(vidx, goal, visited, lim))){
                    e.pour(lim, rev);
                    return lim;
                }
            }
            return 0ll;
        };
        ll ret = 0;
        if((ret = _flow()) || (ret = _flow(true))){
            return ret;
        }
        return ret;
    }
    ll maxFlow(int start, int goal){
        if(start == goal){ exit(1); }
        ll ret = 0;
        while(1){
            vector<char> visited(nodes.size());
            ll f;
            if(!(f = flow(start, goal, visited, MLL))){
                break;
            }
            ret += f;
        }
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    Graph g(n + 2, 2 * n);
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        int a; cin >> a;
        if(a > 0){
            sum += a;
            g.addEdge(i, n + 1, a);
        }else{
            g.addEdge(0, i, - a);
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = i + i; j <= n; j += i){
            g.addEdge(i, j, MLL);
        }
    }
    ll mi = g.maxFlow(0, n + 1);
    cout << sum - mi << '\n';
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 7;

int dp[N][3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a;
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b;
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c;
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';
}

Measured memory_bytes: 1408
import sys
s = int(input())
if s < 3:
  print(0)
  sys.exit()
kumi = [-1 for i in range(2001)]
b = 10**9 + 7
def ckumi(a):
  if kumi[a] != -1:
    return(kumi[a])
  ok = 0
  if a >= 6:
    ok += 1
    for i in range(3,a-2):
      ok += ckumi(a-i)
    kumi[a] = ok
    return(ok)
  elif a >= 3:
    kumi[a] = 1
    return(1)
  else:
    kumi[a] = 0
    return(0)
print(ckumi(s)%b)

Measured memory_bytes: 69640