akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



def C(n, r):
    c = 1
    for i in range(1, r+1):
        c *= n
        c //= i
        n -= 1

    return c

@mt
def slv(H, W, K):
    dp = [[0] * (W+2) for _ in range(H+1)]

    
    L = [0] * (W+2)
    C = [0] * (W+2)
    R = [0] * (W+2)
    for c in product(range(2), repeat=W-1):
        for i in range(W-2):
            if c[i] * c[i+1] != 0:
                break
        else:
            for j in range(1, W+1):
                if j != 1 and c[j-2] == 1:
                    L[j] += 1
                elif j != W and c[j-1] == 1:
                    R[j] += 1
                else:
                    C[j] += 1

    dp[0][1] = 1
    mod = 10**9 + 7
    for h in range(0, H):
        for w in range(1, W+1):
            dp[h+1][w-1] += dp[h][w] * L[w]
            dp[h+1][w-1] %= mod
            dp[h+1][w] += dp[h][w] * C[w]
            dp[h+1][w] %= mod
            dp[h+1][w+1] += dp[h][w] * R[w]
            dp[h+1][w+1] %= mod


    return dp[H][K]


def main():
    H, W, K = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(H, W, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6208
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  char g[52][53];
  fill(g[0],g[52],'#');
  int y,x,d;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      cin>>g[i][j];
      if(g[i][j]=='^'){
	d=0;
	y=i;
	x=j;
      }else if(g[i][j]=='>'){
	d=1;
	y=i;
	x=j;
      }else if(g[i][j]=='v'){
	d=2;
	y=i;
	x=j;
      }else if(g[i][j]=='<'){
	d=3;
	y=i;
	x=j;
      }
    }
  }
  bool u[52][52][4]={};
  for(;;){
    if(u[y][x][d]++)break;
    if(g[y][x]=='G')break;
    const static int dy[]={-1,0,1,0};
    const static int dx[]={0,1,0,-1};
    const static int rdy[]={-1,1,1,-1};
    const static int rdx[]={1,1,-1,-1};
    int ny=y+dy[d];
    int nx=x+dx[d];
    int ry=y+rdy[d];
    int rx=x+rdx[d];
    if(g[ny][nx]=='#'){
      d=(d+3)%4;
    }else if(g[ry][rx]=='#'){
      y=ny;
      x=nx;
    }else{
      u[ny][nx][d]=true;
      y=ny;
      x=nx;
      if(g[ny][nx]=='G')break;
      y=ry;
      x=rx;
      d=(d+1)%4;
    }
  }
  int ans=0;
  if(g[y][x]=='G'){
    for(int i=1;i<=N;i++){
      for(int j=1;j<=M;j++){
	ans+=find(u[i][j],u[i][j+1],true)!=u[i][j+1];
      }
    }
  }else{
    ans=-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  unordered_map<int, ll> freq;
  for (int i = 0 ; i < N; i++) {
    cin >> A[i];
    freq[A[i]]++;
  }
  ll total_pairs = 0;
  for (auto iter : freq) {
    ll f = iter.second;
    total_pairs += f * (f - 1) / 2;
  }
  for (int i = 0 ; i < N; i++) {
    ll f = freq[A[i]];
    ll dec = f * (f - 1) / 2 - (f - 1) * (f - 2) / 2;
    cout << total_pairs - dec << endl;
  }
  return 0;
}

Measured memory_bytes: 8392
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define PI (3.141592653589793)

int main()
{
    double ang_to_rad = PI / 180;
    double now_angle = 90;
    double x = 0, y = 0;
    double distance = 0, angle = 0;
    int final_x, final_y;

    while (1)
    {
        scanf("%lf,%lf", &distance, &angle);

        if (distance == 0 && angle == 0)
            break;
        if (distance < 0 || distance > 100 || angle < -180 || angle > 180)
            continue;

        x += distance * cos(now_angle * ang_to_rad);
        y += distance * sin(now_angle * ang_to_rad);
        now_angle -= angle;
    }

    final_x = x;
    final_y = y;
    printf("%d\n%d\n", final_x, final_y);

    return 0;
} 

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

