akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long 
#define uint unsigned long long 
#define double long double 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sett(c) (c).resize(unique(all(c))-(c).begin())
#define sz(a) (int)(a).size()
#define hell 1000000007
#define pi pair<int,int>
#define vi vector<int> 
#define vb vector<bool> 
#define vpi vector<pair<int,int>> 
#define x first 
#define y second 
#define endl '\n'
#define forn(i,n) for(int i = 0 ; i < n ; i++ )
#define for1(i,n) for(int i = 1 ; i < n ; i++ )
#define fore(i,a,b) for(int i = a ; (a>b)?(i>=b):(i<=b) ; (a>b)?(i--):(i++) ) 
 
using namespace std;
const int MAX = 1e6;

long long binpow(long long a, long long b) {

    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        res %= hell;
        a %= hell;
        b >>= 1;
    }
    return res;
}

bool comp(const pi& a , const pi& b ){
        return a.y < b.y;
}/*
int ncr(int n , int a,  int b , int c , int d){
		int res = n ; 
		
}	*/

void solve(){
		int n ; cin >> n ; 
		string s ; cin >> s;  
		set<string>st ;
		forn(i,10){
			char c1 = char('0'+i);
			int pos = s.find(c1);
			if(pos == -1) continue ;
			forn(j,10){
				char c2 = char('0'+j) ;
				int pos1 = s.find(c2,pos+1) ; 
				if( pos1 == -1 ) continue ;
				forn(k,10){
					char c3 = char('0'+k);
					int pos2 = s.find(c3,pos1+1);
					if( pos2 == -1 ) continue ;
					string a = "";
					a += c1 ; a+= c2; a+=c3 ;
					st.insert(a);
				}
			}
		}
		cout << sz(st) << endl ;
		/*int n ; cin >> n;  
		int arr[n] ; 
		forn(i,n) cin >> arr[i] ; 
		int a[3] = {0,0,0};
		forn(i,n){
			if(a[0] + 1 == arr[i]){
				a[0]++ ;
			}else if(a[1] + 1 == arr[i] ) {
				a[1]++ ;
			}else{
				a[2]++ ;
			}
		}
		int k = 1; 
		if(a[0] == a[1] and a[1] == a[2] ){
			k = 3 ; 
		}else if( a[0] == a[1] or a[1] == a[2] or a[0] == a[2] ){
			k =2  ;
		}
		cout << ncr(a[0]+a[1]+a[2] , a[0] , a[1] , a[2] , k)  << endl ;
		*/
}
 
