akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Scanner;
import java.io.*;
import javax.lang.model.util.ElementScanner6; 

public class Main
{

    public static void main(String args[])
    {  

        FastReader in=new FastReader();
        PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int t=1;
     
        //t=in.nextInt();
        while(t-->0)
        {
           int n=in.nextInt();
           if(n==1)pr.println(0);
           
           else pr.println(1);
           
        }
        pr.flush();
    }



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

    static int lcm(int a,int b)
    {
        return (a*b)/gcd(a,b);
    }


    static boolean prime[];

    static void sieveofe()
    {
        int n=1000000;
      
        prime=new boolean[n+1];
        Arrays.fill(prime,true);
        prime[1]=false;
        for(int i=2;i*i<=n;i++)
        {
            if(prime[i]==true)
            {
                for(int j=i*i;j<=n;j+=i)
                {
                    prime[j]=false;
                }
            }
        }
      
        
    }
    
    static void sort(long[] a) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}
    
    
	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
    }

    
    static class FastReader
    { 
        BufferedReader br; 
        StringTokenizer st; 

        public FastReader() 
        { 
            br = new BufferedReader(new
                    InputStreamReader(System.in)); 
        } 

        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                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; 
        } 
    } 

    
   
}

Measured memory_bytes: 32820
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let n: usize = iter.read();
	let a_list = {
		let mut a_list: Vec<(usize, u32)> = (0..n)
			.into_iter()
			.map(|_| iter.read())
			.enumerate()
			.collect();
		a_list.reverse();
		a_list
	};

	let mut x_list: Vec<u32> = vec![0; n];
	let mut i_list: Vec<usize> = vec![];

	for &(i, a) in a_list.iter() {
		let t = cnt(&x_list, i);
		x_list[i] = if t == a {
			0
		} else {
			i_list.push(i);
			1
		};
	}

	let l = i_list.len();
	println!("{}", l);
	if 0 < l {
		println!(
			"{}",
			i_list
				.into_iter()
				.map(|n| (n + 1).to_string())
				.collect::<Vec<String>>()
				.join(" ")
		);
	}
}

fn cnt(x_list: &Vec<u32>, i: usize) -> u32 {
	let mut j = i;
	let i = i + 1;
	let mut r = 0;
	let s = x_list.len();
	loop {
		j += i;
		if j >= s {
			return r % 2;
		}
		let x = x_list[j];
		if 0 < x {
			r += 1;
		}
	}
}

Measured memory_bytes: 15356
# coding: utf-8

kind, choose = map(int, input().split())
count = 0
total = 0

num = input().split(" ")
for i in num:
    total += int(i)

ok = total / (4 * choose)

for i in num:
    if int(i) >= ok:
        count += 1

if count >= choose:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
using System;
 
