akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
  long N, M;
  cin >> N >> M;
  if (N == 1 && M == 1)
  {
    cout << 1 << endl;
  }
  else if (N == 1 && M > 1 || N > 1 && M == 1)
  {
    cout << N * M - 2 << endl;
  }
  else
  {
    cout << N * M - N * 2 - M * 2 + 4 << endl;
  }
  return 0;
}
// 4 -> Front
// 6 -> Front
// 9 -> Back


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    while(n--)
    {
        int t,x,y;
        cin>>t>>x>>y;
        if(t<abs(x)+abs(y)||(abs(x)+abs(y)-t)%2!=0) return puts("No"),0;
    }
	puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n, p; cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	if (n > 50) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 1;
	for (int i = 2;; i++) {
		int w = 1;
		for (int j = 0; j < n; j++)w *= i;
		if (p < w)break;
		if (!(p%w))ans = i;
	}cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;string s, p;
    cin >> n;
    map<string, bool> T;
    for(int i = 0; i < n; i++){
        cin >> s >> p;
        if(s == "insert") T[p] = true;
        else cout << (T[p] ? "yes" : "no") << endl;

    }
    return 0;
}


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

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

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

	int MAX = 300000;
	SegmentTree<int> seg( MAX + 1, [](int a, int b) { return max(a, b); }, 0 );
	for( int i = 0; i < N; i++ ) {
		int A;
		cin >> A;
		int l = max( 0, A - K );
		int r = min( MAX, A + K );
		int n = seg.query( l, r + 1 );
		seg.update( A, n + 1 );
	}

	int ans = seg.query( 0, MAX + 1 );

	cout << ans << endl;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

map<ll, ll> primeFactorize(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n > 1) ++res[n];
    return res;
}

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

    ll n;
    cin >> n;
    auto res = primeFactorize(n);

    cout << n << ":";
    for (auto p : res) {
        rep(i, p.second) {
            cout << " " << p.first;
        }
    }
    cout << endl;
}

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

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

    int h = 0,n = 0,w = 0;
    for(int i = 1; i <= 3500; i++){
        for(int j = 1; j <= 3500; j++){
            if((4 * i * j) % N != 0) continue;
            int X = i * j;
            int Y = (4 * i * j / N) - (i + j);
            if(Y == 0) continue;
            if(X % Y == 0 && X / Y > 0){
                h = i;
                n = j;
                w = X / Y;
                break;
            }
        }
    }
    cout << h << " " << n << " " << w << endl;

}

Measured memory_bytes: 256
(defn inner-func [S]
  (loop [s S r nil]
    (if (< (count s) 3)
      r
      (recur
        (rest s)
        (cons (->> s
                (take 3)
                (apply str)
                (Integer/parseInt))
          r)))))