int32_t main(){
        
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << fixed;
        cout.precision(10);
 
#ifdef LOCAL_DEFINE
        //freopen("input.txt","rt",stdin);
        //freopen("output.txt","w",stdout);
#endif
 
        int t = 1;
        //cin >> t ;
        while(t--){
                solve();
        }
#ifdef LOCAL_DEFINE
        cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
 
        return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
char a[210];
int main(){
    while(~scanf("%s",a)){
        int len=strlen(a);
        if(len%2!=0) len-=1;
        len-=2;
        for(int i=len;i>1;i-=2){
            int k=i/2;
            int f=1;
            for(int j=0;j<k;j++){
                if(a[j]!=a[j+k]){
                    f=0;
                    break;
                }
            }
            if(f){
                printf("%d\n",i);
                break;
            }
        }
    }
	return 0;
}


Measured memory_bytes: 128
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
Tensu = [K-Q-1] * N

for i in range(Q):
    Tensu[A[i]-1] += 1

for i in range(len(Tensu)):
    if Tensu[i] >= 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10452
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int  mod = 1e9 + 7;
int main() {
	double pi = 3.14;
	int x; cin >> x;
	float res= 2 * pi * x;
	cout << fixed << setprecision(20) << res;
	return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
int main()
{
  char N;
  scanf("%c",&N);
  if(N=='A'){
    printf("T");
  }
  if(N=='T'){
    printf("A");
  }
  if(N=='C'){
    printf("G");
  }
  if(N=='G'){
    printf("C");
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int answer = 0;
	for(int i = 0;i < N - 2;i++) {
		if(vec.at(i + 2) >= vec.at(i + 1) && vec.at(i + 1) >= vec.at(i) || vec.at(i + 2) <= vec.at(i + 1) && vec.at(i + 1) <= vec.at(i)){
			answer++;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll a[N],b[N],c[N];
  for(int i=0;i<N;i++) cin >> a[i];
  for(int i=0;i<N;i++) cin >> b[i];
  for(int i=0;i<N;i++) cin >> c[i];

  priority_queue<ll, vector<ll>, greater<ll> > pql;
  priority_queue<ll> pqr;
  ll suml = 0LL;
  ll sumr = 0LL;
  for(int i=0;i<N;i++){
    pql.push(a[i]);
    suml += a[i];
    pqr.push(c[i]);
    sumr += c[i];
  }

  //iまで使えるときの左の総和の最大値
  ll sml[N+1];
  sml[0] = suml;
  for(int i=1;i<=N;i++){
    suml += b[i-1];
    pql.push(b[i-1]);
    suml -= pql.top();
    pql.pop();
    sml[i] = suml;
  }

  //左がiまで使うときの右の総和の最小値
  ll smr[N+1];
  smr[N] = sumr;
  for(int i=N-1;i>=0;i--){
    sumr += b[i];
    pqr.push(b[i]);
    sumr -= pqr.top();
    pqr.pop();
    smr[i] = sumr;
  }

  /*for(int i=0;i<=N;i++){
    cout << sml[i] << " " << smr[i] << endl;
  }*/

  ll ans = sml[0] - smr[0];
  for(int i=1;i<=N;i++){
    ans = max(ans, sml[i] - smr[i]);
  }

  cout << ans << endl;
  return 0;
}


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

const int N = 500005;

int n, q;
int c[N];

struct BIT {
  int sum[N];
  void update(int x, int val) {
    for (int i = x+1; i <= n; i += i & -i) {
      sum[i-1] += val;
    }
  }

  int query(int x) {
    int ret = 0;
    for (int i = x+1; i > 0; i -= i & -i) {
      ret += sum[i-1];
    }

    return ret;
  }

  int query(int l, int r) {
    return query(r) - query(l-1);
  }
} bit;

int lst[N];
vector<pair<int, int>> queries[N];

int ans[N];

int solve() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) {
    lst[i] = -1;
    scanf("%d", &c[i]);
    --c[i];
  }
  for (int i = 0; i < q; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    --l, --r;
    queries[r].emplace_back(l, i);
  }

  for (int i = 0; i < n; ++i) {
    if (lst[c[i]] != -1) {
      bit.update(lst[c[i]], -1);
    }
    lst[c[i]] = i;
    bit.update(i, 1);

    for (pair<int, int> p: queries[i]) { 
      ans[p.second] = bit.query(p.first, i);
    }
  }

  for (int i = 0; i < q; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 33144
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  vector<int> sieve(1e6 + 1);
  for (int i = 2; i <= n; ++i) {
    if (sieve[i] == 0) {
      for (int j = i * i; j <= n; j += i) {
        sieve[j] = i;
      }
      sieve[i] = i;
    }
  }
  auto del = [&](int x) {
    int smallest = sieve[x];
    int cur = x;
    int ans = 1;
    bool ok = true;
    while (cur > 1) {
      int p = 0;
      while (cur % smallest == 0) {
        cur /= smallest;
        ++p;
      }
      ok &= (p & 1 ^ 1);
      ans *= (p + 1);
      smallest = sieve[cur];
    }
    return make_pair(ans, ok);
  };
  for (int C = 1; C <= n - 1; ++C) {
    int AxB = n - C;
    auto d = del(AxB);
    ans += d.first;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 11096
#include<stdio.h>
#include<set>
#include<algorithm>
#define N 200002
using namespace std;
int A[N], ans=0;
multiset<int> s;
multiset<int>::iterator it;
int main(){
    int i,nm,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
        s.insert(A[i]);
    }
    sort(A+1,A+1+n);
    for(nm=1;nm<=A[n];nm*=2);
    for(i=n;i>=1;i--){
        while(nm>(A[i]*2)){
            nm/=2;
        }
        it=s.find(A[i]);
        if(it==s.end()){continue;}
        s.erase(it);
        it=s.find(nm-A[i]);
        if(it==s.end()){continue;}
        s.erase(it);
        ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 10368
import java.io.PrintWriter;
import java.util.*;

public class Main {

	static int c;
	static int[] w;
	static int[] v;
	static long[][] dp;
	static int n;

	public static long KnapSack(int idx, int remw) {
		if (remw < 0) {
			return -(int) 1e9;
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][remw] != -1) {
			return dp[idx][remw];
		}
		long take = v[idx] + KnapSack(idx + 1, remw - w[idx]);
		long leave = KnapSack(idx + 1, remw);
		return dp[idx][remw] = Math.max(take, leave);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		c = sc.nextInt();
		w = new int[n];
		v = new int[n];
		dp = new long[n][c+5];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		pw.println(KnapSack(0, c));
		pw.close();
	}

}

Measured memory_bytes: 131648
/* 競プロ用のテンプレ
 * SKMT
 * 作成日   2020年09月13日  20:59
 * ファイル名    a.cpp
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;//long long型をllで

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

int main(int argc, char const* argv[]){
	int x;
	cin>>x;
	if(x==0){
	cout<<1<<endl;
	}
	else{
	cout<<0<<endl;
	}
		return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if((i+1)%2==1&&s[i]=='L'){
			cout<<"No"<<endl;
			return 0;
		}
		if((i+1)%2==0&&s[i]=='R'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0; }

Measured memory_bytes: 256
#13A - Cookie Exchanges
A,B,C = map(int, input().split())
cnt = 0
while (A%2 + B%2 + C%2) == 0:
    if A == B == C:
        print (-1)
        exit()
    else:
        a = B/2 + C/2
        b = A/2 + C/2
        c = A/2 + B/2
        A = a
        B = b
        C = c
        cnt += 1

print (cnt)

Measured memory_bytes: 9248
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXZERO=2000;
const int MAXONE=2000;
const int MAXK=2000;
const int MAXH=MAXZERO+MAXONE-1;
const int MOD=1000000007;

int nzero,none,k;

int F[MAXH+1][MAXZERO+MAXONE];


void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
void run() {
	scanf("%d%d%d",&nzero,&none,&k);
	int ret=0;
	F[0][0]=1;
	for(int h=1;;++h) {
		int nside=(k-1)*h;
		if(none-1+nzero<nside) break;
		REP(i,nzero+none) REP(j,k) if(i>=j) inc(F[h][i],F[h-1][i-j]);
		if(none-1>=nside) continue;
		//printf("%d = %d\n",h,F[h][none-1]);
		inc(ret,F[h][none-1]);
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO

    lli n;
    cin >> n;
    lli sum = 0;
    fe(i, 1, n)
    {
        fe(j, 1, n)
        {
            fe(k, 1, n)
            {
                lli tmp = __gcd(j, k);
                sum += __gcd(i, tmp);
            }
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3660
N,M = map(int,input().split())
ans = N*M
if N==1 and M==1:
    print(1)
    exit()
if N < 3 and M < 3:
    print(0)
    exit()
#偶数回操作が行われるもの
even = 0
#奇数回操作が行われるもの
odd = 0
#答えはoddの値
if N<=M:
    if N==1:
        s = 2*N
        print(ans-s)
    else:
        s = 2*N+2*(M-2)
        print(ans-s)
else:
    if M==1:
        s = 2*M
        print(ans-s)
    else:
        s = 2*M+2*(N-2)
        print(ans-s)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (998244353ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

vector<int> g[123456];
int dz[123456],dn[123456];
queue<int> q;

int main(void){
	int n,i,a,b,p,cnt=0;
	fill(dz,dz+123456,INF);
	fill(dn,dn+123456,INF);
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> a >> b; --a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dz[0] = 0; q.push(0);
	while(!q.empty()){
		p = q.front();
		q.pop();
		for(i=(g[p].l_ength()-1); i>=0; --i){
			if(dz[g[p][i]] == INF){
				dz[g[p][i]] = dz[p] + 1;
				q.push(g[p][i]);
			}
		}
	}
	q.push(n-1); dn[n-1] = 0;
	while(!q.empty()){
		p = q.front();
		q.pop();
		for(i=(g[p].l_ength()-1); i>=0; --i){
			if(dn[g[p][i]] == INF){
				dn[g[p][i]] = dn[p] + 1;
				q.push(g[p][i]);
			}
		}
	}
	for(i=0; i<n; ++i){
		if(dz[i] > dn[i]){
			--cnt;
		}else{
			++cnt;
		}
	}
	cout << ((cnt>0)?"Fennec":"Snuke") << endl;
	return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
using namespace std;
int main() {
    int dd[] = {0,6000,4000,3000,2000};
    for(int i = 0; i < 4; i++) {
        int t,n;
        scanf("%d %d",&t,&n);
        printf("%d\n",dd[t] * n);
    }
    return 0;
}

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

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

using namespace std;

using ll = long long int;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  return os;
}

// template <typename T>
// void print_table(ostream& os, const T , int m, int n)
// {
//   for(int i = 0; i < m; ++i)
//   {
//     for(int j = 0; j < n; ++j)
//     {
//       cout << dp[i][j] << " ";
//     }
//     cout << endl;
//   }
// }

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, a;
  cin >> x >> a;
  if (x < a)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll N, K;
	ll i, init;
	ll ans = 0;
	cin >> N >> K;

	if (K == 0) {
		cout << N * N << endl;
		return 0;
	}

	for (ll r = K; r <= N - 1; r++) {
		ans += N - r;
		i = 1;
		while ((init = r + (r + 1) * i) <= N) {
			ans += 1 + (N - init) / i;
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
temp = 1000
ind = -1
for i in range(n):
    if abs(a-(t-0.006*h[i])) < temp:
        temp = abs(a-(t-0.006*h[i]))
        ind = i+1
print(ind)

Measured memory_bytes: 3064
import collections
import sys
input=sys.stdin.readline

def solve():
  n=int(input())
  arr=list(map(int,input().split()))
  cost=[[30000]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      cost[i][j]=min(i,n-(i+1),j,n-(j+1))
  board=[[1]*n for _ in range(n)]
  ans=0
  for val in arr:
    x=(val-1)%n
    y=(val-1)//n
    ans+=cost[y][x]
    board[y][x]=0
    q=collections.deque()
    q.append((x,y))
    while len(q)!=0:
      x,y=q.popleft()
      c=cost[y][x]+board[y][x]
      if x>0 and c<cost[y][x-1]:
        cost[y][x-1]=c
        q.append((x-1,y))    
      if x<n-1 and c<cost[y][x+1]:
        cost[y][x+1]=c
        q.append((x+1,y))    
      if y>0 and c<cost[y-1][x]:
        cost[y-1][x]=c
        q.append((x,y-1))    
      if y<n-1 and c<cost[y+1][x]:
        cost[y+1][x]=c
        q.append((x,y+1))
  print(ans)
solve()

Measured memory_bytes: 121436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		if (x == 7 || x ==5 || x==3)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}

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

const int mod = (int)1e9 + 7;

class modulo_combination {
 private:
  vector<int> factrial, inverse;
  int pow(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return pow((long long)x * x % mod, y / 2);
    return (long long)x * pow(x, y - 1) % mod;
  }

 public:
  modulo_combination(int n) : factrial(n + 1), inverse(n + 1) {
    inverse[0] = factrial[0] = 1;
    for (int i = 1; i <= n; i++) {
      factrial[i] = (long long)factrial[i - 1] * i % mod;
      inverse[i] = pow(factrial[i], mod - 2);
    }
  }
  int operator()(int n, int k) { return (long long)factrial[n] * inverse[k] % mod * inverse[n - k] % mod; }
  int f(int n) { return factrial[n]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (auto &e : a) cin >> e;
  for (auto &e : b) cin >> e;
  sort(begin(a), end(a));
  sort(begin(b), end(b));

  if (unique(begin(a), end(a)) != end(a) || unique(begin(b), end(b)) != end(b)) {
    cout << 0 << endl;
    return 0;
  }

  modulo_combination c(n * m + 1);

  ll r = 1;
  int p = 0;
  for (int i = 0, j = 0; i < n || j < m;) {
    ll x, y, z;
    p++;
    if (i < n && j < m && a[i] == b[j]) {
      x = a[i] - p;
      y = (n - i - 1) + (m - j - 1);
      z = y;
      i++;
      j++;
    } else if (!(j < m) || i < n && a[i] < b[j]) {
      x = a[i] - p;
      y = m - j - 1;
      z = y + 1;
      i++;
    } else {
      x = b[j] - p;
      y = n - i - 1;
      z = y + 1;
      j++;
    }
    if (x - y < 0) {
      r = 0;
      break;
    }
    r *= (ll)c(x, y) * c.f(z) % mod;
    r %= mod;
    p += y;
  }
  cout << r << endl;
}


Measured memory_bytes: 8064
import math
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for x in range(-20,21):
    for y in range(-20,21):
        sx = 0
        sy = 0
        for v in a:
            if v[0]*x+v[1]*y>0:
                sx+=v[0]
                sy+=v[1]
        ans = max(ans,math.sqrt(sx*sx+sy*sy))
print(ans)

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

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

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int n = scanner.nextInt();
        int tmp;
        int count = 0;
        for (int i=0;i<n;i++) {
        	tmp = scanner.nextInt();
        	while(tmp%2==0) {
        		count++;
        		tmp/=2;
        	}
        }
        System.out.println(count);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

using namespace std;
map<string,int> mp;
int main()
{
    int n;
    scanf("%d",&n);
    string str;
    int mn=-1;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        mp[str]++;
        mn=max(mp[str],mn);
    }
    map<string,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
        string a=it->first;
        if(mp[a]==mn)
            cout<<a<<"\n";
    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long[]x=new long[n];
		long[]y=new long[m];
		for(int i=0;i<n;i++)x[i]=sc.nextLong();
		for(int i=0;i<m;i++)y[i]=sc.nextLong();
		
		long ans=0;
		long WidthSum=0;
		long HeightSum=0;
		for(int i=0;i<n;i++){
			WidthSum+=i*x[i]-(n-1-i)*x[i];
			WidthSum%=(1000000000+7);
		}
		for(int i=0;i<m;i++){
			HeightSum+=i*y[i]-(m-1-i)*y[i];
			HeightSum%=(1000000000+7);
		}
		ans+=WidthSum*HeightSum%(1000000000+7);
		System.out.println(ans);
	}

}


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

int main() {
  rep(i,3000){
    int x,y;
    cin >> x >> y;
    if(!(x==0 && y==0)){
      cout << min(x,y) << " " << max(x,y) << endl;
    }
    else return 0;
  }
  return 0;
}


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

const long long INF = 1LL << 60;

int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    long long ans = 0;

    for(int i=0; i<N; ++i){
        cin >> H[i];
    }

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

    if( N <= K){
        ans = 0;
    }else{
        for(int i=K; i<N; ++i){
            ans += H[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4792
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = 100000000000000

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

Measured memory_bytes: 9228
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 15 22:46:42 2019

@author: Yamazaki Kenichi
"""
import math
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

temp1,temp2 = 0,0
if N%2 != 55:
    temp1 += A[-1]+A[-2]-2*A[0]
#    print(temp1,A[-1],A[-2],A[0])
    for i in range(N//2-1):
        temp1 += A[-1-(math.ceil(i/2)*2)] - A[(i//2*2)+1]
        temp1 += A[-2-(math.ceil(i/2)*2)] - A[(i//2*2)+2]
#        print(temp1,-1-(math.ceil(i/2)*2),-2-(math.ceil(i/2)*2),(i//2*2)+1,(i//2*2)+2)
    temp2 += 2*A[-1]-A[0]-A[1]
#    print(temp2,A[-1],A[0],A[1])
    for i in range(N//2-1):
        temp2 += A[-2-(i//2*2)] - A[(math.ceil(i/2)*2)]
        temp2 += A[-3-(i//2*2)] - A[(math.ceil(i/2)*2)+1]
#        print(temp2,-2-(i//2*2),-3-(i//2*2),(math.ceil(i/2)*2),(math.ceil(i/2)*2))
print(max(temp1,temp2))

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ull mod = 1000000007;

int main(){
    ull n, k;
    cin >> n >> k;
    vector<ull> a(n);
    for(auto& i : a) cin >> i;

    vector<ull> r(n), l(n);
    for(ull i = 0; i < n; i++){
        for(ull j = 0; j < i; j++) if(a.at(i) > a.at(j)) l.at(i)++;
        for(ull j = i; j < n; j++) if(a.at(i) > a.at(j)) r.at(i)++;
    }

    ull ans = 0;
    for(ull i = 0; i < n; i++){
        ans = (ans + k * (k + 1) / 2 % mod * r.at(i) % mod + k * (k - 1) / 2 % mod * l.at(i) % mod) % mod; 
    }
    
    cout << ans % mod<< endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 1100000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> X,Y;
ll dp[2100][2];

int main(){
    int N;
    ll Z,W,a[2100];
    cin>>N>>Z>>W;
    for(int i=0;i<N;i++) cin>>a[i];

    for(int i=N-1;i>=0;i--){
        for(int j=0;j<2;j++){
            if(j==0){
                ll ans=0;
                for(int k=i+1;k<=N-1;k++){
                    ans=max(ans,dp[k+1][1]);
                }
                ll b;
                if(i==0) b=W;
                else b=a[i-1];
                dp[i][j]=max(ans,abs(b-a[N-1]));
            }else{
                if(i==0) continue;
                ll ans=1000000000;
                for(int k=i+1;k<=N-1;k++){
                    ans=min(ans,dp[k+1][0]);
                }
                dp[i][j]=min(ans,abs(a[i-1]-a[N-1]));
            }
        }
    }
    cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    const int n = s.size();
    int f[n+1];
    map<int, int> g;
    int dp[n+1];
    f[0] = 0;
    g[0] = 0;
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        f[i] = f[i-1]^(1<<(s[i-1]-'a'));
        int val = i;
        for (int j = 0; j < 26; j++) {
            int b = f[i]^(1<<j);
            if (g.find(b) != g.end())
                val = min(val, 1 + g[b]);
        }
        if (g.find(f[i]) != g.end()) {
            val = min(val, 1 + g[f[i]]);
            g[f[i]] = min(g[f[i]], val);
        } else
            g[f[i]] = val;
        dp[i] = val;
    }
    cout << dp[n] << endl;
}


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

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

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

  int n;
  cin >> n;

  vector<ll> h(n);
  rep(i, n) { cin >> h[i]; }

  vector<ll> diff(n - 1);
  rep(i, n - 1) { diff[i] = h[i + 1] - h[i]; }

  int max_cnt = 0;
  int cnt = 0;
  rep(i, n - 1) {
    if (diff[i] <= 0) {
      cnt++;
      if (max_cnt < cnt) {
        max_cnt = cnt;
      }
    } else {
      cnt = 0;
    }
  }

  cout << max_cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if (sc.next().equals("snuke")) {
					System.out.println(String.valueOf((char) ('A' + j)) + (i+1));
					return;
				}
			}
		}
	}

}


Measured memory_bytes: 10188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
int main(){
    int n;
    cin >> n;
    map<char, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        map<char, int> tmp;
        if (i == 0) {
            rep(i, s.size()) {
                mp[s[i]]++;
            }
            continue;
        }
        rep(i, s.size()) {
            tmp[s[i]]++;
        }
        for (auto p: mp) {
            mp[p.first] = min(p.second, tmp[p.first]);
        }
    }
    for (auto p: mp) {
        rep(i, p.second) {
            cout << p.first;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int amount = input.nextInt();
		int[][] matrix = new int[amount][amount];
		int[] visited = new int[amount];
		int weight = 0;
		visited[0] = 0;
		
		for(int i = 1; i < amount; i++) {
			visited[i] = -1;
		}
		for(int i = 0; i < amount; i++) {
			for(int j = 0; j < amount; j++) {
				int num = input.nextInt();
				matrix[i][j] = num;
			}
		}
		for(int i = 0; i < amount; i++) {
			matrix[i][0] = -1;
		}
		input.close();		
		for(int i = 1; i < amount; i++) {
			int vertex = 0;
			int min = 2001;
			int x = 0;
			int row = 0;
			while(visited[x] != -1) {
				for(int j = 0; j < amount; j++) {
					int compare = matrix[visited[x]][j]; //turned the vertex/weight checking into compare because it is hard to debug
					if(compare < min && compare != -1) { //ignores all -1
						vertex = j;
						min = compare;
						row = visited[x];
					}
				}
				x++;
			}
			weight += min;
			visited[i] = vertex;
			for(int k = 0; k < amount; k++) {
				matrix[k][vertex] = -1; //makes vertex be -1 everywhere, effectively removing it
			}
		}
		System.out.println(weight);
	}
}



Measured memory_bytes: 40892
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns     #-}
{-# LANGUAGE TypeApplications #-}
import           Control.Exception     (assert)
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import           Data.Char             (isSpace)
import           Data.Int              (Int64)
import           Data.List             (unfoldr)
import           Data.Ratio
import qualified Test.QuickCheck       as QC

-- comb2 n = n * (n - 1) `quot` 2 without undue overflow
-- n even: comb2 n = (n `quot` 2) * (n - 1)
-- n odd: comb2 n = n * (n `quot` 2)
comb2 :: (Integral a, Bits a) => a -> a
comb2 n = (n `shiftR` 1) * ((n - 1) .|. 1)

-- floorSum n m a b
-- Assumptions:
-- * n: non-negative, m: positive
-- * a and b can be negative, or >= m
floorSum :: Int64 -> Int64 -> Int64 -> Int64 -> Int64
floorSum !n !m !a !b
  | assert (n >= 0 && m > 0) False = undefined
  | a < 0 = floorSum n m (- a) (b + a * (n - 1))
  | otherwise = floorSum_positive 0 n m a b
  where
    -- Invariants:
    -- * n: non-negative, m: positive, a: non-negative
    -- * 0 <= n <= m
    floorSum_positive :: Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Int64
    floorSum_positive !acc !n !m !a !b
      | n == 0 = acc
      | let m2 = m `quot` 2, a > m2 =
              let (q, a') = (a + m2) `quotRem` m
                  (a'',b'') = if a' < m2 then
                                (m2 - a', b - (m2 - a') * (n - 1))
                              else
                                (a' - m2, b)
              in floorSum_positive (acc + q * comb2 n) n m a'' b''
      | otherwise =
          let (q, b') = b `divMod` m
              t = (a * (n - 1) + b') `div` m
              -- t <= (m * (m - 1) + m) `div` m = m
          in floorSum_positive (acc + n * (q + t)) t a m (b' - m * t)

floorSum_naive :: Int64 -> Int64 -> Int64 -> Int64 -> Integer
floorSum_naive n m a b = sum [ floor ((toInteger a * toInteger i + toInteger b) % toInteger m) | i <- [0..n-1] ]

main = do
  t <- readLn @Int
  replicateM_ t $ do
    [n,m,a,b] <- map fromIntegral . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    print $ floorSum n m a b

prop_comb2 :: Integer -> QC.Property
prop_comb2 n = comb2 n QC.=== n * (n - 1) `quot` 2

prop_floorSum :: QC.NonNegative (QC.Small Int64) -> QC.Positive Int64 -> Int64 -> Int64 -> QC.Property
prop_floorSum (QC.NonNegative (QC.Small n)) (QC.Positive m) a b = QC.within (100 * 1000) $ toInteger (floorSum n m a b) QC.=== floorSum_naive n m a b

prop_floorSum_r :: QC.Property
prop_floorSum_r = QC.forAllShrink (QC.choose (1, 10^4)) QC.shrink $ \n -> n >= 1 QC.==>
  QC.forAllShrink (QC.choose (1, 10^9)) QC.shrink $ \m -> m >= 1 QC.==>
  QC.forAllShrink (QC.choose (0, m - 1)) QC.shrink $ \a ->
  QC.forAllShrink (QC.choose (0, m - 1)) QC.shrink $ \b ->
  QC.within (100 * 1000 {- 100ms -}) $ toInteger (floorSum n m a b) QC.=== floorSum_naive n m a b


Measured memory_bytes: 4940
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  i64 K;
  cin >> N >> K;

  vector<int> as(N);
  F0R(i, N) cin >> as[i];

  vector<bool> visit(N, false);

  vector<int> bs;
  int pos = 0;

  int head, loop;

  while (true) {
    bs.push_back(pos);
    visit[pos] = true;
    pos = as[pos] - 1;

    if (visit[pos]) {
      auto it = find(bs.begin(), bs.end(), pos);
      int fpos = it - bs.begin();

      head = fpos - 0;
      loop = bs.size() - head;
      break;
    }
  }

  //debug(head);
  //debug(loop);
  //Print(bs);
  int idx = K <= head ? K : ((K - head) % loop + head);

  cout << (bs[idx] + 1);
}
#endif


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

int main() {
	long long num=1;
	long long n;
	cin >> n;
	
	long long t=1,a=1;
	for(int cnt=0; cnt<n; cnt++){
		long long T,A;
		cin>>T>>A;
		
		long long bai=max((t-1)/T+1, (a-1)/A+1);
		
		t=T*bai;
		a=A*bai;

	
	
	
	}
	cout<<a+t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int a,b,c;
int main()
{
//////////////////////////a
    a=read(),b=read();c=6-a-b;cout<<c<<"\n";
	return 0;
}


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

typedef long long ll;
using namespace std;
const int maxn = 1e6+5;
int main()
{
    int n, k, s;
    cin >> n >> k >> s;
    for(int i = 1; i <= k; i++) {
        cout << s << " ";
    }
    for(int i = k+1; i <= n; i++) {
        if(s == 1) cout << 2 << " ";
        else cout << s-1 << endl;
    }
    cout << endl;
}


Measured memory_bytes: 1280
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll w,a,b;
    cin >> w >> a >> b;
    cout << max({0LL,b-(a+w),a-(b+w)}) << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;


// '.' white
// '#' black
int countblack(vector< string > &ar) {
    int cnt = 0;
    for(int i = 0; i < ar.size(); i++) {
        for(char ch: ar[i]) if(ch == '#') cnt++;
    }
    return cnt;
}

int main() {
    fast;

    int h, w, k; cin >> h >> w >> k;

    vector< string > ar(h);
    for(int i = 0; i < h; i++) {
        cin >> ar[i];
    }

    int R = (1 << h);
    int C = (1 << w);
    int ans = 0, tmp;

    for(int i = 0; i < R; i++) {
        for(int j = 0; j < C; j++) {

            vector< string > A = ar;

            tmp = i; // row
            for(int row = 0; tmp; row++) {
                if(tmp & 1) {
                    for(int itr = 0; itr < w; itr++) A[row][itr] = '*';
                }
                tmp >>= 1;
            }

            tmp = j; // col
            for(int col = 0; tmp; col++) {
                if(tmp & 1) {
                    for(int itr = 0; itr < h; itr++) A[itr][col] = '*';
                }
                tmp >>= 1;
            }
            if(countblack(A) == k) ans++;
        }
    }


    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

#define INF 1<<30

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            int tmp; cin >> tmp;
            tmp--;
            c[i] += (1<<tmp);
        }
    }
    vector<vector<int>> dp(M+1, vector<int>(1<<N, INF));
    dp[0][0] = 0;
    rep(i, M) {
        rep(j, 1<<N) {
            chmin(dp[i+1][j], dp[i][j]); // 取らない
            int nj = (j|c[i]);
            chmin(dp[i+1][nj], dp[i][j] + a[i]); //　取る
        }
    }
    cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;
}

Measured memory_bytes: 19340
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstdio>
using namespace std;

int main() {
	int n;
	while(cin >> n, n != 0) {
		
		vector<double> p(n);
		vector<vector<int>> rE(n);
		const int inf = 1 << 20;
		vector<vector<int>> b(n, vector<int>(n, inf));
		
		for(int i = 0; i < n; ++i) {
			cin >> p[i];
			
			int m;
			cin >> m;
			
			for(int j = 0; j < m; ++j) {
				int to;
				cin >> to;
				to--;
				rE[to].push_back(i);
				b[i][to] = 1;
			}
		}
		
		for(int k = 0; k < n; ++k) {
			for(int i = 0; i < n; ++i) {
				for(int j = 0; j < n; ++j) {
					b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
				}
			}
		}
		
		vector<int> ids(n, -1);
		
		int nid = 0;
		
		for(int i = 0; i < n; ++i) {
			if(ids[i] != -1) {
				continue;
			}
			
			ids[i] = nid;
			for(int j = i + 1; j < n; ++j) {
				if(ids[j] != -1) {
					continue;
				}
				if(b[i][j] != inf && b[j][i] != inf) {
					ids[j] = ids[i];
				}
			}
			
			nid++;
		}

		//for(int i = 0; i < n; ++i) {
		//	cout << i << ": " << ids[i] << endl;
		//}
		
		double res = 1.0;
		for(int id = 0; id < nid; ++id) {
			bool f = true;
			
			double pid = 1.0;
			for(int i = 0; i < n; ++i) {
				if(ids[i] != id) {
					continue;
				}
				
				for(int from : rE[i]) {
					if(ids[from] != id) {
						f = false;
						break;
					}
				}
				
				if(!f) {
					break;
				}
				
				pid *= p[i];
			}
			
			if(f) {
				res *= 1 - pid;
			}
		}
		
		printf("%.10f\n", res);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const int N = (int) 2e5 + 7;
int n;
int k;
int a[N];
ll sol = 0;

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

        cin >> n >> k;
        for (int i = 1; i <= n; i++)
                cin >> a[i];
        k = n - min(k, n);
        sort(a + 1, a + n + 1);
        for (int i = 1; i <= k; i++)
                sol += a[i];
        cout << sol << "\n";

}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	string s;
	cin >> s;
	
	if (s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) string((s).rbegin(), (s).rend())
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 1000000;


class V{
public:
	int total;
	int ticket;
	int to;
};
bool operator>(const V &lh, const V &rh){
	return (lh.total > rh.total);
}


int main(){
	while(1){

		int c, n, m, s, d;
		cin >> c >> n >> m >> s >> d;
		if(!(c+n+m+s+d))break;
		n++;
		vector<vector<int> > fare(n, vector<int>(n, INF));
		rep(i, m){
			int a, b, f;
			cin >> a >> b >> f;
			fare[a][b] = fare[b][a] = f;
		}

		vector<vector<int> > best(c+1, vector<int>(n, INF));

		V start;
		start.total = 0;
		start.ticket = 0;
		start.to = s;

		priority_queue<V, vector<V>, greater<V> > q;
		q.push(start);

		while(!q.empty()){
			V p = q.top();
			q.pop();

			if(best[p.ticket][p.to] <= p.total) continue;
			best[p.ticket][p.to] = p.total;

			rep(i, n){
				if(fare[p.to][i] == INF ) continue;
				V next;
				next.total = p.total + fare[p.to][i];
				next.ticket = p.ticket;
				next.to = i;
				q.push(next);
				if(p.ticket < c){
					next.total = p.total + fare[p.to][i]/2;
					next.ticket = p.ticket+1;
					next.to = i;
					q.push(next);
				}
			}
		}

		rep(i, c){
			best[c][d] = min(best[c][d], best[i][d]);
		}

		cout << best[c][d] << endl;
	}

	return 0;
}

Measured memory_bytes: 1388
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
        ld ans=0;
        ld pi=3.1415926535897932384626433;
        ans=2*pi*n;
        cout<<fixed<<setprecision(9)<<ans<<endl;

    }
  return 0;
}




Measured memory_bytes: 3784
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(200001, 0);

  rep(i, N) {
    int a;
    cin >> a;
    d.at(a)++;
  }

  sort(all(d), greater<int>());

  int num = 0;

  rep(i, K) {
    num += d.at(i);
  }

  cout << N - num << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a , long long b){
    if(b == 0) return a;
    return gcd(b , a % b);
}

int main(void){

    long long A , B , C , D;   cin >> A >> B >> C >> D;
    long long lcm = C * D /gcd(C , D);
    long long n1 = B / C - A / C, n2 = B / D - A / D , n3 = B / lcm - A / lcm;
    if(A % C == 0) n1++;  if(A % D == 0) n2++; if(A % lcm == 0) n3++;
    long long ans = n1 + n2 - n3;

    cout << B - A + 1 -ans << endl;

    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int h = ri();
	int w = ri();
	int n = ri();
	int s_1 = ri(), s_2 = ri();
	std::string s, t;
	std::cin >> s >> t;
	
	int l = 1, r = w;
	bool res = true;
	for (int i = n - 1; i >= 0; i--) {
		// aoki
		if (t[i] == 'L' && r < w) r++;
		else if (t[i] == 'R' && l > 1) l--;
		if (r < l) {
			res = false;
			break;
		}
		if (s[i] == 'L') l++;
		else if (s[i] == 'R') r--;
		if (r < l) {
			res = false;
			break;
		}
		// std::cerr << "l:" << l << " r:" << r << std::endl;
	}
	// std::cerr << std::endl;
	if (s_2 < l || s_2 > r) res = false;
	l = 1, r = h;
	for (int i = n - 1; i >= 0; i--) {
		// aoki
		if (t[i] == 'U' && r < h) r++;
		else if (t[i] == 'D' && l > 1) l--;
		if (r < l) {
			res = false;
			break;
		}
		if (s[i] == 'U') l++;
		else if (s[i] == 'D') r--;
		if (r < l) {
			res = false;
			break;
		}
		// std::cerr << "l:" << l << " r:" << r << std::endl;
	}
	if (s_1 < l || s_1 > r) res = false;
	std::cout << (res ? "YES" : "NO") << std::endl;
	
	return 0;
}


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


int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0];


 return 0;
}


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

using namespace std;

int main(){
  int N;
  long long ans = 0;
  vector<long long> A;
  cin >> N;
  long long a;
  for(int i =0; i < N; i++){
    cin >> a;
    int count = 0;
    while(a%2 == 0){
      count++;
      a = a/2;
    }
    A.push_back(count);
  }
  for(int i = 0; i < N; i++){
    ans += A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 512