akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


ll pow_mod(ll a, ll n, ll MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 0x01) { 
            res *= a;
            res %= MOD;
        }
        a = a * a;
        a %= MOD;
        n >>= 1LL;
    }
    return res;
}

ll combi_mod(ll n, ll k, const ll MOD) {
    if (k == 0) return 1;
    if (k == 1) return n%MOD;

    ll nume = 1, denom = 1;
    FOR(i, 1, k + 1) {
        nume *= i;
        nume %= MOD;
        denom *= i;
        denom %= MOD;
    }
    nume %= MOD;
    denom %= MOD;
    FOR(i, 1, n-k+1) {
        nume *= k + i;
        nume %= MOD;
        denom *= i;
        denom %= MOD;
    }
    nume %= MOD;
    denom %= MOD;

    ll res = nume * pow_mod(denom, MOD - 2, MOD);
    res %= MOD;
    return res;
}

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

  const ll MOD = ((ll)1e9) + 7LL;
  int GX,GY; cin>>GX>>GY;  

  // (2,1) を p 回、(1,2) を q 回選ぶと
  // (x, y) = (2p+q, p+2q) に到達する
  // (2P+Q, P+2Q) = (GX, GY) とすると
  // 3P = 2GX-GY
  // -3Q = GX-2GY

  int P = (2*GX - GY)/3;
  int Q = (2*GY - GX)/3;

  // 3(P+Q) = GX+GY
  if (P<0 || Q<0 ||
    (GX+GY)%3 != 0) { // GX+GY が 3 の倍数でないとき
    cout << 0 << endl;
    return 0;
  }

  ll ans = combi_mod(P+Q, Q, MOD);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		if(a < 1000) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
		
	}
}

Measured memory_bytes: 21844
x,n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

if n == 0 :
    print(x)
    exit()
elif not x in p :
    print(x)
    exit()
p.sort()
mini = abs(x-(p[0]-1))
maxi = abs(x-(p[-1]+1))
indenxX = p.index(x)
for i in range(1,indenxX+1) :
    if p[indenxX-i] !=  x-i :
        mini = i
        break
for i in range(1,n-indenxX) :
    if p[indenxX+i] != x+i :
        maxi = i
        break


if mini <= maxi :
    print(x-mini)
else :
    print(x+maxi)
    

Measured memory_bytes: 9160
# include <iostream>
# define MAX 100003

using namespace std;

int N, T, A;
int H[MAX];
int dif[MAX];
int ans = 0;
int minv = 10000000;

int main(){
    cin >> N >> T >> A;
    for ( int i = 1; i <= N; i ++ ){
        cin >> H[i];
    }
    
    //  dif = 1000* abs( T− H[i] × 0.006 - A)
    for ( int i = 1; i <= N; i ++ ){
        dif[i] = abs( 1000* T - H[i] * 6 - 1000*A);
    }
    
    for ( int i = 1; i <= N; i ++){
        if ( dif[i] < minv ){
            ans = i;
            minv = dif[i];
        }
    }
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 1000010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - i -1])ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

const int INF = 100000000;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n){
    cin >> a[i];
  }

  int ans = 0;

  REP(i,n){
    ans += a[i] - 1;
  }

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

Measured memory_bytes: 256
import sys
N=int(input())
D=list(map(int,input().split()))
if D[0]!=0:
  print(0)
  sys.exit()
D=sorted(D[1:])
ans=1
count1=1
count2=0
before=1
for i in D:
  if i==count1:
    count2+=1
  elif i==count1+1:
    ans = ans*(before**count2)
    count1+=1
    before=count2
    count2=1
  else:
    print(0)
    sys.exit()
  #print(ans,count1,count2,before)
print((ans*(before**count2))%998244353)

Measured memory_bytes: 14020
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int A, B, C;
    cin >> A >> B >> C;
    YESNO(A <= C && C <= B, "Yes", "No");
    return 0;
}

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

#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	constexpr ll MOD = 1e9 + 7;
	vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i - 1][j] += dp[i - 1][j - 1] ;
			dp[i - 1][j] %= MOD;
		}
		for (int j = 0; j <= k; j++) {
			ll u = (j > a[i - 1])?dp[i - 1][j - a[i - 1] - 1]:0;
			dp[i][j] += dp[i - 1][j] - u + MOD;
			dp[i][j] %= MOD;
		}
	}
	cout << dp[n][k] << endl;
}


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