(defn func [S]
  (->> (inner-func S)
    (map #(Math/abs (- % 753)))
    (apply min)))

(->> (read-line)
  func
  println)

Measured memory_bytes: 67968
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi())
    B=list(mi())
    C=list(mi())

    pre = INF
    ans = 0
    for i in range(N):
        a = A[i]
        b = B[a-1]
        ans += b
        if a == pre + 1:
            ans += C[a-2]
        
        pre = a

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 61984
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,ans="";
  cin >> s >> t;
  long long dp[s.size()+5][t.size()+5]={};
  for(int i=0;i<s.size();i++){
    for(int j=0;j<t.size();j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=max(dp[i][j]+1, max(dp[i+1][j], dp[i][j+1]));
      }else{
        dp[i+1][j+1]=max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
  int i=s.size(),j=t.size();
  while((i!=0 or j!=0) and (dp[i][j]!=0)){
    if(dp[i][j-1]<dp[i][j]){
      while(dp[i-1][j]==dp[i][j]){
        i--;
      }
      ans+=s[i-1];
      i--;
    }
    j--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70784
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    S = li()
    a = ["L", "R"]
    for i in range(len(S)):
        if S[i] == a[i % 2]:
            exit('No')
    print('Yes')
    return


if __name__ == '__main__':
    if not __debug__:
        import doctest
        doctest.testmod()
    main()


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

int main() {
  int N;
  cin>>N;
  int A ,b , c=100;
  for(int i=0 ; i<N ; i++){
    b=0 ;
    cin>>A;
    while(A%2==0&&A>0){
      
      A=A/2;
      b++;
    }
    c=min(c,b);  
  }
  cout<< c <<endl;
}
  

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int w, h;
char s[30][31], b[30][31];
map<char, int>dir{ {'N',0},{'E',1},{'S',2},{'W',3} };
char rd[] = "NESW";
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 }, a[]{ 1,0,3,2 };
int main() {
	while (scanf("%d%d", &w, &h), h) {
		rep(i, h)scanf("%s", s[i]);
		for (int i = 0; i <= 180; i++) {
			bool ok = true;
			rep(i, h)rep(j, w)for (auto p : dir) {
				if (s[i][j] == p.first) { ok = false; break; }
			}
			if (ok) {
				printf("%d\n", i); goto g;
			}
			rep(i, h)rep(j, w) {
				if (dir.find(s[i][j]) == dir.end())continue;
				int bs = dir[s[i][j]];
				rep(k, 4) {
					int nx = i + dx[(bs + a[k]) % 4], ny = j + dy[(bs + a[k]) % 4];
					if (0 <= nx&&nx < h && 0 <= ny&&ny < w && (s[nx][ny] == '.' || s[nx][ny] == 'X')) {
						s[i][j] = rd[(bs + a[k]) % 4]; break;
					}
				}
			}
			rep(i, h)rep(j, w)b[i][j] = s[i][j];
			rep(i, h)rep(j, w) {
				if (s[i][j] != 'X'&&s[i][j] != '.')continue;
				rep(k, 4) {
					int nx = i + dx[a[k]], ny = j + dy[a[k]];
					if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&dir.find(s[nx][ny]) != dir.end() && nx + dx[dir[s[nx][ny]]] == i&&ny + dy[dir[s[nx][ny]]] == j) {
						if (s[i][j] == 'X')b[nx][ny] = '.';
						else swap(b[i][j], b[nx][ny]);
						break;
					}
				}
			}
			rep(i, h)rep(j, w)s[i][j] = b[i][j];
		}
		puts("NA");
	g:;
	}
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;

char S[N],T[N];
int n,m,len,tax[N*2],tnum,x,y;

bool sol()
{
	int ld=1,rd=n;
	for(int i=tnum;i>=1;i--)
	{
		if(tax[i]==0)++ld;
		if(tax[i]==1)--rd;
		if(tax[i]==2)++rd;
		if(tax[i]==3)--ld;
		ld=max(ld,1),rd=min(rd,n);
		if(ld>n||rd<1||ld>rd)return 0;
	}
	if(ld<=x&&x<=rd)return 1;
	return 0;
}

int main()
{
	scanf("%d%d%d",&m,&n,&len);
	scanf("%d%d",&y,&x);
	scanf("%s",S+1);
	scanf("%s",T+1);
	tnum=0;
	for(int i=1;i<=len;i++)
	{
		if(S[i]=='L')tax[++tnum]=0;
		if(S[i]=='R')tax[++tnum]=1;
		if(T[i]=='L')tax[++tnum]=2;
		if(T[i]=='R')tax[++tnum]=3;
	}
	if(!sol())return puts("NO"),0;
	tnum=0,swap(n,m),swap(x,y);
	for(int i=1;i<=len;i++)
	{
		if(S[i]=='U')tax[++tnum]=0;
		if(S[i]=='D')tax[++tnum]=1;
		if(T[i]=='U')tax[++tnum]=2;
		if(T[i]=='D')tax[++tnum]=3;
	}
	if(!sol())return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 1408
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n;
vi g[MAX_N];
int col[MAX_N];
int cnt[2];
int ans[MAX_N];

void rec(int u = 0, int p = -1, int c = 0) {
    cnt[c]++;
    col[u] = c;

    for (int v : g[u]) {
        if (v != p) {
            rec(v, u, 1 - c);
        }
    }
}

int main() {
    fastio();

    cin >> n;
    forn(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int c1 = n / 3 + (n % 3 >= 1);
    int c2 = n / 3 + (n % 3 >= 2);

    rec();

    fill_n(ans, n, -1);
    int one = 1, two = 2, three = 3;

    if (cnt[0] < c1) {
        forn(i, n) {
            if (col[i] == 0) {
                ans[i] = three;
                three += 3;
            }
        }
    } else if (cnt[1] < c2) {
        forn(i, n) {
            if (col[i] == 1) {
                ans[i] = three;
                three += 3;
            }
        }
    } else {
        forn(i, n) {
            if (col[i] == 0 && one <= n) {
                ans[i] = one;
                one += 3;
            } else if (col[i] == 1 && two <= n) {
                ans[i] = two;
                two += 3;
            } else {
                ans[i] = three;
                three += 3;
            }
        }
    }

    forn(i, n) {
        if (ans[i] < 0) {
            if (one <= n) {
                ans[i] = one;
                one += 3;
            } else if (two <= n) {
                ans[i] = two;
                two += 3;
            } else {
                ans[i] = three;
                three += 3;
            }
        }
    }

    forn(i, n) {
        cout << ans[i] << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=(1l<<31)-1;
int k=(1<<17);
class segment{
public:
	vector<long> g;
	segment(int n):g(n){
		rep(i,0,n) g[i]=inf;//tanigen
		// parent:(i-1)/2 children:2i+1,2i+2
	}
	long func(long x,long y){
		return min(x,y);
	}
	void update(int v,long s){
		v+=k-1; g[v]=s;
		while(v>0){
			v=(v-1)/2;
			g[v]=func(g[2*v+1],g[2*v+2]);
		}return;
	}
	long query(int l,int r,int v,int a,int b){// [l,r)
		if(b<=l||r<=a) return inf;
        else if(l<=a&&b<=r) return g[v];
        else{
            long s=query(l,r,2*v+1,a,(a+b)/2);
            long t=query(l,r,2*v+2,(a+b)/2,b);
            return func(s,t);
        }
	}
};
int main(){
	int n,q; cin>>n>>q;
	segment sg(2*k-1);
	int c;int x;long y;
	rep(i,0,q){
		cin>>c>>x>>y;
		if(c) cout<<sg.query(x,y+1,0,0,k)<<endl;
		else sg.update(x,y);
	}
}


Measured memory_bytes: 4964
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M,res;
    string str;
    res = 0;
 
    cin >> N;
 
    map<string,int> B;   
    
    for(int i = 0; i < N; i++){
        cin >> str;
        B[str]++;
    }
    
    cin >> M;
 
    for(int i = 0; i < M; i++){
        cin >> str;
        B[str]--;
    }
 
  	map<string,int>:: iterator iter;
    for(iter = B.begin(); iter != B.end(); iter++){
        res = max(res,iter->second);
    }
 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, sum = 0;
	cin >> n;

	int tmp = n;
	while(tmp>0){
		sum += tmp % 10;
		tmp /= 10;
	}
	if(n%sum==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZEN = 110;
typedef long long LL;
int N,M;
LL f[SIZEN][2][10];
char str[SIZEN];
LL dfs(int x,bool lim,int k){
	if(k > M)return 0;
	if(x == N+1){
		return k == M;
	}
	if(~f[x][lim][k])return f[x][lim][k];
	f[x][lim][k] = 0;
	int top = lim?str[x]-48:9;
	for(int i = 0;i <= top;i++){
		f[x][lim][k] += dfs(x+1,lim & (i == top),k+(i != 0));
	}
	return f[x][lim][k];
}
int main(){
	scanf("%s",str+1);
	N = strlen(str+1);
	scanf("%d",&M);
	memset(f,-1,sizeof f);
	printf("%lld\n",dfs(1,1,0));
	return 0;
}
/*
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
3
*/

Measured memory_bytes: 1744
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int H, W;
    cin >> H >> W;

    vector<vs32> A(H, vs32(W));
    vector<vs32> B(H, vs32(W));
    int m = 0;
    rep (h, H) rep (w, W) cin >> A[h][w];
    rep (h, H) rep (w, W) { cin >> B[h][w]; m = MAX(m, abs(A[h][w] - B[h][w])); }

    vector< vector< vector <bool> > > dp(H, vector< vector<bool> >(W, vector<bool>((H + W) * m + 1, false)));
    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    for (int h = 0; h < H; ++h)
    {
        for (int w = 0; w < W; ++w)
        {
            for (int k = 0; k <= (H + W) * m; ++k)
            {
                if (dp[h][w][k])
                {
                    if (h < H - 1)
                    {
                        int d = abs(A[h + 1][w] - B[h + 1][w]);
                        dp[h + 1][w][abs(k - d)] = true;
                        dp[h + 1][w][abs(k + d)] = true;
                    }
                    if (w < W - 1)
                    {
                        int d = abs(A[h][w + 1] - B[h][w + 1]);
                        dp[h][w + 1][abs(k - d)] = true;
                        dp[h][w + 1][abs(k + d)] = true;
                    }
                }
            }
        }
    }

    int ans;
    for (ans = 0; ans <= (H + W) * m && !dp[H - 1][W - 1][ans]; ++ans);
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 10752
using System;

namespace AOJ.Volume0
{
    public class BMI
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var info = input.Split(',');
                decimal weight = decimal.Parse(info[1]);
                decimal height = decimal.Parse(info[2]);
                if (weight / (height * height) >= 25) { Console.WriteLine(info[0]); }
            }
        }
    }
}

Measured memory_bytes: 9428
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef      long long int 	ll;

void solve(){
	ll k,a,b;
	cin >> k >> a >> b;
	if(a%k && b%k && ((a/k)==(b/k))){
		cout << "NG" << endl;
	}
	else cout << "OK" << endl;
}

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


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    map<int,int> m;
    int over = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if (a >= 3200) {
            over++;
        } else {
            m[a/400]++;
        }
    }
    int Min = 0;
    int Max = 0;
    Min = max(1, (int)m.size()); // m.size()の返り値は符号なし整数
    Max = m.size() + over;
    cout << Min << " " << Max << endl;
    return 0;
}

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

struct Sushi {
  int t, d;
  Sushi(){};
  Sushi(int t_, int d_) { t = t_, d = d_; };
  bool operator<(const Sushi& o)const {return d>o.d;}

};

signed main() {
  int n, k;
  cin >> n >> k;
  vector<Sushi> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i].t >> s[i].d;
  }
  sort(begin(s), end(s));

  priority_queue<Sushi> pq;

  vector<int> score(n + 1);
  vector<bool> used(n + 1, false);
  int sum = 0, cnt = 0;
  for (int i = 0; i < k; ++i) {
    sum += s[i].d;
    if (used[s[i].t])
      pq.push(s[i]);
    else
      used[s[i].t] = true, cnt++;
  }
  score[cnt] = sum + cnt * cnt;
  for (int i = k; i < n && !pq.empty(); ++i)
    if (!used[s[i].t]) {
      sum = sum - pq.top().d + s[i].d;
      cnt++;
      score[cnt] = sum + cnt * cnt;

      used[s[i].t] = true;
      pq.pop();
    }
  int ans = *max_element(begin(score), end(score));
  cout << ans << endl;
}