public class Test
{
	public static void Main()
	{
		int n = int.Parse( Console.ReadLine() );
 
		int [,,] oh = new int[4,3,10];
 
 
		for(int i = 0; i < n; i++) {
			string[] s = Console.ReadLine().Split(' ');
 
			oh[int.Parse(s[0]) - 1, int.Parse(s[1]) - 1, int.Parse(s[2]) - 1] += int.Parse(s[3]);
		}
 
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 10; k++) {
					Console.Write(" " + oh[i, j, k] );
				}
				Console.WriteLine();
			}
			if(i != 3) Console.WriteLine("####################");
		}
	}
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second
//#define M 1000000007
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;
const int M = 1e15;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int32_t main(){
	fastio;
	map<int,int> mapa;
	int n,k;
	cin>>n>>k;
	vector<int> a(n+1);
	vector<int> pre(n+1);
	mapa[0]++;
	int res=0;
	pre[0] =0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pre[i] = pre[i-1]+a[i];
		pre[i]=pre[i]%k;
		
		if(i-k>=0)mapa[mod(pre[i-k]-(i-k),k)]--;
		res+=mapa[mod(pre[i]-i,k)];
		mapa[mod(pre[i]-i,k)]++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 15872
# -*- coding: utf-8 -*-
import sys, copy
s = input();

# def daydream(name,s):
#     print(name)
#     if ( name == s ):
#         return True
#     if ( len( name ) > len(s) ):
#         return False
#     for x in ["dream", "dreamer", "erase", "eraser"]:
#         if ( daydream(name + x, s) ):
#             return True
#     return False
#

#def daydream(s):
#    if (s == ""):
#        return True
#    for x in ["dream", "dreamer", "erase", "eraser"]:
#        if ( s.startswith(x) ):
#            if ( daydream(s[len(x):]) ):
#                return True
#    return False

ss = [s]
while( len(ss) > 0 ):
    tt = copy.deepcopy(ss)
    ss = list()
    for t in tt:
        for x in ["dream", "dreamer", "erase", "eraser"]:
            if ( t.startswith(x) ):
                t_cut = t[len(x):]
                ss.append(t_cut)
                if ( t_cut == "" ):
                    print("YES")
                    sys.exit(0)


print("NO")

Measured memory_bytes: 3984
n,m=list(map(int,input().split()))
if n==1 and m==0:
  print(0)
  exit(0)
d=[-1]*4
for _ in range(m):
  s,c=list(map(int,input().split()))
  if d[s]!=-1 and d[s]!=c:
    print(-1)
    exit(0)
  d[s]=c
ans=0
for i in range(1,n+1):
  if d[i]==-1:
    if ans==0:d[i]=1
    else:d[i]=0
  ans=10*ans+d[i]
if len(str(ans))==n:
  print(ans)
else:
  print(-1)


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


using namespace std;

#define pb push_back
const int maxi = 1e6+10;

vector<int> v[maxi];
int s,t;
int mem[3][maxi];
int dp[3][maxi];

void bfs(int x)
{
    queue<pair<int,int>> q;

    mem[0][x] = 1;
    dp[0][x] = 0;

    q.push({x,0});

    while(!q.empty())
    {
        pair<int,int> node = q.front();
        q.pop();

        for (int i:v[node.first])
        {
            int val = (node.second + 1) %3;
            if (!mem[val][i])
            {
                mem[val][i] = 1;
                dp[val][i] = dp[node.second][node.first] + 1;
                q.push({i,val});
            }
        }

    }

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

   for (int i=1;i<=m;i++)
   {
       int x,y;
       scanf("%d%d",&x,&y);
       v[x].pb(y);
   }

   cin>>s>>t;

   bfs(s);
   if (mem[0][t]) printf("%d\n",dp[0][t]/3); else
    printf("-1\n");
}

Measured memory_bytes: 42496
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
int rint();char rch();long long rlong();
// mt19937 rng; rng.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// template<typename T> int bins(vector<T> &v, T key) {int imin=0,imax=v.size();while(imin<imax) {int imid=(imin+imax)>>1;if (v[imid]<key) imin=imid+1;else imax=imid;}return imin;}
ll n,m; vector<ll> a;
ll getpair(ll L, ll R, ll p) {
	ll l=L+p,r=R-p;
	return a[l]+a[r];
}
bool isok(ll imid) {
	for (ll p=0;p<n-imid;p++) {
		if (getpair(imid*2,2*n-1,p)<m) return false;
	}
	return true;
}
int main() 
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  cin>>n>>m; a.resize(2*n);
  for (ll i=0;i<2*n;i++) cin>>a[i];
  sort(a.begin(),a.end());
	ll imin=0,imax=n+1;
	while(imin<imax) {
		ll imid=(imin+imax)/2;
		if (!isok(imid)) imin=imid+1;
		else imax=imid;
	}
	ll ans=0;
	for (ll p=0;p<imin;p++) {
		chkmax(ans,getpair(0,2*imin-1,p)%m);
	}
	for (ll p=0;p<n-imin;p++) {
		chkmax(ans,getpair(2*imin,2*n-1,p)%m);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#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(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------//

int main(){
	int e[12];
	REP(i, 12) scanf("%d", e + i);
	sort(e, e + 12);
	
	bool ans = true;
	REP(i, 3) {
		bool ng = false;
		REP(j, 4) if (e[i*4+j] != e[i*4]) ng = true;
		if (ng) ans = false;
	}
	
	puts(ans ? "yes" : "no");
	
	return 0;
}

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

int main(){
    string s; cin>>s;
    int k; cin>>k;
    set<string> set;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size()&&j<i+5;j++){
            set.insert(s.substr(i,j-i+1));
        }
    }
    auto it=set.begin();
    for(int i=0;i<k-1;i++,it++);
    cout<<*it<<endl;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


map<int, int> dp;

int main(){
    int n;cin >> n;
    int ans = 0;
    
    FOR(i,1,n+1){
        int count = 0;
        FOR(j,1,i+1){
            if (i%j == 0 && i%2 == 1) count++;
        }
        if (count == 8) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 100 + 10;
char s[N];
int main() {
  int n, k;
  scanf("%s%d", s, &k);
  n = strlen(s);
  vector<int> A;
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && s[j] == s[i]; ++j);
    A.push_back(j - i);
  }
  if (A.size() == 1) {
    printf("%lld\n", (int64)n * k / 2);
    return 0;
  }
  int64 ret = 0;
  if (s[0] == s[n - 1]) {
    for (int i = 0; i < A.size(); ++i) ret += A[i] / 2;
    ret = ret - A[0] / 2 - A.back() / 2 + (A[0] + A.back()) / 2;
    ret *= k - 1;
    for (int i = 0; i < A.size(); ++i) ret += A[i] / 2;
  } else {
    for (int i = 0; i < A.size(); ++i) ret += A[i] / 2;
    ret *= k;
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
program Guess_The_Number
    implicit none
    integer(4):: n, m
    integer(4):: i,j,k
    integer(4), allocatable:: number(:), s(:), c(:)

    read*, n, m
    allocate(number(n), s(m), c(m))

    do i=1, m
        read*, s(i), c(i)
    end do

    number(:) = 0

    do i=1, m
        if(number(s(i)) /= 0 .and. number(s(i)) /= c(i)) call die()
        if(s(i) == 1 .and. c(i) == 0 .and. n > 1) call die()
        number(s(i)) = c(i)
    end do

    if (number(1) == 0 .and. n > 1) number(1) = 1


    block
        character(1):: c_num(n)

        do i=1, n
            write(c_num(i), '(i0)') number(i)
        end do

        print*, c_num(:)
    end block

contains
subroutine die()
    print*, -1
    stop
end subroutine
end program Guess_The_Number

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <math.h>
using namespace std;


int main() {

   double a;
   double b;
  
   cin >> a >> b;
  
   long long c = (int)a;
   long long d = (int)b;
  
   cout << c/d << " ";
   cout << c%d << " ";
  
   printf("%.8f",a/b);
  
   cout << endl;
   
   
   
  return 0;
}


Measured memory_bytes: 3280
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const double PI = 3.14159265358979323846;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main(){
  ll a,b;
  cin >> a >> b;
  ll x = gcd(a,b);
  vector<ll> ret;
  for(ll i=2; i*i<=x; i++){
    if(x%i==0){
      ret.push_back(i);
      while(x%i == 0){
        x /= i;
      }
    }
  }
  if(x != 1){
    ret.push_back(x);
  }
  cout << ret.size() + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, r, s, p, ans, m, f, g, x;
	string t, ss;

	cin >> n >> k >> r >> s >> p >> t;
	ans = 0;

	for (i = 0; i < k; i++) {
		ss = "";
		for (j = i; j < n; j += k) ss = ss + t[j];

		m = ss.length();
		vector<vector<long long>> dp(m + 1, vector<long long>(3, 0));
		for (j = 0; j < m; j++) {
			for (f = 0; f < 3; f++) {
				for (g = 0; g < 3; g++) {
					if (f != g) {
						x = 0;
						if ((g == 0) && (ss[j] == 's')) x = r;
						if ((g == 1) && (ss[j] == 'p')) x = s;
						if ((g == 2) && (ss[j] == 'r')) x = p;
						dp[j + 1][g] = max(dp[j + 1][g], dp[j][f] + x);
					}
				}
			}
		}

		x = max(dp[m][0], max(dp[m][1], dp[m][2]));
		ans += x;
	}

	cout << ans << "\n";



	return 0;
}



Measured memory_bytes: 5920
N, K, Q = gets.chomp.split.map(&:to_i)
A = $<.read.split(?\n).map(&:to_i)

member = Array.new(N.next, 0)
A.each {|i| member[i] = member[i].next}

member[1..-1].each do |score|
  puts (K + score - Q).positive? ? 'Yes' : 'No'
end

Measured memory_bytes: 11772
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    priority_queue<ll> q;
    Rep (i, N) {
        cin >> A[i];
        q.push(A[i]);
    }

    Rep (i, M) {
        ll target = q.top();
        q.pop();
        target /= 2;
        q.push(target);
    }

    ll ans = 0;
    Rep (i, N) {
        ll buy = q.top();
        q.pop();
        ans += buy;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

#define max 10000000
bool a[max];

void f(ll m,ll n){
  fill(a,a+max,true);

  ll k=0;
  for(ll i=m;i<max;i++){
    if(!a[i]) continue;
    if(k==n){
      cout<<i<<endl;
      return;
    }
    k++;
    for(ll j=2*i;j<max;j+=i)
      a[j] = false;
  }
}

int main(){
  ll n,m;

  while(1){
    cin>>m>>n;
    if(n==0) break;
    f(m,n);
  }

  return 0;
}


Measured memory_bytes: 12748
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1005;

int n,d1,d2;

pii col[N*2][N*2];
vector<pii> c1,c2;
int cnt[2][2];

//vector<pii> ans;
int sqr(int x){return x*x;}

bool v1[N*2][N*2],v2[N*2][N*2];
void dfs1(int x,int y,int c){
    if(x<0||x>n*2-1||y<0||y>n*2-1)return;
    if(v1[x][y]){
        if(!(c==col[x][y].fi)){
            //printf("c=%d,col=%d\n",c,col[x][y].fi);
            exit(1);
        }
        return;
    }
    //printf("dfs1(%d,%d,%d)\n",x,y,c);
    assert(col[x][y].fi!=65536);
    col[x][y].fi=c;
    v1[x][y]=1;
    for(pii p:c1){
        int nx=x+p.fi,ny=y+p.se;
        dfs1(nx,ny,!c);
    }
}
void dfs2(int x,int y,int c){
    if(x<0||x>n*2-1||y<0||y>n*2-1)return;
    if(v2[x][y]){
        assert(c==col[x][y].se);
        return;
    }
    col[x][y].se=c;
    v2[x][y]=1;
    for(pii p:c2){
        int nx=x+p.fi,ny=y+p.se;//y写成x
        dfs2(nx,ny,!c);
    }
}

int main(){
    scanf("%d%d%d",&n,&d1,&d2);
    FOR(i,0,n*2-1)FOR(j,0,n*2-1)if(i*i+j*j==d1){
        c1.pb({i,j});
        c1.pb({i,-j});
        c1.pb({-i,j});
        c1.pb({-i,-j});
    }
    //for(pii p:c1){ printf("(%d,%d) ",p.fi,p.se); }
    FOR(i,0,n*2-1)FOR(j,0,n*2-1)if(i*i+j*j==d2){
        c2.pb({i,j});
        c2.pb({i,-j});
        c2.pb({-i,j});
        c2.pb({-i,-j});
    }
    FOR(i,0,n*2-1)FOR(j,0,n*2-1)if(!v1[i][j])dfs1(i,j,0);
    FOR(i,0,n*2-1)FOR(j,0,n*2-1)if(!v2[i][j])dfs2(i,j,0);
    FOR(i,0,n*2-1)FOR(j,0,n*2-1){
        cnt[col[i][j].fi][col[i][j].se]++;
    }
    assert(cnt[0][1]+cnt[1][0]+cnt[0][0]+cnt[1][1]==n*n*4);
    //printf("%d %d %d %d\n",cnt[0][0],cnt[0][1],cnt[1][0],cnt[1][1]);
    FOR(x,0,1)FOR(y,0,1)if(cnt[x][y]>=n*n){
        int tot=0;
        FOR(i,0,n*2-1)FOR(j,0,n*2-1){
            if(tot==n*n)break;
            if(col[i][j]==(pii){x,y}){
                ++tot;
                printf("%d %d\n",i,j);
                //ans.pb({i,j});
                if(tot==n*n)break;
            }
            if(tot==n*n)break;
        }
        assert(tot==n*n);
        /*for(pii a:ans)for(pii b:ans){
            int t=sqr(a.fi-b.fi)+sqr(a.se-b.se);
            if(t==d1||t==d2){
                printf("(%d,%d) (%d,%d)\n",a.fi,a.se,b.fi,b.se);
                puts("ERROR!");
                return 1;
            }
        }*/
        return 0;
    }
    return 0;
}


Measured memory_bytes: 35328
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
char s[330001];
int main()
{
	cin>>n>>a>>b>>c>>d>>(s+1);
	if(c<d)
	{
		for(int i=a;i<c;i++)
			if(s[i]=='#'&&s[i+1]=='#'){cout<<"No\n";exit(0);}
		for(int i=b;i<d;i++)
			if(s[i]=='#'&&s[i+1]=='#'){cout<<"No\n";exit(0);}
		cout<<"Yes\n";
		exit(0);
	}
	if(c==d){cout<<"No\n";exit(0);}
	bool f=0;
	for(int i=b;i<=d;i++)
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){f=1;s[i]='#';break;}
	if(!f){cout<<"No\n";exit(0);}
	for(int i=a;i<c;i++)
		if(s[i]=='#'&&s[i+1]=='#'){cout<<"No\n";exit(0);}
	cout<<"Yes\n";
}


Measured memory_bytes: 768
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    p = LI()
    t = LI()
    dp = [inf] * (10**5)
    dp[0] = 0
    for i in range(10**5):
        for num,ti in enumerate(t):
            if i - ti >= 0:
                dp[i] = min(dp[i], dp[i - ti] + p[num])
    for i in range(10**5-1, 0, -1):
        dp[i - 1] = min(dp[i], dp[i - 1])
    print(dp[n])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()



Measured memory_bytes: 11964
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    vector<bool>v(8,false);
    int p = 0;
    rep(i,n){
        int now = a[i];
        now /= 400;
        if(now>7){
            p++;
        }
        else{
            v[now]=true;
        }
    }
    int m = 0;
    rep(i,8){
        if(v[i])m++;
    }
    cout << max(1,m) << ' ' << m+p << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,k,m,n;
string s;
int main(){
	getline(cin,s);
	int len=s.size();
	if(s[0]==s[len-1]){
		if(len%2==1)cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
	else {
		if(len%2==1)cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max(x,max(y,z))
#define MX4(x,y,z,p) max(x,max(y,max(z,p)))
#define MX5(x,y,z,p,q) max(x,max(y,max(z,max(p,q))))
#define MN3(x,y,z) min(x,min(y,z))
#define MN4(x,y,z,p) min(x,min(y,min(z,p)))
#define MN5(x,y,z,p,q) min(x,min(y,min(z,min(p,q))))
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

int gcd(int x, int y) {
    while((x%=y)&&(y%=x));
    return x+y;
}

void solve() {

    int n;
    SI(n);
    int tmp = -1;
    REP(i, n) {
        int x;
        SI(x);
        if(tmp==-1) tmp = x;
        else tmp = gcd(tmp, x);
    }
    printf("%d\n", tmp);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n,i,data[1000];
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &data[i]);
	}
	for (i = n; 1 < i; i--) {
		printf("%d ", data[i]);
	}
	printf("%d\n", data[i]);
	return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if (s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s;
llong k;

int main() {
    cin >> s >> k;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'a') continue;
        if (26 - (s[i] - 'a') <= k) {
            k -= 26 - (s[i] - 'a');
            s[i] = 'a';
        }
    }
    k %= 26;
    s.back() += k;

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int n,m=0,c=0;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            m++;
        }else{
            m=0;
        }
        c=max(m, c);
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define int long long

signed main(){
  
  int N; cin >> N;
  for(int n = 1; n <= 3500; n++){
    for(int w = 1; w <= 3500; w++){
      int u = N * n * w;
      int s = 4 * n * w - N * w - N * n;
      if(s <= 0) continue;
      if(u % s != 0) continue;

      cout << u / s << " " << n << " " << w << endl;
      return 0;
    }
  }
  return 0;
}


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

struct node {
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node *Node;
Node root;

void insert(int k) {
  Node x = root;
  Node y = NULL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->right = NULL;
  z->left = NULL;

  while (x != NULL) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;

  if (y == NULL) root = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void preorder(Node n) {
  if (n == NULL) return;
  printf(" %d", n->key);
  preorder(n->left);
  preorder(n->right);
}

void inorder(Node n) {
  if (n == NULL) return;
  inorder(n->left);
  printf(" %d", n->key);
  inorder(n->right);
}

Node searchTree(Node n, int k) {
  if (n == NULL) return NULL;
  if (n->key == k) return n;
  if (k < n->key) return searchTree(n->left, k);
  else if (k > n->key) return searchTree(n->right, k);
}

int main() {
  int n, i, k;
  char str[10];
  Node z;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %d\n", str, &k);
    if (str[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (str[0] == 'f') {
      if (searchTree(root, k) == NULL) printf("no\n");
      else printf("yes\n");
    } else {
      insert(k);
    }
  }

  return 0;
}

Measured memory_bytes: 19368
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			double[] array = new double[N];

			double result = 0;
			for (int i = 0; i < N; i++) {
				array[i] = scanner.nextInt();
			}
			for (int i  = 0; i < N; i++) {
				double tmp = 1.0 / array[i];
				result += tmp;
			}

			System.out.println(1 / result);
		}
	}
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
	li a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << min(a * b, min(b * c, a * c)) << endl;

	return 0;
}

Measured memory_bytes: 256
a = [[[0] * 10 for i in range(3)] for j in range(4)]

n = int(input())

for _ in range(n):
    [b, f, r, v] = [int(j) - 1 for j in input().split()]
    a[b][f][r] += v + 1

for i, d in enumerate(a):
    for c in d: print("", *c)
    if i != len(a) - 1:
        print("#" * 20)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

ll dp[N],e[N];

int main(){
	int n,k;
	cin>>n>>k;
	dp[0] = 1;
	for(int i=1;i<=n;i++){
		memset(e,0,sizeof(e));
		int a;
		cin>>a;
		ll cur = 0;
		for(int u = 0;u<=k;u++){
			int tmp = dp[u];
			dp[u] = (dp[u] + cur)%mod;
			cur = (cur + tmp)%mod;
			if(u+a <= k)e[u+a] = (e[u+a] + tmp)%mod;
			cur = (cur - e[u] + mod)%mod;
		}
	}
	cout << dp[k] << endl;
}

Measured memory_bytes: 2560
#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(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int A[3][3];
int N;
bool done[3][3];

int main() {
	REP(i, 3) REP(j, 3) cin >> A[i][j];
	cin >> N;
	REP(i, N) {
		int b;
		cin >> b;
		REP(j, N) REP(k, N) if (A[j][k] == b) done[j][k] = true;
	}
	
	bool ans = false;
	REP(i, 3) {
		bool cur = true;
		REP(j, 3) if (!done[i][j]) cur = false;
		ans |= cur;
		
		cur = true;
		REP(j, 3) if (!done[j][i]) cur = false;
		ans |= cur;
	}
	
	bool cur = true;
	REP(i, 3) {
		if (!done[i][i]) cur = false;
	}
	ans |= cur;
	
	cur = true;
	REP(i, 3) if (!done[i][2 - i]) cur = false;
	ans |= cur;
	
	puts([&] {
		return ans;
	}() ? "Yes": "No");
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, x, a[110], ans;
int main(void){
    // Your code here!
    cin >> n >> x;
    for (ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (ll i = 1; i < n; i++){
        a[i] += a[i - 1];
    }
    ll res = n;
    for (ll i = 0; i < n; i++){
        if (a[i] > x) {
            res = i;
            break;
        }
    }
    if (res == n){
        if (a[n - 1] == x) cout << res << endl;
        else cout << res - 1 << endl;
    } else {
        cout << res << endl;
    }
}


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

int main() {
	int an = 0;

	int m1 = 0;
	int m2 = 0;
	
	int d1 = 0;
	int d2 = 0;

	cin >> m1;
	cin >> d1;
	cin >> m2;
	cin >> d2;

	if (m1 == m2) {
		an = 0;
		cout << an;
	}
	else if (m1 != m2) {
		an = 1;
		cout << an;
		}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int R = fs.nextInt();
        int G = fs.nextInt();
        int B = fs.nextInt();
        int n = fs.nextInt();
        int res = 0;
        for(int i=0;i*R<=n;i++){
            for(int j=0;i*R+j*G<=n;j++){
                if((n-i*R-j*G)%B==0){
                    res++;
                }
            }
        }
        System.out.println(res);
    }
    static class FastScanner {
            private final InputStream in = System.in;
            private final byte[] buffer = new byte[1024];
            private int ptr = 0;
            private int buflen = 0;
            private boolean hasNextByte() {
                if (ptr < buflen) {
                    return true;
                }else{
                    ptr = 0;
                    try {
                        buflen = in.read(buffer);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (buflen <= 0) {
                        return false;
                    }
                }
                return true;
            }
            private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
            private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
            public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
            public String next() {
                if (!hasNext()) throw new NoSuchElementException();
                StringBuilder sb = new StringBuilder();
                int b = readByte();
                while(isPrintableChar(b)) {
                    sb.appendCodePoint(b);
                    b = readByte();
                }
                return sb.toString();
            }
            public long nextLong() {
                if (!hasNext()) throw new NoSuchElementException();
                long n = 0;
                boolean minus = false;
                int b = readByte();
                if (b == '-') {
                    minus = true;
                    b = readByte();
                }
                if (b < '0' || '9' < b) {
                    throw new NumberFormatException();
                }
                while(true){
                    if ('0' <= b && b <= '9') {
                        n *= 10;
                        n += b - '0';
                    }else if(b == -1 || !isPrintableChar(b)){
                        return minus ? -n : n;
                    }else{
                        throw new NumberFormatException();
                    }
                    b = readByte();
                }
            }
            public int nextInt() {
                long nl = nextLong();
                if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
                return (int) nl;
            }
            public double nextDouble() { return Double.parseDouble(next());}
        }
}


Measured memory_bytes: 32528
import math
s = input()
n = len(s)
if s==s[::-1]:
    s_2 = []
    for i in range(math.floor((n-1)/2)):
        s_2 += s[i]
    #print(s_2)
    if s_2==s_2[::-1]:
        s_3 = []
        for i in range(math.floor((n+3)/2)-1,n):
            s_3 += s[i]
        if s_3==s_3[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int INF=1000000000;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
    ll int n;
    cin>>n;
    ll int a[n]={};
    rep(i,n){
        cin>>a[i];
    }
    vector<ll int> v;
    ll int temp=0;
    v.push_back(0);
    rep(i,n){
        temp+=a[i];
        v.push_back(temp);
    }
    sort(v.begin(),v.end());
    ll int mem=v[0];
    ll int memnum=0;
    ll int ans=0;
    rep2(i,0,n){
        while(v[i]==mem&&i!=n+1){
            i++;
        }
        ans+=(i-memnum)*(i-memnum-1)/2;
        memnum=i;
        mem=v[i];

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	cin >>n>>m;
	vector<vector<int>> ans(m,vector<int>( 2,0));
	set<int> list;
	for(int i=1;i<=n;i++){
		list.insert(i);
	}
	
	if(n%2==1){
		for(int i=0;i<m;i++){
			ans[i][0]=i+1;
		}
		for(int i=m-1; i>=0;i--){
			ans[i][1]=2*m+1-i-1;
		}
	}else{
		for (int i = 0; i < m; i++)
		{
			ans[i][0] = i + 1;
		}
		for (int i = m - 1; i >= 0; i--)
		{
		
			ans[i][1] = 2*m+2 - i-2;
		}
		for(int i=0;i<m/2;i++){
			ans[i][1]++;
		}
	}
	for(int i=0;i<m;i++){
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}

	//cout<<ans<<endl;
}
/* 8 3
3 4 -> 1,7
1 7 => 6,2
2 5	-> 3,5

1 7
2 5
3 4

7,1
5 2
2 5
*/

/* 10 4
1  9 8,2
2  8 6,4
3 6  3,7
4 5  1,9

2-> 8
4 ->6
*/

/* 11 5
1 10 -> 9,2
2 9   -> 7,4
3 8  -> 5 ,6
4 7 -> 3,8
5 6

*/

Measured memory_bytes: 16636
H, N = map(int, input().split())
dp = [[0]*(H+1) for _ in range(N)]
AB = [list(map(int, input().split())) for _ in range(N)]
a, b = AB[0]
for i in range(1, H+1):
    dp[0][i] = ((i-1)//a+1)*b
for i in range(1, N):
    a, b = AB[i]
    for j in range(H+1):
        if j>=a:
            dp[i][j] = min(dp[i][j-a]+b, dp[i-1][j])
        else:
            dp[i][j] = min(b, dp[i-1][j])
print(dp[-1][-1])


Measured memory_bytes: 120172
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            int Q = int.Parse(str[2]);
            int[] A = new int[Q];
            for (int i = 0; i < Q; i++) A[i] = int.Parse(Console.ReadLine());
            int[] Correct = new int[N];
            for (int i = 0; i < Q; i++) Correct[A[i] - 1]++;
            for(int i = 0; i < N; i++)
            {
                if (K + Correct[i] - Q > 0) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 17596
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;

int main(){
	cin>>s;
	int k=s.size();
	int xn=0;
	for(int i=0;i<k;i++){
		if(s[i]=='x')xn++;
	}
	if(xn>=8)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N,M = map(int, input().split())
    lr = []
    for _ in range(M):
        l,r = map(int, input().split())
        lr.append((l,r))
    lr1 = sorted(lr, key=lambda x: x[0])
    lr2 = sorted(lr, key=lambda x: x[1])
    res = lr2[0][1] - lr1[-1][0] + 1
    if res < 0:
        res = 0
    print(res)

if __name__ == '__main__':
    main()

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

int main(){
    using namespace std;
    string S;
    unsigned long ans{0};
    cin >> S;
    for(unsigned long i{0}; i * 2 < S.size(); ++i)ans += S[i] != S[S.size() - i - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		String s = sc.next();
		if(s.length() == a+b+1 &&
			s.indexOf("-") == a &&
			s.indexOf("-") == s.lastIndexOf("-")) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using namespace std;
 
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair

int main() 

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    double x=ceil((a+0.0)/d);
    double y=ceil((c+0.0)/b);
    //cout<<x<<y;
    if(x>=y) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a>b) System.out.println("a > b");
        else if(a<b) System.out.println("a < b");
        else System.out.println("a == b");

        sc.close();
    }
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  if (N == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }
  if (N == 4) {
    cout << "2 5 20 63" << endl;
    return 0;
  }
  vector<int> seq = {2,3,4,9};
  vector<int> ans;
  if (N <= 100) {
    ans = seq;
    for (int i = 6; i < 1000000; i+=6) {
      ans.push_back(i);
      if ((int)ans.size() == N) {
        break;
      }
    }
  } else {
    int newN = (N+7)/8;
    vector<int> seq2 = {2,3,4,6,8,9,10,12};
    for (int i = 0; i < newN; i++) {
      for (int j = 0; j < 8; j++) {
        ans.push_back((i * 12) + seq2[j]);
      }
    }
    for (int i = 0; i < (int)ans.size(); i++) {
      if (ans[i] % 6 == 0) {
        ans.erase(ans.begin()+i);
      }
      if ((int)ans.size() == N) {
        break;
      }
    }
  }

  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3716