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

typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define all(x) (x).begin() ,(x).end()

const int p = 1e9 + 7;

ll binpow(ll a, ll b , ll mod) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

const int dx[] = {1 , -1 , 0 , 0};
const int dy[] = {0 , 0 , -1 , 1};
const ll inf = 1e18 - 5LL;
const int N = 1e5 + 9;



void solve() {

	int n;
	cin >> n;

	ll k = binpow(10 , n , p);
	ll t = binpow(8 , n , p);
	ll zo = binpow(9 , n , p);

	k = (k % p + t % p) % p;
	k = (k - (2 * zo) % p + p) % p;

	cout << k << "\n";
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();

	return 0;
}

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

int main()
{
    map<string,bool>mp;
   int n;
   cin >>n;
   while(n--){
        string k;
        cin >> k;
        mp[k] = true;
   }
   cout <<mp.size() <<endl;
    return 0;
}


Measured memory_bytes: 19208
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	vector<LLONG> as(N); REP(i, N) cin >> as[i];
	LLONG money = 1000;
	for (int i = 0; i < N;)
	{
		LLONG high = as[i];
		int next = i + 1;
		for (int j = i + 1; j < N; ++j)
		{
			if (as[i] >= as[j])
			{
				next = j;
				break;
			}
			else
			{
				if (high <= as[j])
				{
					high = as[j];
					next = j + 1;
				}
				else
				{
					next = j;
					break;
				}
			}
		}
		if (high > as[i])
		{
			LLONG stock = money / as[i];
			money %= as[i];
			money += high * stock;
		}
		i = next;
	}
	cout << money << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;cin>>k>>n;
  int a[n+1],b[n+1];a[0]=0,b[0]=0;
  for(int i=1;i<=n;i++){cin>>a[i];b[i]=a[i]-a[i-1];}
  b[1]+=k-a[n];
  int g=INT_MIN;
  for(int i=1;i<=n;i++){g=max(g,b[i]);}
  cout<<k-g<<endl;
}


Measured memory_bytes: 1920
// SPDX-License-Identifier: X11
// 2020-06-27 (Live)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LIMIT 200005

int main(void) {
  char *S = malloc(LIMIT * sizeof(char));
  char *T = malloc(LIMIT * sizeof(char));
  scanf("%s %s", S, T);

  long n = 0;

  for(long i = 0; i < strlen(S); i++)
    if (S[i] != T[i])
      n++;

  printf("%ld\n", n);

  free(S);
  free(T);
}


Measured memory_bytes: 1820
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

bool solve() {
  int n;
  cin >> n;
  if (n == 0)
    return false;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  reverse(s.begin(), s.end());
  vector<long long> v;
  int indent = 0;
  for (int i = 0; i < n; i++) {
    int ind = 0;
    for (; s[i][ind] == '.'; ind++)
      ;
    if (indent < ind) {
      for (int j = 0; j < ind - indent; j++)
        v.push_back(-1);
    }
    indent = ind;

    if (s[i][ind] == '+' || s[i][ind] == '*') {
      long long ret = (s[i][ind] == '+') ? 0 : 1;
      while (v[v.size() - 1] >= 0) {
        if (s[i][ind] == '+') {
          ret += v[v.size() - 1];
        } else {
          ret *= v[v.size() - 1];
        }
        v.pop_back();
      }
      v.pop_back();
      v.push_back(ret);
    } else {
      v.push_back(s[i][ind] - '0');
    }
  }
  cout << v[0] << endl;
  return true;
}

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



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B / 2 << endl;
  } else {
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN = 500005, MAXM = (1 << 20), mod = 1000000007;
int a[MAXN], n, x, dp[MAXM][2], lazy[MAXM], sett, y, ans;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		x ^= a[i];
	}
	for(int i = 1; i < n; ++i) {
		y ^= a[i];
		if(y == 0) {
			++sett;
			dp[y][0] *= 2;
			++dp[y][0];
			dp[y][0] %= mod;
			lazy[y] = sett;
		}
		else {
			if(lazy[y] < sett) {
				dp[y][0] += (1LL * dp[y][1] * (sett - lazy[y])) % mod;
				dp[y][0] %= mod;
				lazy[y] = sett;
			}
			dp[y][1] += dp[y][0] + 1;
			dp[y][1] %= mod;
		}
	}
	for(int i = 0; i < MAXM; ++i) {
		dp[i][0] += (1LL * dp[i][1] * (sett - lazy[i])) % mod;
		dp[i][0] %= mod;		
	}
	if(x == 0) {
		for(int i = 0; i < MAXM; ++i) {
			ans += dp[i][1];
			ans %= mod;
		}
		ans += dp[0][0] + 1;
		ans %= mod;
	}
	else {
		ans = dp[x][0] + 1;
		ans %= mod;
	}
	cout << ans << endl;

}


