akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

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

void dfs(vector<vector<ll>>& z,ll oya,vector<ll> &kyori,vector<bool> &seen,ll now) {
    kyori[now] = oya;
    seen[now] = true;
    for (int i = 0; i < z[now].size(); i++) {
        if (seen[z[now][i]] == false) {
            dfs(z, oya + 1, kyori, seen, z[now][i]);
        }
    }
    return;
}

int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> z(n);
    ll mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> z[i].first >> z[i].second;
        mx = max(z[i].second - z[i].first+1, mx);
    }
    sort(z.begin(), z.end());
    reverse(z.begin(), z.end());
    for (int i = 1; i < n; i++) {
        if (z[i].second >= z[i - 1].second) {
            z[i].first = z[i - 1].first;
            z[i].second = z[i - 1].second;
        }
    }
    ll zx = 0;
    ll ans = mx + max(zx, z[n - 1].second - z[0].first+1);
    ll m = 0;
    for (int i = 0; i < n-1; i++) {
        ans = max(max(zx, z[i].second - z[0].first+1) + max(zx, z[n-1].second - z[i+1].first + 1), ans);
    }
    cout << ans << endl;
}

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

typedef long long ll;

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

const ll INF=1LL<<60;

int N;
ll a[100010][3];
ll dp[100010][3];

int main(){
	int n; cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<3;i++){
		dp[0][i]=a[0][i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j!=k)dp[i+1][j]=max(dp[i][k]+a[i+1][j],dp[i+1][j]);
			}
		}
	}
	ll ans=0;
	for(int i=0;i<3;i++){
		ans=max(dp[n-1][i],ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    deck = string_to_int(inputs[0])
    sums = []
    for i, card in enumerate(deck):
        if i == 0:
            sums.append(card)
        else:
            sums.append(sums[i-1] + card)

    min_diff = None
    for i, s in enumerate(sums):
        if i == len(sums) - 1:
            break
        arai = sums[-1] - s
        sunuke = s

        if min_diff is None or min_diff > abs(arai - sunuke):
            min_diff = abs(arai - sunuke)
    return min_diff


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 87288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int n;
const int MAX_N = 4 * (int)1e5 + 4;

int data[MAX_N], datb[MAX_N];

void init_seg (int _n){
	memset (data, 0, sizeof (data));
	memset (datb, 0, sizeof (datb));
	n = 1;
	while (n < _n) n *= 2;
//	cerr << "n: " << n << endl;
}

void add (int a, int b, int x, int k, int l, int r){
	if (a <= l && r <= b){
		data[k] += x;
	}else
	if (l < b && a < r){
		datb[k] += (min(b,r) - max(a,l)) * x;
		add (a, b, x, 2 * k+1, l, (l + r) / 2);
		add (a, b, x, 2 * k+2, (l + r) / 2, r);
	} // end if
}

int sum(int a, int b, int k, int l, int r){
	if (b <= l || r <= a){
		return 0;
	}else
	if (a <= l && r <= b){
		return data[k] * (r - l) + datb[k];
	}else{
		int res = (min(b,r) - max(a,l)) * data[k];
		res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
		res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
		return res;
	}
}

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

	init_seg((int)1e5);
	for (int i = 0; i < n; ++i){
		add(i, i + 1, 0, 0, 0, n);
	} // end for

	int N,C; cin >> N >> C;
	rep (i, N){
		int s, t, c; cin >> s >> t >> c;
		add (s, t, 1<<(c-1), 0, 0, n);	
	} // end rep

	int res = 0;
	for (int i = 1; i < (int)1e5; ++i){
		int prev = sum(i - 1, i, 0, 0, n);
		int curr = sum(i, i + 1, 0, 0, n);
	 	if (prev == curr){
			res = max(res, __builtin_popcount(curr));
		}else{
			res = max(res, __builtin_popcount(curr | prev));
		} // end if
	} // end for

	cout << res << endl;
		
	return 0;
}

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

int main()
{	
	int i = 0;
	int A[100][2];//n:0,x:1
	int a[100];
	for (int i =0;i < 100;i++) {
		a[i] = 0;
	}
	for (;;) {
		cin >> A[i][0] >> A[i][1];
		if (A[i][0] == 0 && A[i][1] == 0)break;
		i++;
	}
	int j = 0;
	int x, y, z;
	for (j;j < i;j++) {
		for (x = 1;x <= A[j][0];x++)
			for (y = 1;y < x;y++)
				for (z = 1;z < y;z++)
					if (x + y + z == A[j][1]) 
						a[j]++;

		cout << a[j] << endl;
	}

	return 0;
}


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

int main(){
  int x,y;
  cin>>x>>y;
  int ans=abs(abs(x)-abs(y));
  
  if( abs(x) < abs(y) && x<0 )ans++;
  if( abs(x) <= abs(y) && y<0 )ans++;
  
  if( abs(x) > abs(y) && x>0 )ans++;
  if( abs(x) >= abs(y) && y>0 )ans++;
  
  cout<<ans<<endl;
  return 0;
}


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    string a;
    cin >> a;
    string b;
    cin >> b;
    int ans = 0;
    REP(i, 3){
        if(a.at(i) == b.at(i)){
            ans += 1;
        }
    }
    cout << ans;

}


