akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Int solveRet;
Int P, Q, A, N;

int dfs (Int bunsi, Int bunbo, Int preBunbo, Int kousu) {
    if (N < kousu) return 0;
    if (P*bunbo < bunsi*Q) return 0;
    if (bunsi * Q == bunbo * P) solveRet++;
    for (int i = preBunbo; bunbo * i <= A; i++) {
        Int nextBunsi = bunsi * i + bunbo;
        Int nextBunbo = bunbo * i;
        dfs(nextBunsi, nextBunbo, i, kousu+1);
    }
    return 0;
}

long long solve() {
    solveRet = 0;
    for (int i = 1; i <= A; i++) {
        dfs(1, i, i, 1);
    }
    return solveRet;
}

int main(void) {
    vector<long long> ans;
    while (1) {
        cin >> P >> Q >> A >> N;
        if (Q == 0) break;
        ans.push_back(solve());
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}


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

int main() {
  int S;
  cin >> S;
  
  int L = S/100;
  int R = S%100;

  if(1 <= R && R <= 12){
    if(1 <= L && L <= 12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "YYMM" << endl;
    }
  }
  else{
    if(1 <= L && L <= 12){
      cout << "MMYY" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
  
}


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


bool compare(pair<int, long long> x, pair<int, long long> y){
    return x.second > y.second;
}
void solve(long long N, std::vector<long long> X){
    // 候補は２つ 
    // ４こ -> 1 or 2
    vector<pair<int, long long>> v;

    for(int i = 0; i < X.size(); i++){
        v.push_back(make_pair(i, X[i]));
    }
    sort(v.begin(), v.end(), compare);

    map<int, long long> ans;
    int left = (v.size() -1) / 2 ;
    int right = (v.size() -1) / 2 + 1;
    for(int i = 0; i < v.size(); i++){
        if(i <= left){
            ans[v[i].first] = v[right].second;
        } else { 
            ans[v[i].first] = v[left].second;
        }
    }

    for(auto m: ans){
        cout << m.second << endl;
    }



}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 19436
from collections import defaultdict
h, w =  map(int, raw_input().split())

a = []
aa = ""
for i in xrange(h):
    s = raw_input()
    a.append(s)
    aa += s

d = defaultdict(int)
for c in aa:
    d[c] += 1

q = 0
ch = 0
pair = 0
for cnt in d.values():
    q += cnt / 4
    r = cnt % 4
    if r >= 2:
        pair += 1
        r %= 2
    ch += r

def is_odd(x):
    return x % 2 == 1

if is_odd(h) and is_odd(w):
    if q >= (h/2) * (w/2) and ch == 1:
        print 'Yes'
    else:
        print 'No'
elif not is_odd(h) and not is_odd(w):
    if q >= (h/2) * (w/2) and pair == 0 and ch == 0:
        print 'Yes'
    else:
        print 'No'
else:
    if q >= (h/2) * (w/2) and ch == 0:
        print 'Yes'
    else:
        print 'No'

Measured memory_bytes: 2936
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

def cf(x1,x2):
    cf=[]
    for i in range(1, min(x1,x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def primes_for(n):
   is_prime = [True] * (n + 1)
   is_prime[0] = False
   is_prime[1] = False
   for i in range(2, n + 1):
       for j in range(i * 2, n + 1, i):
           is_prime[j] = False
   return [i for i in range(n + 1) if is_prime[i]]

a = make_divisors(A)
b = make_divisors(B)

kouyaku = (set(a) & set(b))

# p = primes_for(10**6)
# p.append(1)

# print(len((set(kouyaku) & set(p))))

def is_prime(n):
    if n == 1:
        return True
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

wa = 0
for i in kouyaku:
	if is_prime(i):
		wa += 1
print(wa)

Measured memory_bytes: 62816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  long int a=1,b=1,c=2;
  for(int i=0;i<N;i++){
    a*=10;
    b*=8;
    c*=9;
    a%=1000000007;
    b%=1000000007;
    c%=1000000007;
  }
  cout << (1000000007+a+b-c)%1000000007 <<endl;
}


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

inline int in() { int x; cin >> x; return x; }

const int inf = 1001001001;

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

  vector<int> r(R);
  for (auto &i : r) i = in() - 1;

  vector<vector<int>> d(n, vector<int>(n, inf));
  for (int i = 0; i < m; ++i) {
    int u = in() - 1, v = in() - 1, c = in();
    d[u][v] = d[v][u] = c;
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = inf;
  sort(r.begin(), r.end());
  do {
    int sum = 0;
    for (int i = 1; i < R; ++i) {
      sum += d[r[i - 1]][r[i]];
    }
    ans = min(ans, sum);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a,b,c;
int main(){FAST;
cin>>a>>b>>c;
if(a+b>c and a+c>b and b+c>a and a==b and b==c){
	cout<<"Yes";
}
else{
	cout<<"No";
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y0 Y0
#define y1 Y1
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 220;

int N, M;
char A[MAXN + 5][MAXN + 5];
int prefix[MAXN + 5][MAXN + 5];

inline int check_sum (int x1, int y1, int x2, int y2)
{
	int sum = prefix[x2][y2] - prefix[x1 - 1][y2] - prefix[x2][y1 - 1] + prefix[x1 - 1][y1 - 1];
	if (sum == 0 || sum == (x2 - x1 + 1) * (y2 - y1 + 1)) return 1;
	return 0;
}

int F[MAXN + 5][MAXN + 5][MAXN + 5];
int G[MAXN + 5][MAXN + 5][MAXN + 5];

inline void Init ()
{
	for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j)
		prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + (A[i][j] == '.');

	for (int i = 1; i <= N; ++i) for (int j = i; j <= N; ++j)
		for (int k = M; k >= 1; --k)
		{
			if (k != M && F[i][j][k + 1] && check_sum (i, k, j, F[i][j][k + 1])) F[i][j][k] = F[i][j][k + 1];
			else if (check_sum (i, k, j, k)) F[i][j][k] = k;
		}

	for (int i = 1; i <= M; ++i) for (int j = i; j <= M; ++j)
		for (int k = N; k >= 1; --k)
		{
			if (k != N && G[i][j][k + 1] && check_sum (k, i, G[i][j][k + 1], j)) G[i][j][k] = G[i][j][k + 1];
			else if (check_sum (k, i, k, j)) G[i][j][k] = k;
		}
}

inline void Solve ()
{
	Init ();
	if (F[1][N][1] == M) return void (puts("0"));

	for (int ans = 1; ; ++ans)
	{
		for (int i = 1; i <= N; ++i) for (int j = i; j <= N; ++j)
			for (int k = 1; k <= M; ++k) if (F[i][j][F[i][j][k] + 1])
				F[i][j][k] = F[i][j][F[i][j][k] + 1];

		for (int i = 1; i <= M; ++i) for (int j = i; j <= M; ++j)
			for (int k = 1; k <= N; ++k) if (G[i][j][G[i][j][k] + 1])
				G[i][j][k] = G[i][j][G[i][j][k] + 1];

		for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j)
		{
			for (int k = i, p = M; k <= N; ++k)
			{
				while (p && G[j][p][i] < k) --p;
				Chkmax (F[i][k][j], p);
			}
			for (int k = j, p = N; k <= M; ++k)
			{
				while (p && F[i][p][j] < k) --p;
				Chkmax (G[j][k][i], p);
			}

		}

		if (F[1][N][1] == M) return void (printf("%d\n", ans));
	}
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= N; ++i) scanf("%s", A[i] + 1);
}

int main ()
{

	Input ();
	Solve ();

	return 0;
}



Measured memory_bytes: 75776
n,*a=map(int,open(0).read().split())
c=0
x=1000
for i in range(n-1):
    if a[i+1]>a[i]:
        c+=x//a[i]
        x%=a[i]
    if a[i+1]<a[i]:
        x+=c*a[i]
        c=0
print(x+c*a[-1])

Measured memory_bytes: 9040
# coding: utf-8;

def main():
    num = [0,1,2,3,4,5,6,7,8,9]
    n, k = map(int, input().split())
    d = list(map(int, input().split()))
    usable_num = list(set(num) - set(d))

    while True:
        if len(set(map(int, str(n))) - set(usable_num)) == 0:
            break
        else:
            n += 1
    print(n)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int i,j,data[10],tmp;
  for(i=0;i<10;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<10;i++){
    for(j=9;j>i;j--){
      if(data[j]>data[j-1]){
    tmp=data[j];
    data[j]=data[j-1];
    data[j-1]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",data[i]);
  }
  return(0);
}

Measured memory_bytes: 2700
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=n; i>1; --i)
const int mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    long long ans = 1;
    if (abs(n-m) > 1) ans = 0;
    if (n == m) ans *= 2;
    rep(i, n) {
        ans *= i;
        ans %= mod;
    }
    rep(i, m) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
 
    long long N,M;
 
    cin >> N>> M;
 
    if(N==1){
      	if(M==1){
        	cout << 1 <<endl;
        }else{
          cout <<M-2 <<endl;
        }
    }else{
      	if(M==1){
	        cout  << N-2 <<endl;
        }else{
        	cout <<(N-2)*(M-2)<<endl;
        }
    }
    
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    if(a<9&&b<9) cout <<"Yay!"<<endl;
    else cout << ":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    a, b, t = map(int, input().split())
    cnt = 0
    for i in range(1, t + 1):
        if i % a == 0:
            cnt += b
    print(cnt)


# region template

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


class ostream:
    def __lshift__(self, a):
        if a is endl:
            sys.stdout.write(b"\n")
            sys.stdout.flush()
        else:
            sys.stdout.write(str(a))
        return self


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
cout, endl = ostream(), object()

readline = sys.stdin.readline
readlist = lambda var=int: [var(n) for n in readline().split()]
input = lambda: readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int n,m; scanf("%d%d", &n, &m);
  static int wf[50][50];
  for(int i = 0; i < n; i++) fill(wf[i],wf[i]+n,1000000000);
  for(int i = 0; i < m; i++) {
    int a,b,c,d; scanf("%d,%d,%d,%d", &a, &b, &c, &d); a--; b--;
    wf[a][b] = c;
    wf[b][a] = d;
  }
  int s,g,pr0,pr1; scanf("%d,%d,%d,%d", &s, &g, &pr0, &pr1); s--; g--;
  for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        wf[i][j] = min(wf[i][j], wf[i][k]+wf[k][j]);
      }
    }
  }
  printf("%d\n", pr0-pr1-wf[s][g]-wf[g][s]);
  return 0;
}

Measured memory_bytes: 1028
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  ll P[N];
  bool CON[N];
  REP(i,N){
    cin>>P[i];
    if(P[i]==i+1) CON[i]=true;
    else CON[i]=false;
  }
  
  REP(i,N){
    if(CON[i]==true){
      ans++;
      i++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

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

  if (n % (d*2+1) == 0) {
	   cout << n / (d*2+1);
    } else {
	    cout << n / (d*2+1) + 1;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=0;i<N;i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    ans += (tmp2-tmp1+1);
  }

  cout << ans << endl;

}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  ll pows = 0,sums = 0;
  rep(i,n){
    ll x;cin >> x;
    sums += x;
    pows += x*x;
  }
  ll d = sums/n;
  ll res = 1ll << 60;
  res = min(res,d*d*n-2*d*sums+pows);
  d++;
  res = min(res,d*d*n-2*d*sums+pows);
  cout << res << endl;






  

  return 0;
}

Measured memory_bytes: 256
long M=998244353,d[90310],e[90310],s=0,r=1;
a;t;
main(){
d[0]=e[0]=1;
for(scanf("%*d");~scanf("%d",&a);){
for(t=s;~t;--t)d[t+a]+=d[t]*2%M,e[t+a]+=e[t]%M;
s+=a;
r=r*3%M;
}
for(t=s/2;~t;--t)r=(r-d[t]*3)%M;
r=(r-~s%2*e[s/2]*3+M)%M;
printf("%d",r);
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;
const int MAX = 1000000 + 1;

bool prime[MAX];

void sieve() {
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2, MAX) {
		if(prime[i]) {
			for(int j=i; j<MAX; j+=i) {
				if(j == i) continue;
				prime[j] = false;
			}
		}
	}
}

int main() {
	sieve();
	int a, d, n;
	while(cin >> a >> d >> n, a|d|n) {
		int cnt = 0;
		REP(i, MAX) {
			if(prime[a + d * i])
				cnt++;
			if(cnt == n) {
				cout << a + d * i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2144
n,m,x = map(int,input().split())

box = []
for i in range(n):
  line = list(map(int,input().split()))
  box.append(line)
anss = []

for i in range(2**n):
  ans = [0 for i in range(m+1)]
  count = 0
  for j in range(n):
    if (i>>j)&1:
      for l in range(m+1):
        ans[l] += box[j][l]
  for k in range(1,m+1):
    if ans[k]>=x:
      count += 1
  if count == m:
    anss.append(ans[0])
if len(anss) == 0:
  print(-1)
else:
  print(min(anss))

Measured memory_bytes: 9280
#include <iostream>
#include <vector>
#define rep(i,n), for(int i=0;i<n;i++)
using namespace std;



int main(void){

    int N;
    cin>>N;
    int amari=0;
    int keta=1;
    int tempN = N;
    // while(1){
    //     tempN/=10;
    //     if(tempN>0){
    //         keta++;
    //     }else{
    //         break;
    //     }
    // }
    
    while(N>0){
        amari+=N%10;
        N/=10;
    }


    //cout << amari << endl;
    if(tempN%amari==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;    
    }
    


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(){

	char c;

	while(1){
	
		scanf( "%c", &c );

		if( c == '\n' ) break;
		if( isprint(c) ){
			if( islower(c) ) 
				printf( "%c", toupper(c) );
			else if( isupper(c) ) 
				printf( "%c", tolower(c) );
			else
				printf( "%c", c );
		}
	}

	
	printf( "\n" );

	return 0;

}

Measured memory_bytes: 524
#include<iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main()
{
 int ans=0;
 int sum=0;
 int N;
 string S;
 cin >> N >>S;
 rep(i,N)
 {
	 if(S[i]=='I')
	 {
		 sum++;
		 if(sum>ans)
		 {
			 ans=sum;
		 }
	 }
	 else
	 {
		 sum--;
	 }
	
 }
 
 cout << ans <<endl;
 return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int l = 0, r = w, u = h, d = 0;
  
  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) chmax(l, x);
    else if(a == 2) chmin(r, x);
    else if(a == 3) chmax(d, y);
    else chmin(u, y);
  }
  int ans = max((r - l), 0) * max(0, (u - d));
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<map>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    map<string, int> m;
    string temp,temp2,temp3;
    cin >> temp;
    cin >> temp2;
    cin >> m[temp];
    cin >> m[temp2];

    cin >> temp3;
    m[temp3]--;
    cout << m[temp] << " " << m[temp2] << endl;
    return 0;
}

Measured memory_bytes: 3044
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int N = scanner.nextInt();
		final int M = scanner.nextInt();
		boolean [][] graph = new boolean [N][N];
		int [] visited = new int[N];
		
		for (int i = 0; i < M; i++) {
			int a = scanner.nextInt()-1;
			int b = scanner.nextInt()-1;
			graph[a][b] = true;
			graph[b][a] = true;			
		}
		System.out.println(paths(graph,0,visited));
		scanner.close();
	}

	private static int paths(boolean[][] graph, int start, int[] visited) {
		int count = 0;
		visited[start] += 1;
		switch (checkPath(visited)) {
		case -1:
			return 0;
		case 1:
			return 1;
		default:
			for (int i = 0; i < graph.length; i++) {
				if (graph[start][i] == true && visited[i] ==0) {
					count += paths(graph, i, Arrays.copyOf(visited, visited.length));
				}
			}
			return count;
		}
	}

	private static int checkPath(int[] visited) {
		for (int i = 0; i < visited.length; i++) {
			if (visited[i] >= 2) {
				return -1;
			} else if (visited[i] == 0) {
				return 0;
			}
		}
		return 1;
	}

}


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

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

    string a;
    char b, c;
    a = "A";
    b = B.at(0);
    c = C.at(0);

    string D;
    D = a+b+c;

    cout << D << endl;  
}

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

int main() {
  int x,y;
  cin>>x>>y;
  int arr[y];
  for(int i=0;i<y;i++){
  	cin>>arr[i];
  }
  int arr2[201];
  for(int i=0;i<201;i++){
  	arr2[i]=i;
  }  
  sort(arr,arr+y);
  for(int i=0;i<y;i++){
  	arr2[arr[i]]=-1;
  }
  int a=x;
  int b=x;
  for(int i=0;i<201;i++){
    if(a>=0 and arr2[a]!=-1){
    	cout<<a<<endl;
    	break;
    }
    if(b<201 and arr2[b]!=-1){
    	cout<<b<<endl;
    	break;
    }
    a-=1;
    b+=1;
  }
}

Measured memory_bytes: 3172
#include <iostream>

using namespace std;

void solve(int x, int y, int count) {
    int mod = x % y;
    if (mod == 0) {
        cout << y << ' ' << count << endl;
    } else {
        solve(y, mod, count+1);
    }
}

int main() {
    int x, y;
    while (cin >> x >> y) {
        if (x < y) {
            int tmp; tmp = x; x = y; y = tmp;
        }
        if (x == 0 && y == 0) break;
        solve(x, y, 1);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

long long n, m;
vector<pi>s;
int dp[1024];

int main(){
  while(scanf("%d", &n)){
	  if(!n)break;
	  int cnt=0;
	  while(n!=1){
	  if(n%2==0){n=n/2;cnt++;}
	  else{n=n*3+1;cnt++;}
	  }
	  printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD=1e9+7;
std::vector<int> v(1e6);

int pw(int a,int b){
  int res=1;
  while(b){
    if(b%2)res*=a;res%=MOD;
    a*=a;a%=MOD;
    b/=2;
  }
  return res;
}

int nCk(int n,int k){
  int res=v[n];
  res*=pw(v[k],MOD-2);res%=MOD;
  res*=pw(v[n-k],MOD-2);res%=MOD;
  return res;
}

signed main() {
  int H,W,A,B;cin>>H>>W>>A>>B;
  int ans=0;
  v[0]=1;for(int i=1;i<1000000;i++)v[i]=v[i-1]*i%MOD;
  for(int i=1;A+i<=H&&B+i<=W;i++){
    ans+=nCk(H-(A+i)+(B+i-1),(B+i-1))*nCk(A+i-1+W-(B+i-1)-1,A+i-1);
    //cout<<nCk(H-(A+i)+(B+i-1),(B+i-1))<<" "<<nCk(A+i-1+W-(B+i-1)-1,A+i-1)<<endl;
    ans%=MOD;
    //cout<<666<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main(){
	int max=0;
	char lb='A';
	for(int i=0,s1,s2;i<5;++i){
		cin>>s1>>s2;
		if(s1==0&&s2==0) break;
		if(s1+s2>max){
			max=s1+s2;
			lb='A'+i;
		}
		if(i==4){
			cout<<lb<<" "<<max<<"\n";
			max=0;
			i=-1;
			lb='A';
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int n,a,b; cin >> n >>a >> b;
  cout << min(a*n,b);

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll p,q,r;

int main(){
  cin >> p >> q >> r;
  cout << min({p+q,p+r,q+r}) << endl;

}


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

int main(void){
    long long int X,K,D;
    cin>>X>>K>>D;
    if(X!=0){
        if(X<0) X=-X;
        if(X/D>=K){
            cout<<X-D*K<<endl;
            return 0;
        }else{
            if((K-X/D)%2==0){
                cout<<X%D<<endl;
                return 0;
            }else{
                cout<<llabs(X%D-D)<<endl;
                return 0;
            }
        }
    }
    if(X==0){
        if(K%2==0){
            cout<<"0\n";
            return 0;
        }else{
            cout<<D<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; 
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ng = 0, ok = 1e9;
    auto isOK = [&](int x){
        int now = 0;
        rep(i,n) now += (a[i] - 1) / x;
        return now <= k;
    };
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(isOK(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

int main()
{
    int L, R, D;
    cin >> L >> R >> D;
    int cnt = 0;
    for (int it = L; it <= R; ++it) {
        if (it % D == 0) {
            cnt = it;
            break;
        }
    }
    if (cnt == 0) {
        cout << "0";
        return 0;
    }
    int res = (R - cnt + D) / D;
    cout << res;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    for(int i = 0 ; i < 200 ; ++i){
      //高橋君の攻撃
      c -= b;
      //青木君の体力０以下かどうか
      if(c <= 0){
        //０以下なら高橋君の勝ち
        System.out.println("Yes");
        break;
      }
      
      //青木君の攻撃
      a -= d;
       //高橋君の体力０以下かどうか
      if(a <= 0){
        //０以下なら青木君の勝ち
        System.out.println("No");
        break;
      }
      
    }
  }
}

Measured memory_bytes: 35376
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n,k;
    cin>>n>>k;
    LL a[n+1];
    for(int i=0;i<=n;i++){a[i]=0;}
    for(int i=0;i<k;i++){
        LL d;
        cin>>d;
        for(int j=0;j<d;j++){
            LL m;
            cin>>m;
            a[m]++;
        }
    }
    LL ans=0;
    for(int i=1;i<=n;i++){if(a[i]==0){ans++;}}
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,k; cin>>n>>k;
    for(int i=1; true; i++){
        if(pow(k,i-1)-1<=n && n<pow(k,i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;
 
int main() {
  lint X,a,b;
  cin >> X;
  a = X/500;
  b = X%500;
  b /= 5;
  co(a*1000 + b*5);
}

Measured memory_bytes: 256
using System;

namespace B___Two_Anagrams
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var t = Console.ReadLine ();
            var sA = new char[s.Length];
            var tA = new char[t.Length];
            for (var i = 0; i < s.Length; i++)
            {
                sA[i] = s[i];
            }
            for (var i = 0; i < t.Length; i++)
            {
                tA[i] = t[i];
            }
            Array.Sort (sA);
            Array.Sort (tA);
            Array.Reverse (tA);
            var sS = "";
            var tS = "";
            foreach (var p in sA)
            {
                sS += p;
            }
            foreach (var p in tA)
            {
                tS += p;
            }
            switch (sS.CompareTo (tS))
            {
                case -1:
                    Console.WriteLine ("Yes");
                    break;

                case 0:
                    Console.WriteLine ("No");
                    break;

                case 1:
                    Console.WriteLine ("No");
                    break;
            }
        }
    }
}

Measured memory_bytes: 13408
#include <iostream>
#include <fstream>
#include <vector>

typedef unsigned long long ull;

ull n,cnt;

int main(){
    
    std::cin >> n;
    
    if(n % 2 == 1){
        std::cout << 0;
        return 0;
    }
    
    while(n){
        ull temp = (n / 5);
        cnt += temp / 2;
        n = temp;
    }
    
    std::cout << cnt;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
using namespace std;
LL n,A,B;
LL h[N];
bool check(LL x){
    LL temp=x*B;
    LL sub=A-B;
    LL sum=0;
    for(LL i=n;i>=1;i--){
        if(h[i]>temp){
            if((h[i]-temp)%sub)
                sum+=(h[i]-temp)/sub+1;
            else
                sum+=(h[i]-temp)/sub;
        }
    }
    if(sum<=x)
        return true;
    return false;
}

int main() {
    scanf("%lld%lld%lld",&n,&A,&B);
    LL right=0;
    for(LL i=1;i<=n;i++){
        scanf("%lld",&h[i]);
        right+=h[i]/B+1;
    }
    sort(h+1,h+1+n);
    LL left=1;
    while(left<right){
        LL mid=(left+right)/2;
        if(check(mid))
            right=mid;
        else
            left=mid+1;
    }
    printf("%lld\n",left);
    return 0;
}


Measured memory_bytes: 1024
import math
a,b,h,m=map(int,input().split())
lo=360*((h*60+m)/720)
sh=360*(m/60)
si=min(abs(lo-sh),360-max(lo,sh)+min(lo,sh))
si1=math.radians(si)
print((a**2+b**2-2*a*b*math.cos(si1))**(1/2))

Measured memory_bytes: 9572
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    string s, t;
    cin >> s >> t;
	bool ok = true;
	rep(i, s.size()){
    	if(s[i] != t[i]) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	ll n;
	std::cin >> n;

	std::vector<std::pair<ll, ll>> values;

	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;

		values.push_back({ i, n / i });
	}

	ll ans = infll;

	for (std::pair<ll, ll> value : values) {
		ans = std::min(ans, value.first - 1 + value.second - 1);
	}

	std::cout << ans << std::endl;

	return 0;
}

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


main()
{
	stack<int> s;
	queue<int> q;
	int n,m,i,j;
	long long clock[105],phd2,phd;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&clock[i]);
	}
	phd=clock[0];
	for(i=1;i<n;i++)
	{
		phd2 = phd;
		phd = __gcd(phd,clock[i]);
		phd = (phd2/phd)*clock[i];	
	}
	printf("%lld",phd);
	
}

Measured memory_bytes: 256
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                flag = 1
                break
        if flag:
            break
    if flag:
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;

using VS = vector<string>;

pair<VS, VS> parse(const string &S) {
    VS num, str;
    bool in_quot = false;
    bool init = true;
    string now = "";
    for(char c : S) {
        if(c == ';' && !in_quot) {
            num.push_back(move(now));
            now = "";
            continue;
        }
        if(c == '"') {
            if(!init) {
                auto &se = (in_quot ? str : num);
                se.push_back(move(now));
                now = "";
            }
            in_quot = !in_quot;
        } else {
            now += c;
        }
        init = false;
    }
    if(now.size()) num.push_back(now);
    return move(make_pair(num, str));
}

ll check(const VS &s, const VS &t) {
    if(s.size() != t.size()) return -1;
    ll cnt = 0;
    for(ll i = 0; i < s.size(); i++) if(s[i] != t[i]) cnt++;
    if(cnt == 0) return 1;
    else if(cnt == 1) return 0;
    else return -1;
}

bool solve() {
    string S;
    cin >> S;
    if(S == ".") return false;
    string T;
    cin >> T;

    VS snum, sstr, tnum, tstr;
    tie(snum, sstr) = parse(S);
    tie(tnum, tstr) = parse(T);

    ll cnum = check(snum, tnum);
    ll cstr = check(sstr, tstr);

    if(cnum == 1 && cstr == 1) cout << "IDENTICAL";
    else if(cnum == 1 && cstr == 0) cout << "CLOSE";
    else cout << "DIFFERENT";
    cout << endl;
    return true;
}

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



Measured memory_bytes: 3208
from collections import Counter
n = int(input())
X = list(map(int, input().split()))
c = Counter(X)
Xsort = sorted(X)

for i in range(n):
    if X[i]<Xsort[n//2]:
        print(Xsort[n//2])
    else:
        print(Xsort[n//2-1])


Measured memory_bytes: 33672
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

double dp[3000][3000];
int main() {
  int n;
  double p[3000];
  cin >> n;
  rep(i,n){
    cin >> p[i];
  }

  dp[0][0] = 1;
  rep(i,n)rep(j,i+2){
    dp[i+1][j] = dp[i][j] * (1-p[i]);
    if ( j != 0 ) {
      dp[i+1][j] += dp[i][j-1] * p[i]; 
    }
  }

  double ans = 0;
  rep(i,n+1){
    if ( i > n-i ) {
      ans += dp[n][i];
    }
  }
  printf("%.10f\n",ans);
}


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

int main() {
    int N; cin>>N;
    string S; cin>>S;
    if(N%2==1)cout<<"No"<<endl;
    else{
        for (int i = 0; i < N/2; i++){
            if(S[i]!=S[i+N/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    long long ans = n/(a+b);
    ans = ans*a;
    n=n%(a+b);
    long long k = min(n,a);
    ans = ans +k;
    cout<<ans;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;


int main(){
    ll n,k;
    cin >> n >> k;
    cout << n-k+1 << endl;
}



Measured memory_bytes: 3472
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500005; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{
    int n, q;
    cin >> n >> q;
    int a[n];
    for(int i = 0; i < n; i++)cin >> a[i];
    Query queries[q];
    for(int i = 0; i < q; i++){
        int a, b;
        cin >> a >> b;
        queries[i].l = a-1;
        queries[i].r = b-1;
        queries[i].idx = i;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 17400