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

int main(void)
{
	string s, ans;
	cin>>s;
	int size=s.size();
	for( int i=0; i<size; i++ ){
		if(s[i]=='0') ans.push_back('0');
		else if(s[i]=='1') ans.push_back('1');
		else if(s[i]=='B' && ans.size()) ans.erase(ans.size()-1);
	}
	cout<<ans<<endl;
	return 0;
}

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

def f(n) :
    if n % 2 == 0 :
        return n // 2
    else :
        return 3 * n + 1
        
done = set()
a = s
i = 1
while not a in done :
    done.add(a)
    a = f(a)
    i += 1
print(i)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int x[200000];
int z[200000];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
        z[i]=x[i];
    }
    sort(z,z+n);
    for(i=0;i<n;i++)
    {
        if(x[i]!=z[n-1])
            printf("%d\n",z[n-1]);
        else printf("%d\n",z[n-2]);
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll a[100010];
ll d[100010];

void solve(){
    
    ll n;
    cin >> n;
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    a[n]=a[0];
    ll tmp = n*(n+1)/2;
    if(sum%tmp!=0){
        cout << "NO" << endl;
        return;
    }
    ll k = sum/(tmp);
    rep(i,n){
        d[i]=a[i+1]-a[i]-k;
    }

    bool b = true;
    rep(i,n){
        if(d[i]>0||abs(d[i])%n!=0) b=false;
    }

    cout << (b?"YES":"NO") << endl;

}

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


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	int N , K;
	cin >> N;
	cin >> K;
	int h[N];
	long long dp[N];
	long long inf=100000000000000000;
	for(int i = 0; i<N; i++){
		cin >> h[i];
		dp[i] = inf;
	}

	dp[0] = 0;

	for(int i = 0 ; i<N;i++){
		for(int j =1 ; j<=K ; j++){
			if(i+j >= N){
				break;
			}
			
			long long cost = abs(h[i] - h[i+j]) + dp[i];
			if( dp[i+j] > cost){
				dp[i+j] = cost;
				// cout << "i : " << i << " j : " << j << endl;
			}
		}

	}

	cout << dp[N-1] << endl;
}



Measured memory_bytes: 1408
n = int(input())
dp = [i for i in range(n+1)]  # dp table 最初は全て1円で払う
for j in range(1, n+1):
    power = 1
    while power <= j:
        dp[j] = min(dp[j], dp[j - power] + 1)
        power *= 6
    power = 1
    while power <= j:
        dp[j] = min(dp[j], dp[j - power] + 1)
        power *= 9
print(dp[n])


Measured memory_bytes: 7064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    if(v.front() != 0){
        puts("-1");
        return 0;
    }
    ll ans = 0;
    for (int i = 0; i < n-1; ++i) {
        if(v[i+1] > v[i]+1){
            puts("-1");
            return 0;
        }
        if(v[i+1] == v[i]+1) ans++;
        else ans += v[i+1];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int A; int B;
	while (~scanf("%d%d%d", &N, &A, &B)) {
		puts(abs(A - B) % 2 == 0 ? "Alice" : "Borys");
	}
	return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==0){
      cout<<s[i];
    }
  }
  cout<<endl;
}
///////////////////////////

Measured memory_bytes: 512
//atcoder clange
#include <stdio.h>



