akhauriyash/Code-Regression huggingface dataset:
#import<regex>

long long a,b,c,i,j,k,n,t;char s[12];

main()

{

for(scanf("%lld ",&n);i++<n;)

{for(scanf("%s",s),j=0;s[j];j++)t+=s[j]==65&&s[j+1]==66;
a+=s[j-1]==65&&s[0]^66;b+=s[0]==66&&s[j-1]^65;c+=s[j-1]==65&&s[0]==66;}
k=c?c-1:0,a&&c?a--,k++:0,b&&c?b--,k++:0,k+=a<b?a:b;
printf("%lld",t+k);

}



Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std; 
const int INF=1e9+5;
int main()
{
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<=(i+2);j++)
		{
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
		}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;



int main()
{
  long long int H;
   long long int count = 0;
    long long int ans=0;
    
  
    cin >> H;
    while (H>1){
        H = floor (H/2);
        count++;
    }
    REP(i,count+1){
        ans+=pow(2,i);
    }
  
    cout << ans << endl;
  
 
}

Measured memory_bytes: 256
#ABC120B
#AもBも割り切る正の整数のうちK番目に大きいものを求める
A,B,K = map(int, input().split())
common_div = []
for i in range(min(A,B)+1,0,-1):
    if A%i==0 and B%i==0:
        common_div.append(i)