total = 0
ans = []
re = 1

for i in range(N):
    total += re*A[i]
    re *= -1
ans.append(total)

for j in range(N-1):
    ans.append(2*A[j]-ans[j])

print(" ".join(map(str, ans)))

Measured memory_bytes: 24908
s = list(input())
l = len(s)
t = [0] * l 
k = 2**(l-1)
for i in range(l):
    if i == 0:
        t[l-1] = k 
    else:
        t[l-1-i] = t[l-i] * 5 + k // 2
ret = 0 
for i in range(l):
    top = int(s[i])
    ret += top * t[i]
print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}


Measured memory_bytes: 256
from fractions import gcd

def div(n,m):
    divisors = [1]
    for i in range(2, 10**7+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            while n % i == 0 and m % i == 0:
                n = n // i
                m = m // i

    return divisors,n,m

a,b = map(int,input().split())

d,n,m = div(a,b)

if gcd(n,m) > 1:
    print(len(d)+1)
else:
    print(len(d))


Measured memory_bytes: 64620
import queue
n,m=map(int,input().split())
vis,ci,cb,cc=[0]*(n+1),0,0,0
g=[[] for i in range(n+1)]
def dfs(x):
	stk,flag=queue.LifoQueue(),True
	stk.put((x,1))
	while not stk.empty():
		u,col=stk.get()
		if vis[u]:
			flag&=(vis[u]==col)
			continue
		vis[u]=col
		for i in g[u]:
			stk.put((i,3-col))
	return flag
for i in range(m):
	u,v=map(int,input().split())
	g[u]+=[v]
	g[v]+=[u]
for i in range(1,n+1):
	if vis[i]==0:
		if len(g[i])==0:
			ci+=1
		else:
			if dfs(i):
				cb+=1
			else:
				cc+=1
print(ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb)

Measured memory_bytes: 97444
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
    const int L = (1 << 20) + 1;

    char buf[L], *S , *T, c;

    char getchar() {
        if(__builtin_expect(S == T, 0)) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }

    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    unsigned inpu()
    {
        unsigned x = 0; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar());
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x;
    }

    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;

        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;

        if(x)
            *--outs = x;

        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
    if (!b) return 1;
    ll t = power(a, b/2, p);
    t = t*t%p;
    if (b&1) t = t*a%p;
    return t;
}

ll gcd(ll a, ll b)
{
    return b ? gcd(b, a%b) : a;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
    if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
    if (a < b) a = b;
}

const int maxN = 100005;
const int DEG = 4;
const int BASE = 10;
const int MAXP = 10000000;
const int MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int a[maxN];
int main()
{
    int a = inp();
    int b = inp();
    if(b%a == 0)
    {
    	cout<<a+b<<endl;
	}
	else
	{
		cout<<b-a<<endl;
	}
    //for (int i = 1; i <= n; ++ i)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
 
int main() {
	int n, m; cin >> n >> m;
	int l, r, maxl = 0, minr = 1e9;
	while (m--) {
		cin >> l >> r;
		maxl = max(maxl, l);
		minr = min(minr, r);
	}
	if (minr < maxl) cout << 0 << endl;
	else cout << minr - maxl + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		ULL N, K; cin >> N >> K;
		ULL d = 1;
		UL n = 0;
		while (N >= d) { d *= K; n++; }
		cout << n << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <vector>

#define MAX_LEN 20000
#define r(i, n) for(int i=0;i<n;i++) 

using namespace std;

// input
string str;

// result help
stack<int> st;
int mark[MAX_LEN] = {0};
int area[MAX_LEN] = {0};
vector<int> A;

int main(){

    getline(cin, str);

    r(i, str.size()){
        char c = str[i];
        if(c == '\\') st.push(i);
        if(c == '_') continue;
        if(c == '/'&& !st.empty()){
            area[i] = i - st.top();
            mark[i] = 1;
            mark[st.top()] = -1; st.pop();
        }
    }    

    int flag = 0, sum = 0, SUM = 0;
    r(i, str.size()) {
        if(mark[i] == 0 && flag == 0) continue;

        flag += mark[i];
        
        if(mark[i] == 1){
            sum += area[i];
        }

        if(flag == 0){
            A.push_back(sum);
            SUM += sum;
            sum = 0;
        }
    }

    // output
    cout << SUM << endl;
    cout << A.size();
    r(i, A.size()){
        cout << " " << A[i];
    }
    cout << endl;
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  string w[n];
  rep(i,0,n) cin>>w[i];
  set<string> a;
  a.insert(w[0]);
  bool p=true;
  rep(i,0,n-1){
    if(a.count(w[i+1])) p=false;
    a.insert(w[i+1]);
    if(w[i+1][0]!=w[i][w[i].size()-1]) p=false;
  }
  if(p) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = input[0]; 
            var l = input[1];
            var min = l + n - 1;
            var sum = 0;
            for(var i=1; i<=n; i++)
            {
                sum += l + i - 1;
                min = (Math.Abs(min) > Math.Abs(l + i - 1)? l+i-1:min);
            }
            sum -= min;
            Console.WriteLine(sum);
        }
    }
}


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