int main()
{
      int n,m,k;
      cin>>n>>m>>k;
      int a[n];
      int b[m];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
      for(int i=0;i<m;i++)
      {
          cin>>b[i];
      }
      int i=0;
      int j=0;
      long long sum=0;
      int ans=0;
      //ans=-1;
      while(j<m &&sum+b[j]<=k){
        sum+=b[j];
        j++;
      }
      ans=j;
    j--;
      //  cout<<ans<<endl;
      for(int i=0;i<n;i++)
      {
          sum+=a[i];
          while(sum>k && j>=0){
            sum-=b[j];
            j--;
          }
          if(sum>k)break;

          ans=max(ans,j+i+2);
      }
      cout<<ans<<endl;
}



Measured memory_bytes: 5152
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        int h[] = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = nextInt(r);
        }

        int dp[] = new int[N];
        dp[1] = Math.abs(h[1]-h[0]);
        for (int i = 2; i < N; i++) {
            int abs2 = Math.abs(h[i]-h[i-2]);
            int abs1 = Math.abs(h[i]-h[i-1]);
            dp[i] = dp[i-2]+abs2 < dp[i-1]+abs1 ? dp[i-2]+abs2 : dp[i-1]+abs1;
        }
        System.out.println(dp[N-1]);
    }

    public static String nextString(InputStreamReader r) throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        return Integer.parseInt(nextString(r));
    }

    public static long nextLong(InputStreamReader r) throws Exception {
        return Long.parseLong(nextString(r));
    }
}


Measured memory_bytes: 44324
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto A = readln.chomp.to!int;
    auto B = readln.chomp.to!int;
    auto C = readln.chomp.to!int;
    auto X = readln.chomp.to!int;

    int result;
    foreach (a; 0..A+1) {
        foreach (b; 0..B+1) {
            auto rest = X - 500*a - 100*b;
            if (rest >= 0 && rest % 50 == 0 && rest / 50 <= C) ++result;
        }
    }
    writeln(result);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, m, x, y; cin >> n >> m >> x >> y;
	int ma = x, mi = y;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		
		ma = std::max(ma, a);
	}
	for(int i = 0; i < m; i++) {
		int a; cin >> a;
		
		mi = std::min(mi, a);
	}
	
	if(ma < mi) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}


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