Measured memory_bytes: 14464
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define pi acos(-1.0)

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    int k = n % 10;
    if (k == 3) {
        cout << "bon";
    } else if (k == 0 || k == 1 || k == 6 || k == 8) {
        cout << "pon";
    } else {
        cout << "hon";
    }

    return 0;
}

Measured memory_bytes: 3644
/**
 *    author:  tourist
 *    created: 13.01.2020 23:27:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cnt += (s[i][j] == '#');
    }
  }
  cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

#define MAXN 100000

int n,m,have[MAXN];
bool red[MAXN];

int main(){
    ios::sync_with_stdio(0);

    cin >> n >> m;

    for(int i = 0;i < n;++i){
        have[i] = 1;
        red[i] = false;
    }

    red[0] = true;
    int ans = 1;

    for(int i = 0,x,y;i < m;++i){
        cin >> x >> y;
        --x; --y;

        if(red[x]){
            if(have[x] == 1){
                red[x] = false;
                if(!red[y]) red[y] = true;
                else --ans;
            }else if(!red[y]){
                red[y] = true;
                ++ans;
            }
        }

        have[x]--;
        have[y]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;

int main (void){
  
    int n;
    long long answer = 1;
    cin >> n;
    FOR(i,1,n+1)
    answer = answer*i;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> height;
    int l;
  for(int i=0;i<n;i++){
    cin>>l;
    height.push_back(l);
  }
  vector<int> X(n,INT_MAX);
  X[0]=0;
 for(int i=0;i<n-1;i++){
 for(int j=1;j<=k;j++){
   if(i+j>=n){
     break;
 }
   X[i+j]=min(X[i+j],X[i]+abs(height[i]-height[i+j]));
 }}
  cout<<X[n-1]<<"\n";
}

Measured memory_bytes: 4160
n,x,y=map(int,input().split())
ans=[0]*(n-1)
ans[0]=n-1
for i in range(1,n-1):
    for j in range(i+2,n+1):
        length=min(abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))
        ans[length-1]+=1
for i in range(n-1):
    print(ans[i])


Measured memory_bytes: 3444
n,a,b = list(map(int,input().split(" ")))
mod = 10**9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result

def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q

print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)

Measured memory_bytes: 27700
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int l;
vi v[20];
vector<pair<int, pii> > ans;
void pri(int i, int j, int k){
  ans.pb(mp(i, mp(j, k)));
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> l;
  int b = 1, L = l, d = l;
  FOR(i, 1, 20){
    if(L%2){
      pri(i, 20, d-b);
      d -= b;
    }
    L >>= 1;
    if(L < 1) break;
    pri(i, i+1, 0);
    pri(i, i+1, b);
    b <<= 1;
  }
  cout << 20 << " " << sz(ans) << endl;
  FOR(i, 0, sz(ans)) cout << ans[i].fi << " " << ans[i].se.fi << " " << ans[i].se.se << endl;
  return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _  in range(3)]
n = int(input())
#b = [list(map(int, input().split())) for _ in range(n)]

while n > 0:
    b = int(input())
    for i in range(3):
        if b == a[0][i]:
            a[0][i] = "Yes"
    for j in range(3):
        if b == a[1][j]:
            a[1][j] = "Yes"
    for k in range(3):
        if b == a[2][k]:
            a[2][k] = "Yes"
    n -= 1
if a[0][0] == a[0][1] == a[0][2]:
    print("Yes")
elif a[1][0] == a[1][1] == a[1][2]:
    print("Yes")
elif a[2][0] == a[2][1] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][0] == a[2][0]:
    print("Yes")
elif a[0][1] == a[1][1] == a[2][1]:
    print("Yes")
elif a[0][2] == a[1][2] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
elif a[0][2] == a[1][1] == a[2][0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
ans = 0
ansl = []
for i in range(h):
    for j in range(w):
        if a[i][j] % 2 == 1 and a[i][j] >= 1:
            if j + 1 < w:
                a[i][j + 1] += 1
                a[i][j] -= 1
                ans += 1
                ansl.append([i + 1, j + 1, i + 1, j + 2])
for k in range(h):
    if a[k][-1] % 2 == 1:
        if k + 1 < h:
            a[k + 1][-1] += 1
            a[k][-1] -= 1
            ans += 1
            ansl.append([k + 1, w, k + 2, w])
print(ans)
for i in ansl:
    i = list(map(str, i))
    print(" ".join(i))

Measured memory_bytes: 30492
//package hiougyf;
import java.util.*;
//import java.lang.instrument.*;
import java.math.*;
import java.io.*;
public class Main {
	  public static void main  (String[] args)
	  	{
		  Scanner sc =new Scanner(System.in);
		  int n=sc.nextInt();
		  int a[]=new int[n+2];
		  boolean s[]=new boolean[n+2];
		  a[0]=0;
		  a[1]=1;
		  for(int i=2;i<=n;i++) {
			  a[i]=2;
			  s[i]=true;
		  }
		  	
		  	for(int i=2;i<=n;i++) {
		  		//if(s[i]) {
		  			int j=2;
		  			while(i*j<=n){
		  				if(s[i*j]==false) {
		  					//System.out.println(j+"fd");
		  					a[j*i]++;
		  				}
		  				else 
		  					{
		  					a[i*j]++;
		  					s[i*j]=false;
		  					}
		  				j++;
		  			}
		  		//}
		  	}
		  	long gg=0;
		  	for(int i=1;i<=n;i++) {
		 // 	System.out.print(a[i]+" "+s[i]);
		  		gg+=(i*(long)a[i]);
		  	}
		System.out.println(gg);
	  	}
	  
}

Measured memory_bytes: 85344
use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let n = sc.next_i32().unwrap();
	let ans = (1..n+1).filter(|x| x % 2 != 0 && (1..x+1).filter(|y| x % y == 0).count() == 8).count();
	println!("{}", ans);
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi p(n),q(n);
	REP(i,n) cin>>p[i];
	REP(i,n) cin>>q[i];
	
	vi v=p;
	sort(ALL(v));
	//line(v);
	
	int cnt=1;
	int pn=0,qn=0;
	do{
		bool jud=true;
		REP(i,n){
			if(p[i]!=v[i]){
				jud=false;
				break;
			}
		}
		if(jud) pn=cnt;
		
		jud=true;
		REP(i,n){
			if(q[i]!=v[i]){
				jud=false;
				break;
			}
		}
		if(jud) qn=cnt;
		
		if(pn>0 and qn>0) break;
		
		cnt++;
	}while(next_permutation(ALL(v)));
	
	debug(pn);
	debug(qn);
	
	cout<<abs(pn-qn)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  v(ll) A(N+1),B(N);
  rep(i,N+1) {
    cin >> A[i];
  }
  rep(i,N) {
    cin >> B[i];
  }
  ll ans = 0;
  rep(i,N) {
    ll able = B[i];
    if(able <= A[i]) {
      ans += able;
    } else {
      ans += A[i];
      able -= A[i];
      ans += min(able,A[i+1]);
      A[i+1] = max((ll)0,A[i+1]-able);
      
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
static const int MAX =1000001;
static const int INF = 1500000;
int Min[MAX]; //memo for speeding things up
int odd[MAX]; // same

// this is the improved version to 1167.cpp
void memo(){
   /*
     Same as problem 17.1 in the book Algo and Data Struct
     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A

    */

    /*
      Made the program substantially faster by making a memo of two different array with one loop

      

     */
    
    Min[0]=0;
    Min[1]=1;
    odd[0]=0;
    odd[1]=1;
    int i,j;
    for(i=0;i<MAX;i++){
	for(j=1;j<MAX;j++){
	    int b=(j*(j+1)*(j+2))/6;
	    if (i+b>MAX)break;
	    Min[i+b]=min(Min[i+b],Min[i]+1);
	    if(b%2){
		odd[i+b]=min(odd[i+b],odd[i]+1);
	    }
	 }
     }
 }


 int main(){
     int n;

     int i;
     memset(Min,INF,sizeof(Min));
     memset(odd,INF,sizeof(odd));
     memo();
    

    while(1){
	cin >>n;
	if(n==0)break;

	cout << Min[n] << " " << odd[n] << endl;
    }

    return 0;
}

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

