akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(N)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, left, right):
        """
        [left, right)のsegfuncしたものを得る
        left: index(0-index)
        right: index(0-index)
        """
        res = self.ide_ele
        left += self.num
        right += self.num
        while left < right:
            if left & 1:
                res = self.segfunc(res, self.tree[left])
                left += 1
            if right & 1:
                res = self.segfunc(res, self.tree[right - 1])
            left >>= 1
            right >>= 1
        return res


def resolve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))

    seg_min = SegTree(P, lambda x, y: min(x, y), f_inf)
    seg_max = SegTree(P, lambda x, y: max(x, y), -f_inf)
    mi = seg_min.query(0, k)
    ma = seg_max.query(0, k)
    res = {(0, k - 1)}
    for i in range(1, n - k + 1):
        prev = P[i - 1]
        new = P[i + k - 1]
        if prev != mi or new < ma:
            res.add((i, i + k - 1))
        mi = seg_min.query(i, i + k)
        ma = seg_max.query(i, i + k)

    ascending = []
    head = 0
    foot = 1
    cnt = 1
    for i in range(1, n):
        if P[i - 1] < P[i]:
            cnt += 1
            foot = i
        else:
            cnt = 1
            head = i
        if cnt == k:
            ascending.append((head, foot))
            head = i
            cnt -= 1

    ans = len(res)
    flg = False
    for section in ascending:
        if section in res:
            if not flg:
                flg = True
            else:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    resolve()


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

int main() {
    double n;
    cin >> n;
    double odd = ceil(n / 2.0);
    printf("%.10lf\n",  odd/n);
    return 0;
}

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

using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    vector<unsigned long long> scale(N);
    for( int i = 0;i < N;++i )
        cin >> scale[i];
    std::sort(scale.begin(),scale.end());

    int divide = 0;
    unsigned long long current = scale[0];
    for( int i = 1;i < N;++i )
    {
        if( scale[i] > current * 2 )
            divide = i;
        current += scale[i];
    }
    cout << (N - divide) << endl;
    return 0;
}

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

#define ll long long
#define uint unsigned int
#define vi vector<int>
#define pii pair<int,int>

#define for0(i,n) for(int i=0; i<(n); i++)
#define for1(i,n) for(int i=1; i<=(n); i++)
#define from(i,a,b) for(int i=(a); i<=(b); i++)
#define forr(i,a,b) for(int i=(a); i>=(b); i--)

#define PB push_back
#define MP make_pair
#define FI first
#define SE second

#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()

#define safe_map unordered_map<long long, int, custom_hash>

#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main

void amax(int& x, int y){if(x<y)x=y;}
void amin(int& x, int y){if(x>y)x=y;}
int gcd(int a, int b){if(b){return gcd(b,a%b);}return a;}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {  // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};






int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n; cin>>n;
    n=((n-1)%1000)+1;
    cout << 1000-n<<'\n';
}



Measured memory_bytes: 3596
h = []
10.times do |i|
  h[i] = gets.chomp.to_i
end
  max1 = 0
  max2 = 0
  max3 = 0
10.times do |i|
  if max1 <= h[i]
     max3 = max2
     max2 = max1
     max1 = h[i]
  elsif max2 <= h[i]
     max3 = max2
     max2 = h[i]
  elsif max3 <= h[i]
     max3 = h[i]
   end
  end
 puts max1
 puts max2
 puts max3

Measured memory_bytes: 8596
def head(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

N = int(input())
Info = [[int(i) for i in input().split()] for j in range(N-1)]

for i in range(N):
    if i == N-1:
        print(0)
    else:
        now = 0
        for j in range(i, N-1):
            start = (Info[j][1] if now <= Info[j][1] else Info[j][1] + head(now-Info[j][1], Info[j][2]) * Info[j][2])
            now = start + Info[j][0]
        print(now)

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.begin(),l.end());
	reverse(l.begin(),l.end());
	int ans = 0;
	rep(i,k){
		ans += l[i];
	}
	cout << ans << endl;
    return 0;
}



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