int main(){

    string S;
    cin >> S;

    if(S=="SUN"){
        cout << "7" << endl;
    } else if(S=="MON"){
        cout << "6" << endl;
    } else if(S=="TUE"){
        cout << "5" << endl;
    } else if(S=="WED"){
        cout << "4" << endl;
    } else if(S=="THU"){
        cout << "3" << endl;
    } else if(S=="FRI"){
        cout << "2" << endl;
    } else if(S=="SAT"){
        cout << "1" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	cout << 180*(n-2) << endl;
	return 0;
}



Measured memory_bytes: 256
X=int(input())

if X<100:
    print(0)
    exit()

if 100<=X<=105:
    print(1)
    exit()

DP=[False]*(X+1)

for i in range(100,106):
    DP[i]=True

for i in range(106,X+1):
    if DP[i-100] or DP[i-101] or DP[i-102] or DP[i-103] or DP[i-104] or DP[i-105]:
        DP[i]=True

if DP[X]==True:
    print(1)
elif DP[X]==False:
    print(0)


Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main()
{
    int R,C;
    int r,c;
    cin >> R >> C;
    cin >> r >> c;
    
    int ans=R*C;
    ans-=C*r;
    ans-=(R-r)*c;
    
   
    
   cout << ans << endl; 
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < S.size(); i++){
        char a = S[i];
        int b = a - '0';
        count = (count + b) % 9;
    }
    if(count == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

#define fastio 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

#define int long long

const int N = 2000 + 5;
int cc[N][N], n;
pair<int, int> a[N];

int dp(int idx, int l, int r){
  if(idx == n)
    return 0;
  if(l > r)
    return -INF;
  int &ans = cc[idx][l];
  if(~ans)
    return ans;
  ans = 0;
  ans = max(ans, abs(l - a[idx].second) * a[idx].first + dp(idx + 1, l + 1, r));
  ans = max(ans, abs(r - a[idx].second) * a[idx].first + dp(idx + 1, l, r - 1));
  return ans;
}

void solve(){
  memset(cc, -1, sizeof cc);
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i].first; a[i].second = i;
  }

  using pii = pair<int, int>;

  sort(a, a + n, [&](pii x, pii y){
    if(x.first != y.first)
      return x.first > y.first;
    return x.second < y.second;
  });

  cout << dp(0, 0, n - 1) << '\n';
}

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

  pre();

  int t = 1, T;
  // cin >> t;
  T = t;
  while(t--){
    // cout << "Case #" << T - t << ": ";
    solve();
  }

  ktj();
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    //cin >> n;
    scanf("%d", &n);
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        //cin >> a[i];
        scanf("%d", &a[i]);
        sum += a[i];
    }
    /*sort(a.begin(), a.end());
    a.push_back(INF);*/
    int target = sum / 2;
    bitset<2000050> dp;
    dp.set(0);
    for(int i = 0; i < n; i++){
        dp = dp | (dp << a[i]);
    }
    for(int i = target; i >= 0; i--){
        if(dp[i]){
            cout << sum - i << endl;
            return 0;
        }
    }
    /*int dp[2001000];
    for(int i = 1; i <= target; i++){
        dp[i] = n;
    }
    dp[0] = -1;
    for(int value = 0; value < target; value++){
        if(dp[value] >= n - 1) continue;
        //cout << value << endl;
        for(int index = dp[value] + 1; value + a[index] <= target; index++){
            //if(value + a[index] > target) break;
            //cout << value << " " << index << endl;
            dp[value + a[index]] = min(dp[value + a[index]], index);
        }
    }
    for(int i = target; i >= 0; i--){
        if(dp[i] < n){
            //cout << sum - i << endl;
            printf("%d\n", sum - i);
            return 0;
        }
    }*/
    return 0;
}



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

const ll mod = 1e9 + 7;
int n, D;
vector<int> num;
vector<vector<vector<ll>>> dp;

ll recursion(int pos, int sum, bool flag) {
	if (pos == n) {
		if (sum % D) {
			return 0;
		}
		return 1;
	}
	if (dp[pos][sum][flag] != -1) {
		return dp[pos][sum][flag];
	}
	ll res = 0;
	int limit = 9;
	if (flag) {
		limit = num[pos];
	}
	for (int i = 0; i <= limit; i++) {
		if (i == num[pos]) {
			res = (res + recursion(pos + 1, (sum + i) % D, flag)) % mod;
		} else {
			res = (res + recursion(pos + 1, (sum + i) % D, 0)) % mod;
		}
	}
	return dp[pos][sum][flag] = res;
}

