akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		char[][] caa = new char[3][];
		caa[0] = next().toCharArray();
		caa[1] = next().toCharArray();
		caa[2] = next().toCharArray();
		int result = 0;
		int[] dif = new int[3];
		for(int i = 0; i < n; i++) {
			Set<Character> tmps = new HashSet<>();
			for(int j = 0; j < 3; j++) {
				tmps.add(caa[j][i]);
			}
			result += tmps.size() - 1;
		}
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 21332
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int count = 0;
			for(int i=0; i < 10; i++){
				for(int j=0; j < 10; j++){
					for(int k=0; k < 10; k++){
						int l = n - i - j - k;
						if(0 <= l && l <= 9){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 12000
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    bs = scanl modAdd 0 as :: [Int]
  print . foldl modAdd 0 $ zipWith modMul bs as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  long long ans = lcm(n, m);
  unordered_map<long long, char> mp;
  for (int i = 0; i < n; i++) {
    mp[1 + ans / n * i] = s[i];
  }
  bool ok = true;
  for (int i = 0; i < m; i++) {
    if (mp.count(1 + ans / m * i)) {
      if (mp[1 + ans / m * i] != t[i]) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    cout << ans << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define prime 31
#define mp make_pair
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
int main()
{
	double d,t,s;
	cin>>d>>t>>s;
	double tym=d/s;
	if(tym>t)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}

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

int main() {
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  vector<long long> cap(5);
  cap.at(0) = A;
  cap.at(1) = B;
  cap.at(2) = C;
  cap.at(3) = D;
  cap.at(4) = E;
  long long lim = A;
  for (int i = 1; i < 5; i++){
    if(lim > cap.at(i)){
      lim = cap.at(i);
    }
  }
  long long time = (N - 1) / lim + 1;
  cout << time + 4 << endl; 
}


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

int main() {
  string N;cin>>N;
  int X=0;
  int l=N.size();
  for(int i=0;i<l;i++) X+= N.at(i)-'0';
  if(X%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(void){
	int h,n,a;

	cin>>h>>n;

	for(int i=0;i<n;i++){
		cin>>a;
		h-=a;
	}

	if(h<=0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
const int maxn=20;
const double eps=1e-9;
const double INF=1e265;
const double pi=acos(-1);
double p[maxn],h[maxn];
int n;
int sgn(double v)
{
	if(abs(v)<eps)return 0;
	else return v<0?-1:1;
}
void cal(double x1,double x2,double h2,double x3,double &a,double &b)
{
	x2-=x1;
	x3-=x1;
	a=h2/x2/(x2-x3);
	b=-a*x3;
}
bool check(int b,double d,double &tmpv)
{
	double A,B,maxA,angle,maxangle=-2*pi;
	double xl,xr;
	int k,j=0;
	tmpv=INF;
	xl=0,xr=d/(b+1);
	for(k=0;k<=b;k++)
	{
		//cout <<xl<<" "<<xr<<" "<<p[j]<<endl;
		for(;p[j]<xr+eps&&j<n;j++)
		{
			if(sgn(xl-p[j])==0||sgn(xr-p[j])==0)return false;
			cal(xl,p[j],h[j],xr,A,B);	
			//cout <<A<<" "<<B<<endl;
			angle=atan(B);
			//cout <<angle<<" "<<pi/4<<endl;
			if(sgn(maxangle-angle)<=0)
			{
				maxangle=angle;
				maxA=A;
			}
		}
		xl=xr;
		xr+=d/(b+1);
	}
	if(maxangle<pi/4)tmpv=sqrt(d/(b+1));
	else tmpv=sqrt(-1.0/(2*cos(maxangle)*cos(maxangle)*maxA));
	//cout <<b<<" "<<maxangle<<" "<<pi/4<<" "<<d<<" "<<tmpv<<endl;
	return true;
}
int main()
{
	int b,i;	
	double d,angle,v;
	double ansv=INF,tmpv;
	scanf("%lf %d %d",&d,&n,&b);
	for(i=0;i<n;i++)
		scanf("%lf %lf",&p[i],&h[i]);
	for(i=0;i<=b;i++)
		if(check(i,d,tmpv))ansv=min(ansv,tmpv);
	printf("%.6f\n",ansv);
	return 0;
}

Measured memory_bytes: 1296
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    cout << a + b << endl;
    return 0;
}

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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var n = ReadLong();
		var c = new int[4];

		for (var i = 0; i < n; i++) {
			var s = Console.ReadLine();
			if (s == "AC") c[0]++;
			if (s == "WA") c[1]++;
			if (s == "TLE") c[2]++;
			if (s == "RE") c[3]++;
		}

		Console.WriteLine("AC x " + c[0]);
		Console.WriteLine("WA x " + c[1]);
		Console.WriteLine("TLE x " + c[2]);
		Console.WriteLine("RE x " + c[3]);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);

    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < m; ++i)
        cin >> b[i];

    for (int i = 1; i < n; ++i)
        a[i] += a[i - 1];
    for (int i = 1; i < m; ++i)
        b[i] += b[i - 1];

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] > k)
            break;
        ans = max(ans, i + 1ll);
        int nxt =  upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        ans = max(ans, i + nxt + 1ll);
    }
    for (int i = 0; i < m; ++i) {
        if (b[i] > k) break;
        ans = max(ans, i + 1ll);
    }
    cout << ans << endl;

}


Measured memory_bytes: 6320
#include <stdio.h>
#include <math.h>
int main(){
  int n,k,x,r=0;
  for(scanf("%d%d",&n,&k);n;n--){
    scanf("%d",&x);
    if(x>k/2)r+=abs(x-k);
      else r+=x;
  }
  printf("%d",r*2);
  return 0;
}


Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f[2000][2000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	ans = n;
	queue<Pll>qu;
	qu.push(Pll(1,1));
	rep(i, 110000)dp[i] = INF;
	while (!qu.empty()) {
		Pll num = qu.front();
		qu.pop();
		if (dp[num.fir] <= num.second)
			continue;
		dp[num.fir] = num.sec;
		if (ans <= num.second)
			continue;
		if (num.first == 0) {
			ans = min(ans, num.second);
		}
		else {
			qu.push(Pll((num.first * 10) % n, num.second));
			qu.push(Pll((num.first + 1) % n, num.second + 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// practice contest

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int x = a - b;
		if (x <= c) {
			System.out.println(c - x);
		}
		if (x > c) {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 21844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N;
	string s;
	if (N < 1000) {
		for (int i = 0; i < 3; i++) {
			s.push_back(N % 10);
			N /= 10;
		}
		reverse(s.begin(), s.end());
		cout << "ABC" << endl;
	}
	else {
		N-=999;
		for (int i = 0; i < 3; i++) {
			s.push_back(N % 10);
			N /= 10;
		}
		reverse(s.begin(), s.end());
		cout << "ABD"  << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))
a = sorted(a)

aMax = a[-1]
l = len(a)
count = 0
k = 0
kSet = set()

for i in range(n):
    value = a[i]
    if not(value in kSet):
        if i != 0 and a[i-1] == value:
            count -= 1
            kSet.add(value)
            continue
        count += 1
        j = 2
        k = 0
        while k < aMax:
            k = a[i] * j
            kSet.add(k)
            j += 1

print(count)

Measured memory_bytes: 86292
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string s1, s2;
	string ss, ss1, ss2;
	int l = s.length();
	s1 = s.substr(0, (l - 1) / 2);
	s2 = s.substr((l + 3) / 2 - 1, (l - (l + 3) / 2) + 1);
	ss = s;
	ss1 = s1;
	ss2 = s2;
	reverse(s.begin(), s.end());
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	if (s==ss&&s1==ss1&&ss2==s2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
S = []
N.times do
    S << gets.chomp
end
h = S.each_with_object(Hash.new(0)) {|s, hash| hash[s] += 1}
max = h.max_by{|k, v| v}[1]
puts h.select{|k, v| v == max}.keys.sort

Measured memory_bytes: 59240
N=int(input())
task=[[]]*N
for i in range(N):task[i]=list(map(int,input().split()))
task.sort(key=lambda x: x[1])
t=0
for i in range(N):
    t+=task[i][0]
    if task[i][1]<t:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 46852
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

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

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

int main() {
	int a, b, c, x, y, ret=2e+9;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	REP(i, max(x, y)+1) {
		ret = min(ret, 2 * c*i + a*max((x - i),0) + b*max((y - i),0));
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

bt, bx, by = 0, 0, 0
cond = True
for i in range(n):
    t, x, y = [int(w) for w in input().split()]
    dt = t-bt
    dist = abs(bx-x)+abs(by-y)
    if dt >= dist and (dt-dist) % 2 == 0:
        bt, bx, by = t, x, y
        continue
    cond = False


print("Yes" if cond else "No")


Measured memory_bytes: 9172
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if(S.equals("ABC")){
      System.out.println("ARC");
    }
    else if(S.equals("ARC")){
      System.out.println("ABC");
    }
    else{
      System.out.println("エラー");
    }
  }
}

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

int main(){
  int n, y;
  cin >> n >> y;
  int a, b, c; //a:10000 b:5000 c:1000
  int buf;
  bool judge = false;
  for(a = n; a >= 0 && judge == false; a--){
    for(b = 0; b <= n - a && judge == false; b++){
      c = n - a - b;
      judge = (y == 10000 * a + 5000 * b + 1000 * c);
    }
  }
  a++;
  b--;
  if(judge == false){
    a = -1;
    b = -1;
    c = -1;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int sum = 0;
	rep(i, n) sum += a[i];

	int ans = n - sum;
	if (ans >= 0) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 7156
<?php
/*
    http://agc006.contest.atcoder.jp/tasks/agc006_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);
$p = explode(" ", trim(fgets(STDIN)));

$arr = array();

foreach ($p as $k => $v) {
	$arr[$v-1] = $k;
	$arr1[$k] = 0;
	$arr2[$k] = 0;
}

ksort($arr);
// var_dump($arr);


// var_dump($arr1);
// var_dump($arr2);
// exit;


for ($i = 0; $i < $N - 1; $i++) {
	if ($arr[$i] < $arr[$i+1]) {
		// echo "A";
		$arr1[$i] = abs($arr[$i] - $arr[$i+1]);
	} else {
		// echo "B";
		$arr2[$i] = abs($arr[$i] - $arr[$i+1]);
	}
}
// var_dump($arr1);
// var_dump($arr2);
$num1[0] = 1;
$num2[$N-1] = 1;

for ($i = 1; $i < $N; $i++) {
	$num1[$i] = $num1[$i-1] + $arr1[$i-1] + 1;
}

for ($i = $N-2; $i >= 0; $i--) {
	$num2[$i] = $num2[$i+1] + $arr2[$i] + 1;
}

ksort($num1);
ksort($num2);
// var_dump($num1);
// var_dump($num2);

echo implode(" ", $num1) . PHP_EOL;
echo implode(" ", $num2) . PHP_EOL;


Measured memory_bytes: 10360
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 110000
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll dp[MAX][5];
ll dfs(ll start,vector<ll>* adj,bool* visited,ll pcolor){
	if(dp[start][pcolor]!=-1) return dp[start][pcolor];
	visited[start]=1;
	ll t1=1,t2=1;
	if(pcolor==0) t2=0;
	for(ll x:adj[start]){
		if(!visited[x]){
			ll first = dfs(x,adj,visited,1);
			t1 = (t1*first)%Mod;
			ll second=0;
			if(pcolor!=0) second=dfs(x,adj,visited,0);
			t2 = (t2*second)%Mod;
		}
	}
	visited[start]=0;
	dp[start][pcolor]=(t1+t2)%Mod;
	return (t1+t2)%Mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	ll n;cin>>n;
	vector<ll> adj[n];
	For(i,0,n-1) {
		ll u,v;cin>>u>>v;u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	bool visited[n];
	visited[0]=1;
	memset(visited,0,sizeof(visited));
	cout<<dfs(0,adj,visited,3)<<endl;
}

Measured memory_bytes: 18432
n,X = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)

# 出発点と都市の座標をソートして差分の配列dをつくる
x.push(X).sort!
d = (1..x.size-1).map{|i|x[i]-x[i-1]}

# 2つの数の最小公倍数を求める
def gcd(a,b)
    a,b = b,a%b while b != 0
    return a
end

# 3つ以上の数の最小公倍数を求める
def gcd_multi(array)
    array.inject{|a,b|gcd(a,b)}
end

# 配列dの最小公倍数を求める
p gcd_multi(d)

Measured memory_bytes: 11376
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
#define NUM 10
using namespace std;

int ans(int, int);
bool next_combination(bool *, int);

int main()
{
	int n, s;
	while(cin >> n >> s){
		cout << ans(n, s) << endl;
	}
	return 0;
}

bool next_combination(bool *p, int N)	//N = 10
{
	int i, c;
	i = N-1, c = 0;
	while(p[i]) c++, p[i] = false, i--;
	while(!p[i]){
		if(i > 0) i--;
		else return false;
	}
	p[i] = false;
	c++, i++;
	for(int j=0; j<c; j++) p[i+j] = true;
	return true;
}

int ans(int n, int s)
{
	int min, max, ret = 0;
	bool p[NUM] = {0};

	min = max = 0;
	for(int i=1; i<=n; i++){
		min += i*(n-i);
		max += i*(NUM-1-n+i);
	}
	if(s < min || max < s) return 0;

	for(int i=0; i<n; i++) p[i] = true;

	do{
		vector<int> pairs;

		for(int i=0; i<NUM; i++)
			if(p[i]) pairs.push_back(i);

		do{
			int sum = 0;
			for(int i=0; i<pairs.size(); i++) sum += (i+1) * pairs[i];
			if(sum == s) ret++;
		}while(next_permutation(pairs.begin(), pairs.end()));
		
	}while(next_combination(p, NUM));

	return ret;
}

Measured memory_bytes: 1216
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
MOD = 10**9+7
# MOD = 998244353

n, m, x = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]

min_val = float("inf")
for i in range(1<<n):
    hon = [0]*m
    val = 0
    for j in range(n):
        if (i>>j) & 1:
            val += A[j][0]
            for k in range(m):
                hon[k] += A[j][k+1]

    if all([hon[t] >= x for t in range(m)]):
        min_val = min(min_val, val)

if min_val == float("inf"):
    print(-1)
else:
    print(min_val)


Measured memory_bytes: 69604
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] t = new int[N];
   for(int i=0;i<N;i++)  t[i] = sc.nextInt();
   
   int[] forans =new int[3];
   for(int i=0;i<N;i++) 
   {
     if(t[i]%4==0) forans[0]++;
     else if(t[i]%2==0) forans[1]++;
     else forans[2]++;
   }
   String ans ="";
   if(forans[1]==0)
   {
     if(forans[0]+1>=forans[2]) ans = "Yes";
     else ans = "No";
   }
   else
   {
     if(forans[0]>=forans[2]) ans = "Yes";
     else ans = "No";
   }
   System.out.println(ans);
 }
}

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

int main() {
  string a,b;
  cin >> a >> b;
  ll ans = 0;
  for (int i = 0; i<a.size(); i++){
    if (a[i] != b[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 


int main()
{
    long N,M;
    std::cin >> N >> M;
    long A[1000000];
    for(long i=0; i<M; i++){
        std::cin >> A[i];
    }

    long sum=0;
    for(long i=0; i<M; i++){
        sum+=A[i];
    }
    if(N<sum){
        std::cout << -1 << std::endl;
    }else{
        std::cout << N-sum << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
vector< pi > v;
int main() {

  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
   int n,m;
   cin >> n >> m;
   int a,b;
   for(int i = 0; i <  n; i++)
   {
   		cin >> a >> b;
   		v.pb(mp(a,b));
   }
   sort(v.begin(), v.end());
   ll done = 0;
   ll fans = 0;
   int ptr = 0;
   while(done < m)
   {
   		int take = v[ptr].S;
   		take = min((m - done)*1ll , take * 1ll);
   		fans += v[ptr].F * 1ll * take;
   		done += take;
   		ptr++;
   }

   cout << fans << '\n';
   return 0;
}

Measured memory_bytes: 1400
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
h = inpl()
ans = 0
cnt = 0

for i in range(1,n):
    if h[i] > h[i-1]:
        ans = max(ans,cnt)
        cnt = 0
        tmp = h[i]
    else:
        cnt += 1
ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 15536
#include <iostream>
#include <vector>

using namespace std;


int main()
{
    vector<bool> alice(101,false);
    vector<bool> bob(101,false);

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    for(int i=a;i < b;i ++)
    {
        alice[i] = true;
    }
    for(int i=c;i < d;i ++)
    {
        bob[i] = true;
    }

    int count = 0;
    for(int i=0;i < 101;i ++)
    {
        if(alice[i] && bob[i])
        {
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import math

A,B=map(int,input().split())
p=[]

for k in range(len(bin(B))-2):
	a = (A >> k) & 1
	b = (B >> k) & 1

	if k == 0:
		if a ^ b == 1:
			p.insert(0, ((B-A+1)//2)%2)
		else:
			p.insert(0, (((B-A+1)//2)%2+a)%2)
	else:
		if a == 0 and b == 0:
			p.insert(0, 0)
		elif a == 1 and b == 1:
			p.insert(0, (A+B+1)%2)
		elif a == 1:
			p.insert(0, A % 2)
		else:
			p.insert(0, (B+1) % 2)

print(int("".join(map(str, p)), 2))


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n-1);
    for(int i = 0;i <n-1;i++){
        cin >> a[i];
    }
    vector<int> b(n+1,0);
    for(int i = 0;i <n;i++){
        int k = a[i];
        b[k]++;
    }
    for(int i = 1;i <n+1;i++){
        cout << b[i] << endl;
    }
}


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

Bsum = sum(A)
oddsum = 0
for i in range(0,N,2):
    oddsum += A[i]*2
B = []
B.append(oddsum-Bsum)
for i in range(N-1):
    B.append(2*A[i]-B[i])

for e in B:
    print(e, end=" ")


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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> good(n, true);
  for (auto&& e : h) {
    cin >> e;
  }
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (h[a] == h[b]) {
      good[a] = false;
      good[b] = false;
    } else if (h[a] > h[b]) {
      good[b] = false;
    } else {
      good[a] = false;
    }
  }
  int ans = 0;
  for (auto&& e : good) {
    ans += e;
  }
  cout << ans << '\n';
  return 0;
}


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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;

int main()
{
	fast();
	int n;
	string s;
	ll r = 0, g = 0, b = 0;
	cin >> n >> s;
	for(char c: s){
		if(c == 'R') r++;
		if(c == 'B') b++;
		if(c == 'G') g++;
	}
	ll ans = (ll) (r * b  * g);
	for(int i = 0; i < n; ++i){
		for(int j = 1; i + j + j < n; ++j){
			if((s[i] ^ s[i + j] ^ s[i + j + j]) == ('R' ^ 'G' ^ 'B')) ans--;
		}
	}
	cout << ans;
}



Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
map<string,int> dp;
int direction[] = {1,-1,4,-4};

void bfs()
{
	queue<string> que;
	que.push("01234567");
	dp["01234567"] = 0;
	while(!que.empty()){
		string now = que.front();
		que.pop();
		int p = 0;
		for(int j = 0; j < 8; j++){
			if(now[j] == '0'){
				p = j;
				break;
			}
		}
		for(int i = 0; i < 4; i++){
			int n = p + direction[i];
			if(0 <= n && n < 8 && !(p == 3 && i == 0) && !( p ==4 && i == 1)){
				string next = now;
				swap(next[p], next[n]);
				if(dp.find(next) == dp.end()){
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}

int main()
{
	bfs();
	string line;
        while(getline(cin,line)){
		line.erase(remove(line.begin(),line.end(),' '), line.end());
		cout<<dp[line]<<endl;
	}
	return 0;
}



Measured memory_bytes: 5328
using System;

namespace A_Subscribers2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int A = int.Parse(s[1]);
            int B = int.Parse(s[2]);

            int Max;
            int Min = A + B - N;

            if (Min < 0)
                Min = 0;

            if(A>B)
            {
                Max = B;
            }
            else
            {
                Max = A;
            }

            Console.WriteLine(Max.ToString() + " " + Min.ToString());

        }
    }
}


Measured memory_bytes: 11092
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,ans=0;
  std::cin>>n;

  std::vector<std::string> s(n);

  rep(i,0,n){
    std::cin>>s[i];
    s[i]+=s[i];
  }

  rep(i,0,n){
    bool flag=true;
    rep(j,0,n){
      rep(k,j,n){
        if(s[j][k+i]!=s[k][j+i]){
          flag=false;
          break;
        }
      }
      if(!flag)break;
    }
    if(flag)ans++;
  }

  std::cout<<ans*n;

  return 0;
}


Measured memory_bytes: 512
#coding: UTF-8

import sys
import math

class Algo:
  @staticmethod
  def bubbleSort(r, n):
    flag = 1
    count = 0
    while flag:
      flag = 0
      for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
          r[j], r[j-1] = r[j-1], r[j]
          count += 1
          flag = 1

    for i in range(0, n):
      if i == n-1:
        print(r[i])
      else:
        print(r[i], " ", sep="", end="")
    print(count)

N = int(input())
R= list(map(int, input().split()))
Algo.bubbleSort(R, N)

Measured memory_bytes: 5676
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  long long H,W;
  cin >> H >> W;
  
  int h=H%2;
  int w=W%2;
  
  if(H==1||W==1){
    cout<<1<<endl;
  }
  else{
    cout<<(H*W+1)/2<<endl;
  }
}

Measured memory_bytes: 3548
import java.util.Scanner;
//import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        double[] a = new double[n];
        for(int i = 0;i < n;i++){
            a[i] = stdIn.nextDouble();
            a[i] = 1 / a[i];
        }
        double x = 0;
        for(int i = 0;i < n;i++){
            x += a[i];
        }
        System.out.println(1 / x);
        
        
    }

}

Measured memory_bytes: 25172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {

            List<int> h = new List<int>();

            TextReader input = Console.In;

            string str = "";

            // データを入れる
            while ((str = input.ReadLine()) != null) {
                int work = 0;
                if (!int.TryParse(str, out work)) {
                    continue;
                }
                h.Add(work);
            }

            // ソート
            h.Sort(delegate(int a, int b) { return b.CompareTo(a); });
            // 出力
            Console.WriteLine(h[0]);
            Console.WriteLine(h[1]);
            Console.WriteLine(h[2]);
        }
    }
}

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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string s;
  cin >> N >> s;
  int count = 0;
  char pre_c = '0';
  for (int i = 0; i < s.size(); i++) {
    if (pre_c != s[i]) {
      count++;
      pre_c = s[i];
    }
  }
  cout << count << endl;
}


int main() {
  answer1();
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int sum = a+b+c;
    int max = Math.max(Math.max(a,b),c);
    int min = Math.min(Math.min(a,b),c);
    int middle = sum-max-min;
    int count = 0;
    if((3*max)%2 != sum%2) {
      max++;
      count++;
      sum++;
    }
    count+=(3*max-sum)/2;
    
    System.out.println(count);
  }
}

Measured memory_bytes: 32696
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
string s,t;

void solve(){
    cin>>s>>t;
    if(s.size()>80 or t.size()>80){
        cout << "overflow" << endl;
        return;
    }
    if(s.size() > t.size()){
        while(s.size()>t.size()) t = "0" + t;
    }
    if(s.size() < t.size()){
        while(s.size()<t.size()) s = "0" + s;
    }
    reverse(all(s));
    reverse(all(t));
    string ans(s.size(),'0');
    int over=0;
    for(int i=0;i<s.size();i++){
        int ss = s[i]-'0';
        int tt = t[i]-'0';
        int a = ss + tt + over;
        over = a/10;
        a %= 10;
        ans[i] = a+'0';
    }
    if(over>0){ ans.push_back('0'+over); }
    reverse(all(ans));
    if(ans.size()>80){
        cout << "overflow" <<endl;
        return;
    }
    cout << ans << endl;
}

int main(){
    int N;
    cin >> N;
    rep(i,N) solve();
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
long long qwerty[500001];
long long a[500001],b[500001];
int main()
{
    int n;
    cin>>n;
    long long ma=0,mi=0;
    priority_queue<long long> miq;
    priority_queue<long long, vector<long long>, greater<long long> > maq;
    for(int i=1;i<=3*n;i++)
	{
        cin>>qwerty[i];
        if(i<=n)
		{
            ma+=qwerty[i];
            maq.push(qwerty[i]);
        }
        else if(i>2*n)
		{
            mi+=qwerty[i];
            miq.push(qwerty[i]);
        }
    }
    a[n]=ma;
    for(int i=n+1;i<=2*n;i++) 
	{
        long long lk=maq.top();
        if(lk<qwerty[i])
		{
            ma+=qwerty[i]-lk;
            maq.pop();
            maq.push(qwerty[i]);
        }
        a[i]=ma;
    }
    b[2*n]=mi;
    for(int i=2*n-1;i>=n;i--)
	{
        long long po=miq.top();
        if(po>qwerty[i+1])
		{
            mi+=qwerty[i+1]-po;
            miq.pop();
            miq.push(qwerty[i+1]);
        }
        b[i]=mi;
    }
    long long res=a[n]-b[n];
    for(int i=n+1;i<=2*n;i++)
        res=max(res,a[i]-b[i]);
    cout<<res;
    return 0;
}

Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, R;
    cin >> N >> R;

    if(N >= 10) cout << R << endl;
    else cout << R + (100 * (10 - N)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n; cin>>n;
  string a="Sunny",b="Cloudy",c="Rainy";
  if(n==a)cout<<b<<endl;
  if(n==b)cout<<c<<endl;
  if(n==c)cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
 
void solve()
{
    ll n;cin>>n;
    if(IsPrime(n)){cout<<n-1<<endl;return;}
    for(ll i=sqrt(n);i>1;i--)
        if(n%i==0){cout<<i+n/i-2<<endl;return;}
    
}

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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String A = scanner.next();
        if (A.indexOf("AC") != -1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 22996
n = gets.to_i

ary = Array.new
cnt = 0

while line = $stdin.gets
    
    cnt += 1
    aa = Array.new
    bb = line.chomp.split
    aa << bb[0] << bb[1].to_i <<  cnt.to_i
    ary << aa

    break if cnt == n
end

ary.sort! { |a, b| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1])}
ary.each  { |a, b, c| puts c.to_i }


Measured memory_bytes: 1788
#include<stdio.h>

int main(){

  int sum=0,n,y,i2,m,j,d,a,b,ans,da,da2,i; 

  scanf("%d",&n);

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

    scanf("%d %d %d",&y,&m,&d);

    da=333*200+666*195;

    for(j=1;j<y;j++){
      if(j%3==0){
	sum+=200;
      }
      else{
	sum+=195;
      }
    }
    if(y%3==0){
      sum+=(m-1)*20;
    }
    else{
      for(i2=1;i2<m;i2++){
	if(i2%2==1){
	  sum+=20;
	}
	else{
	  sum+=19;
	}
      }
    }
    sum+=d;
      ans = da - sum+1;
      printf("%d\n",ans);
      sum=0;
  }
  return 0;
}

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

int main() {
	int N;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		char S;

		cin >> S;
		if (S == 'Y')
		{
			cout << "Four" << endl;
			return (0);
		}
	}
	cout << "Three" << endl;
}


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

int main(){
	string s;
	while(cin>>s,s!="0"){
		int a,b;
		a=b=0;
		for(int i=1;i<s.size();i++){
			if(s[i]=='A') a++; else b++;
		}
		if(a>b) a++; else b++;
		cout<<a<<" "<<b<<endl;
		
	}
}

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

int main() {
  int n;
  cin >> n;
  int m = n % 10;
  if (m == 3) {
    cout << "bon";
  } else if (m == 0 || m == 1 || m == 6 || m == 8) {
    cout << "pon";
  } else {
    cout << "hon";
  }
}

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

void init(int* a) {
	for (int i = 0;i < sizeof(a)/sizeof(int);i++) {
		a[i] = 0;
	}
}
 
int main() {
	int n;
	long long int ans = 0;
	long mch[5];
	cin >> n;
	string name[n];
	for (int i = 0;i < 5;i++) {
		mch[i] = 0;
	}
	for (int i = 0;i < n;i++) {
		cin >> name[i];
		if (name[i][0] == 'M') {mch[0]++;}
		if (name[i][0] == 'A') {mch[1]++;}
		if (name[i][0] == 'R') {mch[2]++;}
		if (name[i][0] == 'C') {mch[3]++;}
		if (name[i][0] == 'H') {mch[4]++;}
	}
	for (int i = 0;i < 5;i++) {
		for (int j = i + 1;j < 5;j++) {
			for (int k = j + 1;k < 5;k++) {
				ans += mch[i] * mch[j] * mch[k];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6264
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    map <int,bool>mp;
    int a,b,c; 
    cin>>a>>b>>c;
    int s=a;
    for (int i=a;i;i+=a){
        s=i;
        if (s%b==c) break;
        if (mp[s%b]){
            cout << "NO" << endl;
            return ;
        }
        mp[s%b] = true;
    }
    cout << "YES" << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

n=int(input())
list1=[]
for i in range(n):
    a=list(input().split())
    a[1]=int(a[1])
    a.append(i)
    list1.append(a)

    

list1.sort(reverse=True,key=itemgetter(1))
list1.sort(key=itemgetter(0))

for i in range(n):
    print(list1[i][2]+1)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m, a[MAX_N];
    bool p[MAX_N]{};
    cin >> n >> m;
    REP(i,n+1)a[i] = 1;
    p[1] = true;
    REP(i,m){
        int x, y;
        cin >> x >> y;
        if(p[x])p[y] = true;
        a[x]--;
        a[y]++;
        if(!a[x])p[x] = false;
    }
    int ans = 0;
    REP(i,n+1)ans += p[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
N,X,Y = map(int,input().split(sep=" "))
root = []
X = X-1
Y = Y-1
sumRoot = [0 for i in range(0,N-1,1)]
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if j - i < abs(i-X)+abs(j-Y)+1:
            sumRoot[j-i-1] += 1
        else:
            sumRoot[abs(i-X)+abs(j-Y)] += 1
for k in range(0,N-1,1):
    print(sumRoot[k])


Measured memory_bytes: 46524
// Ami_Nafi SONNASI <3
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
typedef long long ll;
const int M = 1e5 + 20, MOD = 1e9 + 7;

int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    string s;
    cin >> s;
    int x = s.length();
    x /= 2;
    int cnt = 0;
    int ln = s.length() - 1;
    for (int i = 0; i < x; i++) {
        if (s[i] != s[ln - i]) cnt++;
    }
    cout << cnt << endl;
return 0;
}


Measured memory_bytes: 256