int main(){
  
  bool torf=true;
 int N,M,count=0;
  cin >> N >> M;
  
  vector<int> H(N);
  rep(i,N){
    cin >> H.at(i);
  }
  
  vector<int> A(M);
  vector<int> B(M);
  vector<vector<int>> C(N,vector<int>());
  
  
  rep(i,M){
    cin >> A.at(i) >> B.at(i);
    C.at(A.at(i)-1).push_back(B.at(i));
    C.at(B.at(i)-1).push_back(A.at(i));
  }
  
  rep(i,N){
    rep(j,C.at(i).size()){
      if(H.at(i)<=H.at(C.at(i).at(j)-1))
        torf=false;
      
    }
    
    if(torf==true){
      count++;
      //cout << i << endl;
    }
    
    torf=true;
      
    
  }
  
  
  
  cout << count << endl;
  
  
}

Measured memory_bytes: 9596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int BIAS = 2501;
const int W = 5100;
const int N = 51;
ll dp[N][W];

int main(void){
  int n, a;cin >> n >> a;
  VI x(n); REP(i, 0, n) { cin >> x[i]; x[i] -= a; }
  REP(i, 0, n) {
    REP(j, 0, W) {
dp[i + 1][j] += dp[i][j];
       int nj = j + x[i];
if (nj < 0 || nj >= W) { continue; }
dp[i + 1][nj] += dp[i][j];
     }
dp[i + 1][BIAS + x[i]] += 1;
  }
  cout << dp[n][BIAS] << endl;
}


Measured memory_bytes: 2304
#n=int(input())
h,w=map(int,input().split())
#l=list(map(int,input().split()))
l=[list(input()) for i in range(h)]

# まずは行について確認する
row_compare=['.' for i in range(w)]
save_rows=[]
for row in range(h):
    if not l[row]==row_compare:
        save_rows.append(row)

newl=[l[row] for row in save_rows]

h=len(newl)
#次は列
save_col=[]
col_compare=["." for i in range(h)]
for col in range(w):
    temp=[]
    for row in range(h):
        temp.append(newl[row][col])
    if not temp==col_compare:
        save_col.append(col)

ansl=[]
for row in range(h):
    temp=[]
    for col in range(w):
        if col in save_col:
            temp.append(newl[row][col])
    ansl.append(temp)

for row in ansl:
    print(*row,sep="")

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, k; cin >> a >> b >> k;
    if(a == b){
        cout << a << endl;
        return 0;
    }
    if(k > b or b - a < k){
        for(int i = a; i <= b; i++) cout << i << endl;
        return 0;
    }
    vector<int> ans(0);
    for(int i = a; i < k + a; i++) ans.push_back(i);
    int num = b - k + 1;
    if(num <= ans.back()) num = ans.back() + 1;
    for(int i = num; i <= b; i++) ans.push_back(i);
    REP(i, ans.size()) cout << ans[i] << endl;
}

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

int main() {
	int x;
	cin >> x;
	if (x >= 400 && x < 600) cout << 8 << endl;
	if (x >= 600 && x < 800) cout << 7 << endl;
	if (x >= 800 && x < 1000) cout << 6 << endl;
	if (x >= 1000 && x < 1200) cout << 5 << endl;
	if (x >= 1200 && x < 1400) cout << 4 << endl;
	if (x >= 1400 && x < 1600) cout << 3 << endl;
	if (x >= 1600 && x < 1800) cout << 2 << endl;
	if (x >= 1800 && x < 2000) cout << 1 << endl;
	return 0;
}

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