Measured memory_bytes: 256
N,C=map(int,input().split())
D=[[int(x) for x in input().split()] for y in range(C)]
c=[[int(x)-1 for x in input().split()] for y in range(N)]

d=[[0 for x in range(C)] for y in range(3)]
for i in range(N):
  for j in range(N):
    d[(i+j)%3][c[i][j]]+=1

a=10**9
for c0 in range(C):
  for c1 in range(C):
    for c2 in range(C):
      if c0!=c1 and c1!=c2 and c0!=c2:
        a=min(a,sum([d[0][c]*D[c][c0]+d[1][c]*D[c][c1]+d[2][c]*D[c][c2] for c in range(C)]))
print(a)


Measured memory_bytes: 7284
#include <stdio.h>
struct bt{
    int n;
    int l;
    int r;
    int left;
};
bt b[1000000];
int now=0;
void insert(int n,int here){
    if(now==0){
        b[0].n=n;
        b[0].l=0;
        b[0].r=0;
        b[0].left=1;
        now++;
        return;
    }
    if(n==b[here].n){
        b[here].left++;
        return;
    }
    if(n>b[here].n){
        if(b[here].r==0){
            b[here].r=now;
            b[now].n=n;
            b[now].l=0;
            b[now].r=0;
            b[now].left=1;
            now++;
            return;
        }
        else{
            insert(n,b[here].r);
            return;
        }
    }
    if(b[here].l==0){
        b[here].l=now;
        b[now].n=n;
        b[now].l=0;
        b[now].r=0;
        b[now].left=1;
        now++;
        return;
    }
    insert(n,b[here].l);
    return;
}
bool find(int n,int here){
    if(b[here].n==n){
        if(b[here].left>0){
            b[here].left--;
            return true;
        }
        return false;
    }
    if(b[here].n>n){
        if(b[here].l==0)return false;
        return find(n,b[here].l);
    }
    if(b[here].r==0)return false;
    return find(n,b[here].r);
}
int main(){
    int n,temp,m;
    bool f;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        insert(temp,0);
    }
    scanf("%d",&m);
    f=m<=n;
    for(int i=0;i<m&&f;i++){
        scanf("%d",&temp);
        f=find(temp,0);
    }
    if(f)printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 4224
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    cnt = 0
    sorted_s_count = collections.defaultdict(int)
    for _ in range(N):
        s = S()
        s = ''.join(sorted(s))
        if s in sorted_s_count:
            cnt += sorted_s_count[s]
        sorted_s_count[s] += 1
    print(cnt)
main()



Measured memory_bytes: 20340
#include<cstdio>

