akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  
  int a, b, c;
  cin >> a >> b >> c;
  
  vector<int> A(3);
  
  A.at(0) = a;
  A.at(1) = b;
  A.at(2) = c;
  
  sort(A.begin(), A.end());
  int n=3;
  
  for (int i=0; i<2; i++){
    
    if (A.at(i) == A.at(i+1))
      n--;
    
  }
  
  cout << n << endl;

}

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

int check(int);

int main(void){
  int n, a, b, sum;
  cin >> n >> a >> b;
  sum = 0;

  for(int i = 1;i <= n; i++){
    if(a <= check(i) && check(i) <= b) sum += i;
  }
  cout << sum << endl;
  return 0;
}

int check(int n){
  int t, sum;
  sum = n % 10;
  while(n != 0){
    n = (int)(floor(n / 10.0));
    sum += n % 10;
  }
  return sum;
}

Measured memory_bytes: 256
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
a=0
aa=0
for i in l:
    if i%4==0:
        aa+=1
    elif i%2==0:
        a+=1
aaa=n-a-aa
aaa+=a%2
if aaa-1<=aa:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62704
import collections
def main():
    s = input()
    d = collections.defaultdict(list)
    chars = set(list(s))
    for c in chars:
        d[c].append(-1)
    for i in range(len(s)):
        d[s[i]].append(i)
    for c in chars:
        d[c].append(len(s))
    minmax_dist = float('inf')
    for c in chars:
        max_dist = 0
        for i in range(len(d[c])-1):
            max_dist = max(max_dist, d[c][i+1] - d[c][i]-1)
        minmax_dist = min(minmax_dist, max_dist)
    return minmax_dist


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3444
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    canWin = [None] * (K + 1)
    canWin[0] = False

    for k in range(1, K + 1):
        for a in A:
            if k - a >= 0 and canWin[k - a] == False:
                canWin[k] = True
                break
        else:
            canWin[k] = False

    if canWin[K]:
        print('First')
    else:
        print('Second')

sol()

Measured memory_bytes: 40048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int ans = 0;
	for (int ii = 0; ii < s.size(); ++ii){
		if (s[ii] != t[ii]){
			ans++;
		}

	}

	cout << ans << "\n";

	return 0;
}


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

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    int B[M];
    int A[N][M];
    for(int i=0;i<M;i++)cin>>B[i];

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    int tmp;
    int ans=0;
    for(int i=0;i<N;i++){
        tmp=0;
        for(int j=0;j<M;j++){
            tmp = tmp + A[i][j]*B[j];
        }
        tmp = tmp+C;
        if(tmp>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int n; cin >> n;
    string s; cin >> s;

    int red=0, blue=0;

    REP(i,n){
        if(s[i]=='R') red++;
        else blue++;
    }

    if(red>blue) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

dt, dx, dy = 0, 0, 0
for i in range(n) :
    t, x, y = map(int, input().split())
    dt, dx, dy = abs(dt - t), abs(dx - x), abs(dy - y)
    if dt < dx + dy or dt % 2 != (dx + dy) % 2 :
        print("No")
        exit()
    dt, dx, dy = t, x, y

print("Yes")

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=20+3,ms=(1<<19)+3,mo=1e9+7;
int n,m,K,a[mn][mn],f[2][ms],nx[ms][mn];
inline int mod(int x){return (x>=mo)?x-mo:x;}
int main(){
	scanf("%d%d%d",&n,&m,&K);
	fo(i,1,K){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		a[x][y]=z+1;
	}
	int lim=(1<<(n-1))-1,tg=0;
	fd(s,lim,0)fd(i,n-1,1)nx[s][i]=((s>>(i-1))&1)?i:nx[s][i+1];
	f[tg][0]=1;
	fo(i,1,m)fo(j,1,n-1){
		fo(s,0,lim)if(f[tg][s]){
			int tmp=(nx[s][j])?(1<<(nx[s][j]-1)):0,
				tm2=s+(1<<(j-1))-tmp;
			if((a[i][j]!=1)&&(!(s&(1<<(j-1)))))
				f[!tg][tm2]=mod(f[!tg][tm2]+f[tg][s]);
			if(a[i][j]+((s>>j-1)&1)!=2)
				f[!tg][s]=mod(f[!tg][s]+f[tg][s]);
		}
		memset(f[tg],0,sizeof(f[tg]));
		tg=!tg;
	}
	int ans=0;
	fo(s,0,lim)ans=mod(ans+f[tg][s]);
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 51328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n, a; cin >> n >> a;
    n %= 500;
    if (n <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] cL = s.toCharArray();
        for (int i = 1; i< cL.length;i++) {
            if (cL[i-1] == cL[i]) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
bool sortby(const pair<string, int> &a,
			const pair<string, int> &b)
{
	if (a.first == b.first){
		 return a.second > b.second;
		 }
	else return a.first < b.first;
}
int main(){
	int n;
	cin >> n;
	int p;
	map<pair<string,int>, int> m;
	vector<pair<string,int>> v;
	for (int i = 0; i<n;i++){
		string s;
		cin >> s >> p;
		v.push_back(make_pair(s,p));
		m[make_pair(s,p)] = i+1;
	}
	sort(v.begin(),v.end(),sortby);
	for (auto x: v) cout << m[x] <<endl;
	
 }


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    scanf("%d", &N);
    int h[N];
    int max_h = -1;
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
        max_h = max(max_h, h[i]);
    }
    int count[max_h];
    bool status[max_h];
    for (int i = 0; i < max_h; i++) {
        count[i] = 0;
        status[i] = false;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= max_h; j++) {
            if (h[i] >= j) {
                if (!status[j-1]) count[j-1]++;
                status[j-1] = true;
            } else status[j-1] = false;
        }
    }
    int sum = 0;
    for (int j = 0; j < max_h; j++) sum += count[j];

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int abs(int a)
{
  return (a > 0) ? a : -a;
}

int main()
{
	
  int n;
  std::cin >> n;
  
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++ )
    std::cin >> a[i] >> b[i] >> c[i];
 
  int dpa[n], dpb[n], dpc[n];
  dpa[0] = a[0];
  dpb[0] = b[0];
  dpc[0] = c[0];
  
  for ( int i = 1; i < n; i++ )
  {
    dpa[i] = a[i] + std::max(dpb[i - 1], dpc[i - 1]);
    dpb[i] = b[i] + std::max(dpa[i - 1], dpc[i - 1]);
    dpc[i] = c[i] + std::max(dpa[i - 1], dpb[i - 1]);
  }
  
  std::cout << std::max(dpa[n - 1], std::max(dpb[n - 1], dpc[n - 1])) << std::endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
bool reached[8];
bool g[10][10];

int dfs(int now,int depth)
{
    if(reached[now]) return 0;
    if(depth == n) return 1;

    reached[now] = true;

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(g[now][i]){
            ans += dfs(i,depth+1);
        }
    }
    reached[now] = false;
    return ans;
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        reached[i] = false;
    }
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a][b] = true;
        g[b][a] = true;
    }
    cout << dfs(0,1);
}

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

