akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    N = int(input())

    primes = []
    p = [0] * 1000000

    for i in range(2, 1000000):
        done = False
        m = int(i ** (1/2))
        for k in primes:
            if k > m:break
            if i % k == 0:
                done = True
                break
        if not done:
            primes.append(i)
            p[i] = 1


    count = 0

    for i in primes:
        if p[2]:
            s = i
            while True:
                if not N % s:

                    N = N // s
                    count += 1
                    s *= i

                else:break
            s = s // i
            while s > 1:
                if not N % s:
                    N = N // s
                else:
                    s = s // i


    if count == 0 and N != 1:
        print(1)
    elif N != 1:
        print(count + 1)
    else:
        print(count)



if __name__ == "__main__":
    run()

Measured memory_bytes: 20536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  int ans = 0;
  rep(i, S.length()-1) {
    if (S[i+1] != S[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long long dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
  return 0;
}

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


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

  rep(i,k){
    cout<< "ACL";
  }
  cout << endl;


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//#define int long long
#define double long double

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

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

int n,k,a[5100],x[5100][5100],y[5100][5100];
signed main(){
  cin>>n>>k;rep(i,n)cin>>a[i+1];
  x[0][0] = y[n+1][0] = 1;
  repd(i,1,n+1){
    rep(j,k+1){
      x[i][j] = (x[i-1][j] || (j-a[i] >= 0 && x[i-1][j-a[i]]));
    }
  }
  for(int i = n;i >= 1;i--){
    rep(j,k+1){
      y[i][j] = (y[i+1][j] || (j-a[i] >= 0 && y[i+1][j-a[i]]));
    }
  }
  int ans = 0;

  rep(i,n+2){
    repd(j,1,k+2)y[i][j] += y[i][j-1];
  }
 // rep(i,n+2)rep(j,k+2)cout << x[i][j] << (j == k+1 ? "\n" : " ");
 // cout << endl;
 // rep(i,n+2)rep(j,k+2)cout << y[i][j] << (j == k+1 ? "\n" : " ");
  repd(i,1,n+1){
    rep(j,k){
      if(!x[i-1][j])continue;
      int l = k-a[i]-j-1, u = k-j-1;
      if(y[i+1][u]-(l < 0 ? 0 : y[i+1][l])){
        ans++;break;
      }
    }
  }
  cout << n-ans << endl;
}




Measured memory_bytes: 203008
def cmb(n, r, mod):
    if (r < 0) or (r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

mod = 10 ** 9 + 7
N = 10 ** 6
g1 = [1, 1]  # 元
g2 = [1, 1]  # 逆元
inverse = [0, 1]  # 逆元計算用

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


X, Y = map(int, input().split())

if ((2 * X - Y) >= 0) and ((2 * X - Y) % 3 == 0):
    t = (2 * X - Y) // 3
else:
    print(0)
    exit()

if ((2 * Y - X) >= 0) and ((2 * Y - X) % 3 == 0):
    s = (2 * Y - X) // 3
else:
    print(0)
    exit()

print(cmb(s + t, s, mod))


Measured memory_bytes: 122128
#import<cstdio>
int t,c[1510],i,a,j;main(){for(;~scanf("%d",c+j++););for(;c[*c*3]=i<*c;a=!printf("%d\n",a))for(j=3*i++;t=c[j+=3];)a=(a<c[j-1]?c[j-1]:~-a/t*t+t)+c[j-2];}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt powmod(lnt a, lnt p, lnt m){
	lnt res = 1, tmp = a;
	while(p != 0){
		if(p % 2) res = (res*tmp) % m;
		tmp = (tmp*tmp) % m;
		p /= 2;
	}
	return res;
}

int main(){
	summon_tourist;

	lnt N; cin >> N;

	lnt c00 = 0, c01 = 0, c10 = 0;
	vector<plnt> X;
	map<plnt, lnt> mp;

	REP(i, N){
		lnt a, b; cin >> a >> b;
		if(a==0 and b==0) c00++;
		else if(a==0) c01++;
		else if(b==0) c10++;
		else X.eb(a, b);
	}

	for(plnt &p: X){
		lnt a = p.first, b = p.second;
		lnt g = __gcd(abs(a), abs(b));
		a /= g; b /= g;
		if(a < 0){
			a*=-1; b*=-1;
		}
		mp[{a, b}]++;
		if(b < 0){
			lnt ta = -b, tb = a;
			a = ta; b = tb;
		}
		p = {a, b};
	}
	sort(ALL(X));
	X.erase(unique(ALL(X)), X.end());
	lnt ans = (powmod(2, c01, MOD) + powmod(2, c10, MOD) - 1 + MOD) % MOD;
	for(plnt p: X){
		lnt a = p.first, b = p.second;
		lnt A = b, B = -a;
		lnt c0 = mp[p], c1 = mp[{A, B}];
		ans = ans * ((powmod(2, c0, MOD) + powmod(2, c1, MOD) - 1 + MOD) % MOD) % MOD;
	}
	
	cout << (ans-1+c00+MOD) % MOD << ln;
}

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

int GCD(int a, int b){
    int tmp;
    assert(a>1&&b>1);
    while (a){
        tmp = a;
        a = b % a;
        b = tmp;
    }
    return b;
}

int main() {
    int a,b;
    cin>>a>>b;
    cout<<GCD(a,b)<<endl;
    return 0;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int n;cin>>n;
	ll ct=0;
	for(int i=1; i<=n; i++){
		if(to_string(i).length()%2 ==1)ct++;
	}

	writeln(ct);


}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n, x,diff=100000000;
	cin >> n >> x;
	vector<ll>city(n);
	rep(i, n)cin >> city[i];
	/*１つしか都市がない場合はxとの絶対値を出力*/
	if (n == 1) { cout << abs(x - city[0]); return 0; }
	/*複数ある場合は、各都市の座標とxの座標の絶対値同士の最大公約数をとってあげる
	　そうすると、xからその座標までの距離が求まり、その最大公約数を求めるため
	　D*nが出て来る。それの最小値をとってあげると答えが出る*/
	rep(i, n - 1)diff = min(diff, gcd(abs(city[i] - x), abs(city[i + 1] - x)));
	cout << diff << endl;
	return 0;
}



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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	string s; 
	cin>>s ;
	int cnt = 0 , cnt1 = 0;
	for(int i = 0 ; i < s.size() ; ++i)
	{
		if(s[i] == '(')
			cnt++ ;
		else
			cnt-- ;
		if(cnt < 0)
			cnt1++ , cnt++ ;
	}
	for(int i = 0 ; i < cnt1 ; ++i)
		cout<<"(" ;
	cout<<s ;
	for(int i = 0 ; i < cnt ; ++i)
		cout<<")" ;
	return 0 ;
}

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

int powint(int x,int y){
  int res=1;
  for(int i=0;i<y;i++)res*=x;
  return res;
}

int main() {
  int n,k,iii;
  double res=0;
  cin >> n >> k;
  if(n>=k){
    for(int i=1;i<=17;i++){
      res+=std::pow(0.5,i)*((k-1)/powint(2,i-1)-(k-1)/powint(2,i))/n;
    }
    res+=(n-k+1.0)/n;
  }else{
    for(int i=17;(k-1)/powint(2,i-1)<=n;i--){
      res+=std::pow(0.5,i)*((k-1)/powint(2,i-1)-(k-1)/powint(2,i))/n;
      iii=i;
    }
    iii--;
    res+=std::pow(0.5,iii)*(n-(k-1)/powint(2,iii))/n;
  }
std::cout << std::setprecision(12) << res;
return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0
for a in A:
    allsum = C
    for x, y in zip(a, B):
        allsum += x*y
    if allsum > 0:
        ans += 1

print(ans)

Measured memory_bytes: 62384
/*
khoi orz, go check out his algo
-normie-
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "robot.inp"
#define FILE_OUT "robot.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 1048576
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
#define ll long long
#define pi 3.1415926535897
//------START-----------//
//------END-----------//
ll n,m,k,t,t1,i,j,a,b, res=-1,resi,resj;
vector<ll> po;
vector<pll> vs;
ll f(ll a, ll b)
{
	ll res=0, rega=a/mag,regb=b/mag;	
	for (ll i=a;i<min(rega*mag+mag,b+1);i++) res^=i;
	if (regb-rega)
	for (ll i=regb*mag;i<b+1;i++ )res^=i;
	return res;
}
int main()
{
//	ofile;
	fio;
	cin>>a>>b;
	cout<<f(a,b);
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


int main()
{
    int n,m;cin >> n >> m;
    vector<vector<ll> > n_cake(n, vector<ll>(3));
    rep(i, n)
    {
        cin >> n_cake[i][0] >> n_cake[i][1] >> n_cake[i][2];
    }

    vector<ll> sortable(n);
    ll mx = 0;
    rep(i, 8)
    {
        rep(i, n) sortable[i] = 0;
        rep(j,3)
        {
            if(i & (1 << j))
            {
                rep(k,n)sortable[k] += n_cake[k][j];
                continue;
            }
            rep(k, n) sortable[k] -= n_cake[k][j];
        }
        sort(sortable.begin(),sortable.end(), greater<ll>());
        ll temp = 0;
        rep(i,m) temp += sortable[i];
        mx = max(mx, temp);
    }
    cout << mx << endl;
}

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

int A[3][3];
int n, x;
set<int> b;

int main()
{
  bool flg = false;
  for (int i = 0; i < 3; i++)
  {
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }

  cin >> n;

  for (int i = 0; i < n; i++)
  {
    cin >> x;
    b.insert(x);
  }

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      set<int> c = b;
      c.insert(A[i][j]);

      if (c.size() == b.size())
      {
        A[i][j] = 1;
      }
    }
  }

  for (int i = 0; i < 3; i++)
  {
    // 横
    if (A[i][0] + A[i][1] + A[i][2] == 3)
    {
      printf("Yes");
      exit(0);
    }
  }

  for (int i = 0; i < 3; i++)
  {
    if (A[0][i] + A[1][i] + A[2][i] == 3)
    {
      printf("Yes");
      exit(0);
    }
  }

  if ((A[0][0] + A[1][1] + A[2][2] == 3) || (A[0][2] + A[1][1] + A[2][0] == 3))
  {
    printf("Yes");
    exit(0);
  }

  printf("No");

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static int count;

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for(int i = 0;i < n; i++){
			int num = Integer.parseInt(br.readLine());
			solve(num);
		}

		System.out.println(count);

	}

	public static void solve(int num){
		if(num == 1){
			return;
		}
		else if(num == 2){
			count++;
			return;
		}
		else if(num % 2 == 0){
			return;
		}
		else{
			for(int i = 3;i <= Math.sqrt(num); i++){
				if(num % i == 0){
					return;
				}
			}
		}
		count++;
	}

}

Measured memory_bytes: 29632
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;


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

    int ans = N/111;

    if(N%111==0){
        printf("%d", ans*111);
    }else{
        printf("%d", ans*111+111 );
    }


    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s[s.size()-1] != 's') s += "s";
	else s += "es";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   if(n>=s.length())
   {
       cout<<s;
   }
   else
   {
       string k;
       for(int i=0;i<n;i++)
       {
           k+=s[i];
       }
       k+="...";
       cout<<k;
   }

}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

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

	private void run() throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] values = br.readLine().split(" ");
		int N = Integer.parseInt(values[0]);
		int X = Integer.parseInt(values[1]);
		int Y = Integer.parseInt(values[2]);
		//距離
		int[] ks = new int[N+1];
		for(int i = 0; i < N; i++) {
			for(int j = i+1; j < N; j++) {
				int dist1 = j-i;
				int dist2 = Math.abs(X-1-i) + Math.abs(Y-1-j) + 1;
				int dist = Math.min(dist1, dist2);
				ks[dist]++;
			}
		}
		for(int k=1; k < N; k++) {
			out.println(ks[k]);
		}
		out.flush();
		br.close();
	}
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  cout << a.back()-a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)
newArr = []

# 増加 or 減少
isUp = false
isDown = false

count = 1

(arr.size-1).times do |id|
  chk = arr[id+1] - arr[id]
#  puts %(id : #{id} #{arr[id]} , #{arr[id+1]})

  if isUp
    if chk >= 0 #|| chk == 0
      newArr << arr[id]
    else
      isUp = false
      count += 1
      newArr << arr[id]
      newArr << "|"
      next
    end
  end

  if isDown
    if chk <= 0 # || chk == 0
      newArr << arr[id]
    else
      isDown = false
      count += 1
      newArr << arr[id]
      newArr << "|"
      next
    end
  end

  if isDown == false && isUp == false
    newArr << arr[id]
    case
      when chk > 0
        isUp = true
        isDown = false
      when chk < 0
        isDown = true
        isUp = false
      when chk == 0
      else
        isUp = false
        isDown = false
        count += 1
        newArr << "|"
    end
  end

#  puts %(chk:#{chk})
#  puts %(isUp:#{isUp}, isDown:#{isDown})
#  puts count

end

#p newArr
puts count

Measured memory_bytes: 12308
import sys
from typing import Dict, List


def find_group(groups: Dict[int, List], tgt: str) -> (bool, str):
    for k, v in groups.items():
        if tgt in v:
            return k
    return "-1"


def main():
    n, q = map(int, input().split())
    query_lines = sys.stdin.readlines()
    queries = [query_lines[x].split() for x in range(q)]

    answers = [None] * q
    num_ans = 0

    groups = {str(i): [str(i)] for i in range(n)}
    groups_memo = {str(i): str(i) for i in range(n)}

    for query in queries:
        if query[0] == '0':     # unite
            q1 = query[1]
            q2 = query[2]
            g1 = find_group(groups, q1)
            g2 = find_group(groups, q2)
            if g1 == g2:
                continue
            assert g1 != -1 and g2 != -1
            for item in groups[g2]:
                groups_memo[item] = g1
            groups[g1] = groups[g1] + groups[g2]
            del groups[g2]
        else:                   # same
            if groups_memo[query[1]] == groups_memo[query[2]]:
                answers[num_ans] = 1
            else:
                answers[num_ans] = 0
            num_ans += 1

    [print(answers[x]) for x in range(num_ans)]
    return


main()


Measured memory_bytes: 47432
#include <iostream>
#include <string>

using namespace std;

using std::cin;
using std::cout;
using std::endl;

// カードを格納
string s[3];

// A, B, Cのカードの配列の位置
int ap, bp, cp;

int game(int participant) {
  if (participant == 0) {
    ap++;
    // 勝利条件
    if (!s[participant][ap]) {
      return participant;
    } else {
      return game(s[participant][ap] - 97);
    }
  } else if (participant == 1) {
    bp++;
    // 勝利条件
    if (!s[participant][bp]) {
      return participant;
    } else {
      return game(s[participant][bp] - 97);
    }
  } else {
    cp++;
    // 勝利条件
    if (!s[participant][cp]) {
      return participant;
    } else {
      return game(s[participant][cp] - 97);
    }
  }
}

int main() {
  // 勝った人を表す
  int win;
  // カードのイテレータの初期値
  ap = -1;
  bp = -1;
  cp = -1;

  // 手札の入力
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }

  /* 勝者を判定する
  　　参加者は0, 1, 2で表す
  　　A -> 0
  　　B -> 1
  　　C -> 2
  */
  ap++; // ゲーム開始
  win = game(0);

  // 出力
  switch (win) {
    case  0:
      cout << "A" << endl;
      break;
    case  1:
      cout << "B" << endl;
      break;
    case  2:
      cout << "C" << endl;
      break;
  }
  return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
ls = len(s)
lt = len(t)

for i in range(ls, lt-1, -1):
  a = s[i-lt:i]
  if(all([a[j] == t[j] or a[j] == "?" for j in range(lt)])):
    s = s[:i-lt] + t + s[i:]
    print(s.replace("?","a"))
    exit()
    
print("UNRESTORABLE")

Measured memory_bytes: 3064
def getlist():
	return list(map(int, input().split()))

N, M = getlist()
L = [0 for i in range(N + 100)]
L[0] = 1
L[1] = 1

for i in range(M):
	a = int(input())
	L[a] = -1

for i in range(2, N + 1):
	if L[i] != -1:
		if L[i - 1] != -1:
			if L[i - 2] != -1:
				L[i] = (L[i - 1] + L[i - 2]) % 1000000007
			else:
				L[i] = L[i - 1]
		else:
			if L[i - 2] != -1:
				L[i] = L[i - 2]

print(L[N] % 1000000007)

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

int main() {
	
	int n;
	cin >> n;
	int tmp = n;
	int s = 0;
	while(tmp != 0){
		s += tmp % 10;
		tmp /= 10;
	}
	if(n % s == 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int N, T, A, H0, ans;
	double dif, min = 100000;

	cin >> N >> T >> A;

	for (int i = 0; i < N; i++) {
		cin >> H0;
		dif = abs(A - (T - H0 * 0.006));
		if (dif < min) {
			min = dif;
			ans = i + 1;
		}
	}

	cout << ans;

	return 0;

}

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

#define PB push_back
#define F first
#define S second
#define MP make_pair

vector<pair<int,int> > edge[100100];
int in_deg[100100];
int po[100100];

main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<=n;i++)po[i]=-1;
    for(int i=0;i<m;i++)
    {
        int l,r,d;
        scanf("%d %d %d",&l,&r,&d);
        edge[l].PB(MP(r,d));
        in_deg[r]++;
    }
    int err=0;
    for(int i=1;i<=n;i++)
    {
        if(in_deg[i]==0)
        {
            po[i]=0;
            queue<int> q;
            q.push(i);
            while(!q.empty())
            {
                int nw=q.front();
                q.pop();
                for(int i=0;i<edge[nw].size();i++)
                {
                    int go=edge[nw][i].F;
                    int where=edge[nw][i].S+po[nw];
                    //printf("%d %d %d\n",go,where,po[go]);
                    if(po[go]!=-1)
                    {
                        if(where!=po[go])
                        {
                            err=1;
                        }
                    }
                    else
                    {
                        po[go]=where;
                        if(where>1e9)err=1;
                        q.push(go);
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        //printf("%d\n",po[i]);
        if(po[i]==-1)err=2;
    }
    //printf("%d",err);
    if(err==0)printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
  long a,b,x,o,p,q;
  cin>>a>>b>>x;
  if(a==0){
      cout<<b/x+1<<endl;
  }
  else{
    o=(a-1)/x;
    p=b/x;
    cout<<p-o<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数

/****************************** START ******************************/

signed main(){
  int D,T,S;
  cin >> D >> T >> S;
  if (D <= T * S){
    cYes;
  } else {
    cNo;
  }
}
  


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

#define F first
#define S second

using namespace std;

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

const int N = 110, M = 110;

int n, m;
char g[N][N];

int main()
{	
	cin >> n >> m;
	for (int i = 0; i < 50; i ++ )
		for (int j = 0; j < 100; j ++ )
			g[i][j] = '#';
	for (int i = 50; i < 100; i ++ )
		for (int j = 0; j < 100; j ++ )
			g[i][j] = '.';
			
	n -- , m -- ;
	for (int i = 0; i < 49 && n; i += 2)
		for (int j = 0; j < 100 && n; j += 2)
			g[i][j] = '.', n -- ;
			
	for (int i = 51; i < 100 && m; i += 2)
		for (int j = 0; j < 100 && m; j += 2)
			g[i][j] = '#', m -- ;
			
	puts("100 100");
	for (int i = 0; i < 100; i ++ ) puts(g[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int ans = 0;
    string S;
    cin >> S; 
    for(int i=0; i<4; i++){
        if(S[i]=='+'){
            ans++;
        }
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int H, A[MAX+1];

int left(int i) {
  return 2*i;
}

int right(int i) {
  return 2*i+1;
}

void maxHeapify(int i) {
  int argmax = i;
  int l = left(i);
  int r = right(i);
  if (l<=H && A[argmax]<A[l]) {
    argmax = l;
  }
  if (r<=H && A[argmax]<A[r]) {
    argmax = r;
  }

  if (argmax!=i) {
    swap(A[i], A[argmax]);
    maxHeapify(argmax);
  }
}

int main() {
  cin >> H;
  for (int i=1; i<=H; i++) {
    cin >> A[i];
  }

  for (int i=H/2; i>=1; i--) {
    maxHeapify(i);
  }

  for (int i=1; i<=H; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 5044
#include <iostream> 
#include <cassert> 
//#define NDEBUG 
int main(void){ 
	using namespace std; 
	static const int INPUT_NUM_MIN = 1; 
	static const int INPUT_NUM_MAX = 10000; 
	static const int SORT_NUMBERS = 3;	/* Sorting Three Numbers */
	int input_num[SORT_NUMBERS]; 
	int min_num = INPUT_NUM_MAX; 
	int middle_num = 0; 
	int max_num = INPUT_NUM_MIN; 
	int index_min = 0; 
	int index_max = 0; 
	for (int i=0; i<SORT_NUMBERS; i++){
		cin >> input_num[i]; 
	}
	assert(INPUT_NUM_MIN <= input_num[0] && input_num[0] <= INPUT_NUM_MAX); 
	/* Precondition */ assert(INPUT_NUM_MIN <= input_num[1] && input_num[1] <= INPUT_NUM_MAX); 
	/* Precondition */ assert(INPUT_NUM_MIN <= input_num[2] && input_num[2] <= INPUT_NUM_MAX); 
	/* Precondition */ /* Calculation */ 
	for (int i=0; i<SORT_NUMBERS; i++){ 
		/* Calculation Min */ 
		if(input_num[i] < min_num){ 
			min_num = input_num[i]; 
			index_min = i;
		 }
	 } 
	for (int i=0; i<SORT_NUMBERS; i++){ 
		/* Calculation Max */ 
		if(input_num[i] > max_num){
			max_num = input_num[i]; 
			index_max = i;
 		}
 	} 
	for (int i=0; i<SORT_NUMBERS; i++){ 
		/* Calculation Middle */ 
		if(i != index_min && i != index_max){ 
			middle_num = input_num[i]; 
		}
 	} 
	cout << min_num << " " << middle_num << " " << max_num << endl;
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main(){
  string S, T;
  cin >> S >> T;

  int N = (int)S.size();

  vector<bool> fg(26);
  Graph ch(26);
  for( int i = 0; i < N; i++ ){
    ch.at(S.at(i)-'a').push_back(i+1);
    fg.at(S.at(i)-'a') = 1;
  }

  int ans = 0;
  for( int i = 0; i < T.size(); i++ ){
    if( fg.at(T.at(i)-'a') == false ){
      cout << -1 << endl;
      return 0;
    }
    auto Iter = upper_bound(ch.at(T.at(i)-'a').begin(), ch.at(T.at(i)-'a').end(), ans%N);
    if( Iter == ch.at(T.at(i)-'a').end() ){
      ans += N-(ans%N)+ch.at(T.at(i)-'a').at(0);
    }else ans += *Iter - ans%N;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1724
from itertools import accumulate


N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2 for p in P]

cum = [0]
cum.extend(list(accumulate(E)))

ans = 0
for i in range(N-K+1):
        ans = max(ans, cum[i+K] - cum[i])

print(ans)


Measured memory_bytes: 26368
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(){
    int ans;
    int N,S,dig;
    cin>>N;
    
    int NN=N;
    
    while(N){
        dig = N % 10;
        S = S + dig;
        N = N / 10;
    }
    if(NN % S == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int d;
    while(scanf("%d",&d)!=EOF){
        int ans=0;
        for (int i=1;i<600/d;i++) {
            ans+=(d*i)*(d*i)*d;
        }
    printf("%d\n",ans);
    }
    return 0;
}

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

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

  string s, t;
  cin >> s >> t;

  bool ans = true;

  map<char, int> sUniqs, tUniqs;
  for (int i = 0; i < s.size(); i++) {
    char sc = s.at(i);
    char tc = t.at(i);

    sUniqs[sc]++;
    tUniqs[tc]++;

    if (sUniqs[sc] != tUniqs[tc]) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 916
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
int V,E;
const ll INF =1234567890123456;
vector<edge>g[100005];
ll d[100005];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d, d + V+3, INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		ll v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < g[v].size(); i++){
			edge e=g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	return;
}
int main(){
	cin>>V>>E;
	for(int i=0;i<E;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		g[a].push_back(edge{b,c});
	}
  for(int i=1;i<V;i++){
    g[i+1].push_back(edge{i,0});
  }
	dijkstra(1);
	if(d[V]==INF)cout<<-1<<endl;
	else cout<<d[V]<<endl;
}


Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())

#define MOD 998244353
ll modpow(ll e, ll x){
    if(0==e) return 0;
    ll ret=1;
    rep(_, x) {
        ret *= e;
        ret %= MOD;
    }
    return ret;
}

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

    // solution comes here
    ll N;
    cin >> N;

    vl D(N);
    rep(i, N) cin >> D[i];

    if(D[0]!=0){
        cout << 0 << nl;
        return 0;
    }
    
    sortup(D);

    if(D[0]!=0 or D[0]==D[1]) {
        cout << 0 << nl;
        return 0;
    }

    ll a=1, b=1, ans=1;
    rep(i, N-1) {
        if(D[i]==D[i+1]) b++;
        else if(D[i+1]-D[i] != 1){
            cout << 0 << nl;
            return 0;
        }
        else {
            ans *= modpow(a, b);
            ans %= MOD;
            a=b;
            b=1;
        }
    }
    ans *= modpow(a, b);
    ans %= MOD;
    cout << ans << nl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	ll int tc=1;
	while(tc--)
	{
		ll int n;
		cin>>n;
		vector<ll int> v;
		ll int x;
		ll int s=0;
		//ll int flag=0;
		for(ll int i=0;i<n;i++)
		{
			cin>>x;
			s^=x;
			v.push_back(x);

		}
		for(int i=0;i<n;i++)
		{
			int x=s^v[i];
			
		cout<< x <<" ";
		}
		cout<<endl;
		

	}
}




Measured memory_bytes: 5236
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int N;
	int T[1000], A[1000];
	int64_t Tn, An;
	int64_t answer=0;
	int64_t k;

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


	Tn = 1;
	An = 1;

	for (int j = 0; j < N; ++j) {
		k = max((Tn + T[j] - 1) / T[j], (An + A[j] - 1) / A[j]);//切り上げテクニック
			Tn = T[j] * k;
			An = A[j] * k;
		
	}
	answer = Tn + An;

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(n, a_str_list):

    count_25 = [[0] * 19 for _ in range(19)]
    for i in range(n):
        a_str = a_str_list[i]
        if "." in a_str:
            a_str_a, a_str_b = a_str.split(".")
            a_int = int(a_str_a + a_str_b + "0" * (9 - len(a_str_b)))
        else:
            a_int = int(a_str) * 1000000000
        count_2 = 0
        count_5 = 0
        while a_int % 2 == 0:
            a_int = a_int // 2
            count_2 += 1
        while a_int % 5 == 0:
            a_int = a_int // 5
            count_5 += 1
        count_2 = min(count_2, 18)
        count_5 = min(count_5, 18)
        # print(a_str, count_2, count_5)
        count_25[count_2][count_5] += 1
    # print(count_25)

    res = 0
    for i0 in range(19):
        for j0 in range(19):
            for i1 in range(19):
                for j1 in range(19):
                    if count_25[i0][j0] * count_25[i1][j1] and i0 + i1 >= 18 and j0 + j1 >= 18:
                        # print(i0, j0, i1, j1)
                        if i0 == i1 and j0 == j1:
                            res += (count_25[i0][j0] - 1) * count_25[i0][j0]
                        elif i0 == i1:
                            res += count_25[i0][j0] * count_25[i0][j1]
                        elif j0 == j1:
                            res += count_25[i0][j0] * count_25[i1][j0]
                        else:
                            res += count_25[i0][j0] * count_25[i1][j1]
    # print(res)
    return res // 2


def main():
    n = int(input())
    a_str_list = [input() for _ in range(n)]
    res = solve(n, a_str_list)
    print(res)


def test():
    assert solve(5, ["7.5", "2.4", "17.000000001", "17", "16.000000000"]) == 3
    assert solve(11, [
        "0.9", "1", "1", "1.25", "2.30000", "5", "70", "0.000000001", "9999.999999999", "0.999999999", "1.000000001"
    ]) == 8


if __name__ == "__main__":
    test()
    main()


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

int main(void){
  int n, l, h;
  int ans=1;
  
  cin >> n;
  l = 0;
  for (int i=0; i<n; i++){
    cin >> h;
    if (l>h) ans=0;
    l = l==h?h:h-1;
  } 
  cout << (ans?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
mp={}
for i in range(n):
    s=input()
    if s in mp:
        mp[s]+=1
    else:
        mp[s]=1
_max=0
for x,y in mp.items():
    _max=max(_max,y)
ans=[]
for x,y in mp.items():
    if y==_max:
        ans.append(x)
ans.sort()
for x in ans:
    print(x)

Measured memory_bytes: 92376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m,X,Y;cin>>n>>m>>X>>Y;
  vector<int> x(n);
  vector<int> y(m);
  rep(i,n)cin>>x[i];
  rep(i,m)cin>>y[i];
  bool flag=true;
  sort(ALL(x));
  sort(ALL(y));
  if(y[0]>x[n-1]&&X<Y){
    if(y[0]>X&&x[n-1]<Y)
    flag=false;
  }
  if(flag){
    cout<<"War"<<endl;
  }
  else{
    cout<<"No War"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
s=input()
a=len(s)
flag=0
for i in range(len(s)):
  if s[i]=='C':
    a=i
  if s[i]=='F':
    if i>a:
      flag=1
      break
    else:
      continue 
if flag==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long,long>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a,b) get<a>(b)
#define INF (ll)1e18+5
#define ull unsigned long long
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
const int N = 2e5+5;
/*ll parent[N];
ll siz[N];
vector<pair<ll, pair<ll, ll> > > v;
void make(){
    REP(i, 0, N){
        parent[i]=i;
        siz[i] = 1;
    }
}
ll find(ll x){
    while(parent[x] != x){
        x = parent[x];
    }
    return x;
}
void unite(ll a, ll b){
    a = find(a);
    b = find(b);
    if(a != b){
        if(siz[a] < siz[b]){
            swap(a, b);}
        parent[b] = a;
        if(siz[a] == siz[b]){
            siz[a]++;
        }
    }
}*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout<<(ull)pow(1024, 14);
    ll n;
    cin>>n;
    ll ans = (ll)1e18;
    REP(i, 1, (ll)sqrt(n)+1){
        if(n%i == 0){
            ll t = n/i+i-2;
            //if(i == 1){t--;}
            //else{t-=2;}
            ans = min(ans, t);
        }
    }
    cout<<ans;
}

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

using namespace std;
typedef long long ll;

#include <vector>

using namespace std;

const int N = 1000000;
vector<bool> isp(N, true);
void sieve()
{
  isp[0] = false;
  isp[1] = false;
  for (auto i = 0; i <= N; i++)
  {
    if (isp[i])
    {
      for (auto j = 2; i * j <= N; j++)
        isp[i * j] = false;
    }
  }
}

int main()
{
  ll n;
  cin >> n;
  // sieve();
  // vector<ll> fact = {};

  ll ans = 1LL << 60;
  ll limit = min((long long)N, n);
  for (auto i = 1; i <= limit; i++)
  {
    if (n % i == 0)
    {
      ll x = n / i;
      ll y = i;
      ans = min(ans, (x - 1) + (y - 1));
    }
  }
  cout << ans << endl;

  return 0;
}


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

typedef unsigned long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define MOD 998244353
#define int ll

int N,K;

int fac[5001];


int exp(int a,int b){
	int res = 1;
	
	while (b > 0){
		if (b&1){
			res *= a;
			res %= MOD;
		}
		
		b >>= 1;
		a *= a;
		a %= MOD;
	}
	return res;
}

int modinv(int A,int B){
	A %= MOD;
	B = exp(B,MOD-2);
	A *= B;
	A %= MOD;
	return A;
}

int nchoosek(int n,int k){
	if (n < k) return 0;
	return modinv(fac[n],(fac[k] * fac[n-k]) % MOD);
}
			
int32_t main(){
	fast;
	
	cin>>K>>N;
	
	
	
	
	fac[0] = 1;
	FOR(i,1,4999){
		fac[i] = (fac[i-1] * i) % MOD;
	}
	int num = nchoosek(N + K - 1,N);
	
	//cout<<num<<'\n';
	FOR(k,2,2*K){
		int pairs = 0;
		FOR(i,1,K){
			if (1 <= k - i && k-i <= K) pairs++;
		}
		if (k % 2 == 0) pairs++;
		pairs /= 2;
		
		//cout<<pairs<<'\n';
		
		int ans = num;
		FOR(i,1,pairs){
			int val = (nchoosek(N - i * 2 + K - 1,N - i * 2) * nchoosek(pairs,i)) % MOD;
			if (i % 2 == 0) ans = (ans + val) % MOD;
			else ans = (ans - val + MOD)%MOD;
		}
		
		cout<<ans<<'\n';
	}
		
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    int n, x, t; cin >> n >> x >> t;

    if(n%x) cout << (n/x+1)*t << endl;
    else cout << n/x*t << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>

int main() {

	long long int N;
	std::cin >> N;

	if (N % 2 == 1) {
		std::cout << N * 2 << std::endl;
	}
	else {
		std::cout << N << std::endl;
	}

	return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> C(H);
	for (int i = 0; i < H; i++) cin >> C.at(i);

	for (int i = 0; i < H; i++) {
		cout << C.at(i) << endl;
		cout << C.at(i) << endl;
	}
}

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

struct Card
{
	int num;
	string suit;
};

void swapCard(Card& a, Card& b) {
	Card temp = a;
	a = b;
	b = temp;
}

void BubbleSort(vector<Card>& c, int n) {
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (c[j].num < c[j - 1].num) {
				swapCard(c[j], c[j - 1]);
			}
		}
	}
}

void SelectionSort(vector<Card>& c, int n) {
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (c[j].num < c[minj].num) {
				minj = j;
			}
		}
		swapCard(c[i], c[minj]);
	}
}

bool stable(vector<Card> b, vector<Card> s, int n) {	
	for (int i = 0; i < n; i++) {
		if ((b[i].num != s[i].num) || (b[i].suit != s[i].suit))
			return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	vector<Card> c(n), c1(n), c2(n);
	for (int i = 0; i < n; i++) {
		string t;
		cin >> t;
		c[i].suit = c1[i].suit = c2[i].suit = t[0];
		c[i].num = c1[i].num = c2[i].num = t[1] - '0';
	}
	BubbleSort(c1, n);
	SelectionSort(c2, n);
	for (int i = 0; i < n; i++) {
		cout << c1[i].suit << c1[i].num;
		if (i < n - 1)
			cout << " ";
		else
			cout << endl;
	}
	cout << "Stable" << endl;
	for (int i = 0; i < n; i++) {
		cout << c2[i].suit << c2[i].num;
		if (i < n - 1)
			cout << " ";
		else
			cout << endl;
	}
	cout << (stable(c1, c2, n) ? "Stable" : "Not stable") << endl;
	return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	int t=0;
	while(b<=a)
	{
		b=b*2;
		t++;
	}
	while(c<=b)
	{
		c=c*2;
		t++;
}
if(t<=k)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;

	
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;
typedef pair<plint, lint> query;

template< typename T >
struct BinaryIndexedTree {
	vector< T > data;

	BinaryIndexedTree(int sz) {
		data.assign(++sz, 0);
	}

	T sum(int k) {
		T ret = 0;
		for (++k; k > 0; k -= k & -k) ret += data[k];
		return (ret);
	}

	void add(int k, T x) {
		for (++k; k < data.size(); k += k & -k) data[k] += x;
	}
};

lint N, Q, L, R;
lint arr[500000];
vector<query> queries;
vector<plint> sec;
lint last[500000];
lint ans[500000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> Q;
	REP(i, N) last[i] = -1;
	REP(i, N) {
		cin >> arr[i]; arr[i]--;
		if (last[arr[i]] != -1) sec.push_back({ last[arr[i]], i });
		last[arr[i]] = i;
	}
	REP(i, Q) {
		cin >> L >> R; L--; R--;
		queries.push_back({ { L, R }, i });
	}
	sort(ALL(queries), greater<query>());
	sort(ALL(sec), greater<plint>());
	BinaryIndexedTree<int> bit(N);
	lint sec_idx = 0;
	REP(i, Q) {
		while (sec_idx < SZ(sec) && queries[i].first.first <= sec[sec_idx].first) {
			bit.add(sec[sec_idx].second, 1);
			sec_idx++;
		}
		lint l = queries[i].first.first, r = queries[i].first.second;
		ans[queries[i].second] = (r - l + 1) - (bit.sum(r));
	}
	REP(i, Q) {
		cout << ans[i] << endk;
	}
}

Measured memory_bytes: 40468
using System;

namespace Constest
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] stArrayData = line.Split(' ');
            int n = int.Parse(stArrayData[0]);
            int x = int.Parse(stArrayData[1]);
            int t = int.Parse(stArrayData[2]);
            int o = ((n % x) == 0) ? (n / x) : (n / x) + 1;
            o = o * t;

            Console.WriteLine(o);
        }
    }
}


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

int main(){

int a,b,c,count;

cin >> a;

for(int i=0; i<a; i++){

    cin >> b >> c;
 
    if(b>c && b%c !=0) cout << b%c << endl;
 
    else if(b > c && b%c == 0) cout << c << endl;

    else cout << b << endl;
}

return 0;
}

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

#define M 1000000007

int main(){
    int N;
    string s1,s2;
    cin >> N;
    cin >> s1 >> s2;

    int addr=0;
    long long n;
    while(addr<N){
        if(s1[addr]==s2[addr]){
            if(addr==0) n=3;
            else if(s1[addr-1]==s2[addr-1]) n=(n*2)%M;
            else ;
            addr++;
        }
        else{
            if(addr==0) n=6;
            else if(s1[addr-1]==s2[addr-1]) n=(n*2)%M;
            else n=(n*3)%M;
            addr+=2;
        }
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256