akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

def arraycount(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

a.sort()
a = arraycount(a)
ans = 0

for i in range(len(a)):
    if a[i][1] % 2 != 0:
        ans += 1

print(ans)

Measured memory_bytes: 59480
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

const lli INF=1e8+8;

int main()
{
    lli n,d;
    cin>>n>>d;
    lli ans=0;
    for(lli i=0;i<n;i++)
    {
        lli x,y;
        cin>>x>>y;
        if(d*d-x*x-y*y>=0)
        {
            ans++;
        }
    }

    cout<<ans<<"\n";
    
    
    

    return 0;
    
}

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

int main()
{
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int vx[n+15],vy[m+15];
    for(int i=0 ;i<n; i++){
        cin>>vx[i];
    }
    for(int i=0; i<m; i++){
        cin>>vy[i];
    }
    sort(vx,vx+n);
    sort(vy,vy+m);
    if(vx[n-1]>=vy[0]||x==y){
        cout<<"War";
        return 0;
    }
    for(int i=vx[n-1]+1; i<=vy[0]; i++){
        if(i<=y&&i>x){
            cout<<"No War";
            return 0;
        }
    }
    cout<<"War";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long n,m=0,sum=1000,r=0;
	long long num[100];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>num[i];
	for(int i=0;i<n-1;i++)
	{	
		if(m==0)
		{
			if(num[i]<num[i+1])
			{
				m=sum/num[i];
				sum=sum-m*num[i];
			}		
		}			
		else if(m>0)
		{
			if(num[i]<=num[i+1])
				continue;
			else if(num[i]>num[i+1])
			{
				sum=m*num[i]+sum;
				m=0;
			}				
		}			
	}
	if(m>0)
		sum=sum+m*num[n-1];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3632
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]
wa = [0,0]
num = 0
for i in range(2,N+1):
  if S[i-2:i] == "AC":
    num += 1
  wa.append(num)
left = 0
right = 0
for i in range(Q):
  left = lr[i][0]
  right = lr[i][1]
  print(wa[right]-wa[left])

Measured memory_bytes: 29740
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,bool> row,colum;
    int n,m;
    cin >> n >> m ;
    string s[n];
    for (int i=0;i<n;i++) cin>>s[i];

    for (int i=0;i<n;i++){
        bool ok=true;
        for (int j=0;j<m;j++)
            if (s[i][j] == '#') ok=false ; 
        if (ok) row[i] = true ; 
    }
    for (int i=0;i<m;i++){
        bool ok=true;
        for (int j=0;j<n;j++)
            if (s[j][i] == '#') ok=false ; 
        if (ok) colum[i] = true ; 
    }
    for (int i=0;i<n;i++){
        if (!row[i]){
          for (int j=0;j<m;j++){
              if (!colum[j]) cout << s[i][j] ; 
          }
          cout << endl ; 
        }
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}


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

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


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

    string s;
    cin >> s;

    if(s[s.length()-1]!='s')
        s += "s";
    else
        s += "es";

    cout << s << endl;
 
    return 0;
}



Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AApplePie solver = new AApplePie();
        solver.solve(1, in, out);
        out.close();
    }

    static class AApplePie {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            w.println((s.nextInt() * 3 + s.nextInt()) >> 1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define mst(x, a) memset(x, a, sizeof(x))

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9 + 7;

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

const int MAXN = 301;
int N;
int vis[MAXN][MAXN][MAXN];
double dp[MAXN][MAXN][MAXN];

double calc(int b, int c, int d) {
  if (vis[b][c][d]) return dp[b][c][d];
  vis[b][c][d] = 1;

  double sum = b + c + d;
  double ans = N / sum;
  if (b) ans += b * calc(b - 1, c, d) / sum;
  if (c) ans += c * calc(b + 1, c - 1, d) / sum;
  if (d) ans += d * calc(b, c + 1, d - 1) / sum;
  dp[b][c][d] = ans;
  return ans;
}

int main() {
  scanf("%d", &N);
  int cnt[4] = {};
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }

  mst(vis, 0);
  dp[0][0][0] = 0;
  vis[0][0][0] = 1;
  printf("%.10lf\n", calc(cnt[1], cnt[2], cnt[3]));
}


Measured memory_bytes: 319872
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll gcd (ll a, ll b)
{
    return b == 0 ? a : gcd(b,a % b);
}
int main()
{

   ll n; cin >> n;
   ll tmp = pow(2,(ll)log2(n));
   cout << 2 * tmp  - 1 << '\n';

}


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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    int ans = 1e9;
    rep(i, N - K + 1) {
        int l = x[i], r = x[i + K - 1];
        if (l < 0) {
            if (r < 0) {
                ans = min(ans, -l);
            } else {
                ans = min({ans, -l + r - l, r + r - l});
            }
        } else {
            ans = min(ans, r);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import bisect,sys
input = sys.stdin.readline
a,b,q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(a)]+[INF]
T = [-INF]+[int(input()) for i in range(b)]+[INF]

def f(S,T):
    res = INF
    s = bisect.bisect_left(S,x)
    for i in range(2):
    	for j in range(2):
            t = bisect.bisect_left(T,S[s-i])
            ans= abs(x-S[s-i])+abs(S[s-i]-T[t-j])
            if ans < res:
                res = ans
    return res

for i in range(q):
    x = int(input())
    print(min(f(S,T),f(T,S)))


Measured memory_bytes: 13952
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M, R := sc.nextInt(), sc.nextInt(), sc.nextInt()
	towns := make([]int, R)
	for i := 0; i < R; i++ {
		towns[i] = sc.nextInt() - 1
	}
	D := make([][]int, N)
	for i := 0; i < N; i++ {
		D[i] = make([]int, N)
		for j := 0; j < N; j++ {
			if i != j {
				D[i][j] = INF
			}
		}
	}
	for i := 0; i < M; i++ {
		a, b, c := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		D[a][b] = c
		D[b][a] = c
	}
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if D[i][k]+D[k][j] < D[i][j] {
					D[i][j] = D[i][k] + D[k][j]
				}
			}
		}
	}
	ans := INF
	sort.Ints(towns)
	for {
		total := 0
		for i := 0; i < len(towns)-1; i++ {
			total += D[towns[i]][towns[i+1]]
		}
		if total < ans {
			ans = total
		}
		if !nextPermutation(sort.IntSlice(towns)) {
			break
		}
	}

	fmt.Fprintln(wtr, ans)
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