int main(){
  int a[5];
  int tmp = 0;
  for(int i = 0; i < 5; i++){
    cin >> a[i];
    if(0 == a[i]){
      tmp = i;
    }
  }
  
  if(0 == a[0]){
    cout << a[1] - 1 << endl;
  }
  else if(0 == a[4]){
    cout << a[3] + 1 << endl;
  }
  else{
    cout << a[tmp + 1] - 1 << endl;
  }
  return 0;
}
  

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    char a,b,c;
    cin >> a >> b >> c;

    if(a+b+c == 'a' + 'b' + 'c') cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cout << v << " ";  \
  }                    \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  print(N / 3);
}

Measured memory_bytes: 256
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = A+B+1;
		int X = K;
		if(X>C) X = C;

		System.out.println(B+X);

	}
}

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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

int main()
{   
    int n;
    scanf("%d", &n);

    vector < int > V;
    while (n)
    {
        int newN = n / -2;
        if (newN * -2 > n)
            ++newN;
        V.push_back((bool)(n - newN * -2));
        n = newN;
    }
    if (V.empty())
        printf("0");
    for (int i = V.size() - 1; i >= 0; --i)
        printf("%d", V[i]);

    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-8;
const double inf=1e12;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
P reflection(const L& l,const P& p){
  return p+2.0*(projection(l,p)-p);
}
//// counter-clockwise
int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L& l,const L& m){
  return abs(cross(l[1]-l[0],m[1]-m[0]))>eps;
}