#print(common_div)
print(common_div[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

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

    int L[N];
    int position = 0;
    int count = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
        position += L[i];
        if (position <= X)
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main()
{
  int N, A[256];
  int count = 0;

  cin >> N;

  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  while(true){
    for(int i=0;i<N;i++){
      if(A[i]%2 == 1){
        cout << count << endl;
        return 0;
      }
      else A[i] = A[i]/2;
    }
    count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b) * h / 2 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;
 
int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
 
int max(int a,int b){return (a>b?a:b);}
 
int min(int a,int b){return (a<b?a:b);}
 
struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};
 
struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

int32_t main(){
    IOS
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans = "";
    for(int i=0;i<n;i++){
        ans += s[i];
        ans += t[i];
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 3628
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  L,R=map(int,pin().split())
  for i in range(M-1):
    l,r=map(int,pin().split())
    if L<l and l<=R:
      L=l
    elif R<l:
      print(0)
      return
    if L<=r and r<R:
      R=r
    elif r<L:
      print(0)
      return
  print(R-L+1)
  return 
main()

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

using namespace std;

int N, M;
vector<vector<int> > G;

int dfs(int v, vector<bool> &visited) {
  bool flag = true;
  for (int i = 0; i < visited.size(); i++) {
    if (!visited[i]) {
      flag = false;
      break;
    }
  }
  if (flag) return 1;
  int result = 0;
  for (int i = 0; i < G[v].size(); i++) {
    int to = G[v][i];
    if (!visited[to]) {
      visited[to] = true;
      result += dfs(to, visited);
      visited[to] = false;
    }
  }
  return result;
}

int main() {
  cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<bool> visited(N, false);
  visited[0] = true;
  cout << dfs(0, visited) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))
#define vi vector<int>


const int maxn = 5e5 + 10;

int n, t;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    cin >> s;
    if(n==1 || n%2)
    {
        cout << "No" << endl;
        return 0;
    }
    int x = n / 2;
    for (int i = 0; i < x;i++)
    {
        if(s[i]!=s[i+x])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
	long n, ans = 0;
  string s;
  cin >> n >> s;
  for(long i = 0; i < n; i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#ABC070C

def gcd(a, b):
 while b:
  a, b = b, a % b
 return a

def lcm(a, b):
 return a * b // gcd (a, b)

n=int(raw_input())
res=1
for i in xrange(n):
 temp=int(raw_input())
 res=lcm(res,temp)
print res


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

using namespace std;

class ModInt{
private:
  long long number;

public:
  static constexpr long long mod = 1000000007;

  constexpr ModInt(const ModInt& x) : number(x.number){};

  constexpr ModInt(const long long number = 0) : number((mod + number) % mod){}

  constexpr long long get() const{
    return number;
  }

  constexpr ModInt& operator+=(const ModInt& rhs){
    number += rhs.number;
    if(number >= mod) number -= mod;
    return *this;
  }

  constexpr ModInt& operator*=(const ModInt& rhs){
    (number *= rhs.number) %= mod;
    return *this;
  }
};

constexpr ModInt operator+(const ModInt& lhs, const ModInt& rhs){
  return ModInt(lhs) += rhs;
}

std::ostream& operator<<(std::ostream& os, const ModInt& x){
  os << x.get();
  return os;
}


void dfs(int node, int parent, vector<vector<int>>& to, vector<vector<ModInt>>& dp){
  if(to[node].size() == 1 && to[node][0] == parent) return;
  
  for(int next : to[node]){
    if(next == parent) continue;
    
    dfs(next, node, to, dp);
    
    dp[0][node] *= dp[0][next] + dp[1][next];
    dp[1][node] *= dp[0][next];
  }
}

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> to(N);
  for(int i = 0; i < N - 1; ++i){
    int x, y;
    cin >> x >> y;
    --x; --y;
    
    to[x].emplace_back(y);
    to[y].emplace_back(x);
  }
  
  vector<vector<ModInt>> dp(2, vector<ModInt>(N, 1));
  dfs(0, -1, to, dp);
  
  cout << dp[0][0] + dp[1][0] << endl;
  
  return 0;
}

Measured memory_bytes: 15600
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	ll a,b,t;cin>>a>>b>>t;
	ll ans=t/a;
	ans*=b;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    public static void Main()
    {
        while(true)
        {
            string[] data = Console.ReadLine().Split();
            if(data[1] == "?")break;
            
            switch(data[1])
            {
                case "+":
                    Console.WriteLine(int.Parse(data[0]) + int.Parse(data[2]));
                    break;
                case "-":
                    Console.WriteLine(int.Parse(data[0]) - int.Parse(data[2]));
                    break;
                case "*":
                    Console.WriteLine(int.Parse(data[0]) * int.Parse(data[2]));
                    break;
                case "/":
                    Console.WriteLine(int.Parse(data[0]) / int.Parse(data[2]));
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 17856
#include<cstdio>

int n, m, c;
int b[111];

int main() {
	scanf("%d%d%d", &n, &m, &c);
	for(int i=0;i<m;i++) scanf("%d", &b[i]);
	int ans=0;
	for(int i=0;i<n;i++) {
		int res = c;
		for(int j=0;j<m;j++) {
			int x; scanf("%d", &x);
			res += x*b[j];
		}
		if (res>0) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        ll n,ans=0;
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++) cin>>a[i];
        for(ll i=1;i<n;i++)
        {
            if(a[i]<a[i-1]) {ans+=a[i-1]-a[i];a[i]=a[i-1];}
        }
        cout<<ans<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n; cin >> n;
  string s; cin >> s;

  vector<ll> e(n, 0);
  vector<ll> w(n, 0);

  w[0] = s[0] == 'W' ? 1 : 0;
  for (int i = 1; i < n; i++) {
    w[i] = w[i-1];
    if (s[i] == 'W') w[i]++;
  }

  e[n-1] = s[n-1] == 'E' ? 1 : 0;
  for (int i = n-2; i >= 0; i--) {
    e[i] = e[i+1];
    if (s[i] == 'E') e[i]++;
  }

  ll ans = INF;
  rep(i, n) {
    chmin(ans, e[i] + w[i] - 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5396
d = int(input())
cList = input().split()

sList = []

for idx in range(0, d):
    tempList = input().split()
    sList.append(tempList)

tList = []

for idx in range(0, d):
    tList.append(int(input()))

countList = [0] * 26
val = 0

for idx in range(0, d):
    val += int(sList[idx][tList[idx] -1])

    countList = list(map(lambda x: x+1, countList))
    countList[int(tList[idx]) -1] = 0

    for wkChar in range(0,26):
        val -= int(countList[wkChar]) * int(cList[wkChar])
    print(val)




Measured memory_bytes: 9652
N=int(input())
x = [input() for i in range(N)]
A=str(x.count("AC"))
B=str(x.count("WA"))
C=str(x.count("TLE"))
D=str(x.count("RE"))
print("AC x "+A)
print("WA x "+B)
print("TLE x "+C)
print("RE x "+D)


Measured memory_bytes: 16220
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
int main(){
    string s;cin>>s;
    ll one=0;
    ll zero=0;
    rep(i,0,s.size()){
        if(s[i]=='0')zero++;
        if(s[i]=='1')one++;
    }
    ll ans=min(one,zero);
    ans*=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import numpy as np
n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.array([0 for _ in range(n)])
dp[0] = 0
for i in range(1, n):
  j = max(0, i-k)
  dp[i] = min(dp[j:i] + np.abs(h[i]-h[j:i]))

print(dp[n-1])

Measured memory_bytes: 22828
// Problem : A - Round One
// Contest : AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>

using namespace std;



int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	
	int r[]{1, 2, 3};
	 
	for(int i = 0; i < 3; ++i)
		if(r[i] != a && r[i] != b){
			printf("%d", r[i]);
			return 0;
		}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  char s;
  cin >> s;
  cout << (char)(s + 1) << endl;
  return 0;
}

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

int main(){
	int n,stone[200001],stones[200001],ans=0x7fffffff;
	char s[200001];
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++)stone[i]=s[i]=='#';
	for(int i=n;i>=0;i--)stones[i]=stones[i+1]+stone[i];
	for(int i=0;i<=n;i++)ans=min(ans,stones[0]-2*stones[i]+n-i);
	printf("%d\n",ans);
}

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

int main() {
    long long n,a,b;
    cin >> n >> a >> b;
    if(n%(a+b)<=a){
        cout << a*(n/(a+b))+n%(a+b) << endl;
    }
    else{
        cout << a*(n/(a+b))+a << endl;
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int sum = 0;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'I')
      sum += 1;
    else
      sum -= 1;
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

export const solveD = (n: number, s: string): number => {
  type RGB = "R" | "G" | "B";
  const rgb: { [k in RGB]: number } = { R: 0, G: 0, B: 0 };
  const r: number[] = [];
  const g: number[] = [];
  const b: number[] = [];
  for (let i = n - 1; i >= 0; i--) {
    rgb[s[i] as RGB]++;
    r[i] = rgb.R;
    g[i] = rgb.G;
    b[i] = rgb.B;
  }
  let comb = 0;
  const arr = (...a: RGB[]): number[] => {
    if (a.includes("R") && a.includes("G")) return b;
    if (a.includes("R") && a.includes("B")) return g;
    if (a.includes("G") && a.includes("B")) return r;
    return [];
  };
  for (let i = 0; i < n - 3; i++) {
    for (let j = i + 1; j < n - 1; j++) {
      if (s[i] === s[j]) continue;
      const ar = arr(s[i] as RGB, s[j] as RGB);
      const v =
        s[2 * j - i] && s[2 * j - i] !== s[i] && s[2 * j - i] !== s[j]
          ? ar[j + 1] - 1
          : ar[j + 1];
      comb += v;
    }
  }
  return comb;
};

if (require.main === module) {
  const [n, s] = readFileSync("/dev/stdin", "utf8").split("\n");
  console.log(solveD(+n, s));
}


Measured memory_bytes: 39544
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf = hell, N=20005;
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
vector<ll> adj[N], revg[N], dist(N,inf);
void solve(){
	map<ll,ll> ans;
	ll n, a, b;
	cin>>n>>a>>b;
	rep(i,1,n){
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[a].pb(b);
	adj[b].pb(a);
	rep(i,1,n+1){
		vector<ll> dist(n+1,inf);
		dist[i]=0;
		queue<ll> q;
		q.push(i);
		while(!q.empty()){
			ll x = q.front();
			q.pop();
			if(x>i)ans[dist[x]]++;
			for(auto u : adj[x])
				if(dist[u]==inf){
					dist[u]=dist[x]+1;
					q.push(u);
				}
		}
	}
	rep(i,1,n)cout<<ans[i]<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 1536
#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 int64 INF = 1LL << 60;
const int MOD = 1e9 + 7;

const int N = 3000;
vector<ii> a[N];

int main() {
  int n, m, val;
  scanf("%d%d%d", &n, &m, &val);
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    --x; --y;
    a[x].push_back({y, z - val});
  }
  vector<int64> d(n, -INF);
  d[0] = 0;
  int k;
  for (k = 0; k < m; ++k) {
    for (int i = 0; i < n; ++i) {
      for (auto& it : a[i]) {
        int j = it.first, cost = it.second;
        d[j] = max(d[j], d[i] + cost);
      }
    }
  }
  int64 ret = d[n - 1];
  for (int k = 0; k < m; ++k) {
    for (int i = 0; i < n; ++i) {
      for (auto& it : a[i]) {
        int j = it.first, cost = it.second;
        d[j] = max(d[j], d[i] + cost);
      }
    }
  }
  if (d[n - 1] != ret) {
    puts("-1");
  } else {
    ret = max(ret, 0LL);
    printf("%lld\n", ret);
  }
  return 0;
}


Measured memory_bytes: 384
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        c += 1
if P[n-1] == n:
    P[n-1], P[n-2] = P[n-2], P[n-1]
    c += 1
print(c)

Measured memory_bytes: 14008
#include <iostream>

using namespace std;

int main()
{
	int N, A[101], i = 0, max = 0;

	for (int i = 0; i < 100; i++) { A[i] = 0; }

	while (cin >> N)
	{
		i++;

		A[N]++;
	}

	for (int j = 1; j <= 100; j++)
	{
		if (A[j] > max) { max = A[j]; }
	}

	for (int j = 1; j <= 100; j++)
	{
		if (A[j] == max) { cout << j << endl; }
	}

	return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	while (true)
	{
		int q;
		scanf("%d", &q);
		if (q == -1)
			break;

		double x = q/2.0;
		while (abs(x*x*x - q) >= 0.00001*q)
			x = x - (x*x*x-q)/(3*x*x);
		printf("%.6f\n", x);
	}

	return 0;
}

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


Measured memory_bytes: 4360
import sys 
import collections

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')
n,m = map(int,input().split())

s = {i:[] for i in range(n+1)}
for i in range(m):
    a,b = map(int,input().split())
    s[a].append(b)
    s[b].append(a)

bfs = [0]*(n+1)
try:
    bfs[1] = s[1][0]
except IndexError:
    print("No")
    exit()
q = collections.deque()
q.append({1:s[1]})

while  q:
    tmp = q.popleft()
    for k,v in tmp.items():
        for room in v:
            if bfs[room] == 0:
                bfs[room] = k
                q.append({room:s[room]})

if bfs.count(0) <= 1:
    print("Yes")
    for i in bfs[2:]:
        print(i)
else:
    print("No")
   


Measured memory_bytes: 62780
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
--import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO
import qualified Data.Set                      as S


getVUIL :: IO (VU.Vector Int)
getVUIL = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readI :: BSC8.ByteString -> Int
readI = fst . fromJust . BSC8.readInt
readIL :: BSC8.ByteString -> [Int]
readIL = map readI . BSC8.words
getI :: IO Int
getI = readI <$> BSC8.getLine
getIL :: IO [Int]
getIL = readIL <$> BSC8.getLine

getNIS :: Int -> IO [(Int, BSC8.ByteString)]
getNIS 0 = return []
getNIS n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getNIS (n - 1))
    return ((readI aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show (mod a modNum)

int2MInt :: Int -> Mint
int2MInt a = M (mod a modNum)

main :: IO ()
main = do
    aR <- getI
    let ret = pi * (realToFrac aR * 2)
    print ret


Measured memory_bytes: 4216
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long int n,m,x[100000],min,tmp,sum;
    cin >>n>>m;
    if(n>=m){
        cout << 0 <<endl;
        return 0;
    }
    cin >>x[0];
    for(int i=1;i<m;i++){
        cin>>x[i];
    }
    /*
    for(int i=0;i<m;i++){
        min = i;
        for(int k=i+1;k<m;k++){
            if(x[min]>x[k])min=k;
        }
        tmp = x[min];
        x[min] = x[i];
        x[i] = tmp;
    }
    */
    sort(x,x+m);
    sum = x[m-1]-x[0];
    for(int i=0;i<m-1;i++){
        x[i] = x[i+1]-x[i];
    }
    /*
    for(int i=0;i<m-1;i++){
        min = i;
        for(int k=i+1;k<m-1;k++){
            if(x[min]>x[k])min=k;
        }
        tmp = x[min];
        x[min] = x[i];
        x[i] = tmp;
    }*/
    sort(x,x+m-1);
    for(int i=1;i<=n-1;i++){
        sum -= x[m-1-i];
    }
    cout <<sum <<endl;
    return 0;
}

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

#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (ll i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<ll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    if (abs(A-B) % 2 == 0) {
        cout << abs(A-B) / 2 << endl;
    } else {
        cout << min(A + abs(1 - (B-(A-1)-1)) / 2,
                    N-B+1 + abs(N - (A+(N-B)+1)) / 2) << endl;
    }
}

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

using namespace std;

using ll = long long;

ll sum[200000] = {0};
struct TSK{
  int p;
  int x;

  bool operator<(const TSK &another){
    return (p==another.p) ? x < another.x : p < another.p;
  }
};


int main(){
  int n, q;
  cin >> n >> q;
  cin.ignore();
  for(int i = 0; i < n - 1; i++){
    sum[i] = 0;
  }
  //vector<int> p[n];
  int parent[n] = {0};
  for(int i = 0; i < n; i++){
    parent[i] = -1;
  }
  int a, b;
  for(int i = 0; i < n - 1; i++){
    cin >> a >> b;
    --a;
    --b;
    //p[a].push_back(b);
    parent[b] = a;
    cin.ignore();
  }

  // 更新
  TSK tmp_tsk;
  vector <TSK> t;
  
  for(int i = 0; i < q; i++){
    cin >> tmp_tsk.p >> tmp_tsk.x;
    --tmp_tsk.p;
    t.push_back(tmp_tsk);
    cin.ignore();
  }

  sort(t.begin(), t.end());
  int ptr = 0;
  for(int i = 0; i < n; i++){
    while(t[ptr].p == i){ // それ自身に対する処理
      sum[i] += t[ptr].x;
      ++ptr;
    }
    if(parent[i] != -1){ // 親に対する処理
      sum[i] += sum[parent[i]];
    }
  }

  //for(int i = 0; i < n; i++){
  //  cout << parent[i] << " " << flush;
  //}
  //cout << endl;
  for(int i = 0; i < n; i++){
    cout << sum[i] << " " << flush;
  }
  cout << endl;
  
  return 0;
}

      


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

int main()
{
	int inputNum = 0;
	std::cin >> inputNum;
	std::vector<int> input(inputNum);
	
	for(int i = 0; i < inputNum; i++)
	{
		std::cin >> input[i];
	}
	
	int count = 0;
	for(int i = 0; i < inputNum; i++)
	{
		int minj = i;
		for(int j = i; j < inputNum; j++)
		{
			if(input[j] < input[minj])
			{
				minj = j;
			}
		}
		if(minj != i)
		{
			std::swap(input[i], input[minj]);
			count++;
		}
	}
	
	for(int i = 0; i < inputNum; i++)
	{
		std::cout << input[i];
		if(i != inputNum - 1)
		{
			std::cout << " ";
		}
	}
	std::cout << "\n" << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 2996
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if c-a-b < 0 {
		fmt.Println("No")
		return
	}
	condition := (c-a-b)*(c-a-b) - 4*a*b
	if condition > 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
// Written by	: by_sknight
// Date			: 2018-11-14

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int getnumberOfArray();
long* creatArrayWithNumberOfArray(int nubmerOfArray);
int* getStepOrder(int numberOfNeedSortArray, int* pLen);
void ShellSort(long* array, int len, int *pCount);
void shellSortWithOneStep(long *array, int len, int step,int *pCount);
void printArray(long* array, int len);


int main(void)
{
	int nubmerOfArray = getnumberOfArray();
	long *array = creatArrayWithNumberOfArray(nubmerOfArray);
	int count;
	ShellSort(array, nubmerOfArray, &count);
	// printArray(array, nubmerOfArray);
	printf("%d\n", count);
	int i;
	for (i = 0; i < nubmerOfArray; i++)
	{
		printf("%ld\n", *(array + i));
	}
}

int getnumberOfArray()
{
	int input;
	scanf("%d", &input);
	return input;
}

long* creatArrayWithNumberOfArray(int nubmerOfArray)
{
	int i;
	long* array = (long*) malloc(nubmerOfArray * sizeof(long));
	for (i = 0; i < nubmerOfArray; i++)
		scanf("%ld", array + i);
	return array;
}

int* getStepOrder(int numberOfNeedSortArray, int* pLen)
{
	// printf("getStepSort\n");
	int i;
	int *tempArray = (int*) malloc(numberOfNeedSortArray * sizeof(int));
	for (i = 0; i < numberOfNeedSortArray; i++)
	{
		if (numberOfNeedSortArray / (pow(2, i + 1)) < 1)
			break;
		*(tempArray + i) = numberOfNeedSortArray / (pow(2, i + 1));
		// printf("tempArray %d : %d\n", i, *(tempArray + i));
	}
	*pLen = i;
	int *array = (int *) malloc(*pLen * sizeof(int));
	for (i = 0; i < *pLen; i++)
	{
		*(array + i) = *(tempArray + i);
	}
	return array;
}

void ShellSort(long* array, int len, int *pCount)
{
	if (len != 1)
	{
		*pCount = 0;
		int i;
		int numberOfOrder;
		int* order = getStepOrder(len, &numberOfOrder);
		printf("%d\n", numberOfOrder);
		//*****
		for (i = 0; i < numberOfOrder - 1; i++)
		{
			printf("%d ", *(order + i));
		}
		printf("%d\n", *(order + i));
		//*****

		for (i = 0; i < numberOfOrder; i++)
		{
			shellSortWithOneStep(array, len, *(order + i), pCount);
		}
	}
	else
	{
		*pCount = 0;
		printf("1\n");
		printf("1\n");
		shellSortWithOneStep(array, len, 1, pCount);
	}
}

void shellSortWithOneStep(long *array, int len, int step,int *pCount)
{
	int i, j;
	long temp;
	for (i = step; i < len; i++)
	{
		// printf("i = %d\n", i);
		temp = *(array + i);
		j = i - step;
		// printf("j = %d\n", j);
		while (j >= 0 && *(array + j) > temp)
		{
			// printf("i = %d && j = %d\n", i, j);
			*(array + j + step) = *(array + j);
			j -= step;
			(*pCount)++;
		}
		*(array + j + step) = temp;
	}
}

void printArray(long* array, int len)
{
	int i;
	for (i = 0; i < len; i++)
		printf("%ld ", *(array + i));
	printf("\n");
}


Measured memory_bytes: 9740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  ll ans=0;
  int a,b,c;
  int k;
  cin>>a>>b>>c>>k;
  int u=max(a,max(b,c));
  int v=u;
  for(int i=0;i<k;i++){
    u*=2;
  }
  cout<<a+b+c+u-v<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main(){
    ll n, m;
    cin >> n >> m;

    vector<vector<pair<ll, ll>>> v(n+1);  // v[i][j] : 県i(iは1-index)に属する市の中でj番目に早く誕生した市の (誕生年, 市の番号)
    exrep(i, 1, m) {
        ll p, y;
        cin >> p >> y;
        v[p].pb(make_pair(y, i));
    }

    exrep(i, 1, n) {
        sort(all(v[i]));
    }

    vector<pair<ll, ll>> w(m+1);  // w[i] : 市i(iは1-index)の (属する県の番号, その県の中で誕生した順番)
    exrep(i, 1, n) {
        rep(j, v[i].size()) {
            ll k = v[i][j].second;
            w[k] = make_pair(i, j+1);
        }
    }

    exrep(i, 1, m) {
        ll A = w[i].first;
        ll B = w[i].second;
        printf("%06lld", A);
        printf("%06lld\n", B);
    }

    re0;
}

Measured memory_bytes: 8576
#include <iostream>

using namespace std;

#define INF -1

int dp[45];

int main()
{
	for(int i = 0; i < 45; i++) { dp[i] = INF; }

	int n;

	cin >> n;

	dp[0] = 1;
	dp[1] = 1;

	for(int i = 2; i <= n; i++)
	{
		dp[i] = dp[i - 1] + dp[i - 2];
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1160
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
q = deque([A[0]])
i = 1
j = N-1
while i <= j:
    temp = max(abs(A[i]-q[0]), abs(A[j]-q[0]), abs(A[i]-q[-1]), abs(A[j]-q[-1]))
    if temp == abs(A[i]-q[0]):
        q.appendleft(A[i])
        i += 1
    elif temp == abs(A[j]-q[0]):
        q.appendleft(A[j])
        j -= 1
    elif temp == abs(A[i]-q[-1]):
        q.append(A[i])
        i += 1
    else:
        q.append(A[j])
        j -= 1
L = list(q)
ans = 0
for i in range(N-1):
    ans += abs(L[i+1]-L[i])
print(ans)

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const A = read<sint>();
	auto const B = read<sint>();
	sint r = (A < 10 && B < 10) ? A * B : -1;
	writeln(r);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#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 (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const N_MAX = 1e5;

int N, K;
int A[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &K);
  int min_idx = 0;
  int min_v = 1e9;
  rep(i, N) {
    scanf("%d", &A[i]);
    if (A[i] < min_v) {
      min_v = A[i];
      min_idx = i;
    }
  }
  int count = 1e6;
  rep(i, K) {
    int cnt = 1;
    int left = min_idx - i;
    if (left < 0) break;
    if (left % (K - 1) == 0) {
      cnt += left / (K - 1);
    } else {
      cnt += (left / (K - 1)) + 1;
    }

    int right = min(min_idx + K - 1 - i, N - 1);
    if ((N - 1 - right) % (K - 1) == 0) {
      cnt += (N - 1 - right) / (K - 1);
    } else {
      cnt += ((N - 1 - right) / (K - 1)) + 1;
    }
    count = min(count, cnt);
  }
  printf("%d\n", count);
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second

using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pp;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll n, m, A[1000001], B[1000001];
string s, t;
char c[1000001];
int main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '1') cout << 9;
		else cout << 1;
	}
	cout << endl;
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i;
    cin >> n;
    vector<pii>v(n+1);    
    rep(i,1,n+1){
        cin >> v[i].ff >> v[i].ss;
    }
    vector<ll>v1(n);
    iota(all(v1),1);
    double ans = 0;
    ll c = 0;
    do{ c++;
        rep(i,1,n){
            ans += sqrt( ( ( (1.0 * v[v1[i]].ss) - (1.0 * v[v1[i-1]].ss) ) * ( (1.0 * v[v1[i]].ss) - (1.0 * v[v1[i-1]].ss) ) )+ 
                      ( ( (1.0 * v[v1[i]].ff) - (1.0 * v[v1[i-1]].ff) ) * ( (1.0 * v[v1[i]].ff) - (1.0 * v[v1[i-1]].ff) ) ) );
        }
    }
    while(next_permutation(all(v1)));
    cout << fixed << setprecision(10) << (ans / (1.0*c))<< nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	ll n;
	cin >> n;
	for(int i = sqrt(n) ; i  >= 1; i--){
		if(n%i==0){
			cout << i + n/i  -2 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import numpy as np

a, b, c = map(int, raw_input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b


if res <0:
    print "No"
elif res**2 > temp:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 16100
#include <iostream>

using namespace std;

int a[105] , n , x;

int main() 
{
   int i;
    cin >> x >> n;
    for(i = 1 ; i <= n ; i++)
        cin >> a[i];
   int p = 0 , nr = x;
   while(true)
   {
       for(i = 1 ; i <= n && a[i] != nr - p ; i++)
                    ;
        if(i > n)
        {
            cout << nr - p << "\n";
            return 0;
        }
         for(i = 1 ; i <= n && a[i] != nr + p ; i++)
                    ;
        if(i > n)
        {
            cout << nr + p << "\n";
            return 0;
        }
        p++;
   }
    return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-

n=int(input())
w=[input() for _ in range(n)]

if len(w)!=len(set(w)):
    print("No")
else:
    prev=w[0]
    for i in range(1,n):
        cur=w[i]
        if prev[-1]!=cur[0]:
            print("No")
            break
        prev=cur
    else:
        print("Yes")


Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc =new Scanner(System.in);
		while(sc.hasNext())
		{
			BigInteger ans = sc.nextBigInteger().gcd(sc.nextBigInteger());
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import heapq
import sys
input=sys.stdin.readline
n,m,s,t=map(int,input().split())
edge1=[[] for i in range(n)]
edge2=[[] for i in range(n)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    edge1[u-1].append(a*(10**6)+(v-1))
    edge1[v-1].append(a*(10**6)+(u-1))
    edge2[u-1].append(b*(10**6)+(v-1))
    edge2[v-1].append(b*(10**6)+(u-1)) 

def dijkstra_heap(edge,s):
  d=[float("inf")]*n
  used=[True]*n
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge=heapq.heappop(edgelist)
    minedge_cost=minedge//(10**6)
    minedge_v=minedge%(10**6)
    if not used[minedge_v]:
      continue
    d[minedge_v] = minedge_cost
    used[minedge_v] = False
    for e in edge[minedge_v]:
      e_cost=e//(10**6)
      e_v=e%(10**6)
      if used[e_v]:
        heapq.heappush(edgelist,e+minedge_cost*10**6)
  return d

d1=dijkstra_heap(edge1,s-1)
d2=dijkstra_heap(edge2,t-1)
d=[0]*n

for i in range(n):
  d[i]=d1[i]+d2[i]
for i in range(n-1):
  d[-i-2]=min(d[-i-2],d[-i-1])
for dd in d:
  print(10**15-dd)


Measured memory_bytes: 58572
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    ll x;
    if(b>n){
    	x = n;
    }
    else{
    	x = b-1;
    }
    cout<<(a*x)/b<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

//????\??????????list??¢??°???????£????prev key next??¨???????????¢????§????

struct list{

    int key;

    list *next,*prev ;

};

//list????????????

list *nil;

void initialize(){

    nil = ( list * )malloc( sizeof(list) );

    nil -> next = nil;

    nil -> prev = nil;

}

//?????\

void insert( int key ){

    list *x = (list *)malloc( sizeof(list) );

    x-> key = key;

    //nil?????´??????x????????\

    x -> next = nil -> next;

    nil -> next -> prev = x;

    nil -> next = x ;

    x -> prev = nil;

}

//????´??????¢?´¢

list* search( int key ){

    list *cursor = nil -> next;

    while( cursor != nil && cursor -> key != key ){

        cursor = cursor -> next; 

    }

    return cursor;

}

//delete??¢??°?????????

void deletelist( list *t ){

    if( t == nil ) return;

    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);

}

//??????????¶????

void deleteFirst(){

    deletelist( nil -> next );

}

//??????????¶????

void deleteLast(){

    deletelist( nil -> prev );

}

//??????????¶????

void deletekey( int key ){

    deletelist( search(key) );

}

//????????????

void printlist(){

    list *cursor = nil -> next;

    int i = 0;

    while(1){

        if( cursor == nil ) break;

        if( i++ > 0 ) printf(" ");

        printf( "%d" , cursor -> key );

        cursor = cursor->next;

    }

    printf("\n");

}

//??¬???

int main(){

    int n, i, key;
    int size;
    char command[20];

    scanf("%d", &n);

    initialize();

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

        scanf("%s %d", command, &key );

        if( command[0] == 'i' ) insert(key);

        else if( command[0] == 'd' ){

            if( strlen(command) > 6 ){

                if( command[6] =='F' ) deleteFirst();

                else deleteLast();

            } else deletekey(key);

        }

    }

    printlist();

    return 0;

}

Measured memory_bytes: 33880
def data_input():
    a,b,c,d = input().split(' ')
    return (a,b,c,d)
def answer():
    a,b,c,d = data_input()
    s = '1974'
    s = s.replace(a,'').replace(b,'').replace(c,'').replace(d,'')
    if len(s) == 0:
        print('YES')
    else:
        print('NO')
answer()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, m, i, ans=0, money=0;
    map<string, long long> mpr, mpb;
    cin >> n;
    for(i=0;i<n;i++){
        string s;
        cin >> s;
        mpb[s]++;
    }
    cin >> m;
    for(i=0;i<m;i++){
        string s;
        cin >> s;
        mpr[s]++;
    }
    for(auto x : mpb){
        if(x.second>mpr[x.first]) money=x.second-mpr[x.first];
        ans=max(ans, money);
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>


#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	/* === input paramater === */
	char *s;
	lli k;

	/* === operate paramater === */
	char anum;
	char *p;

	/* === input === */
	s = calloc(sizeof(char),10E5+5);
	scanf("%s",s);
	scanf("%lld",&k);

	/* === pre === */
	p = s;
	anum = 'z'+1;
	while(*(s+1)){
		if(k >= (anum - *s)%26){
			k -= (anum - *s)%26;
			*s = 'a';
		}
		s++;
	}
	if(k >= anum - *s){
		k -= anum - *s;
		*s = 'a' + (char)(k % 26);
	}else{
		*s += (char)k;
	}
	printf("%s\n", p);


	return 0;
}

Measured memory_bytes: 1280
import bisect
N = int(input())
list = list(map(int,input().split()))
list = sorted(list)
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        x = list[i]+list[j]
        ind = bisect.bisect_left(list,x)
        ans+=(ind-j-1)
print(ans)
    

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


void solve(long long N, std::vector<long long> A){
    vector<int> v;
    map<int, ll> mp;
    for(int i = 0;i < N;i++){
        v.push_back(A[i]);
        mp[v.back()]++;
    }
    ll ans = 0;
    for(auto a : mp){
        ans += a.second*(a.second-1)/2;
    }
    for(int i = 0;i < N;i++){
        ans -= mp[v[i]]*(mp[v[i]]-1)/2;
        mp[v[i]]--;
        ans += mp[v[i]]*(mp[v[i]]-1)/2;
        cout<<ans<<endl;
        ans -= mp[v[i]]*(mp[v[i]]-1)/2;
        mp[v[i]]++;
        ans += mp[v[i]]*(mp[v[i]]-1)/2;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11892