Measured memory_bytes: 2560
a = []
a = gets.split.map(&:to_i)
n = gets.chomp.to_i

cnt = 0
while n>0 do
    t = 0
if n >= 2
    t = n / 2
    cnt += t *([8*a[0], 4*a[1], 2*a[2], a[3]].min)
    n -= 2 * t
elsif n>= 1
    cnt += [4*a[0], 2*a[1], a[2]].min
    n -= 1
end
#p n
end
puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll H, W, h, w;
int main() {
	cin >> H >> W >> h >> w;
	if (H % h == 0 && W % w == 0) return printf("No"), 0;
	puts("Yes");
	if (H % h != 0) {
		for (int i = 0; i < H; i ++) {
			for (int j = 0; j < W; j ++)
				if (i % h == 0) printf("%lld ", 1000 * h - 1001);
				else printf("-1000 ");
			puts("");
		}
	} else {
		for (int i = 0; i < H; i ++) {
			for (int j = 0; j < W; j ++)
				if (j % w == 0) printf("%lld ", 1000 * w - 1001);
				else printf("-1000 ");
			puts("");
		}
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main() {
    ll n,a,b;cin >>n>>a>>b;
    ll ans=(n-1)*(b-a)+(a-b)+1;
    if(ans<0)ans=0;
    cout <<ans <<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

using segment = vector<tuple<int,int>>;

segment rotate(segment const &seg) {
  segment ret;
  for (auto &&pt : seg) {
    int x, y; tie(x, y) = pt;
    ret.emplace_back(-y, x);
  }
  return ret;
}

segment reverse(segment const &seg) {
  segment ret = seg;
  reverse(begin(ret), end(ret));
  int ox, oy; tie(ox, oy) = seg.back();
  transform(begin(ret), end(ret), begin(ret),
      [ox, oy](auto const &pt) {
        int x, y; tie(x, y) = pt;
        return make_tuple(x-ox, y-oy);
      });
  return ret;
}

bool same(segment const &base, segment const &seg) {
  segment target = seg;
  REP(rev, 2) {
    REP(rot, 4) {
      /*
      cerr << "\t  ";
      for (auto &&pt : target) {
        cerr << "(" << get<0>(pt) << "," << get<1>(pt) << ")";
      }
      cerr << "\n";
      */

      if (base == target) {
        return true;
      }
      target = rotate(target);
    }
    target = reverse(target);
  }
  return false;
}

void solve(int n, vector<segment> const &segs) {
  FOR(i, 1, n) {
    /*
    cerr << "\t";
    cerr << i << ":";
    for (auto &&pt : segs[i]) {
      cerr << "(" << get<0>(pt) << "," << get<1>(pt) << ")";
    }
    cerr << "\n";
    */
    if (same(segs[0], segs[i])) {
      cout << i << "\n";
    }
  }
  cout << "+++++" << "\n";
}

int main() {
  // cout << fixed << setprecision(10);

  int N;
  while (cin >> N && N) {
    vector<segment> segs;
    REP(i, N+1) {
      segment pts;
      int M; cin >> M;
      int ox, oy; cin >> ox >> oy;
      pts.emplace_back(0, 0);
      REP(j, M-1) {
        int X, Y; cin >> X >> Y;
        pts.emplace_back(X-ox, Y-oy);
      }
      segs.push_back(pts);
    }
    solve(N, segs);
  }
  return 0;
}



Measured memory_bytes: 3028
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;



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

    map<string, int>mp;
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";

}
/*

*/


Measured memory_bytes: 3644
/**
 * Bubble Sort
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=ja
 */

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

void trace(vector <int>A) {
  // 現在の並び替え状態を出力する
  int size = A.size();
  for (int i = 0; i < size; i++) {
    cout << A.at(i);
    if (i < size - 1) {
      cout << ' ';
    }
  }

  cout << endl;
}

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

  vector <int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  // trace(A);
  
  /**
   * bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
   *   flag = 1 // 逆の隣接要素が存在する
   *   while flag
   *     flag = 0
   *     for j が N-1 から 1 まで
   *       if A[j] < A[j-1]
   *         A[j] と A[j-1] を交換
   *         flag = 1
   */
  int count = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int j = N - 1; j > 0; j--) {
      if (A.at(j) < A.at(j - 1)) {
        swap(A.at(j), A.at(j - 1));
        count++;
        flag = true;
        // trace(A);
      }
    }
  }

  trace(A);
  cout << count << endl;
}



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

