akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 1000050

int conta[N];
int n, m, q, k, v[N], ans;
int ini[N];
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int i = 1; i <= n; i++){
		cin>>v[i];
		ini[v[i]] ++;
	}

	for(int i = 1; i < N; i++){
		for(int j = i; j < N; j += i)
			conta[j] += ini[i];
	}

	for(int i = 1; i <= n; i++){
		if(conta[v[i]] <= 1) ans ++;
	}
	cout<<ans<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

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

double dist(double x, double y) {
	double ans = sqrt(x * x + y * y);
	return ans;
}

int main() {
	int n, d;
	cin >> n >> d; int ans = 0;
	while (n--) {
		double x, y;
		cin >> x >> y;
		if (dist(x, y) <= d) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3836
#include <stdio.h>
#define N 10000
#define Q 500
main(){
  int n,q,s[N],t[Q];
  int i,j,count=0;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&s[i]);

  scanf("%d",&q);
  for(i=0;i<q; i++)
    scanf("%d",&t[i]);


  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(t[i]==s[j]){
	count++;
break;
}
    }
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]

def helper(s):
  d = {}
  for c in s:
    if c not in d:
      d[c] = 0
    d[c] += 1
  
  return d

def pairs(n):
    return int(n * (n - 1) / 2)

d = {}
for s in S:
  if s not in d:
    d[s] = 0
  d[s] += 1

ans = sum([pairs(v) for v in d.values() if v > 1])
  
print(ans)



Measured memory_bytes: 19400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(z) (z).begin(),(z).end() 
#define MOD 1000000007
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll isprime(ll n)
{
	for(int i=2;i<n;i++)
		if(n%i==0)
		return 0;
		
	return 1;	
}
int main()
{ 
    FAST;
	string s;
	cin>>s;
	ll cnt=0;
	for(int i=0;i<s.size()/2;i++)
	{
		if(s[i]!=s[s.size()-1-i])cnt++;
	}
	cout<<cnt;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i * i <= x; i++){
        int t = i * i;
        while(t <= x){
            ans = max(ans, t);
            t *= i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

from itertools import product
ptns = list(product([0,1,2,-1], repeat = n))

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)

Measured memory_bytes: 10996
import java.util.Scanner;

public class Main {

	private static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(System.getProperty("line.separator"));
		int n = sc.nextInt();
        String aStr = sc.next();
        int[] s = toIntAry(aStr, n);

        int[] ret = mergeSort(s,0,n);

        for (int i = 0; i < ret.length; i++) {
        	if(i==ret.length-1){
        		System.out.println(ret[i]);
        	}else{
        		System.out.print(ret[i] + " ");
        	}

		}
        System.out.println(count);

	}




	private static int[] mergeSort(int[] A, int left, int right) {
		if(left+1 < right){
			int mid = (left+right)/2;
			mergeSort(A,left,mid);
			mergeSort(A, mid, right);
			merge(A,left,mid,right);
		}

		return A;

	}




	private static void merge(int[] a, int left, int mid, int right) {
		final int MAX = 2147483647;
		int n1 = mid - left;
		int n2 = right -mid;
		int[] l1 = new int[n1+1];
		int[] r1 = new int[n2+1];
		for(int i=0; i<n1; i++){
			l1[i] = a[left+i];
		}
		for(int i=0; i<n2; i++){
			r1[i] = a[mid+i];
		}
		l1[n1] = MAX;
		r1[n2] = MAX;
		int i=0;
		int j=0;
		for(int k=left; k<right; k++){
			if(l1[i] <= r1[j]){
				a[k] = l1[i];
				i++;
				count++;
			}else{
				a[k] = r1[j];
				j++;
				count++;
			}
		}
	}




	private static int[] toIntAry(String str, int n) {
        String[] tmp = str.split(" ");
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(tmp[i]);
		}
        return A;
	}


}

