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

int main(){
    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        l = max(a, l);
        r = min(b, r);
    }
    cout << max(0, r-l+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, a = 0, b = 0;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		if (a < p[i])a = p[i];
		b += p[i];
	}
	b -= a / 2;
	cout << b << endl;
}

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

int main()
{
  int a,b,c,d,e;
  cin >>a>>b>>c>>d>>e;
  int a1,b1,c1,d1,e1;
  int a2,b2,c2,d2,e2;
  a1=a%10;
  a2=a/10;
  if(a1!=0)a2++;
  b1=b%10;
  b2=b/10;
  if(b1!=0)b2++;
  c1=c%10;
  c2=c/10;
  if(c1!=0)c2++;
  d1=d%10;
  d2=d/10;
  if(d1!=0)d2++;
  e1=e%10;
  e2=e/10;
  if(e1!=0)e2++;
  int hasuu;
  int kotae;
  if(a1+b1+c1+d1+e1==0){
    hasuu=0;
    kotae=(a2+b2+c2+d2+e2)*10;
    cout<<kotae<<endl;
    return 0;
  }else{
    if(a1==0)a1=INT_MAX;
    if(b1==0)b1=INT_MAX;
    if(c1==0)c1=INT_MAX;
    if(d1==0)d1=INT_MAX;
    if(e1==0)e1=INT_MAX;
    hasuu=min({a1,b1,c1,d1,e1});
    kotae=(a2+b2+c2+d2+e2)*10+hasuu-10;
    cout<<kotae<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {
		int N = s.nextInt();
		int index = 0;
		int ans = 0;

		while ((++index) * (index) <= N) {
			ans = index * index;
		}
		System.out.println(ans);

	}
}

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

int main(void)
{
	int a, b;
	int n;
	int i, j;
	int work;
	long int x;
	long int r, d;
	
	scanf("%ld%ld%ld", &r, &d, &x);
	
	for(i = 0; i < 10; i++) {
		x = r * x - d;
		printf("%ld\n", x);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    ll N;
    cin >> N;
    int c = 0;
    int ans = 0;
    int tmp = 0;
    while(N){
        tmp = N % 10;
        ans += tmp;
        N /= 10;
        c ++;
    }
    ans = max(ans, (c - 1) * 9 + tmp - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin>>X;
  if(X==3){
    cout<<"YES"<<endl;
  }
  else if(X==5){
    cout<<"YES"<<endl;
  }
  else if(X==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

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

const ll N = 3e5;

ll t, a[N], b[N], pfa[N], pfb[N];
int n, m, ans;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> t;
    for (int i = 0; i < n; ++i)
	cin >> a[i];
    for (int i = 0; i < m; ++i)
	cin >> b[i];
    for (int i = 0; i < n; ++i)
	pfa[i] = (i - 1 < 0 ? 0 : pfa[i - 1]) + a[i];
    for (int i = 0; i < m; ++i)
	pfb[i] = (i - 1 < 0 ? 0 : pfb[i - 1]) + b[i];

    for (int i = 0; i < n; ++i)
	if (pfa[i] <= t)
	    ans = max(ans, i + 1);
    for (int i = 0; i < m; ++i)
	if (pfb[i] <= t)
	    ans = max(ans, i + 1);

    for (int i = 0; i < n; ++i) {
	ll ost = t - pfa[i];
	int l = 0, r = m - 1;

	while (l < r) {
	    int md = (l + r + 1) / 2;

	    if (pfb[md] <= ost) l = md;
		else r = md - 1;
	}

	if (pfb[l] > ost)
	    continue;

	ans = max(ans, i + 1 + l + 1);
    }

    for (int i = 0; i < m; ++i) {
	ll ost = t - pfb[i];
	int l = 0, r = n - 1;

	while (l < r) {
	    int md = (l + r + 1) / 2;

	    if (pfa[md] <= ost) l = md;
		else r = md - 1;
	}

	if (pfa[l] > ost)
	    continue;

	ans = max(ans, i + 1 + l + 1);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 9872
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

struct lft {
	int l;
	int r;
	int index;
	bool operator < (const lft& lf)const {
		return l < lf.l;
	}
	bool operator > (const lft& lf)const {
		return l > lf.l;
	}
};

struct rht {
	int l;
	int r;
	int index;
	bool operator < (const rht& rh)const {
		return r < rh.r;
	}
	bool operator > (const rht& rh)const {
		return r > rh.r;
	}
};

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

	cin >> N;
	long long int ans = MOD * MOD;
	vector<lft>l(N);
	vector<rht>r(N);
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		lft lf;
		lf.l = L;
		lf.r = R;
		lf.index = i;
		rht rh;
		rh.l = L;
		rh.r = R;
		rh.index = i;
		l[i] = lf;
		r[i] = rh;
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	sort(r.begin(), r.end());
	long long int  p = 0;
	int lindex = 0;
	int rindex = 0;
	vector<bool>used(N);
	long long int box = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2) {
			while (used[l[lindex].index]) {
				lindex++;
			}
			used[l[lindex].index] = true;
			if (l[lindex].l <= p && p <= l[lindex].r) {
				continue;
			}
			if (abs(p - l[lindex].l) > abs(p - l[lindex].r)) {
				box += abs(p - l[lindex].r);
				p = l[lindex].r;
			}
			else {
				box += abs(p - l[lindex].l);
				p = l[lindex].l;
			}
		}
		else {
			while (used[r[rindex].index]) {
				rindex++;
			}
			used[r[rindex].index] = true;
			if (r[rindex].l <= p && p <= r[rindex].r) {
				continue;
			}
			if (abs(p - r[rindex].l) > abs(p - r[rindex].r)) {
				box += abs(p - r[rindex].r);
				p = r[rindex].r;
			}
			else {
				box += abs(p - r[rindex].l);
				p = r[rindex].l;
			}
		}
	}
	box += abs(p);
	ans = min(box, ans);
	for (int i = 0; i < N; i++) {
		used[i] = false;
	}
	lindex = 0;
	rindex = 0;
	box = 0;
	p = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			while (used[l[lindex].index]) {
				lindex++;
			}
			used[l[lindex].index] = true;
			if (l[lindex].l <= p && p <= l[lindex].r) {
				continue;
			}
			if (abs(p - l[lindex].l) > abs(p - l[lindex].r)) {
				box += abs(p - l[lindex].r);
				p = l[lindex].r;
			}
			else {
				box += abs(p - l[lindex].l);
				p = l[lindex].l;
			}
		}
		else {
			while (used[r[rindex].index]) {
				rindex++;
			}
			used[r[rindex].index] = true;
			if (r[rindex].l <= p && p <= r[rindex].r) {
				continue;
			}
			if (abs(p - r[rindex].l) > abs(p - r[rindex].r)) {
				box += abs(p - r[rindex].r);
				p = r[rindex].r;
			}
			else {
				box += abs(p - r[rindex].l);
				p = r[rindex].l;
			}
		}
	}
	box += abs(p);
	ans = max(box, ans);
	cout << ans << endl;
	return 0;
}

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

int main() {
    cout.tie(0)->sync_with_stdio(0);
    int N; cin >> N;
    vector<int> values(N);
    for (int i = 0; i < N; ++i) cin >> values[i];
    for (int i = 1; i < N; ++i) values[i] += values[i-1];
    int M;
    cin >> M;
    for (int i = 0; i < M; ++i) {
        int pos, delta;
        cin >> pos >> delta;
        pos--;
        if (pos == 0) {
            cout << (values[pos] > delta ? values[N-1] - (values[0] - delta) :
                    values[N-1] + (delta - values[0])) << '\n';
        }
        else {
            if (values[pos] - values[pos-1] < delta) {
                cout << (values[N-1] + delta - (values[pos] - values[pos-1])) << '\n';
            }
            else {
                cout << (values[N-1] - (values[pos] - values[pos-1] - delta)) << '\n';
            }
        }
    }
}


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

using namespace std;
#define ll long long
const int maxn=1e3+5;
ll dp[maxn][maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	for(int i=0;i<maxn;i++)
    {
        for(int j=i;j<maxn;j++)
        {
            if(i==0)
            {
                dp[i][j]=1;
            }
            else
            {
                dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
            }
        }
    }
	int n,m;
	cin>>n>>m;
	cout<<dp[2][n]+dp[2][m]<<'\n';










}



Measured memory_bytes: 7424
#include <iostream>

using namespace std;

int main( void )
{
	int N, A, B, C, X;
	int Y[100];
	while(cin >> N >> A >> B >> C >> X,
		N | A | B | C | X)
	{
		for(int i=0; i < N; ++i) cin >> Y[i];
		int idx, count;
		idx = count = 0;
		if(X == Y[idx]) ++idx;
		while(idx < N) {
			++count;
			X = (A * X + B) % C;
			if(X == Y[idx]) ++idx;
			if(count > 10000) break;
		}
		if(count <= 10000)
			cout << count << endl;
		else
			cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "NO" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,W,N; cin>>H>>W>>N;
    ll sx,sy; cin>>sx>>sy;
    string S,T; cin>>S>>T;
    ll u=0,d=H+1,l=0,r=W+1;
    repr(i,N-1,0){
        if(T[i]=='U') d=min(d+1,H+1);
        if(T[i]=='D') u=max(u-1,0LL);
        if(T[i]=='L') r=min(r+1,W+1);
        if(T[i]=='R') l=max(l-1,0LL);

        if(S[i]=='U') u++;
        if(S[i]=='D') d--;
        if(S[i]=='L') l++;
        if(S[i]=='R') r--;

        if(u+1>=d or l+1>=r) dame;
    }
    if(sx<=u or sx>=d or sy<=l or sy>=r) dame;
    cout<< "YES" <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 920
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mod 1000000007
#define M 998244353
#define PI 3.141592653589793
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int n;
    IN n;
    vector<int> a(n);
    bool flag=true;
    loop(i,0,n)
    {
        IN a[i];
        if(a[i]%2==0)
        {
            if(a[i]%3==0 || a[i]%5==0)
            {
                
            }
            else
            {
                flag=false;
            }
        }
    }
    if(flag)
    {
        OUT "APPROVED"<<endl
    }
    else
    {
        OUT "DENIED"<<endl
    }
    return 0;
}


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

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    if(s[0]==t[0])ans++;
    if(s[1]==t[1])ans++;
    if(s[2]==t[2])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,d=0;
    scanf("%d",&n);
    while(n!=0)
    {
        i=n%10;
        if(i==7){printf("Yes");d=1;break;}
        n/=10;
    }
    if(d!=1)printf("No");
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    if (a * b % 2 != 0) {
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
    return 0;
}


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

L=[]

for i in range(N):
  S,P=input().split()
  L=L+[[S,-int(P),i]]
  
#print(L)
 
L.sort()

#print(L)
#print(L[1][1])

for z in range(N):
  print(L[z][2]+1)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
LL s;
int n,L,T;
struct chj{
	int x,f;
	bool operator <(const chj b)const{return x<b.x;}
}a[maxn];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	n=read();L=read();T=read();
	for (int i=0;i<n;i++){
		a[i]=(chj){read(),read()};
		if (a[i].f==1) s+=(a[i].x+T)/L,a[i].x=(a[i].x+T)%L;
		else{s+=(a[i].x-T)/L;a[i].x=(a[i].x-T)%L;if(a[i].x<0) s--,a[i].x+=L;}
	}
	sort(a,a+n);
	s=(s%n+n)%n;
	for(int i=s;i<n;i++) printf("%d\n",a[i].x);
	for(int i=0;i<s;i++) printf("%d\n",a[i].x);
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<map>

using namespace std;

string str;
map<char, int> record;

int main() {
    cin >> str;
    for(auto s : str) {
        record[s]++;
    }
    for(auto c : record) {
        if(c.second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <complex>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = complex<double>;

const double INF = 1010;

double dist2(const P& a, const P& b) {
  double dx = a.real() - b.real();
  double dy = a.imag() - b.imag();
  return dx * dx + dy * dy;
}

bool with_in_all(const vector<P>& ps, const P& c, double R) {
  for (auto p : ps) {
    if (dist2(p, c) > R * R + 1e-9) return false;
  }
  return true;
}

bool check(const vector<P>& ps, const P& a, const P& b, double R) {
  P m = (a + b) / 2.0;
  double l = dist2(b, m);
  if (R * R < l) return false;
  double d = sqrt(R * R / l - 1);
  double dx = d * (b.imag() - m.imag());
  double dy = d * (b.real() - m.real());
  P p1 = m + P(dx, -dy), p2 = m + P(-dx, dy);
  return with_in_all(ps, p1, R) || with_in_all(ps, p2, R);
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<P> ps(N);
    for (auto& p : ps) {
      double x, y;
      cin >> x >> y;
      p = P(x, y);
    }
    double fail = 0, pass = INF;
    for (int t = 0; t < 100; t++) {
      double R = (fail + pass) / 2;
      bool ok = false;
      for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
          ok |= check(ps, ps[i], ps[j], R);
        }
      }
      if (ok) {
        pass = R;
      } else {
        fail = R;
      }
    }
     printf("%.20f\n", pass);
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  char x;
  std::cin >> x;
  if(x == 'A') std::cout << 'T' << std::endl;
  else if(x == 'T') std::cout << 'A' << std::endl;
  else if(x == 'C') std::cout << 'G' << std::endl;
  else std::cout << 'C' << std::endl;
}

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

struct Y{
  string n; int b,e;
  Y(void){}
  Y(string a,int x,int y):n(a),b(x),e(y){}
  bool operator<(const Y a)const{return b<a.b;}
};

int main(){
  int n,q,i;
  int a,b,y;
  string name;
  Y e[1010];
  std::ios::sync_with_stdio(false);
  while(cin >> n >> q, n+q){
    for(i=0;i<n;i++){
      cin >> name >> a >> b;
      e[i] = Y(name,b-a+1,b);
    }
    sort(e,e+n);
    for(i=0;i<q;i++){
      cin >> y;
      int l=-1,r=n;
      while(r-l>1){
	int m = (l+r)/2;
	if(e[m].e>=y)r = m;
	else l = m;
      }

      if(r==n || e[r].b>y)cout << "Unknown\n";
      else cout << e[r].n << " " << y-e[r].b+1 << endl;
    }
  }
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<double, double>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979
#define MOD (ll)1000000007

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>A(N);
  vector<ll>dp(K+1);
  rep(i,N){cin>>A[i];}
  rep(i,K+1){dp[i]=0ll;}
  dp[0]=1ll;
  rep(i,N){
    ll x[K+1],y[K+1];
    rep(j,K+1){
      x[j]=0ll;y[j]=0ll;
    }
    ll p=A[i];
    rep(j,K+1){
      x[j]+=dp[j];
      if(j+p+1<=K){x[j+p+1]-=dp[j];}
    }
    y[0]=x[0];
    
    rep(j,K){
      y[j+1]=y[j]+x[j+1];
      y[j+1]%=MOD;
    }
    rep(j,K+1){
      dp[j]=y[j];
      dp[j]=(dp[j]+MOD)%MOD;
    }
  }
  cout<<dp[K];
}


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

using namespace std;

vector<vector<int>> G;

int dfs() {

}

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

    G.assign(N, vector<int>());

    int x, y;
    for(int i = 0; i < N-1; i++) {
        cin >> x >> y;
        x--, y--;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }

    queue<int> q1, q2, tmp;

    q1.push(0);
    q2.push(N-1);

    vector<bool> used(N, false);

    int fen = 0, snu = 0;

    bool turn = true;
    while(true) {
        if(fen + snu == N) {
            break;
        }
        if(turn) {
            while(!q1.empty()) {
                fen++;
                int v = q1.front();
                used[v] = true;
                q1.pop();

                for(int u : G[v]) {
                    if(used[u]) continue;
                    used[u] = true;
                    tmp.push(u);
                } 
            }
            while(!tmp.empty()) {
                q1.push(tmp.front());
                tmp.pop();
            }
        } else {
            while(!q2.empty()) {
                snu++;
                int v = q2.front();
                used[v] = true;
                q2.pop();

                for(int u : G[v]) {
                    if(used[u]) continue;
                    used[u] = true;
                    tmp.push(u);
                } 
            }
            while(!tmp.empty()) {
                q2.push(tmp.front());
                tmp.pop();
            }

        }

        turn = !turn;
    }

    fen--, snu--;

    if(fen > snu) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl; 
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <stdio.h>
#include<cstdlib>
#include<math.h>
#include<complex>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)cout << a-1 << endl;
	else cout << a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
 
        int k = scan.nextInt();
        int x = scan.nextInt();
		for(int i = x - k + 1; i <  k + x; i++){
          System.out.print(i);
          System.out.print(" ");
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    long long int x,k,d,ans,a;
    cin>>x>>k>>d;
    
    //if(x>=k*d){cout<<x-k*d<<endl;return 0;}
    //else{
        
    //}
    x=abs(x);
    ans=x;
    if(k<x/d){
        x-=k*d;cout<<x<<endl;return 0;
    }
    else{
        a=x/d;x-=a*d;k=k-a;
    }
    if(k%2==0)a++;
    else if(k%2==1){x=abs(x-d);}
    
    
    cout<<x<<endl;
    return 0;
}



Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

int main() {
    ll n, m;
    cin >> n >> m;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    UnionFind Uni(n+2);
    Uni.init(n+2);

    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        Uni.unite(x, y);
    }

    vvl G(n);
    ll cnt = 0;  // 森の連結成分の個数
    rep(v, n) {
        if(Uni.root(v) == v) {
            cnt++;
        }
        ll p = Uni.root(v);
        G[p].pb(a[v]);
    }

    if(2*(cnt-1) > n) {
        out("Impossible");
        re0;
    }

    if(cnt == 1) {
        out(0);
        re0;
    }

    ll ans = 0;
    vl vt;
    rep(v, n) {
        if(Uni.root(v) == v) {
            sort(all(G[v]));
            ans += G[v][0];
            exrep(j, 1, G[v].size()-1) {
                vt.pb(G[v][j]);
            }
        }
    }

    sort(all(vt));
    rep(i, cnt-2) {
        ans += vt[i];
    }

    out(ans);
    re0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		scan.close();

		System.out.println((Math.min(b, d)-Math.max(a, c)>0)? Math.min(b, d)-Math.max(a, c):"0");

	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#define llint long long

using namespace std;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	llint ans = 0;
	for(int i = 0; i < s.size()/2; i++){
		if(s[i] != s[(int)s.size()-1-i]) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k;

int main () {
  cin>>a>>b>>c>>k;
  for (int i=0;i<k;i++) {
    if (2*a+b+c>=a+2*b+c&&2*a+b+c>=a+b+2*c) a*=2;
    else if (a+2*b+c>=2*a+b+c&&a+2*b+c>=a+b+2*c) b*=2;
    else if (a+b+2*c>=2*a+b+c&&a+b+2*c>=a+2*b+c) c*=2;
  }
  cout<<a+b+c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>
#include <string>
#include <stack>
#include <queue>

#define INT_MAX 2147483647
#define INT_MIN -2147483647

#define NUM 10000
#define INVALID_IDX -1
using namespace std;

struct BTree
{
private:
	struct BTreeNode{
		int p, l, r;
	};
	BTreeNode data[25];
	int len;
	int rootIdx;
	int D[25], H[25];

	void getDepth(int idx, int depth)
	{
		D[idx] = depth;
		if (data[idx].l != INVALID_IDX) getDepth(data[idx].l, depth + 1);
		if (data[idx].r != INVALID_IDX) getDepth(data[idx].r, depth + 1);
	}

	int getHeight(int idx)
	{
		if (idx == INVALID_IDX) return -1;

		int hl = getHeight(data[idx].l);
		int hr = getHeight(data[idx].r);

		H[idx] = max(hl, hr) + 1;
		return H[idx];
	}

	int getSibling(int idx)
	{
		int pIdx = data[idx].p;

		if (pIdx == INVALID_IDX) return INVALID_IDX;
		if (idx == data[pIdx].l && data[pIdx].r != INVALID_IDX)
			return data[pIdx].r;
		if (idx == data[pIdx].r && data[pIdx].l != INVALID_IDX)
			return data[pIdx].l;
		return INVALID_IDX;
	}

	void markHead()
	{
		for (int i = 0; i < len; ++i)
		{
			if (data[i].p == INVALID_IDX)
			{
				rootIdx = i;
				break;
			}
		}
	}

	void printNode(int idx)
	{
		cout << "node " << idx << ": ";
		cout << "parent = " << data[idx].p << ", ";
		cout << "sibling = " << getSibling(idx) << ", ";
		
		int degree = 0;
		if (data[idx].l != INVALID_IDX) degree++;
		if (data[idx].r != INVALID_IDX) degree++;
		cout << "degree = " << degree << ", ";

		cout << "depth = " << D[idx] << ", ";
		cout << "height = " << H[idx] << ", ";

		string type = "";
		if (data[idx].p == INVALID_IDX) type = "root";
		else if (data[idx].l != INVALID_IDX || data[idx].r != INVALID_IDX) type = "internal node";
		else type = "leaf";
		cout << type << endl;
	}

public:
	BTree()
	{
		for (int i = 0; i < 25; ++i)
		{
			data[i].l = data[i].r = data[i].p = INVALID_IDX;
		}
	}

	void construct()
	{
		int idx, lc, rc;
		cin >> len;
		for (int i = 0; i < len; ++i)
		{
			cin >> idx >> lc >> rc;
			data[idx].l = lc;
			data[idx].r = rc;

			data[lc].p = idx;
			data[rc].p = idx;
		}
		markHead();
		getDepth(rootIdx, 0);
		getHeight(rootIdx);
	}

	void print()
	{
		for (int i = 0; i < len; ++i)
			printNode(i);
	}
};


int main()
{
	BTree t;
	t.construct();
	t.print();
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <math.h>

int main(void) {
	int a,b,c,n;
	scanf("%d",&n);
	while (n--){
		scanf("%d %d %d",&a,&b,&c);
		if ((c*c-a*a-b*b)*(a*a-b*b-c*c)*(b*b-c*c-a*a)==0){
			puts("YES");
		}else{
			puts("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> vect(3);
    for(int i=0;i<3;i++){
        cin>>vect[i];
    }
    int go=0,nana=0;
    for(int i=0;i<3;i++){
        if(vect[i]==5)go++;
        else if(vect[i]==7)nana++;

    }
    if(nana==1&&go==2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;



}

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

int main(){
    int m,f,b;
    cin>>m>>f>>b;
    if(b<=m){
        cout<<0<<endl;
    }else if((m+f)>=b){
        cout<<b-m<<endl;
    }else{
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
n = int(input())
table = [0]*n
for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            a = (x+y+z)**2 - x*y - y*z - z*x
            if a <= n:
                table[a-1] += 1
for a in table:
    print(a)

Measured memory_bytes: 9188
#include <stdio.h>

int main(){

	int N;
	double L[101];
	double MAX;
	double other=0;
	int i;
	
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%lf",&L[i]);
	
	MAX=L[0];
	for(i=0;i<N-1;i++){
		if(MAX<L[i+1])
			MAX=L[i+1];
	}
	
	for(i=0;i<N;i++)
		other+=L[i];
	other-=MAX;
	
	if(MAX < other){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
	
}

Measured memory_bytes: 128
def resolve():
    x, y = map(int, input().split())
    c = []
    for i in range(1 << 2):
        ans = 0
        _x, _y = x, y
        if i & 1:
            _x *= -1
            ans += 1
        if i & 2:
            _y *= -1
            ans += 1
        if _x <= _y:
            ans += _y - _x
            c.append(ans)
    print(min(c))


if __name__ == "__main__":
    resolve()


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

int main(){
  int a,b,t;cin>>a>>b>>t;
  cout << (t/a)*b << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int room[10][3][4] = {0};
	int n,b,f,r,v;
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		room[--r][--f][--b] += v;
	}
	for(int i = 0;i < 4;++i)
	{
		for(int j = 0;j < 3;++j)
		{
			for(int k = 0; k < 10;++k)
			{
				printf(" %d",room[k][j][i]);
			}
			printf("\n");
		}
		if(i == 3)break;
		printf("####################\n");
	}
	return 0;
}


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

using namespace std;
typedef long long int ll;
vector<vector<int>>v;
vector<int>atime,btime;

int n;
int nowtime = 1;

void func(int i)
{
    if(atime[i] == 0) 
    {
        atime[i] = nowtime;
        nowtime++;
    }
    else return;
    for(auto x:v[i]) func(x);
    btime[i] = nowtime;
    nowtime++;
}

int main()
{
    int n;
    cin >> n;
    v.resize(n);
    atime.resize(n);
    btime.resize(n);
    for(int i = 0; i < n; i++)
    {
        atime[i]=0;
        btime[i]=0;
        int u,k;
        cin >> u >> k;
        for(int j = 0; j < k; j++)
        {
            int p;
            cin >> p;
            p--;
            v[i].push_back(p);
        }
    }
    for(int i = 0; i < n; i++) func(i);
    for(int i = 0; i < n; i++) cout << i+1 << " " << atime[i] << " " << btime[i] << endl; 
    
}



Measured memory_bytes: 3176
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*(n) for i in range(n)]
if n%2 == 0:
    for i in range(n):
        dp[i][i] = -a[i]
else:
    for i in range(n):
        dp[i][i] = a[i]
for i in range(1,n):
    for j in range(n-i):
        if (n-i)%2==1:
            dp[j][i+j] = max(dp[j][i+j-1]+a[i+j],dp[j+1][i+j]+a[j])
        else:
            dp[j][i+j] = min(dp[j][i+j-1]-a[i+j],dp[j+1][i+j]-a[j])
print(dp[0][-1])


Measured memory_bytes: 112988
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        String atoz = "abcdefghijklmnopqrstuvwxyz";

        String str = sc.nextLine();
        for (String s : str.split("")) {
            atoz = atoz.replace(s, "");
        }

        if (atoz.length() != 0) {
            System.out.println(str + atoz.charAt(0));
            return;
        } else {
            int max = -1;
            char maxc = ' ';
            for (int i = 25; i >= 0; i--) {
                char tmp = str.charAt(i);
                for (int j = i - 1; j >= 0; j--) {
                    if (tmp > str.charAt(j)) {
                        if (max < j) {
                            max = j;
                            maxc = tmp;
                        }
                    }
                }
            }

            if (max != -1) {
                System.out.println(str.substring(0, max) + maxc);
            } else {
                System.out.println(-1);
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 23636
#include <stdio.h>
int main(void) {
  int days, num;
  int homework, i, sum_day=0;
  scanf("%d %d", &days, &num);
  for(i=0;i<num; i++){
    scanf("%d", &homework);
  sum_day+=homework;
  }
  if(days-sum_day < 0)
  printf("-1\n");
  else
  printf("%d\n", days - sum_day);
  return 0;
}

Measured memory_bytes: 1684
#https://atcoder.jp/contests/abc157/tasks/abc157_c
n,m=map(int,input().split())
s=[0]*m
c=[0]*m
for i in range(m):
    s[i],c[i]=map(int, input().split())

for num in range(1000):
    if len(str(num))==n:
        digit=[0]*n
        l=n
        k=num
        while l>0:
            digit[l-1]=k%10
            k=k//10
            l-=1
        flag=0
        for j in range(m):
            if digit[s[j]-1]==c[j]:
                flag+=1
        if flag==m:
            print(num)
            exit()
print("-1")


Measured memory_bytes: 39792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pi              pair<int,int>
#define vi              vector<int>
#define mi              map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1N
#define loop(i,a,b)     for(int i=a;i<b;i++)

void FIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int32_t main(){
    FIO();
    string s; cin >> s;
    int p = s.length();
    for(int i=0;i<p;i++){
        if(s[i] == '?' && s[i-1] == 'P'){
            s[i] = 'A' + 3;
        }
        else if(s[i] == '?'){
            s[i] = 'A' + 3;
        }

    }
    cout<<s;
}


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 3768
n, a, b = gets.split(" ").map(&:to_i)
 
if n % (a + b) == 0
  puts (n / (a + b)) * a
else
  if n % (a + b) > a
    puts (n / (a + b)) * a + a
  else
    puts (n / (a + b)) * a + n % (a + b)
  end
end

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

bool comp(vector<int> lhs, vector<int> rhs) {
  if (lhs[0] != rhs[0]) {
    return lhs[0] > rhs[0];
  } else if (lhs[1] != rhs[1]) {
    return lhs[1] < rhs[1];
  } else {
    return lhs[2] < rhs[2];
  }
}

int main(void) {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if(!t && !p && !r) break;
    VVI record(r);
    REP(i, r) {
      int tid, pid, Time, message;
      string mess;
      cin >> tid >> pid >> Time >> mess;
      if (mess == "CORRECT")
        message = 1;
      else
        message = 0;
      record[i] = (vector<int>{Time, tid, pid, message});
    }
    sort(ALL(record));

    VVI ans(t, VI(3, 0));
    int pen[55][15] = {0};
    REP(i, t) ans[i][2] = i + 1;
    REP(i, r) {
      int Time = record[i][0], tid = record[i][1], pid = record[i][2];
      tid--;
      if (record[i][3] == 1) {
        ans[tid][0]++;
        ans[tid][1] += pen[tid][pid] * 1200 + Time;
      } else {
        pen[tid][pid]++;
      }
      //cout << tid << " " << pid << " " << ans[tid][2] << " " << ans[tid][0]
           //<< " " << ans[tid][1] << endl;
    }

    sort(ALL(ans), comp);

    REP(i, t) {
      cout << ans[i][2] << " " << ans[i][0] << " " << ans[i][1] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3156
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


template<class T>
T gcd(T a,T b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(a%b,b);
}

bool solve(){
  ll n,x;cin>>n>>x;
  ll ans=0;
  rep(i,n){
    ll a;cin>>a;
    ans=gcd(ans,abs(x-a));
  }
  cout<<ans<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


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

int main(){
    string s,p;
    cin >> s >> p;

    s=s+s;
    if(s.find(p)!=string::npos) {
        cout << "Yes" << endl;
    }else {cout << "No" << endl;}

    return 0;
    }


Measured memory_bytes: 3204
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class solve{
  constructor(){
    this.a = Array(60).fill(0n);
  }
  add(s){
    var c = 0, t = BigInt(s);
    for(var i = 60; i--;){
      if((t >> BigInt(i)) & 1n){
        if(this.a[i])t ^= this.a[i];
        else c = Math.max(i,c);
      }
    }
    if(t)this.a[c] = t;
  }
  has(s){
    var t = BigInt(s);
    for(var i = 60; i--;){
      if((t >> BigInt(i)) & 1n){
        if(this.a[i])t ^= this.a[i];
        else return false;
      }
    }
    return true;
  }
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var t = next();
  for(var i = 0; i < t; i++){
    var n = next();
    var a = nexts(n,1);
    var s = nextstr();
    var flag = 0;
    var f = new solve();
    for(var j = n; j--;){
      if(s[j] === "0")f.add(a[j]);
      else{
        if(!f.has(a[j])){
          flag = 1;
          break;
        }
      }
    }
    console.log(flag);
  }
}

Measured memory_bytes: 38240
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1000
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            ans += (A[i + 1] - A[i]) * (ans // A[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9560
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve():
    try:
        r = int(input())

        print(pow(r, 2))

    except IndexError as err:
        print("インデックスエラー:", err.args[0])


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """2"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """100"""
        output = """10000"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main(verbosity=2)


Measured memory_bytes: 75008
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

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

void solve()
{
    //If you cannot approach a problem
    //directly in the way it is proposed then try to think from backwards
    int n;
    cin>>n;
    if(n >= 30){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){

  int N, tmp;
  string s;
  int ans=0;
  cin >> N >> s;
  vector<int> s_int(N);
  rep(i,N) s_int[i] = s[i] - '0';

  for(int i=0; i<10; i++){
    auto itr_i = find(s_int.begin(),s_int.end(),i);
    if(itr_i == s_int.end()) continue;
    itr_i++;
    for(int j=0; j<10; j++){
      auto itr_j = find(itr_i,s_int.end(),j);
      if(itr_j == s_int.end()) continue;
      itr_j++;
      for(int k=0; k<10; k++){
        if(find(itr_j,s_int.end(),k) != s_int.end()){
          ans++;
        }
      }
    }
  }


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

Measured memory_bytes: 384