int main(){
	cin.sync_with_stdio(false);
  int q;
  cin>>q;
  while(q--){
    P p[4];
    rep(i,4){
      double x,y;
      cin>>x>>y;
      p[i]=P(x,y);
    }
    if(intersectLL(L(p[1],p[0]),L(p[2],p[3]))){
      if(abs(dot(p[1]-p[0],p[3]-p[2]))<eps)cout<<1<<endl;
      else cout<<0<<endl;
    }else cout<<2<<endl;
  }
  return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  int A,B; cin>>A>>B;
  cout << max(A-B*2,0);
}

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

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

    int n, m;
    cin >> n >> m;
    vector<int> G[100010];
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        G[a].push_back(b);
    }

    long long ans = 0;
    priority_queue<int> que;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j < G[i].size(); j++){
            que.push(G[i][j]);
        }
        if(que.size() > 0){
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,int>P;

string rot(string s,int p){
	if(p==0){
		swap(s[10],s[12]);
		swap(s[18],s[13]);
		swap(s[7],s[22]);
		swap(s[8],s[23]);
		swap(s[9],s[24]);
	}
	if(p==1){
		swap(s[12],s[19]);
		swap(s[15],s[13]);
		swap(s[3],s[22]);
		swap(s[6],s[25]);
		swap(s[9],s[28]);
	}
	if(p==2){
		swap(s[15],s[16]);
		swap(s[21],s[19]);
		swap(s[1],s[28]);
		swap(s[2],s[29]);
		swap(s[3],s[30]);
	}
	if(p==3){
		swap(s[10],s[21]);
		swap(s[18],s[16]);
		swap(s[1],s[24]);
		swap(s[4],s[27]);
		swap(s[7],s[30]);
	}
	return s;
}

int chk(string s){
	
	if(s[1]!=s[2])return 0;
	if(s[2]!=s[3])return 0;
	if(s[3]!=s[4])return 0;
	if(s[4]!=s[5])return 0;
	if(s[5]!=s[6])return 0;
	if(s[6]!=s[7])return 0;
	if(s[7]!=s[8])return 0;
	if(s[8]!=s[9])return 0;
	
	if(s[10]!=s[11])return 0;
	if(s[11]!=s[12])return 0;
	
	if(s[13]!=s[14])return 0;
	if(s[14]!=s[15])return 0;
	
	if(s[16]!=s[17])return 0;
	if(s[17]!=s[18])return 0;
	
	if(s[19]!=s[20])return 0;
	if(s[20]!=s[21])return 0;
	
	if(s[22]!=s[23])return 0;
	if(s[23]!=s[24])return 0;
	if(s[24]!=s[25])return 0;
	if(s[25]!=s[26])return 0;
	if(s[26]!=s[27])return 0;
	if(s[27]!=s[28])return 0;
	if(s[28]!=s[29])return 0;
	if(s[29]!=s[30])return 0;
	
	return 1;
}

int main(){
	
	int n;cin>>n;
	while(n--){
		string s=" ";
		for(int i=0;i<30;i++){
			char c;cin>>c;
			s+=c;
		}
		map<string,int>M;
		queue<P>Q;
		Q.push(P(s,1));
		while(!Q.empty()){
			s=Q.front().first;
			int cnt=Q.front().second;
			Q.pop();
			if(M[s])continue;
			M[s]=cnt;
			if(chk(s)){
				cout<<cnt-1<<endl;
				break;
			}
			for(int i=0;i<4;i++){
				string t=rot(s,i);
				if(M[t])continue;
				Q.push(P(t,cnt+1));
			}
		}
		
	}
	
	
	return 0;
}


Measured memory_bytes: 1280
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
#define float double
#define pi 3.141592653589793
void bfs(vector<int> adj[],int n , int visarr[])
{
    vector<bool> visited(n+1,false);
    visited[1]=visited[0]=true;
    list<int> queue;
     vector<int>:: iterator i;
    queue.push_back(1);
    visited[1]=true;
    while (!queue.empty())
    {
      int s=queue.front();
     // visited[s]=true;
     queue.pop_front();
      for(i=adj[s].begin();i!=adj[s].end();++i)
      {
           if (!visited[*i]) 
            { 
                visarr[*i]=s;
                visited[*i] = true; 
                queue.push_back(*i); 
            } 
      }
    }
}
void solve()
{
int n,m;
cin>>n>>m;
int arr[n+1];
int visarr[n+1]={0};
queue<int> q;
vector<int> adj[n+1];
rep(i,0,m)
{
int a,b;
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
bfs(adj,n,visarr);
int test[n+1];
visarr[0]=visarr[1]=1;
rep(i,0,n+1) 
 test[i]=visarr[i];
sort(test,test+n+1);
if(test[0]==0)  cout<<"No"<<el;
else
{
   cout<<"Yes"<<el;
rep(i,2,n+1 ) cout<<visarr[i]<<el; 
}
}
int main()
{
  
 
solve();
  return 0;
}


Measured memory_bytes: 13228
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main() {
	unsigned long long N, K, i, M;
	cin >> N >> K;
	for (i = 1;i < 60;i++) {
		M = pow(K, i);
		if (N < M) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;
  int base = min(a, b);
  int digits = max(a, b);
  for (int i = 0; i < digits; ++i) {
    cout << base;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


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

	int a, b, c, d;
	a = t[0] - 48;
//	cout << a << endl;
	vector<int>bcd(3);
	rep(i, 3) {
		bcd[i] = t[i+1] - 48;
	//	cout << bcd[i] << endl;
	}
	int i = 0;
	string s = "";
	while (i < 8) {
		int sum = a;
		rep(k, 3) {
			if (i&(1 << k)) {
				sum += bcd[k];
			}
			else {
				sum -= bcd[k];
			}
		}
		if (sum == 7) {
			s+='0'+ a;
			rep(k, 3) {
				if(i&(1 << k)) {
					s += '+';
				}
				else {
					s += '-';
				}
				s += '0' + bcd[k];
			}
			break;
		}
		i++;
	}
	s += "=7";
	cout << s << endl;
}


Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
S = [0]*N
P = [0]*N
index = [i+1 for i in range(N)]
for i in range(N):
  S[i],P[i] = map(str,input().split())
  P[i] = int(P[i])
X = zip(S,P,index)
X = sorted(X,key = lambda x: (x[0],-x[1]),reverse = False)

S,P,index = zip(*X)
for i in range(N):
  print(index[i])

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

ll N, K;

void solve()
{
	if(N == 0) cout << 0 << '\n';
	else{
		if(K==1) cout << 0 << '\n';
		else{
			ll x=N/K;
			cout << min(abs(N-x*K), abs(N-(x+1)*K)) << '\n';
		}
	}
}

int main()
{
	cin >> N >> K;
	solve();
	return 0;
}

Measured memory_bytes: 3628
import math

a,b,h,m = map(int, input().split())

fun = 6 * m
ji = 30 * h + 0.5 * m
diff = min(abs(ji-fun),360-abs(ji-fun))
theta = math.radians(diff)
cos = math.cos(theta)
ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos)
print(ans)

Measured memory_bytes: 9448
#include <iostream>
using namespace std;
 
int main() {
  	int x,y;
  	while(true){
    	cin>>x>>y;
      	if(x==0 && y==0) break;
      	if(x>=y) cout<<y<<" "<<x<<endl;
      	if(x<y) cout<<x<<" "<<y<<endl;
      
      
    }
}



Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <deque>
#include <utility>

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i = int(a); i < int(b); ++i)
#define RREP(i, n) RFOR(i, 0, n)
#define RFOR(i, a, b) for(int i = int(b) - 1; i >= int(a); --i)

std::vector<bool> eratosthenes(int n) {
	std::vector<bool> num(n + 1, true);
	std::vector<int> prime;
	num[1] = false;
	for (int i = 2; i*i <= n; ++i) {
		if (num[i]) {
			for (int j = 2; i*j <= n; ++j) {
				num[i * j] = false;
			}
		}
	}

	return num;
}

const int MAXN = 2003;

bool B[MAXN][MAXN];
int num[MAXN][MAXN];
using PAIR = std::pair<int, int>;
PAIR dp[MAXN][MAXN];
PAIR pos[2000006];

int dx4[] = { 1,0,-1,0 };
int dy4[] = { 0,-1,0,1 };

PAIR dfs(int y, int x, int m) {
	if (dp[y][x].first != -1) return dp[y][x];
	dp[y][x].first = 0;

	int dy = y + 1;
	FOR(dx, x - 1, x + 1 + 1) {
		if (num[dy][dx] > m) continue;
		dp[y][x] = std::max(dp[y][x], dfs(dy, dx, m));
	}
	if (B[y][x]) {
		if (dp[y][x].first == 0) {
			dp[y][x].second = num[y][x];
		}
		++dp[y][x].first;
	}
	return dp[y][x];
}

signed main() {

	REP(i, MAXN) REP(j, MAXN) {
		B[i][j] = false;
		num[i][j] = 100000008;
	}

	auto prime(eratosthenes(2000006));
	{
		int d = 0;
		int x = MAXN / 2;
		int y = MAXN / 2;
		FOR(i, 1, 2000006) {
			B[y][x] = prime[i];
			num[y][x] = i;
			pos[i] = PAIR(y, x);

			while (true) {
				int dy = y + dy4[d];
				int dx = x + dx4[d];

				if (num[dy][dx] != 100000008) d = (d - 1 + 4) % 4;
				else {
					y = dy;
					x = dx;
					break;
				}
			}
			d = (d + 1) % 4;
		}
	}

	/*FOR(i, 990, 1010) {
		FOR(j, 990, 1010) {
			std::string s(std::to_string(num[i][j]));
			s = std::string(4 - s.size(), ' ') + s;
			std::cout << s << (B[i][j] ? '#' : ' ') << " ";
		}
		std::cout << "\n";
	}*/

	while (true) {
		int m, n;
		std::cin >> m >> n;
		if (m == 0 && n == 0) break;

		REP(i, MAXN) REP(j, MAXN) dp[i][j] = PAIR(-1, 0);

		int y = pos[n].first;
		int x = pos[n].second;

		PAIR ans = dfs(y, x, m);
		std::cout << ans.first << " " << ans.second << "\n";
	}

	return 0;
}


Measured memory_bytes: 69716
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++) {
            int a = in.nextInt();
            while(0 < a && a % 2 == 0) {
                ans++;
                a /= 2;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35292
my @a = split(//, <>);

if ($#a != 4) {
    print "Bad";
    exit 0;
}

my $last = "Z";
my $i;
for($i=0; $i<4; $i++) {
    if($last eq $a[$i]) {
        print "Bad";
        exit 0;
    }
    $last = $a[$i];
}
print "Good";


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 10000
#define MAXM 10000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int n;

int main()
{
	//WRT(1^6^11);
	cin>>n;
	if (n<=2)
	{
		cout<<"No";
		return 0;
	}
	if (n%2==0 && n==(n & (-n)))
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	cout<<1<<' '<<2<<endl;
	cout<<2<<' '<<3<<endl;
	cout<<3<<' '<<1+n<<endl;
	cout<<1+n<<' '<<2+n<<endl;
	cout<<2+n<<' '<<3+n<<endl;
	RPT(i,0,(n-3)/2)
	{
		cout<<2*i+4<<' '<<1<<endl;
		cout<<2*i+4<<' '<<2*i+5<<endl;
		cout<<2*i+5+n<<' '<<1<<endl;
		cout<<2*i+4+n<<' '<<2*i+5+n<<endl;
	}
	if (n%2==0)
	{
		cout<<2*n<<' '<<2*n-1<<endl;
		cout<<((n-1)^1^n)<<' '<<n<<endl;
	}
	return ~~(0^_^0);
}



Measured memory_bytes: 2304
#include <stdio.h>
int main()
{
    //int a,b,c;
    char ch[5];
    scanf("%s",ch);
    //scanf("%d %d",&a, &b);
    int i=0,flag = 0;
    if(ch[0]==ch[1] && ch[0]==ch[2]) printf("Yes\n");
    else if(ch[1]==ch[2] && ch[1]==ch[3] ) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

int ans = -1;

int n, m, x;
int A[12][12], C[12];

void check(vector<bool> &B) {
    for(int j=0; j<m; j++) {
        int sum = 0;
        for(int i=0; i<n; i++) {
            if(B[i]) sum += A[i][j];
        }
        if(sum < x) return;
    }

    int cost = 0;
    for(int i=0; i<n; i++) if(B[i]) cost += C[i];
    ans = (ans == -1) ? cost : min(ans, cost);
}

void dfs(int u, vector<bool> &B) {
    if(u >= n) {
        check(B);
        return;
    }
    B[u] = true;
    dfs(u+1, B);
    B[u] = false;
    dfs(u+1, B);
}

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

    for(int i=0; i<n; i++) {
        cin >> C[i];
        for(int j=0; j<m; j++) {
            cin >> A[i][j];
        }
    }

    vector<bool> B(12, false);
    dfs(0, B);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=1,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T,U;
  cin>>S>>T>>N>>M>>U;
  S==U?cout<<N-1<<" "<<M<<endl:cout<<N<<" "<<M-1<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int N;
string s;
vector<pair<string, int> > v;
vector<string> ans;
map<string, int> m;

bool cmp(pair<string, int> a, pair<string, int> b) {
    if (a.second == b.second) {
        return a.first < b.first;
    }
    return a.second > b.second;
}

int main() {

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        m[s] += 1;
    }
    map<string, int>::iterator it = m.begin();
    for (; it != m.end(); it++) {
        v.push_back(pair<string, int>(it->first, it->second));
    }
    sort(v.begin(), v.end(), cmp);
    int maxn = v.begin()->second;
    for (it = m.begin(); it != m.end(); it++) {
        if (it->second == maxn) {
            ans.push_back(it->first);
        }
    }
    vector<string>::iterator it_ans = ans.begin();
    for (; it_ans != ans.end(); it_ans++) {
        cout << *it_ans << endl;
    }
}

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

int main () {
  int  N , M ;
  cin >> N >> M ;
  vector<pair<int,int>> a ;
  for(int i = 0 ; i < M ; i++ ) {
    int A , B ;
    cin >> A >> B ;
    a.push_back(make_pair(B,A)) ;
  }
  sort(a.begin(),a.end()) ;
  int cut = 0 ;
  int pre = 0 ;
  for(int i = 0 ; i < M ; i++ ){
    if(pre<a[i].second)cut++,pre=a[i].first-1;
  }
  cout << cut << endl ;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<set>
#include<queue>
using namespace std;
char conv(char c1,char c2){
  if(c1=='r'){
    if(c2=='g')return 'b';
    if(c2=='b')return 'g';
  }else if(c1=='g'){
    if(c2=='r')return 'b';
    if(c2=='b')return 'r';
  }else if(c1=='b'){
    if(c2=='r')return 'g';
    if(c2=='g')return 'r';
  }
}
int bfs(string s){
  queue< pair<int, string> > qs;
  set<string> vis;
  qs.push( make_pair(0,s) );
  while(!qs.empty()){
    bool bFound=false;
    int ret = qs.front().first;
    string now = qs.front().second;
    qs.pop();

    //cout << vis.size() << endl;
    if( vis.find(now) != vis.end() ){
      continue;
    }
    vis.insert(now);
    for(int i = 0; i < now.length()-1; ++i){
      if(now[i]!=now[i+1]){
	bFound = true;
	string next = now;
	char nc = conv(now[i],now[i+1]);
	next[i] = next[i+1] = nc;
	qs.push(make_pair(ret+1,next));
      }
    }
    if(!bFound){
      //cout << now << endl;
      return ret;
    }
  }
  return -1;
}
int main(){
  while(true){
    string s;
    cin >> s;
    if( s == "0" )  break;
    int ans = bfs(s);
    if( ans < 0 )
      cout << "NA" << endl;
    else
      cout << ans << endl;    
  }
  return 0;
}

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

int main(){
	char ch, ch2, ch3;
	int num;
	int counter[26] = {0};
	
	while ( cin >> ch ){
    	ch2 = tolower(ch);
		num = ch2 - 'a';
		
		counter[num]++;
		
	}
	
	for(int i=0; i<26; i++){
		ch3 = 'a' + i;
		cout << ch3 << " : " << counter[i] << endl;
	}
		
 	return 0;
}

Measured memory_bytes: 3076
import sys
  
for s in sys.stdin:
    h,w = [ int(x) for x in s.split() ]

    if h==0 and w==0:
        break

    print('#'*w)
    for i in range(h-2):
        print('#'+ '.'*(w-2) + '#')
    print('#'*w)
    print()


Measured memory_bytes: 5628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int a,b;
	scanf("%d %d", &a,&b);
	if(a%2==1&&b%2==1){
		printf("Odd\n" );
	}else{
		printf("Even\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int ac, wa, tle, re;
  ac = 0;
  wa = 0;
  tle = 0;
  re = 0;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
    if (s.at(i) == "AC" ){
      ac++;
    }
    else if (s.at(i) == "WA" ){
      wa++;
    }
    else if (s.at(i) == "TLE" ){
      tle++;
    }
    else {
      re++;
    }
  }
  cout << "AC x "<< ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

int main() {
  int N,i,j,k,ans=0;
  cin>>N;
  vector<int> L(N);
  for (i=0;i<N;i++) cin>>L[i];
  for (i=0;i<N-2;i++) {
    for (j=i+1;j<N-1;j++) {
      if (L[i]==L[j]) continue;
      for (k=j+1;k<N;k++) {
        if (L[i]==L[k] || L[j]==L[k]) continue;
        if (L[i] < L[j]+L[k] && L[j] < L[i]+L[k] && L[k] < L[j]+L[i]) ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
long long n,w[1010],v[1010],dp[100010],mx,wm,jumw;

int main()
{
	cin>>n>>wm;
	
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
		mx+=v[i];
		jumw+=w[i];
	}
	
	for(int j=0;j<=mx;j++)
	{
		dp[j]=jumw+10;
	}
	dp[0] = 0;
	for(int i=1;i<=n;i++)
	{
		for(int j=mx;j>=v[i];j--)
		{
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	for(int i=mx;i>=0;i--)
	{
		if(dp[i]<=wm)
		{
			cout<<i<<'\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    static const double pi = 3.141592653589793;
    double a,b,C;
    cin >> a >> b >> C;    
    // cout << a << b << C << endl;
    // cout << C / 360 * 2 << endl;/
    double radians = pi * (C / 360 * 2);
    // cout << sin(radians) << endl;
    // cout << sin(pi/2) << endl;
    double S = a * b * sin(radians) / 2; 
    double L = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(radians)) + a+b;
    double h = S / a * 2;
    cout << setprecision(10) << S << endl;
    cout << setprecision(10) << L << endl;
    cout << setprecision(10) << h << endl;
    return 0;
}




Measured memory_bytes: 3604
#include<stdio.h>
#define MAX 50
int f(int);
int F[50],n;
int main(){
  int i;
  scanf("%d",&n);
  for(i=0; i<50; i++) F[i] = -1;
  printf("%d\n",f(n));
  return 0;
}
int f(int n){
  if(n == 1 || n == 0) return F[n] = 1;
  if(F[n] != -1) return F[n];
  return F[n] = f(n - 2) + f(n - 1);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    rep(i, H) cin >> s.at(i);

    int ans = 0;
    rep(i, 1 << H) rep(j, 1 << W){
        int count = 0;
        rep(m, H) rep(n, W){
            if(i >> m & 1) continue;
            if(j >> n & 1) continue;
            if(s.at(m).at(n) == '#') count++;
        }
        if(count == K) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys, itertools, collections
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, l = lmi()
a = [(abs(l + i), i) for i in range(n)]
i = sorted(a)[0][1]
# print(i,a)

print(sum([l+i for i in range(n)]) - (l+i))


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p;char s U;L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}L M(L i){return i?B[i]+M(i^i&-i):0;}L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1<<17;i+=i&-i)B[i]+=x;}L K(L a){p=X[a];n=X[b];return p-n?E[p]<E[n]?swap(p,n),swap(a,b),0:0,M(O[a])-M(O[p])+G(p)+K(P[p]):abs(M(O[a])-M(O[b]));}main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!b|a;S(a=H[a],O[a]=b++))X[a]=p;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33488
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;



// Geometry
using Float = double;
using Point = complex<Float>;
constexpr Float EPS = 1e-7;

inline int sgn(const Float &r) {
	return (r > EPS) - (r < -EPS);
}
bool operator==(const Point &a, const Point &b) {
	bool xeq = sgn(real(a) - real(b)) == 0;
	bool yeq = sgn(imag(a) - imag(b)) == 0;
	return xeq && yeq;
}
bool operator<(const Point &a, const Point &b) {
	int xsgn = sgn(real(a) - real(b));
	if (xsgn == 0) {
		return sgn(imag(a) - imag(b)) < 0;
	}
	return xsgn < 0;
}

Float dot(const Point &a, const Point &b) {
	return real(conj(a)*b);
}
Float cross(const Point &a, const Point &b) {
	return imag(conj(a)*b);
}

struct Circle {
	Point center;
	Float radius;

	Circle() {}
	Circle(const Point &center, const Float &radius)
		: center(center), radius(radius) {}

	// 1: interior, 0: boundary, -1: exterior
	int relation(const Point &p) const {
		return sgn(radius - abs(p - center));
	}
};

vector<Point> intersection(const Circle &a, const Circle &b) {
	Point p = b.center - a.center;
	Float d = norm(p);
	Float t = (d + a.radius*a.radius - b.radius*b.radius) / 2.;
	Float q = d*a.radius*a.radius - t*t;
	int qsgn = sgn(q);
	vector<Point> ret;
	if (qsgn < 0) return ret;
	ret.emplace_back(
		(t*real(p) + imag(p)*sqrt(q)) / d,
		(t*imag(p) - real(p)*sqrt(q)) / d
	);
	if (qsgn > 0) {
		ret.emplace_back(
			(t*real(p) - imag(p)*sqrt(q)) / d,
			(t*imag(p) + real(p)*sqrt(q)) / d
		);
	}
	for (auto &x : ret) {
		x += a.center;
	}
	return ret;
}


int main() {
	int n; cin >> n;
	vector<Point> p(n);
	for (int i = 0; i < n; i++) {
		Float x, y; cin >> x >> y;
		p[i] = { x, y };
	}
	vector<Circle> c(n);
	for (int i = 0; i < n; i++) c[i].center = p[i];
	auto ok = [&](const Point &center) {
		bool ret = true;
		for (int i = 0; i < n; i++) {
			ret &= c[i].relation(center) >= 0;
		}
		return ret;
	};
	Float lo = 0, hi = 1e9;
	for (int iter = 0; iter < 100; iter++) {
		Float mid = (hi + lo)/2;
		for (int i = 0; i < n; i++) c[i].radius = mid;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				auto points = intersection(c[i], c[j]);
				cerr << points.size() << endl;
				for (const auto &v : points) {
					flag |= ok(v);
				}
			}
		}
		if (flag) hi = mid;
		else lo = mid;
	}
	printf("%.15f\n", hi);
	return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
    
    int s, w;
    
    cin>> s >> w;
    
    cout<< ( w< s? "safe\n" : "unsafe\n");

    return 0;
}




Measured memory_bytes: 3556
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int x,yb,yc,yd,p;
	cin >> x >> yb >> yc >> yd >> p;
	cout << min(p*x,yb + max(p - yc,0)*yd) << endl;
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
bool is_palindrom(string s,int i,int n)
{
	for(i=0; i<n; i++)
	{
		if(s[i]!=s[n-1-i])
			return false;
	}
	return true;
}
int main()
{
	fast
	string s;
	cin>>s;
	int n=s.length();
	if(is_palindrom(s,0,n)&&is_palindrom(s,0,(n-1)/2)&&is_palindrom(s,(n+3)/2,n))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
c_a=[list(map(int,input().split())) for _ in range(N)]

ans=float('inf')

for x in range(2**N):
   b=format(x,'b').zfill(N)
   cost=0
   A=[0]*(M+1)
   flag=[0]*(M+1)
   for i,n in enumerate(b):
      if n=='1':
         cost+=c_a[i][0]
         for j in range(1,M+1):
            A[j]+=c_a[i][j]
            if A[j]>=X: flag[j]=1
   if sum(flag)==M:
      ans=min(ans,cost)
if ans==float('inf'): print(-1)
else: print(ans)

Measured memory_bytes: 9224
pay, num = gets.chomp.split
unluck_num = gets.chomp.split.map(&:to_i).sort
 
def like_it?(num, pay)
 return true if num.to_a & pay.to_s.chars.map(&:to_i) == []
 return false
end
 
until like_it?( unluck_num, pay)
 pay = pay.to_i + 1
end
puts pay

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	int now,prev = (1 << 28);
	int res = 0;
	for (int i = 0; i < N-1; ++i) {
		cin >> now;
		res += min(prev,now);
		prev = now;
	}
	res += now;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np
input = stdin.readline
h,w = map(int,input().split())
s = (np.array([list(input().strip()) for _ in range(h)])=="#")
ans = np.zeros((h+2,w+2),dtype=np.uint8)
for i,j in [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]:
  ans[1+i:h+1+i,1+j:w+1+j] += s
ans = ans[1:h+1,1:w+1].astype("str")
ans[s] = "#"
for i in ans:
  print("".join(i))

Measured memory_bytes: 12508
import java.util.*;

public class Main {
    public static void main(String... args) {

        /*
        ここは、フィールド
         */

        //Scanner インスタンス生成
        Scanner sc = new Scanner(System.in);
        //標準入力の値を代入する
        //枚数
        int numberMochi = sc.nextInt();
        //各自の直径を格納する配列
        int[] diameterArray = new int[numberMochi];
        //枚数分繰り返す。
        for(int i = 0; i < numberMochi; i++){
            diameterArray[i] = sc.nextInt();
        }
        //重複確認変数
        Set<Integer> duplicationNumber = new HashSet<Integer>();
        /*
        ここからは、アルゴリズム
         */
        //重複分はノーカウント
        //重複しているものが何個あるのか？
        for(int i = 0; i < diameterArray.length; i++){
            duplicationNumber.add(diameterArray[i]);
        }
        //標準出力をする
        System.out.print(duplicationNumber.size());
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (a >= b) cout << "delicious" << endl;
    else if (a + x >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,a[200010],b[200010];
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  for (i=0;i<n;i++){
    if (a[i]<=b[n/2-1]) cout << b[n/2] << endl;
    else cout << b[n/2-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
#define mod 1000000007

map<ll, int> primeFactorize(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++ret[i];
      n /= i;
    }
  }
  if( n != 1 ) ret[n] = 1;
  return ret;
}

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

  ll n; cin >> n;
  ll prime[1010] = {};
  for (ll i = 2; i <= n; ++i) {
    for (auto e : primeFactorize(i)) {
      prime[e.first] += e.second;
    }
  }

  ll ans;
  if( !prime[2] ) ans = 1;
  else ans = prime[2] + 1;

  for (int i = 3; i <= 1000; i += 2) {
    if( prime[i] ) {
      ans *= (prime[i] + 1);
      ans %= mod;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        StringBuilder sb = new StringBuilder(s);
        char repl = ' ';
        switch(s.charAt(k-1)){
          case 'A':
            repl = 'a';
            break;
          case 'B':
            repl = 'b';
            break;
          default:
            repl = 'c';
            break;
        }
        sb.setCharAt(k-1, repl);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22228
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int xp0 = sc.nextInt();
			int yp0 = sc.nextInt();
			int xp1 = sc.nextInt();
			int yp1 = sc.nextInt();
			int xp2 = sc.nextInt();
			int yp2 = sc.nextInt();
			int xp3 = sc.nextInt();
			int yp3 = sc.nextInt();

			if (Geom.lineSegsIntersect(xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3)) {
				System.out.println("1");
			} else {
				System.out.println("0");
			}
		}

		sc.close();
	}
	
	@SuppressWarnings("unused")
	private static class Geom {
		static int dot(int xa, int ya, int xb, int yb) {
			return xa * xb + ya * yb;
		}

		static int cross(int xa, int ya, int xb, int yb) {
			return xa * yb - xb * ya;
		}
		
		static int sumofsquare(int xa, int ya) {
			return xa * xa + ya * ya;
		}

		static boolean lineSegsIntersect(int xa, int ya, int xb, int yb, int xc, int yc, int xd, int yd) {
			int abx = xb - xa;
			int aby = yb - ya;
			int acx = xc - xa;
			int acy = yc - ya;
			int adx = xd - xa;
			int ady = yd - ya;
			int cdx = xd - xc;
			int cdy = yd - yc;
			int cax = xa - xc;
			int cay = ya - yc;
			int cbx = xb - xc;
			int cby = yb - yc;

			if (((long)cross(abx, aby, acx, acy) * cross(abx, aby, adx, ady) <= 0)
					&& ((long)cross(cdx, cdy, cax, cay) * cross(cdx, cdy, cbx, cby) <= 0)) {
				if (cross(abx, aby, cdx, cdy) != 0) {
					return true;
				}
				if ((dot(abx, aby, acx, acy) >= 0 || dot(abx, aby, adx, ady) >= 0)
						&& (dot(-abx, -aby, -cbx, -cby) >= 0 || dot(-abx, -aby, xd - xb, yd - yb) >= 0)) {
					return true;
				}
				/*
				if (sumofsquare(acx, acy) == 0 || sumofsquare(adx, ady) == 0) {
					return true;
				}
				if (dot(abx, aby, acx, acy) * dot(abx, aby, adx, ady) < 0) {
					return true;
				}
				if (dot(abx, aby, acx, acy) > 0 && dot(abx, aby, acx, acy) <= sumofsquare(abx, aby)) {
					return true;
				}
				if (dot(abx, aby, adx, ady) > 0 && dot(abx, aby, adx, ady) <= sumofsquare(abx, aby)) {
					return true;
				}
				*/
			}				

			return false;
		}
	}
}

Measured memory_bytes: 29600