Measured memory_bytes: 137612
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x,y,ans=0; cin >> x >> y;
	if (abs(x)>abs(y)) {
		if (x>0) {
			ans++;
			x = -x;
		}
		ans += abs(x)-abs(y);
		x = -abs(y);
		if (x != y) ans++;
	} else {
		if (x<0) {
			ans ++;
			x = -x;
		}
		ans += abs(y)-abs(x);
		x = abs(y);
		if (x != y) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1e9+7;



int main() {
	ll n;
	cin >> n;
	ll k = sqrt(n-1);
	vector<ll> v;
	repd(i,1, k+1) {
		v.push_back((n-1) / i);
	}
	ll ans = 0;
	rep(i, v.size()) {
		ans += (v[i]-i);
	}
	cout << ans * 2 - k << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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 namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    ll res = 1;
    int i;
    int pre;
    if (s1[0] == s2[0]) {
        i = 1;
        pre = 0;
        res = 3;
    } else {
        i = 2;
        pre = 1;
        res = 6;
    }

    for(i; i < n;) {
        cerr << i << " ";
        if (s1[i] == s2[i]) {
            i++;
            if (pre == 0) {
                res *= 2;
                res %= MOD;
                pre = 0;
            } else {
                res *= 1;
                res %= MOD;
                pre = 0;
            }
        } else {
            i+=2;
            if (pre == 0) {
                res *= 2;
                res %= MOD;
                pre = 1;
            } else {
                res *= 3;
                res %= MOD;
                pre = 1;
            }
        }
        cerr << res << endl;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3608
import sys
from itertools import combinations

n, *lll = map(int, sys.stdin.buffer.read().split())
ans = 0
for i, j, k in combinations(lll, 3):
    if i == j or j == k or k == i:
        continue
    l = max(i, j, k)
    if (i + j + k - l) > l:
        ans += 1
print(ans)


Measured memory_bytes: 9168
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;
lli dp[51][51][2501];

int main(void)
{
	int N, A; cin >> N >> A;
	vector<int> x(N); rep(i, 0, N)cin >> x[i];
	dp[0][0][0] = 1;

	rep(i, 0, N) {
		rep(j, 0, i+1) {
			rep(k, 0, 2500) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
			}
		}
	}

	lli ans = 0;
	rep(i, 1, N + 1)ans += dp[N][i][i*A];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 49152
n = int(input())
t_score = 0
h_score = 0

for i in range(n):
    t_card, h_card = input().split()
    if t_card < h_card:
        h_score += 3
    elif t_card > h_card:
        t_score += 3
    else:
        h_score += 1
        t_score += 1

print(t_score, h_score)


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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    ll ans = 0;
    REP(i, N) REP(j, N) ans = max(ans, (ll)abs(A[i]-A[j]));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  n = n*n*n;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int w, h, x, y, ans2;
double ans1;

int main() {
    scanf("%d %d %d %d", &w, &h, &x, &y);
    ans1 = (double)w * (double)h * 0.5;
    ans2 = 0;
    
    if ( ( w == x * 2 ) and ( h == y * 2 ) ) {
        ans2 = 1;
    } else {
        ans2 = 0;
    }

    printf("%f %d\n", ans1, ans2);
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
const int inf = 99999;
int A, B;
int d[11][11];
vector<piii> E;

int main(){
    scanf("%d%d",&A,&B);
    for(int i=1;i<=A;i++){
        for(int j=1;j<=B;j++){
            scanf("%d", &d[i][j]);
        }
    }
    for(int a=0;a<100;a++){
        for(int b=0;b<100;b++){
            int c = -1;
            for(int x=1;x<=A;x++){
                for(int y=1;y<=B;y++){
                    c = max(d[x][y] - a*x - b*y, c);
                }
            }
            if (c >= 0 && c <= 100)E.emplace_back(pii(a,b),c);
        }
    }
    for(int i=1;i<=A;i++){
        for(int j=1;j<=B;j++){
            int mn = inf;
            for(auto e : E){
                mn = min(mn, e.first.first * i + e.first.second * j + e.second);
            }
            if(mn != d[i][j]){
                puts("Impossible");
                return 0;
            }
        }
    }
    puts("Possible");
    printf("%d %d\n", 200, (int)E.size() + 198);
    for(int i=1;i<100;i++){
        printf("%d %d X\n", i, i+1);
    }
    for(int j=101;j<200;j++){
        printf("%d %d Y\n", j+1, j);
    }
    for(auto e : E){
        int a = e.first.first;
        int b = e.first.second;
        int c = e.second;
        printf("%d %d %d\n", 1+a, 101+b, c);
    }
    printf("%d %d\n", 1, 101);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll N;
  cin>>N;
  vector <vector<ll>> a(N,vector <ll> (2));
  for(int i = 0;i<N;i++){
    cin>>a[i][0];
    a[i][1] = i;
  }
  ll ans = 0;
  sort(a.begin(),a.end());
  for(ll i = 0;i<N;i++){
    if((i%2) != (a[i][1]%2)){
      ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int n,l;
	cin >> n >> l;
	string arr[n];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;i++)
		cout << arr[i];
}

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

const int MOD = 1e9 + 7;
long long dp[45][(2 << 18) - 1];
long long all, mx, ledge, ans;
int x, y, z, n;

long long pow_mod (int b, int k)
{
	long long ans = 1, base = b % MOD;
	while (k)
	{
		if (k & 1)
			ans = (ans * base) % MOD;
		base = (base * base) % MOD;
		k >>= 1;
	}
	return ans;
}

int main()
{
	scanf ("%d%d%d%d", &n, &x, &y, &z);
	all = pow_mod (10, n), mx = (1 << (x + y + z)) - 1;
	ledge = ledge | (1 << (x - 1));
	ledge = (ledge << y) | (1 << (y - 1));
	ledge = (ledge << z) | (1 << (z - 1));
	
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++ i)
		for (int j = 0; j <= mx; ++ j)
		{
			if (!dp[i - 1][j])
				continue;
			for (int add = 1; add <= 10; ++ add)
			{
				long long cur = (j << add) | (1 << (add - 1));
				cur &= mx;
				if ((cur & ledge) == ledge)	
					continue;
				dp[i][cur] = (dp[i][cur] + dp[i - 1][j]) % MOD;
			}
		}
	
	for (int i = 0; i <= mx; ++ i)
		ans = (ans + dp[n][i]) % MOD;
	
	ans = (MOD + all - ans) % MOD;
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 82176
#include <iostream>
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;
    return 0;
}

Measured memory_bytes: 256
N,C,K=map(int,input().split())
T=[0]*N
for i in range(N):
    T[i]=int(input())

T=sorted(T)

las=T[0]+K
ans,cnt=0,0

for t in T:
    if cnt<C and las>=t:
        cnt+=1
    else:
        ans+=1
        cnt=1
        las=t+K

if cnt>0:
    ans+=1
    
print(ans)

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

using namespace std;

const int NMAX = 1e5+5;

vector<int> g[NMAX];
bool viz[NMAX];

inline void DFS(int node)
{
    viz[node] = 1;
    for(auto gnode : g[node])
    {
        if(!viz[gnode])
            DFS(gnode);
    }
}

int main()
{
    int N,M,i,j;
    cin>>N>>M;

    for(i = 1 ; i <= M ; ++i)
    {
        int x,y,c;
        cin>>x>>y>>c;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int cnt = 0;
    for(i = 1 ; i <= N ; ++i)
    {
        if(!viz[i])
        {
            DFS(i);
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;

int main(){
    int N; cin >> N;
    int a = 0, b = 0, c = 0;
    string res = "No";
    for (int i = 0; i < N; i++)
    {
        ll r;cin >> r;
        if (r % 4 == 0) a++;
        else if (r % 4 == 2) b++;
        else c++;
        
    }
    if (c <= a + 1 and b == 0) res = "Yes";
    if (c <= a and b >= 1 )res = "Yes";
    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

//while(c){
//    total += c%10;
//    c/=10;
//}

int main() {
    string x,y,z; cin >> x >> y;
    int ans = stoi(x+y);
    string a = "No";
    for(int i = 1;i*i <= 1000000;i++){
        if(i*i == ans){
            a = "Yes";
        }
    }
    cout << a;
}




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

int main(){
  int n;
  cin >> n;
  int rui = 0;
  vector<int> vec(n);
  for(int i=0; i<n; ++i){
    cin >> vec[i];
    rui ^= vec[i];
  }
  for(int i=0; i<n; ++i){
    if(i != n-1) cout << (rui ^ vec[i]) << " ";
    else cout << (rui ^ vec[i]) << endl;
  }
}

Measured memory_bytes: 4048
N, X, Y = map(int, input().split())
x = X-1
y = Y-1
dist = [0] * N
for i in range(N-1):
    for j in range(i+1, N):
        dist_ = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) +1 + abs(j - x))
        dist[dist_] += 1
for i in range(N-1):
    print(dist[i+1])



Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

ll N,K,mina;
vector<ll> a(105,0);
vector<ll> dp(100007,-1);

//残りx個で渡されて勝てるか
bool F(ll x){
    if(dp[x]!=-1)return dp[x];
    if(x<mina)return dp[x]=0;
    bool ret=1;
    for(ll i=0;i<N;++i){
        if(x-a[i]>=0&&!F(x-a[i]))return dp[x]=1;
    }
    return dp[x]=0;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin>>N>>K;
    for(ll i=0;i<N;++i)cin>>a[i];
    mina=INF;
    for(ll i=0;i<N;++i)chmin(mina,a[i]);

    if(F(K)){prt("First")}
    else prt("Second")

    return 0;
}


Measured memory_bytes: 4224
import math
from decimal import Decimal
hour_len, minute_len, hour, minute = list(map(int, input().split()))

degree_hm = abs(((hour * 60 + minute) * 0.5) - (minute * 6))
rad_hm = math.radians(degree_hm) # 長針は1分で0.5deg、短針は1分で6deg
cos_hm = math.cos(rad_hm)

a_double = hour_len ** 2 + minute_len ** 2 - (2 * hour_len * minute_len * cos_hm)
ans = math.sqrt(a_double)
print( f"{ans:.20f}" )

Measured memory_bytes: 10188
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    ll n;
    cin >> n;
    ll hoge=1;
    int ans = 0;
    while(hoge < n){
        hoge *= 3;
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3096
#include <iostream>
#include <unordered_set>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  unordered_set<string> A;
  
  for (int i=0; i<N; i++){
    cin >> S;
    A.insert(S);
  }
  cout << A.size() << endl;
  return 0;
}


Measured memory_bytes: 13848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,m,a,b,c=0,ans=0;
  P br[100010];
  cin>>n>>m;
  fr(i,m){
    cin>>a>>b;
    br[i]=mp(b,a);
  }
  sort(br,br+m);
  fr(i,m){
    if(c<=br[i].second){ans++;c=br[i].first;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
int main(void){
    
    
    map<string, int> m;
    
    int N;
    cin >> N;    
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        m[s]++;
    }
    
    int M;
    cin >> M;
    for(int i = 0; i < M; i++){
        string s;
        cin >> s;
        m[s]--;
    }
    
    int ans = 0;
    for(auto A : m){
        auto value = A.second;
        ans = max(ans, value);
    }
    cout << ans << endl;
    
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    int t;
    int count = 0;
    REP(i,n){
        cin >> t;
        if(i%2==0&&t%2!=0){
            count++;
        }
    }
    COUT(count);
}

Measured memory_bytes: 3616
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    *this << "\n[";
    for (auto &elem : x) *this << elem << ", ";
    return *this << "]";
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << "{" << x.first << ", " << x.second << "}";
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args ...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(string(#args)), args), dbg << endl
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int n, m, K, T, Q, cn;//}
const int inf = 1000000007, mxn = 205;

pair<int, int> a[mxn];

ll euclid(const pair<int, int> &x) {
    return x.first*ll(x.first)+x.second*ll(x.second);
}

double angle(const pair<int, int> &x) {
    return atan2(x.second, x.first);
}

struct cmp { bool operator() (const pair<int, int> &ls, const pair<int, int> &rs) const {
    return angle(ls)<angle(rs);
}};

pair<int, int> operator+(const pair<int, int> &x, const pair<int, int> &y) {
    return pair<int, int>(x.first+y.first, x.second+y.second);
}

pair<int, int>& operator+=(pair<int, int> &x, const pair<int, int> &y) {
    return x.first += y.first, x.second += y.second, x;
}

pair<int, int> operator-(const pair<int, int> &x, const pair<int, int> &y) {
    return pair<int, int>(x.first-y.first, x.second-y.second);
}

pair<int, int>& operator-=(pair<int, int> &x, const pair<int, int> &y) {
    return x.first -= y.first, x.second -= y.second, x;
}

int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.precision(11);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a+n, cmp());
    for (int i = 0; i < n; i++) {
        a[i+n] = a[i];
    }
    ll mx = 0;
    pair<int, int> cur = {0, 0};
    for (int i = 0, j = 0; j<2*n; ) {
        if (j-i<n and (j<=i or euclid(cur+a[j])>=euclid(cur))) {
            cur += a[j++];
            mx = max(mx, euclid(cur));
        } else {
            cur -= a[i++];
            mx = max(mx, euclid(cur));
        }
    }
    cout << sqrt(mx) << '\n';
}

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

int main(){
  long x,  A, B, tmp, r;
  cin >> A >> B;
  x = A * B;
 
  /* 自然数 A > B を確認・入替 */
  if(A<B){
    tmp = A;
    A = B;
    B = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
	cout << x / B << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int prt=0;
		for(int i=0;i<s.length;i++){
			int cnt=0;
			for(int j=0;j<s.length-i;j++){
				boolean t = false;
				switch(s[i+j]){
				case "A":
					cnt++;
					break;
				case "T":
					cnt++;
					break;
				case "C":
					cnt++;
					break;
				case "G":
					cnt++;
					break;
				default:
					t=true;
					break;
				}
				if(t)break;
			}
			if(cnt>prt)prt=cnt;
		}
		System.out.print(prt);
	}
}

Measured memory_bytes: 35588
def main():
    S = input()
    K = int(input())
    S_splited = list(map(int, list(str(S))))
    offset = 0
    day = 5 * 10**18
    for i in S_splited:
        if i == 1:
            offset += 1
            if offset >= K:
                break
            continue
        else:
            break
    print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    k = ni()
    s = ns()

    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + '...')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9736
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int i, j, x, y;
	x = 0;
	y = 0;
	i = 0;
	j = 0;
	while (1)
	{
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		for(i = 1;i<=x;i++)
		{
			for (j=1;j<=y;j++)
			{
				printf("#");
			}
			printf("\n");
			j = 0;
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 3076
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  int best = INF, best_i = -1;
  for (int i = 0; i < n; ++i) {
    int cur = abs(sum - n * a[i]);
    if (best > cur || (best == cur && best_i > i)) {
      best = cur;
      best_i = i;
    }
  }
  printf("%d\n", best_i);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  vector<int> dp(n+1,INF);
  dp[0]=0;
  for(int i=1;i<=n;i++){
    dp[i]=dp[i-1]+1;
    int k=6;
    while(i-k>=0){
      dp[i]=min(dp[i],dp[i-k]+1);
      k*=6;
    }
    k=9;
    while(i-k>=0){
      dp[i]=min(dp[i],dp[i-k]+1);
      k*=9;
    }
  }
  cout<<dp[n]<<endl;

  return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    ll h, w;
    cin >> w >> h;
    int x, y;
    cin >> x >> y;
    cout << fixed << setprecision(10);
    cout << h*w/2.0 << ' ';
    if(2*x == w && 2*y == h) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    int i=2, j=2;
    deque<int> ans(1,1);
    while (i*i <= n) {
        while (pow(i, j) <= n) {
            ans.push_back(pow(i, j));
            j++;
        }
        j=2;
        i++;
    }
    sort(ans.begin(), ans.end());
    cout<<ans.at(ans.size()-1)<<endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for(int i = 0; i < (n/r + 1); i++){
        for(int j = 0; j < ((n-i*r)/g + 1); j++){
            if((n - (i*r + j*g))%b == 0)cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		sc.close();

		System.out.println(A + B < X || A > X ? "NO" : "YES");
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a = 0;
		for (int i = 1; i < 10; i++) {
			if (N % i == 0 && N / i < 10) {
				a++;
			}
		}
		if (a == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll a[15];
ll b[15];
ll s=0;
void solve(){
	char ch;
	while (ch=getchar()){
		if (ch<'0' || ch>'9') break;
		a[++n]=ch-'0';
	}
	b[n]=true;
	while (b[0]==0){
		ll k=n-1;
		while (b[k]) b[k--]=0;
		b[k]++;
//		for (int i=1;i<=n;i++) cout << b[i] << ' ';
//		cout << endl;
		ll tmp=0;
		for (ll i=1;i<=n;i++){
			tmp=tmp*10+a[i];
			if (b[i]){
				s+=tmp;
				tmp=0;
			}
		}
//		cout << "s=" << s << endl;
	}
	cout << s;
}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))

        sign = lambda x1, y1, x2, y2, x3, y3: (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)
        b1 = sign(xp, yp, x1, y1, x2, y2) < 0.0
        b2 = sign(xp, yp, x2, y2, x3, y3) < 0.0
        b3 = sign(xp, yp, x3, y3, x1, y1) < 0.0


        if b1 == b2 and b2 == b3:
            print("YES")
        else:
            print("NO")
    except:
        break


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

using namespace std;
int N;
vector<long long int> A;
vector<long long int> V;

int main(void) {

	cin >> N;
	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; A.push_back(tmp);
	}

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

	for (int i = 0; i < N - 1;) {
		if (A[i] == A[i + 1]) { V.push_back(A[i]); i += 2; }
		else { i++; }
	}

	sort(V.rbegin(), V.rend());

	long long int ans;

	if (V.size() <= 1) { ans = 0; }
	else { ans = V[0] * V[1]; }

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll x;
    cin >> x;
    ll count=0;
    ll p = 100;
    while(p<x){
        p+=(long long)(p/100);
        count++;
    }    

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

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

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int H,W;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {
  int n;
  cin >> n;
  int l[n];
  int max=0,sum,maxnum;
  rep(i,n) {
    cin >> l[i];
    if(l[i] > max) {
      max = l[i];
      maxnum = i;
    }
  }
  sum = 0;
  rep(i,n) {
    if(i!=maxnum) 
      sum +=l[i];
  }
  if(sum > max)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
 


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;

typedef long long ll;


//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

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

    cin >> N;
    int A[N + 2];
    A[0] = 0;
    A[N+1] = 0;
    REP(i, 1, N + 1) cin >> A[i];
    int L = 0;
    REP(i, 1, N + 2) L += abs(A[i] - A[i-1]);
    REP(i, 1, N + 1){
        cout << L - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]))+ abs(A[i+1] - A[i-1]) << endl;
    }
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();

		int ans=1;
		for (int i=1; i<N; i++){
			if (S.charAt(i-1) != S.charAt(i)){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
  int N, ans;
  double avg, c = 100;
  cin >> N;
  vector <int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  avg = accumulate(a.begin(), a.end(),  0) / (double)a.size();
  for(int i = 0; i < N; i++) {
    if(avg > a.at(i)) {
      if (c > avg - a.at(i)){ 
        ans = i;
        c = avg - a.at(i);
      }
    }else{
      if (c > a.at(i) - avg){ 
        ans = i;
        c = a.at(i) - avg; 
     }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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



int main(){
    int n, x, y;    cin >> n >> x >> y;
    x--; y--;

    vector<vector<int>> dis(n, vector<int>(n, -1));
    vector<vector<int>> dis2(n, vector<int>(n, -1));
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            dis[i][j] = j-i;
            dis[j][i] = j-i;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int tmp1 = dis[i][x] + 1 + dis[y][j];
            int tmp2 = dis[i][y] + 1 + dis[x][j];
            dis2[i][j] = min(dis[i][j], min(tmp1, tmp2));
        }
    }

    vector<ll> res(n, 0);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            res[dis2[i][j]]++;
        }
    }

    for(int k = 1; k < n; k++){
        cout << res[k] << endl;
    }

    return 0;
}

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

int main(int argc,char* argv[]){
  int N,count=0;
  cin >> N;
  int box[N+1]={0};
  for(int i=1;i<N+1;i=i+2){
    for(int j=1;i*j<N+1;j=j+2){
      box[i*j]++;
    }
  }
  for(int i=1;i<N+1;i++) if(box[i]==8) count++;
  cout << count << endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll ans=n;
	for(ll i=1; i*i<=n; i++){
		if(n%i==0){
			ans=min(ans, i+n/i-2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    if(a > b){
        int p = a;
        a = b;
        b = p;
    }
    if(a < c && c < b)
        puts("Yes");
    else 
        puts("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

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

signed main(void){
    vector<vector<int>> dp(3100, vector<int>(3100));
    string s, t; cin >> s >> t;
    REP(i, 3100) REP(j, 3100) dp[i][j] = 0;
    
    REP(i, s.size()){
        REP(j, t.size()){
            if(s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }

    string ans = "";
    int i = s.size(), j = t.size();
    while(i > 0 and j > 0){
        if(dp[i][j] == dp[i - 1][j]) i--;
        else if(dp[i][j] == dp[i][j -1]) j--;
        else{
            ans = s[i - 1] + ans;
            i--, j--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 75648
#[allow(unused_imports)]
use proconio::{fastout, input};
use std::char;
#[fastout]
fn main() {
    input!(n: u32, s: String);
    for ss in s.chars() {
        print!(
            "{}",
            char::from_u32((ss as u32 + n - 65) % 26 + 65).unwrap()
        );
    }
}


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

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

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

int main()
{
  int N;
  cin >> N;
  ll sum = 0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for (int k = 1; k <= N; k++)
      {
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


ll out(ll a, ll b, ll c){
    if(a==b && b==c) return 1;
    if(a!=b && b!=c && c!=a) return 6;
    return 3;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int N;
    cin >> N;
    vint ret(N);
    REP(i,N) ret[i] = 0;

    FOR(x,1,N){
        FOR(y,1,N){
            FOR(z,1,N){
                int n = x*x + y*y + z*z + x*y + y*z + z*x;
                if(n > N) break;
                ret[n-1]++;
                // out(x,y,z);
            }
        }
    }

    REP(i,N){
        cout << ret[i] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3576
while(1):
    m,f,r = map(int,raw_input().split())
    if(m == -1 and f == -1 and r == -1):
        break
    if(m == -1 or f == -1):
        print "F"
    if m == -1:
        m = 0
    elif f == -1:
        f = 0

    elif(m + f >= 80):
        print "A"
    elif 65 <= m + f < 80:
        print "B"
    elif 50 <= m + f < 65:
        print "C"
    elif 30 <= m + f < 50:
        if r >= 50:
            print "C"
        else:
            print "D"
    elif m + f < 30:
        print "F"


Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

struct Timestamp{
	int discovered;
	int finished;
};

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

	set<int> A[n+1];
	bool reached[n+1]{};
	int v1, v2, deg;
	r(i, n){
		cin >> v1 >> deg;

		r(j, deg){
			cin >> v2;
			A[v1].insert(v2);
			//A[v2].insert(v1);
		}
	}

	Timestamp ts[n+1];
	for(int i = 1; i <= n; i++){
		ts[i].discovered = 0;
		ts[i].finished = 0;
	}
	ts[1].discovered = 1;


	int time = 0;
	stack<int> s;

	while(true){
		for (int i = 1; i <= n; i++) {
			if (reached[i])
				continue;
			reached[i] = true;
			s.push(i);
			time++;
			ts[i].discovered = time;
			goto DFS;
		}
		break;

		DFS:;
		while (!s.empty()) {
			v1 = s.top();

			bool hasNext = false;
			for (int v2 : A[v1]) {
				if (!reached[v2]) {
					reached[v2] = true;
					s.push(v2);
					hasNext = true;
					break;
				}
			}

			if (!ts[v1].discovered) {
				time++;
				ts[v1].discovered = time;
			}

			if (!hasNext) {
				time++;
				ts[v1].finished = time;
				s.pop();
			}
		}
	}

	for(int i = 1; i <= n; i++){
		printf("%d %d %d\n", i, ts[i].discovered, ts[i].finished);
	}

	return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll a, b, x; cin >> a >> b >> x;
    ll ax = (a-1)/x+1;
    ll bx = b/x+1;
    if(a==0){
        cout << b/x + 1 << endl;
        return 0;
    }
    

    cout << bx - ax << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
int a[100004];
int t[100004];
P p[100000];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,l;
	int i,j;
	scanf("%d %d",&n,&l);
	a[0]=0;t[0]=-1;
	a[1]=0;t[1]=-1;
	a[n+2]=0;t[n+2]=-1;
	a[n+3]=0;t[n+3]=-1;
	for(i=2;i<=n+1;i++){
		scanf("%d",&a[i]);
		p[i-2].first=a[i];
		p[i-2].second=i;
		t[i]=0;
	}
	sort(p,p+n);
	reverse(p,p+n);
	int ans=0;
	int x,y;
	for(i=0;i<n;i++){
		x=p[i].first;
		y=p[i].second;
		if(x+(ans-t[y])<l){
			ans+=l-x-(ans-t[y]);
			if(a[y-1]<a[y])t[y-1]=max(t[y-1],ans);
			if(a[y+1]<a[y])t[y+1]=max(t[y-1],ans);
			a[y]=0;
		}else{
			if(a[y-1]<a[y])t[y-1]=max(t[y-1],t[y]+l-x);
			if(a[y+1]<a[y])t[y+1]=max(t[y+1],t[y]+l-x);
			a[y]=0;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int MAX_N = 5001;

std::vector<int> G[5001];
int order[5001], rank[5001]; bool used[5001], hasChild[5001];

class UnionFind{
public:
    UnionFind(int n){
        REP(i, n){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
private:
    int rank[MAX_N], par[MAX_N];
};

void dfs(int v, int &r, bool &d){
    used[v] = true;

    int h = -1;
    for(int u : G[v]){
        if(!used[u]){
            dfs(u, r, d);
        }
        // printf("compare(v=%d): rank[%d](=%d) rank[%d](=%d)\n", v, h, h==-1?-1:rank[h], u, rank[u]);
        if(h == -1 || rank[h] < rank[u]){h = u;}
    }
    
    // printf("%d -> %d\n", v, h);
    if(h != -1 && hasChild[h]){d = true;}
    else{hasChild[h] = true;}

    order[r] = v; rank[v] = r;
    r += 1;
}

int main(){
    int N, M;
    std::cin >> N >> M;

    UnionFind uf(N+1);
    REP(i, M){
        int x, y;
        std::cin >> x >> y;

        G[y].push_back(x);
        uf.unite(x, y);
    }

    int scc = 0, r = 1;
    bool d = false;
    FOR(i, 1, N+1){
        if(!used[i]){dfs(i, r, d);}
        if(i == uf.find(i)){scc += 1;}
    }

    FOR(i, 1, N+1){
        std::cout << order[i] << std::endl;
    }

    std::cout << (scc < 1 || d) << std::endl;
}

Measured memory_bytes: 2044