akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#include <string.h>
#include <math.h>

int main()
{
  int q;
  int p[100001];
  int a[100001];

  memset(p, 1, sizeof(p));

  p[0] = p[1] = 0;
  for(int i = 2; i < sqrt(100001); i++){
    if(p[i]){
      for(int j = 2; i * j < 100001; j++){
        p[i*j] = 0;
      }
    }
  }

  a[0] = 0;
  for(int i = 1; i < 100001; i++){
    if(p[i] && p[(i+1)/2]) a[i] = a[i-1] + 1;
    else a[i] = a[i-1]; 
  }

  cin >> q;
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;
    cout << a[r] - a[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {

	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    
    set<string> s;
    for (int i = 0; i < n; i++) {
        string op, x;
        cin >> op >> x;
        if (op == "insert") s.insert(x);
        else if (op == "find") {
            auto it = s.find(x);
            if (it == s.end()) cout << "no" << "\n";
            else cout << "yes" << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 29008
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    cout << (s=="abc"?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<string> s;
    s.resize(n);
    
    for (auto&& e : s) {
        cin >> e;
    }
    
    vector<string> m;
    m.resize(n);
    
    int cnt = 0;
    for (int a = 0; a < n; ++a) {
        for (int i = 0; i < n; ++i) {
            m[i] = s[(i + a) % n];
        }
        
        bool ng = false;
        for (int i = 0; i < n && !ng; ++i) {
            for (int j = 0; j < n && !ng; ++j) {
                if (m[i][j] != m[j][i]) {
                    ng = true;
                }
            }
        
        }
            
        if (!ng) {
            cnt += n;
        }
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

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

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


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n;
	cin >> n;
	vi h(n);
	f_vI(h, n);
	vi dp(n + 2, ll_INF);
	dp[0] = 0;
	f(i, 0, n - 1) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if (i < n - 2) {
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1792
using System;
class Ho{
   static void Main(){
     var a = Console.ReadLine().Split();
     var N = int.Parse(a[0]);
     var M = int.Parse(a[1]);
     
     var k = (N*(N-1))/2+(M*(M-1))/2;
     Console.WriteLine(k);
   }
    
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int SZ = 10005;
int ms[10]={0,2,5,5,4,5,6,3,7,6};
int memo[SZ];
int track[SZ];
vector<int> sti;
vector<int> ans;
bool myf(int a, int b){
	return a>b;
}
int main(void){
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int x; scanf("%d",&x);
		sti.push_back(x);
	}
	sort(sti.begin(),sti.end(),myf);
	for(int i=1;i<=n;i++){
		for(int x : sti){
			if(i<ms[x]) continue;
			if(memo[i-ms[x]]==0 && i!=ms[x]) continue;
			if(memo[i]<(memo[i-ms[x]]+1)){
				memo[i]=memo[i-ms[x]]+1;
				track[i]=x;
			} 
		}
	}
	while(n){
		int x = track[n];
		ans.push_back(x);
		n-=ms[x];
	}
	sort(ans.begin(),ans.end(),myf);
	for(int x : ans) printf("%d",x);
	return 0;
}

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

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<ll> L(n); rep(i,n) std::cin >> L[i];

  int ans = 0;
  for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) for(int k=j+1; k<n; k++) {
    if ( L[i] != L[j] && L[j] != L[k] && L[k] != L[i] ) {
      if ( L[i] + L[j] > L[k] ) {
        if ( L[j] + L[k] > L[i] ) {
          if ( L[k] + L[i] > L[j] ) {
            ans++;
          }
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    vector<int64_t> s(N + 1);
    s.at(0) = 0;
    for (int i = 0; i < N; i++)
    {
        s.at(i + 1) = s.at(i) + A.at(i);
    }

    int64_t res = 0;
    map<int64_t, int64_t> m;
    for (int j = 0; j < N + 1; j++)
    {
        if (j - K >= 0)
            m[(s.at(j - K) - (j - K)) % K]--;
        int64_t t = (s.at(j) - j) % K;
        res += m[t];
        m[t]++;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;
#define pb push_back
const int mn=2e5+5;

int n,m;
char s[mn];

int a[mn],b[mn];
bool vis[mn];
vector<int> g[mn];

int main() {
    scanf("%d%d",&n,&m);
    scanf("%s",s+1);
    for(int i=1; i<=m; i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
        if (s[u]=='A') a[v]++;
        else b[v]++;
        if (s[v]=='A') a[u]++;
        else b[u]++;
    }

    queue<int> q;
    for(int i=1; i<=n; i++) {
        if (a[i]==0||b[i]==0) q.push(i),vis[i]=1;
    }
    while(!q.empty()) {
        int u=q.front();
        q.pop();
        for(auto &i:g[u]) {
            if (s[u]=='A') {
                a[i]--;
                if (!vis[i]&&a[i]==0) q.push(i),vis[i]=1;
            }
            else {
                b[i]--;
                if (!vis[i]&&b[i]==0) q.push(i),vis[i]=1;
            }
        }
    }
    int ans=0;
    for(int i=1; i<=n; i++)
        if (!vis[i]) ans=1;
    if (ans) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, k, a[200000], cnt; vector<int>x[200000];
int dfs(int pos) {
	int maxn = 0;
	for (int i = 0; i < x[pos].size(); i++) {
		maxn = max(maxn, dfs(x[pos][i]) + 1);
	}
	if (maxn == k - 1 && pos != 1 && a[pos] != 1) { maxn = -1; cnt++; }
	return maxn;
}
int main() {
	cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (i >= 2) { x[a[i]].push_back(i); } }
	if (a[1] != 1) { a[1] = 1; cnt++; }
	dfs(1);
	cout << cnt << endl;
	return 0;
}

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


int main(){

    int n;
    int apt=0,bpt=0;
    int a[10000]={0};
    int b[10000]={0};
    for(;;){
        apt=0;
        bpt=0;
    cin >> n;
    if(n==0)break;
    for(int i=0; i < n; i++){
        cin >>a[i];
        cin >>b[i];
    }
    for(int i=0; i < n; i++){
        if(a[i]>b[i])apt+=a[i]+b[i];
        else if(a[i]<b[i])bpt+=a[i]+b[i];
        else apt+=a[i],bpt+=b[i];
        }
    cout<<apt<<' '<<bpt<<endl;
    }
    return 0;
}

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

#define ll long long int
#define all(v) v.begin(), v.end()
#define single(v) for (auto i: v) cout << i << " ";
#define double(v) for (auto i: v) { single(i); cout << endl; }
#define yes_no(boolean) if (boolean) cout << "YES"; else cout << "NO";
#define mn(a) *min_element(a.begin(), a.end())
#define mx(a) *max_element(a.begin(), a.end())
int fact(int n){
    if (n == 0 || n == 1) return 1;
    return n * fact(n - 1);
}

int permut(vector<int> a){
    if (a.size() == 0) return 0;
    int r = a[0] - 1;
    for (int i = 1; i < a.size(); i++){
        if (a[i] > a[0]) a[i]--;
    }
    a.erase(a.begin());
    return r * fact(a.size()) + permut(a);
}

int main(){
    int n; cin >> n;
    vector<int> p(n, 0), q(n, 0);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) cin >> q[i];
    cout << abs(permut(p) - permut(q));
}


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

int main() {
  int s;
  cin >> s;
  int i = 0;
  if(s/1%10 == 1) i++;
  if(s/10%10 == 1) i++;
  if(s/100%10 == 1) i++;
    
  cout << i << endl;
  
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll a[7];

int main(){
  rep(i,0,7) cin >> a[i];
  ll ans = a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
  if(a[0] && a[3] && a[4]) {
    ans = max(ans , 3 + (a[0] - 1) / 2 * 2 +
        (a[3] - 1) / 2 * 2 + (a[4] - 1) / 2 * 2);
  }
  ans += a[1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


int n , m ,u, v, nxt[N],to[N],head[N],ne;
int dp[N];

void init(){

    ne = 0;
    memset(head, -1 , sizeof head);
}

void addEdge(int f, int t){

    to[ne] = t;
    nxt[ne] = head[f];
    head[f] = ne++;
}

int solve(int idx){

   // if(idx == n) return 0;

    int& ret = dp[idx];
    if(~ret) return ret;
    //if(~ret) return 0;

    ret = 0;
    for (int e = head[idx]; ~e ; e = nxt[e])
        ret = max(ret, solve(to[e])+1);


    return ret;

}



int main(){


    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);


    scanf("%d %d",&n,&m);
    init();

    loop(i , m){
        scanf("%d %d",&u,&v);
        addEdge(u, v);
    }

    int mx = 0;
    memset(dp, -1 , sizeof dp);


    for(int i = 1 ; i <= n ; ++i)
        mx = max(mx , solve(i));


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

    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    long long int n ; cin >> n;

    long long int nek=1e15;
    for(int i=0;i<5;i++){
        long long int tmp;
        cin >> tmp;
        nek=min(tmp,nek);
    }
    p((n+nek-1)/nek+4)
}

Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void bomb(const int y,const int x, vector<string> &vs){
  vs[y][x] = '0' ;
  int x2 = x, y2 = y;
  rep(i,4){//up
    if(y2>= 0){
      if(vs[y2][x2] == '1'){
        vs[y2][x2] = '0';
        bomb(y2,x2,vs);
      }
    }
    else{
      break;
    }
    --y2 ;
  }
  x2 = x, y2 = y;
  rep(i,4){//down
    if(y2<=7){
      if(vs[y2][x2] == '1'){
        vs[y2][x2] = '0' ;
        bomb(y2,x2,vs);
      }
    }
    else{
      break;
    }
    ++y2;
  }
  x2 = x, y2 = y;
  rep(i,4){//left
    if(x2>= 0){
      if(vs[y2][x2] == '1'){
        vs[y2][x2] = '0';
        bomb(y2,x2,vs);
      }
    }
    else{
      break;
    }
    --x2 ;
  }
  x2 = x, y2 = y;
  rep(i,4){//right
    if(x2<=7){
      if(vs[y2][x2] == '1'){
        vs[y2][x2] = '0' ;
        bomb(y2,x2,vs);
      }
    }
    else{
      break;
    }
    ++x2 ;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ,x,y;
  vector<string> vs;
  cin >> n;
  rep(i,n){
    vs.resize(8,"");
    rep(j,8){
      cin >> vs[j];
    }
    cin >> x>> y;
    bomb(y-1,x-1,vs) ;
    cout << "Data " << i+1 << ":" << endl;
    repa(n1,vs){
      cout << n1 << endl;
    }
  }
  return 0;
}

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

typedef long long ll;

#define optimize() 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 tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int x1, x2, y1, y2;

    cin>>  x1>> y1>> x2>> y2;

    int dx= x2-x1, dy= y1- y2;

    cout << x2+ dy <<' ' << y2 + dx<< ' ' << x1+ dy<< ' '<< y1+ dx;
    nl;

    return 0;
}




Measured memory_bytes: 3660
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n);
  int i;
  int m,m2;
  long long kcount = 0;
  for(i = 0; i < n+1; i++)cin >> a.at(i);
  for(i = 0; i < n; i++)cin >> b.at(i);
  for(i = 0; i < n; i++)
  {
    m = min(a.at(i), b.at(i));
    a.at(i) -= m;
    b.at(i) -= m;
    kcount += m;
    if(b.at(i) > 0)
    {
      m2 = min(a.at(i+1), b.at(i));
      a.at(i+1) -= m2;
      kcount += m2;
    }
  }
  cout << kcount << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        String a = sc.next();
        String b = sc.next();
        int num = Integer.parseInt(a + b);
        String answer = String.valueOf(Math.sqrt(num));
        if (answer.trim().endsWith(".0")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author I.E
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

#pragma GCC optimize("Ofast")
static auto speedup = [](){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

class CHAndV {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int h, w, k;
	    in >> h >> w >> k;
	    vector<vector<char>> m;
	    for (int i = 0; i < h; i++) {
	        string s;
	        in >> s;
	        m.push_back(vector<char>());
	        for (int j = 0; j < w; j++) {
                m[i].push_back(s[j]);
	        }
	    }
//        for (int i = 0; i < h; i++) {
//            for (int j = 0; j < w; j++) {
//                out << m[i][j] << " ";
//            }
//            out << endl;
//        }
	    int ans = 0;
        for (int maskR = 0; maskR < (1 << h); maskR++) {
            for (int maskC = 0; maskC < (1 << w); maskC++) {
                int black = 0;
                for (int i = 0; i < h; i++) {
                    if (((maskR >> i) & 1) == 0) {
                        for (int j = 0; j < w; j++) {
                            if (((maskC >> j) & 1) == 0 && m[i][j] == '#') {
                                black += 1;
                            }
                        }
                    }
                }
//                out << "black = " << black << endl;
                if (black == k) ans += 1;
            }
        }
        out << ans << endl;
	}
};


int main() {
	CHAndV solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3152
inputNum = list(map(int, input().split()))
L = list(map(int, input().split()))

N = inputNum[0]
X = inputNum[1]

D = [0]
# 座標0を含める
count = 1

for i, l in enumerate(L):
    # D[i+1]を求める
    D.append(D[i] + l)
    if(D[i+1] <= X):
        count += 1
    else:
        break

print(count)


Measured memory_bytes: 3060
h, w = map(int, input().split())
grid = []
inf = 400
for i in range(h):
    grid.append(list(input()))
graph = [[0 for i in range(h*w)] for j in range(h*w)]
for i in range(h):
    for j in range(1,w):
        u = i * w + j - 1
        v = i * w + j
        if grid[i][j-1] != '#' and grid[i][j] != '#':
            graph[u][v] = graph[v][u] = 1
for i in range(w):
    for j in range(1,h):
        u = (j - 1) * w + i
        v = j * w + i
        if grid[j-1][i] != '#' and grid[j][i] != '#':
            graph[u][v] = graph[v][u] = 1
distance = [[inf for i in range(h*w)] for j in range(h*w)]
for i in range(h*w):
    for j in range(w*h):
        if graph[i][j] == 1:
            distance[i][j] = 1
    distance[i][i] = 0
for k in range(h*w):
    for j in range(w*h):
        for i in range(w*h):
            distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j])
ans = 0
for i in range(h*w):
    for j in range(h*w):
        if distance[i][j] != inf:
            ans = max(ans, distance[i][j])
print(ans)

Measured memory_bytes: 45916
# abc150 C
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)


ai = 0
bi = 0
(1..n).to_a.permutation(n).to_a.each_with_index do |arr, ind|
  ai = ind if arr == a
  bi = ind if arr == b
end
p (bi - ai).abs



Measured memory_bytes: 6780
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

ll N;
ll A[200007];

int main()
{
    cin >> N;
    rep(i, N) cin >> A[i];
    //cout << N << endl;
    ll SS = 0;
    ll XOR = 0;
    ll e = -1;
    ll ans = 0;
    rep(s,N){
        while (SS==XOR && e<N){
            e++;
            if (e>=N)
                break;
            SS += A[e];
            XOR ^= A[e];
        }
        ans += e - s ;
        //cout << s << " " << SS << " " << XOR << " " << ans << endl;
        SS -= A[s];
        XOR ^= A[s];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
class Main
  def self.run
    r = read_input
    circle = Circle.new(r)
    puts "#{circle.area} #{circle.perimeter}"
  end

  private

  def self.read_input
    gets.to_f
  end

end

class Circle
  def initialize(radius)
    @radius = radius
  end

  def area
    (@radius ** 2 * Math::PI).round(6)
  end

  def perimeter
    (@radius * 2 * Math::PI).round(6)
  end
end

Main.run

Measured memory_bytes: 8712
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int X,Y;
    cin >> X >> Y;
    if (Y % 2 ==1) {
        cout << "No" << endl;
    }else{
        int min_n = X * 2;
        int max_n = X * 4;
        if(min_n <= Y & max_n >= Y){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3620
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    b=LIST()
    p=sum(a)

    for i in range(n):
        tmp=max(b[i]-a[i], 0)
        a[i]=max(a[i]-b[i],0)

        a[i+1] = max(a[i+1]-tmp,0)
        #print(i,tmp)

    #print(a)
    print(p-sum(a))

if  __name__=='__main__':
    main()

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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >
#define vii vector < pair < int, int > >

const int N = 507;
const ll INF = 1e18 + 7;

ll a[N], dp[N][N], pr[N];
int n;

ll calc (int l, int r){
    if (dp[l][r])
        return dp[l][r];
    if (l == r)
        return 0;
    dp[l][r] = INF;
    ll s1 = pr[r] - pr[l - 1];
    for (int i = l; i < r; i++){
        ll s2 = calc(l, i) + calc(i + 1, r);
        dp[l][r] = min(dp[l][r], s2 + s1);
    }
    return dp[l][r];
}

main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
    }
    cout << calc(1, n);
}


Measured memory_bytes: 1920
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val x = new Array[Long](N)

  for(i <- 0 until N) {
    x(i) = in.next().toLong
  }


  //
  val x2 = x.filter(_ <= 0)
  var ans = Long.MaxValue

  if(x2.length >= K){
    val res = x2.reverse.apply(K-1)
    ans = -res
  }

  for(i <- 0 until N) {
    if(i + K - 1 < N) {
      if(x(i+K-1) >= 0){
        ans = Math.min(ans, x(i+K-1) - Math.min(0, x(i) * 2))
      }
    }
  }

  for(i <- 0 until N) {
    if(i + K - 1 < N) {
      if(x(i) <= 0){
        ans = Math.min(ans, Math.max(0, x(i+K-1) * 2) - x(i))
      }
    }
  }


  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 43188
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  cout << fixed << setprecision(12);
  double PI = 3.14159265358979323846;
  
  double A, B, X;
  cin >> A >> B >> X;
  
  double S = X/A;
  
  if( A*B == S ){
    cout << 0 << endl;
    return 0;
  }
  
  double AC = 0;
  double ans = 0;
  if( S > A*B/2.000000000 ){ //台形
    double B2 = (2.00000000*S/A)-B;
    S -= A*B2;
    B -= B2;
    AC = 2.00000000*S/B;
  }else if( S <= A*B/2.000000000 ){ //三角形
    AC = 2.0000000000*S/B;
  }
  
  double kakudo = atan(B/AC);
  ans = kakudo * (180.00000000/PI);
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define first fi
#define second se
#define MOD 1000000007
#define MAXN 2003
#define endl "\n"
#define readln(x) getline(cin, x);
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
ll fpow(ll x, ll n, ll mod){if (n==0) return 1%mod; ll u = fpow(x, n/2, mod); u = (u*u)%mod; if (n%2==1)u = (u*x)%mod;return u;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
 
int N, X, Y;
vector<int> adj[MAXN];
int dist[MAXN], freq[MAXN];
bool visited[MAXN];
queue<int> q;
 
void BFS(int x){
    memset(visited,false,sizeof visited); 
    memset(dist,0,sizeof dist);
	visited[x] = true;
	dist[x] = 0;
	q.push(x);
	while(!q.empty()){
		int s = q.front(); q.pop();
		for (auto u : adj[s]){
			if (visited[u]) continue;
			visited[u] = true;
			dist[u] = dist[s]+1;
			q.push(u);
		}
	}
}
int main(){
    //freopen("data.txt","r",stdin);
    cin >> N >> X >> Y;
    for (int i = 1; i < N; i++){
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    adj[X].pb(Y);
    adj[Y].pb(X);
    for (int i = 1; i<=N; i++){
        BFS(i);
        for (int j = 1; j<=N; j++){
            freq[dist[j]]++;
        }
    }
    for (int i = 1; i<N; i++){
        cout << freq[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int N,C,cst[33][33],a[555][555],cnt[33],tmp[3][33];
int main(){
	scanf("%d%d",&N,&C);
	for(int i=1; i<=C; i++)
	for(int j=1; j<=C; j++)
		scanf("%d",&cst[i][j]);
	for(int i=1; i<=N; i++)
	for(int j=1; j<=N; j++)
		scanf("%d",&a[i][j]);
	for(int k=0; k<3; k++){
		memset(cnt,0,sizeof(cnt));
		for(int i=1; i<=N; i++)for(int j=1; j<=N; j++)
			if((i+j)%3==k){
				cnt[a[i][j]] ++;
			}
		for(int t=1; t<=C; t++){
			int cur = 0;
			for(int i=1; i<=C; i++)
				cur += cnt[i] * cst[i][t];
			tmp[k][t] = cur;
		}
	}
	int res = 2147483647;
	for(int i=1; i<=C; i++)for(int j=1; j<=C; j++)if(i!=j)
	for(int k=1; k<=C; k++)if(i!=k && j!=k)
		res = min(res, tmp[0][i] + tmp[1][j] + tmp[2][k]);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }
  typedef pair<ll, pair<ll, ll> > P;
  vector<P> C(N);
  rep(i, N) {
    C[i].se.fi = A[i];
    C[i].se.se = B[i];
    C[i].fi = A[i] + B[i];
  }

  sort(all(C), greater<P>());

  ll AA = 0, BB = 0;
  rep(i, sz(C)) {
    if (i % 2)
      BB += C[i].se.se;
    else
      AA += C[i].se.fi;
  }

  ll ans = AA - BB;
  cout << ans << endl;
}

Measured memory_bytes: 4096
a = [int(x) for x in input().split()]

ans = a[0] * a[2]
if a[0] * a[3] > ans:
    ans = a[0] * a[3]
if a[1] * a[2] > ans:
    ans = a[1] * a[2]
if a[1] * a[3] > ans:
    ans = a[1] * a[3]

print(ans)

Measured memory_bytes: 61856
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 101010, P = 1e9 + 7;

int a[N];

int add(int a, int b) {
	if((a += b) >= P) a -= P;
	return a;
}
int mul(int a, int b) {
	return 1ll * a * b % P;
}
int kpow(int a, int b) {
	int r = 1;
	while(b) {
		if(b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n, k; cin >> n >> k;
	rep(i, 2, k + 1) {
		for(int j = 2; j * j <= i; ++j) if(i % j == 0) {
			a[i] = add(a[i], a[j]);
			if(j != i / j) a[i] = add(a[i], a[i / j]);
		}
		a[i] = P - (1 + a[i]);
	}
	int ans = 0;
	rep(i, 1, k + 1) {
		int res = kpow(k / i, n);
		for(int j = 2; k >= j * i; ++j) {
			res = add(res, mul(a[j], kpow(k / (i * j), n)));
		}
		ans = add(ans, mul(res, i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define FOR(i,x,y) for(int i=(x),i##END=(y);i<=i##END;++i)
#define DOR(i,x,y) for(int i=(x),i##END=(y);i>=i##END;--i)
template<typename T,typename _T>inline bool chk_min(T &x,const _T y){return y<x?x=y,1:0;}
template<typename T,typename _T>inline bool chk_max(T &x,const _T y){return x<y?x=y,1:0;}
typedef long long ll;
bool vis[4000005];
int X[13][13];
int n,m;

int main()
{
	FOR(i,0,2000)vis[i*i]=1;
	scanf("%d%d",&n,&m);
	int cnt=0;
	FOR(i,1,n)FOR(j,1,m)scanf("%d",&X[i][j]);
	FOR(i,1,n)FOR(j,i+1,n)
	{
		int sum=0;
		FOR(k,1,m)sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
		if(vis[sum])cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <unordered_set>
#include <set>
using namespace std;
typedef long long ll;



int main(){
	ll a,b;
	cin >> a >> b;
	vector<int> x={1,3,5,7,8,10,12};
	vector<int> y={2};
	vector<int> z={4,6,9,11};
	for(auto w:x) if(a==w) a=-1;
	for(auto w:x) if(b==w) b=-1;
	for(auto w:y) if(a==w) a=-2;
	for(auto w:y) if(b==w) b=-2;
	for(auto w:z) if(a==w) a=-3;
	for(auto w:z) if(b==w) b=-3;
	if(a==b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    LL W, H, x, y;
    cin >> W >> H >> x >> y;

    double S = 0.5*W*H;
    int count = 0;
    if(2*x==W && 2*y==H){
        count = 1;
    }

    cout << fixed << setprecision(10) << S << " ";
    cout << count << endl;
    return 0;
}

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	i64 n, k;

	std::cin >> n >> k;

	std::vector<i64> h(n);

	for(i64 i=0; i<n; ++i)
	{
		std::cin >> h[i];
	}

	std::sort(h.begin(), h.end(), std::greater<i64>());

	for(i64 i=0; i<std::min(k, n); ++i)
	{
		h[i] = 0;
	}

	i64 ans = std::accumulate(h.begin(), h.end(), 0LL);

	std::cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 1792
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    int t, n, k=0, x, y;
   cin >> n;
   string s;
   cin >> s;
   for(int i=0; i<n-2; i++){
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') k++;
   }
   cout << k << "\n";
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}


Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  map<char, string> m;
  m['2'] = m['4'] = m['5'] = m['7'] = m['9'] = "hon";
  m['0'] = m['1'] = m['6'] = m['8'] = "pon";
  m['3'] = "bon";
  cout << m[s.back()] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    vector<int> cost(n);
    cost[0] = 0;
    cost[1] = abs(h[1]-h[0]);
    for(int i = 2; i < n; ++i){
       cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
    }
    cout << cost[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
def is_palindrome(text):
    l = len(text)
    for i in range(l // 2 if l % 2 == 0 else (l + 1) // 2):
        if text[i] != text[l - 1 - i]:
            return False
    return True

s = input()
q1 = is_palindrome(text=s)
q2 = is_palindrome(text=s[0:(len(s) - 1) // 2])
q3 = is_palindrome(text=s[(len(s) + 3) // 2 - 1:len(s)])
print("Yes" if q1 and q2 and q3 else "No")

Measured memory_bytes: 62004
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n);
	cin >> a;

	int maxi = *max_element(all(a));

	int ans;
	int diff = -1;
	for(auto i : a){
		if(i == maxi) continue;
		if(diff < min(i, abs(maxi - i))){
			diff = min(i, abs(maxi - i));
			ans = i;
		}
	}
	cout << maxi << ' ' << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, m;
	int l, r;
	int maxl, minr;
	cin >> n >> m;
	maxl = 0;
	minr = 100001;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		maxl = max(l, maxl);
		minr = min(r, minr);
	}
	cout << max(0,minr - maxl  + 1) << endl;
	return 0;
}


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

int main()
{
    vector<vector<int> > tetra(2);
    for(int i = 1; (i * (i + 1) * (i + 2)) / 6 < 1000001; i++){
        tetra[0].push_back((i * (i + 1) * (i + 2)) / 6);
        tetra[((i * (i + 1) * (i + 2)) / 6) % 2].push_back((i * (i + 1) * (i + 2)) / 6);
    }
    // for(int i = 0; i < 2; i++){
    //     for(int j = 0; j < tetra[i].size(); j++){
    //         cout << tetra[i][j] << endl;
    //     }
    //     cout << endl;
    // }
    int result[1000001][2];
    for(int i = 0; i < 1000001; i++){
        for(int j = 0; j < 2; j++){
            result[i][j] = 1000001;
        }
    }
    result[0][0] = 0;
    result[0][1] = 0;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < tetra[i].size(); j++){
            for(int k = 0; k + tetra[i][j] < 1000001; k++){
                result[k + tetra[i][j]][i] = min(result[k + tetra[i][j]][i], result[k][i] + 1);
            }
        }
    }
    int n;
    while(1){
        cin >> n;
        if(n == 0)break;
        cout << result[n][0] << " " << result[n][1] << endl;
    }
    return 0;
}

Measured memory_bytes: 9036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
vector<ll> a[4];
ll prfx[4][105];
ll ans,n,W,sz,mn,mx;
void recur(ll idx,ll val,ll wt){
    if(idx==sz){
        ans=max(ans,val);
        return;
    }
    for(ll i=0;i<=a[idx].size();i++){
        ll tot = wt + i*(mn+idx);
        if(tot>W)break;
        ll v = (i-1>=0?prfx[idx][i-1]:0ll);
        recur(idx+1,val+v,tot);
    }
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>W;
    mn=LLONG_MAX,mx=LLONG_MIN;
    ll w[n],v[n];for(ll i=0;i<n;i++)cin>>w[i]>>v[i],mx=max(mx,w[i]),mn=min(mn,w[i]);
    sz = mx-mn+1;
    for(ll i=0;i<n;i++)a[w[i]-mn].push_back(v[i]);
    for(ll i=0;i<sz;i++)sort(a[i].rbegin(),a[i].rend());
    for(ll i=0;i<sz;i++){
        for(ll j=0;j<a[i].size();j++){
            prfx[i][j]=a[i][j];
            if(j>0)prfx[i][j]+=prfx[i][j-1];
        }
    }
    recur(0,0,0);
    cout<<ans;
}




Measured memory_bytes: 256
// D - Negative Cycle
#include <bits/stdc++.h>

using namespace std;

#define	INF	1e16

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	vector<vector<long long> > a(n, vector<long long>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j) cin >> a[i][j];

	vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, INF));
	dp[0][0] = 0;

	for (int i = 1; i <= n; i++) {
		vector<long long> x(i), y(i);
		for (int j = 0; j < i; j++) {
			for (int k = i + 1; k <= n; k++) x[j] += a[k - 1][j - 1];
			if (j > 0) x[j] += x[j - 1];
		}
		for (int j = i - 1; j >= 0; j--) {
			for (int k = j + 1; k <= i; k++) y[j] += a[j][k - 1];
			if (j + 1 < i - 1) y[j] += y[j + 1];
		}
		for (int j = 0; j < i; j++)
			for (int k = 0; k <= j; k++)
				dp[i][j] = min(dp[i][j], dp[j][k] + x[j] - x[k] + y[j]);
	}

	cout << *min_element(dp[n].begin(),dp[n].end()) << endl;

	return 0;
}


Measured memory_bytes: 4224
# -*- coding: utf-8 -*-

import math

while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        scores = map(int, raw_input().split())

        ave = 0.0
        for i in scores:
            ave += i
        ave /= n

        dev = 0.0
        for i in scores:
            dev += (i-ave)*(i-ave)
        dev /= n

        print math.sqrt(dev)

Measured memory_bytes: 6480
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=100005;

int n,m,f[N],s[N],col[N],tot,t[3],cnt,last[N],nx[3]={1,2,0},ls[3]={2,0,1},flag;
bool vis[N];
struct edge{int to,next,op;}e[N*2];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int find(int x)
{
	if (f[x]==x) return x;
	else return f[x]=find(f[x]);
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].op=0;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].op=1;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x)
{
	vis[x]=1;t[col[x]]++;tot++;
	for (int i=last[x];i;i=e[i].next)
		if (!vis[e[i].to]) col[e[i].to]=!e[i].op?nx[col[x]]:ls[col[x]],dfs(e[i].to);
		else if (col[e[i].to]!=(!e[i].op?nx[col[x]]:ls[col[x]])) flag=1;
}

int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++) f[i]=i;
	for (int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
		if (find(x)!=find(y)) x=find(x),y=find(y),s[y]+=s[x],f[x]=y;
		s[find(x)]++;
	}
	LL ans=0;
	for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			tot=t[0]=t[1]=t[2]=flag=0;
			dfs(i);
			if (flag) ans+=(LL)tot*tot;
			else if (t[0]&&t[1]&&t[2]) ans+=(LL)t[0]*t[1]+(LL)t[1]*t[2]+(LL)t[2]*t[0];
			else ans+=s[find(i)];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pir pair<int,int>
#define pb push_back
#define fi first
#define se second
using namespace std;

const int N=510;
int h,w,num,foo[N];
vector<pair<pir,pir>> ans;

int main() {
	scanf("%d%d",&h,&w);
	for(int i=1,j=0;i<=h;i++) {
		scanf("%d",&num);
		int tmp=num&1;
		for(int j=2;j<=w;j++) {
			scanf("%d",&num);
			if(tmp) ans.pb({{i,j-1},{i,j}});
			if(num&1) tmp^=1;
		}
		if(j&1) ans.pb({{i-1,w},{i,w}});
		if(tmp&1) j^=1;
	}
	printf("%d\n",ans.size());
	for(auto p:ans) {
		printf("%d %d %d %d\n",p.fi.fi,p.fi.se,p.se.fi,p.se.se);
	}
	return 0;
}

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

int main(){
  int a,b,x; cin >> a >> b >> x;
  double v=(double)x/(a*a);
  double ans=0;
  if(v<(b/2)) ans=(180/PI)*atan((b*b)/(2*v*a));
  else ans=(180/PI)*atan(((b-v)*2)/a);
  printf("%.11lf\n",ans);
 return 0;
}


Measured memory_bytes: 256