#define MAX_NODE 10000000

typedef long long ll;
typedef unsigned int uint;
ll INF=(1LL<<60);

extern inline uint xor128(void){
  static uint x=123456789,y=362436069,z=521288629,w=88675123; 
  uint t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}

struct treap{
  treap* lch;
  treap* rch;
  uint pri;
  int cnt;
  ll val;
  ll min;
  treap(){  }
};

treap Field[MAX_NODE];
typedef treap* Treap;

int cnt(Treap t){  return (t?t->cnt:0); }
ll min(Treap t){ return (t?t->min:INF); }

Treap update(Treap t){
  if(!t)return NULL;
  t->cnt = cnt(t->lch) + cnt(t->rch) + 1;
  ll dat=t->val;
  dat=min(dat, min(t->lch) );
  dat=min(dat, min(t->rch) );
  t->min = dat;
  return t;
}

Treap makenode(ll v){
  static int cc=1;
  treap &res=Field[cc++];
  res.lch=res.rch=NULL;
  res.val=v;
  res.cnt=1;
  res.pri=xor128();
  return &res;
}

ll Find(Treap t,int k=1e9){
  k=min(k,cnt(t)-1);
  int f=cnt(t->lch);
  ll res;
  if(f>k)res=Find(t->lch,k);
  if(f<k)res=Find(t->rch,k-f-1);
  if(f==k)res=t->val;
  return res;
}