Measured memory_bytes: 3708
N = int(input())
A = list(map(int, input().split()))

A.sort()

l = [0] * (A[N - 1] + 1)

for i in A:
        j = i 
        while j <= A[N - 1]: 
                l[j] += 1
                j += i 

cnt = 0 
for k in A:
        if l[k] == 1:
                cnt += 1

print(cnt)

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

int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int num;
  double s = w * h / 2.0;
  if(w / 2.0 == x && h / 2.0 == y) num = 1;
  else num = 0;
  cout << s << " " << num <<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double x = sc.nextDouble();
    if(x<=a*a*b/2)System.out.println(Math.toDegrees(Math.atan(a*b*b/(2*x))));
    else System.out.println(Math.toDegrees(Math.atan((2*a*a*b-2*x)/(a*a*a))));
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  vector<int> d(N-1);
  for (int j=0; j<N-1; j++) {
    d.at(j)=h.at(j+1)-h.at(j);
  }
  vector<int> s(N-K+1);
  for (int k=0; k<N-K+1; k++) {
    s.at(k)=d.at(k);
    for (int l=1; l<K-1; l++) {
      s.at(k)=s.at(k)+d.at(k+l);
    }
  }
  sort(s.begin(),s.end());
  cout << s.at(0) << endl;
}