int main() {
	int n;
	cin >> n;
	double sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		sum += 1.0 / a;
	}
	cout << (1.0/sum) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n; i++){
        if(n%i != 0)continue;
        res.push_back(i);
        if(i*i != n) res.push_back(n/i);
    }
    return res;
}

int main()
{
    ll n;
    cin >> n;
    int ans = 0;
    for(ll x : enumDivisor(n)){
        if(x ==1)continue;
        ll tmp = n;
        while (tmp%x == 0) tmp /= x;
        tmp %= x;
        if(tmp == 1) ++ans;
    }
    ans += enumDivisor(n-1).size()-1;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9;
#define LINF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

void input(vector<int> x, auto n){
   rep(i,n)cin >> x[i];
}

void PFra(){

    int h, w;
    cin >> h >> w;
    if(h == 0 && w == 0)return;
    rep(i, h){
        rep(j, w){
            if(i == 0 || i == h-1 || j == 0 || j == w-1)putchar('#');
            else putchar('.');
        }
        putchar('\n');
    }
    putchar('\n');
    return PFra();
}

int main(){
    PFra();
}


Measured memory_bytes: 3052
def solution(arr):
  count = 0
  for i, j in arr:
    if i == j:
      count += 1
    else:
      count = 0
    if count == 3:
      return 'Yes'
  return 'No'
n = int(input())
arr = []
for _ in range(n):
  arr.append([ int(i) for i in input().split()])
print(solution(arr))

Measured memory_bytes: 9140
n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)

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

ok = 0
ng = 0
ng_tmp = [0] * n
flag = [True] * n

for i in range(m):
  tmp = input().split()
  p = int(tmp[0])
  s = tmp[1]
  if flag[p-1]:
    if s == 'AC':
      flag[p-1] = False
      ok += 1
      ng += ng_tmp[p-1]
    if s == 'WA':
      ng_tmp[p-1] += 1

  
print(ok, ng)

Measured memory_bytes: 4596
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int A = NextInt();
        int B = NextInt();
        Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DIGIT_MAX		105										// 最大桁数