Treap merge(Treap l,Treap r){
  if(!l)return update(r);
  if(!r)return update(l);
  
  if( l->pri > r->pri ){
    l->rch = merge( l->rch , r );
    return update(l);
  }else{
    r->lch = merge( l , r->lch );
    return update(r);
  }
}

typedef pair< Treap, Treap > treaps;
treaps split(Treap t,int k){
  if(!t)return treaps(NULL,NULL);
  
  if(k<=cnt(t->lch)){
    treaps s=split(t->lch,k);
    t->lch=s.second;
    return treaps(s.first,update(t));
  }else{
    treaps s=split(t->rch, k-cnt(t->lch)-1 );
    t->rch=s.first;
    return treaps( update(t), s.second );
  }
}

Treap insertk(Treap t,int k,ll val){
  Treap f=makenode(val);
  treaps s=split(t,k);
  Treap res= merge( merge(s.first,f) , s.second );
  return res;
}

Treap erasek(Treap t,int k){
  treaps a=split(t,k);
  treaps b=split(a.second,1);
  Treap res= merge(a.first,b.second);
  return res;
}


int main(){
  Treap root=NULL;
  int n,q;
  scanf("%d %d",&n,&q);
  for(int i=0;i<n;i++){
    root=insertk(root,i,2147483647);
  }
  while(q--){
    int type;
    scanf("%d",&type);
    if(type==0){
      int i,x;
      scanf("%d %d",&i,&x);
      root=erasek(root,i);
      root=insertk(root,i,x);
    }else{
      int l,r;
      scanf("%d %d",&l,&r);
      r++;
      treaps tmp = split(root,r);
      treaps tmp2 = split( tmp.first,l);
      
      cout<< tmp2.second->min <<endl;
      root= merge( merge(tmp2.first,tmp2.second) , tmp.second );
    }
  }
  return 0;
}

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