int main() {
	ios_base::sync_with_stdio(false);

	string K;
	cin >> K >> D;
	n = K.length();
	for (auto it : K) {
		num.push_back(it - '0');
	}
	dp.resize(n);
	for (int i = 0; i < n; i++) {
		dp[i].resize(D, vector<ll> (2, -1));
	}
	ll ans = recursion(0, 0, 1);
	ans--;
	if (ans == -1) {
		ans = mod - 1;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 59412
#include<bits/stdc++.h>
using namespace std;
int n,ans;
double t,h[1010],b,a,lmin=100100;
int main()
{
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		b=abs(a-(t-h[i]*0.006));
		if(b<lmin){lmin=b;ans=i;}
	}
	cout<<ans;
	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 ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#include <queue>
typedef long long LL;
const int maxn = 0x7fffffff;
using namespace std;
LL m, l, n;
int main() {
    scanf("%lld", &m);
    vector<vector<int>> ji(m, vector<int>(26, 0));
    vector<int> res(26, maxn);
    for(int i = 0; i < m; i++) {
        char str[52];
        scanf("%s", str);
        string tmp(str);
        for(auto p: tmp) {
            ji[i][p - 'a'] ++;
        }
    }
    for(auto& v: ji) {
        for(int j = 0; j < 26; j++) {
            res[j] = min(res[j], v[j]);
        }
    }
    string ret;
    for(int j = 0; j < 26; j++) {
        for(int i = 0; i < res[j]; i++)
            ret+= ('a' + j);
    }
    printf("%s\n", ret.c_str());
    return 0;
}


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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;


class Match {
   public:
   vector<int> fNarabi;
   Match(){;}
   void Add(int a) {fNarabi.push_back(a);}
   void Dump(void){
      for (int i = fNarabi.size()-1;i>=0;i--) {
         cout<<fNarabi[i];
      }
      cout<<endl;
   }
   bool operator<(const Match& c1)const
   {
      if (fNarabi.size() == c1.fNarabi.size()) {
         for (int i = fNarabi.size()-1;i>=0;i--) {
            if (fNarabi[i]!=c1.fNarabi[i]) return (fNarabi[i]<c1.fNarabi[i]);
         }
         return false;
      } else return (fNarabi.size() < c1.fNarabi.size());
   }
};

const int MAXN = 10010;
Match dp[MAXN];
set<int> A;
int Nneed[9] = {2,5,5,4,5,6,3,7,6};

void Update(int i) {
   Match ne = Match();
   Match ne_cd;
   rep(j,1,10) {
      if (i-Nneed[j-1]==1) continue;
      if (A.count(j) && i-Nneed[j-1]>=0) {
         ne_cd = dp[i-Nneed[j-1]];
         if (ne_cd.fNarabi.size()==0) continue;
         ne_cd.Add(j);
         chmax(ne,ne_cd);
      }
   }
   chmax(dp[i],ne);
   return;
}

int main(void) {
   int N,M;
   cin>>N>>M;
   int a;
   rep(j,0,M) {
      cin>>a;
      A.insert(a);
   }
   dp[0] = Match();
   for (auto el: A) {
      Match ne;
      ne.Add(el);
      chmax(dp[Nneed[el-1]],ne);
   }
   rep(i,2,N+1) {
      Update(i);
      // cout<<i<<" ";
      // dp[i].Dump();
   }
   dp[N].Dump();



   return 0;
}

Measured memory_bytes: 107136
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep (i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        String[] Sarr = new String[S.length()];
        for (int i = 0; i < S.length(); i++) {
            Sarr[i] = S.substring(i) + S.substring(0,i);
        }

        boolean result = false;
        for (int i = 0; i < S.length(); i++) {
            if(Sarr[i].equals(T)){
                result = true;
                break;
            }
        }
        System.out.println(result ? "Yes":"No");

    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  int n,i;
  cin >> n;
  vector<P> x(n);
  for(i=0;i<n;i++){
    cin >> x[i].first >> x[i].second;
  }
  ll ma=0;
  for(i=0;i<n;i++){
    ma=max(ma,x[i].second);
  }
  ll sum=0;
  for(i=0;i<n;i++){
    sum+=ma-x[i].second;
  }
  for(i=0;i<n;i++){
    x[i].first+=sum-(ma-x[i].second);
  }
  sort(x.begin(),x.end(),greater<P>());
  ll ans1=0,ans2=0;
  for(i=0;i<n;i=i+2){
    ans1+=x[i].first-sum+(ma-x[i].second);
  }
  for(i=1;i<n;i=i+2){
    ans2+=x[i].second;
  }
  cout << ans1-ans2 << endl;
}

Measured memory_bytes: 4844
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [2, 1]

for i in range(2, N+1):
	L.append(L[i-1]+L[i-2])

print(L[N])

Measured memory_bytes: 5196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
vector<int> a;

int main()
{
	int ans = 0;

	cin >> n;
	for (int i = 0;i < n;i++) {
		int t;
		cin >> t;
		a.push_back(t-1);
	}

	int flag;
	while (1) {
		flag = 0;

		for (int i = 0;i < n;i++) {
			if (a[i] == i) {
				flag = 1;
				ans++;

				if (i - 1 >= 0 && a[i - 1] == i - 1) {
					a[i] = i - 1;
					a[i - 1] = i;
					continue;
				}

				if (i + 1 < n && a[i + 1] == i + 1) {
					a[i] = i + 1;
					a[i + 1] = i;
					continue;
				}

				if (i - 1 >= 0) {
					a[i] = a[i - 1];
					a[i - 1] = i;
					continue;
				}

				if (i + 1 < n) {
					a[i] = a[i + 1];
					a[i + 1] = i;
					continue;
				}

			}
		}

		if (flag == 0) {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 2e5;
ll a[MAX_N + 5], T;
int n;
int main()
{
    scanf("%d%lld", &n, &T);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    ll ans = a[n] + T;
    for (int i = 1; i <= n - 1; i++) {
        ans -= max(0LL, a[i + 1] - a[i] - T);
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

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

    char c;
    cin >> c;
    cout << (isupper(c) ? "A" : "a");
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0};
const char rd[4]={'u','d','l','r'};
struct gg{
	int mp[9];
	int space;
	string path;
	bool operator<(const gg &tmp)const
	{
		for(int i=0;i<=8;i++)
		   {
		   	if(mp[i]!=tmp.mp[i])return mp[i]>tmp.mp[i];
		   }
		return false;   
	}
};
bool ifok(gg a)
{
	for(int i=0;i<8;i++)
	  if(a.mp[i]!=i+1)return false;
	return true;  
}
gg bfs(gg bg)
{
	queue<gg> q;gg now,tmp;int x,y;
	map<gg,bool>vis;
	vis[bg]=1;
	q.push(bg);
	while(!q.empty())
	{   
		now=q.front();q.pop();
		if(ifok(now))return now;
		x=now.space%3;y=now.space/3;
		for(int i=0;i<=3;i++)
		   {
		     tmp=now;
		     if(x+dx[i]<0||x+dx[i]>2||y+dy[i]<0||y+dy[i]>2)continue;
		     tmp.space=x+dx[i]+(y+dy[i])*3;
		     swap(tmp.mp[x+y*3],tmp.mp[x+dx[i]+(y+dy[i])*3]);
		     tmp.path+=rd[i];
		     if(vis[tmp])continue;
		     vis[tmp]=1;q.push(tmp);
		   }
	}	
}
int main()
{
	gg bg,ans;
	for(int i=0;i<=8;i++)
	   {
	   	scanf("%d",&bg.mp[i]);
	   	if(bg.mp[i]==0)bg.space=i;
	   }   
	bg.path="";
	ans=bfs(bg);
	cout<<ans.path.length()<<endl;
}

Measured memory_bytes: 33832
import numpy as np

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for _ in range(N)])

cnt = 0
for i in range(1, N):
    A = np.sqrt(np.sum(np.square(X[i:] - X[i - 1]), axis=1))
    cnt += np.count_nonzero(A % 1 == 0)

print(cnt)


Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,N,M,sum,ans=LLONG_MAX;
  cin>>N>>M;
  vec a(N,0),b(N,LLONG_MAX);
  rep(i,N){
    cin>>a[i];
  }
  rep(i,N){
    rep(j,N){
      b[j]=min(b[j],a[(j-i+N)%N]);
    }
    sum=0;
    rep(j,N){
      sum+=b[j];
    }
    ans=min(ans,sum+i*M);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

import itertools
h = itertools.combinations_with_replacement(list(range(1,N+1)), 3)

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for n1, n2, n3 in h:
  #print("{} {} {}".format(n1,n2,n3))
  if n1 == n2 == n3:
    ans += gcd(n1,n2,n3)
  elif n1 == n2 or n1 == n3 or n2 == n3:
    ans += gcd(n1,n2,n3)*3
  else:
    ans += gcd(n1,n2,n3)*6
print(ans)


Measured memory_bytes: 9644
A = list(map(int, input().split()))
A.sort()
a = A[0]
b = A[1]
c = b-a

if a <= 0 <= b:
    print("Zero")

elif a > 0:
    print("Positive")

elif b < 0:
    if c%2 == 1:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool ok = true;
    if (n % 2 == 0) {
        for (int i = 1; i < n; i += 2) {
            if (cnt[i] != 2) {
                ok = false;
                break;
            }
        }
    } else {
        if (cnt[0] != 1)
            ok = false;
        for (int i = 2; i < n; i += 2) {
            if (cnt[i] != 2) {
                ok = false;
                break;
            }
        }
    }
    if (ok) {
        cout << mint(2).pow(n / 2) << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define X first
#define Y second
#define for0 for(int i=0;i<n;i++)
int main(){
    string s,t;
  cin>>s>>t;
  if(s.size()==t.size()-1)
  {int f=1;
    for(int i=0;i<s.size();i++)
    {
      if(s[i]!=t[i])
      {f=0;break;}}
   if(f==1)
     cout<<"Yes";
   else cout<<"No";}
  else cout<<"No";
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int a, b, c;
    cin >> a >> b >> c;

    bool flag = false;
    for(int i = a; i <= a * b; i += a){
        if(i % b == c) flag = true;
    }

    outYES(flag);
}

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

int main()
{
  vector<int> match {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  int n, m;
  cin >> n >> m;
  vector<int> num(m);
  for (auto&& e : num) cin >> e;
  sort(begin(num), end(num), greater<>());
  vector<int> dp(n + 1);
  vector<string> dps(n + 1);

  for (int i = 1; i <= n; i++) {
    for (auto&& e : num) {
      int x = i - match[e];
      if (x < 0) continue;
      if (dps[x].length() == 0 && x != 0) continue;
      string s = dps[i];
      string t = dps[x] + to_string(e);
      if ((s.length() == t.length() && s < t) || s.length() < t.length()) {
        dp[i] = dp[x] + 1;
        dps[i] = dps[x] + to_string(e);
      }
    }
  }
  cout << dps[n] << endl;
}


Measured memory_bytes: 33024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

int main() {
	dd A, B, N;
	cin >> A >> B >> N;

	cout << floor(A * min(B - 1.0, N) / B) << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
const long mod = 1000000007;

long n, m;
long f[500001];

long mpow(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return b * mpow(b, e - 1) % mod;
  long t = mpow(b, e / 2);
  return t * t % mod;
}

long inv(long n) {
  return mpow(n, mod - 2);
}

long comb(long n, long k) {
  return f[n] * inv(f[n - k] * f[k] % mod) % mod;
}

long perm(long n, long k) {
  return comb(n, k) * f[k] % mod;
}

long sub(long k) {
  long t = perm(m - k, n - k);
  return comb(n, k) * perm(m, k) % mod * t % mod * t % mod;
}

int main() {
  cin >> n >> m;
  f[0] = 1;
  for (int i = 1; i <= m; ++i) {
    f[i] = i * f[i - 1] % mod; 
  }
  
  long sum = 0;
  for (int k = 0; k <= n; ++k) {
    long res = sub(k);
    long cof = k % 2 == 0 ? 1 : mod - 1;
    sum = (sum + cof * res) % mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 7408
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
	int x, y, z, c;
	char a[10];
	char b[2];
	strcpy(b, "Y");
	z = 0;
	scanf("%d", &x);
	for (y = 0; y < x + 1; y++) {
		scanf("%s", a);
		c = strcmp(a, b);
		if (c == 0) {
			z = 1;
		}
	}
	if (z == 1) {
		printf("Four\n");
	}
	else {
		printf("Three\n");
	}

	return 0;
}

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

int main()
{
    int s, w;
    cin >> s >> w;
    if(s > w){
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import math

A, B, H, M = map(int, input().split())

Hw = H / 12 * 360 + M * 0.5
Mw = M / 60 * 360


A1, A2 = A * math.cos(math.radians(Hw)), A * math.sin(math.radians(Hw))
B1, B2 = B * math.cos(math.radians(Mw)), B * math.sin(math.radians(Mw))

print(math.sqrt((A1 - B1) ** 2 + (A2 - B2) ** 2))


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

int main(){
  using namespace std;
  unsigned long a, b, x;
  cin >> a >> b >> x;
  if(a * a * b > 2 * x){
    cout << setprecision(15) << atan2(b * b * a, 2 * x) * 4068 / 71 << endl;
  }else{
    cout << setprecision(15) << atan2(2 * (a * a * b - x), a * a * a) * 4068 / 71 << endl;
  }
  return 0;
}

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

X = sum(a)
x =[a[0]]
for i in range(n-1):
	x.append(x[i]+a[i+1])
ans = min(list(abs(X-2*x[i]) for i in range(n-1)))

print(ans)

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

signed main() {
  string s, t;
  cin >> s >> t;

  string ans = "{}";
  for (int i = 0; i <= (int)s.size() - (int)t.size(); ++i) {
    string po = s;
    bool f = true;
    for (int j = 0; j < t.size(); ++j) {
      if (po[i + j] != '?' && po[i + j] != t[j]) {
        f = false;
      }
      po[i + j] = t[j];
    }
    if (f) {
      for (int j = 0; j < s.size(); ++j) {
        if (po[j] == '?') po[j] = 'a';
      }
      ans = min(ans, po);
    }
  }

  if (ans == "{}") {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int d;
    cin>>d;
    if (d==22) cout<<"Christmas Eve Eve Eve";
    else if(d==23) cout<<"Christmas Eve Eve";
    else if(d==24) cout<<"Christmas Eve";
    else if(d==25) cout<<"Christmas";
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
 
int compare(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}
 
 
int main(){
	
	int N,C,K,T[100010],i,ans=0,j=0,count;
	
	scanf("%d",&N);
	scanf("%d",&C);
	scanf("%d",&K);
	
	for(i=0;i<N;i++){
		scanf("%d",&T[i]);
	}
	
	qsort(T,N,sizeof(int),compare);
	
	while(j<N){
		count=0;
		
		for(i=j;i<j+C&&i<N;i++){
		if(T[i]<=T[j]+K){
			count++;
			
			}
		}
		ans++;
		
		j+=count;
	}
	
	printf("\n%d\n\n",ans);
	
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main(void){
  int n,a[100],min,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
    min=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[min]){
	min=j;
      }
    }
    if(i!=min)
      ans++;
    swap(a[i],a[min]);
  }
  for(int i=0;i<n-1;i++)
    cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main()
{
  int n,v,j,i,s;
  int A[1001];
  cin >> n;
  for(i=0; i<n;i++){
    cin >> A[i];
  }
for(s=0;s<n;s++){
  if(s==n-1) cout << A[s];
  else cout << A[s] << " ";
}
cout << "\n";
   for(i=1; i<n; i++){
     v = A[i];
     j = i-1;
     while(j>=0&&A[j]>v){
       A[j+1]=A[j];
       j--;
       A[j+1]=v;
     }
     for(s=0;s<n;s++){
       if(s==n-1) cout << A[s];
       else cout << A[s] << " ";

     }
     cout << "\n";
   }

     return 0;
   }



Measured memory_bytes: 3100
//int _(){
//    int n,z,w;
//    cin >> n >> z >> w;
//    vi arr(n);
//    cin >> arr;
//    reverse(all(arr));
//    int ans = abs(arr[0]-w);
//    if(n >= 2)
//    ans = max(ans,abs(arr[0]-arr[1]));
//    return ans;
//}
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
int _(){
    int n,z,w;
    cin >> n >> z >> w;
    vi arr(n);
    cin >> arr;
    reverse(all(arr));
    int ans = abs(arr[0]-w);
    if(n >= 2)
    ans = max(ans,abs(arr[0]-arr[1]));
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
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; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    map<string, int> mp;
    rep (i, n) {
        cin >> s;
        mp[s]++;
    }
    print("AC x", mp["AC"]);
    print("WA x", mp["WA"]);
    print("TLE x", mp["TLE"]);
    print("RE x", mp["RE"]);

    return 0;
}


Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();
        long[] x = sc.LongArray();

        long answer = long.MaxValue;

        for (int i = 0; i <= n - k; i++)
        {
            long tmpAnswer = 0;
            if (x[i] * x[i + k - 1] >= 0)
            {
                tmpAnswer += Math.Max(Math.Abs(x[i + k - 1]), Math.Abs(x[i]));
            }
            else
            {
                tmpAnswer += x[i + k - 1] - x[i];
                tmpAnswer += Math.Min(Math.Abs(x[i + k - 1]), Math.Abs(x[i]));
            }
            answer = Math.Min(answer, tmpAnswer);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 38440
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		SeiveOfEratosthenes.init(1000000L*1000000L);
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(SeiveOfEratosthenes.countPrime(2, n));
		}
	}

}
class SeiveOfEratosthenes {
	private static long max_number;
	private static int max_number_sieve;
	private static boolean[] is_not_prime;
	private static ArrayList<Integer> prime = new ArrayList<Integer>();
	public static void init(long maxnum) {
		max_number = maxnum;
		max_number_sieve = (int) Math.sqrt(max_number);
		is_not_prime = new boolean[max_number_sieve+1];
		is_not_prime[0] = is_not_prime[1] = true;
		for(int i=2;i*i<=max_number_sieve;i++) {
			if (!is_not_prime[i]) {
				int j = 2;
				while(i*j<=max_number_sieve) {
					is_not_prime[i*j] = true;
					j++;
				}
			}
		}
		for(int i=2;i<=max_number_sieve;i++) {
			if(!is_not_prime[i]) {
				prime.add(i);
			}
		}
	}
	public static boolean isPrime(long n) {
		if (n>max_number) {
			return false;
		}
		if (n<=max_number_sieve) {
			return !is_not_prime[(int) n];
		}else{
			for(int p:prime) {
				if (n%p==0 && n!=p) {
					return false;
				}
			}
			return true;
		}
	}
	public static int countPrime(long first,long last) {
		if (first>last) {
			return 0;
		}
		if (last>max_number) {
			return -1;
		}
		int num = 0;
		for(int i=(int) first;i<=last;i++) {
			if (isPrime(i)) {
				num++;
			}
		}
		return num;
	}
}

Measured memory_bytes: 24772
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 302;

const int BITS = 60;

int n;

ll v[N_MAX];

ll A, B, C;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    A = v[1];
    B = v[2];
    for(int i = 3; i <= n; i++)
        C ^= v[i];
    ll D = A + B - C;
    if(D & 1)
    {
        cout << "-1\n";
        return 0;
    }
    D >>= 1;
    for(int i = 0; i < BITS; i++)
        if(((C >> i) & 1) && ((D >> i) & 1))
        {
            cout << "-1\n";
            return 0;
        }
    ll X = D;
    for(int i = BITS - 1; i >= 0; i--)
        if(((C >> i) & 1) && X + (1LL << i) <= A)
            X += (1LL << i);
    if(X == 0 || X > A)
    {
        cout << "-1\n";
        return 0;
    }
    cout << A - X << "\n";
    return 0;
}


Measured memory_bytes: 3632