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

const int N = 100;

int bubble_sort(int n, int A[]) {
  int step = 0, flag = 1, sorted = 0;
  
  while (flag) {
    flag = 0;
    for (int i = n-1; i > sorted; i--) {
      if (A[i-1] > A[i]) {
        step++;
        int tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        flag = 1;
      }
    }
    sorted++;
  }

  return step;
}

int main() {
  int n;
  int A[N];

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

  int step = bubble_sort(n, A);
  
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << step << endl;

  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;
const int MAXN = 55;

int n;
lint a[MAXN];

void simulate(){
	for(int i=0; i<n-1; i++) a[i]++;
	a[n-1] -= n;
	sort(a, a+n);
}
int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	lint ans = 0;
	for(int i=n-1; i; i--){
		if(a[i-1] <= a[i] - n - 1){
			lint fast_step = (a[i] - a[i-1]) / (n+1);
			for(int j=i; j<n; j++) a[j] -= fast_step * (i + 1);
			for(int j=0; j<i; j++) a[j] += fast_step * (n - i);
			ans += fast_step * (n-i);
		}
	}
	lint fast = a[0] / n - 5;
if(fast > 0){
	for(int i=0; i<n; i++) a[i] -= fast * n;
	ans += fast * n * n;
}
	sort(a, a+n);
	while(a[n-1] >= n) simulate(), ans++;
	cout << ans;
}


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;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
ll MOD = 1000000007;

int main(void){
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 1; i <= n; i++){
    ll prc = n/i;
    ans += i*prc*(prc+1)/2;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long s64; 
#define debug(args...) fprintf(stderr, args)  
#define foredge(u) for (int e = adj[u], v; v = to[e], e; e = nxt[e])

template <class T>
inline void read(T &x) {
	static char ch; 
	while (!isdigit(ch = getchar())); 
	x = ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
}

namespace ModuloCalculator {
	const int mod = 1e9 + 7; 
	inline void add(int &x, const int &y) {
		if (x += y, x >= mod) x -= mod; 
	}
	inline int minus(int x, const int &y) {
		return x -= y, x < 0 ? x + mod : x; 
	}
	inline int qpow(int x, int y) {
		int res = 1; 
		for (; y; y >>= 1, x = 1LL * x * x % mod)
			if (y & 1) res = 1LL * res * x % mod; 
		return res; 
	}
}
using namespace ModuloCalculator; 

namespace UnionFindSet {
	const int ufsN = 1e3 + 5; 
	int ufs[ufsN]; 
	inline void ufsInit(int n) {
		for (int i = 1; i <= n; ++i) {
			ufs[i] = i; 
		}
	}
	inline int ufsFind(int x) {
		return ufs[x] == x ? x : ufs[x] = ufsFind(ufs[x]); 
	}
	inline bool ufsMerge(int x, int y) {
		x = ufsFind(x), y = ufsFind(y); 
		if (x != y)
			return ufs[x] = y, true; 
		else
			return false; 
	}
}
using namespace UnionFindSet; 

const int MaxN = 1e3 + 5; 
const int MaxM = 2e3 + 5;
const int MaxE = MaxM << 1; 

struct edge {
	int u, v, w; 
	inline bool operator < (const edge &rhs) const {
		return w < rhs.w; 
	}
	inline void scan() {
		read(u), read(v), read(w); 
	}
}e[MaxM]; 

int n, m; 
s64 minSum, X; 

int cntTree; 
bool can[MaxM]; 

int maxW[MaxN][MaxN]; 
int ect, adj[MaxN], nxt[MaxE], to[MaxE], weight[MaxE]; 

inline void addEdge(int u, int v, int w) {
	nxt[++ect] = adj[u]; 
	adj[u] = ect; 
	to[ect] = v; 
	weight[ect] = w; 
}

inline void dfsWeight(int u, int frm, int pre = 0, int curW = 0) {
	maxW[frm][u] = curW;
	foredge(u) if (v != pre) {
		dfsWeight(v, frm, u, std::max(curW, weight[e])); 
	}
}

int main() {
#ifdef orzczk
	freopen("tree.in", "r", stdin); 
#endif

	read(n), read(m), read(X), ufsInit(n); 
	for (int i = 1; i <= m; ++i) {
		e[i].scan(); 
	}

	std::sort(e + 1, e + m + 1); 

	for (int l = 1, r = 0; l <= m; l = r + 1) {
		while (r < m && e[r + 1].w == e[l].w) {
			++r; 
		}
		for (int i = l; i <= r; ++i) {
			can[i] = ufsFind(e[i].u) != ufsFind(e[i].v); 
			cntTree += can[i]; 
		}
		for (int i = l; i <= r; ++i) {
			if (ufsMerge(e[i].u, e[i].v)) {
				minSum += e[i].w; 
				addEdge(e[i].u, e[i].v, e[i].w); 
				addEdge(e[i].v, e[i].u, e[i].w); 
			}
		}
	}

	if (minSum == X) {
		// debug("type1\n"); 
		
		std::cout << 1LL * minus(qpow(2, cntTree), 2) * qpow(2, m - cntTree) % mod << '\n'; 
	} else {
		for (int u = 1; u <= n; ++u) {
			dfsWeight(u, u); 
		}

		int res = 0; 
		std::vector<s64> valTree; 
		for (int i = 1; i <= m; ++i)
			if (!can[i]) {
				valTree.push_back(minSum - maxW[e[i].u][e[i].v] + e[i].w); 
			}
		
		std::sort(valTree.begin(), valTree.end()); 
		for (int i = 0; i < (int)valTree.size(); ++i)
			if (valTree[i] == X) {
				// debug("%d : %d\n", i, m - cntTree - i); 
				add(res, qpow(2, m - cntTree - i)); 
			}
		std::cout << res << '\n'; 
	}

	return 0; 
}

Measured memory_bytes: 7676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,d;
    cin>>n>>d;
    int ct=0;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)
        ct++;
    }
    cout<<ct<<endl;
    
}