int main(){
	int topping = 0;
	for (int i = 0; i < 3; ++i){
		char tmp;
		scanf("%c", &tmp);
		if(tmp == 'o') topping++;
	}
	printf("%d\n", 700 + 100*topping);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
p=list(map(int,input().split()))
foundpair=False
foundi=False
sortedp=sorted(p)
pair=[]
if p==sortedp:
  print("YES")
  exit(0)
for i in range(N):
  if p[i]== sortedp[i]:
    continue
  else:
    if foundpair==False:
      if foundi:
        foundpair=True
        pair.append(i)
      else:
        foundi=True
        pair.append(i)
    else:
      print("NO")
      exit(0)
      
p[pair[0]],p[pair[1]]=p[pair[1]],p[pair[0]]
if p==sortedp:
  print("YES")
else:
  print("NO")
      

Measured memory_bytes: 3064
#include <iostream> 
#include <cstdio> 
#include <cstdlib>  
#include <algorithm> 
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    int k;
    cin >> k;
    string s = "ACL";
    for (int i = 1; i < k; i++) s += "ACL";
    cout << s << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  
  switch(n % 10) {
    case 2:
      printf("hon\n");
      break;
    case 4:
      printf("hon\n");
      break;
    case 5:
      printf("hon\n");
      break;
    case 7:
      printf("hon\n");
      break;
    case 9:
      printf("hon\n");
      break;
    case 0:
      printf("pon\n");
      break;
    case 1:
      printf("pon\n");
      break;
    case 6:
      printf("pon\n");
      break;
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
  }
  return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
char a[105][105];
int dp[105][105];
const int dirx[] = {0, 1};
const int diry[] = {1, 0};

void solve() {
    int n, m;
    cin >> n >> m;
    rep(i, 1, n)cin >> (a[i] + 1);
    memset(dp, 0x3f, sizeof(dp));
    dp[1][1] = a[1][1] == '#';
    rep(i, 1, n) {
        rep(j, 1, m) {
            rep(k, 0, 1) {
                int x = i + dirx[k];
                int y = j + diry[k];
                if (x <= n && y <= m)
                    dp[x][y] = min(dp[x][y], dp[i][j] + (a[i][j] == '.' && a[x][y] == '#'));
            }
        }
    }
    cout << dp[n][m];
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	string S;
	cin >> S;

	if (S[6] == '3' || S[6] == '4') {
		cout << "Heisei" << endl;
	}
	else if (S[5] == '0' && S[6] == '1') {
		cout << "Heisei" << endl;
	}
	else if (S[5] == '0' && S[6] == '2') {
		cout << "Heisei" << endl;
	}

	else {
		cout << "TBD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
struct mmp{
	string s;
	int a,i;
};
int cmp(mmp a,mmp b){
	if(a.s!=b.s)return a.s<b.s;
	else return a.a>b.a;
}
int main(){
	fio;
	int n;
	cin>>n;
	mmp a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i].s>>a[i].a;
		a[i].i=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)cout<<a[i].i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;
ll dp[111][111][333];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,t; cin >> n >> t;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<n+1;j++){
			for(int k=0;k<256;k++){
				(dp[i+1][j+1][k^a[i]]+=dp[i][j][k])%=mod;
				(dp[i+1][j][k]+=dp[i][j][k])%=mod;
			}
		}
	}
	ll ans=(t==0),f=1;
	for(int i=1;i<=n;i++){
		f*=i;
		f%=mod;
		(ans+=dp[n][i][t]*f%mod)%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 30592
ls_c = [[i for i in input()] for j in range(2)]

if (ls_c[0][0] == ls_c[1][2]) and (ls_c[0][2] == ls_c[1][0]) and (ls_c[0][1] == ls_c[1][1]):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

#define ll long long

using namespace std;

/*   Every goose should go to prison!!!!!
     ██▀▀▄  ██     ██
▄███▀██░░░▌ ██     ██
█████████████████████████████
    ▐██░░░▐ ██     ██
    ▌██░░░░▐██     ██
█████████████████████████████
   ▐░██░▐▒▒▒██▒▒▒▀▀██
   ▐░██░▐▄▒▒██▒▒▒▒▒██▄
█████████████████████████████
     ██▄▄▄▄▄██▄▄▄▄▄██▄▄▄▀▄
     ██    ▌██▌▌   ██
█████████████████████████████
     ██  ▄▄▌██▌▌   ██ */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll h;
    cin >> h;
    ll k = 1;
    ll a = 0;
    while(h > 0) {
        h /= 2;
        a += k;
        k *= 2;
    }
    cout << a;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int N,K,D[10];
bool H[10];

bool hate(int V)
{
    while(V)
    {
        if(H[V%10]) return false;
        V /= 10;
    }
    return true;
}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i,10) H[i] = false;
    REP(i,K)
    {
        int tmp;
        cin >> tmp;
        H[tmp] = true;
    }
    while(1)
    {
        if(hate(N))
        {
            cout << N << endl;
            break;
        }
        N++;
    }

}