int main(){
	
	int N,a[200],c,temp,hikaku;

	bool flag;

	cin>>N;

	c=0;

	hikaku =9999999;
	for(int i=0; i<N; i++){

		cin>>temp;

		while(temp %2 ==0){

		//	cout<<i<<" "<<temp<< " " << hikaku <<" " <<c<<endl;
			temp=temp/2; 

			c++;

			
		}


		if(hikaku > c ) hikaku=c; 

		
		c=0;

	}

	cout << hikaku<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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 () {
  int N; cin >> N;
  vi B(N-1); REP(i,N-1) cin >> B[i];

  int ans = 0;
  if (N==2) ans += B[0];
  RREP(i,N-1) {
    if (i == N-2) {
      ans += B[i];
      ans += min(B[i-1],B[i]);
    }
    else if (i >= 1) {
      ans += min(B[i-1],B[i]);
    }
    else {
      ans += B[i];
    }
  }

  cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 0;
  for(int i=0;i<N-2;i++){
    if(S.substr(i,3)=="ABC"){
      count++;
    }
    
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)
int main(){
	double a,b;
	while(cin >> a >> b){
		if(a<35.5  && b<71.0)puts("AAA");
		else if(a<37.5  && b<77.0)puts("AA");
		else if(a<40.0  && b<83.0)puts("A");
		else if(a<43.0  && b<89.0)puts("B");
		else if(a<50.0  && b<105.0)puts("C");
		else if(a<55.0  && b<116.0)puts("D");
		else if(a<70.0  && b<148.0)puts("E");
		else puts("NA");
	}
}

Measured memory_bytes: 0
c = [1,2,4,8,16,32,64]
N = int(input())

if 1 <= N < 2:
	print(c[0])
elif 2 <= N < 4:
	print(c[1])
elif 4 <= N < 8:
	print(c[2])
elif 8 <= N < 16:
	print(c[3])
elif 16 <= N < 32:
	print(c[4])
elif 32 <= N < 64:
	print(c[5])
elif 64 <= N:
	print(c[6])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<double> vs;
    double v;
    for (int i = 0; i < N; ++i) {
        cin >> v;
        vs.push_back(v);
    }

    sort(vs.begin(), vs.end());

    for (int i = 0; i < N - 1; ++i) {
        vs[i + 1] = (double) vs[i] + (double) (vs[i + 1] - vs[i]) / (double) 2;
    }

    cout << vs[N - 1] << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



signed main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(0);

	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	int ans = 0;
	rep(i, N)ans += a[i] - 1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int k,s; std::cin >> k >> s;

    int ans=0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            if( s-k <= x+y && x+y <= s ) ans++;
        }
    }

    std::cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main(int argc, char**argv) {
  long n;
  cin >> n;

  unordered_map<long, int> lookup;
  for (long i = 1; i <=n; i++) {
    auto val = abs((n -i) - (i-1));
    lookup[val]++;
  }

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

  if (lookup != a) {
    cout << 0 << endl;
    return 0;
  }

  long mod = 1e9 + 7;
  long result = 1;
  for (int i = 0; i < n / 2; i++) {
    result = (2 * result) % mod;
  }
  cout << result << endl;


  return 0;
}