constexpr int MAX_V = 100001;

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

  int v[n];
  for(int i = 0; i < n; ++i) cin >> v[i];

  int cnt[MAX_V] = {};
  for(int i = 0; i < n; i += 2){
    ++cnt[v[i]];
  }
  
  int fm1 = -1;
  int fid1;
  for(int i = 0; i < MAX_V; ++i){
    if(fm1 < cnt[i]){
      fid1 = i;
      fm1 = cnt[i];
    }
  }
  cnt[fid1] = -1;
  
  int fm2 = -1;
  int fid2;
  for(int i = 0; i < MAX_V; ++i){
    if(fm2 < cnt[i]){
      fid2 = i;
      fm2 = cnt[i];
    }
  }

  fill(cnt, cnt+MAX_V, 0);
  for(int i = 1; i < n; i += 2){
    ++cnt[v[i]];
  }
  int sm1 = -1;
  int sid1;
  for(int i = 0; i < MAX_V; ++i){
    if(sm1 < cnt[i]){
      sid1 = i;
      sm1 = cnt[i];
    }
  }
  cnt[sid1] = -1;
  
  int sm2 = -1;
  int sid2;
  for(int i = 0; i < MAX_V; ++i){
    if(sm2 < cnt[i]){
      sid2 = i;
      sm2 = cnt[i];
    }
  }

  if(fid1 != sid1){
    cout << n/2-fm1+n/2-sm1 << endl;
  }else{
    cout << min(n/2-fm1+n/2-sm2,n/2-fm2+n/2-sm1) << endl;
  }
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;