Measured memory_bytes: 4556
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    cin >> n >> m;
    l = 1;
    long A[100][100],B[100][100],C[100][100];
    for(int i = 0;i < n; i ++){
        for(int j = 0; j < m; j ++){
            cin >> A[i][j];
        }
    }
    for(int i = 0;i < m; i ++){
        for(int j = 0; j < l; j ++){
            cin >> B[i][j];
        }
    }
    for(int i = 0;i < n; i ++){
        for(int j = 0; j < l; j ++){
            C[i][j] = 0;
            for(int k = 0; k < m; k ++){
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    for(int i = 0;i < n; i ++){
        for(int j = 0; j < l; j ++){
            if (j == l-1) cout << C[i][j] << endl;
            else cout << C[i][j] << " ";
        }
    }  
    return 0;
}


Measured memory_bytes: 3268
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int x[]=new int[n+1];
		for(int i=1;i<=n;i++)
			x[i]=nextInt();
		int d[]=new int[n+1];
		for(int i=1;i<=n;i++)
			d[i]=x[i]-x[i-1];
		int m=nextInt();
		long k=nextLong();
		int swap[]=new int[n+1];
		for(int i=1;i<=n;i++)
			swap[i]=i;
		for(int i=1;i<=m;i++)
		{
			int a=nextInt();
			int temp=swap[a];
			swap[a]=swap[a+1];
			swap[a+1]=temp;
		}
		Permutations perm=new Permutations();
		swap=perm.exp(swap,k);
		d=perm.multiply(d,swap);
		double curr=0;
		for(int i=1;i<=n;i++)
			out.println(curr+=d[i]);
	}
	class Permutations
	{
		int[] exp(int a[],long k)
		{
			int n=a.length-1;
		    int ret[]=new int[n+1];
		    for(int i=1;i<=n;i++)
		    	ret[i]=i;
		    while(k>0)
		    {
		        if(k%2==1)
		            ret=multiply(ret,a);
		        a=multiply(a,a);
		        k=k/2;
		    }
		    return ret;
		}
		int[] multiply(int a[],int b[])
		{
			int n=a.length-1;
			int c[]=new int[n+1];
			for(int i=1;i<=n;i++)
				c[i]=a[b[i]];
			return c;
		}
	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 53552
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  S.sort();
  var ans="No";
  if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
    ans="Yes";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
#import numpy as np

    
##################################################################

if __name__ == "__main__":

    Input1 = [str(input()) for i in range(1)]
    if Input1[0] == 'Sunny':
        print('Cloudy')
    elif Input1[0] == 'Cloudy':
        print('Rainy')
    else:
        print('Sunny')


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;

int main (int argc, char const* argv[]){
  int n;
  double x1,x2,x3,x4,y1,y2,y3,y4;
  
  
  cin >> n;
  //座標取得
  while(cin >> x1 >>y1 >>x2 >>y2 >>x3 >>y3 >>x4 >>y4){
    double ax=x2-x1, ay=y2-y1, bx=x4-x3,by=y4-y3;
    double det = ax*by - ay*bx;
    if(EQ(det,0.0)) cout << "YES" <<endl;
    else cout << "NO" << endl;
    
  }
  
  
  
  
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

//modの値の確認をすること
int main(){
    string s;
    ll k;
    cin >> k >> s;
    if(s.size() > k)pf(s.substr(0,k) + "...");
    else pf(s);
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  int i,sum=1<<30;
  string ch;	
  cin>>ch;
  for(i=1;i<ch.length();i++)
    if(ch[i]!=ch[i-1]) 
      sum=min(sum,max(i,int(ch.length())-i)); 
  cout<<min(sum,int(ch.length()))<<endl; 
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

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

  int z=0;
  for(int i=0;i<N;i++){
    if(i%2)z-=A[i];
    else z+=A[i];
  }

  int index=0;
  if(z<0)z*=-1,index=1;

  vector<int>ans(N);
  ans[index]=z;

  if(index==0){
    for(int i=1;i<N;i++){
      ans[i]=2*A[i-1]-ans[i-1];
    }
  }
  else{
    ans[0]=A[0]-ans[1]/2;
    for(int i=2;i<N;i++){
      ans[i]=2*A[i-1]-ans[i-1];
    }
  }

  for(auto it:ans)cout<<it<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;

int n, a[100005], l;
priority_queue<pi,vector<pi>,greater<pi> > pq;

int main(){
    scanf("%d %d",&n,&l);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]);
    }
    for (int i=1; i<=n; i++) {
        if(a[i] > a[i-1] && a[i] > a[i+1]){
            pq.push(pi(l - a[i],i));
        }
    }
    int ret = 0;
    while (!pq.empty()) {
        pi t = pq.top();
        pq.pop();
        ret = max(ret,t.first);
        a[t.second] = 0;
        if(t.second > 1 && a[t.second-1] > a[t.second-2]){
            pq.push(pi(l - a[t.second-1] + t.first,t.second-1));
        }
        if(t.second < n && a[t.second+1] > a[t.second + 2]){
            pq.push(pi(l - a[t.second+1] + t.first,t.second + 1));
        }
    }
    printf("%d\n",ret);
}

Measured memory_bytes: 1892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int[] ary=new int[N];
		for(int i=0; i<N; i++) {
			ary[i]=sc.nextInt();
		}
		int zougen=0;
		int counter=0;
		int now=ary[0];
		for(int i=1; i<N; i++) {
			if(now==ary[i]) {
				//増加減少どちらでもない
			}
			else {
				if(zougen==0) {	//増加減少未定の時
					if(now>ary[i]) {//減少
						zougen=-1;
						now=ary[i];
					}
					else if(now<ary[i]) {//増加
						zougen=1;
						now=ary[i];
					}
				}
				else if(zougen==1) {	//増加の時
					if(now>ary[i]) {//減少してしまう時
						zougen=0;
						counter++;
						now=ary[i];
					}
					else if(now<=ary[i]) {//増加
						zougen=1;
						now=ary[i];
					}
				}
				else if(zougen==-1) {	//減少の時
					if(now>ary[i]) {//減少してしまう時
						now=ary[i];
					}
					else if(now<=ary[i]) {//増加してしまう時「
						zougen=0;
						counter++;
						now=ary[i];
					}
				}
			}
		}
		counter++;
		pl(counter);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 37588
H,N=map(int, input().split())
l=list(map(int, input().split())) 

import math

# H,N=3,1
# l=[4,1,5]

import sys
if N>=len(l):
    print(0)
    sys.exit()

    
sort_l=sorted(l)
delete_l=sort_l[:len(l)-N]
print(sum(delete_l))

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


signed main()
{
	#ifndef ONLINE_JUDGE
   		freopen("input.txt","r",stdin);
   		freopen("output.txt","w",stdout);   
	#endif

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

   	int n,k,i,ret=0,ch=0;
	cin>>n>>k;
	inp(p,n,1);
	inp(cost,n,1);
	for(i=1;i<=n;i++)
		if(cost[i]<=0)
			ch++;
	if(ch==n)
	{
		ret=-inf;
		for(i=1;i<=n;i++)
			ret=max(ret,cost[i]);
		cout<<ret;
		return 0;
	}
	for(i=1;i<=n;i++)
	{
		int node=i,sz=0,res=0;
		int h[n+1]={0};
		while(h[node]==0)
		{
			h[node]++;
			sz++;
			node=p[node];
		}
		if(sz>k)
		{
			int cnt=0,ans=0;
			node=i;
			while(cnt!=k)
			{
				ans+=cost[p[node]];
				res=max(res,ans);
				node=p[node];
				cnt++;
			}
		}
		else
		{
			int cnt=0,ans=0;
			node=i;
			while(cnt!=sz)
			{
				ans+=cost[p[node]];
				res=max(res,ans);
				node=p[node];
				cnt++;
			}
			if(ans>=0)
			{
				int anss=0,mx=0;
				int ans1=ans*(k/sz);
				int kk=k%sz;
				cnt=0;
				node=i;
				while(cnt!=kk)
				{
					anss+=cost[p[node]];
					mx=max(mx,anss);
					node=p[node];
					cnt++;
				}
				ans1+=mx;
				res=max(res,ans1);
				cnt=0,node=i,anss=0,mx=0;
				int ans2=ans*max(0LL,k/sz-1);
				while(cnt!=sz)
				{
					anss+=cost[p[node]];
					mx=max(mx,anss);
					node=p[node];
					cnt++;
				}
				ans2+=mx;
				res=max(res,ans2);
			}
		}
		ret=max(ret,res);
	}
	cout<<ret;
	return 0;
}


Measured memory_bytes: 3748
N,x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(1,N):
    if a[i-1] > x:
        b = a[i-1] - x
        cnt += b
        a[i-1] -= b
    if a[i-1]+a[i] > x:
        b = a[i-1] + a[i] - x
        cnt += b
        a[i] -= b
print(cnt)

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n,a);
    lli ans[n+1];
    REP(i,0,n) {
        ans[a[i]] = i+1;
    }
    REPE(i,1,n) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


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

