akhauriyash/Code-Regression huggingface dataset:
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18
#define mm 998244353

void solve(){
	string s; cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#define ll long long int
using namespace std;
 
ll H,W;
 
ll maxfun(int  a, int b , int c){
  ll result;
  a>b? (result = a):(result =b);
  return (result >c)? (result):c;
}
ll minfun(int  a, int b , int c){
  ll result;
  a<b? (result = a):(result =b);
  return   (result <c)? (result):c;
}
int main(){
  ll s1,s2,s3;
  ll result=100000;
  ll min, max;
  
  cin >> H >> W;
 
  if((H%3)*(W%3)==0){
    cout << "0" << endl;
    return 0;
  }
  else result = H<W? H:W;
  for(int i =H/3; i< H/2+1;i++){
    for(int j = W/3; j< W/2+1; j++){
      s1 = i*W;
      s2 = j*(H-i);
      s3 = (H-i)*(W-j);
      min = minfun(s1,s2,s3);
      max = maxfun(s1,s2,s3);
      if(result> (max-min)) result = max-min;
 
      s1 = j*H;
      s2 = i*(W-j);
      s3 = (H-i)*(W-j);
      min = minfun(s1,s2,s3);
      max = maxfun(s1,s2,s3);
      if(result> (max-min)) result = max-min;
      
    }
  }
 
  cout << result << endl;
  return 0;
 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, D;
	int ans = 0;
	cin >> A >> B >> C >> D;
	if (A < B) {
		ans += A;
	}
	else {
		ans += B;
	}
	if (C < D) {
		ans += C;
	}
	else {
		ans += D;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
K = int(input())
A, B = map(int, input().split())

can_K_times = False
if (A % K) == 0 or (B % K) == 0:
    can_K_times = True
elif (A // K) != (B // K):
    can_K_times = True


if can_K_times:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 8984
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int buf[n+1];
    int f = 0;
    rep(i, 0, 4){
        if(i == 0){
            buf[0] = 1;
            buf[1] = 1;
        }else if(i == 1){
            buf[0] = 1;
            buf[1] = 0;
        }else if(i == 2){
            buf[0] = 0;
            buf[1] = 0;
        }else{
            buf[0] = 0;
            buf[1] = 1;
        }
        rep(j, 1, n){
            if(s[j] == 'o'){
                if(buf[j]){
                    buf[j+1] = buf[j-1];
                }else{
                    buf[j+1] = (buf[j-1] + 1) % 2;
                }
            }else{
                if(buf[j]){
                    buf[j+1] = (buf[j-1] + 1) % 2;
                }else{
                    buf[j+1] = buf[j-1];
                }
            }
        }
        if(buf[0] == buf[n]){
            if(s[0] == 'o'){
                if(buf[0]){
                    if(buf[n-1] == buf[1]){
                        f = 1;
                        break;
                    }
                }else{
                    if(buf[n-1] != buf[1]){
                        f = 1;
                        break;
                    }
                }
            }else{
                if(buf[0]){
                    if(buf[n-1] != buf[1]){
                        f = 1;
                        break;
                    }
                }else{
                    if(buf[n-1] == buf[1]){
                        f = 1;
                        break;
                    }
                }
            }
        }
    }
    if(f){
        rep(i, 0, n){
            printf("%c", buf[i] ? 'S' : 'W');
        }
    }else{
        printf("-1");
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll s; cin >> s;
    int x1 = 0, y1 = 0;
    ll x2 = 1000000000, y2 = 1;
    ll x3, y3;
    y3 = s/x2;
    if (y3 == 0) {
        x3 = s;
    }
    else {
        if (s%1000000000 != 0) {
            x3 = 1000000000-s%1000000000;
            y3++;
        }
        else {
            x3 = 0;
        }

    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 3005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n;
LD ans, p[MAXN], f[MAXN][MAXN*2];

int main()
{
	scanf("%d", &n);
	for(rint i=1; i<=n; ++i) scanf("%Lf", &p[i]);
	f[0][n]=1;
	for(rint i=1; i<=n; ++i)
	{
		for(rint j=1; j<=n*2; ++j) f[i][j]=f[i-1][j-1]*p[i]+f[i-1][j+1]*(1-p[i]);
	}
	for(rint i=n+1; i<=n*2; ++i) ans+=f[n][i];
	printf("%.10Lf\n", ans);
	return 0;
}

Measured memory_bytes: 281856
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        long ans = 1L;
        long std = 1000000000000000000L;
        for (int i = 0; i < time; i++) {
            long mul = sc.nextLong();
            if(mul == 0){
                System.out.println(0);
                return;
            }else if(ans == -1){
                continue;
            }else if(mul > std / ans){
                ans = -1;
            }else{
                ans *= mul;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60316
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
string a[MAXN],b[MAXN];
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int flag2 = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int flag = 0;
            for(int k=0;k+i<n&&k<m;k++){
                for(int t=0;t+j<n&&t<m;t++){
                    if(a[k+i][j+t]==b[k][t])
                        flag ++;
                }
            }
            if(flag == m*m)
                flag2 = 1;
        }
    }
    if(flag2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;

class Point {
public:
    double x, y;

    Point(double x=0, double y=0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(x*a, y*a); }
    Point operator / (double a) { return Point(x/ a, y/ a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x, y*y; }
    bool operator < (const Point &p) const {
	return x != p.x ? x<p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
double cross(Vector a, Vector b) {
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Point p0, Point p1, Point p2, Point p3) {
    return dot(p0 - p1, p2-p3) == 0.0;
}

bool isParallel(Point p0, Point p1, Point p2, Point p3) {
    return cross(p0-p1, p2-p3) == 0.0;
}

int main() {
    int q,i;
    cin >> q;
    Point p0, p1, p2, p3;
    for(i=0;i<q;i++){
	cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
	if (isOrthogonal(p0,p1,p2,p3)) cout << 1 << endl;
	else if(isParallel(p0,p1,p2,p3)) cout << 2 << endl;
	else cout << 0 << endl;
    }
    return 0;

}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include<queue>
#define rep(i,n) for (int i=0; i<(n);++i)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	string s;
	int k;
	cin >> k;
	cin >> s;
	if (s.size() <= k) cout << s << endl;
	else cout << s.substr(0, k) << "..." << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(void) {

    // Set up
    int n, m;
    cin >> n >> m;
    vector<int> S(m), C(m);
    for (int i = 0; i < m; ++i) {
        cin >> S[i] >> C[i];
    }

    string ans;
    for (int i = 0; i < n; ++i) {
        ans += "x";
    }

    for (int i = 0; i < m; ++i) {

        int ix = S[i] - 1;

        // check
        if (n != 1 && S[i]==1 && C[i]==0) {
            cout << -1 << endl;
            return 0;
        }

        if (ans[ix] != 'x' && ans[ix] != '0' + C[i]) {
            cout << -1 << endl;
            return 0;            
        }

        ans[ix] = '0' + C[i];
    }

    for (int i = 0; i < ans.size(); ++i) {
        if (ans[i] == 'x') {
            if (i == 0 && n != 1) {
                ans[i] = '1';
            } else {
                ans[i] = '0';
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int d;
	cin >> d;
	if (d == 22){
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else if (d == 23){
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 24){
		cout <<"Christmas Eve" << endl;
	}
	else{
		cout <<"Christmas" << endl;
	}
	return 0;
}

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

using namespace std;

template<typename T>
struct Dinic{
    //辺
    struct edge
    {
        //行先と逆辺、revはid参照されているので、
        //追加された順に1,2,3,...となっている
        int to,rev;
        //cap は capacityの略
        T cap;
        edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){};
    };

    const T INF;

    //グラフと探索済みかの配列
    vector<vector<edge>> graph;
    vector<int> iter,level;

    Dinic(int n):INF(numeric_limits<T>::max()){
        graph.resize(n);
    }

    void add_edge(int from, int to, T cap){
        //from ~ toにcapの辺を通す
        graph[from].emplace_back(to,cap,int(graph[to].size()));
        //to~from　に0容量の辺を通す
        graph[to].emplace_back(from,0,int(graph[from].size())-1);
    }

    //容量がある条件で最短距離の検索
    bool bfs(int s, int t){
        level.assign(graph.size(),-1);
        queue<int> que;
        level[s] = 0;
        que.push(s);

        while(!que.empty() and level[t] == -1){
            int p = que.front();
            que.pop();

            for(auto &e : graph[p]){
                if(e.cap > 0 and level[e.to] == -1){
                    que.push(e.to);
                    level[e.to] = level[p] + 1;
                }
            }
        }

        return level[t] != -1;

    }

    //ただのdfs探索
    //これは一本のパスについてflowを返していく
    T dfs(int v, const int t, T flow){
        //終了地点にきたらflowを返す
        if(v == t) return flow;
        for(int &i = iter[v]; i < graph[v].size(); i++){
            //流す余地があって未探索
            auto &e = graph[v][i];
            if(e.cap > 0 and (level[v] < level[e.to])){
                //このノード以降のフローを求める
                T d = dfs(e.to,t,min(flow,e.cap));
                if(d > 0){
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        //ここにたどり着くのは増加パスがない時
        return 0;
    }

    T max_flow(int s,int t){
        T flow = 0;
        //
        //cout << " bfs?" << " " << bfs(s,t) << endl;
        while(bfs(s,t)){
            //探索回数のリセット
            iter.assign(graph.size(),0);
            
            T f = 0;
            //dfsで見つかる限りflowを追加
            
            while((f = dfs(s,t,INF)) > 0){
                
                flow += f;
            }
            
        }
        return flow;
    }
};

int main(){
    int n,m; cin >> n >> m;
    Dinic<int> g(n);
    for(int i=0; i < m; i++){
        int a,b,c; cin >> a  >> b >> c;
        g.add_edge(a,b,c);
    }
    cout << g.max_flow(0,n-1) << endl;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) cin >> A[i];

    int cnt1 = H * W % 2;
    int cnt4 = (H / 2) * (W / 2);
    int cnt2 = (H * W - 4 * cnt4 - cnt1) / 2;

    unordered_map<char, int> map;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            map[A[i][j]]++;
        }
    }

    for (auto p : map) {
        while (p.second / 4 && cnt4) {
            p.second -= 4;
            cnt4--;
        }
        while (p.second / 2 && cnt2) {
            p.second -= 2;
            cnt2--;
        }
        while (p.second && cnt1) {
            p.second -= 1;
            cnt1--;
        }
    }

    if (cnt1 == 0 && cnt2 == 0 && cnt4 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
  int N; cin >> N;

  vector<long long> L(N + 1);
  vector<long long> R(N + 1);

  vector<int> vec(3 * N);
  for (int i = 0; i < 3 * N; i++) cin >> vec[i];

  priority_queue<int, vector<int>, greater<int>> q;

  for (int i = 0; i < N; i++)
  {
    q.push(vec[i]);
    L[0] += vec[i];
  }

  for (int i = 0; i < N; i++)
  {
    q.push(vec[N + i]);
    L[i + 1] = L[i] + vec[N + i];
    L[i + 1] -= q.top();
    q.pop();
  }

  reverse(vec.begin(), vec.end());
  priority_queue<int, vector<int>> q2;

  for (int i = 0; i < N; i++)
  {
    q2.push(vec[i]);
    R[0] += vec[i];
  }

  for (int i = 0; i < N; i++)
  {
    q2.push(vec[N + i]);
    R[i + 1] = R[i] + vec[N + i];
    R[i + 1] -= q2.top();
    q2.pop();
  }

  const long long  INF = 1e18 + 10;
  long long ans = -INF;

  for (int i = 0; i < N + 1; i++)
  {
    long long tmp = L[i] - R[N - i];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4216
import java.lang.Long.parseLong
import java.util.*

fun main(args:Array<String>) {
    var L = readLine()!!

    val mod = 1000000007L
    val dp = longArrayOf(1L, 0L)
    // 1 1 0 0
    // 1 0 1 0

    for (l in L) {
        if (l == '0') {
            dp[1] = dp[1]*3%mod
        } else {
            dp[1] = (dp[0]+dp[1]*3)%mod
            dp[0] = dp[0]*2%mod
        }
    }

    println(dp.sum()%mod)
}

Measured memory_bytes: 38696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int N = cin.NextInt();
        int[] A = cin.ArrayInt(N);

        long[,] dp = new long[N+2,2];
        dp[0, 0] = 0;
        dp[0, 1] = -100000000;

        for(int i = 0; i < N; ++i)
        {
            dp[i + 1, 0] = Math.Max(dp[i, 0] + A[i], dp[i, 1] - A[i]);
            dp[i + 1, 1] = Math.Max(dp[i, 0] - A[i], dp[i, 1] + A[i]);
        }
        Console.WriteLine(dp[N, 0]);

    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

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

long attack_count(long h) {
  if (h < 1) return 0;
  if (h == 1) {
    return 1;
  } else {
    if (h % 2 == 0) {
      return 2 * attack_count(h/2) + 1;
    } else {
      return 2 * attack_count((h-1)/2) + 1;
    }
  }
}

int main() {
  long h;
  cin >> h;
  cout << attack_count(h) << endl;
  return 0;
}


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

int main(int argc, char const *argv[]) {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> point(n, k-q);

    for (size_t i = 0; i < q; i++) {
        int a;
        cin >> a;
        point[a-1] += 1;
    }

    for (size_t i = 0; i < n; i++) {
        if (point[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3736
N,A,B=map(int,input().split())
if (A-B)%2:
  a,b=min(A,B),max(A,B)
  if a-1<N-b:
    print((b-a-1)//2+a)
  else:
    print((b-a-1)//2+(N-b+1))
else:
  print(abs(A-B)//2)


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int dx2[] = {1,1,1,0,0,0,-1,-1,-1};
const int dy2[] = {1,0,-1,1,0,-1,1,0,-1};

void go(vector<vector<int> > &F,int h,int w){
    if(F[h][w]==0) return;
    F[h][w] = 0;
    for(int i=0;i<9;i++){
        go(F,h+dy2[i],w+dx2[i]);
    }
}
int main(){
    while(true){
        int w,h;
        cin >> w >> h;
        if(w==0) break;
        vector<vector<int> > F(h+2,vector<int>(w+2,0));
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                int x;
                cin >> x;
                F[i][j] = x;
            }
        }
        int c=0;
        for(int i=0;i<h+2;i++){
            for(int j=0;j<w+2;j++){
                if(F[i][j] == 1){
                    go(F,i,j);
                    c++;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

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

using namespace std;

char animal[100003];
char s[100001];

//取相反的一个动物类别
char reverse_animal(char sw1)
{
	if (sw1 == 'S')
		return 'W';
	else
		return 'S';
}
//判断是否是正确的序列
int judge(char sw1, char sw2, int length)
{
	animal[0] = sw1;
	animal[1] = sw2;
	s[length] = s[0];
	for (int j = 2; j <= (length+1); j++)
	{
		if (s[j - 1] == 'o'&& animal[j - 1] == 'S')
			animal[j] = animal[j - 2];
		else if (s[j - 1] == 'o'&& animal[j - 1] == 'W')
			animal[j] = reverse_animal(animal[j-2]);
		else if (s[j - 1] == 'x'&& animal[j - 1] == 'W')
			animal[j] = animal[j - 2];
		else
			animal[j] = reverse_animal(animal[j - 2]);
	}
	if (animal[length] == sw1&&animal[length + 1] == sw2)
		return 1;
	else
		return 0;
}
int main()
{
	int N;
	scanf("%d", &N);
	getchar();
	scanf("%s", s);
	int length = strlen(s);
	if (judge('S', 'S', length))
	{
		animal[length] = '\0';
		printf("%s\n", animal);
		return 0;
	}
	if (judge('S', 'W', length))
	{
		animal[length] = '\0';
		printf("%s\n", animal);
		return 0;
	}
	if (judge('W', 'S', length))
	{
		animal[length] = '\0';
		printf("%s\n", animal);
		return 0;
	}
	if (judge('W', 'W', length))
	{
		animal[length] = '\0';
		printf("%s\n", animal);
		return 0;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A0 = list(map(int, input().split()))
A = [0] + A0 + [0]
tot = 0
for i in range (N+1):
    tot += abs(A[i+1]-A[i])
for i in range (1, N+1):
    print(tot - abs(A[i-1]-A[i]) -abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))

Measured memory_bytes: 14048
#include <stdio.h>
#define F 44

// recursive call
/*
  int fibonacci(int n){

  if(n == 0 || n == 1){
  return 1;
  }
  return fibonacci(n - 2) + fibonacci(n - 1);
  }
*/

// dynamic programinng 1

int fibonacci(int n){
  int i;
  int a = 1, b = 1, temp = 1;

  for(i = 2; i <= n; i++){
    temp = a + b;
    a = b;
    b = temp;
  }
  return temp;
}

int main(){
  int i, n;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#define MAX_WH 20

using namespace std;

int w, h;

class Point {
public:
  int x, y;
  Point(int x=0, int y=0) : x(x), y(y) {}
  bool operator <(const Point &p) const {
    if(y != p.y) return y < p.y;
    if(x != p.x) return x < p.x;
    return false;
  }

};
char data[MAX_WH][MAX_WH];

class State {
public:
  vector<Point> pyogore;

  int x, y;
  int step;
  State() {
    step = 0;
  }
  bool operator <(const State &s) const {
    if(x != s.x) return x < s.x;
    if(y != s.y) return y < s.y;
    if(pyogore.size() != s.pyogore.size()) 
      return pyogore.size() < s.pyogore.size();
    for(int i = 0; i < pyogore.size(); i++) {
      if(pyogore[i] < s.pyogore[i] || s.pyogore[i] < pyogore[i])
	return pyogore[i] < s.pyogore[i];
    }
    return false;
  }

  void next() {
    step++;
    del();
  }

  void del() {
    Point p(x,y);
    for(vector<Point>::iterator it = pyogore.begin();
	it != pyogore.end(); it++) {
      if(!(p < *it || *it < p)) {
	pyogore.erase(it);
	break;
      }
    }
  }
};

int enableFloor;
char data2[MAX_WH][MAX_WH];

void rec(int x, int y) {
  const int dx[4] = {1,0,-1,0};
  const int dy[4] = {0,1,0,-1};

  for(int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= w) continue;
    if(ny < 0 || ny >= h) continue;
    if(data2[ny][nx] == 'x') continue;
    if(data2[ny][nx] == 'x') continue;
    if(data2[ny][nx] == '*') enableFloor++;
    data2[ny][nx] = 'x';
    rec(nx, ny);
  }
}

int yogore;

int solve(State s) {
  queue<State> Q;
  set<State> visited;
  const int dx[4] = {1,0,-1,0};
  const int dy[4] = {0,1,0,-1};
  State tmp;
  char floor;
  Q.push(s);
  visited.insert(s);
  while(!Q.empty()) {
    s = Q.front();
    if(s.pyogore.size() == 0) return s.step;
    Q.pop();
    for(int i = 0; i < 4; i++) {
      tmp = s;
      tmp.x = s.x + dx[i];
      tmp.y = s.y + dy[i];
      if(tmp.x < 0) continue;
      if(tmp.x >= w) continue;
      if(tmp.y < 0) continue;
      if(tmp.y >= h) continue;
      if(data[tmp.y][tmp.x] == 'x') continue;
      tmp.next();
      if(visited.find(tmp) != visited.end()) continue;

      Q.push(tmp);
      visited.insert(tmp);
    }
  }
  return -1;
}

main() {
  while(1) {
    State s;
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    yogore = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	cin >> data[i][j];
	data2[i][j] = data[i][j];
	if(data[i][j] == 'o') {
	  s.x = j;
	  s.y = i;
	  data[i][j] = '.';
	  data2[i][j] = '.';
	} else if(data[i][j] == '*') {
	  yogore++;
	  s.pyogore.push_back(Point(j,i));
	  data[i][j] = '.';
	}
      }
    }
    enableFloor = 0;

    rec(s.x, s.y);
    if(enableFloor != yogore) cout << -1 << endl;
    else                      cout << solve(s) << endl;
  }
}

Measured memory_bytes: 9408
H,W=map(int,input().split())
def search(H,W):
    a=H//2
    b=H//2+H%2
    ans=float('inf')
    for w in range(1,W):
        x=a*w
        y=b*w
        z=H*(W-w)
        ans=min(ans,max(x,y,z)-min(x,y,z))
    return ans
if H%3==0 or W%3==0:
    print(0)
else:
    ans=float('inf')
    if H>3:ans=min(ans,W)
    if W>3:ans=min(ans,H)
    print(min(search(H,W),search(W,H),ans))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	void run() {
		// 入力
		int n; 
		int[] arr = new int[10];
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
//		int[] ans = new int[n];
		for( int i = 0; i < n; i++ ) {
			// 箱 
			int box1 = 0, box2 = 0;
			for( int j = 0; j < 10; j++ ) {
				arr[j] = scan.nextInt();
			}
			// 判定
			for( int j = 0; j < 10; j++ ) {
				if( arr[j] > box1 ) box1 = arr[j];
				else if( arr[j] > box2 ) box2 = arr[j];
				else {
					System.out.println("NO");
					break;
				}
				if( j == 9 ) {
//					ans[i] = 1;
					System.out.println("YES");
				}
			}
		}
//		for( int i = 0; i < n; i++ ) {
//			if( ans[i] == 1 ) System.out.println("YES");
//			else System.out.println("NO");
//		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 26380
a,b = map(int,input().split())
ans = 0
if a%2 == 0:
    for i in range(a,a+4):
        ans ^= i
        if i == 0:
            continue
        if ans == 0:
            break
    m = (b-i)%4
    for r in range(m):
        ans ^= b
        b -= 1
else:
    ans = a
    m = (b-a)%4
    for r in range(m):
        ans ^= b
        b -= 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,k; string s; cin >> n >> k >> s;
  s[k-1] += 'a'-'A'; 
  cout << s << endl;
}


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

namespace AthleteProgramming2
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ').ToArray();
            IntStack stack = new IntStack(300);
            for(int i = 0;i<str.Length; i++)
            {
                stack.Input(str[i]);
            }
            Console.WriteLine(stack.Pop());
        }
        
    }
    
    class IntStack
    {
        int[] array;
        int top;
        public IntStack(int arrayCount)
        {
            array = new int[arrayCount];
            top = 0;
        }

       public  void Push(int num)
        {
            array[top] = num;
            top++;
        }

        public int Pop()
        {
            top--;
            return array[top];
        }

        public void Input(string s)
        {
            if (s == "+" || s == "-" || s == "*")
            {
                int num1 = Pop();
                int num2 = Pop();
                int sum;
                if (s == "+")
                {
                    sum = num1 + num2;
                }else if (s == "-")
                {
                    sum = num2 - num1;
                }else
                {
                    sum = num1 * num2;
                }
                Push(sum);
            }else
            {
                Push(int.Parse(s));
            }
        }

    }


}

Measured memory_bytes: 9504
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  s[3] = '8';
  cout << s << "\n";
  return 0;
}


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

public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        boolean flg = true;

        ArrayList<Integer> intList = new ArrayList<Integer>();

         while(flg) {

            int n = scan.nextInt();
            int m = scan.nextInt();
            int p = scan.nextInt();

            scan.nextLine();

               // 選手数
            int num = 0;
            int xm = 0;

            if (n == 0 && m == 0 && p == 0) {
                flg = false;
            } else {
                for (int i = 0; i < n; i++) {
                    int x = scan.nextInt();

                    if (i == m - 1) {
                        xm = x;
                    }
                    num = num + x;
                }
                scan.nextLine();

                int y = 0;

                if (xm != 0) {
                    y = (int)((double)num * (100 - p) / xm);
                }

                intList.add(y);
            }
        }
        

        scan.close();

        for(int j : intList) {
            System.out.println(j);
        }
    }
}


Measured memory_bytes: 40252
N,K = map(int,input().split())
a = list(map(int,input().split()))

dp = [ False ] *(K+1)

dp[0] = False
for i in range(1,K+1):
    for j in range(N):
        if i - a[j] >= 0:
            dp[i] |= not dp[i-a[j]]


if dp[K] == True:
    print("First")
else:
    print("Second")


Measured memory_bytes: 42348
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int swt[10][10];
    int p[M];
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            swt[i][j] = 0;
        }
    }
    for (int i=0; i<M; i++) {
        int k;
        cin >> k;
        for (int j=0; j<k; j++) {
            int s;
            cin >> s;
            swt[i][j] = s;
        }
    }
    for (int i=0; i<M; i++) {
        cin >> p[i];
    }

    int res = 0;
    for (int bit=0; bit < (1<<N); bit++) {
        for (int i=0; i<M; i++) {
            int this_swt = 0;
            for (int j=0; j<10; j++) {
                if (swt[i][j] != 0) {
                    this_swt += pow(2, swt[i][j]-1);
                }              
            }

            int bit_and = this_swt & bit;
            int c = 0;
            for (int j=0; j<N; j++) {
                if (bit_and & (1<<j)) {
                    c += 1;
                }
            }
            if (p[i] != (c % 2)) {
                break;
            } else if (i == M-1) {
                res += 1;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

const int N = 201000;

set <int> s;
int a[N], rev[N];

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

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		a[i]--;
		rev[a[i]] = i;

	}

	s.insert(-1);
	s.insert(n);

	set <int>::iterator it;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		it = s.lower_bound(rev[i]);
		int r = *it;
		--it;
		int l = *it;
		//printf("%d %d %d %d\n", i+1, rev[i], l, r);
		//printf("%d %d\n", i-l, r-i);
		ans += ((i+1) * 1ll * (rev[i]-l) * 1ll * (r-rev[i]));
		//printf("%d\n", ans);
		s.insert(rev[i]);	
	}

	printf("%lld\n", ans);




}

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

int main(){
  int c = 0;
  string s;
  cin >> s;
  for (int i = 0; i < 2; i++){
    c = 0;
    for(int j = i+1; j < 4; j++){
      if (s[i] == s[j]){
        c++;
      }else{
        break;
      }
    }
    if (c >= 2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
ans = A[0]
cur = A[1]
num = 1
for i in range(N-2):
    if i%2 == 0:
        ans += A[num]
    else:
        ans += A[num]
        num += 1
print(ans)

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

const int MAX_N=100005;
int n, m;
int par[MAX_N], sz[MAX_N];

int find(int a) {
    if(a == par[a]) return a;
    return (par[a]=find(par[a]));
}

void unite(int a, int b) {
    a=find(a);
    b=find(b);
    if(a==b) return;
    if(sz[a]<sz[b]) swap(a,b);
    par[b]=a;
    sz[a]+=sz[b];
}

bool same(int a, int b) {
    return find(a)==find(b);
}

int main() {
    cin >> n >> m;
    rep(i,n) par[i]=i;
    rep(i,m) {
        int x,y,z;
        cin>>x>>y>>z;
        x--; y--;
        unite(x, y);
    }
    int ans=0;
    rep(i, n) if(par[i]==i) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 210000;
int n, a[MX];
ll s[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	rep(i, n){
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
	}
	ll ans = 1e18;
	for(int m = 2, i = 1, j = 3; m < n - 1; m++){
		
		while(i + 1 < m){
			if(s[i + 1] >= s[m] - s[i + 1]) break;
			i++;
		}
		while(j + 1 < n){
			if(s[j + 1] - s[m] >= s[n] - s[j + 1]) break;
			j++;
		}
		rep(it, 2) rep(jt, 2){
			int ii = i + it, jj = j + jt;
			if(ii == m || jj == n) continue;
			vector<ll> v = {s[ii], s[m] - s[ii], s[jj] - s[m], s[n] - s[jj]};
			sort(all(v));
			ans = min(ans, v[3] - v[0]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
word = set(s+t)
cou = 0
clist = []
for i in word:
  cou = s.count(i) - t.count(i)
  clist.append(cou)
ans = max(clist)
if ans < 0:
  ans = 0
print(ans)
  

Measured memory_bytes: 3060
#include <iostream>
#include <queue>

using namespace std;

long long n, ans, now, cnt3, cnt5, cnt7;

queue <string> q;

int main()
{
	cin >> n;
	q.push("3");
	q.push("5");
	q.push("7");
	while (!q.empty())
	{
		string s = q.front();
		q.pop();
		now = 0;
		cnt3 = 0;
		cnt5 = 0;
		cnt7 = 0;
		for (int i = 1; i <= s.length(); i++)
		{
			now *= 10;
			now += s[i - 1] - '0';
			if (s[i - 1] == '3') cnt3++;
			if (s[i - 1] == '5') cnt5++;
			if (s[i - 1] == '7') cnt7++;
		}
		if (now <= n)
		{
			if (cnt3 && cnt5 && cnt7) ans++;
			q.push("3" + s);
			q.push("5" + s);
			q.push("7" + s);
		} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = long.Parse(Console.ReadLine());
            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            
            //var C = new  

            for (int i = 0; i < K && i <= (long)Sqrt(N); i++)
            {
                var B = new int[N];
                for (int j = 0; j < N; j++)
                {
                    B[(int)Max(j - A[j], 0)]++;
                    if (j + A[j] < N - 1) B[(int)Min(j + A[j]+1, N-1)]--;
                }
                for (int j = 1; j < N; j++)
                {
                    B[j] += B[j - 1];
                }
                A = new List<int>(B);
            }
            Console.WriteLine(String.Join(" ",A));
           
        }


    }
}


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

class Dice {
public:
  int u;
  int r;
  int l;
  int d;
  int b;
  int f;
  void S(void) {
    int temp;
    temp = u; u = b; b = d; d = f; f = temp;
  }
  void N(void) {
    int temp;
    temp = u; u = f; f = d; d = b; b = temp;
  }
  void E(void) {
    int temp;
    temp = u; u = l; l = d; d = r; r = temp;
  }
  void W(void) {
    int temp;
    temp = u; u = r; r = d; d = l; l = temp;
  }
  void T(void) {
    int temp;
    temp = f; f = r; r = b; b = l; l = temp;
  }
};

bool operator == (const Dice d1, const Dice d2) {
  return
    d1.u == d2.u &&
    d1.f == d2.f &&
    d1.r == d2.r &&
    d1.l == d2.l &&
    d1.b == d2.b &&
    d1.d == d2.d;
}

int main() {

  Dice dice[128];
  int N;
  bool b;

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> dice[i].u;
    std::cin >> dice[i].f;
    std::cin >> dice[i].r;
    std::cin >> dice[i].l;
    std::cin >> dice[i].b;
    std::cin >> dice[i].d;
  }

  srand(time(NULL));

  b = true;
  for(int i = 0; i < N; ++i) {
    for(int j = i+1; j < N; ++j) {
      for(int k = 0; k < 10000; ++k) {
	if( dice[i] == dice[j] ) {
	  b = false;
	  goto label_1;
	}
	switch( rand() % 4 ) {
	case 0:
	  dice[i].E();
	  break;
	case 1:
	  dice[i].N();
	  break;
	case 2:
	  dice[i].W();
	  break;
	case 3:
	  dice[i].S();
	  break;
	}
      }
    }
  }  

 label_1:
  
  if( b ) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
    
  
  return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    string o,e;
    cin >> o;
    cin >> e;

    int osize = o.size();
    int esize = e.size();

    rep(i, esize){
        cout << o[i] << e[i];
    }

    if(osize > esize) cout << o[osize - 1];

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n,d=map(int,input().split())
point=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        now=0
        for k in range(d):
            now+=(point[i][k]-point[j][k])**2
        if int(now**0.5)**2==now:
            ans+=1
print(ans)

Measured memory_bytes: 3064
class Dice
   attr_accessor :dice,:top

   def initialize(nums)
      @dice = nums
      @top = nums[0]
   end

   def throw(direction)
      case direction
      when "S"
         @dice = [@dice[4],@dice[0],@dice[2],@dice[3],@dice[5],@dice[1]]
      when "N"
         @dice = [@dice[1],@dice[5],@dice[2],@dice[3],@dice[0],@dice[4]]
      when "W"
         @dice = [@dice[2],@dice[1],@dice[5],@dice[0],@dice[4],@dice[3]]
      when "E"
         @dice = [@dice[3],@dice[1],@dice[0],@dice[5],@dice[4],@dice[2]]
      end
      @top = @dice[0]
   end
end

nums = gets.chomp.split.map(&:to_i)
directions = gets.chomp

dice = Dice.new(nums)
directions.each_char do |char|
   dice.throw(char)
end
puts dice.top

Measured memory_bytes: 8636
n = int(input())

pedras = list(map(int,input().split()))

dp = [0] * n

dp[0] = 0
dp[1] = abs(pedras[0] - pedras[1])


for i in range(2,n):
    custo1 = dp[i-1] + abs(pedras[i-1] - pedras[i])
    custo2 = dp[i-2] + abs(pedras[i-2] - pedras[i])
    dp[i] = min(custo1,custo2)

print(dp[n-1])


Measured memory_bytes: 20696
import itertools
n = int(input())
p = tuple(map(lambda x:int(x)-1,input().split()))
q = tuple(map(lambda x:int(x)-1,input().split()))

a = 0
b = 0
for i,now in enumerate(itertools.permutations(range(n))):
  if (now == p):
    a = i
  if (now == q):
    b = i
print(abs(a-b))

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0; i<n; i++){
        cin >> p.at(i);
    }
    int num;
    num = 0;
    int a, b, c;
    for (int i=1; i<n-1; i++){
        a = p.at(i-1);
        b = p.at(i);
        c = p.at(i+1);
        if ( b > a ){
            if ( b < c ){
                num++;
            }
        // b < a
        }else if( b > c ) {
            num++;
        }
    }
    cout << num << endl;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int x;
  cin>>x;
  if(x==5||x==7||x==3)
    yes;
  else
    no;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3600
def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      j=1<<b[0]-97
      if d[i]==j:continue
      d[i]=j
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r)))
main()

Measured memory_bytes: 45556
import math

a, b, x = map(int, input().split())
result = math.atan(2 * ( a*a*b - x) / (a*a*a))
if a * math.tan(result) > b:
    result = math.pi / 2 - math.atan(2 * x / (a*b*b))

print(math.degrees(result))


Measured memory_bytes: 2940
"use strict";

function main(arg) {
    const input = arg.split("\n")
    const X = input[0].split(" ").map(x=>Number(x))
    const N = 5
    
    let sum = X.reduce((a,b)=>a+b)

    console.log(15-sum)
    
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29528
import java.util.*;
 
public class Main {
 	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      String str;
      str = sc.next();
      
      if(str.equals("AAA") || str.equals("BBB")) {
          System.out.print("No");
      } else {
          System.out.print("Yes");
      }
      
      
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    string S;
    cin >> S;

    int N = S.size();
    int P = 2019;
    vector<int> v(P);

    int t = 0;
    int ten = 1;
    for(int i=0; i<N; i++) {
        t += (S[N-1-i]-'0') * ten;
        ten *= 10;
        t %= P;
        ten %= P;
        v[t]++;
    }

    int ans = 0;
    for(auto e: v) {
        ans += e*(e-1)/2;
    }

    cout << ans + v[0] << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <cstdio>
#include <vector>

int count = 0;
void mergeSort(std::vector<int> &a, std::vector<int> &b, int left, int right){
    if(left >= right) return;

    int mid = left + (right - left) / 2;
    mergeSort(a, b, left, mid);
    mergeSort(a, b, mid + 1, right);

    int i = left;
    int j = mid + 1;
    for(int k = left; k <= right; ++k){
        if(i > mid) b[k] = a[j++];
        else if(j > right) b[k] = a[i++];
        else if(a[i] <= a[j]){
            b[k] = a[i++];
        } else if(a[i] > a[j]){
            b[k] = a[j++];
        }
    }
    count += right - left  + 1;
    for(int k = left; k <= right; ++k){
        a[k] = b[k];
    }
}

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

    std::vector<int> a(n, 0);
    std::vector<int> b(n, 0);
    for(int i = 0; i < n; ++i){
        std::scanf("%d", &a[i]);
    }

    mergeSort(a, b, 0, n - 1);
    std::printf("%d", a[0]);
    for(int i = 1; i < n; ++i){
        std::printf(" %d", a[i]);
    }
    std::printf("\n");
    std::printf("%d\n", count);
    return 0;
}


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

int main()
{
	//freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    string a;
    cin>>a;
    if(a=="ABC")
    	cout<<"ARC";
    else
    	cout<<"ABC";
	return 0;
}

Measured memory_bytes: 3624