akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define N 8
#define FREE -1
#define NFREE 1
#define EXIST -10
void initialize(void);
void printQ(void);
void putqueen(int);

int row[N],col[N],dpos[2*N-1],dneg[2*N-1],X[N][N];

int main(){
  int i,k,r,c;
  initialize();
  scanf("%d",&k);
  for(i = 0;i < k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=EXIST;
  }
  putqueen(0);
  return 0;
}

void initialize() {
  int i,j;
  for(i = 0;i < N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(j = 0;j < 2*N-1;j++){
    dpos[j]=FREE;
    dneg[j]=FREE;
  }
}

void printQ(){
  int i,j;
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(X[i][j]){
        if(row[i]!=j) return;
      }
    }
  }
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i]==j){
        printf("Q");
      }
      else printf(".");
    }
      printf("\n");
  }
}

void putqueen(int i){
  int j;
  if(i == N){
    printQ();
    return;
  }
  for(j = 0;j < N;j++){
    if(col[j]==NFREE || dpos[i+j]==NFREE || dneg[i-j+N-1]==NFREE) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NFREE;
    putqueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

int main() {
  ll x;
  cin >> x;
  vec ans;
  ans.push_back(1);
  for(ll i=2;mpow(i,2)<=x;i++) {
    for(ll j=2;mpow(i,j)<=x;j++) {
      ans.push_back(mpow(i,j));
    }
  }
  sort(ans.begin(),ans.end());
  cout << ans[ans.size()-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,m; cin>>n>>m;
    vector<ll> x(m);
    rep(i,m) cin>>x[i];
    sort(x.begin(),x.end());
    ll ans=x[m-1]-x[0];
    vector<ll> y(m-1);
    rep(i,m-1) y[i]=x[i+1]-x[i];
    sort(y.begin(),y.end(),greater<ll>());
    if(n>=m)cout<<0<<endl;
    else{
        rep(i,n-1) ans-=y[i];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main (void){

double x, y, X, Y, a, b, L;

scanf("%lf %lf %lf %lf", &x, &y, &X, &Y);

a = pow(x - X, 2);

b = pow(y - Y, 2);

L = sqrt(a + b);

printf("%lf\n",L);
return 0;
}

Measured memory_bytes: 1852
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
 ** A main function starts from here  **
 ***************************************/
int main(){
  ll N;
  cin >> N;
  llvec H(N, 0);
  rep(i, N)cin >> H[i];

  ll ans = 0;
  ll count = 0;
  rep(i, N-1){
    if(H[i]>=H[i+1])count+=1;
    else count = 0;
    ans = max(count , ans);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	paths := make([]int, 4)
	for i := 0; i < 3; i++ {
		a, b := scanInt(sc)-1, scanInt(sc)-1
		paths[a] += 1
		paths[b] += 1
	}

	ok := true
	for _, p := range paths {
		ok = ok && p < 3
	}
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 640
N, M = map(int, input().split(' '))
ans = [1]*N
H = list(map(int, input().split(' ')))

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        ans[B-1] = 0
    elif H[A-1] < H[B-1]:
        ans[A-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(ans.count(1))


Measured memory_bytes: 20812
n, m = map(int, input().split())
mod = 10**9 + 7
dp = [0]*(n+1)
broken = [0]*(n+1)
dp[0] = 1
for _ in range(m):
    broken[int(input())] = 1
# print(broken)
for i in range(1, n+1):
    if broken[i]:
        continue
    if i == 1:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] %= mod

print(dp[n])

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

int main(void){
    int h,w,D;

    while(cin>>h>>w, h|w){
        bool notFound=true;
        for(D=h*h+w*w; notFound; h=0,++D){
            /*?????????1???????????°????????¢?´¢*/
            while(++h, h*h<D/2){
                /*??????????????§???????????°????????´????????¢?????????????????????*/
                for(w=h; w*w+h*h<D; ++w);
                if(w*w+h*h==D){
                    cout<<h<<" "<<w<<endl;
                    notFound=false;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1164
import bisect
from collections import deque

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

ans = deque([A[0]])
for i in range(1, N):
    index = bisect.bisect_left(ans, A[i])
    if index > 0:
        ans[index - 1] = A[i]
    else:
        ans.appendleft(A[i])

print(len(ans))


Measured memory_bytes: 8060
S = input()
def f(X):
    if len(X) == 1:
      return(int(X))
    else:
      n = len(X)
      s = 0
      for i in range(1, n):
        s += f(X[:n-i]) + int(X[n-i:n])*(2**(n-i-1))
      s += int(X)
      return(s)
print(f(S))

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
use std::iter::FromIterator;

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [usize; m]
    }
    let mut tab: Vec<usize> = vec![0; n + 1];
    tab[0] = 1;
    if m == 0 || v[0] != 1 {
        tab[1] = 1;
    }
    let d = 1000000007;
    let set: HashSet<usize> = HashSet::from_iter(v);
    for i in 2..n + 1 {
        if set.contains(&i) {
            continue;
        }
        tab[i] = (tab[i - 2] + tab[i - 1]) % d;
    }
    println!("{}", tab[n]);
}


Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>

using namespace std;

int n, a[200000];

int main() {
    cin >> n;
    int cur = 1, ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == cur) {
            cur++;
        }
        else {
            ans++;
        }
    }
    cout << (ans == n ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    auto G = new int[][N];
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        G[B] ~= A;
    }

    auto P = new bool[](N);
    void walk(int i, ref int[] ps) {
        ps ~= i+1;
        P[i] = true;
        foreach (j; G[i]) if (!P[j]) {
            walk(j, ps);
            break;
        }
    }
    int[] rs;
    walk(0, rs);
    rs = rs[1..$];
    rs.reverse();
    walk(0, rs);
    writeln(rs.length);
    writeln(rs.to!(string[]).join(" "));
}

Measured memory_bytes: 15484
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Objects;
import java.util.StringTokenizer;

public class Main {

    public void solve() throws IOException {
        int n = nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[0] - h[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
        }
        out.print(dp[n - 1]);
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    class Pair implements Comparable<Pair> {
        int f;
        int s;

        public Pair(int f, int s) {
            this.f = f;
            this.s = s;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return f == pair.f &&
                    s == pair.s;
        }

        @Override
        public int hashCode() {
            return Objects.hash(f, s);
        }

        @Override
        public int compareTo(Pair o) {
            if (f == o.f) {
                return s - o.s;
            }
            return f - o.f;
        }
    }

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public int[] nextArr(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }
}

Measured memory_bytes: 31860
#include <iostream>
#include <set>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  string str;
  cin >> str;
  
  set<char> s;
  for (auto c: str) {
    s.insert(c);
  }

  string ans = "None";
  for(char c = 'a'; c <= 'z'; ++c) {
    if(!s.count(c)) {
      ans = c;
      break;
    }
  }

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


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    reps(a, i, b+1) {
        string s = to_string(i);
        string s2 = s;
        reverse(all(s2));

        if (s == s2) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL a,b,n;
    cin >> a >> b >> n;
    LL x=min(n,b-1);
    cout << a*x/b - x/b*a << '\n';
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;
    string s;
    cin >> n >> s;
    map<char,int> mp;
    for(int i = 0; i < n; i++){
        mp[s[i]]++;
    }
    ll ans = 1;
    for(char t = 'a'; t <= 'z'; t++){
        ans *= (mp[t]+1);
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}



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

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

    vector<int> a(300000);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int cnt;
    cnt=n-1;
    while(cnt>=0){
        if(cnt==n-1) cout << a[cnt];
        else cout << ' ' << a[cnt];
        cnt-=2;
    }
    if(n%2==0) cnt=0;
    else cnt=1;
    while(cnt<n){
        cout << ' ' << a[cnt];
        cnt+=2;
    }
    
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int N, W; cin >> N >> W;
	VI v(N), w(N);
	REP(i, N) cin >> w[i] >> v[i];
	VVI dp(N + 1, VI(W + 1, 0));
	REP(i, N) {
		REP(j, W + 1) {
			if (w[i] <= j)
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
from collections import defaultdict
from collections import Counter


def prime_factorization(divs, n):
    while n % 2 == 0:
        divs[2] += 1
        n //= 2

    i = 3
    while i <= int(n ** .5) + 1:
        while n % i == 0:
            divs[i] += 1
            n //= i
        i += 2
    if n != 1:
        divs[n] += 1

    return divs


def num(m):
    return sum([value if key >= m else 0 for key, value in cnt_divs.items()])


N = int(input())
divs = defaultdict(int)
for n in range(2, N + 1):
    divs = prime_factorization(divs, n)

cnt_divs = Counter(divs.values())

print(num(74) + \
      num(24) * (num(2) - 1) + \
      num(14) * (num(4) - 1) + \
      num(4) * (num(4) - 1) * (num(2) - 2) // 2)


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

int main()
{
    string N;
    cin >> N;
    for (int i = 0; i < N.size();i++){
        if(N.at(i)=='7'){
            cout << "Yes" << endl;
            break;
        }
        else if (N.at(i) != '7'){
          if(i<N.size()-1){
            continue;
          }
          else if(i==N.size()-1){
             cout << "No" << endl;
          }
        }
        
    }
   
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int h, w;
int biggest = 0;
int inf = 100000000;

void wid(int startX, int startY, int goalX, int goalY, vector<vector<char>> mp){
  if(startX == goalX && startY == goalY) return;
  queue<pair<int, int>> que;
  pair<int, int> start = make_pair(startX, startY);
  pair<int, int> goal = make_pair(goalX, goalY);
  que.push(start);
  
  vector<vector<int>> disMap(h, vector<int>(w, inf));
  disMap[startY][startX] = 0;
  
  while(!que.empty()){
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    int newX, newY;
    for (int dx = -1, dy = 0, i = 0; i < 4; dx += dy, dy = dx - dy, dx = dy - dx, ++i) {
      newX = x+dx;
      newY = y+dy;
      if(newX < 0 || newX >= w || newY < 0 || newY >= h || disMap[newY][newX] != inf || mp[newY][newX] == '#') continue;
      else if(newX == goal.first && newY == goal.second){
        if(biggest < disMap[y][x] + 1){
          biggest = disMap[y][x] + 1;
        }
        return;
      }else{
        disMap[newY][newX] = disMap[y][x] + 1;
        que.push(make_pair(newX, newY));
      }
    }
  }
}

int main(){
  cin >> h >> w;
  if(h == 1 && w == 1){
    cout << 0 << endl;
    return 0;
  }
  vector<vector<char>> theMap(h, vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      char num;
      cin >> num;
      theMap[i][j] = num;
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      for(int ii=0; ii<h; ii++){
    	for(int jj=0; jj<w; jj++){
          int startX, startY, goalX, goalY;
          startX = j; startY = i, goalX = jj; goalY = ii;
          if(theMap[i][j] == '#' || theMap[ii][jj] == '#') continue;
          wid(startX, startY, goalX, goalY, theMap);
        }
      }
    }
  }
  cout << biggest << endl;
  return 0;
}
        
        
        
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N);
  vector<pair<ll, ll>> p(N);
  rep(i, 0, N) {
    in(p[i].second, p[i].first);
  }
  sort(all(p));
  ll t = 0;
  rep(i, 0, N) {
    t += p[i].second;
    if (t > p[i].first) {
      print("No");
      return;
    }
  }
  print("Yes");
}


Measured memory_bytes: 3456
// review
#include <iostream>
#include <set>

using namespace std;

int n;
set<int> s;

void solve() {
  if (s.size() % 2 == 0) {
    cout << s.size() - 1 << endl;
  } else {
    cout << s.size() << endl;
  }
}

int main() {
  cin >> n;
  int tmp;
  for (int i=0;i<n;i++) {
    cin >> tmp;
    s.insert(tmp);
  }
  solve();
}


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

using LLI = long long int;

int N;
LLI k;

int main() {
  scanf("%d%lld", &N, &k);

  LLI idx = 0;
  for (int i=0; i<N-1; i++) {
    LLI low = -1;
    LLI high = 1LL << 62LL;
    while (high - low > 1) {
      LLI mid = (high+low)/2;
      LLI t = mid - (mid/k+1);
      if (idx <= t) high = mid;
      else low = mid;
    }

    idx = high;
  }

  printf("%lld\n", idx);
}

Measured memory_bytes: 3160
#include <iostream>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(std::string w){
    map<char, int> alpha;
    REP(i, w.size()) {
        alpha.insert(make_pair(w[i], 0));
        alpha[w[i]]++;
    }

    bool ans = true;
    for (auto itr = alpha.begin(); itr != alpha.end(); itr++)
        if (itr->second % 2) ans = false;

    if (ans) cout << YES << '\n';
    else cout << NO << '\n';
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int P=sc.nextInt();
		int Q=sc.nextInt();
		int R=sc.nextInt();

		int a=0;
		int b=0;
		if(P <= Q) {
			a=P;
			b=Q;
		}else {
			a=Q;
			b=P;
		}
		if(R <= b) {
			b =R;
		}
		System.out.println(a+b);
		sc.close();
	}


}


Measured memory_bytes: 35716
#include<cstdio>
#include<iostream>
using namespace std;
long long a[10010],b[10010];
int main()
{
	int n,flag=1,flag1=1;
	long long suma=0,sumb=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) cin>>a[i],suma+=a[i];
	for(int i=1;i<=n;i++) cin>>b[i],sumb+=b[i];
	for(int i=1;i<=n;i++) 
	{
		if(a[i]!=b[i]) flag=0;
	}
	if(flag)
	{
		printf("Yes\n");
		return 0;
	}
	long long ka=sumb-suma,kb=ka;
	if(ka<0) 
	{
		printf("No\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>a[i])
		{
			if((b[i]-a[i])%2) kb--;
			b[i]++;
			ka-=(b[i]-a[i])/2;
		}
		else if(a[i]>b[i])
		{
			kb-=a[i]-b[i];
		}
	}
	if(ka*2==kb&&ka>=0&&kb>=0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int mod=1e9+7;
const int INF=2e9;
const int MAX=2e3+5;

int n,k;
int arr[MAX][MAX];

pair<int,int> getRange(int v,bool s,int ad){
	pair<int,int> ret(ad,ad);
	int tmp=v/k;
	if((tmp%2)!=s)
		ret.first+=k-(v%k),v+=k-(v%k);
	ret.second=ret.first+k-(v%k)-1;
	ret.second=min(ret.second,2*k-1);
	return ret;
}
void fll(pair<int,int> x,pair<int,int> y){
	arr[x.second][y.second]++;
	if(x.first>0)arr[x.first-1][y.second]--;
	if(y.first>0)arr[x.second][y.first-1]--;
	if(x.first>0&&y.first>0)arr[x.first-1][y.first-1]++;
}

void go(int x,int y,bool s1,bool s2){
	set<pair<int,int>>v1,v2;
	pair<int,int> tmp=getRange(x,s1,0);
	v1.insert(tmp);
	tmp=getRange(x+tmp.second+1,s1,tmp.second+1);
	if(tmp.first<2*k)
		v1.insert(tmp);
	tmp=getRange(y,s2,0);
	v2.insert(tmp);
	tmp=getRange(y+tmp.second+1,s2,tmp.second+1);
	if(tmp.first<2*k)
		v2.insert(tmp);
	for(set<pair<int,int>>::iterator it=v1.begin();it!=v1.end();it++)
		for(set<pair<int,int>>::iterator it2=v2.begin();it2!=v2.end();it2++)
			fll(*it,*it2);
}

int acc(){
	int ret=-INF;
	int end=2*k;
	for(int i=end-1;i>=0;i--){
		for(int j=end-1;j>=0;j--){
			if(i+1<end)
				arr[i][j]+=arr[i+1][j];
			if(j+1<end)
				arr[i][j]+=arr[i][j+1];
			if(i+1<end&&j+1<end)
				arr[i][j]-=arr[i+1][j+1];
			ret=max(ret,arr[i][j]);
		}
	}
	return ret;
}

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

	cin>>n>>k;
	vector<int>x(n),y(n),c(n);
	for(int i=0;i<n;i++){
		char col;
		cin>>x[i]>>y[i]>>col;
		c[i]=(col=='B');
	}
	memset(arr,0,sizeof arr);
	for(int i=0;i<n;i++){
		if(!c[i]){
			go(x[i],y[i],0,0);
			go(x[i],y[i],1,1);
		}
		else{
			go(x[i],y[i],0,1);
			go(x[i],y[i],1,0);
		}
	}
	int ans=acc();
	memset(arr,0,sizeof arr);
	for(int i=0;i<n;i++){
		if(c[i]){
			go(x[i],y[i],0,0);
			go(x[i],y[i],1,1);
		}
		else{
			go(x[i],y[i],0,1);
			go(x[i],y[i],1,0);
		}
	}
	cout<<max(ans,acc())<<endl;
	return 0;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    cout << (n%1000==0 ? 0 : (((n/1000)+1)*1000-n));
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool rotate = false;

    int q;
    cin >> q;
    rep(i,q)
    {
        int t;
        cin >> t;
        if (t==1) rotate = !rotate;
        else
        {
            int f;
            string c;
            cin >> f >> c;

            if ((f+rotate)%2)
            {
                s.insert(0, c);
                // end_c.push_back(c);
            }
            else
            {
                s.insert(s.size(), c);
                // first_c.push_back(c);
            }
        }
    }
    if (rotate)
    {
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
    
    
}




Measured memory_bytes: 912
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
ll solve() {
    ll N, M;
    cin >> N >> M;
    if (min(N, M) == 1) return max(N, M) == 1 ? 1 : max(N, M) - 2;
    return N * M - 2 * (N + M) + 4;
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int K=0;

int twice(int A){
return 2*A;
}

int kplus(int B){
return B+K;
}

int main(){
    int N,now_num=1;

    cin>>N;
    cin>>K;

    for(int i;i<N;i++){
    if(twice(now_num)>kplus(now_num)) now_num=kplus(now_num);
    else now_num=twice(now_num);
    }

    cout<<now_num<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

template <class T> int getbit(T s, int i) { return (s >> i) & 1; }
template <class T> T onbit(T s, int i) { return s | (T(1) << i); }
template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template <class T> ll cntbit(T s) { return __builtin_popcntll(s); }

#define all(a) (a).begin(), (a).end()
#define ms(a, x) memset(a, x, sizeof(a))
#define sz(a) ((ll)(a).size())
#define bot(i, n) for (int i = 0; i < (n); ++i)
#define top(i, n) for (int i = (n)-1; i >= 0; --i)
#define bot_(i, a, b) for (int i = (a); i <= (b); ++i)
#define top_(i, a, b) for (int i = (a); i >= (b); --i)
#define forv(v, it) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define print(x) cout << __LINE__ << #x << " = " << x << endl
#define clear(x) v.clear(); vector<T>(v).swap(v)

#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define eps 1e-12

#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define y0 ___y0
#define y1 ___y1

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

  int n, m;
  cin >> n >> m;

  long long time_per_turn = 100 * (n - m) + 1900 * m;
  long long series = pow(2, m);

  cout << series * time_per_turn << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
const int NQmax = 100000;
int N,Q;
string S[NQmax];
int prefix[NQmax];
map<int, int> former[NQmax];

struct trie {
  int k; // index of this node
  int n; // number of children
  struct trie* c[26];
} root[400000];

int main(){
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  int n = 1;
  for(int i=0; i<N; i++){
    struct trie *t = root;
    for(int j=0; j<S[i].size(); j++){
      int c = S[i][j]-'a';
      if(t->c[c] == NULL) t->c[c] = root+n;
      n++;
      t->c[c]->n++;
      t=t->c[c];
    }
    t->k=i+1;
  }

  for(int i=0; i<N; i++){
    struct trie *t=root;
    for(int j=0; j<S[i].size(); j++){
      int c = S[i][j]-'a';
      struct trie* s = t->c[c];
      if(t->k > 0) prefix[i]++;
      for(int k=0; k<26; k++){
        if(k==c|| t->c[k]==NULL) continue;
        former[i][k*26+c] += t->c[k]->n;
      }
      t=s;
    }
  }

  cin >> Q;
  for(int i=0; i<Q; i++){
    int K;
    string P;
    cin >> K;
    cin >> P;
    int res = prefix[K-1]+1;
    for(char j=0; j<26; j++){
      for(int k=j+1; k<26; k++){
        int l=(P[j]-'a')*26+P[k]-'a';
        auto m=former[K-1].find(l);
        if(m != former[K-1].end())
           res += m->second;
      }
    }
    cout << res << endl;
  }


  return 0;
}


Measured memory_bytes: 447744
n,m = map(int, input().split())
s = input()
t = input()
def gcd(a,b):
  while b > 0:
    a,b = b,a%b
  return a
g = gcd(n,m)
x = n*m//gcd(n,m)
d = dict()
a,b = n//g,m//g
for i in range(n):
  d[i*b] = s[i]
for j in range(m):
  if j*a in d and d[j*a] != t[j]:
    print(-1)
    break
else:
  print(x)

Measured memory_bytes: 15396
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin >> n >> m;
	vector<ll> xl(n), yl(m);
	REP(i,n) cin >> xl[i];
	REP(i,m) cin >> yl[i];
	ll ansx = 0;
	REP(i,n){
		ansx += i * xl[i] - (n-i-1) * xl[i];
		ansx %= MOD;
	}
	ll ansy = 0;
	REP(j,m){
		ansy += j * yl[j] - (m-j-1) * yl[j];
		ansy %= MOD;
	}
	cout << ansx * ansy % MOD << '\n';
	return 0;
}



Measured memory_bytes: 1792
import java.util.*; 
import java.lang.*; 
 
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
 
		long N = scan.nextLong();
		long sum = 0;
 
		for(long i=1; i<=N; i++){
			if(!(i%3==0) && !(i%5==0) ){
				sum = sum + i;
			}
		}
		
		System.out.println(sum);
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long ok = *max_element(A.begin(), A.end()), ng = 0;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      int cut = 0;
      for (int i = 0; i < N; i++) {
        cut += (A.at(i) + mid - 1) / mid - 1;
      }
      (cut <= K) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}

Measured memory_bytes: 4052
#include <stdio.h>
int main(void){
	int i,c=0,f;
	char s[21],ans[21];
	scanf("%s",s);
	for(i=0;s[i];i++){
		if(s[i]=='A'||s[i]=='Z')
			ans[c++]=s[i];
	}
	f=1;
	for(i=0;i<c-1;i++){
		if(ans[i]=='A'&&ans[i+1]=='Z'){
			printf("AZ");
			f=0;
		}
	}
	if(f)
		printf("-1");
	puts("");
	return 0;
}

Measured memory_bytes: 532
open System

let n = stdin.ReadLine() |> int

let yen x u =
    match u with
    | "JPY" -> x
    | "BTC" -> x * 380000.0
    

[0..n-1]
|> List.map (fun a -> stdin.ReadLine().Split(' '))
|> List.map (fun a -> yen (float a.[0]) a.[1])
|> List.sum
|> printfn "%f"

Measured memory_bytes: 12124
#include <iostream>
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

int cnt[2];
const int maxn = 101;

int main() {
    //os_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, p;
    cin >> n >> p;
    ll C[maxn+10][maxn+10];
    for (int n=0; n<=maxn; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k=1; k<n; ++k)
            C[n][k] = C[n-1][k-1] + C[n-1][k];
    }
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        cnt[x % 2]++;
    }
    if(p == 0) {
        ll ans = (1LL << (ll)cnt[0]);
        ll res = 0;
        for(int i = 0; i <= 50; i += 2)
            res += C[cnt[1]][i];
        cout << ans * res << "\n";
    }
    else {
        ll ans = (1LL << (ll)cnt[0]);
        ll res = 0;
        for(int i = 1; i <= 50; i += 2)
            res += C[cnt[1]][i];
        cout << ans * res << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    string a;
    cin>>a;
    int n=a.length();
    for(int i=0;i<n;i++)
    {
        if(a[i]=='?')
            a[i]='D';
    }   
    cout<<a;

} 



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

using namespace std;
using ll = long long;

std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

std::vector<int> factor(int n, const std::vector<int>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::vector<int> res;
  while (n > 1) {
    res.push_back(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}

vector<int> min_fact = sieve(1101010);


int main()
{
	int n; cin >> n;
	set<int> st;
	vector<int> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	bool ok = true;

	for(int i = 0; i < n; i++) {
		vector<int> fac = factor(a[i], min_fact);
		sort(fac.begin(), fac.end());
		fac.resize(unique(fac.begin(), fac.end()) - fac.begin());
		for(auto i : fac) {
			if(st.count(i)) {
				ok = false;
				break;
			}
			st.insert(i);
		}
		if(!ok)break;
	}


	if(ok) {
		cout << "pairwise coprime" << endl;
		return 0;
	}

	int gc = 0;
	for(int i = 0; i < n; i++)gc = __gcd(a[i], gc);
	if(gc == 1) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
}

Measured memory_bytes: 11452
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const ll N = 2e5+2;
ll n, a[N], ans = 0;

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    a[0] = -1, a[n+1] = 0;
    FOR(i, 1, n) {
    	if(a[i] > a[i-1]+1 || a[i] > i-1) {
    		cout << -1 << endl;
    		exit(0);
    	}
    }
    FOR(i, 1, n+1) {
    	if(a[i] <= a[i-1]) ans += a[i-1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
 
int main(){
  int n,a,b,c,ans; cin>>n;
  a=n/100; c=n%10; b=(n-100*a-c)/10;
  if(a>=b){
    if(b>=c || c==a)
    ans=a*111;
    else
    ans=(a+1)*111;}
  else{
    ans=(a+1)*111;}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long a = saori.saorihayami()-1;
		long b = saori.saorihayami();
		long  c = saori.saorihayami();
		long  d = saori.saorihayami();
		long num1 = b - b/c - b/d + b/lcm(c, d);
		long num2 = a - a/c - a/d + a/lcm(c, d);  
		System.out.println(num1 - num2);
		saori.close();
	}
	private static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
def p(x):
  if x<2:
    return 0
  for i in range(2,int(x**0.5)+1):
    if x%i==0:
      return 0
  return 1

C=[0]
for i in range(1,10**5+1):
  C.append(C[-1]+(p(i)&p((i+1)//2)))
l,r=0,0
for i in range(int(input())):
  l,r=map(int,input().split())
  print(C[r]-C[l-1])

Measured memory_bytes: 78208
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 x, y;
  cin >> x >> y;
  i64 ans = 0;
  if (x == 3)
    ans += 100000;
  else if (x == 2)
    ans += 200000;
  else if (x == 1)
    ans += 300000;
  if (y == 3)
    ans += 100000;
  else if (y == 2)
    ans += 200000;
  else if (y == 1)
    ans += 300000;
  if (x == 1 && y == 1)
    ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
f = F//100

ans = [0,0]
per = -1
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    st = 0
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(min(w*E,F-water),-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break

    if s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  map<lint, int> map;
  rep(i, n) {
    int a;
    cin >> a;
    ++map[a];
  }
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    map[c] += b;
  }
  int left = n;
  lint sum = 0;
  for (auto itr = map.rbegin(); itr != map.rend(); ++itr) {
    if (left >= itr->second) {
      sum += itr->first * itr->second;
      left -= itr->second;
    } else {
      sum += itr->first * left;
      break;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] A = new int[N];
        int odds = 1;
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();

            if (A[i] % 2 == 1) {
                odds *= 1;
            } else {
                odds *= 2;
            }
        }
//        System.out.println("odds = " + odds);
        System.out.println((long) Math.pow(3, N) - odds);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        s[i] = 'A' + ((s[i] - 'A' + n) % 26);
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
    int n, b;
    cin >> n;
    int a[100000] = {};
    for (int i = 0 ; i < n ; i++) {
    	cin >> b;
    	if (b > 0) a[b - 1]++;
    	a[b]++;
    	a[b + 1]++;
	}
	int c = 0;
	for (int i = 0 ; i < 100000 ; i++) c = max(c, a[i]);
	cout << c;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC156();
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC156();
}

void ABC156(){
    int n,sum=0,minv;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(i=vec[0]+1;i<vec[vec.size()-1];i++){
        for(j=0;j<vec.size();j++){
            sum+=abs(vec[j]-i)*abs(vec[j]-i);
        }
        if(i==vec[0]+1)minv=sum;
        minv=min(minv,sum);
        sum=0;
    }
    cout<<minv<<endl;
}

Measured memory_bytes: 256