template<typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
  return (a*b)/gcd(b%a, a);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i, n) {
    cin >> w[i];
  }
  int ans = INT_MAX;
  rep2(i, 1, n) {
    int left = accumulate(&w[0], &w[i], 0);
    int right = accumulate(&w[i], &w[n], 0);
    ans = min(ans, abs(left - right));
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n,q;
    std::cin >> n >> q;
    std::vector<long long> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];

    for(int j = 0; j < q; j++){
        long long x;
        std::cin >> x;
        long long res  = 0;


        int right = 0;
        long long sum = 0;

        for(int left = 0; left < n; left++){
            while(right < n && sum + a[right]<= x){
                sum += a[right];
                right++;
            }

            res += (right - left);

            if(right == left)right++;
            else sum -= a[left];
        }
        std::cout << res << std::endl;
    }
}


Measured memory_bytes: 3620
// ABC162C - Sum of gcd of Tuples (Easy)

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

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

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

	long long int ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				int t;
				t = gcd(a, b);
				ans += gcd(t, c);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

const int maxn = 1e5+5;

int t[maxn];

int sum(int r){
	int ans = 0;
	while(r >= 0){
		ans += t[r];
		r = (r & (r+1)) - 1;
	}
	return ans;
}

void add(int k, int x){
	while(k < maxn){
		t[k] += x;
		k = k | (k+1);
	}
}