int main(void){
    int N,X;
   scanf("%d", &N);//数値の取得
      scanf("%d", &X);//数値の取得
	int L[N];
  	int i=0;
  for(i=0;i<N;i++){
	scanf("%d",&L[i]);
  }
  int D = 0;
  for(i=0;i<N;i++){
	D =D + L[i];
    if(D > X){
		printf("%d",i+1);
      	return 0;
    }
  }
    
  printf("%d",i+1);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2e5 + 9;
int n, k, c, mem[N];
ii last[N];
vi take;
string str;
int solve(int idx) {
	if (idx >= n) return 0;
	int& ret = mem[idx];
	if (ret != -1) return ret;
	if (str[idx] == 'o')
		return ret = 1 + solve(idx + c + 1);
	return ret = solve(idx + 1);
}
int main() {
//	file();
	fast();
	memset(mem, -1, sizeof mem);
	memset(last, -1, sizeof last);
	cin >> n >> k >> c;
	cin >> str;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'o')
			take.push_back(i);
	}
	int cnt = 0;
	int before = -1;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'x') continue;
		last[i] = { cnt, before };
		cnt++, before = i;
		i += c;
	}
	for (int i = 0; i < n; i++) {
		if (str[i] == 'x') continue;
		if (last[i].first == -1)
			continue;
		int can = last[i].first;
		int idx = upper_bound(all(take), i) - take.begin();
		if (idx != sz(take)) {
			can += solve(take[idx]);
		}
		if (can < k)
			cout << i + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 11276
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final char NG = '1';
    static final char OK = '0';
    static long[][] dp;
    static long[] sum;
    
    public static void main(String[] args) {
        int N = nint();
        long[] a = nlongs(1, N, 0);
        sum = new long[N+1];
        for (int i = 1; i <= N; i++) {
            sum[i] = sum[i-1] + a[i];
        }
        
        dp = new long[N+1][N+1];
        
        System.out.println(solve(1, N));
    }
    
    private static long solve(int l, int r) {
        if (l == r) { return 0; }
        if (dp[l][r] != 0) { return dp[l][r]; }
        
        long min = INF_L;
        for (int k = l; k < r; k++) {
            min = min(min, solve(l, k) + solve(k+1, r));
        }
        
        return dp[l][r] = min + sum[r] - sum[l-1];
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(0, N, 0);
    }

    @Deprecated
    private static int[] nints(int padL, int N, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(0, N, 0);
    }

    static long[] nlongs(int padL, int N, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(0, N, 0);
    }

    static double[] ndoubles(int padL, int N, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve();

int main()
{
    fst;
    //test(t);
     solve();
}

/**********************<="Actual code strats here"=>*****************************/


void solve()
{
    vector<vin> v(100);

    int x,n;
    cin>>x>>n;
    rep(i,0,n)
    {
        int l;
        cin>>l;
        v[abs(l-x)].push_back(l);
    }

    if(v[0].size()==0) {cout<<x<<endl;return;}
    rep(i,1,100)
    {
        if(v[i].size()<2)
        {
            if(v[i].size()==0)
            {
                cout<<x-i<<endl;
            }
            else 
            {
                cout<<2*x-v[i][0]<<endl;
            }
            return;
        }
    }
}

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

int main(){
  int a, b, c;
  cin >> a >> b >>c;
  int ans =0;
  for(int i=a; i<=b; i++){
    if(c%i ==0){
      ans++;
    }
  }

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

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v0(n);
    for (int i = 0; i < n; i++) std::cin >> v0[i];
    std::cin >> n;
    std::vector<int> v1(n);
    for (int i = 0; i < n; i++) std::cin >> v1[i];
    
    int size;
    int large;
    if (v0.size() < v1.size()){
        size = v0.size();
        large = 1;
    }
    else {
        size = v1.size();
        large = 0;
    }
    
    for (int i = 0; i < size; i++){
        if (v0[i] > v1[i]){
            std::cout << "0" << std::endl;
            return 0;
        }
        if (v0[i] < v1[i]){
            std::cout << "1" << std::endl;
            return 0;
        }
    }
    std::cout << large << std::endl;
    
}


Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int X,Y;
    cin >> X>>Y;



    cout << X+Y/2;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      mut n: usize,
   }
   let mut i = 2;
   let mut ans = 0;
   let s: Vec<_> = (1..20)
      .scan(0, |state, i| {
         *state += i;
         Some(*state)
      })
      .collect();
   while i * i < n {
      if n % i == 0 {
         let mut c = 0;
         while n % i == 0 {
            c += 1;
            n /= i;
         }
         ans += s.upper_bound(&c);
      }
      i += 1;
   }
   if n != 1 {
      ans += 1;
   }
   println!("{}", ans);
}


/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
   fn lower_bound(&self, x: &T) -> usize;
   fn upper_bound(&self, x: &T) -> usize;
}
#[allow(dead_code)]
impl<T: Ord> BinarySearch<T> for [T] {
   fn lower_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            std::cmp::Ordering::Less => {
               low = mid + 1;
            }
            std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
   fn upper_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
               low = mid + 1;
            }
            std::cmp::Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
}


Measured memory_bytes: 2196
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<set>
using namespace std;
using ll = long long;