#define D_K_MAX			5										// 最大K

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_DIGIT_MAX];								// 文字列
static int siLen;												// 文字列長
static int siK;													// K
static int si3Cnt[D_DIGIT_MAX][2][D_K_MAX];						// 個数[桁数][上限][0以外の個数]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);
	siLen = fCutCrLf(sc1Str);

	// K - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siK);

	// 個数 - セット
	si3Cnt[0][1][0] = 1;
	for (i = 1; i <= siLen; i++) {

		// 対象桁の数値
		int liNum = sc1Str[i - 1] - '0';

		// 0以外の個数でループ
		for (j = 0; j <= siK; j++) {
			if (liNum == 0) {

				// 上限 -> 上限
				si3Cnt[i][1][j] += si3Cnt[i - 1][1][j];
			}
			else {

				// 上限 -> 上限
				si3Cnt[i][1][j + 1] += si3Cnt[i - 1][1][j];

				// 上限 -> 上限未満
				si3Cnt[i][0][j] += si3Cnt[i - 1][1][j];
				si3Cnt[i][0][j + 1] += si3Cnt[i - 1][1][j] * (liNum - 1);
			}

			// 上限未満 -> 上限未満
			si3Cnt[i][0][j] += si3Cnt[i - 1][0][j];
			si3Cnt[i][0][j + 1] += si3Cnt[i - 1][0][j] * 9;
		}
	}

	return si3Cnt[siLen][1][siK] + si3Cnt[siLen][0][siK];
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si3Cnt, 0, sizeof(si3Cnt));							// 個数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll nPermute(string str) 
{ 	string s=str;
    sort(str.begin(), str.end()); 
    ll i = 1; 
    do { 
        // check for nth iteration 
        if(s==str) {
        	break;
        }
  
        i++; 
       // cout << i <<endl;
    } while (next_permutation(str.begin(), str.end())); 
    return i;
} 
string removeSpaces(string str)  
{ 
    str.erase(remove(str.begin(), str.end(), ' '), str.end()); 
    return str; 
} 
void solve() {
	int n;
	cin >> n;
	cin.ignore();
	string p="",q="";
	getline(cin,p);
	getline(cin,q);
	p=removeSpaces(p);q=removeSpaces(q);
	//cout << p << " "<<q <<endl;
	ll a = nPermute(p);
	ll b= nPermute(q);
	cout << abs(b-a)<<endl;
}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ma[200][200],ans;
 
void dfs(int x,int y,int t){
  if(t==0)return;
  if(ma[x-1][y]<t)ma[x-1][y]?:ans++,ma[x-1][y]=t,dfs(x-1,y,t-1);
  if(ma[x+1][y]<t)ma[x+1][y]?:ans++,ma[x+1][y]=t,dfs(x+1,y,t-1);
  if(ma[x][y-1]<t)ma[x][y-1]?:ans++,ma[x][y-1]=t,dfs(x,y-1,t-1);
  if(ma[x][y+1]<t)ma[x][y+1]?:ans++,ma[x][y+1]=t,dfs(x,y+1,t-1);
  if(ma[x-1][y-1]<t)ma[x-1][y-1]?:ans++,ma[x-1][y-1]=t,dfs(x-1,y-1,t-1);
  if(ma[x+1][y+1]<t)ma[x+1][y+1]?:ans++,ma[x+1][y+1]=t,dfs(x+1,y+1,t-1);
}
 