Measured memory_bytes: 256
USE_STDIO = False

if not USE_STDIO:
    try: import mypc
    except: pass

def main():
    n, k = map(int, input().split(' '))
    ans = 0

    x = n // k
    ans += x ** 3

    if k % 2 == 0:
        x = (n + k // 2) // k
        ans += x ** 3
    print(ans)


if __name__ == '__main__':
    main()





Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a,b;
	int ans=0;
	
	cin>>a>>b;
	if(a%3==0 || b%3==0 || (a+b)%3==0)
	{
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    int res = 1;

    for (int b = 2; b <= x; b++) {
        int ep = b * b;
        while (ep <= x) {
            res = max(res, ep);
            ep *= b;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin>>r;
	double ans = 3.1415*2*r;
	cout<<fixed<<setprecision(12)<<ans;	
	return 0;
}

Measured memory_bytes: 3808
def main():
  import bisect
  n=int(input())
  l=sorted(list(map(int,input().split())))
  ans=0
  for a in range(n-2):
    for b in range(a+1,n-1):
      ans+=bisect.bisect_left(l,l[a]+l[b])-b-1
  print(ans)
if __name__=='__main__':
  main()

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        x: usize,
        aa: [usize; m],
    }
    let mut ans1 = 0;

    let mut aa = aa;
    let mut cs = vec![false; n+1];
    for i in 0..n+1 {
        if i == aa[0] {
            cs[i] = true;
            aa.remove(0);
            if aa.len() == 0 { break; }
        }
    }
    for i in x+1..n+1 {
        if cs[i] {
            ans1 += 1;
        }
    }
    let mut ans2 = 0;
    for i in 0..x {
        if cs[i] {
            ans2 += 1;
        }
    }
    println!("{}", min(ans1, ans2));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N,vector<int>(N,0));
    rep(i,M) {
        int a,b;cin >> a >> b;
        --a; --b;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    
    vector<int> v;
    for (int i = 1;i < N;++i) v.push_back(i);
    int cnt = 0;
    do {
        if (G[0][v[0]] == 0) continue;
        bool flag = true;
        rep(i,N - 2) {
            if (G[v[i]][v[i + 1]] == 0) {
                flag = false;
            }
        }
        if (flag) ++cnt;
    } while(next_permutation(v.begin(),v.end()));
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, ans;
  cin >> n;
  
  ans = 0;
  for (; n > 0; n--) {
    int a, b;
    cin >> a >> b;
    ans += b - a + 1;
  }
   cout << ans << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002];
	rep1(i, N) A[i] = ((ll)getint() << 16) + i;
	rep(i, N + 2) LR[i] = -1;

	priority_queue<int> q;
	priority_queue<int, vector<int>, greater<int>> q2[2002];
	int q3[2002];
	rep1(i, N) q3[i] = i;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 16) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 16;
		int k = A[i] & m;

		int l = (LR[k - 1] == -1) ? k : LR[k - 1];
		int r = (LR[k + 1] == -1) ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		//if (k + k > l + r) swap(q3[l], q3[k + 1]);

		while (q2[q3[k + 1]].size()) {
			int tmp = q2[q3[k + 1]].top();
			q2[q3[l]].push(tmp);
			q2[q3[k + 1]].pop();
		}
		q2[q3[l]].push(a);
		while (q2[q3[l]].size() >= K) {
			int tmp = q2[q3[l]].top();
			q.push(tmp);
			q2[q3[l]].pop();
		}
		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 10880
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  happiness <- V.replicateM n $ do
    [a,b,c] <- map (read . BS.unpack) . BS.words <$> BS.getLine
    -- a,b,c <= 10^4
    return (a,b,c :: Int)
  let (a,b,c) = V.last $ V.scanl1' (\(a,b,c) (a',b',c') -> (max b c + a', max a c + b', max a b + c')) happiness
  print (max a (max b c))


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll digits(ll N){
  ll ans = 0;
  while(N>0){
    ans++;
    N/=10;
  }
  return ans;
}

int main(){
  ll N;
  IN(N);

  ll ans = 0;
  REP(i,N){
    if(digits(i+1)%2==1) ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void print(int a[], int N)
{
	for (int i = 0; i < N; i++)
	{
		printf("%d", a[i]);
		if (i != N - 1)
		{
			printf(" ");
		}
	}
	printf("\n");
}
int main()
{
	int a[100];
	int key;
	int N;
	scanf("%d", &N);

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

	print(a, N);

	int j;
	for (int i = 1; i < N; i++)
	{
		key = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > key)
		{
			a[j + 1] = a[j];
			j--;
			a[j + 1] = key;
		}
	
		print(a, N);
	}

	return 0;
}


Measured memory_bytes: 1976
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> pol;
vector<int> pol_odd;
int dp1[1000100],dp2[1000100];
int main()
{
	for(int i=0;i<=1000000;i++)dp1[i]=dp2[i]=INF;
	dp1[0]=dp2[0]=0;
	for(int i=1;;i++)
	{
		int k=i*(i+1)*(i+2)/6;
		if(k>1000000)break;
		pol.pb(k);
		if(k%2)pol_odd.pb(k);
	}
	for(int i=0;i<=1000000;i++)
	{
		for(int j=0;j<pol.size();j++)
		{
			if(i<pol[j])break;
			dp1[i]=min(dp1[i],dp1[i-pol[j]]+1);
		}
	}
	for(int i=0;i<=1000000;i++)
	{
		for(int j=0;j<pol_odd.size();j++)
		{
			if(i<pol_odd[j])break;
			dp2[i]=min(dp2[i],dp2[i-pol_odd[j]]+1);
		}
	}
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n==0)break;
		printf("%d %d\n",dp1[n],dp2[n]);
	}
	return 0;
}