int ans[maxn];

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

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

	vector< pair<int, int> > a(n);

	for(int i = 0; i < n; i++){
		cin >> a[i].first >> a[i].second;
		ans[a[i].second-a[i].first+1]++;
	}

	sort(a.begin(), a.end(), [](pair<int, int> x, pair<int, int> y){
		return x.second-x.first < y.second-y.first;
	});

	for(int i = m-1; i >= 1; i--)
		ans[i] += ans[i+1];

	int k = 0;

	for(int i = 2; i <= m; i++){
		while(k < n && a[k].second-a[k].first+1 < i){
			add(a[k].first, 1);
			add(a[k].second+1, -1);
			k++;
		}
		for(int j = i; j <= m; j += i)
			ans[i] += sum(j);
	}

	for(int i = 1; i <= m; i++) cout << ans[i] << "\n";

	return 0;
}


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

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll  i, x, j, y, 	z = 0, k, n;
	string s, t;
	cin >> s >> t;	n = s.size();
	rep(i, 0, n, 1)	z += s[i] != t[i];
	ce(z)
}


Measured memory_bytes: 3884
from math import gcd
from functools import reduce


def main():
    l = int(input())
    answer = 0
    for i in range(1, l + 1):
        for j in range(1, l + 1):
            for k in range(1, l + 1):
                answer += reduce(gcd, [i, j, k])
    print(answer)