int main() {
	int n,i;
	for (i = 1; i <= 5; i++) {
		cin >> n;
		if (n == 0) {
			break;
		}
	}
	cout << i << endl;

}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, ans = 1;
   string s;
   cin >> n >> s;
   FOR(i, 0, n - 1)
   {
      if (s[i] != s[i + 1])
         ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 512
from itertools import accumulate as acc
from collections import Counter
n, m = map(int, input().split())
A = [a % m for a in map(int, input().split())]
B = [a % m for a in acc(A)]
C = Counter({0: 1})
cnt = 0
for x in B:
    if x in C:
        cnt += C[x]
    C[x] += 1
print(cnt)

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

using namespace std;
typedef long long ll;
#define mp make_pair

const int N = 1e5 + 10;

ll a[N];
ll dp[N][2];
ll res[N];

int main() {
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[n - 1][0] = dp[n - 1][1] = 1;
	for (int i = n - 2; i >= 0; i--) {
		dp[i][0] = dp[i][1] = 1;
		if (a[i] <= a[i + 1])
			dp[i][0] += dp[i + 1][0];
		if (a[i] >= a[i + 1])
			dp[i][1] += dp[i + 1][1];
	} 
	res[n] = 0;
	for (int i = n - 1; i >= 0; i--) {
		res[i] = min(res[i + dp[i][0]], res[i + dp[i][1]]) + 1;
	}
	cout << res[0] << endl;
	return 0;
}


Measured memory_bytes: 3328
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7744
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    S1 = list(_ for _ in input())
    S2 = list(_ for _ in input())
    S1_used = [-1]*N
    S2_used = [-1]*N
    
    if S1[0] == S2[0]:
        ans = 3
    else:
        ans = 6
    for i in range(1,N):
        if S1[i] != S1[i-1] and S1[i] != S2[i]:
            if S1[i-1] == S2[i-1]:
                ans *=2
            else:
                ans *=3
        elif S1[i] != S1[i-1] and S1[i] == S2[i]:
            if S1[i-1] == S2[i-1]:
                ans *=2
    print(ans%MOD)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define ll long long

int main(void){
    ll n;
    cin >> n;
    ll len[n];
    for(ll i = 0; i < n; i++)
        cin >> len[i];
    sort(len, len+n);
    ll ans = 0;
    for(ll i = 0; i < n-2; i++){
        for(ll j = i+1; j < n-1; j++){
            for(ll k = n-1; k >= j+1; k--){
                if(len[i]+len[j] > len[k]){
                    ans+=k-j;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// SegmentTree (0 - indexed)
// T: モノイド
template<typename T>
class SegmentTree {
    int n;
    const T ZERO;
    std::vector<T> data;
public:
    // 要素数を指定し、全要素加法単位元で初期化
    SegmentTree(int n_, T ZERO) : ZERO(ZERO) {
        n = 1;
        while (n < n_)n <<= 1;
        data.resize(2 * n);
        std::fill(data.begin(), data.end(), ZERO);
    }

    // 元となるstd::vectorを用意して初期化
    SegmentTree(std::vector<T> source, T ZERO) : ZERO(ZERO) {
        n = 1;
        while (n < source.size())n <<= 1;
        data.resize(2 * n);
        std::copy(source.begin(), source.end(), data.begin() + n);
        for (int i = n - 1; i > 0; i--)data[i] = data[2 * i] + data[2 * i + 1];
    }

    // [l, r)の区間和を取得
    T getSum(int l, int r) const {
        l += n, r += n;
        T ret = ZERO;
        while (l < r) {
            if (l & 1)ret += data[l], l++;
            if (r & 1)ret += data[r - 1];
            l >>= 1, r >>= 1;
        }
        return ret;
    }

    // 要素iをxに更新
    void update(int i, T x) {
        i += n;
        data[i] = x;
        while (i > 1) {
            i >>= 1;
            data[i] = data[2 * i] + data[2 * i + 1];
        }
    }
};

class Magma {
public:
    int val;

    Magma operator+(const Magma obj) {
        return Magma(min(val, obj.val));
    }

    Magma &operator+=(const Magma &obj) {
        val = (*this + obj).val;
        return *this;
    }

    Magma(int value) : val(val) {}
};

int n, q;

signed main() {
    cin >> n >> q;
    SegmentTree<int> st(n, 0);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)st.update(x - 1, y + st.getSum(x - 1, x));
        else cout << st.getSum(x - 1, y) << endl;
    }
}


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

int main(){
    stack<int> stk;
    int a;
    while(scanf("%d",&a) != EOF){
        if(a == 0){
            cout << stk.top() << endl;
            stk.pop();
        }else{
            stk.push(a);
        }
    }

    return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> lis(n), ruiseki(n+1), pu;
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, n){
        ruiseki[i+1] = ruiseki[i] + lis[i];
    }
    REP(i, 0, n){
        REP(l, i+1, n+1){
            pu.pb(ruiseki[l] - ruiseki[i]);
        }
    }
    n = pu.size();
    for(ll i = 49; i >= 0; i--){
        sort(ALL(pu), greater<>());
        ll c = (1LL << i);
        ll count = 0;
        REP(l, 0, n){
            ll f = 0;
            if((pu[l] & c) > 0){
                f = 1;
            }
            count += f;
        }
        //cout << count << endl;
        if(count >= k){
            pu.erase(pu.begin()+ count, pu.begin()+n);
            n = pu.size();
        }else{
            //cout << "# " << count << endl;
            //cout << c << endl;
            REP(l, 0, n){
                if((pu[l] & c) > 0){
                    //cout << pu[l] << endl;
                    pu[l] -= c;
                }
            }
        }
    }
    sort(ALL(pu),greater<>());
    cout << pu[0] << endl;
}

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

vector <int> niz;
int n,a,b,k;
vector <int> mini;


int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		niz.push_back(a);
	}
	
	mini.insert(mini.begin(),niz.size(),1e5);
	mini[0]=0;
	for(int i=1;i<niz.size();i++){
			mini[i]=mini[i-1]+abs(niz[i-1]-niz[i]);
			
			for(int j=2;j<=k && i-j>=0;j++){
				b=mini[i-j]+abs(niz[i-j]-niz[i]);
				if(b<mini[i])mini[i]=b;
		}
	}
	
	cout<<mini[n-1];
}


Measured memory_bytes: 1144
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func zalgo(str string) []int {
	n := len(str)
	a := make([]int, n)
	from, last := -1, -1
	a[0] = n
	for i := 1; i < n; i++ {
		idx := a[i]
		if from != -1 {
			idx = min(a[i-from], last-i)
			idx = max(0, idx)
		}
		for idx+i < n && str[idx] == str[idx+i] {
			idx++
		}
		a[i] = idx
		if last < i+idx {
			last = i + idx
			from = i
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	S := getString()

	ans := 0
	for n := 0; n < N; n++ {
		// out(S[n:])
		ret := zalgo(S[n:])
		for i := 1; i < len(ret); i++ {
			l := min(i, ret[i])
			ans = max(l, ans)
		}
	}
	out(ans)
}


Measured memory_bytes: 14208
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long ret = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    ret += input[i] * input[j];
                }
            }
            Console.Write(ret);
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
//import java.util.Scanner;
import java.util.StringTokenizer;

public class Main{

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}

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

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

		System.out.println(a*b);
	}

}