Measured memory_bytes: 9020
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	i := 2
	lcm := 1
	for true {
		if a%i == 0 && b%i == 0 {
			a = a / i
			b = b / i
			lcm = lcm * i
		}
		if a%i != 0 || b%i != 0 {
			i++
			if i > a || i > b {
				lcm = lcm * a * b
				break
			}
		}
	}
	fmt.Println(lcm)
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p;
	vector<bool> sieve(n + 1, 1);
	for (int i = 2; i < n; i++) {
		if (!sieve[i])
			continue;
		p.emplace_back(i);
		for (int j = i * i; j < n; j += i)
			sieve[j] = 0;
	}
	vector<int> b(p.size());
	for (int i = 0, m; i < (int) p.size(); i++) {
		m = n;
		while (m > 0) {
			b[i] += m / p[i];
			m /= p[i];
		}
	}

	vector<int> c(98);
	for (int i = 0; i < (int) p.size(); i++) {
		for (int j = 2; j <= b[i]; j++) {
			c[j]++;
		}
	}

	int result = 0;
	result += c[74];
	result += c[24] * (c[2] - 1);
	result += c[14] * (c[4] - 1);
	result += c[4] * (c[4] - 1) / 2 * (c[2] - 2);
	cout << result << endl;

}


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  int n, k;
  cin >> n >> k;

  vector<int> p(n);
  for (int i=0; i<n; i++) {
    cin >> p.at(i);
  }

  sort(p.begin(), p.end());
  int ans = 0;
  for (int i=0; i<k; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      int[] seqA = new int[nHalf];
      int[] seqB = new int[nHalf];
      int[][] seq = {seqA, seqB};

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      List<Map<Integer,Integer>> aMap = new ArrayList<>();
      aMap.add(mapA);
      aMap.add(mapB);
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        seq[(i&1)][i>>1] = num;
        aMap.get(i&1).merge(num, 1, Integer::sum);
      }

      int[] vm = {0,0};
      int[] x =  {0,0};

      for (int i=0; i<aMap.size(); i++) {
        for (Map.Entry<Integer,Integer> m : aMap.get(i).entrySet()) {
          if(vm[i] < m.getValue()) {
            vm[i] = m.getValue();
            x[i]  = m.getKey();
          }
        }
      }

      int cca = nHalf - vm[0];
      int ccb = nHalf - vm[1];

      int[] vm2 = {0,0};
      int ans = 0;
  
      if(x[0] == x[1]) {
        for(int i=0; i<aMap.size(); i++) {
          for (Map.Entry<Integer,Integer> m : aMap.get(i).entrySet()) {
            if(vm2[i] < m.getValue() && m.getKey() != x[i]) {
              vm2[i] = m.getValue();
            }
          }
        }
      
        int cca2 = nHalf -vm2[0];
        int ccb2 = nHalf -vm2[1];

        ans = cca2 > ccb2 ? cca + ccb2 : cca2 + ccb;
      }
      else {
        ans = cca + ccb;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 48396
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N; string S;
  cin >> N >> S;
  if(N % 2 == 1){
    cout << "No";
    return 0;
  }
  bool a = true;
  rep(i,N/2){
    if(S[i] != S[i+N/2]){
      a = false;
    }
  }
  if(a){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3604
let solve n m d =
  let dp = Array.init (n + 1) (fun i -> i) in
  for i = 1 to m - 1 do
    for j = d.(i) to n do
      if dp.(j - d.(i)) + 1 < dp.(j) then
        dp.(j) <- dp.(j - d.(i)) + 1;
    done
  done;
  dp.(n)

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> n, m) in
  Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i))
  |> solve n m |> Printf.printf "%d\n"