if __name__ == '__main__':
    main()



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

using namespace std;

int main(){
    int n,k;
    cin >> n >>k;
    string s;
    cin >> s;
    for(int i=0;i<n;i++){
        if(i==k-1)cout << char(tolower(s[i]));
        else cout << s[i];
    }
}

Measured memory_bytes: 384
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e6 + 10;

struct node {
    int l, r;
    int val, key;
    int size;
    bool lazy;
} tree[N];

int cnt, root;
char s[N],ans[N],pos;

int newnode(int val) {
    tree[++cnt].val = val;
    tree[cnt].key = rand();
    tree[cnt].size = 1;
    return cnt;
}

void update(int now) {
    tree[now].size = tree[tree[now].l].size + tree[tree[now].r].size + 1;
}

void pushdown(int now) {
    swap(tree[now].l, tree[now].r);
    tree[tree[now].l].lazy ^= 1;
    tree[tree[now].r].lazy ^= 1;
    tree[now].lazy = false;
}

void split(int now, int siz, int &x, int &y) {
    if (!now)x = y = 0;
    else {
        if (tree[now].lazy)
            pushdown(now);
        if (tree[tree[now].l].size < siz) {
            x = now;
            split(tree[now].r, siz - tree[tree[now].l].size - 1, tree[x].r, y);
        } else {
            y = now;
            split(tree[now].l, siz, x, tree[y].l);
        }
        update(now);
    }
}

int merge(int x, int y) {
    if (!x || !y)
        return x + y;
    if (tree[x].key < tree[y].key) {
        if (tree[x].lazy)
            pushdown(x);
        tree[x].r = merge(tree[x].r, y);
        update(x);
        return x;
    } else {
        if (tree[y].lazy)
            pushdown(y);
        tree[y].l = merge(x, tree[y].l);
        update(y);
        return y;
    }
}