int n, r, a, b;
int t[100];
int u[100], size;
int main() {
	while (cin >> n >> r && n&&r) {
		for (int i = 0; i<n; i++)t[i] = n - i;
		for (int i = 0; i<r; i++) {
			cin >> a >> b;
			for (int j = 0; j<b; j++)u[j] = t[j + a - 1];
			for (int j = a - 2; j >= 0; j--)t[j + b] = t[j];
			for (int j = 0; j<b; j++)t[j] = u[j];
		}
		cout << t[0] << endl;
	}
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007
#define GRID 3

using namespace std;

typedef long long ll;

int main()
{
    int c[GRID][GRID] = {0};
    REP(i, GRID)
    {
        REP(j, GRID)
        {
            cin >> c[i][j];
        }
    }
    // a1, a2, a3 を固定してb1, b2, b3 が存在するか確かめる
    int a1, a2, a3;
    for (a1 = 0; a1 <= 100; ++a1)
    {
        for (a2 = 0; a2 <= 100; ++a2)
        {
            for (a3 = 0; a3 <= 100; ++a3)
            {
                if ((c[0][0] - a1 >= 0) && (c[0][0] - a1 == c[1][0] - a2) && (c[0][0] - a1 == c[2][0] - a3) &&
                    (c[0][1] - a1 >= 0) && (c[0][1] - a1 == c[1][1] - a2) && (c[0][1] - a1 == c[2][1] - a3) &&
                    (c[0][2] - a1 >= 0) && (c[0][2] - a1 == c[1][2] - a2) && (c[0][2] - a1 == c[2][2] - a3) )
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

const mod int64 = 1000000007

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,10000000),bufio.NewWriterSize(os.Stdout,100)}
  n := io.NextInt()
  a := io.NextIntArray()
  m := int64(0)
  s := int64(0)
  for i:=0;i<n;i++ {
    s = (s+inv(a[i]))%mod
    if m < a[i] { m = a[i] }
  }
  for p:=int64(2);p*p<=m;p++ {
    x := 0
    for i:=0;i<n;i++ {
      y := 0
      for a[i]%p == 0 { a[i],y = a[i]/p,y+1 }
      if x < y { x = y }
    }
    s = (s*pow(p,x))%mod
  }
  set := make(map[int64]struct{})
  for i:=0;i<n;i++ {
    if a[i] != 1 { set[a[i]] = struct{}{} }
  }
  for k,_ := range set { s = (s*k)%mod }
  io.Println(s)
  io.Flush()
}

func pow(a int64,b int) int64 {
  p := int64(1)
  for b != 0 {
    if b&1 == 1 { p = (p*a)%mod }
    a = (a*a)%mod
    b = b>>1
  }
  return p
}
func inv(n int64) int64 {
  var a,b,c,x int64 = (n%mod+mod)%mod,mod,0,1
  for b != 0 { a,b,c,x = b,a%b,x-(a/b)*c,c }
  return (x%mod+mod)%mod
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInt() int {
  n,_ := strconv.Atoi(io.NextLine())
  return n
}
func(io *IO) NextIntArray() []int64 {
  s := strings.Fields(io.NextLine())
  a := make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define endl "\n"
#define mod 1000000007

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
n,k = map(int, input().split())
h = list(int(input()) for _ in range(n))
h.sort()
ans = float("INF")
for i in range(n-k+1):
  if h[i+k-1] - h[i] < ans:
    ans = h[i+k-1] - h[i]
print(ans)

Measured memory_bytes: 7492
def divisor(x):
    res = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            res.append(i)
            if i * i != x:
                res.append(x // i)
    res.sort()
    return res


def prime_factorization(x):
    N = x
    d = divisor(x)
    res = []
    for i in d:
        if i == 1:
            continue
        cnt = 0
        while N % i == 0:
            cnt += 1
            N //= i
        if cnt != 0:
            res.append((i, cnt))
    return res


if __name__ == "__main__":
    n, p = map(int, input().split())
    pf = prime_factorization(p)

    ans = 1
    for v, cnt in pf:
        if cnt >= n:
            ans *= v**(cnt//n)

    print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+10;
int vis[maxn];
pair<int,int> ans[maxn];
void dfs(int a,int b)
{
	if (a==0)return ;
	printf("%d %d\n",a,b);
	if (vis[a])dfs(a-1,a);
	else dfs(a-1,b);
}
int main()
{
	int n=0;
	int x;
	while (~scanf("%1d",&x)){
		n++;
		vis[n]=x;
	}
	for (int i=0;i<=n;i++)if (vis[i]!=vis[n-i])return 0*puts("-1");
	if (vis[1]==0)return 0*puts("-1");
	dfs(n-1,n);
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC168 B
	string s;
	int k;
	// K
	// S

	cin >> k;
	cin >> s;

	if (s.length() > k) {
		cout << s.substr(0, k) << "...";
	}
	else {
		cout << s;
	}


	return 0;
}


Measured memory_bytes: 3624
n = int(input())
ml = list(map(int, input().split()))
bl = list(map(int, input().split()))

bl = [0] + bl
mod = 0
kill = 0
for i in reversed(range(n+1)):
	if ml[i] >= bl[i] + mod:
		kill += bl[i] + mod
		mod = 0
	else:
		kill += ml[i]
		if mod >= ml[i]:
			mod = bl[i]
		else:
			mod = bl[i] + mod  - ml[i] 

print(kill)

Measured memory_bytes: 18624
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
//END OF TEMPLATE

void main(){
    ulong n,k;
    scan(n,k);
    ulong[ulong] a;
    foreach(i;0..k){ 
        scan!int;
        scanarr!ulong.each!(as=>a[as]=0);
    }       
    iota(1,n+1).filter!(s=>!(s in a)).array.length.writeln;
}


Measured memory_bytes: 3948
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
ll n,a,b;
ll tmax(ll x1,ll y1)
{
    if (x1>y1) return x1;
    return y1;
}
ll tmin(ll x1,ll y1)
{
    if (x1<y1) return x1;
    return y1;
}
int main()
{
    cin>>n>>a>>b;
    cout<<tmin(a,b)<<' '<<tmax(0,a+b-n)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        String b = Integer.toString(n, k);
        System.out.println(b.length());
        sc.close();
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
#include <stack>
#include <unordered_set>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 3e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n, m;
map<int, int> mp;

int main() {
    int i, j;
    cin >> n;
    for (i = 0; i < n; ++i) {
        int t;
        cin >> t;
        ++mp[t];
    }
    int ans = 0;
    for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
        if (it->first > it->second)
            ans += it->second;
        else if (it->first < it->second)
            ans += it->second - it->first;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    long long a[100];

    queue<pair<int, int> > que;

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    int ma = INT_MIN, mi = INT_MAX;
    int mai, mii;
    for(int i = 0;i < n;i++){
        if(ma < a[i]){
            ma = a[i];
            mai = i;
        }else if(mi > a[i]){
            mi = a[i];
            mii = i;
        }
    }

    if(abs(mi) < abs(ma)){
        que.push(make_pair(mai+1, n));
        que.push(make_pair(n, n));
        for(int i = 1;i < n;i++){
            que.push(make_pair(n, i));
            que.push(make_pair(n, n));
        }
    }else{
        que.push(make_pair(mii+1, 1));
        que.push(make_pair(1, 1));
        for(int i = n;i > 1;i--){
            que.push(make_pair(1, i));
            que.push(make_pair(1, 1));
        }
    }

    cout << que.size() << endl;

    while(!que.empty()){
        cout << que.front().first << " " << que.front().second << endl;
        que.pop();
    }

    return 0;
}


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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> cnts(26, 0);
  for (int i = 0; i < n; ++i) cnts[s[i] - 'a']++;
  vector<int> lcnts(26, 0);
  int mx = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    int nu = s[i] - 'a';
    lcnts[nu]++;
    if (lcnts[nu] == 1 && cnts[nu] > 1) cnt++;
    else if (lcnts[nu] == cnts[nu] && cnts[nu] > 1) cnt--;
    mx = max(cnt, mx);
  }
  cout << mx << endl;
}


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

int edge[200][200];
string s[300];
int l[200];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<n;j++)
			edge[i][j]=int(s[i][j]-'0');
	}
	queue<int> q;
	int ans=-1;
	for(int i=0;i<n;i++){
		memset(l,-1,sizeof l);
		l[i]=0;
		q.push(i);
		bool ok=true;
		while(!q.empty()){
			int now=q.front();q.pop();
			for(int j=0;j<n;j++)
				if(edge[now][j]){
					
					if(l[j]==-1){
						l[j]=l[now]+1;
						q.push(j);
					}
					else{
						if(abs(l[j]-l[now])!=1){
							ok=false;
							break;
						}
					}
				}
			if(!ok){
				while(!q.empty())	q.pop();
				break;
			}
		}
		if(!ok)	continue;
		for(int j=0;j<n;j++)
			ans=max(ans,l[j]+1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    long long X, Y;
    cin >> X >> Y;

    long long now = X;
    int ans = 0;
    while (now <= Y) {
        ans++;
        now *= 2;
    }

    cout << ans << endl;

    return 0;
}

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

N = int(input())

str_list = [input() for _ in range(N)]
count_dict={'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for i in range(N):
    count_dict[str_list[i]] += 1

for k, v in count_dict.items():
    print(k,' x ', v)

Measured memory_bytes: 16316
#include <bits/stdc++.h>
#define trav(var, container) for(auto& var: container)
#define all(container) begin(container), end(container)
using namespace std;
using ld = long double; 
using ll = long long;
const int N = (int)1e5;

ll arr[N];
ll dp[N][2];
int main() {
  int n; cin >> n;
  for(int i = 0; i < n; ++i) cin >> arr[i];
  for(int i = 0; i < n; ++i) dp[i][0] = dp[i][1] = LLONG_MIN / 10;
  dp[0][0] = arr[0];
  dp[0][1] = -arr[0];
  for(int i = 1; i < n - 1; ++i) {
    dp[i][0] = max(dp[i-1][0] + arr[i], dp[i-1][1] - arr[i]);
    dp[i][1] = max(dp[i-1][0] - arr[i], dp[i-1][1] + arr[i]);
  }
  dp[n-1][0] = max(dp[n-2][0] + arr[n-1], dp[n-2][1] - arr[n-1]);
  cout << dp[n-1][0];
  return 0;
}

Measured memory_bytes: 2560
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []

H=lines[1].split(' ')

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y.append(A-1)
    if int(H[B-1]) <= int(H[A-1]):
      Y.append(B-1)
Z = len(set(Y))
print(N-Z)


Measured memory_bytes: 30720
#include <stdio.h>
int main(void){
    int d;
    long area=0;
    int i;
    
    while(scanf("%d",&d) != EOF){
        area=0;
        for(i=d; i<=600-d; i+=d){
            area+=i*i*d;
        }
        printf("%ld\n",area);
    }
    
    return 0;
}

Measured memory_bytes: 592
MOD = 10 ** 9 + 7
dp = [0, 0]
ans = 0
t = 1
for c in input():
    ndp = dp.copy()
    if c in 'A':
        ndp[0] = (dp[0] + t) % MOD
    elif c in 'B':
        ndp[1] = (ndp[1] + dp[0]) % MOD
    elif c in 'C':
        ans = (ans + dp[1]) % MOD
    else:
        ndp[0] = (3 * dp[0] + t) % MOD
        ndp[1] = (3 * dp[1] + dp[0]) % MOD
        ans = (3 * ans + dp[1]) % MOD
        t = (t * 3) % MOD
    #print(*ndp, ans)
    dp = ndp
print(ans)

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int K, X;
  cin >> K >> X;
  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap( int* num1, int* num2 );
int getGCD( int num1, int num2, int* numOfStep );

int main( void )
{
	int num1;
	int num2;
	
	int GCD;
	int numOfStep;
	
	while( 1 )
	{
		numOfStep = 0;
		scanf( "%d%d", &num1, &num2 );
		if( num1 == 0 && num2 == 0 )break;
		
		GCD = getGCD( num1, num2, &numOfStep );
		printf( "%d %d\n", GCD, numOfStep );
	}
	
	return (0);
}

void swap( int* num1, int* num2 )
{
	int tmp = *num1;
	*num1 = *num2;
	*num2 = tmp;
}

int getGCD( int num1, int num2, int* numOfStep )
{
	if( num1 < num2 )swap( &num1, &num2 );
	
	num1 = num1 % num2;
	swap( &num1, &num2 );
	(*numOfStep)++;
	if( num2 == 0 )return (num1);
	
	return ( getGCD( num1, num2, numOfStep ) );
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

const int inf = INT32_MAX;

int main() {
  int v, e;
  cin >> v >> e;
  V<V<ll>> graph(v, V<ll>(v, inf));

  rep(i, v) {
    graph[i][i] = 0;
  }

  rep(i, e) {
    int s, t, d;
    cin >> s >> t >> d;
    graph[s][t] = d;
  }

  rep(k, v) {
    rep(i, v) {
      if(graph[i][k] == inf) continue;
      rep(j, v) {
        if(graph[k][j] == inf) continue;
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }

  bool negative = false;

  rep(i, v) {
    if(graph[i][i] < 0) {
      negative = true;
      break;
    }
  }

  if(negative) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  rep(i, v) {
    rep(j, v) {
      if(graph[i][j] == inf) {
        cout << "INF";
      } else {
        cout << graph[i][j];
      }

      if(j != v - 1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>

using namespace std;

#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<int,int> P;

#define NMAX 200005
char s[NMAX],t[NMAX];

int main(){
    
    int H,W,N;
    cin >> H >> W >> N;
    int sr,sc;
    cin >> sr >> sc;
    sr --;
    sc --;
    cin >> s;
    cin >> t;
    int lx = 0,rx = H-1,ly=0,ry=W-1;
    for(int i=N-1;i>=0;i--){
        if (t[i]=='U'){
            rx ++;
            rx=min(rx,H-1);
        } elif (t[i]=='D'){
            lx --;
            lx=max(lx,0);
        }elif (t[i]=='R'){
            ly --;
            ly=max(ly,0);
        }else{
            ry ++;
            ry=min(ry,W-1);
        }
        if(s[i]=='U') lx++;
        elif(s[i]=='D')rx--;
        elif(s[i]=='R')ry--;
        else ly++;
        if(lx>rx||ly>ry){
            cout << "NO"<<endl;
            return 0;
        }
    }
    if(!(lx<=sr&&sr<=rx)){
        cout << "NO"<<endl;
    }elif(!(ly<=sc&&sc<=ry)){
        cout << "NO"<<endl;
    }else{
        cout << "YES"<<endl;
    }
}

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

int main(){
  int n; cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  vector<double> dist(n*(n-1)/2);
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i];
  }
  double ans = 0.0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      ans += pow(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2), 0.5);
    }
  }
  ans = ans * 2 / n;
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
template<typename T>
struct edge {

	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	bool operator<(const edge<T> e1) {
		return cost < e1.cost;
	}


	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }

};
template<typename T>
using Edge = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edge<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;


int num[100005];
int main() {


	ll N, M;

	cin >> N >> M;

	rep(i, M) {
		ll a, b;
		cin >> a >> b;
		num[a] += 1;
		num[b] += 1;
	}

	bool flag = true;
	for (int i = 1; i <= N; i++) {


		if (num[i] % 2 == 1) { cout << "NO" << endl; return 0; }


	}

	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 768
from collections import *
n, m = map(int, input().split())
a = list(map(int, input().split()))
c = Counter()
v = 0
for e in a:
    v += e
    v %= m
    c[v] += 1
v = r = 0
for e in a:
    r += c[v]
    v += e
    v %= m
    c[v] -= 1
print(r)

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

using namespace std;

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int n, m, k;

inline bool isValidNode(int x, int y) {
	return x >= 0 && x < n && y >= 0 && y < m;
}

inline bool isWithinK(int x, int y, int ox, int oy, int k) {
	return (x == ox && abs(y - oy) <= k) || (y == oy && abs(x - ox) <= k);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin >> n >> m >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1;
	--y1;
	--x2;
	--y2;

	bool vis[4][n * m];
	bool empty[n * m];

	for (int i = 0; i < n; i++) {
		char c;
		for (int j = 0; j < m; j++) {
			cin >> c;
			empty[i * m + j] = c != '@';
			for (int k = 0; k < 4; k++)
				vis[k][i * m + j] = false;
		}
	}

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

	int dist[4][n * m];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < n * m; j++)
			dist[i][j] = INF;

	int s = x1 * m + y1;

	priority_queue<tuple<int, int, int, int>> pq;
	for (int i = 0; i < 4; i++) {
		dist[i][s] = 1;
		pq.push(make_tuple(-1, s, s, i));
	}

	while (!pq.empty()) {
		auto node = pq.top();
		pq.pop();
		int pos = get<1>(node), origin = get<2>(node), dir = get<3>(node);

		if (vis[dir][pos])
			continue;
		vis[dir][pos] = true;

		for (int i = 0; i < 4; i++) {
			int x = pos / m + dx[i], y = pos % m + dy[i];
			int newPos = x * m + y;
			int newDir = i;
			if (!isValidNode(x, y) || !empty[newPos] || vis[newDir][newPos])
				continue;
			int newCost = 0;
			int newOrigin = origin;
			if (!isWithinK(x, y, origin / m, origin % m, k)) {
				++newCost;
				newOrigin = pos;
			}
			if (dist[dir][pos] + newCost < dist[newDir][newPos]) {
				dist[newDir][newPos] = dist[dir][pos] + newCost;
				pq.push(
						make_tuple(-dist[newDir][newPos], newPos, newOrigin,
								newDir));
			}
		}
	}
	int e = x2 * m + y2;
	int ans = INF;
	for (int i = 0; i < 4; i++)
		ans = min(ans, dist[i][e]);
	cout << (ans == INF ? -1 : ans) << '\n';
	return 0;
}


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

#define MAX 999999
bool flag[MAX+1];

void check_prime_num(int x){

  int way = sqrt(x);

  for(int i=2;i<way+1;++i) {
    if(x%i==0) break;
    else if(way==i) flag[x] = true;
  }

}

int solve(int n){

  int cnt = 0;

  for(int i=0;i<=n;++i){
    if(flag[i]) ++cnt;
  }

  return cnt;
}

int main(){

  int n;

  memset(flag, false, MAX);
  flag[2] = true; flag[3] = true;

  for(int i=4;i<=MAX;++i){ check_prime_num(i); }

  while(cin>>n){ cout << solve(n) << endl; }

}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N>>K;
}
//=============================
void func(){}
//=============================
void solve()
{
    int ans = 0;

    ans = N;
    if (K < N)ans--;
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
/* AtCoder Regular Contest 080. Task D - Grid Coloring, by Abreto<m@abreto.net>. */
#include <stdio.h>

int H, W;
int gird[128][128];

void next(int *i, int *j)
{
    if( (*i) & 1 ) /* from right to left */
    {
        if(*j) (*j)--;
        else   (*i)++;
    } else { /* from left to right */
        if((*j) != W-1) (*j)++;
        else (*i)++;
    }
}

int main(void)
{
    int i = 0, j = 0;
    int N = 0, ai = 0;
    int x = 0, y = 0;
    scanf("%d %d", &H, &W);
    scanf("%d", &N);
    for(i = 1;i <= N;++i)
    {
        scanf("%d", &ai);
        while(ai--)
        {
            gird[x][y] = i;
            next(&x, &y);
        }
    }
    for(i = 0;i < H;++i)
    {
        printf("%d", gird[i][0]);
        for(j = 1;j < W;++j)
            printf(" %d", gird[i][j]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
//#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Ans = 0;cin >> N;
map<string, ll> MAP;
for(ll i = 0; i < N; i++){
string s;cin >> s;
sort(ALL(s));
MAP[s]++;
}

for(auto x : MAP){
Ans += (x.second*(x.second - 1))/2;
}
cout << Ans;
}


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

using ll = long long;
using pint = pair<int, int>;

const ll INF = 1e12;
const ll MOD = 1e9 + 7;

ll N;
vector<ll> A;

ll gcd(ll x, ll y)
{
    return (y ? gcd(y, x % y) : x);
}

int main()
{
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    vector<ll> left(N);
    vector<ll> right(N);

    left[0] = A[0];
    for (int i = 0; i < N - 1; ++i)
    {
        left[i + 1] = gcd(left[i], A[i + 1]);
    }

    right[N - 1] = A[N - 1];
    for (int i = N - 1; i > 0; --i)
    {
        right[i - 1] = gcd(right[i], A[i - 1]);
    }

    ll res = right[1];
    for (int i = 1; i < N - 1; ++i)
    {
        res = max(res, gcd(left[i - 1], right[i + 1]));
    }
    res = max(res, left[N - 2]);
    cout << res << endl;
}


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

int main(){
    int n,m;
    while(cin>>n,n){
        set<pair<int,int> > sp;

        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            sp.insert(make_pair(y,x));
        }

        cin>>m;
        int c=0;
        pair<int,int> now(10,10);

        for(int i=0;i<m;i++){
            char d;
            int len;

            cin>>d>>len;
            cin.ignore();

            for(int j=0;j<len;j++){
                switch(d){
                    case 'N':
                        now.first++;
                        break;
                    case 'S':
                        now.first--;
                        break;
                    case 'E':
                        now.second++;
                        break;
                    case 'W':
                        now.second--;
                        break;
                }

                decltype(sp.end()) it;
                if((it=sp.find(now)) != sp.end()){
                    c++;
                    sp.erase(it);
                }
            }
        }

        cout << (c==n ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class231
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var table = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                for(int j = -1; j <= 1; j++)
                {
                    var num = a[i] + j;
                    if (!table.ContainsKey(num)) table[num] = 1;
                    else table[num]++;
                }
            }
            Console.WriteLine(table.Values.Max());
        }
    }
}


Measured memory_bytes: 26208
#include<stdio.h>
int main(void){
  int x;
  
  scanf("%d",&x);
  
  if(x==25){
    printf("Christmas");
  }
  else if(x==24){
    printf("Christmas Eve");
  }
  else if(x==23){
    printf("Christmas Eve Eve");
  }
else if(x==22){
  printf("Christmas Eve Eve Eve");
  }
  
  return 0;
}

Measured memory_bytes: 128
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

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


Measured memory_bytes: 256
def attack(h, n, arr):
    h -= sum(arr)
    if h <= 0:
        return 'Yes'
    else:
        return 'No'

if __name__ == "__main__":
    h, n = map(int, input().split())
    arr = list(map(int,input().split()))
    print(attack(h, n, arr))

Measured memory_bytes: 13964
n = int(input())
a111 = list(map(int,input().split()))
a222 = list(map(int,input().split()))
al = []
sums = 0

for i in range(n):
    p = i
    for j in range(p+1):
        sums = sums + a111[j]    
    for k in range(p,n):
        sums = sums + a222[k]
    al.append(sums)
    sums = 0
    
print(max(al))

Measured memory_bytes: 3064
int main(int argc,const char * argv[])
{
    int H,W,i,j;
    while(1) {
        scanf("%d %d", &H, &W);
        if (H==0 && W==0) {
            break;
        }
        for (i=0;i<H;i++) {
            for (j=0;j<W;j++) {
                if ((i+j) % 2 == 0) {
                    putchar('#');
                }else{
                    putchar('.');
                }
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
using namespace std;
int sub(int n, int base) {
  int sum = 0;
  while (n > 0) {
    sum += n % base;
    n /= base;
  }
  return sum;
}

int N;
int main() {
  cin >> N;
  int mn = 1e9;
  for (int a = 0; a <= N; ++a) {
    int b = N - a;
    int ans = sub(a, 6) + sub(b, 9);
    mn = min(mn, ans);
  }
  cout << mn << endl;
}


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

int main(){
 int n,a,b;
 int sum=0;
 cin>>n>>a>>b;

 rep(i,n+1){
     if(i%10+(i/10)%10+(i/100)%10+(i/1000)%10+i/10000>=a&&i%10+(i/10)%10+(i/100)%10+(i/1000)%10+i/10000<=b){
sum+=i;
    }

 }

 cout<<sum<<endl;
}

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

int main(){

    int a,b;
    cin>>a>>b;
    for(int i=1;i<=1000;i++){
        if((int)(i*0.08)==a&&(int)(i*0.10)==b){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



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

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    string s;
    cin >> s;
    s[5] = s[13] = ' ';
    cout << s << endl;
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}  

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

using namespace std;

int main(){
    int n,m,total,sum=0;
    cin >>n >>m;

    vector<int> a(n);
    for(auto& e:a) cin >>e;
    total = accumulate(a.begin(),a.end(),0);
    for(auto& e:a){ 
        
        if(e>=total/4./m){
            sum++;
        }

    }
    if(sum>=m){
        cout << "Yes" <<endl;
    }else {
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;


/*--------------------template--------------------*/

ll dp[500][500];

int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			vi v(n, 0);
			memset(dp, 0, sizeof(dp));
			REP(i, n) cin >> v[i];
			FOR(i, 1, n)
			{
				REP(j, n - i)
				{
					FOR(k, j, j + i)
					{
						dp[j][j + i] = max(dp[j][j + i], dp[j][k] + dp[k + 1][j + i]);
						if (dp[j + 1][j + i - 1] == i - 1 && abs(v[j] - v[j + i]) < 2) {
							dp[j][j + i] = i + 1;
						}
					}
				}
			}
			cout << dp[0][n - 1] << endl;
		}
	}
}

Measured memory_bytes: 5016