Measured memory_bytes: 5644
a, b = map(int, input().split())
s = list(input())
flag = True
if len(s) == a+b+1:
    if s[a] == "-":
        s.pop(a)
        for i in s:
            if i == "-":
                flag = False
    else:
        flag = False
else:
    flag = False
if flag:
    print("Yes")
else:
    print("No")


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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


const ll SIZE = 1e5+10;
ll n;

int main(){
    cin >> n;
    ll cou = 1e12+1;
    for(ll i = 1; i <= sqrt(n); i++){
        if(n%i == 0){
            cou = min(cou, i-1+(n/i)-1);
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[1010][1010] = {}; 
	vector<int> E[1000010] = {}; // iとj(i<j)の試合にi*N+jを対応
	vector<int> F[1000010] = {}; // iとj(i<j)の試合にi*N+jを対応
	map<pair<int, int>, bool> M; // すでに加えたか
	int In[1000010] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 1; j < N; j++){
			cin >> A[i][j]; A[i][j] --; 
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 2; j < N; j++){
			int a = min(i, A[i][j-1]) * N + max(i, A[i][j-1]); 
			int b = min(i, A[i][j]) * N + max(i, A[i][j]); 
			if(M[make_pair(a, b)] || M[make_pair(b, a)]) continue; 
			M[make_pair(a, b)] = true; 
			M[make_pair(b, a)] = true; 
			E[a].push_back(b); F[b].push_back(a); 
			In[b] ++; 
		}
	}
	stack<int> st;
	for(int i = 0; i < N * N; i++){
		int a = i / N; int b = i % N; 
		if(a >= b) continue; 
		if(!In[i]) st.push(i); 
	}
	vector<int> S = {}; //トポロジカルソート後
	while(st.size()){
		int i = st.top(); st.pop(); 
		S.push_back(i); 
		for(int j = 0; j < E[i].size(); j++){
			In[E[i].at(j)] --; 
			if(!In[E[i].at(j)]) st.push(E[i].at(j)); 
		}
	}
	if(S.size() != N * (N - 1) / 2){
		cout << -1 << endl; return 0; 
	}
	int dist[1000100] = {}; 
	dist[S.at(0)] = 1; 
	for(int i = 1; i < S.size(); i++){
		int mx = 0; 
		for(int j = 0; j < F[S.at(i)].size(); j++){
			mx = max(mx, dist[F[S.at(i)].at(j)]); 
		}
		dist[S.at(i)] = mx + 1; 
	}
	int ans = 0; 
	for(int i = 0; i < 1000010; i++){
		ans = max(ans, dist[i]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 217076
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
LL fh(LL h) {
	if (h == 1)return 1;
	else {
		return 2*fh(h/2)+1;
	}

}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	LL h;//入力
	LL ans = 1; //出力

	cin >> h;
	
	ans = fh(h);
	cout << ans << "\n";
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> d(k),snk(n,0);
	vector<vector<int>> a(k);

	rep(i,k){
		cin>>d[i];
		a[i].resize(d[i]);
		rep(j,d[i]){
			int x;
			cin>>x;
			snk[x-1]++;
		}
	}
	int ans=0;
	rep(i,n)if(snk[i]==0)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3604
# Thanks for http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759

N, M = map(int, input().split())


def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


try:
    fct = factorize(M)
    L   = []
    for div in divisorize(fct):
        L.append(num(div))
except:
    L = [1, M]

L.sort()
L.reverse()

for l in L:
    if l * N <= M and M % l == 0:
        print(l)
        break


Measured memory_bytes: 3188
N = int(input())
a = list(map(int, input().split()))
l = [0, 0, 0, 0, 0, 0, 0, 0]
pro = 0
m1 = 0
m2 = 0

for i in a:
    if i < 400:
        l[0] += 1
    elif 400 <= i and i < 800:
        l[1] += 1
    elif 800 <= i and i < 1200:
        l[2] += 1
    elif 1200 <= i and i < 1600:
        l[3] += 1
    elif 1600 <= i and i < 2000:
        l[4] += 1
    elif 2000 <= i and i < 2400:
        l[5] += 1
    elif 2400 <= i and i < 2800:
        l[6] += 1
    elif 2800 <= i and i < 3200:
        l[7] += 1
    elif 3200 <= i:
        pro += 1

if l != [0, 0, 0, 0, 0, 0, 0, 0]:
    for i in l:
        if i != 0:
            m1 += 1
    m2 = m1 + pro
else:
    m1 = 1
    m2 = pro


print(m1, m2)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    string s,t;cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.size();i++){
	if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define bug(x) cerr << "[" << #x << "] = ["<<x<<"]"<<'\n'
using namespace std;
ll  ara[11][11] ;
ll  findd(ll  x)
{
    while(x/10) x/=10;
    return x;
}
int  main()
{
    ll  n;
    cin>>n;
    for(ll  i=1;i<=n;i++)
    {
        ara[findd(i)][i%10]++;
    }
    ll  ans=0;
    for(ll  i=1;i<=9;i++)
    {
        for(ll  j=1;j<=9;j++)
        {
            ans+=ara[i][j]*ara[j][i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using pii = pair<int, int>;
using ll = long long;

int encode(pii a, int w) { return a.first * w + a.second; }

pii decode(int a, int w) {
  pii res;
  res.first = a / w;
  res.second = a - res.first * w;
  return res;
}

inline bool valid(int i, int j, int h, int w) {
  return 0 <= i && i < h && 0 <= j && j < w;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> map(h);
  for (int i = 0; i < h; i++) {
    cin >> map[i];
  }

  vector<vector<ll>> dis(h * w, vector<ll>(h * w, 1ll << 55));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (map[i][j] == '.') {
        for (int k = 0; k < 4; k++) {
          int ni = i + dx[k];
          int nj = j + dy[k];
          if (valid(ni, nj, h, w)) {
            if (map[ni][nj] == '.') {
              dis[encode(pii(i, j), w)][encode(pii(ni, nj), w)] = 1;
            }
          }
        }
        dis[encode(pii(i, j), w)][encode(pii(i, j), w)] = 0;
      }
    }
  }

  for (int k = 0; k < h * w; k++) {
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < h * w; i++) {
    for (int j = 0; j < h * w; j++) {
      pii p = decode(i, w);
      pii n = decode(j, w);
      if (map[p.first][p.second] == '.' && map[n.first][n.second] == '.') {
        ans = max(ans, dis[i][j]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1536
//write for s26

#include<bits/stdc++.h>
using namespace std;
vector<int>g[200010];
int dad[100010];
int main() {
	int n,m;
	cin>>n>>m;
	queue<int>q;
	for(int i=1;i<=m;i++) {
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	q.push(1);
	while(!q.empty()) {
		int fr=q.front();
		q.pop();
		for(int i=0;i<g[fr].size();i++) {
			int ni=g[fr][i];
			if(dad[ni]==0&&ni!=1) {
				q.push(ni);
				dad[ni]=fr;
			}
		}
	}
	for(int i=2;i<=n;i++) {
		if(dad[i]==0) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++) {
		cout<<dad[i]<<endl;
	}
	return 0;
}


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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=1;i<n;i++){
    b.at(i) = a.at(i) - a.at(i-1);
  }
  b.at(0) = min(a.at(n-1)-a.at(0),k-a.at(n-1)+a.at(0));
  sort(b.begin(),b.end());
  cout << k - b.at(n-1) << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n); i++)

int main(){

    int N;
    long int A[200001],ans=0;
    cin>>N;
    rep(i,N)    cin>>A[i];

    for(int i=1;i<N;i++){
        if(A[i]<A[i-1]){
            ans+=(A[i-1]-A[i]);
            A[i]=A[i-1];
        }
    }

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

Measured memory_bytes: 5152
import itertools
N = int(input())
A = [int(_) for _ in input().split()]


class BinaryIndexedTree:
    """
        Parameters
        ----------
        array : list
            to construct BIT from
        f : func
            binary operation of the abelian group
        fi : func
            inverse mapping of f
            i.e. f(a, b) == c <-> fi(c, a) == b
        e : 
            identity element of the abelian group
        size : int
            limit for array size
    """

    def __init__(self, array, f, fi, e, size):
        self.f = f
        self.fi = fi
        self.e = e
        self.size = size
        self.n = len(array)
        self.dat = [e] * (size + 1)
        self.array = [e] * size
        self.build(array)

    def build(self, array_):
        for i, v in enumerate(array_):
            self.modify(i, v)

    def modify(self, p, v):
        """
        set value at position p (0-indexed)
        """
        fi, dat, f, size, array = self.fi, self.dat, self.f, self.size, self.array
        dv = fi(v, array[p])
        array[p] = v
        p += 1
        while p <= size:
            dat[p] = f(dat[p], dv)
            p += p & -p

    def query(self, l, r):
        """
        result on interval [l, r) (0-indexed)
        """
        return self.fi(self._query(r), self._query(l))

    def _query(self, p):
        dat, f, res = self.dat, self.f, self.e
        while p:
            res = f(res, dat[p])
            p -= p & -p
        return res


e = 0
size = 2 * N + 2
f = lambda a, b: a + b
fi = lambda c, a: c - a
offset = N


def check(x):
    cumsum = list(itertools.accumulate([0] + [1 if a <= x else -1 for a in A]))
    # sum([l:r)) = cumsum[r] - cumsum[l] >= 0
    # ⇔ cumsum[l] <= cumsum[r]
    BIT = BinaryIndexedTree([e] * size, f=f, fi=fi, e=e, size=size)
    count = 0
    for c in cumsum:
        c += offset
        count += BIT.query(0, c + 1)
        BIT.modify(c + 1, BIT.query(c + 1, c + 2) + 1)
    return 2 * count > N * (N + 1) // 2


A_sorted = [0] + sorted(set(A)) + [10**10]
lb = 0
rb = len(A_sorted) - 1
# check(x) == Trueとなる最小のx
while rb - lb > 1:
    mid = (rb + lb) // 2
    if check(A_sorted[mid]):
        rb = mid
    else:
        lb = mid
print(A_sorted[rb])


Measured memory_bytes: 119724
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll d = 1e9+7;

ll madd(ll a, ll b){
    return (a + b) % d;
}

ll mpow(ll a, ll b){
    return (a*b) % d;
}

ll gyaku(ll n){
    ll e = d - 2;
    ll ret = 1;
    ll bai = n;
    while(e > 0){
        if(e%2 == 1){
            ret = mpow(ret, bai);
        }
        bai = mpow(bai, bai);
        e/=2;
    }
    return ret;
}

vector <int> primes;

vector <vector<int>> is_primes(1e6+10, vector<int>());

map<int,int> soinsus(int n){
    map<int, int> ret;

    while(n > 1){
        for(auto p: is_primes[n]){
            while (n%p == 0){
                ret[p]++;
                n /= p;
            }
        }
    }
    return ret;
}


int main(void){
    is_primes[0] = is_primes[1] = {-1};
    for(int i=2; i<1e6+5; i++){
        if (is_primes[i].size() > 0){
            continue;
        }
        ll idx = i;
        while(idx < 1e6+5){
            is_primes[idx].push_back(i);
            idx += i;
        }
    }
    REP(i, 1e6+5) {
        if (is_primes[i].size() == 1 && is_primes[i][0] == i) {
            primes.push_back(i);
        }
    }
    ll n; cin >> n;
    vector <ll> as;
    REP(i, n){
        ll a; cin >> a; as.push_back(a);
    }
    map<int, int> koubai;
    REP(i, n){
        map<int, int> soinsu = soinsus(as[i]);
        for(auto p: soinsu){
            koubai[p.first] = max(p.second, koubai[p.first]);
        }
    }
    dump(as.size())
    ll kbi = 1;
    for(auto p: koubai){
        REP(_, p.second){
            kbi = mpow(kbi, p.first);
        }
    }
    dump(primes.size())
    ll ans = 0;
    REP(i, n){
        ans = madd(ans, mpow(kbi, gyaku(as[i])));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 56444
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(void){
    int h,w;
    cin>>h>>w;
    vector<string> str(h);
    for(int i=0;i<h;i++){
        cin>>str[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str.at(i).at(j)=='.'){
                str.at(i).at(j)='0';
                if(i+1<h&&str.at(i+1).at(j)=='#'){
                        str.at(i).at(j)++;
                }
                if(j+1<w&&str.at(i).at(j+1)=='#'){
                        str.at(i).at(j)++;
                }
                if(j-1>=0&&str.at(i).at(j-1)=='#'){
                    if(str.at(i).at(j-1)=='#')
                    str.at(i).at(j)++;
                }
                if(i-1>=0&&str.at(i-1).at(j)=='#'){
                    if(str.at(i-1).at(j)=='#')
                    str.at(i).at(j)++;
                }
                if(i+1<h&&j+1<w&&str.at(i+1).at(j+1)=='#'){
                    str.at(i).at(j)++;
                }
                if(i+1<h&&j-1>=0&&str.at(i+1).at(j-1)=='#'){
                    str.at(i).at(j)++;
                }
                if(i-1>=0&&j+1<w&&str.at(i-1).at(j+1)=='#'){
                    str.at(i).at(j)++;
                }
                if(i-1>=0&&j-1>=0&&str.at(i-1).at(j-1)=='#'){
                    str.at(i).at(j)++;
                }
            }
        }
        cout<<str[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	--X; --Y;
	
	vector<int> ans(N);
	REP(i, N) FOR(j, i + 1, N) {
		int cur = abs(j - i);
		chmin(cur, abs(i - X) + abs(j - Y) + 1);
		chmin(cur, abs(j - X) + abs(i - Y) + 1);
		++ans[cur];
	}
	
	FOR(i, 1, N) printf("%d\n", ans[i]);
}


Measured memory_bytes: 764
#include<stdio.h>

int main(){
  int i,j,k,n;
  int house[4][3][10]={};
  int b,f,r,v;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    house[b-1][f-1][r-1] += v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        printf(" %d", house[i][j][k]);
      }
      printf("\n");
    }
    if(i==3){
      continue;
    }
    printf("####################\n");
  }


  return 0;
}


Measured memory_bytes: 2096
n, m = gets.split.map(&:to_i)

py = m.times.with_object([]) do |i, obj| 
    pp, y = gets.split.map(&:to_i)
    obj << [i, pp, y]
end

count = Array.new(n + 1, "000001")
ans = Array.new(m)

py.sort_by{|e| e[2]}.each do |i, pp, y|
    ans[i] = pp.to_s.rjust(6, "0") + count[pp]
    count[pp] = count[pp].next
end

puts ans

Measured memory_bytes: 25940
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

int main() {
	string s;
	cin >> s;
	int w = 0,l = 0;
	for (int i = 0; i < s.size(); i++) {
		char m = (i % 2 ? 'p' : 'g');
		if (s[i] == 'g' && m == 'p') w++;
		if (s[i] == 'p' && m == 'g') l++;
	}
	cout << w - l << endl;;
}

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

using namespace std;

int main(){
  string o,e; cin >> o >> e;
  for(int i=0;i<o.size()+e.size();++i){
    if(i%2) cout << e[i/2];
    else cout << o[i/2];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i < x; i++){
        int j =  2;
        while (pow(i,j) <= x){
            int t = pow(i,j);
            ans = max({ans, t});
            j++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class PaizaSample
{

    static void Main()
    {
        string pass = Console.ReadLine();

        bool upperFlag = false;
        bool downFlag = false;
        bool numberFlag = false;


        if (pass.Length >= 6)
        {
            foreach (char c in pass)
            {
                int r = 0;
                if (int.TryParse(c.ToString(), out r))
                {
                    numberFlag = true;
                }
                else if (char.IsUpper(c))
                {
                    upperFlag = true;
                }
                else
                {
                    downFlag = true;
                }
            }
        }

        if (upperFlag && downFlag && numberFlag)
        {
            Console.WriteLine("VALID");
        }
        else
        {
            Console.WriteLine("INVALID");
        }


        //Console.ReadKey();

    }
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
const int P = 1e9 + 7, N = 1e5 + 54;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int power(int x, int y, int ret = 1) { 
	for (; y; y >>= 1, x = (long long) x * x % P) 
		if (y & 1) ret = (long long) ret * x % P;
	return ret;
}
inline void upd(int &x) {
	if (x < 0) x += P;
	if (x >= P) x -= P;
}
int n, k, ans[N], s;
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> k;
	for (int i = k; i; --i) {
		ans[i] = power(k / i, n);
		for (int j = i * 2; j <= k; j += i) upd(ans[i] -= ans[j]);
	}
	for (int i = 1; i <= k; ++i) ans[i] = (long long) ans[i] * i % P, upd(s += ans[i]);
	std::cout << s << '\n';
}	




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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { 
        cin >> A[i];
    }
    ll l = 0;
    ll r = N-1;
    ll l_sum = 0;
    ll r_sum = 0;
    while(l <= r) {
        if (l_sum > r_sum) {
            r_sum += A[r];
            r--;
        } else {
            l_sum += A[l];
            l++;
        }
    }
    print(abs(l_sum - r_sum));
    return 0;
}

Measured memory_bytes: 1792