akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n; cin >> n;
  while(n>0){
    if(n%10==7) {
      cout << "Yes" << "\n";
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;

}

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

int main() {
    
    int n,k;
    cin >> n >> k;
    
    double ans=0.0;

    for (int d = 1; d <= n; d++){
        int scr=d;
        int cnt=0;
        while(scr<k){
            scr=scr*2;
            cnt++;
        }
        ans=ans+(1.0/(double)n)*pow(0.5,(double)cnt);
    }

    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4220
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		if (inint() == 1) out.println("Hello World");
		else {
			out.println(inint() + inint());
		}
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   ll N;
   cin >> N;
   string ans = "";
   while (N != 0) {
      if (N % 2 != 0) {
         N--;
         ans = "1" + ans;
      } else {
         ans = "0" + ans;
      }
      N /= -2;
   }
   if (ans == "") ans = "0";

   cout << ans << endl;

   return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

ll count(ll x){
	ll ret=0;
	while(x%2==0){
		x/=2;
		ret++;
	}
	return ret;
}

int main()
{
	ll n,m;
	cin>>n>>m;
	vector<ll> a(n);
	rep(i,n)cin>>a[i],a[i]/=2;

	ll cnt = count(a[0]);
	rep(i,n){
		// cout<<cnt<<endl;
		if(cnt!=count(a[i])){
			cout<<0<<endl;
			return 0;
		}
	}

	ll x = 1;
	rep(i,n){
		ll g = gcd(x,a[i]);
		x =(x/g)*a[i];
		if(x>m){
			cout<<0<<endl;
			return 0;
		}
	}

	ll ans=0;
	for (ll i = 1; i*x<=m; i+=2){
		ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static FastScanner sc = new FastScanner();
    public void solve1(int testNumber, Scanner in, PrintWriter out) {
        int K = Integer.parseInt(in.next());
        int x = 7 % K;
        int i = 1;
        Set<Integer> s = new HashSet<>();
        while (!s.contains(x)) {
            if (x == 0) {
                out.println(i);
                return;
            } else {
                s.add(x);
                x = (x * 10 + 7) % K;
                ++i;
            }
        }
        out.println(-1);
    }
    static void solve(int k){
        int x=7%k;
        int i=1;
        Set<Integer> s= new HashSet<>();
        while (!s.contains(x)){
            if (x==0){
                System.out.println(i);
                return;
            }
            else{
                s.add(x);
                x=(x*10+7)%k;
                i++;
            }
        }
        System.out.println("-1");
    }

    public static void main(String[] args) {
        int t=sc.nextInt();
        int x=7%t;
        int count=1;
        Set<Integer> s= new HashSet<>();
        while (!s.contains(x)){
            if (x==0){
                System.out.println(count);
                return;
            }
            else{
                s.add(x);
                x=(x*10+7)%t;
                count++;
            }
        }
        System.out.println("-1");



    }

        static void sortint(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sort(long[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (long i : a) l.add((int) i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}





Measured memory_bytes: 100056
N, A, B = map(int, input().split())
total = 0
for i in range(1, N + 1):
    sum_digits = 0
    j = i
    while j > 0:
        sum_digits += j % 10
        j //= 10
    if A <= sum_digits <= B:
        total += i
print(total)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int n,dp[N],sum[N];
int main()
{
	scanf("%d",&n);
	if (n==1) return puts("1"),0;
	dp[0]=sum[0]=1;
	for (int i=1;i<=n;i++){
		dp[i]=dp[i-1];
		if (i>=3) dp[i]=inc(dp[i],sum[i-3]);
		sum[i]=inc(sum[i-1],dp[i]);
	}
	int ans=0;
	//最后循环的不是1且完全循环
	ans=inc(ans,mul(sum[n-1],n-1));
	//最后循环的不是1且不是完全循环
	ans=inc(ans,mul(sum[n-2],mul(n-1,n-2)));
	//最后循环的是1且完全循环
	ans=inc(ans,dp[n-1]);
	//最后循环的是1且溢出了
	for (int i=0;i<n-2;i++) ans=inc(ans,mul(dp[i],i+2));
	ans=inc(ans,mul(dp[n-2],n-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#include<stdio.h>
int main()
{
  int l,i,j,k,minj,N,a,b=0;
  int A[100];
  scanf("%d",&N);
  if(1<=N && N<=100)
    {
      for(l=0;l<N;l++)
	{
	  scanf("%d",&A[l]);
	}
    }
      for(i=0;i<=N-1;i++)
	{
	  minj=i;
		for(j=i;j<=N-1;j++)
	{
	  if(A[j]<A[minj])
	    {
	      minj=j;
	    }
	
	}
      if(minj!=i)
	b++;
	  a=A[i];
	  A[i]=A[minj];
	  A[minj]=a;
	  
	}
      for(k=0;k<N;k++)
	{
	  printf("%d",A[k]);
	  if(k!=N-1)
	    printf(" ");
	}
	
      
  printf("\n");
  printf("%d",b);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <sstream>

using namespace std;
int main()
{
	string str;
	getline(cin, str);
	istringstream iss(str);
	iss >> str;
	int A = stoi(str);
	iss >> str;
	int B = stoi(str);

	if ((A*B) % 2 == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int i = H  - h;
    int j = W - w;
    cout << i*j << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<int> q;
  ll ans=0;
  rep(i,n){
    int x;cin >> x;
    q.push(x);
  }
  rep(i,m){
    int y=q.top();q.pop();
    q.push((int)y/2);
  }
  rep(i,n){
    int x=q.top();q.pop();
    ans+=x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3892
#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll Q, H, S, D, N;   cin >> Q >> H >> S >> D >> N;
    H = min(2*Q, H);
    S = min(2*H, S);
    ll ans = 0;

    ans = N/2 * min(S*2, D) + N%2*S;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, q, l, r, b = 1, c = 0, e = 0; char s;
	cin >> n >> q; int test[100010] = { 0 };
	int fgh[100010] = { 0 };
	int uio[100010] = { 0 };
	for (int h = 1; h <= n; h++) {
		cin >> s;
		if (s == 'C' && e == 1) {
			e = 0; c++; 
		}
		else if (e == 1) {
			e = 0;
		}
		if (s == 'A'&& e == 0) {
			e++;
		}
		test[h] = c;
	}
	for (int h = 1; h <= q; h++) {
		cin >> l >> r;
		fgh[h] = l;
		uio[h] = r;
	}
	for (int h = 1; h <= q; h++) {
		cout << test[uio[h]] - test[fgh[h]] << endl;
	}
	cin >> e;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;cin>>N;
  cout<<N*(N+1)/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 1'000'000 + 5;

i64 T;

i64 x;


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> x;

    i64 c = 100;
    for (i64 i = 1; true; i++) {
        c *= 1.01;
        if (c >= x) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

#define OM ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define pi 3.14159265358979323846

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF MAHADEV*/

int main(){
	OM;
	int n, d;
	cin >> n >> d;
	int answer = 0;
	for(int i = 0; i < n; ++i){
		ll x, y;
		cin >> x >> y;
		long double dis = sqrt(x * x + y * y);
		if(dis <= d)
			++answer;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr i32 MOD = 1e9 + 7;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

namespace null_null {

i64 mod_pow(i64 x, i64 n, i64 MOD = MOD) {
  if (n == 0)
    return 1;
  i64 res = mod_pow(x * x % MOD, n / 2, MOD);
  if (n % 2 == 1)
    res = res * x % MOD;
  return res;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace null_null {

void main_() {
  std::string s;
  std::cin >> s;
  usize N = s.size();

  static i64 dp[101010][20] = {};
  dp[0][0] = 1;
  i32 X = mod_pow(10, N - 1, 13);
  i32 div = mod_pow(10, 11, 13);

  for (usize i = 0; i < N; i++) {
    for (usize j = 0; j < 13; j++) {
      if (s[i] != '?') {
        i32 tmp = j + X * ((i32)(s[i] - '0')) % 13;
        dp[i + 1][tmp % 13] += dp[i][j];
        dp[i + 1][tmp % 13] %= MOD;
      } else {
        for (usize k = 0; k < 10; k++) {
          i32 tmp = j + X * k % 13;
          dp[i + 1][tmp % 13] += dp[i][j];
          dp[i + 1][tmp % 13] %= MOD;
        }
      }
    }
    X = X * div % 13;
  }

  std::cout << dp[N][5] << std::endl;
} // namespace null_null

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
    int n, h, w;
    cin >> n >> h >> w;

    cout << (n-h+1)*(n-w+1) << endl;



    return 0;
}



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

int main() {
	string s,t;
	cin>>s>>t;
	for(char c='a';c<='z';c++)
    {
		if(s+c==t)
        {
            puts("Yes");

            return 0;
            }
    }
	puts("No");
	return 0;
}


Measured memory_bytes: 3600
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){
  
  int N,R,rate;
  
  cin >> N >> R;
  
 if(N < 10){
   rate = R + 100 * (10 - N);
 }else{
   rate = R;
 }



  cout << rate << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    Robot r;
    public int w, h, t;
    String com;

    void run(){
	while(sc.hasNext()){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0) break;

	    r = new Robot();
	    com = sc.next();
	    while(!com.equals("STOP")){

		if(com.equals("FORWARD"))
		    r.forward(sc.nextInt());
      
		else if(com.equals("BACKWARD"))
		    r.forward((sc.nextInt())*(-1));

		else if(com.equals("RIGHT"))
		    r.turnR();

		else if(com.equals("LEFT"))
		    r.turnL();

		com = sc.next();
	    }
	    System.out.println(r.getX()+" "+r.getY());
	}
    }

    class Robot{
	int x, y;
	int d; // 0=f=(y+), 1=r=(x+), 2=b=(y-), 3=l=(x-)
	Robot(){
	    x = 1;
	    y = 1;
	    d = 0;
	}

	void forward(int g){
	    if(d==0) y = y+g>h ? h : y+g<1 ? 1 : y+g;  
	    if(d==1) x = x+g>w ? w : x+g<1 ? 1 : x+g;  
	    if(d==2) y = y-g>h ? h : y-g<1 ? 1 : y-g;	  
	    if(d==3) x = x-g>w ? w : x-g<1 ? 1 : x-g;  
	}

	int getX(){ return x; }
	int getY(){ return y; }
	
	void turnR(){ d = (d+1)%4; }
	void turnL(){ d = (d+4-1)%4; }
    }
    
}

Measured memory_bytes: 25920
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5;
ll ans;
set<pa>appear;
typedef set<pa>::iterator It;
int n,m,flag;
int fa[maxn],sz[maxn],cnt[maxn],used[maxn],col[maxn],vis[3];
vector<pa>e[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void dfs(int x,int y){
	col[x]=y;vis[y]++;
	rep2(i,0,SZ(e[x]))
		if(col[e[x][i].w1]==-1)
			dfs(e[x][i].w1,(3+y+e[x][i].w2)%3);
		else
			flag&=(3+col[x]+e[x][i].w2)%3==col[e[x][i].w1];
}
int main(){
	read(n);read(m);
	rep(i,1,n)fa[i]=i,sz[i]=1;
	rep(i,1,m){
		int x,y;read(x);read(y);
		appear.insert(mp(x,y));
		x=find(x);y=find(y);
		if(x!=y)fa[x]=y,sz[y]+=sz[x],cnt[y]+=cnt[x];
		cnt[y]++;
	}
	for(It it=appear.begin();it!=appear.end();it++){
		int x=it->w1,y=it->w2,z=find(x);
		if(used[z])continue;
		if((x==y)||appear.count(mp(y,x))){
			used[z]=1;
			ans+=1ll*sz[z]*sz[z];
		}
	}
	for(It it=appear.begin();it!=appear.end();it++){
		int x=it->w1,y=it->w2,z=find(x);
		if(used[z])continue;
		e[x].pb(mp(y,1));
		e[y].pb(mp(x,-1));
	}
	memset(col,-1,sizeof col);
	for(It it=appear.begin();it!=appear.end();it++){
		int x=it->w1,y=it->w2,z=find(x);
		if(used[z])continue;
		vis[0]=vis[1]=vis[2]=0;
		flag=1;
		dfs(x,0);
		used[z]=1;
		if(!flag){
			ans+=1ll*sz[z]*sz[z];
		}else if(vis[0]&&vis[1]&&vis[2]){
			ans+=1ll*vis[0]*vis[1]+1ll*vis[1]*vis[2]+1ll*vis[2]*vis[0];
		}else ans+=cnt[z];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 20224
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    string s1, s2;
    s1 = (char)(a + '0');
    s2 = (char)(b + '0');
    for (ll i = 0; i < b - 1; i++)
    {
        s1+= (char)(a + '0');
    }
    for (ll i = 0; i < a - 1; i++)
    {
        s2 += (char)(b + '0');
    }
    if (s1 < s2) cout << s1;
    else cout << s2;
}

Measured memory_bytes: 888
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int dp[1<<21];
bool a[21][21];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    dp[0] = 1;
    iter(mask, 1, 1<<n) {
        int i = __builtin_popcount(mask) - 1;
        rep(j, n) if(a[i][j] && (mask & (1<<j))) dp[mask] = (dp[mask] + dp[mask^(1<<j)]) % MOD;
    }
    cout << dp[(1<<n)-1] << endl;
}



Measured memory_bytes: 8448
N = int(input())
X = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 1
n = 0
for x in X:
  if x < 2*(n+1) - 1:
    ans = ans * (n+1) % MOD
  else:
    n += 1

for i in range(1, n+1):
  ans = ans * i % MOD

print(ans)

Measured memory_bytes: 14588
n = int(input())
a = list(map(int, input().split()))
ans = 0

while(1):
    odd = False
    for i, v in enumerate(a):
        if a[i] % 2 == 1:
            odd = True
    if odd:
        break
    ans += 1
    for i, v in enumerate(a):
        a[i] //= 2

print(ans)

Measured memory_bytes: 3060
#include<iostream>   
#include<cstdio>  
#include<algorithm>
#include<queue>
#include<map>
#include<string>
using namespace std;
const int row = 4;
const int maxx = 16;
const int LIMIT = 100;
struct Puzzle {
    int f[maxx], space, MD;
};
 
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { 1, 0, -1 ,0 };
const char dir[4] = { 'r','u','l','d' };
int MDT[maxx][maxx];
 
Puzzle state;
int limit;
int path[LIMIT];
 
int getAllMD(Puzzle pz) {
    int sum = 0;
    for (int i = 0; i < maxx; i++) {
        if (pz.f[i] != maxx)
            sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}
 
bool isSolved() {
    for (int i = 0; i < maxx; i++)
        if (state.f[i] != i + 1)
            return false;
    return true;
}
 
bool dfs(int depth, int prev) {
 
    if (state.MD == 0)
        return true;
 
    if (depth + state.MD > limit)
        return false;
 
    int sx = state.space / row;
    int sy = state.space % row;
 
    Puzzle tmp;
    for (int r = 0; r < 4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if (tx < 0 || ty < 0 || tx >= row || ty >= row)
            continue;
        if (max(prev, r) - min(prev, r) == 2)
            continue;
        tmp = state;
        state.MD -= MDT[tx * row + ty][state.f[tx * row + ty] - 1];
        state.MD += MDT[sx * row + sy][state.f[tx * row + ty] - 1];
        swap(state.f[tx * row + ty], state.f[sx * row + sy]);
        state.space = tx * row + ty;
        if (dfs(depth + 1, r)) {
            path[depth] = r;
            return true;
        }
        state = tmp;
    }
    return false;
}
 
string iterative_deepening(Puzzle in) {
    in.MD = getAllMD(in);
    for (limit = in.MD; limit <= LIMIT; limit++) {
        state = in;
        if (dfs(0, -100)) {
            string ans = "";
            for (int i = 0; i < limit; i++)
                ans += dir[path[i]];
            return ans;
        }
    }
    return "unsolvable";
}
 
int main()
{
    for (int i = 0; i < maxx; i++) {
        for (int j = 0; j < maxx; j++) {
            MDT[i][j] = abs(i / row - j / row) + abs(i % row - j % row);
        }
    }
    Puzzle in;
    for (int i = 0; i < maxx; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = maxx;
            in.space = i;
        }
    }
    string ans = iterative_deepening(in);
    printf("%d\n", ans.size());
    return 0;
}


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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int a,b,c;
    int count=0;
    cin>>a>>b>>c;
    if(a%2==1 or b%2==1 or c%2==1)
    {
        cout<<0;
    }
    else if(a==b and b==c  and c==a)
    {
        cout<<-1<<endl;
    }
    else
    {
        while(1)
        {
            int A=b/2+c/2;
            int B=a/2+c/2;
            int C=a/2+b/2;
            ++count;
            a=A;
            b=B;
            c=C;
            
             if(a%2==1 or b%2==1 or c%2==1)
                break;
        }
    cout<<count<<endl;
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int s0 = 0,s1 = Math.abs(arr[1]-arr[0]);
        int res=s1;
        for(int i=2;i<n;++i){
            res =Math.min(s0+Math.abs(arr[i]-arr[i-2]),s1+Math.abs(arr[i]-arr[i-1]));
            s0 =s1;
            s1=res;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 59468
module ABC162

    export execute_task_a

    function evaluate_task_a(given_string::Core.AbstractString)
        return given_string == "ABC" ? "ARC" : "ABC"
    end

    function execute_task_a()
        Base.println( evaluate_task_a(Base.readline(Base.stdin)) )
    end

end


ABC162.execute_task_a()

Measured memory_bytes: 152032
#include<bits/stdc++.h>
using namespace std;
long long arr[3000000],cnt[3000000];
int main()
{
	long long n,i,j,k;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
		//cnt[arr[i]]++;
	}
	sort(arr,arr+n);
	for (i=0;i<n-1;i++)
	{
		if (arr[i+1]==arr[i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    //ll ans=0;
    rep(i,N){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        //ans += mp[s];
        mp[s] +=1;
    }

    ll ans=0;
    for(auto p :mp){
        ans += (ll) p.second*(p.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11056
#include <iostream>
using namespace std;
static const int maxn = 2e5 + 5;
int a[maxn],sum[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		int x;
		cin>>x;
		a[i] = a[i - 1] + x;
		sum[i] = sum[i - 1] ^ x;
	}
	long long ans = 0;
	int l = 1;
	for(int r = 1;r <= n; ++r)
	{
		while((a[r] - a[l - 1]) != (sum[r] ^ sum[l - 1]))
		{
			l++;
		}
		ans += (r - l + 1);
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define MAXN 1000

int N, K;
long long a[MAXN];

long long A[MAXN][MAXN];

long long power( long long x, int n )
{
	if( n == 0 ) {
		return 1;
	}
	if( n % 2 ) {
		return x * power( x, n - 1 );
	}
	else {
		return power( x * x, n / 2 );
	}
}

int main()
{
	cin >> N >> K;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
		A[i][0] = a[i];
	}

	int n1 = N * (N + 1) / 2;
	for( int i = 0; i < N; i++ ) {
		int k = 1;
		for( int j = i + 1; j < N; j++ ) {
			A[i][k] = A[i][k - 1] + a[j];
			k++;
		}
	}
	long long ans = 0;
	long long t = power( 2, 40 - 1 );
	for( int l = 40; l > 0; l-- ) {
		int n = 0;
		for( int i = 0; i < N; i++ ) {
			int k = 1;
			for( int j = i + 1; j < N; j++ ) {
				if( ( ( ans + t) & A[i][k] ) == (ans + t) ) {
					n++;
					if( n == K ) {
						ans += t;
					}
				}
				k++;
			}
		}
		t /= 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7424
# http://drken1215.hatenablog.com/entry/2020/02/09/225000

class Calc:
    def __init__(self, *, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def combination(self, n, r):
        if n - r < r:
            return self.combination(n, n - r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def factorial(self, n):
        return self.fact[n]


def main():
    mod = 10 ** 9 + 7

    r1, c1, r2, c2 = map(int, input().split())

    cl = Calc(max_value=r2 + c2 + 1, mod=mod)

    ret = 0
    for r in range(r1, r2 + 1):
        ret += cl.combination(r + c2 + 1, r + 1)
        ret -= cl.combination(r + (c1 - 1) + 1, r + 1)
        ret %= mod

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73564
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int gcd(int a, int b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &e : A) cin >> e;
	
	int ans = A[0];
	for(const auto &e :A) {
		ans = gcd(ans, e);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <complex>
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  int n, k;
  std::cin >> n >> k;
  int ans = 0;
  for (int i = 0; n >= std::pow(k, i); i++) {
    ans = i;
  }

  std::printf("%d\n", ans + 1);
  return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder.Problems
{
    public class ProblemB
    {
        public static void Main(string[] args)
        {
            var s = new SolveB();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = 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(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(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[] GetLongArray(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[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveB
    {
        public void Solve()
        {
            var cin = new ProblemB.Scanner();
            var n = cin.NextInt();

            var result = GetAnswer(n);
            Console.WriteLine(result);
        }

        public long GetAnswer(int n)
        {
            long sum = 0;
            for (var i = 1; i <= n; i++)
            {
                if (i % 3 != 0 && i % 5 != 0) { sum += i; }
            }
            return sum;
        }
    }
}


Measured memory_bytes: 27484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
int ar[N];
int dp[N];
int n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	for (int i = 2; i <= n + 1; i++){
		cin >> ar[i];
	}
	ar[0] = INT_MAX;
	ar[1] = INT_MAX;
	int sum = 0;
	for (int i = 3; i <= n + 1; i++){
		dp[i] = min(dp[i - 1] + abs(ar[i] - ar[i - 1]), dp[i - 2] + abs(ar[i] - ar[i - 2]));
	}
	cout << dp[n + 1] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int h,w,i,p;
	while(1){
		scanf("%d %d",&h,&w);
		if((h*w)==0){break;}
		for(i=0;i<h;i++){
			for(p=0;p<w;p++){
				if((i*p)==0 || i == (h-1) || p == (w-1)){
					printf("#");
				}else{
					printf(".");
				}
			}
		printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
    vector<int> t(5);
    int sum;
    for(int i=0; i<5; i++){
        cin >> t.at(i);
        sum += t.at(i);
    }
    vector<int> t1(5);
    for(int i=0; i<5; i++){
        if(t.at(i) % 10 != 0){
            sum += 10 - (t.at(i) % 10);
        }
    }
    for(int i=0; i<5; i++){
        if(t.at(i) % 10 != 0){
            t1.at(i) = sum - (10 - (t.at(i) % 10));
        }
        else{
            t1.at(i) = sum;
        }
    }
    sort(t1.begin(), t1.end());
    cout << t1.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,i,j;
char s[11];
int main()
{
    cin>>n;
    for(i=sqrt(n);i>=1;--i)
    {
        if(n%i==0)
        {
            j=n/i;
            sprintf(s,"%d",j);
            cout<<strlen(s)<<endl;
            return 0;
        }
    }
    
}

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

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


Measured memory_bytes: 3592
#include<bits/stdc++.h> 
using namespace std; 
  
int a[1000007];
int b[1000007];
// Driver program 
int main() 
{ 
    int n;
    cin>>n;
    int m = 1000001;
    for(int i=0;i <n; i++){
        cin>>a[i];
    }
    int f = 0;
    for(int i=0; i<n; i++){
        int j = a[i];
        if(b[j]==0){
            b[j]=1;
            j = 2*a[i];
            for(; j<m; j+=a[i]){
                b[j] = -1;
            }
        }
        else if(b[a[i]]==1)
            b[a[i]] = 2;
        
    }
    int cnt = 0;
    // for(int i=0; i<100; i++)cout<<b[i]<<" ";
    for(int i=0; i<m; i++){
        if(b[i]==1)
            cnt++;
    }
    cout<<cnt;
} 

Measured memory_bytes: 8280
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define ll long long
#define int long long
#define mp make_pair

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0 || i % 5 == 0){
            continue;
        }
        else{
            sum += i;
        }
    }
    cout << sum;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int m, n, s, t;//?¨????????????¢?¨??????????????????°?¨?????????°
int dis[100][100];//???????¨?
const int vx1[6] = { -1,-1,0,1,0,-1 };//?????????????\???°??¨???????????¶??°??¨
const int vx2[6] = { -1,0,1,1,1,0 };//??????????????¶??°??¨??????????\???°??¨
const int vy[6] = { 0,-1,-1,0,1,1 };
P store[10], plan[10];

void bfs() {
	queue<PP> q;//???????????????y??§?¨????x??§?¨?
	for (int i = 0; i < s; i++) {
		q.push(make_pair(0, make_pair(store[i].first, store[i].second)));
		dis[store[i].first][store[i].second] = -1;//?????§???????????¨?????????-1??¨??????
	}
	while (q.size()) {
		int ct = q.front().first;
		P tmp = q.front().second;
		q.pop();
		for (int i = 0; i < 6; i++) {
			int fy = tmp.first, fx = tmp.second;
			if (fy % 2)fx += vx2[i];
			else fx += vx1[i];
			fy += vy[i];
			if (fy < 0 || fy >= n || fx < 0 || fx >= m)continue;
			if (dis[fy][fx] == 0) {
				dis[fy][fx] = ct + 1;
				q.push(make_pair(ct + 1, make_pair(fy, fx)));
			}
		}
	}
}

int bfs2(int a) {
	int ans = 1;
	queue<PP> q;
	q.push(make_pair(0, plan[a]));
	bool islook[100][100] = {};
	bool f = false;
	for (int i = 0; i < s; i++) {
		if (plan[a] == store[i])f = true;
	}
	if (f)return 0;
	islook[q.front().second.first][q.front().second.second] = true;
	while (q.size()) {
		P tmp = q.front().second;
		int ct = q.front().first;
		q.pop();
		for (int i = 0; i < 6; i++) {
			int fy = tmp.first, fx = tmp.second;
			if (fy % 2)fx += vx2[i];
			else fx += vx1[i];
			fy += vy[i];
			if (fy < 0 || fy >= n || fx < 0 || fx >= m)continue;
			if (!islook[fy][fx] && dis[fy][fx] - ct > 1) {
				ans++;
				islook[fy][fx] = true;
				q.push(make_pair(ct + 1, make_pair(fy, fx)));
			}
		}
	}
	return ans;
}

int main() {
	while (cin >> m >> n, m * n) {
		cin >> s;
		for (int i = 0; i < s; i++) {
			cin >> store[i].second >> store[i].first;
			store[i].first--, store[i].second--;
		}
		cin >> t;
		for (int i = 0; i < t; i++) {
			cin >> plan[i].second >> plan[i].first;
			plan[i].first--, plan[i].second--;
		}
		bfs();//?????????????????????????????¢?????¬???
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans = max(bfs2(i), ans);//??¨????£???°?????????
		}
		cout << ans << endl;
		for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)dis[i][j] = 0;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <cstring>
using namespace std;
const int N=1000010;
char str[N];
int main()
{
    int n;
    cin>>str;
    n=strlen(str);
    int l=0,r=n-1;
    bool h=true;
    while(l<r)
    {
        if(str[l]!=str[r]){
            h=false;
            break;
        }
        l++,r--;
    }
    int ps1=(n-1)/2-1;
    l=0,r=ps1;
    while(l<r)
    {
        if(str[l]!=str[r]){
            h=false;
            break;
        }
        l++,r--;
    }
    ps1=(n+3)/2-1;
    l=ps1,r=n-1;
    while(l<r)
    {
        if(str[l]!=str[r]){
            h=false;
            break;
        }
        l++,r--;
    }
    if(h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
<?php
$N = (int)trim(fgets(STDIN));
//list($X,$N) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$S = trim(fgets(STDIN));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
sort($A);

$mx = max($A);
$chkary = array_fill(0,$mx+1,0);
foreach($A as $v) {
  $j = 1;
  while(1) {
    if ($v*$j>$mx) break;
    $chkary[$v*$j]+=1;
    $j++;
  }
}
$tot = 0;
foreach($A as $v) {
  if ($chkary[$v]==1) $tot++;
}
printf("%d\n",$tot);


Measured memory_bytes: 61244
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    s = list(input())
    t = list(input())

    s_ord = [ord(i) for i in s]
    t_ord = [ord(i) for i in t]
    s_ord.sort()
    t_ord.sort(reverse=True)

    for i in range(min(len(s), len(t))):
        if s_ord[i] < t_ord[i]:
            print("Yes")
            exit(0)
        elif s_ord[i] > t_ord[i]:
            print("No")
            exit(0)

    if len(s) >= len(t):
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 60652
Node = Struct.new(:key, :left, :right)

class Tree
  def initialize
    @root = nil
  end
  
  def insert(key)
    unless @root
      @root = Node.new(key)
      return
    end
    node = @root
    while node
      if key < node.key
        if node.left
          node = node.left
        else
          node.left = Node.new(key)
          break
        end
      else
        if node.right
          node = node.right
        else
          node.right = Node.new(key)
          break
        end
      end
    end
  end
  
  def search(key)
    node = @root
    while node
      if key < node.key
        node = node.left
      elsif key > node.key
        node = node.right
      else
        return node
      end
    end
    nil
  end
  
  def delete(key)
    delete_min = ->(node) {
      return node.right unless node.left
      node.left = delete_min.(node.left)
      node
    }
    del = ->(node) {
      value = nil
      if node
        if key == node.key
          if node.left.nil?
            return node.right
          elsif node.right.nil?
            return node.left
          else
            min_node = search_min(node.right)
            node.key = min_node.key
            node.right = delete_min.(node.right)
          end
        elsif key < node.key
          node.left  = del.(node.left)
        else
          node.right = del.(node.right)
        end
      end
      return node
    }
    
    @root = del.(@root)
  end
  
  def preorder
    traverse = ->(node) {
      if node
        yield(node.key)
        traverse.(node.left)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
  
  def inorder
    traverse = ->(node) {
      if node
        traverse.(node.left)
        yield(node.key)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
  
  private
  
  def search_min(node)
    node = node.left while node.left
    node
  end
end

t = Tree.new

$<.gets.to_i.times do
  com, key = $<.gets.split
  key = key.to_i
  case com
  when "insert" then t.insert(key)
  when "print"
    t.inorder  {|key| print " #{key}"}
    puts
    t.preorder {|key| print " #{key}"}
    puts
  when "find"
    puts t.search(key) ? "yes" : "no"
  when "delete" then t.delete(key)
  end
end


Measured memory_bytes: 31468
#!/usr/bin python3
# -*- coding: utf-8 -*-

# Binary Indexed Tree for Range Add Query
# 1-indexed
#    初期値は a_1 = a_2 = ... = a_n = 0
#    ・add(l,r,x): [l,r) に x を加算する
#    ・sum(i): a_1 + a_2 + ... + a_i を計算する

class BinaryIndexedTree:
    # 初期化処理
    def __init__(self, size):
        self.size = size
        self.dat = [0]*(size+1)
        self.depth = size.bit_length()

    def init(self, a):
        for i, x in enumerate(a):
            self.add(i, x)

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.dat[i] += x
            i += i & -i # 更新すべき位置

    def sum(self, r):
        r += 1
        ret = 0
        while r>0:
            ret += self.dat[r]
            r -= r & -r # 加算すべき位置
        return ret

# sum(i) >= vとなる最小のindex
    def lower_bound(self, x):
        """ 累積和がx以上になる最小のindexと、その直前までの累積和 """
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.dat[k] < x:
                sum_ += self.dat[k]
                pos += 1 << i
        return pos  #0-indexed

#### for debug
    def get_original_sequence(self):
        ret = self.get_aggrigate_sequence()
        for i in range(self.size-1, 0, -1):
            ret[i] -= ret[i-1]
        return ret

    def get_aggrigate_sequence(self):
        return [bit.sum(i) for i in range(self.size)]

    def __str__(self):
        seq = self.get_original_sequence()
        ret = 'original :' + ' '.join(map(str, seq))
        ret += '\n'
        seq = self.get_aggrigate_sequence()
        ret += 'aggrigate:' + ' '.join(map(str, seq))
        return ret

class BitRAQ:
    def __init__(self, size):
        self.size = size
        self.bit0 = BinaryIndexedTree(size)
        self.bit1 = BinaryIndexedTree(size)

    def init(self, a):
        self.bit0.init(a)

    def add(self, l, r, x):
        self.bit0.add(l, -x * (l - 1))
        self.bit0.add(r, x * (r - 1))
        self.bit1.add(l, x)
        self.bit1.add(r, -x)

    def sum(self, r):
        return self.bit0.sum(r) + self.bit1.sum(r) * r
##################################
mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int,input().split())) for _ in range(k)]
bit = BitRAQ(2*10**5+100)
bit.bit0.add(1,1)
for i in range(1,n):
    cnt = bit.sum(i) - bit.sum(i-1)
    cnt %= mod
    for l, r in lr:
        bit.add(i+l, i+r+1, cnt)
ret = bit.sum(n) - bit.sum(n-1)
ret %= mod
print(ret)

Measured memory_bytes: 110568
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_edges3(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n;
    cin >> n;
    ll arr[n];
    rep(I, 0, n) cin >> arr[I];

    ll mx = 0;
    ll res = 0;

    rep(i, 0, n){
        if(arr[i] < mx) res += mx - arr[i];
        else mx = max(mx, arr[i]);
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 5176