Measured memory_bytes: 3832
#include<stdio.h>
int main(void)
{
	int i =1;
	int x;
	
	while(1){
		scanf("%d",&x);
		if(x == 0){
			break;
		}
	printf("Case %d: %d\n",i,x);
	i +=1;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int sum[9000000]={};
long long mm=1e9+7;
/*long long poww(long long a,long long b){
    if(b==0)
        return 1;
    else if(b==1)
        return a;
    long long v=poww(a,b/2);
    v*=v;
    v%=mm;
    if(b%2==1){
        v*=v;
        v%=mm;
    }
    return v;
}*/    //function to pow
/*long long pow2(long long k){
long long j=2;
while(--k)
    {j*=2;
    j%=mm;}
return j;


}*/
/*bool prime[100000];
vector<long long >v;
void sieve(){
prime[0]=prime[1]=true;
long int n=10000;
int t=sqrt(n);
for(long int i=2;i<=n;++i){
    if(prime[i]==false){
        v.push_back(i);
        for(long int p=i*i;p<=n;p+=i)
            prime[p]=true;
    }
}
}*/
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     long long n,w;
     cin>>n>>w;
     if(w>=n)
        cout<<"unsafe";
     else
        cout<<"safe";

    return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int n;  cin >> n;
    set<string> s;
    for(int i = 0;i < n;i++){
        string st;  cin >> st;
        s.insert(st);
    }

    cout << s.size();

}

Measured memory_bytes: 19288
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
    //ll sieve[10000009];
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin >> arr[i];
    unordered_map<ll,ll>m;
    for(ll i=0;i<n;i++)
    {
        m[arr[i]]++;
    }
    ll count=0;
    for(ll i=0;i<n;i++)
    {
        ll flag=0;
        ll num=arr[i];
        m[num]--;
        for(ll j=1;j*j<=num;j++)
        {
            if(num%j==0)
            {
                ll a=j;
                ll b=num/j;
                //cout << num << " Num" << endl;
                //cout << a << " a" << endl;
                //cout << b << " b" << endl;
                if(m[a]>0 || m[b]>0)
                {
                    flag=1;
                    break;
                }
            }
        }
        m[num]++;
        if(flag==0)
            count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 33204
n,x=map(int,input().split())
length=[0]*n;p=[0]*n
length[0]=1
p[0]=1
for i in range(1,n):
  length[i]=length[i-1]*2+3
  p[i]=p[i-1]*2+1
def meat(n,x):
  if n==0:
    return 0 if x<=0 else 1
  elif x<=1+length[n-1]:
    return meat(n-1,x-1)
  elif x==2+length[n-1]:
    return p[n-1]+1
  else:
    return p[n-1]+1+meat(n-1,x-length[n-1]-2)
print(meat(n,x))


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC153C
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var K = NN;
            var HList = NNList(N);
            var sorted = HList.OrderByRand().OrderByDescending(e => e).ToList();
            var sum = 0L;
            foreach (var item in sorted)
            {
                --K;
                if (K < 0)
                {
                    sum += item;
                }
            }
            Console.WriteLine(sum);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 46144
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, K;
const int M = 1e9+7, ms = 2e5+9;
int dp[ms], a[ms], pre[ms];
main(){
  cin >> n >> K;

  for(int i = 0; i < n; i++) cin >> a[i];
  
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    for(int k = K; k>=0; k--){
      int val = dp[k];
      int up = a[i];
      int l = 1 + k;
      int r = min(up, K-k) + k;
      if(l <=r){
        pre[l] = (pre[l] + val)%M;
        pre[r+1] = (pre[r+1] - val)%M;
      }
    }
    
    int acc = 0;
    for(int i = 0; i <= K; i++){
      acc = ((acc + pre[i])%M + M)%M;
      dp[i] = ((dp[i] + acc)%M+M)%M;
      pre[i] = 0;
    }
  }

  cout<<(dp[K])%M;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

ll N;
string S;
ll Q;

template <typename T>
struct BinaryIndexedTree
{
    vector<T> data;

    BinaryIndexedTree(int sz)
    {
        data.assign(++sz, 0);
    }

    T sum(int k)
    {
        T ret = 0;
        for (++k; k > 0; k -= k & -k)
            ret += data[k];
        return (ret);
    }

    void add(int k, T x)
    {
        for (++k; k < data.size(); k += k & -k)
            data[k] += x;
    }
};

int main()
{
    cin >> N;
    cin >> S;
    cin >> Q;
    vector<BinaryIndexedTree<ll>> bit = vector<BinaryIndexedTree<ll>>(26, BinaryIndexedTree<ll>(N));
    REP(i, N)
    {
        REP(j, 26)
        {
            if ('a' + j == S[i])
            {
                bit[j].add(i, 1);
            }
        }
    }

    REP(i, Q)
    {
        ll t, x, y;
        char c;
        cin >> t >> x;
        --x;
        if (t == 1)
        {
            cin >> c;
            bit[S[x] - 'a'].add(x, -1);
            bit[c - 'a'].add(x, 1);
            S[x] = c;
        }
        else
        {
            cin >> y;
            --y;
            ll ans = 0;
            REP(j, 26)
            {
                if ((x > 0 and bit[j].sum(y) - bit[j].sum(x - 1) >= 1) or (x == 0 and bit[j].sum(y) >= 1))
                {
                    ++ans;
                }
            }
            OUT(ans);
        }
    }
}


Measured memory_bytes: 106372
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let h = cin.next_usize();
    let w = cin.next_usize();
    let mut dp = (0..10).map(|_| (0..10).map(|_| cin.next_i64()).collect::<Vec<_>>()).collect::<Vec<_>>();
    let a = (0..h).map(|_| (0..w).map(|_| cin.next_i64()).collect::<Vec<_>>()).collect::<Vec<_>>();

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                dp[i][j] = std::cmp::min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    let mut ans = 0;
    for y in 0..h {
        for x in 0..w {
            if a[y][x] != -1 {
                ans += dp[a[y][x] as usize][1];
            }
        }
    }

    println!("{}", ans);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_f64(&mut self) -> f64 { self.next_generics::<f64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

struct UnionFind
{
    vector<int> par;

    UnionFind(int N) : par(N)
    {
        for (int i = 0; i < N; i++)
            par[i] = -1;
    }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        return par[x] = root(par[x]);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;

        if (par[rx] > par[ry])
            std::swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

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

    UnionFind uf(n);

    vector<int> capita(n, -1);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        uf.unite(a - 1, b - 1);
        capita[a - 1]--;
        capita[b - 1]--;
    }

    for (int i = 0; i < n; i++)
    {
        capita[i] += uf.size(i);
    }

    for (int i = 0; i < k; i++)
    {
        int c, d;
        cin >> c >> d;
        if (uf.same(c - 1, d - 1))
        {
            capita[c - 1]--;
            capita[d - 1]--;
        }
    }

    for (auto &&item : capita)
        cout << item << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int n;
vector<int> et[100000];
int root_id;
int parent[100000];
int depth[100000];

void input() {
	static bool is_root[100000];
	
	cin >> n;
	for (int i = 0; i < n; i++) is_root[i] = true;
		
	for (int i = 0; i < n; i++) {
		int id, k, ch_id;
		cin >> id >> k;
		for (int j = 0; j < k; j++) {
			cin >> ch_id;
			et[id].push_back(ch_id);
			is_root[ch_id] = false;
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (is_root[i]) {
			root_id = i;
			break;
		}
	}
}

void dfs(int p, int v, int dep = 0) {
	parent[v] = p;
	depth[v] = dep;
	for (int i = 0; i < et[v].size(); i++) {
		dfs(v, et[v][i], dep + 1);
	}
}

int main() {
	input();
	dfs(-1, root_id);
	
	for (int i = 0; i < n; i++) {
		char *type;
		if (i == root_id) type = "root";
		else if (et[i].size() == 0) type = "leaf";
		else type = "internal node";
		printf("node %d: parent = %d, depth = %d, %s, [", i, parent[i], depth[i], type);
		for (int j = 0; j < et[i].size(); j++) {
			printf("%d", et[i][j]);
			if (j + 1 < et[i].size()) printf(", ");
		}
		printf("]\n");
	}
	return 0;
}

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


int main(){
    int N,M,C,ans;
    cin  >> N >> M >> C;
    vector<int> B(M);
    rep(i,M) cin >> B[i];
    rep(_,N){
        int s = 0;
        rep(j,M){
            int a;
            cin >> a;
            s += B[j] * a;
        }
        s += C;
        (s > 0) && (ans++);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define y1 djsfah
using namespace std;
const int N=400005;
const int mo=998244353;
int fa[N],fav[N],v[N];
int q[N],f[N],val[N],n;
char x[N];
int get(int x){
	if (x==fa[x]) return x;
	int tmp=fa[x];
	fa[x]=get(fa[x]);
	v[x]=v[tmp]^fav[x];
	fav[x]=v[x]^v[fa[x]];
	return fa[x];
}
bool merge(int x,int y,int vv){
	int px=get(x);
	int py=get(y);
	if (px!=py){
		fa[px]=py;
		fav[px]=v[x]^v[y]^vv;
		return 1;
	} 
	return !(v[x]^v[y]^vv);
}
bool check(int x,int vv,int &S){
	int px=get(x);
	//printf("%d %d %d %d\n",px,val[px],v[x],vv);
	if (val[px]==-1){
		S=1ll*(mo+1)/2*S%mo;
		return 1;
	}
	if ((val[px]^v[x])!=vv)
		return S=0;
	return 1;
}
bool sett(int x,int vv,int &S){
	int px=get(x);
	if (val[px]==-1){
		val[px]=v[x]^vv;
		S=1ll*(mo+1)/2*S%mo;
		return 1;
	}
	if ((val[px]^v[x])!=vv)
		return S=0;
	return 1;
}
void check(int v){
	q[++*q]=v;
	For(i,1,2*n) fa[i]=i,fav[i]=::v[i]=0,val[i]=-1;
	For(i,1,n) merge(i,i+n,1);
	For(i,1,n){
		int ni=i+v;
		if (ni>2*n) ni-=2*n;
		if (!merge(i,ni,0)) return;
	}
	//puts("233");
	int S=1;
	For(i,1,2*n)
		if (get(i)==i)
			S=2ll*S%mo;
	bool ava=1;
	For(i,1,n){
		if (x[i]=='1'){
			int nS=S;
			if (check(i,0,nS))
				f[*q]=(f[*q]+nS)%mo;
			//printf("%d\n",nS);
		}
		//printf("%d %d %d\n",i,get(i),::v[i]);
		if (!sett(i,x[i]-'0',S)){
			ava=0;
			break;
		}
		//printf("CHECK %d %d %d\n",i,f[*q],S);
	}
	if (ava)
		++f[*q];
	//printf("RES %d %d\n",f[*q],q[*q]);
}
int main(){
	int ans=0;
	scanf("%d%s",&n,x+1);
	For(i,1,2*n) if (2*n%i==0) check(i);
	For(i,1,*q) For(j,i+1,*q)
		if (q[j]%q[i]==0) f[j]=(f[j]+mo-f[i])%mo;
	For(i,1,*q) ans=(ans+1ll*q[i]*f[i])%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;


ll dp[100010];
int main() {
    int N;
    cin >> N;
    dp[0] = 0;

    for(int i=1; i<=100000; i++) {
        dp[i] = INF;
        int power = 1;
        while(power <= i) {
            dp[i] = min(dp[i], dp[i-power] + 1);
            power *= 6;
        }
        power = 1;
        while(power <= i) {
            dp[i] = min(dp[i], dp[i-power] + 1);
            power *= 9;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(K >= S.size()){
        cout << S << enld;
    }else{
        cout << S.substr(0,K) + "..." << enld;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

//===== グラフ受け取り =====//
/*
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    
    // == 重み付きグラフ == //
    
    struct Edge {
        int to; 
        int weight; 
        Edge(int t, int w) : to(t), weight(w) { }
    };
    using Graph = vector<vector<Edge>>;
    int main() {
        int N, M; cin >> N >> M;
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            int from, to, weight;
            cin >> from >> to >> weight;
            G[from].push_back(Edge(to, weight));
        }
    }
*/    

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N, L; cin >> N >> L;
    if(L>0){
        cout << (N-1) * (L+1 + L+N-1) / 2 << endl; 
    } else if(L+N>0) {
        cout << N * (L + L + N-1) / 2 << endl; 
    } else {
        cout << (N-1) * (L + L + N-2) / 2 << endl;
    }
}






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

ll pow(ll n, ll p) {
  ll x = 1;
  for (ll i = 0; i < p; i++) {
    x *= n;
  }
  return x;
}
int main() {
  ll N; cin >> N;
  ll dp[100001];
  dp[0] = 0;
  for (ll i = 1; i <= 100000; i++) {
    ll m = 100000;
    ll p = 1;
    for (ll j = 0; j < 10; j++) {
      if (i-p>=0 && m > dp[i-p]) {m = dp[i-p];}
      p*=6;
    }
    p = 1;
    for (ll j = 0; j < 10; j++) {
      if (i-p>=0 && m > dp[i-p]) {m = dp[i-p];}
      p*=9;
    }
    dp[i] = m+1;
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
let n, h = Scanf.scanf " %d %d" @@ fun a b -> a, ref b
let ab_s, ans = Array.make (n + n) (0, false), ref 0
let f _ = Printf.printf "%d\n" !ans; exit 0
let _ = for i = 0 to n - 1 do Scanf.scanf " %d %d" @@ fun a b -> ab_s.(2 * i) <- a, false; ab_s.(2 * i + 1) <- b, true done;
  Array.(sort (fun x y -> compare y x) ab_s; iter (fun (x, b) -> if b then (h := !h - x; incr ans; if !h <= 0 then f ()) else (ans := !ans + (!h + x - 1) / x; f ()))) ab_s

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

int A[200001];
int B[200001];
int C[200001];

int main(void) {
 
    int N;
    cin >> N;
    for(int i=0;i<200001;++i)
    {
        B[i]=0;
    }
  
    for(int i=0;i<N;++i)
    {
        cin >> A[i];
        B[A[i]]++;
    }

    long x = 0;
  	for(int i=0;i<200001;++i)
    {
        C[i]=(B[i]-1);
        x+=(long)(B[i])*(long)(B[i]-1)/2;
    }

    for(int i=0;i<N;++i)
    {
      	cout << x - C[A[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

string ast;
map<string, vector<int>>avars;
int a;
vector<int>getform();
vector<int>getst() {
	string name;
	while( ('a' <= ast[a] && 'z' >= ast[a]) || ('A' <= ast[a] && 'Z' >= ast[a])){
		name.push_back(ast[a]);
		a++;
	}
	if (avars.find(name) == avars.end()) {
		assert(false);
	}
	else {
		return avars[name];
	}
}
vector<int>getfact() {
	if (ast[a] == '(') {
		a++;
		vector<int>v = getform();
		assert(ast[a] == ')');
		a++;
		return v;
	}
	else {
		return getst();
	}
}
vector<int>getterm() {
	auto v = getfact();
	while (a != ast.size()&&ast[a]!=')') {
		if (ast[a] == '*') {
			a++;
			auto nv = getfact();
			assert(v.size() == nv.size());
			for (int i = 0; i < v.size(); ++i) {
				v[i] += nv[i];
			}
		}
		else if (ast[a] == '/') {
			a++;
			auto nv = getfact();
			assert(v.size() == nv.size());
			for (int i = 0; i < v.size(); ++i) {
				v[i] -= nv[i];
			}
		}
		else if (ast[a] =='+'||ast[a]=='-'){
			break;
		}
		else {
			assert(false);
		}
	}
	return v;
}
vector<int>getform() {
	auto v = getterm();
	while (a!=ast.size() && ast[a] != ')') {
		if (ast[a] == '+'||ast[a]=='-') {
			a++;
			auto nv = getterm();
			if (v == nv) {
				continue;
			}
			else {
				throw(false);
			}
		}
		else {
			assert(false);
		}
	}
	return v;
}

vector<int>getans(const string st,const map<string,vector<int>>&vars) {
	ast = st;
	avars = vars;
	a = 0;
	return getform();
}

int main() {
	while (1) {
		int N, M, P; cin >> N >> M >> P;
		if (!N)break;
		map<string,vector<int>>dim;
		map<vector<int>, string>revdim;
		for (int i = 0; i < M; ++i) {
			string name; cin >> name;
			vector<int>dims(N);
			for (int j = 0; j < N; ++j) {
				cin >> dims[j];
			}
			dim[name] = dims;
			revdim[dims] = name;
		}
		string st; cin >> st;
		map<string,vector<int>>vars;
		for (int i = 0; i < P; ++i) {
			string v; string n; cin >> v >> n;
			vars[v] = dim[n];
		}
		try {
			vector<int>ans = getans(st, vars);
			if (revdim.find(ans) == revdim.end()) {
				cout << "undefined" << endl;
			}
			else {
				cout << revdim[ans] << endl;
			}
		}
		catch (...) {
			cout << "error" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
void rec(int);
int solve(int,int);
int A[20],S[20];
int n;
int main(){
  int i,m,q;
  cin>>n;
  for(i=0;i<n;i++)S[i]=0;
   rec(0);
  for(i=0;i<n;i++) cin>>A[i];
  cin>>q;
  for(i=0;i<q;i++){
    cin>>m;
    if(solve(0,m))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
}

void rec(int i){
  if(i==n){
    //for(int j=0;j<n;j++)cout<<S[j]<<endl;
    return;
  }
  rec(i+1);
  S[i]=1;
  rec(i+1);
  S[i]=0;
}

int solve(int i,int m){
  int res;
  if(m==0)return true;
  if(i>=n)return false;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}




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

namespace _0003
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1行目：データセットの数n
            // 2～n+1行目：三角形の3辺を示す整数がスペース区切りで3つ与えられる
            // それぞれを3辺とする三角形が直角三角形ならYES,そうでなければNOと出力するプログラム

            // 辺a ≤ 辺b ≤ 辺c の時、a^2 + b^2 = c^2 ならば三角形は直角三角形となる。

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)          
            {
                int[] ary = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Array.Sort(ary);                                                            // 読み込んだ配列を昇順に並び替え

                if (Math.Pow(ary[0], 2) + Math.Pow(ary[1], 2) == Math.Pow(ary[2], 2))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}



Measured memory_bytes: 18288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");

		int A = Integer.parseInt(str[0]);
		String op = str[1];
		int B = Integer.parseInt(str[2]);

		if (op.equals("+")) {
			System.out.println(A + B);
		} else if (op.equals("-")) {
			System.out.println(A - B);
		}

	}

}


Measured memory_bytes: 8148
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////
int L[100000];
int main(void) {
	double w, h, x, y; cin >> w >> h >> x >> y;
	int a;
	(x == w / 2 && y == h / 2) ? a = 1 : a = 0;
	printf("%lf %d", h*w / 2, a);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, inf = 1e8;
int n, nn, k, a[N], b[N], cnt, ans[N];
bool mark[N];
int seg[N << 2];
priority_queue<int> s;
void upd(int p, int val) {
	p += nn, seg[p] = val, p /= 2;
	for (; p > 0; p /= 2)
		seg[p] = max(seg[p * 2], seg[p * 2 + 1]);
	return;
}
int get(int l, int r) {
	l = max(l, 0), r = min(r, n);
	int rtr = -inf;
	for (l += nn, r += nn; l < r; l /= 2, r /= 2) {
		if (l % 2) rtr = max(rtr, seg[l++]);
		if (r % 2) rtr = max(rtr, seg[--r]);
	}
	return rtr;
}
void add(int plc) {
	if (plc >= cnt || plc < 0)
		return;
	int mx = get(k * plc, k * (plc + 1));
//	cout << "plc = " << plc << " : " << mx << endl;
	if (mx < 0)
		return;
	if (!mark[b[mx]] && get(b[mx] - k + 1, b[mx] + k) == mx)
		s.push(b[mx]), mark[b[mx]] = true;
//	cout << "done" << endl;
	return;
}
void makeFind(int plc) {
	add(plc - 1);
	add(plc);
	add(plc + 1);
}
int main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	cin >> n >> k, nn = n, cnt = (n + k - 1) / k;
	while (__builtin_popcount(nn) != 1) nn++;
	for (int i = 0; i < n; i++) {
		cin >> a[i], a[i]--, b[a[i]] = i;
		upd(i, a[i]);
	}
	for (int i = 0; i < cnt; i++)
		add(i);
//	cout << "GO NEXT" << endl;
	for (int i = 0; i < n; i++) {
		int ls = s.top();
		s.pop();
		ans[ls] = n - i - 1;
		upd(ls, -inf);
		int plc = ls / k;
		makeFind(plc);
	}
	for (int i = 0; i < n; i++)
		cout << ans[i] + 1 << "\n";
	return 0;
}


Measured memory_bytes: 17648
n,m = map(int, input().split())
a = list(map(int, input().split()))

s = sum(a)
min_num = float(s)/(4*m)

res = "No"
count = 0
for x in a:
    if x >= min_num:
        count += 1
    if count >= m:
        res = "Yes"
        break
print(res)

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

X = I()

from math import gcd

print(360//gcd(360,X))

Measured memory_bytes: 62092
H, W = [int(i) for i in input().split()]

# ちょうど3等分できるなら、0
if H%3==0 or W%3==0:
    print(0)
    quit()

mind = 10**18

for h in range(H+1):
    a = [W*h]
    if W%2==0 or (H-h)%2==0:
        a.append(int(W/2*(H-h)))
    else:
        a.append(W*(H-h)-min(H-h, W)*(max(H-h, W)//2))
        a.append(W*(H-h)-a[-1])
    mind = min(mind, max(a)-min(a))


for w in range(W+1):
    a = [w*H]
    if (W-w)%2==0 or H%2==0:
        a.append(int((W-w)/2*H))
    else:
        a.append((W-w)*H-min(W-w, H)*(max(W-w, h)//2))
        a.append((W-w)*h-a[-1])
    mind = min(mind, max(a)-min(a))

print(mind)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10000)
def f(x,y):
    if 0<=x<w and 0<=y<h and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:f(x+dx,y+dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[list(input().split()) for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)

Measured memory_bytes: 11760
n=int(input())
a=list(map(int,input().split()))
def ni(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
ans=0
for i in range(n):
    if a[i]%2==0:
        ans+=ni(a[i])
print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,px,py,nx,ny,d,t,k,m,posible;
    while(cin >> n)
    {
        px = py = 0; k = 0; posible = 1;
        for(int i = 0; i < n; i++)
        {
            cin >> t >> nx >> ny;
            d = abs(nx - px) + abs(ny - py);
            m = t - k;
            if((d % 2) != (m % 2) || m < d)
                posible = 0;
            k = t;
            px = nx; 
            py = ny;
        }
        cout << (posible? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define max(a,b) a<b?b:a
#define min(a,b) a<b?b:a

typedef struct POINT{
	double x,y;
}POINT;
typedef struct LINE{
	double x,y;
}LINE;

//double 

double dot(POINT a,POINT b){//内積
	return a.x*b.x + a.y*b.y;
}
double cross(POINT a,POINT b){//外積
	return a.x*b.y - a.y*b.x;
}
POINT make_vec(POINT a,POINT b){//a->b
	b.x -= a.x;
	b.y -= a.y;
	return b;
}

int inclusion(POINT a[],int n,POINT p){
	int ans = 0;
	int i;
	POINT g[n+1];
	double w,rad = 0.0;

	for(i = 0;i < n;i++){
		g[i] = a[i];
	}
	g[n] = g[0];

	for(i = 0;i < n;i++){
		if(g[i].x == p.x && g[i].y == p.y){
			return ans = 1;
		}
	}
	for(i = 0;i < n;i++){
		w = atan2(cross(make_vec(p,g[i]),make_vec(p,g[i+1])),
				dot(make_vec(p,g[i]),make_vec(p,g[i+1])));
		rad += w;
		if(fabs(w - 3.1415926535) <= 0.000001 ||
			 fabs(w + 3.1415926535) <= 0.000001)
			return ans = 1;
	}
	if(fabs(rad - 3.1415926535*2)<=0.000001){//2π
		return ans = 2;//in!
	}
	return ans;
}

int main(){
	int i,m,n;
	POINT g[100];//n
	POINT q;//m
	int ans = 0;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%lf%lf",&g[i].x,&g[i].y);
	}
	scanf("%d",&m);
	for(i = 0;i < m;i++){
		scanf("%lf%lf",&q.x,&q.y);
		ans = inclusion(g,n,q);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 728
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 

        while(sc.hasNext()){
        	String[] shikaku = new String[8];
        	for (int i = 0; i < 8; i++) {
        		shikaku[i] = sc.next();
        	}

        	int x = 0;
        	int y = 0;
        	boolean hakken = false;

        	for(int i = 0; i < 8; i++){
        		for (int j = 0; j < 8; j++) {
        			if(shikaku[i].charAt(j) == '1'){
        				x = j;
        				y = i;
        				hakken = true;
        				break;
        			}
        		}
        		if (hakken) {
        			break;
        		}
        	} 

        	if(x < 7 && y < 7){
        		if(shikaku[y].charAt(x+1) == '1' && shikaku[y+1].charAt(x) == '1' && shikaku[y+1].charAt(x+1) == '1'){
        			System.out.println("A");
        			continue;
        		}
        	}

        	if(x < 8 && y < 5){
        		if(shikaku[y+1].charAt(x) == '1' && shikaku[y+2].charAt(x) == '1' && shikaku[y+3].charAt(x) == '1'){
        			System.out.println("B");
        			continue;
        		}
        	}

        	if(x < 5 && y < 8){
        		if(shikaku[y].charAt(x+1) == '1' && shikaku[y].charAt(x+2) == '1' && shikaku[y].charAt(x+3) == '1'){
        			System.out.println("C");
        			continue;
        		}
        	}

        	if(x > 0 && y < 6){
        		if(shikaku[y+1].charAt(x-1) == '1' && shikaku[y+1].charAt(x) == '1' && shikaku[y+2].charAt(x-1) == '1'){
        			System.out.println("D");
        			continue;
        		}
        	}

        	if(x < 6 && y < 7){
        		if(shikaku[y].charAt(x+1) == '1' && shikaku[y+1].charAt(x+1) == '1' && shikaku[y+1].charAt(x+2) == '1'){
        			System.out.println("E");
        			continue;
        		}
        	}

        	if(x < 7 && y < 6){
        		if(shikaku[y+1].charAt(x) == '1' && shikaku[y+1].charAt(x+1) == '1' && shikaku[y+2].charAt(x+1) == '1'){
        			System.out.println("F");
        			continue;
        		}
        	}

        	System.out.println("G");

    	}
	}
}

Measured memory_bytes: 19992
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

int inp(){
  int x; 
  cin>>x;
  return x;
}

//=============================================================================//
ll f(int n){
  ll t = 1;
  int n_ = n;
  for(int i=2; i*i<=n_; i++){
    int k=0;
    while(n%i == 0) {
      k++; n/=i;
    }
    t *= (k+1);
  }
  if(n!=1) t*=2;
  //cout<<t<<endl;
  //if(t&1 && t!=1) return t-1;
  return t;
}
void solve() {
    int n; cin>>n;
    ll ans=0;
    for(int i=1; i<=n-1; i++){
      ans += f(i);
    }
    cout<<ans;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

char p[8][10];

void explode(int x, int y) {
  if (x < 0 || x >= 8 || y < 0 || y >= 8 || p[y][x] == '0')
    return;
  p[y][x] = '0';
  for (int i = 1; i <= 3; i++) {
    explode(x, y+i);
    explode(x, y-i);
    explode(x+i, y);
    explode(x-i, y);
  }
}

int main() {
  int N;
  cin >> N;
  for (int I = 1; I <= N; I++) {
    for (int i = 0; i < 8; i++)
      cin >> p[i];
    int x, y;
    cin >> x >> y;
    explode(x-1, y-1);
    cout << "Data " << I << ':' << endl;
    for (int i = 0; i < 8; i++)
      cout << p[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long 

signed main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N+1,0);
    for(int i=1;i<=N;++i) cin >> A[i];
    for(int i=1;i<=N;++i) A[i] += A[i-1];
    unordered_map<int,int> mp;
    for(int i=0;i<=N;++i) ++mp[A[i] % M];

    int ans = 0;
    for(auto p : mp){
        ans += (p.second * (p.second-1)) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4492
package main

import (
	"bufio"
	"fmt"
	"os"
	"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
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

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

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C, D, E, F := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	dp := make([]bool, F+1)
	dp[0] = true
	for i := 1; i <= F/100; i++ {
		if B <= i {
			dp[i] = dp[i-B] || dp[i-A]
		} else if A <= i {
			dp[i] = dp[i-A]
		}
	}
	waters := []int{}
	for water, b := range dp {
		if b {
			waters = append(waters, water)
		}
	}
	ansTotal := 100 * A
	ansSuger := 0
	for _, water := range waters {
		restForSuger := min(F-water*100, E*water)
		dp := make([]bool, restForSuger+1)
		dp[0] = true
		max := 0
		for i := 1; i <= restForSuger; i++ {
			if D <= i {
				dp[i] = dp[i-D] || dp[i-C]
			} else if C <= i {
				dp[i] = dp[i-C]
			}
			if dp[i] {
				max = i
			}
		}
		if float64(ansSuger)/float64(ansTotal) < float64(max)/(float64(water*100)+float64(max)) {
			ansSuger = max
			ansTotal = water*100 + max
		}
	}

	fmt.Fprintln(wtr, ansTotal, ansSuger)
	wtr.Flush()
}


Measured memory_bytes: 640
from collections import Counter
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
v=[[] for i in range(m)]
for i in x:
    v[i%m].append(i)
ans=0
for i in range(1,m//2+1*(m%2==1)):
    d=len(v[i])-len(v[m-i])
    if d<0:
        d=-d
        v[i],v[m-i]=v[m-i],v[i]
    c=sorted(Counter(v[i]).items(),key=lambda x:x[1])
    p=0
    for t in c:
        p+=(t[1]//2)
    ans+=len(v[m-i])+min(p,(d//2))

ans+=len(v[0])//2+(len(v[m//2])//2 if m%2==0 else 0)
print(ans)

Measured memory_bytes: 82028
k = int(input())
a,b = map(int,input().split())
count = 1
flag = 0
while k * count <= b:
    if k * count >= a and k * count <= b:
        flag = 1
        count += 1
    else:
        count += 1
if flag == 1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    cin>>n;
    long long int arr[n]={0},temp[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        temp[i]=arr[i]-i;
    }
    sort(temp,temp+n);
    long long int b=temp[n/2],sum=0;
    for(i=0;i<n;i++)
    {
        sum+=abs(b-temp[i]);
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<queue>
#define LL long long

using namespace std;
const int mod = 1e9+7;

LL fun(LL k)
{
	return (k*(k+1)/2-k)%mod;
}

int main()
{
	LL n,k;
	cin>>n>>k;
	int a[2010];
	for(int i=0;i<n;i++) cin>>a[i];
	LL num1=0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++) 
		if(a[i]>a[j]) num1++;
	}
	if(k==1) {
		cout<<num1<<endl;
	}
	else {
		LL num2=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)
			if(a[i]>a[j]) num2++;
		}
		cout<<(num1*k%mod+fun(k)*num2%mod)%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int a, b,c;

	scanf("%d %d %d", &a, &b,&c);

	if (a<b&&b<c&&a<c)
	{
		printf("Yes\n");
	}
	
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580