int main(){
  int a, b, c, d ;
  cin >> a >> b >> c >> d;
  if(a + b > c + d){
    cout << "Left" << endl; 
  }else if(a + b == c + d){
    cout << "Balanced" << endl; 
  }else{
    cout << "Right" << endl; 
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }
 
int solve() {fastio
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    ll a1,a2;
    a1 = a*b;
    a2 = c*d;
    if(a1 >= a2)
    cout<<a1;
    else cout<<a2;

    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

const int N = 22;
bool a[N][N];
mi dp[N][1 << N];
bool vis[N][1 << N];
int n;

mi solve(int i, bitset<32> bm) {
  if (i == n) return 1;
  int bv = (int)bm.to_ulong();
  if (!vis[i][bv]) {
    for (int j = 0; j < n; ++j) {
      if (a[i][j] && bm[j] == 0) {
        auto cp = bm;
        cp[j] = 1;
        dp[i][bv] += solve(i+1, cp);
      }
    }
    vis[i][bv] = 1;
  }
  return dp[i][bv];
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  cout << solve(0, 0).toInt() << nl;

  return 0;
}



Measured memory_bytes: 428416
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a, b;
    char op;
    
    //処理
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        switch (op) {
            case '+':
                printf("%d\n", a+b);
                break;
            case '-':
                printf("%d\n", a-b);
                break;
            case '*':
                printf("%d\n", a*b);
                break;
            case '/':
                printf("%d\n", a/b);
                break;
            case '?':
                return 0;
            default:
                break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//const llint mod=987654323;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint mod;
llint pow(llint a,llint n){//a^n
	llint ans=1;
	for(int h=0;h<30;h++){
		if((1<<h)&n){ans*=a;ans%=mod;}
		a*=a;a%=mod;
	}
	return ans;
}
vector<llint>fla;
vector<llint>gya;
vector<llint>niwa;
vector<llint>niruru;
llint nCr(int n,int r){return ((fla[n]*gya[r])%mod *gya[n-r])%mod;}
int main(void){
	//包除?
	llint n,i,j;cin>>n>>mod;
	fla.res(n+1);gya.res(n+1);niwa.res(n+1);niruru.res(n+1);
	niwa[0]=1;
	for(i=1;i<=n;i++){niwa[i]=niwa[i-1]*2%mod;}
	niruru[0]=2;
	for(i=1;i<=n;i++){niruru[i]=niruru[i-1]*niruru[i-1]%mod;}
	fla[0]=1;
	for(i=1;i<=n;i++){fla[i]=(fla[i-1]*i)%mod;}
	gya[n]=pow(fla[n],mod-2);
	for(i=n;i>=1;i--){gya[i-1]=(gya[i]*i)%mod;}
	vector<vector<llint>>ipai(n+2,vector<llint>(n+2));
	//ピッタリ1杯が0~n個、m分割
	//これはなぜかdpでできる 修行のおかげのエスパー
	ipai[0][0]=1;
	ipai[1][1]=1;
	for(i=1;i<=n;i++){
		for(j=1;j<=i;j++){
			ipai[i][j]%=mod;
			ipai[i+1][j]+=ipai[i][j]*j;
			ipai[i+1][j+1]+=ipai[i][j];
		}
	}
	//0か1杯 が n1,m+1
	//例 0か1がa種類,b杯->dp[a+1][b+1]
	
	llint ans=0;
	for(i=0;i<=n;i++){//条件を満たさない具材の数
		for(j=0;j<=i;j++){//条件を満たさない を含むラーメンの数
			llint gen=nCr(n,i)*ipai[i+1][j+1];gen%=mod;
			gen*=pow(niwa[n-i],j);gen%=mod;
			gen*=niruru[n-i];gen%=mod;
			//cerr<<"i="<<i<<"j="<<j<<"dp="<<ipai[i+1][j+1]<<endl;
			if(i%2){ans-=gen;ans%=mod;}
			else{ans+=gen;ans%=mod;}
		}
	}
	ans+=mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 72832
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <limits.h>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
const int maxn = 5e3 + 7;
const int mod = 1e9 + 7;
ll arr[maxn];
ll dp[maxn];
int main(void)
{
	int n ;
	cin >> n;
	for(int i = 0; i <= n - 3; i ++ ) arr[i] = i + 3;
	dp[0] = 1;
	for(int i = 0; i <= n; i ++ )
	{
		for(int j = 0; j <= n - 3; j ++ )
			if(i - arr[j] >= 0) dp[i] = (dp[i]%mod + dp[i - arr[j]] % mod) %mod;
	}
	cout << dp[n];
    return 0;
}

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



int main() {
int dish[5];
for(int i = 0; i < 5; i++){
    cin >> dish[i];
}
int time = 0;
int mi = 9;
int last = 0;
for(int i = 0; i < 5; i++){
  int hika = dish[i] % 10;
  if(hika < mi && hika != 0){
last = i;
mi = hika;
  }
}

for(int i = 0; i < 5; i++){
if(dish[i] % 10 == 0 || i == last)time += dish[i];
else time += ((dish[i]/10)+1)*10;

}
cout << time << endl;

}


Measured memory_bytes: 256
S = input()

flag=1
if S[0]!='A':
  flag=0
  
cnt=0
N=len(S)
for i in range(2,N-1):
  if S[i]=='C':
    cnt +=1
if cnt!=1:
  flag=0

S=S.replace('A','a')
S=S.replace('C','c')  

if not S.islower():
  flag=0
     
print('AC' if flag==1 else 'WA')


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

int main(){
    int n; //ボールの個数
    cin >> n;
    vector<long long> num(n+1); //要素数が何番目のボールか、要素がボールの番号
    vector<long long> count(n+1); //要素数がボールの番号、要素が何個あるか

    //入力
    for(int i=1; i<=n; i++){
        int k; //入力値
        cin >> k;

        num[i] = k;
        count[k] += 1;
    }

    /* ２個取る組み合わせをそれぞれ計算 */
    vector<long long> c_2(n+1);
    for(int i=1; i<=n; i++) c_2[i] = ((count[i]-1)*count[i])/2;

    /* ２個取る組み合わせ（自身の番号を引く）をそれぞれ計算 */
    vector<long long> c_2_sub1(n+1);
    for(int i=1; i<=n; i++){
        if(count[i] > 0) c_2_sub1[i] = ((count[i]-1)*(count[i]-2))/2;
        else c_2_sub1[i] = 0;
    }

    /* それぞれ求める */
    long long int sum = 0;
    for(int i=1; i<=n; i++) sum += c_2[i];

    for(int i=1; i<=n; i++){

        long long int ans = sum - c_2[num[i]] + c_2_sub1[num[i]];

        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b; cin >> a >> b;
  if(a >=13) cout << b << endl;
  else if(a >=6 and a <=12) cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}


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

int main() {
	int x,a,b;cin>>x>>a>>b;
	int da=abs(x-a);
	int db=abs(x-b);
	if(da>db){
		cout<<'B'<<endl;
	}else{
		cout<<'A'<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

    int n=s.size();
    int cnt=0;
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[n-i-1]) cnt++;
    }
    cout<<cnt<<endl;
}



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

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

	int ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int tmp = i;
		while (tmp <= x) {
			tmp *= i;
		}
		tmp /= i;
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main(){
  int a,h,b;
  cin >> a >> b >> h;
  cout << (a+b)*h / 2 << endl;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int max_ = max({a, b, c});
    rep(i, k){
        max_ *= 2;
    }
    cout << max_+a+b+c-max({a, b, c}) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNIGNS 
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>

using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}



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

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if ((a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0)){
		cout << 0 << endl;
		return 0;
}
	cout << min(min(a*b, b*c), c*a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
long A,B,X;
main()
{
	cin>>N>>A>>B;
	for(int i=2;i<N;i++)
	{
		long x;cin>>x;X^=x;
	}
	long S=A+B;
	if(S<X||(S-X)%2==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	long D=(S-X)/2;
	if(D>A||D&X)
	{
		cout<<-1<<endl;
		return 0;
	}
	long a=D;
	for(int i=40;i--;)
	{
		if(X>>i&1&&(a|1L<<i)<=A)a|=1L<<i;
	}
	cout<<(a?A-a:-1)<<endl;
}


Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	for i := range h {
		fmt.Scan(&h[i])
	}
	// fmt.Println("N", N, "h", h)
	ans := 0
	for {
		cnt := 0
		on := false
		for i := 0; i < N; i++ {
			if !on {
				if h[i] > 0 {
					h[i]--
					on = true
					cnt++
				}
			} else {
				if h[i] == 0 {
					on = false
				} else {
					h[i]--
				}
			}
		}
		if cnt == 0 {
			break
		}
		ans += cnt
		// fmt.Println("h", h, "cnt", cnt, "tot", ans)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define prin(ans) cout << ans << endl
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 105
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

ll N, M;
ll fact[100101];
ll rfact[100101];
ll ans=1;
Map mp;

ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

void prime_factor(ll n) {
    
}


int main(void) {
    cin >> N >> M;
    ll i;
    
    fact[0]=rfact[0]=1;
    for(i=1; i<=100100; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    for (ll i=2; i*i<=M; i++) {
        while (M%i==0) {
            mp[i]++;
            M/=i;
        }
    }
    if (M!=1) mp[M]++;
    
    
    
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ans*=fact[N+it->second-1]%MOD*rfact[N-1]%MOD*rfact[it->second]%MOD;
        ans%=MOD;
    }
    
    prin(ans);
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Node{
	int id;
	Node left,right;
	
	public void display(){
		System.out.print(" "+id);
	}
}

class Tree{
	private Node root;
	public boolean find(int key){
		Node current = root;
		while(current!=null){
			if(current.id>key)
				current = current.left;
			else if(current.id<key)
				current = current.right;
			else if(current.id==key){
				System.out.println("yes");
				return true;
			}
		}
		System.out.println("no");
		return false;
	}
	public void insert(int id){
		Node newNode = new Node();
		newNode.id = id;
		if(root==null) 
			root = newNode;
		else{
			Node current = root;
			Node parent;
			while(true){
				parent = current;
				if(current.id>id){
					current = current.left;
					if(current == null){
						parent.left = newNode;
						return;
					}
				}else{
					current = current.right;
					if(current==null){
						parent.right = newNode;
					 	return;
					}
				}
			}
		}
	}
	
	public void inOrder(Node localRoot){
		if(localRoot!=null){
			inOrder(localRoot.left);
			localRoot.display();
			inOrder(localRoot.right);
		}
	}
	public void preOrder(Node localRoot){
		if(localRoot!=null){
			localRoot.display();
			preOrder(localRoot.left);
			preOrder(localRoot.right);
		}
	}
	public void print(){
		inOrder(root);
		System.out.println("");
		preOrder(root);
	}
}

public class Main {
	public static void main(String[] args) throws IOException{
		Tree tree = new Tree();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String in;
		String[] input;
		for(int i=0;i<n;i++){
			in = br.readLine();
			if(in.charAt(0)=='i'){
				input = in.split(" ");
				tree.insert(Integer.parseInt(input[1]));
			}
			else if(in.charAt(0)=='p'){
				tree.print();
				System.out.println("");
			}else if(in.charAt(0)=='f'){
				input = in.split(" ");
				tree.find(Integer.parseInt(input[1]));
			}
		}
	}
}

Measured memory_bytes: 126796
N, K = map(int, input().split())
S = input()

happiness = 0
if N >= 2:
    if S[0] == 'R' and S[1] == 'R':
        happiness += 1
    for i in range(1, N-1):
        if S[i] == 'R':
            if S[i+1] == 'R':
                happiness += 1
        else:
            if S[i-1] == 'L':
                happiness += 1
    if S[N-1] == 'L' and S[N-2] == 'L':
        happiness += 1

aihan = []
ai = 1
han = -1
happi = 0
for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        aihan.append(ai)
    elif S[i] == 'L' and S[i+1] == 'R':
        aihan.append(han)
    else:
        aihan.append(happi)

aihan_count = 0

for i, e in enumerate(aihan):
    if K <= 0:
        break
    if e * aihan_count < 0:
        happiness += 2
        K -= 1
    aihan_count += e

if K > 0:
    if aihan_count != 0:
        happiness += 1
        K -= 1

print(happiness)


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

const int MAXN = 100005;

set <pair <int, int> > ms;
int a[MAXN];
vector <int> g[MAXN];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n-1; i++)
    {
        int u, v;
        cin >> u >> v;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    for (int i = 1; i <=n; i++) a[i] = -1;
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int u, w;
        cin >> u >> w;
        a[u] = w;
        ms.insert({w, u});
    }

    while(!ms.empty())
    {
        int v = ms.begin()->second;
     //   cout << v << " " << a[v] << endl;
        ms.erase(ms.begin());
        for (int i = 0; i < g[v].size(); i++)
        {
            int to = g[v][i];
            if (a[to] == -1)
            {
                a[to] = a[v] + 1;
                ms.insert({a[to], to});
            }
            else if (max(a[to] - a[v], a[v] - a[to]) != 1)
            {
                cout << "No";
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class lpsg_tree {
private:
    vector<T> lazy;
    vector<T> seg;
    T def;
    lli num;
    void push(lli k){
        if(lazy[k] == def) return;
        set(k*2+1,lazy[k]/2);
        set(k*2+2,lazy[k]/2);
        lazy[k] = def;
    }
    void set(lli k,T x){
        lazy[k] += x;seg[k] += x;
    }
    void update(lli a,lli b,T x,lli k,lli l,lli r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) set(k,x*(r-l));
        else {
            push(k);
            update(a,b,x,k*2+1,l,(r+l)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
            seg[k] = func(seg[k*2+1],seg[k*2+2]);
        }
    }
    T func(T a,T b){
        return a + b;
    }
    T query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return seg[k];
        push(k);
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return func(vl,vr);
    }
public:
    lpsg_tree(){}
    lpsg_tree(lli n,lli d = 0):lazy(n*4,d),seg(n*4,d){
        def = d;
        num = 1;
        while(n > num) num <<= 1;
    }
    void update(lli a,lli b,lli x){
        update(a,b,x,0,0,num);
    }
    T query(lli a,lli b){
        return query(a,b,0,0,num);
    }

};


lpsg_tree<lli> sg;
lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    sg = lpsg_tree<lli> (n);
    for(lli i = 0;i < q;i++){
        cin >> c;
        if(c){
            cin >> s >> t;
            cout << sg.query(s-1,t) << endl;
        }else{
            cin >> s >> t >> x;
            sg.update(s-1,t,x);
        }
    }
    return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define vpll        vector<pair<ll,ll>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    int x,y;cin>>x>>y;
    int id[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    if(id[x]==id[y])cout<<"Yes";
    else cout<<"No";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
const int N = 1e5 + 5;
typedef long long ll; 
using namespace std;

int cnt, n;
char s[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	scanf("%s", s + 1), n = strlen(s + 1);
	for(int i = 2; i <= n; i++) if(s[i] != s[i - 1]) cnt++;
	cout<<cnt<<endl; 
	return 0; 
}


Measured memory_bytes: 3352
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse::<i64>().unwrap());
    let n = itr.next().unwrap();
    let m = itr.next().unwrap();
    let mut x = vec![];
    let mut y = vec![];

    for _ in 0..n {
        let mut is = String::new();
        stdin().read_line(&mut is).ok();
        let mut itr = is.split_whitespace().map(|e| e.parse::<i64>().unwrap());
        let a = itr.next().unwrap();
        let b = itr.next().unwrap();
        x.push((a, b));
    }

    for _ in 0..m {
        let mut is = String::new();
        stdin().read_line(&mut is).ok();
        let mut itr = is.split_whitespace().map(|e| e.parse::<i64>().unwrap());
        let a = itr.next().unwrap();
        let b = itr.next().unwrap();
        y.push((a, b));
    }

    for (a, b) in x {
        let mut h = 1 << 30;
        let mut ans = 0;
        for (i, &(c, d)) in y.iter().enumerate() {
            let t = (a - c).abs() + (b - d).abs();
            if t < h {
                h = t;
                ans = i;
            }
        }

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


Measured memory_bytes: 2056
H, W = map(int, input().split())

ans = 10**10

for _ in range(2):
    for h in range(1, H):
        a = h * W
        b = (H-h)//2 * W
        c = (H - h - (H-h)//2) * W
        d = max(a,b,c) - min(a,b,c)
        ans = min(ans, d)
        b = (H-h) * (W//2)
        c = (H-h) * (W-W//2)
        d = max(a,b,c) - min(a,b,c)
        ans = min(ans, d)
    H, W = W, H

print(ans)

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

cnt=0
for i in range(n):
  if a[i]<0:
    cnt+=1
  a[i]=abs(a[i])

a.sort()
sum=0

if cnt%2==0:
  for j in range(n):
    sum+=a[j]
else:
  for j in range(n-1):
    sum+=a[j+1]
  sum-=a[0]

print(sum)

Measured memory_bytes: 14252
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scanf("%d",&n)
  
  hp := 0
  num := make([]int,n)
  for i:=0; i < n; i++ {
    fmt.Scanf("%d",&num[i])
  }
  for i:=0; i < n-1; i++ {
    for j:=i+1; j<n; j++ {
      hp += num[i] * num[j]
    }
  }
  fmt.Printf("%d",hp)
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
    string n;
    cin >> n;

    for(int i = 0;i < 3;i++){
        if(n[i] == '1')
            n[i] = '9';
        else if(n[i] == '9')
            n[i] = '1';
    }

    cout << n << endl;
  
    
}


Measured memory_bytes: 256
h,w=io.read("*n","*n")
grid={}
for i=1,h+2 do
    grid[i]={}
    if i~=1 and i~=h+2 then
        s=io.read()
    end
    for j=1,w+2 do
        if i==1 or i==h+2 then
            grid[i][j]="."
        else
            if j==1 or j==w+2 then
                grid[i][j]="."
            else
                grid[i][j]=s:sub(j-1,j-1)
            end
        end
    end
end

feasible=true
for i=2,h+1 do
    for j=2,w+1 do
        if grid[i][j-1]..grid[i][j]..grid[i][j+1]==".#." and grid[i-1][j]..grid[i][j]..grid[i+1][j]==".#." then
            feasible=false
        end
    end
end
if feasible then
    print("Yes")
else
    print("No")
end

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> ss(H);
  for(int i = 0; i < H; ++i) {
    cin >> ss[i];
  }
  for(int i = 0; i < W + 2; ++i) {
    cout << '#';
  }
  cout << endl;
  for(auto s : ss) {
    cout << '#' << s << '#' << endl;
  }
  for(int i = 0; i < W + 2; ++i) {
    cout << '#';
  }
  cout << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	ll N;
	scanf("%lld", &N);
	
	ll sqrtN = N;
	for(ll i = 0; i <= N; i++){
		sqrtN =i;
		if(i*i > N){
			break;
		}
	}
	
	ll min = N;
	
	for(ll i = 1; i <= sqrtN; i++){
		if(N % i == 0){
			ll j = N/i;
			ll move = i + j - 2;
			if(min > move){
				min = move;
			}
		}
	}
				
	printf("%lld\n", min);
	
	return 0;
}

Measured memory_bytes: 128
N,K,Q = gets.split.map(&:to_i)
results = []

Q.times do
	results << gets.to_i
end

score_participants = Array.new(N){K - Q}
results.each do |r|
	score_participants[r-1] += 1
end

score_participants.each do |s|
	if s > 0
		puts 'Yes'
	else
		puts 'No'
	end
end






Measured memory_bytes: 4148
print(*[11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381][:int(input())])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}

signed main(){
  int N,M;
  cin>>N>>M;
  vector<bool>a(N+1,true);
  rep(i,M){
    int t;cin>>t;
    a[t]=false;
  }
  ll dp[N+1]={0};
  dp[0]=1;
  rep(i,N+1){
    for(int j=i+1;j<=min(N+1,i+2);j++){
      if(a[j]){
        // print(dp[i]);
        dp[j] += dp[i];
        dp[j] %= 1000000007;
        // print(dp[j]);
      }
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define F(i,j,k) for(int i=(j);i<=(k);i++)
#define DF(i,j,k) for(int i=(j);i>=(k);i--)
using namespace std;
template<typename T>inline void read(T &n){
    T w=1;n=0;char ch=getchar();
    while(!isdigit(ch)&&ch!=EOF){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch)&&ch!=EOF){n=(n<<1)+(n<<3)+(ch^48);ch=getchar();}
    n*=w;
}
template<typename T>inline void write(T x){
    ull y=0;
    T l=0;
    if(x<0){x=-x;putchar('-');}
    if(!x){putchar(48);return;}
    while(x){y=y*10+x%10;x/=10;l++;}
    while(l){putchar(y%10+48);y/=10;l--;}
}
template<typename T>inline void writeln(T x){
    write(x);
    puts("");
}
template<typename T>inline void writes(T x){
    write(x);
    putchar(' ');
}
template<typename T>inline void checkmax(T &a,T b){a=a>b?a:b;}
template<typename T>inline void checkmin(T &a,T b){a=a<b?a:b;}
int w[101000],h[22],dp[(1<<15)+1],s[(1<<15)+1],ans,st;
int main(){
 	int n;read(n);
 	F(i,1,n-1){int x,y,a;read(x);read(y);read(a);w[x]^=a;w[y]^=a;}
 	F(i,0,n-1)h[w[i]]++;
 	F(i,1,15){ans+=h[i]/2;h[i]%=2;st^=(1<<(i-1))*h[i];}
 	F(i,1,(1<<15))dp[i]=dp[i>>1]+(i&1);
 	F(i,1,(1<<15))dp[i]--;
 	F(i,1,(1<<15))
 		F(j,0,14)
 			if(i&(1<<j))s[i]^=(j+1);
 	F(i,1,(1<<15)){
 		if(s[i])continue;
 		for(int k=(i-1)&i;k;k=(k-1)&i){if(!s[k])checkmin(dp[i],dp[k]+dp[i^k]);}
 	}
 	writeln(ans+dp[st]);
    return 0;
}

Measured memory_bytes: 4248
#include<iostream>
using namespace std;
int a[200];
int n;

int search(int i){
  int count = 0;
  int lix = 0,rix = n - 1;
  while(lix <= rix){
    //cout << lix << rix << endl;
    int med = (lix + rix)/2;

    count++;
    if(a[med] == i)return count;

    if(a[med] < i){
      lix = med + 1;
      continue;
    }

    if(a[med] > i){
      rix = med - 1;
      continue;
    }
  }
  return count;
}

int main(){

  while(true){
    cin >> n;
    if(n == 0)break;
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
      
    int i;
    cin >> i;
    cout << search(i) << endl; 
  }
}

Measured memory_bytes: 1160
def hult(ans)
  puts ans
  exit
end

def check(x, y)
  zip = @a[y..(y + @m - 1)].map { |s|
    s[x..(x + @m - 1)]
  }.zip(@b)
  hult 'Yes' if zip.all? { |a, b| a == b }
end

@n, @m = gets.split.map(&:to_i)
@a = @n.times.map { gets.chomp }
@b = @m.times.map { gets.chomp }
i = @n - @m + 1
i.times do |w|
  i.times do |h|
    check(w, h)
  end
end
hult 'No'


Measured memory_bytes: 2300
/**
 *
 * Chu-Liu/Edmonds's Algorithm
 *
 */

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

using edge = pair<int,pair<int,int>>;

int INF = 1 << 30;

int Edmonds(const vector<edge>& G,int V,int r){
  vector<pair<int,int>> MIN(V,pair<int,int>(INF,-1));
  for(auto &e : G){
    MIN[e.second.second] = min(MIN[e.second.second] , pair<int,int>(e.first,e.second.first));
  }

  MIN[r] = {-1,-1};

  vector<int> group(V,0);
  vector<bool> isCycle(V,false);
  int count = 0;

  vector<bool> used(V,false);

  for(int i = 0;i < V;i++){
    if(used[i]) continue;
    vector<int> chain;
    int now = i;
    while(now != -1 && !used[now]){
      used[now] = true;
      chain.push_back(now);
      now = MIN[now].second;
    }
    if(now != -1){
      bool inCycle = false;
      for(int j : chain){
        group[j] = count;
        if(j == now){
          isCycle[count] = true;
          inCycle = true;
        }
        if(!inCycle) 
          count++;
      }
      if(inCycle) 
        count++;
    }
    else{
      for(int j : chain){
        group[j] = count;
        count++;
      }
    }
  }
  int res = 0;
  if(count == V){
    for(int i = 0;i < V;i++){
      if(i == r) continue;
      res += MIN[i].first;
    }
    return res;
  }

  for(int i = 0;i < V;i++){
    if(i == r) continue;
    if(isCycle[group[i]])
      res += MIN[i].first;
  }

  vector<edge> nG;
  for(auto & e : G){
    int to = e.second.second;
    int gfrom = group[e.second.first];
    int gto = group[e.second.second];
    if(gfrom == gto) continue;
    else if(isCycle[gto])
      nG.push_back({e.first - MIN[to].first,{gfrom,gto}});
    else{
      nG.push_back({e.first,{gfrom,gto}});
    }
  }
  return res + Edmonds(nG,count,group[r]);
}

#include <iostream>

int main(){
  int V,E,r;
  cin >> V >> E >> r;
  vector<edge> G;

  for(int i = 0;i < E;i++){
    int s,t,w;
    cin >> s >> t >> w;
    G.push_back({w,{s,t}});
  }
  auto res = Edmonds(G,V,r);
  cout << res << endl;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    ll n, p; cin >> n >> p;
    ll ans = 1LL;
    if(n==1) {
        cout << p << endl;
        return 0;
    }
    for(ll i=2; i*i<=p; i++) {
        int cnt = 0;
        if(p%i != 0) continue;
        while(p%i==0) p/=i,cnt++;
        rep(j, cnt/n) {
            ans *= i;
        }
    }
    print(ans);
}



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

int main(){
  int d ; cin >> d ;
  if(d==25) cout << "Christmas" << endl ;
  if(d==24) cout << "Christmas Eve" << endl ;
  if(d==23) cout << "Christmas Eve Eve" << endl ;
  if(d==22) cout << "Christmas Eve Eve Eve" << endl ;
}

Measured memory_bytes: 256
n,m,c=map(int, input().split())
b=list(map(int, input().split()))
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))

ans=0
for i in range(n):
    accept=0
    for _m in range(m):
        accept+=a[i][_m]*b[_m]

    if accept+c > 0:
        ans+=1

print(ans)


Measured memory_bytes: 3060