Measured memory_bytes: 32456
s = input()
c1,c2 = 0,0
for i in range(len(s)):
    if i%2 and s[i] == "1":
        c1 += 1
    elif i%2 and s[i] == "0":
        c2 += 1
    elif i%2==0 and s[i] == "0":
        c1 += 1
    else:
        c2 += 1
print(min(c1,c2))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int a[5]={},v_max=0,ans=0;
  rep(i,5){
    cin >> a[i];
    if(a[i]%10==0){
      ans += a[i];
    }else{
       ans += a[i] + (10 - a[i]%10);
       v_max = max(v_max,10 - a[i]%10);
    }
    // c(ans);
  }
  cout << ans - v_max << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    if a == 0 or b == 0:
        return max(a,b)
    return a if b==0 else gcd(b,a%b)
N = int(input())
A = list(map(int,input().split()))
rA = A[::-1]

LEFT = [0]
g = A[0]
for i in range(N):
    g = gcd(g,A[i])
    LEFT.append(g)


RIGHT = [0]
g = rA[0]
for i in range(N):
    g = gcd(g,rA[i])
    RIGHT.append(g)


ans = 0
for i in range(1,N+1):
    ans = max(ans,gcd(LEFT[i-1],RIGHT[N-i]))
print(ans)

Measured memory_bytes: 97832
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,m,d;
  cin>>n>>m>>d;
  if(d == 0){
    cout << (1/n)*(m-1) << endl;
  }
  else{
    cout << setprecision(10) << (2*(n-d))*(m-1)/(n*n)<< endl;
  }
  return 0;
}


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