Measured memory_bytes: 2812
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  cout << (N - 1) / min({A, B, C, D, E}) + 5 << endl;
}


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

int main()
{
	int  N, ans = 0;
	cin >> N;
	int P[30];
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 1; i < N-1; i++) {
		if (P[i - 1] > P[i] && P[i] > P[i + 1] || P[i - 1] < P[i] && P[i] < P[i + 1]) {
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	int X,N,i;
	cin>>X>>N;
	if (N==0){
		cout<<X<<endl;
		return 0;
	}
	vector<int> p(N);
	for (i=0;i<N;i++){
		cin>>p[i];
	}
	sort(p.begin(),p.end());
	bool bFind=false;
	for (i=0;i<N;i++){
		if (p[i]==X){
			bFind=true;
			break;
		}
	}
	if (!bFind){
		for (i=0;i<N-1;i++){
			if (p[i]<X && X<p[i+1]){
				if (X-1!=p[i]){
					cout<<X-1<<endl;
					return 0;
				}
				if (X+1!=p[i+1]){
					cout<<X+1<<endl;
					return 0;
				}
				int x1=X-p[i];
				int x2=p[i+1]-X;
				if (x1<=x2){
					break;
				}else{
					i++;
					break;
				}
			}
		}
	}
	int MinAns,MaxAns;
	int j=i;
	bFind=false;
	while (j>0){
		MinAns=p[j]-1;
		j--;
		if (j>=0 && MinAns!=p[j]){
			bFind=true;
			break;
		}
	}
	if (!bFind){
		MinAns=p[0]-1;
	}
	j=i;
	while (j<N){
		MaxAns=p[j]+1;
		j++;
		if (j<N && MaxAns!=p[j]){
			break;
		}
	}
	int x1=MaxAns-X;
	if (x1<0){
		x1=-x1;
	}
	int x2=X-MinAns;
	if (x2<0){
		x2=-x2;
	}
	if (x1<x2){
		cout<<MaxAns<<endl;
	}else{
		cout<<MinAns<<endl;
	}

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

signed main(){
	int N;cin>>N;
	int ans=N-1;
	for(int i=2;i*i<=N;i++){
		if(N%i)continue;
		chmin(ans,i-1+N/i-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// ABC171-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    ll s=0;
    vector<int> num(n);
    rep(i,n){
        int a;
        cin>>a;
        s=s^a;
        num[i]=a;
    }
    rep(i,n){
        cout<<(s^num[i])<<" ";
    }
    cout<<endl;
    //cout<<(4^2)<<endl;
    return 0;
}

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

int main() {
  int n, i;
  cin >> n;
  
  vector<double> a(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  double ans = 0;
  for(i = 0; i < n; i++){
    ans += 1/a.at(i);
  }
  
  ans = 1 / ans;
  
  cout << fixed << setprecision(20) << ans << endl;
}

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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int out=0;
  for (auto i=0; i!=s.size(); ++i){
    if (s[i] != t[i]){
      ++out;
    }
  }
  cout << out << endl;
	return 0;
}


Measured memory_bytes: 3924
from collections import deque
import sys

def bfs(M, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    M[sy][sx] = 0
    while queue:
        # queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        y, x = queue.popleft()  # queueに入っていたものを消す。
        if [y, x] == [gy, gx]:  # もしゴールについていたならば、そのときの手数を出す。
            return M[y][x]
        for dx, dy in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            for k in range(1, K + 1):
                new_x = x + dx * k
                new_y = y + dy * k

                if (0 <= new_y < H) and (0 <= new_x < W):
                    if m[new_y][new_x] == "@":
                        break
                    elif M[new_y][new_x] == -1:  # まだ来たことない点だったという条件
                        M[new_y][new_x] = M[y][x] + 1
                        queue.append([new_y, new_x])  # 新しい点を足す。
                    elif M[new_y][new_x] < M[y][x] + 1:
                        break
                else:
                    break


H, W, K = map(int, input().split())
# K = min(K, max(H, W))
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1 - 1, y1 - 1, x2 - 1, y2 - 1

m = []
for i in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))
    
M = [[-1] * W for i in range(H)]

bfs(M, x1, y1, x2, y2)

print(M[x2][y2])


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

class D
{
	class C
	{
		public int Color;
	}

	class R
	{
		public int P;
		public C C;
	}

	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Select(r => new { r, c = new C() }).ToArray();

		var map = new int[n + 1].Select(_ => new List<R>()).ToArray();
		foreach (var r in rs)
		{
			map[r.r[0]].Add(new R { P = r.r[1], C = r.c });
			map[r.r[1]].Add(new R { P = r.r[0], C = r.c });
		}

		var q = new Queue<int>();
		q.Enqueue(1);
		var u = new int[n + 1];

		while (q.Any())
		{
			var p = q.Dequeue();
			var t = 1;
			foreach (var r in map[p])
			{
				if (r.C.Color > 0) continue;
				if (u[p] == t) t++;

				q.Enqueue(r.P);
				u[r.P] = t;
				r.C.Color = t;
				t++;
			}
		}
		Console.WriteLine(rs.Max(x => x.c.Color));
		Console.WriteLine(string.Join("\n", rs.Select(x => x.c.Color)));
	}
}


Measured memory_bytes: 45324
def main():
 n,a = int(input()),list(map(int, input().split()))
 d = [0]*n
 for i,x in enumerate(a):
  if i+x<n:d[i+x] += 1
 print(sum([d[i-x]for i,x in enumerate(a)if i-x>=0]))
main()

Measured memory_bytes: 32284
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

const int MAX = 500000;

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

int main() {
    COMinit();
    int n; cin >> n;
    map<int, int>m;
    int a[n + 1];
    int l, r;
    rep(i, n + 1) {
        cin >> a[i];
        int tmp = m[a[i]];
        m[a[i]] = i + 1;
        if(tmp != 0) {
            l = tmp - 1;
            r = i;
        }
    }
    r = n - r;
    cout << n << endl;
    for(int i = 2; i <= n + 1; ++i) {
        cout << (COM(n + 1, i) - COM(r + l, i - 1) + MOD)%MOD << endl;
    }
}


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

int main()
{
  int n,k;
  int count=0;
  cin>>n>>k;
  int arr[n];
  int i;
  for(i=0;i<n;i++)
	cin>>arr[i];    
  for(i=0;i<n;i++)
  	if(arr[i]>=k)
    	count++;
  
  cout<<count;
 return 0; 
}

Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int N;
  //入力
  scanf("%d", &N );
  //計算
  int answer;
  if ( N%2 == 0) {
    answer = N;
  } else {
    answer = 2*N;
  }
  //出力
  printf("%d\n", answer );
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  SORT(a);
  int ma = k - a[n - 1] + a[0];
  rep(i, n - 1) { ma = max(abs(a[i + 1] - a[i]), ma); }
  cout << k - ma << endl;
}

Measured memory_bytes: 1024