akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {

  string s;
  cin >> s;

  int p = 0;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'p') {
      p++;
    }
  }

  cout << s.size() / 2 - p << endl;

}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int[] ary = new int[5];
        for(int i=0; i<5; i++){
            ary[i] = Integer.parseInt(sc.next());
        }

        for(int i=0; i<5; i++){
            if(ary[i] == 0){
                System.out.println((i+1));
            }
        }
    }
}

Measured memory_bytes: 35628
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    }

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

	/**
	 * @param args
	 * @throws IOException
	 */
	 

	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		String se = s.next();
		String a = s.next();
		int k=0,max=Integer.MAX_VALUE,c=0;
		
		for(int i=0;i<=se.length()-a.length();i++) {
			k=0;
			int p=i;
			for(int j=0;j<a.length();j++) {
				if(se.charAt(p++)!=a.charAt(j))k++;
			}
//			System.out.println(k);
			max = Math.min(max, k);
		}
		System.out.println(max);
	}
}
	



Measured memory_bytes: 32772
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	int n,i,mid=0,k,c[26]={0},flag=0;
    string a;
    cin>>a;
    
	/*if(n>2){
		for(i=1;i<n;i++)
		{
			k=1;
			flag=0;
			if(i-k>=0&&i+k<=n-1&&a[i-1]!=a[i+1])
			{
				mid=i;
				while(1){
					if(mid-k>0&&mid+k<n-1){
						if(a[mid-k]!=a[mid+k])
						{
							k++;
						}
						else break;
					}
					else break;
				}
				for(int j=mid-k;j<=mid+k;j++){
					c[a[j]-'a']++;
				}
				sort(c,c+26);
				if(c[25]*2>=(2*k+1)){
					flag=1;
					break;
				}
				else{
					for(int j=0;j<26;j++) c[j]=0;
				}
			}
			if(flag!=0) break;
		}
		if(flag!=0){
			printf("%d %d\n",mid-k+1,mid+k+1);
		}
		else printf("-1 -1\n");
	}
	else{
		if(a[0]==a[1])
			printf("-1 -1\n");
		else printf("1 2\n");
	}*/
	for(int i=0;i<a.size()-1;i++){
        if(a[i]==a[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            break;
        }
        else if(i<a.size()-2&&a[i]==a[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            break;
        }
    }
    if(!flag)
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

struct D
{
  bool movable[20][20];
};

int const dir[][2] = {
  {  1, 0 },
  { -1, 0 },
  { 0,  1 },
  { 0, -1 }
};

void count( D& d, int& num, int const px, int const py )
{
  if ( !d.movable[px][py] )
    return;

  ++num;
  d.movable[px][py] = false;

  for( int i=0; i<4; ++i ) {
    int const npx = px + dir[i][0];
    int const npy = py + dir[i][1];
    if ( npx < 0 || npy < 0 || npx >= 20 || npy >= 20 )
      continue;
    count( d, num, npx, npy );
  }
}

int main()
{
  int w, h;
  while( cin >> w >> h ) {
    if ( w == 0 && h == 0 )
      break;

    D d = {};
    int px, py;
    for( int y=0; y<h; ++y ) {
      for( int x=0; x<w; ++x ) {
        char c;
        cin >> c;
        if ( c == '@' ) {
          px = x;
          py = y;
        }

        d.movable[x][y] = ( c != '#' );
      }
    }

    int num = 0;
    count( d, num, px, py );
    cout << num << endl;
  }
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    cout << "square1001" << endl;
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

struct node{
  int key;
  struct node *p,*l,*r;
};

typedef struct node * Node;

Node root;

void pre(Node u){
  if (u == NIL) return;
  printf(" %d",u->key);
  pre(u->l);
  pre(u->r);
}

void in(Node u){
  if (u == NIL) return;
  in(u->l);
  printf(" %d",u->key);
  in(u->r);
}

void insert(int c){
  Node z,y,x;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = c;
  z->l = NIL;
  z->r = NIL;

  y = NIL;
  x = root;
  while(x  != NIL){
    y = x;
    if (z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;

  if (y == NIL) root = z;
  else if (z->key < y->key) y->l = z;
  else y->r = z;
}

Node find(Node x,int f){
  while(x != NIL && f != x->key){
    if (f < x->key) x = x->l;
    else x = x->r;
  }
  return x;
}

int main(){
  int n,c,f;
  char word[7];
  int i;
  Node t;

  scanf("%d",&n);

  for (i=0; i<n; i++){
    scanf("%s",word);
    if (strcmp(word,"insert") == 0){
      scanf("%d",&c);
      insert(c);
    }
    else if (strcmp(word,"print") == 0){
      in(root);
      printf("\n");
      pre(root);
      printf("\n");
    }
    else if (strcmp(word,"find") == 0){
      scanf("%d",&f);
      t = find(root,f);
      if (t == NIL) printf("no\n");
      else if (t->key == f) printf("yes\n");
    }
  }

  return 0;
}


Measured memory_bytes: 20540
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}
template <class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int K, N;
    cin >> K >> N;
    vi a(N);
    cin >> a;

    int diff = K - a[N - 1] + a[0];
    REP(i, N - 1) {
        chmax(diff, a[i + 1] - a[i]);
    }
    cout << K - diff;
}

#pragma region main
signed main() {
    std::ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cin.tie(nullptr);
    //out << std::fixed;
    // out.precision(20);
    Main();
    //cout << flush;
}
#pragma endregion


Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 3e5 + 10;

int a[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline bool check(int L,int R) {
	if((R - L) & 1) return false;
	if(L == R) return true;
	for(int i = L + 1;i <= R - 1;i += 2) if(a[i] != i) return false;
	int Px = 0,Py = 0;
	for(int i = L;i <= R;i += 2) {
		if(a[i] < i) {
			if(a[i] < Px) return false;
			Px = a[i];
		} else if(a[i] > i) {
			if(a[i] < Py) return false;
			Py = a[i];
		} else return false;
	}
	return true;
}

int main() {

	int n = read(),Max = 0,Las = 1;
	For(i,1,n) a[i] = read();

	For(i,1,n) {
		chkmax(Max,a[i]);
		if(Max == i) {
			if(!check(Las,i)) return puts("No"),0;
			Las = i + 1;
		}
	}

	puts("Yes");

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    char a;
    cin >> a;
    if('A'<=a&&a<='Z')pr('A');
    else pr('a');
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    long double b;
    cin>>a>>b;
    ll ans=0;
    int aa[100]={0};
    int s=0;
    ll temp = a*b;
    while(temp>0)
    {
        aa[s]=temp%10;
        s++;
        temp/=10;
    }
    for(int i=s-1;i>=0;i--)
        ans = ans*10 + aa[i];
    cout<<ans;


}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main()
{
	int a,b,i;
    cin>>a>>b;
    for(i=1;i<=100000;i++)
    {
        int x=(i*8)/100;
        int y=(i*10)/100;
        if(x==a&&y==b)
            break;
    }
    if(i>100000)
        cout<<"-1\n";
    else cout<<i<<endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI = 3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM =
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin >> x;
	cout << (x ^ 1) << endl;
	return 0;
}


//252908XL

/*
comments:-

*/


Measured memory_bytes: 3608
//
//M-SOLUTIONS 2020
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll m=1000;
    ll k=0;
    REP(i,n-1){
        if (k == 0){
            if (a[i]<a[i+1]) {
                k = m/a[i];
                m = m - (k * a[i]);
            }
        }
        if (k > 0){
            if (a[i]>a[i+1]){
                m += k * a[i];
                k = 0;
            }
        }
    }
    m += k*a[n-1];
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int r;	cin >> r;
	cout << r*r;	
	return 0;
}

Measured memory_bytes: 764
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if i==0:
            if j==0 and s[i][0]=='#':
                l1=[s[0][1],s[1][0],s[0][0]]
                l1l=l1.count('#')
                if l1l==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='#':
                r1=[s[0][w-2],s[0][w-1],s[1][w-1]]
                r1r=r1.count('#')
                if r1r==1:
                    print('No')
                    exit()
            elif s[i][j]=='#':
                l1j=[s[0][j-1],s[0][j+1],s[0][j],s[1][j]]
                l1jj=l1j.count('#')
                if l1jj==1:
                    print('No')
                    exit()
            else:pass
        elif i==h-1:
            if j==0 and s[i][0]=='#':
                lh=[s[h-1][0],s[h-2][0],s[h-1][1]]
                lhl=lh.count('#')
                if lhl==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='#':
                rh=[s[h-1][w-1],s[h-1][w-2],s[h-2][w-1]]
                rhr=rh.count('#')
                if rhr==1:
                    print('No')
                    exit()
            elif j!=0 and j!=w-1 and s[i][j]=='#':
                lhj=[s[i][j],s[i][j+1],s[i][j-1],s[i-1][j]]
                lhjj=lhj.count('#')
                if lhjj==1:
                    print('No')
                    exit()
        else:
            if j==0 and s[i][0]=='#':
                li=[s[i-1][0],s[i][0],s[i][1],s[i+1][0]]
                lil=li.count('#')
                if lil==1:
                    print('No')
                    exit()
            elif j==w-1 and s[i][w-1]=='#':
                ri=[s[i-1][w-1],s[i][w-1],s[i][w-2],s[i+1][w-1]]
                rir=ri.count('#')
                if rir==1:
                    print('No')
                    exit()
            elif s[i][j]=='#':
                lij=[s[i-1][j],s[i][j],s[i][j+1],s[i][j-1],s[i+1][j]]
                lijj=lij.count('#')
                if lijj==1:
                    print('No')
                    exit()
            else:pass
print('Yes')

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>

int compare(const void *a, const void *b) {
  return (strcmp((char *)a,(char *)b));
}

int main() {
  int n, i;
  char s[200001][11];
  int ans;
  scanf("%d", &n);
  
  i = 0;
  while (i < n) {
    scanf("%s", s[i]);
    i++;
  }
  
  qsort(s, n, sizeof *s, compare);
  
  i = 0;
  ans = 0;
  while (i < n) {
    if (strcmp(s[i],s[i + 1]) != 0)
      ans++;
    i++;
  }
  
  printf("%d", ans);
  return (0);
}

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

int N;

void dfs(string w, char c){
  w+=c;
  if(w.size()==N){
    cout << w << endl;
  }else{
    char max='a';
    for(int i=0;i<w.size();i++){
      if(max<w.at(i)){
        max=w.at(i);
      }
    }
    for(char i='a';i<=max+1;i++){
      dfs(w, i);
    }
  }
}

int main(){
  cin >> N;
  dfs("", 'a');
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[101][101],start[101],end[101],n,p=0,v[101];
void dfs(int u){
	if(!v[u]){v[u]++;
	start[u]=++p;
	r(i,1,n+1)if(a[u][i])dfs(i);
	end[u]=++p;}
}
int main(){
	int q,qq,qqq;
	cin>>n;
	r(i,0,n){cin>>q>>qq;
		r(i,0,qq){cin>>qqq;
			a[q][qqq]++;
		}
	}
	r(i,1,n+1)if(!v[i])dfs(i);
	r(i,1,n+1)cout<<i<<' '<<start[i]<<' '<<end[i]<<endl;
}

Measured memory_bytes: 3128
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	// input1 = input[0].split('').map((n) => (parseInt(n)))
	// input[0].split(' ').map((n) => (parseInt(n)))
	arr = input[1].split(' ').map((n) => (parseInt(n)))
	var diff = 0
	ans = 'NO'
	for (var i = 0; i < arr.length; i++) {
		if (arr[i] !== i + 1) {
			diff++
		}
	}

	if (diff === 2 || diff === 0) {
		ans = 'YES' 
	}

	//出力
	console.log(ans )
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	double d;
	cin >> n >> d;

	ll cnt = 0;
	for (int i = 0; i < n; ++i) {
		long double x, y;
		cin >> x >> y;
		long double dist = sqrt(x * x + y * y);
		if (dist <= d) {
			++cnt;
		}
	}

	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3828
import math
def isPrime(n):
  if n == 1: return False

  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

x = int(input())

for i in range(10**5):
  if isPrime(x+i):
    print(x+i)
    break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const ll MOD = 1000000007;
const int MAXN = 126;

ll dp[MAXN][4][4][4];

bool good(int p,int q,int r,int s) {
    if(q == 0 && r == 2 && s == 3) return false;
    if(q == 0 && r == 3 && s == 2) return false;
    if(q == 2 && r == 0 && s == 3) return false;
    if(p == 0 && r == 2 && s == 3) return false;
    if(p == 0 && q == 2 && s == 3) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    ll ans = 0;
    for(int a = 0;a < 4;a++) {
        for(int b = 0;b < 4;b++) {
            for(int c = 0;c < 4;c++) {
                dp[3][a][b][c] = good(-1, a, b, c);
                if(N == 3) ans += dp[3][a][b][c];
            }
        }
    }
    for(int i = 4;i <= N;i++) {
        for(int a = 0;a < 4;a++) {
            for(int b = 0;b < 4;b++) {
                for(int c = 0;c < 4;c++) {
                    ll &cur = dp[i][a][b][c];
                    cur = 0;
                    for(int d = 0;d < 4;d++) {
                        if(good(d, a, b, c))
                            cur += dp[i - 1][d][a][b];
                    }
                    cur %= MOD;
                    if(i == N) ans += cur;
                }
            }
        }
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define sz 4
vector <long long int> vv[sz];
int main(){
    long long int n,i,j,x,y,mx = 0,temp;
    cin >> n;
    for(i = 0;i<n;i++){
        cin >> x >> y;
        vv[0].push_back(x + y);
        vv[1].push_back(x - y);
        vv[2].push_back(-x - y);
        vv[3].push_back(-x + y);
    }
      for(i = 0;i<4;i++) {
          sort(vv[i].begin(),vv[i].end());
          mx = max(mx,vv[i][n-1] - vv[i][0]);
      }
       cout << mx << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int64_t ans = 0;
    int64_t tmp = 0;
    REP(i, n) {
        int64_t a, b;
        cin >> a >> b;
        if(a > tmp) {
            ans = a + b;
            tmp = a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int NA,NB;

        NA = N*A;
        
        if(NA < B){
            System.out.println(NA);
        }else{
            System.out.println(B);
        }
        
    }

}

Measured memory_bytes: 21588
import sys
S= list(str(input()))
for i in range(len(S)-1):
    if S[i]=='h'and S[i+1]=='i'and S.count('h')==S.count('i'):
        print('Yes')
        sys.exit()
    elif S[i]=='h'and S[i+1]=='h':
        print('No')
        sys.exit()
print('No')

Measured memory_bytes: 3060
import numpy as np

from collections import defaultdict
N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
BC= [list(map(int,input().split())) for _ in range(Q)]

counter = defaultdict(int)
for x in A:
    counter[x] += 1

total = sum(A)
for b, c in BC:
    total += (c - b) * counter[b]
    counter[c] += counter[b]
    counter[b] = 0
    print(total)


Measured memory_bytes: 57784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        string[] inputs = Console.ReadLine().Split();
        int height = int.Parse(inputs[0]);
        int width  = int.Parse(inputs[1]);
        string[] field =
            Enumerable.Range(0, height)
            .Select(x => Console.ReadLine())
            .ToArray();
        int[][] dp =
            Enumerable.Range(0, height)
            .Select(x => new int[width])
            .ToArray();
        dp[0][0] = 1;
        foreach(int h in Enumerable.Range(0, height))
            foreach(int w in Enumerable.Range(0, width))
            {
                if(dp[h][w] >= 1000000007)
                {
                    dp[h][w] %= 1000000007;
                }
                if(h + 1 < height && field[h + 1][w] == '.')
                {
                    dp[h + 1][w] += dp[h][w];
                }
                if(w + 1 < width && field[h][w + 1] == '.')
                {
                    dp[h][w + 1] += dp[h][w];
                }
            }
        //Console.WriteLine(string.Join("\n", dp.Select(x => string.Join(",", x))));
        Console.WriteLine(dp[height - 1][width - 1]);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 25516
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int a[5]={0};
    int f,i,delta;
  for(i=0;i<5;i++){
  cin>>a[i];
  }
  cin>>f;
  sort(a,a+5);
  delta=abs(a[0]-a[4]);
  if(delta>f){
  cout<<":("<<endl;
  }else{
  cout<<"Yay!"<<endl;
  }
  
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<string,int> P;
map<string,int> dp;
int opt[4]= {1,-1,4,-4};
void bfs() {
	queue<P> que;
	que.push(P("01234567",0));
	dp["01234567"]=0;

	while(que.size()) {
		P p =que.front();
		que.pop();
		string s = p.first;
		int cur = p.second;
		for(int i=0; i<4; i++) {
			int next = cur+opt[i];
			string str = s;
			swap(str[cur],str[next]);
			map<string,int>:: iterator it = dp.find(str);
			if(next>=0&&next<8&&!(cur==3&&opt[i]==1)&&!(cur==4&&opt[i]==-1)&&it==dp.end()){
				que.push(P(str,next));
				dp[str]=dp[s]+1;
			}

		}
	}
}
int main() {
	string a;
	bfs();
	while(getline(cin,a)) {
		a.erase(remove(a.begin(), a.end(),' '), a.end());
		printf("%d\n",dp[a]);
	}
}

Measured memory_bytes: 5488
let hand a =
    let (i,j,k,l,m) = (a.(0),a.(1),a.(2),a.(3),a.(4)) in
    if (j,k,l) = (i,i,i) || (k,l,m) = (j,j,j) then "four card"
    else if (j,l,m) = (i,k,k) || (j,k,m) = (i,i,l) then "full house"
    else if (j,k) = (i,i) || (k,l) = (j,j) || (l,m) = (k,k) then "three card"
    else if (j,l) = (i,k) || (j,m) = (i,l) || (k,m) = (j,l) then "two pair"
    else if j = i || k = j || l = k || m = l then "one pair"
    else if (i,j,k,l,m) = (i,(i+1),(i+2),(i+3),(i+4)) || (i,j,k,l,m) = (1,10,11,12,13) then "straight"
    else "null"
;;

let () =
    let rec read () =
        try let line = Scanf.scanf " %d,%d,%d,%d,%d\n" (fun v w x y z -> [|v;w;x;y;z|]) in
        Array.sort compare line;
        hand line |> print_endline;
        read ()
        with End_of_file -> ()
    in read ()
;;

Measured memory_bytes: 2116
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define S second
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e16, MOD=1000000007;
     
ll n, q=1, a[N], b[N], dp[2020][2020], m, x, y, z, X, Y, Z, o, u, h, w, mx, mn, ans, Ans;
string s, S;
vector <ll> v[N];
pair<ll, ll> p[N];

int main(){ios_base::sync_with_stdio(false), cin.tie(0);
                    
//    cin>>q;
                        
    while(q--){
        
        cin>>n;
        
        for (int i=1; i<=n; i++){
        	cin>>x; p[i]={-x, i};
		}
		
		sort(p+1, p+n+1);
		
		for (int i=1; i<=n; i++){
			for (int j=0; j<=i; j++){
				int k=i-j;
				if(!k)dp[j][k]=dp[j-1][k]+abs(p[i].F*(j-p[i].S));
				if(!j)dp[j][k]=dp[j][k-1]+abs(p[i].F*(n-k+1-p[i].S));
				if(j*k)dp[j][k]=max(dp[j-1][k]+abs(p[i].F*(j-p[i].S)), dp[j][k-1]+abs(p[i].F*(n-k+1-p[i].S)));
				ans=max(dp[j][k], ans);
			}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 49800
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct edge{int u,v;};

const int INF=1e18;

class UnionFind
{
 public:
    vector<int> par,sz;
    UnionFind(int N):par(N),sz(N){
        for(int i=0;i<N;i++){
            par[i]=i; sz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]<sz[y]) swap(x,y);
        par[y]=x;
        sz[x]+=sz[y];
    }
    bool same(int x,int y){ return find(x)==find(y); }
    int size(int x){ return sz[find(x)]; }
    bool root(int x){ return par[x]==x; }
};

void solve()
{
    int N,M; cin>>N>>M;
    if(N==0) exit(0);
    vector<vector<edge>> es(100010);
    UnionFind tree(N);
    for(int i=0;i<M;i++){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        es[c].push_back({a,b});
        tree.unite(a,b);
    }
    if(tree.size(0)<N){
        cout<<-1<<endl;
        return;
    }

    int ans=INF;
    auto calc=[&](int c)
    {
        UnionFind tree(N);
        // cout<<c<<endl;
        for(int i=0;c+i<=10000;i++){
            for(edge e:es[c+i]) tree.unite(e.u,e.v);
            if(tree.size(0)==N) return i;
            // cout<<c<<' '<<i<<endl;
            // for(int i=0;i<N;i++) cout<<tree.find(i)+1<<' '; cout<<endl;
        }
        return INF;
    };
    for(int i=1;i<=10000;i++) chmin(ans,calc(i));
    cout<<ans<<endl;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    while(true){
        solve();
    } 
}


Measured memory_bytes: 5656
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){

  int sum = 0;
  for(int i=0;i<5;i++){
    int score;
    scanf("%d",&score);
    sum += max(40,score);
  }
  printf("%d\n",sum / 5);
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define mp make_pair
int main(){
set<int> s;
for(int i=0;i<3;i++){
int x;
cin>>x;
s.insert(x);
}
if(s.size()==1)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int main(){
  int A[N];
  int i,j,n,x,r,tmp,cnt=0,flag=0;
  
  scanf("%d",&n);
  if(n<0 || n>100001) printf("Error\n");
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<0 || A[i] > 100001) printf("Error\n");
  }
  
  r = i-1;
  x = A[i-1];
  
  for(i=0;i<r;){
    for(j=0;j<r;){
      if(A[j] <= x){
	if(A[j] == x) cnt++;
	tmp = A[i];
	A[i] = A[j];
	A[j] = tmp;
	i++;
      }
      j++;
    }
    if(j == r){
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
      break;
    }
  }
  
  for(i=0;i<n;i++){
    if(A[i] == x){
      if(cnt == flag){
	if(i == n-1){
	  printf("[%d]\n",A[i]);
	  continue;
	}
	else {
	  printf("[%d] ",A[i]);
	  continue;
	}
      }
      else flag++;
    }
      if(i == n-1) printf("%d\n",A[i]);
      else printf("%d ",A[i]);
  }
  return 0;
}



Measured memory_bytes: 2104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265358979323846;

#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<vi> adj;
const int N = 1e5+5;
bool visited[N];
int arr[N];
class DEquals {
public:
    set<int> path;
    vi pos;
    void dfs(int u){
        if(visited[u]) return;
        visited[u] = true;
        path.insert(arr[u]);
        pos.push_back(u);
        for(int v: adj[u]) dfs(v);
    }

	void solve(std::istream& in, std::ostream& out) {
	    int n, m; in>>n>>m;
        f(i, n) in>>arr[i+1];
        adj = vector<vi>(n+1);
        f(i, m){
            int u, v; in>>u>>v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        memset(visited, false, sizeof(visited));
        int res = 0, cnt;

	    rep(i, 1, n){
            if(!visited[i]){
                path.clear();
                pos.clear();
                dfs(i);
                cnt = 0;
                for(int x: pos){
                    if(path.find(x)!=path.end()) ++cnt;
                }
                res += cnt;
            }
        }
        out<<res;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	DEquals solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 12920
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){

  string str;
  int cnt=0;
  
  while(cin>>str){
    
    int len = str.size();
    
    int flg=1;
    for(int i=0;i<(len/2);i++){
      if(str[i] != str[len-1-i]){
	flg=0;
	break;
      }
    }

    cnt+=flg;

  }

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

  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

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

int n;
int input[10][10], state[10][10], ans[10][10];

void pass(int y, int x) {
    for (int i=0; i<5; ++i) {
        if (0 <= y + dy[i] && y + dy[i] < 10 && 0 <= x + dx[i] && x + dx[i] < 10) {
            state[y + dy[i]][x + dx[i]] = !state[y + dy[i]][x + dx[i]];
        }
    }
    ans[y][x] = !ans[y][x];
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    while (n --) {
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cin >> input[i][j];
            }
        }
        for (int bt=0; bt<(1<<10); ++bt) {
            memcpy(state, input, sizeof(input));
            memset(ans, 0, sizeof(ans));
            for (int j=0; j<10; ++j) {
                if ((bt>>j) & 1) {
                    pass(0, j);
                }
            }
            for (int i=1; i<10; ++i) {
                for (int j=0; j<10; ++j) {
                    if (state[i-1][j] == 1) {
                        pass(i, j);
                    }
                }
            }
            if (accumulate(state[9], state[9] + 10, 0) == 0) break;
        }
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cout << (j == 0 ? "" : " ") << ans[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

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

using namespace std;

int cmp(int x, int y) {
	return x > y;
}

int main() {
	int n;
	scanf("%d", &n);
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		v.push_back(x);
	}
	sort(v.begin(), v.end(), cmp);
	vector<int> used(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (used[i]) {
			continue;
		}
		int x = v[i];
		int s = 1;
		while (s <= x) s <<= 1;
		int l = i + 1, r = n - 1;
		while (l <= r) {
			int m = (l + r) / 2;
			int y = v[m];
			if (x + y > s) {
				l = m + 1;
			} else {
				r = m - 1;
			}
		}
		while (l < n && x + v[l] == s && used[l]) l++;
		if (x + v[l] == s) {
			used[l] = 1;
			ans++;
			l++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

#define all(x) 		 (x).begin(),(x).end()
#define mp     		 make_pair
#define pb 				 push_back
#define fi 				 first
#define se 				 second
#define sz(x) 		 ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x)  for(auto& y:x)
#define pii 			 pair<int,int>
#define vi 				 vector<int>

int dbg = 0;
#define cri   		 if(0)
#define shame 		 cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;


void solve() {
  double x;
  cin >> x;
  x /= 3.0;
  cout << (x * x * x) << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout<<setprecision(20);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}



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

int main(){
	int W,H,N,u=0,d=0,l=0,r=0;
	cin >> W >> H >> N;
	vector <int> x(N),y(N),a(N);
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i] >> a[i];
		if((a[i]==1) && (l<x[i])){
			l=x[i];
		}else if((a[i]==2) && (r<W-x[i])){
			r=W-x[i];
		}else if((a[i]==3) && (d<y[i])){
			d=y[i];
		}else if((a[i]==4) && (u<H-y[i])){
			u=H-y[i];
		}
	}
	if(((W-r-l)<=0) || ((H-u-d)<=0)){cout << 0 << endl;}
	else{cout << (W-l-r)*(H-u-d) << endl;}
	return 0;
}


Measured memory_bytes: 256
mod = 10**9+7

def naive_quad_power(n):
    ret = 1
    for i in range(n):
        ret = (2*ret)%mod
        
    return ret

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    valid = {abs(N-1-2*i):2 for i in range(N)}
    if N % 2 == 1:
        valid[0] = 1
        
    check = {k:0 for k in valid}
    val = True
    for a in A:
        if a in check and check[a] < valid[a]:
            check[a] = check[a]+1
        else:
            val = False
            break
    
    #print(check, valid)
    
    ret = naive_quad_power(N//2) if val else 0
    print(ret)
    
solve()

Measured memory_bytes: 17888
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


N = 10 ** 5
primes = prime_numbers(N)
a = [1 if n in primes and (n + 1) // 2 in primes else 0 for n in range(N + 1)]
a = list(accumulate(a))

ans = []
Q, *LR = map(int, open(0).read().split())
for l, r in zip(*[iter(LR)] * 2):
    ans.append(a[r] - a[l - 1])

print(*ans, sep='\n')


Measured memory_bytes: 29012
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int N=0,M=0,sum=0,a=0;
	scanf("%d %d",&N,&M);
	int N1[N]={0},M1[M]={0},A[N]={0};
	for(int i=0;i<N;i++){
		cin>>N1[i];
	}
	for(int i=0;i<M;i++){
		cin>>M1[i];
		for(int j=0;j<N;j++){
			if(N1[j]<=M1[i]){A[j]++;break;}
		}
	}
	for(int j=0;j<N;j++){
		if(A[j]>sum){
			sum=A[j];
			a=j+1;
		}
	}
	cout<<a<<endl;
	return 0;
}
//7:53.198途中


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=555;
int n,k,a[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k;
	REP(i,n) cin>>a[i];
	int sum=accumulate(a,a+n,0);
	int res=1;
	auto check=[&](int x)->bool{
		int tot=0;
		int used=0;
		vector<int> t;
		REP(i,n) t.pb(a[i]%x),tot+=x-a[i]%x;
		sort(all(t));
		REP(i,n){
			used+=t[i];
			tot-=x-t[i];
			if(used==tot&&used<=k) return true;
		}
		return false;
	};
	for(int i=1;i*i<=sum;++i){
		if(sum%i!=0) continue;
		if(check(i)) res=max(res,i);
		if(i*i!=sum&&check(sum/i)) res=max(res,sum/i);
	}
	cout<<res<<'\n';
}
// invariant factor: S = sum of Ai is unchanged
// for every divisor of S, we check whether if it's possible or not


Measured memory_bytes: 3612
import java.util.*;

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

        int n = sc.nextInt();
        int r = sc.nextInt();

        if (10<=n){
            System.out.print(r);
        }else {
            System.out.print(r+100*(10-n));
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll a,b;
    cin>>a>>b;
    if(a%2==1&&b%2==1)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	a, b, c := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	colors := map[int]bool{}
	colors[a] = true
	colors[b] = true
	colors[c] = true
	fmt.Println(len(colors))
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
#include <time.h>
#include "set"
#include "vector"
#include <iterator>

using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

int n, m,b[100009],c,a;
vector<pair<int, int>>v;


int main() {
	cin >> n>> m;
	a = n + 1;
	fori0(m) {
		int p, q;
		cin >> p>>q;
		v.push_back({ p,q });
	}
	sort(v.begin(), v.end());
	for (int i = m - 1;i >= 0;i--) {
		if (b[v[i].first] == 0&&a>(v[i].second)) {
			c++;
			//cout << v[i].first << endl;
			b[v[i].first] = 1;
			a = v[i].first + 1;
		}
	}
	cout << c;

	//system("pause");
	return 0;

}


Measured memory_bytes: 1524
#include <stdio.h>
#include <stdbool.h>

int num(int N, int a[8]) {
	bool t[9] = {false};
	int re=0, u = 1;
	for (int i = 1; i <= N;i++) {
		u = u * i;
	}

	for (int i = 0; i < N - 1; i++) {
		u = u/(N-i);
		t[a[i]] = true;
		int f = a[i] - 1;
		for (int j = 1; j < a[i]; j++) {
			if (t[j] == true) {
				f--;
			}
		}
		re = re + f*u;
	}
	return re+1;
}

int main() {
	int P[8], Q[8],N;
	scanf("%d", &N);
	for (int i = 0; i<N ; i++) {
		scanf("%d",&P[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &Q[i]);
	}
	int p = num(N, P);
	int q = num(N, Q);
	if (p > q) {
		printf("%d", p - q);
	}
	else {
		printf("%d", q - p);
	}
	return 0;
}

Measured memory_bytes: 128
from itertools import chain
# 入力
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
ls.insert(0,[0,0,0])
ls = list(chain.from_iterable(ls))

# 階差数列
time = [(ls[i+3]-ls[i]) for i in range(0,len(ls)-3,3)]
cost = [abs(ls[i+1]-ls[i+4])+abs(ls[i+2]-ls[i+5]) for i in range(0,len(ls)-4,3)]

# 要素ごとに比較して条件式がすべてTrueならYESを出力
result = 'Yes' if all(time[i]%2==cost[i]%2 and time[i] >= cost[i] for i in range(len(time))) else 'No'
print(result)


Measured memory_bytes: 29852