int q1,q2,q3;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        if(t<=a) q1++;
        else if(t>=b+1) q3++;
        else q2++;
    }
    cout<<min({q1,q2,q3})<<endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	vector<int> a(3);
	for (auto &i : a) cin >> i;
	sort(a.begin(), a.end());
	if ((a[0]==a[1]) + (a[1]==a[2]) + (a[0]==a[2]) == 1)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
int coj, coi;

int main(){
	while (cin >> s){
		coi = coj = 0;
		REP(i, s.size() - 2){
			string t = s.substr(i, 3);
			if (t == "JOI")coj++;
			if (t == "IOI")coi++;
		}
		cout << coj << endl;
		cout << coi << endl;
	}
}

Measured memory_bytes: 1212
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;


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

    unordered_map<string, int> mp;

    for(int i=0;i<n;i++){
        string temp;
        cin>>temp;
        sort(temp.begin(), temp.end());
        mp[temp]++;
    }
    int ans = 0;
    for(auto itr = mp.begin();itr!=mp.end();itr++){
        int temp = itr->second;
        ans += (temp*(temp-1))/2;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10660
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static int[] par, dep, ch;

	static void solve() {
		out.println((ir.nextInt()+ir.nextInt()+1)>>>1);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 20948
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 3010;
const int mod = 1e9 + 7;

char s[N];
int g[N], l[N], r[N], tr[N];
LL c[N][N], f[N][N];

void upd(LL &a, LL b) { a = (a + b) % mod;}

int main()
{
	//freopen("f.in", "r", stdin);
	//freopen("f.out", "w", stdout);
	
	int n, m;
	scanf("%d%d", &n, &m);
	
	c[0][0] = 1;
	Rep(i, n) {
		c[i][0] = 1;
		Rep(j, i) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
	}
	
	scanf("%s", s + 1);
	Rep(i, n) g[i] = g[i - 1] + s[i] - '0';
	
	Rep(i, m) {
		int ll, rr;
		scanf("%d%d", &ll, &rr);
		tr[ll] = max(tr[ll], rr);
	}
	int m0 = 0;
	Rep(i, n) if (tr[i]){
		bool flag = true;
		Rep(j, i - 1) if (tr[i] <= tr[j]) flag = false;
		if (flag) l[++ m0] = i, r[m0] = tr[i];
	}
	f[0][0] = 1;
	Rep0(i, m0 - 1){
		if (l[i + 1] > r[i])
			Rep0(j, r[i] - l[i] + 1) upd(f[i + 1][g[r[i + 1]] - g[l[i + 1] - 1]], f[i][j] * c[r[i] - l[i] + 1][j]);
		else {
			Rep0(j, r[i] - l[i] + 1) if (f[i][j]){
				for (int k = max(0, j - (r[i] - l[i + 1] + 1)); k <= min(l[i + 1] - l[i], j); k ++)
					upd(f[i + 1][j - k + g[r[i + 1]] - g[r[i]]], f[i][j] * c[l[i + 1] - l[i]][k]);
			}
		}
	}
	
	LL ans = 0;
	Rep0(i, r[m0] - l[m0] + 1) upd(ans, f[m0][i] * c[r[m0] - l[m0] + 1][i]);
	
	printf("%lld\n", ans);
	
	return 0;
}
/*
10 2
1011010000
1 2
3 7
*/

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

int main() {
  
  long long int n,k;
  
  cin >> n >> k;
  
  if(n>k)
    n %= k;
  else if(n==k){
    cout << "0" << endl;
    return 0;
  }
  
  
  if(n*2<k)
    cout << n << endl;
  else
    cout << k-n << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

ll A[100009];
ll B[100009];

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

	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];

	B[1] = A[1];
	for (int i = 1; i <= N / 2; i++) {
		B[1] += (A[2 * i + 1] - A[2 * i]);
	}

	for (int i = 2; i <= N; i++) {
		B[i] = 2 * A[i - 1] - B[i - 1];
	}

	for (int i = 1; i <= N; i++) cout << B[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944