void reverse(int l, int r) {
    int x, y, z;
    split(root, l - 1, x, y);
    split(y, r - l + 1, y, z);
    tree[y].lazy ^= 1;
    root = merge(merge(x, y), z);
}

void print(int now) {
    if (!now)
        return ;
    if (tree[now].lazy)
        pushdown(now);
    print(tree[now].l);
    //ans[pos++]=tree[now].val+'a';
    if(tree[now].val!=100)
    	printf("%c",tree[now].val+'a');
    print(tree[now].r);
}

void head(int v){
	int x,y;
	split(root,1,x,y);
	root=merge(merge(x,newnode(v)),y);
}


int main() {
    
#ifdef xiaofan
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
#endif

	cin>>s+1;
	int n=strlen(s+1);
	root=merge(root,newnode(100));
	for(int i=1;i<=n;i++)
		root=merge(root,newnode(s[i]-'a'));
	int q;
	cin>>q;
	while(q--){
		int op;
		cin>>op;
		if(op==1){
			reverse(2,n+1);
		}else{
			int x;
			char oo;
			cin>>x>>oo;
			if(x==1){
				head(oo-'a');
			}else{
				root=merge(root,newnode(oo-'a'));
			}
			n++;
		}
	}
	print(root);
	/*for(int i=0;i<pos;i++){
		if(i!=0)printf("%c",ans[i]);
	}*/
	
	
	



    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    vector<int> a(3);
    cin >> n >> a[0] >> a[1] >> a[2];
    vector<int> l(n);
    rep(i, n)cin >> l[i];

    int mx = 1;
    rep(i, n)mx *= 4;
    int ans = 1001001001;
    rep(i, mx){
        vector<vector<int>> cnt(3);
        int x = i;
        rep(j, n){
            int k = x % 4;
            x /= 4;
            if(k == 0)cnt[0].push_back(j);
            else if(k == 1)cnt[1].push_back(j);
            else if(k == 2)cnt[2].push_back(j);
        }
        if(cnt[0].size() == 0 || cnt[1].size() == 0 || cnt[2].size() == 0)continue;
        int sum = 0;
        rep(j, 3){
            sum += 10 * (cnt[j].size() - 1);
            int asum = 0;
            rep(k, cnt[j].size()){
                asum += l[cnt[j][k]];
            }
            sum += abs(asum - a[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;

    if(A >= 13){
        cout << B << endl;
    }

    else if(6 <= A && A <= 12){
        cout << B / 2 << endl;
    }

    else if (A <= 5){
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#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>;

int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i, n-1) cin>>b[i];
    ll ans=b[0] + b[n-2];
    rep(i, n-2){
        ans += min(b[i],b[i+1]);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n, m, h;
  cin >> n;
  cin >> m;
  int c = 1;
  for (int i = 1; i < n; i++) {
    cin >> h;
    if (m <= h) {
      m = h;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 384
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
ans = 1
A = [0]*(max(D)+1)
for i in range(N):
  A[D[i]] += 1
if D[0] != 0 or not all(D[1:]) or not all(A):
  print(0)
  exit()
for i in range(1, max(D)+1):
  ans = ans * pow(A[i-1], A[i], mod) % mod
print(ans % mod)

Measured memory_bytes: 13892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define inf 10e8
using namespace std;



int main(){
    int n;
    cin >> n;
    int ans=n*n*n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 100
#define WHITE 0
#define BLACK 1
#define GRAY  2

int i, j, n ,M[MAX][MAX];

void print()
{
	printf("%d\n",prim());
}

int prim()
{ 
	int u, minv, wheight = 0;
	int d[MAX], p[MAX], color[MAX];
	
	for (i = 0; i < n; i++) {
		d[i] = 100000;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while (1) {
		minv = 100000;
		u = -1;
		for (i = 0; i < n; i++) { 
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) {
			break;
		}
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != 100000) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	
	for (i = 0; i< n; i++) {
		if (p[i] != -1) {
			wheight = wheight + M[i][p[i]];
		}
	}
	return wheight;
}



int main() 
{
	int e;
	
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			scanf("%d",&e);
			M[i][j] = e;
			if (e == -1) {
				M[i][j] = 100000;
			}
		}
	}
		
	print();
		
    return 0;
}


Measured memory_bytes: 2044