int main(){
  int n,t,x,y;
  while(cin>>t>>n,t+n){
    ans=1;
    for(int i=0;i<200;i++)for(int j=0;j<200;j++)ma[i][j]=0;
    for(int i=0;i<n+1;i++)cin>>x>>y,ma[x+100][y+100]=100;
    dfs(x+100,y+100,t);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>

using namespace std;

int A,B;

int main(){
  cin >> A >> B;
  int ans;
  if(A >= 13){
    ans = B;
  }else if(A >= 6){
    ans = B / 2;
  }else if(A <= 5){
    ans = 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l, m, n, v;
    cin >> l >> m >> n;
    int** A; int** B;
    A = new int*[l];
    for (int i = 0; i < l; i++) {
        A[i] = new int[m];
        for (int j = 0; j < m; j++) {
            cin >> v;
            A[i][j] = v;
        }
    }
    B = new int*[m];
    for (int i = 0; i < m; i++) {
        B[i] = new int[n];
        for (int j = 0; j < n; j++) {
            cin >> v;
            B[i][j] = v;
        }
    }
    for (int i = 0; i < l; i++) {
        for (int j = 0; j < n; j++) {
            int s = 0;
            for (int k = 0; k < m; k++)
                s += A[i][k] * B[k][j];
            char c = j==n-1?'\n':' ';
            cout << s << c;
        }
    }
}

Measured memory_bytes: 3272
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k, s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k >> s;
  
  REP(i, n) {
    if(i < k) {
      cout << s << " ";
    } else {
      if(s == INF) cout << 3 << " ";
      else cout << s + 1 << " ";
    }
  }

  cout << endl;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <array>
#include <iostream>

int main() {
  size_t n;
  std::array<size_t, 5> v;
  std::cin >> n >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];

  std::array<size_t, 5> mod;
  for (size_t i = 0; i < 5; ++i)
    mod[i] = (n % v[i] == 0) ? n / v[i] : (n / v[i] + 1);

  const auto it = std::max_element(mod.begin(), mod.end());
  const auto t = *it + 4;
  std::cout << t << std::endl;
}

Measured memory_bytes: 256
/// wa ^3^

#pragma GCC optimize("O3")

#include<iostream>
#include<vector>
                           
using namespace std;

const int MOD = 1e9 + 7;

int cnt[(int)2e5+10];

int main() {
    int n;
    scanf("%d", &n);
    int dp = -1;
    vector<int> a;
    for (int x; n--;) {
        scanf("%d", &x);
        if (x != dp)
            a.push_back(x);
        dp = x;            
    }
    dp = 1;
    for (int x : a) {
        cnt[x] += dp;
        if (cnt[x] >= MOD)
            cnt[x] -= MOD;
        dp = cnt[x];    
    }
    printf("%d", dp);
    return 0;
}



Measured memory_bytes: 1908
#include<iostream>
#include<algorithm>
#include<functional>
#include<stack>
#include<tuple>
#include<vector>

using namespace std;

int N;

vector<vector<char>> ans3_2, ans4_3, ans5_3, ans6_3, ans7_3;

int main() {

	cin >> N;

	vector<vector<char>> ans;
	
	ans3_2 = {
		{'a', 'a', 'b'}, 
		{'d', '.', 'b'},
		{'d', 'c', 'c'}
	};
	
	ans4_3 = {
		{ 'a', 'a', 'c', 'd' },
		{ 'b', 'b', 'c', 'd' },
		{ 'h', 'g', 'e', 'e' },
		{ 'h', 'g', 'f', 'f' }
	};
	
	ans5_3 = {
		{ 'a', 'a', '.', 'b', 'c' },
		{ '.', '.', 'd', 'b', 'c' },
		{ 'e', '.', 'd', 'f', 'f' },
		{ 'e', 'g', 'g', '.', 'h' },
		{ 'i', 'i', 'j', 'j', 'h' }
	};
	
	ans6_3 = {
		{ 'a', 'a', 'b', 'b', 'c', 'c' },
		{ 'd', 'd', 'e', 'e', 'f', 'f' },
		{ 'g', 'h', 'i', '.', '.', '.' },
		{ 'g', 'h', 'i', '.', '.', '.' },
		{ '.', '.', '.', 'j', 'k', 'l' },
		{ '.', '.', '.', 'j', 'k', 'l' },
	};
	
	ans7_3 = {
		{ 'a', 'a', 'b', 'b', 'c', 'c', '.' },
		{ 'd', 'd', '.', 'd', 'd', '.', 'a' },
		{ '.', '.', 'd', '.', '.', 'd', 'a' },
		{ '.', '.', 'd', '.', '.', 'd', 'b' },
		{ 'd', 'd', '.', 'd', 'd', '.', 'b' },
		{ '.', '.', 'd', '.', '.', 'd', 'c' },
		{ '.', '.', 'd', '.', '.', 'd', 'c' }
	};
	
	if (N == 2){
		cout << -1 << endl;
		return 0;
	}
	else if(N == 3){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++)
				cout << ans3_2[i][j];
			cout << endl;
		}
		return 0;
	}{
		ans = vector<vector<char>>(N, vector<char>(N, '.'));
		int div4;
		if(N % 4 == 0)div4 = N / 4;
		if(N % 4 == 1)div4 = N / 4 - 1;
		if(N % 4 == 2)div4 = N / 4 - 1;
		if(N % 4 == 3)div4 = N / 4 - 1;
		
		int i = 0;
		for(; i < div4 * 4 ; i += 4){
			for(int bi = i; bi < i + 4; bi++){
				for(int bj = i; bj < i + 4; bj++){
					ans[bi][bj] = ans4_3[bi - i][bj - i];
				}
			}
		}
		
		if(N % 4 == 1){
			for(int bi = i; bi < i + 5; bi++){
				for(int bj = i; bj < i + 5; bj++){
					ans[bi][bj] = ans5_3[bi - i][bj - i];
				}
			}
		}else if(N % 4 == 2){
			for(int bi = i; bi < i + 6; bi++){
				for(int bj = i; bj < i + 6; bj++){
					ans[bi][bj] = ans6_3[bi - i][bj - i];
				}
			}
		}else if(N % 4 == 3){
			for(int bi = i; bi < i + 7; bi++){
				for(int bj = i; bj < i + 7; bj++){
					ans[bi][bj] = ans7_3[bi - i][bj - i];
				}
			}
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++)
			cout << ans[i][j];
		cout << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s[n];
    
    for(int i = 0; i < n; i++) cin >> s[i];
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 9; j++) {
            for(int k = j + 1; k < 10; k++) {
                if(s[i][j] > s[i][k]) {
                    char temp = s[i][j];
                    s[i][j] = s[i][k];
                    s[i][k] = temp;
                }
            }
        }
    }


    sort(s, s + n);

    /*
    for(int i = 0; i < n; i++) {
        cout << s[i] << endl;
    }
    */

    long long ans = 0;
    long long cnt = 1;
    for(int i = 0; i < n - 1; i++) {
        if(s[i] == s[i + 1]) {
            cnt++;
        } else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }

    ans += cnt * (cnt - 1) / 2;

    cout << setprecision(20) << ans << endl;

    return 0;
}

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

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

	int	n;
	cin >> n;
	if (n == 2)
	{
		cout << 2 << endl;
		return (0);
	}
	for (int i = n;; i++)
	{
		int		sq;
		bool	flag;

		if (i % 2 == 0)
			continue;
		flag = false;
		sq = sqrt(i);
		for (int j = 3; j <= sq; j += 2)
		{
			if (i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag)
			continue;
		cout << i << endl;
		return (0);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=105;
int tim=0,m=0;
vector<int> be[MAXN],E[MAXN];
void build(int l,int r)
{
	while(l<=r)
	{
		be[tim].pb(l);
		be[tim].pb(r);
		tim++;
		l++;r--;
	}
}
void addedge(int u,int v)
{
	for(int i:be[u])
		for(int j:be[v])
		{
			E[i].pb(j);
			m++;
		}
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	scanf("%d",&n);
	int tot=(n+1)/2;
	if(n&1)
	{
		build(1,n-1);
		be[tim].pb(n);
	}
	else
	{
		build(1,n);
	}
	if(tot==2) addedge(0,1);
	else
	{
		for(int i=0;i<tot;i++)
			addedge(i,(i+1)%tot);
	}
	printf("%d\n",m);
	for(int i=1;i<=n;i++)
		for(int v:E[i])
			printf("%d %d\n",i,v);
	return 0;
}


Measured memory_bytes: 256
# xの式： x = N * 800
# yの式： y = N // 15 * 200 '//で整数切り捨ての割り算

N = int(input())    # 食べた食事数Nを代入

x = N * 800 # 食事代xを計算

y = N // 15 * 200   # 15食毎の返金額yを計算

answer = x - y  # x - yの値

print(answer)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;

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

const int inf = 1 << 28;

struct Edge{
    int to, cost, weight;
    Edge(){}
    Edge(int to_, int cost_, int weight_):to(to_), cost(cost_), weight(weight_){}
};

int N, M, L;
vector<vector<Edge> > G;
vector<vector<int> > mem;

int solve(int s){
    mem.assign(N+1, vector<int>(L+1, -inf));
    mem[s][L] = 0;
    typedef tuple<int, int, int> State;
    priority_queue<State> q;
    for(q.emplace(0, L, s); !q.empty();){
        int w, c, v; tie(w, c, v) = q.top(); q.pop();
        if(v == N)return -w;
        for(auto e: G[v]){
            if(e.cost <= c && mem[e.to][c-e.cost] < w){
                mem[e.to][c-e.cost] = w;
                q.emplace(w, c - e.cost, e.to);
            }
            if(mem[e.to][c] < w - e.weight){
                mem[e.to][c] = w - e.weight;
                q.emplace(w - e.weight, c, e.to);
            }
        }
    }
    return inf;
}

int main(){
    while(cin >> N >> M >> L, N|M|L){
        G.assign(N+1, vector<Edge>(0));
        rep(i, M){
            int A, B, D, E;
            cin >> A >> B >> D >> E;
            G[A].emplace_back(B, D, E);
            G[B].emplace_back(A, D, E);
        }
        cout << solve(1) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1484
#include<bits/stdc++.h>
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 Would
#define you
#define please


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


	int N, Q;
	string S;
	cin >> N >> S >> Q;

	int C[2000001] = {};
	rep(i, N) {
		C[i + 1] = C[i];
		if (S[i] == 'C') C[i + 1]++;
	}
	rep(i, N) {
		C[i + N + 1] = C[i + N];
	}

	rep(i, Q) {
		int K;
		cin >> K;
		ll kotae = 0;

		int M = 0;
		ll kari = 0;
		rep(j, K) {
			if (S[j] == 'M') {
				kari += C[K] - C[j + 1];
				M++;
			}
		}


		rep(j, N) {
			if (S[j] == 'D') kotae += kari;

			if (j + K < N) {
				if (S[j + K] == 'C') kari += M;
				if (S[j + K] == 'M') M++;
			}

			if (S[j] == 'M') {
				kari -= C[j + K + 1] - C[j + 1];
				M--;
			}

		}

		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 9116
#include<stdio.h>

void swap(int *x, int *y){
  int temp=*x;
  *x = *y;
  *y = temp;
}
    
int main(){
  
  int N,i,j,count=0,minj;
  scanf("%d",&N);
  
  int A[N];
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0; i<=N-1; i++){
    minj = i;
    for(j=i; j<=N-1; j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(A[i]!=A[minj]){
      swap(&A[i],&A[minj]);
      count++;
    }
  }
  
  
  
  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[N-1],count);
  return 0;
}




Measured memory_bytes: 2088
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

double calc(VD p, VD q, double x){
    double ret = 0.0;
    REP(i,p.size()) ret += fmax(x * p[i], (1.0 - x) * q[i]);
    return ret;
}

int main() {
    int n = 6;
    VD p(n), q(n);
    REP(i,n) p[i] = in() / 100.0;
    REP(i,n) q[i] = in() / 100.0;
    double le = 0.0, ri = 1.0;
    REP(i,100){
        double p1 = (2 * le + ri) / 3, p2 = (le + 2 * ri) / 3;
        if (calc(p, q, p1) < calc(p, q, p2)) ri = p2;
        else le = p1;
    }
    double ans = calc(p, q, le);
    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 256
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, ans = 1 << 30;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		int cnt = 0;
		while ((a % 2) == 0) {
			++cnt;
			a /= 2;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
vi a;
int main() {
    cin>>n;
    a.resize(n);
    REP(i,n)
        cin>>a[i];

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

    cout << abs(a[0]-a[n-1]) << endl;
    return 0;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

vector<long long> sieve(long long N) {
    vector<long long> res;
    vector<long long> is_prime(N+1, true);
    is_prime[0] = is_prime[1] = false;
    for (long long i = 2; i <= N; i++) {
        if (is_prime[i]) {
            res.push_back(i);
            for (long long j = 2 * i; j <= N; j+=i) {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

//--------------------------- Solve ---------------------------//

void solve() {
    vector<long long> primes = sieve(100000);
    vector<int> cumsum(100001);
    for (int i = 1; i < 100001; i++) {
        cumsum[i] = cumsum[i-1];
        if (i % 2 == 0) continue;
        if (binary_search(primes.begin(), primes.end(), i) && 
            binary_search(primes.begin(), primes.end(), (i+1)/2)) cumsum[i]++;
    }

    int Q; cin >> Q;
    while (Q--) {
        int l, r; cin >> l >> r;
        cout << cumsum[r] - cumsum[l-1] << '\n';
    }
    
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4232
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int a,b,c,d,e,i;
    scanf("%d%d",&a,&b);
    if(b<10)
        c=a*10+b;
    else if(b<100)
        c=a*100+b;
    else
        c=a*1000+b;
    for(i=1;i<1000;i++)
    {
        if(i*i==c)
            {
                d=0;
                break;
            }
            else
                d=1;

    }
    if(d==0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vi p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }
    int ans = 0;
    rep(i, n) {
        if (i == p[i]) ans++;
        else if (uf.same(i, p[i])) ans++;
    }
    cout << ans << endl;
}

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

struct Edge {
    int from, to, cost;
    Edge () {}
    Edge (int from, int to, int cost ) : from(from), to(to), cost(cost) {}
};

vector < int > BellmanFord(int V, vector < Edge > &edges, int s, int t)
{
    constexpr int INF = (1 << 30) - 1;
    vector < int > d(V, INF);
    d[s] = 0;
    for ( int i = 0; i < 2 * V; i++ ) {
        for ( auto &e : edges ) {
            if ( d[e.from] != INF && d[e.to] > d[e.from] + e.cost ) {
                d[e.to] = d[e.from] + e.cost;
                if ( i >= V - 1 ) {
                    if ( i == V ) d[e.to] = -INF;
                    if ( e.to == t ) return ( vector < int > () );
                }
            }
        }
    }
    return ( d );
}

int main()
{
    int N, M, P;
    vector < Edge > edges;
    vector < int > ans;
    
    cin >> N >> M >> P;
    for ( int i = 0; i < M; i++ ) {
        int from, to, cost;
        cin >> from >> to >> cost;
        edges.emplace_back(from - 1, to - 1, -cost + P);
    }
    
    ans = BellmanFord(N, edges, 0, N - 1);

    if ( ans.size() == 0 ) {
        cout << -1 << endl;
    } else {
        cout << max(0, -ans[N - 1]) << endl;
    }

    return ( 0 );
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, ans = 0;
    cin >> n;
    priority_queue<ll> q;
    queue<ll> q2;
    rep(i, n)
    {
        ll x;
        cin >> x;
        q.push(x);
    }

    while (q.top() > n - 1)
    {
        ll now = q.top(), p;
        q.pop();

        if (now >= 2 * n - 1)
        {
            ans += (now - n + 1) / n;
            p = (now - n + 1) / n;
            q2.push(now - p * n);
        }
        else
        {
            ans++;
            p = 1;
            q2.push(now - n);
        }

        while (!q.empty())
        {
            ll next = q.top() + p;
            q.pop();
            q2.push(next);
        }

        while (!q2.empty())
        {
            q.push(q2.front());
            q2.pop();
        }
    }

    cout << ans << endl;
}

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

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

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

    int ans = 0;
    set<int> b;
    for(int i=0; i<N; i++){
        b.insert(a[i]);
        if(*b.begin() == a[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    string op;
    cin >> a >> op >> b;
    // 出力

    int s;
    if(op=="+"){
	s = a+b;
    }
    else{
        s = a-b;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  //9:33:16

char S[101010];
  cin >> S;
  bool t[26];
  for(int i = 0; i < 26; i++){
    t[i] = false;
  }
  for(int i = 0; S[i] != '\0'; i++){
    t[S[i] - 'a'] = true;
  }
  for(int i = 0; i < 26; i++){
    if(!t[i]){
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;


  return 0;
}


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

int threeGCD (int a, int b, int c) {
  return __gcd(__gcd(a,b),__gcd(b,c));
}

int main() {
  int K; cin >> K;
  int ans =0;
  for (int i =1; i<=K; i++) {
    for (int j =1; j<=K; j++) {
      for (int k =1; k<=K; k++) {
        ans += threeGCD(i,j,k);
      }
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		int hit = 0, blow = 0;
		for(int i = 0 ; i < 4; i++){
			cin >> b[i];	
			if(a[i] == b[i]){
				hit++;
				a[i] = -1;
			}
			else{
				for(int j = 0;j < 4; j++){
					if(i != j && b[i] == a[j]) blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
    int n, m, l, i, j, k, a[128][128], b[128][128] = {0};
    long c[128][128] = {0};

    scanf("%d %d %d\n", &n, &m, &l);
    
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for(j = 0; j < m; j++)
    {
        for(k = 0; k < l; k++)
        {
            scanf("%d", &b[j][k]);
        }
    }
    
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            for(k = 0; k < l; k++)
            {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < l; j++)
        {
            printf("%ld", c[i][j]);
            if(j < l - 1)
            {
                printf(" ");
            }
            else
            {
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 856