akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	double w;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	while(fscanf(fp, "%lf", &w) != EOF){
#else
	while(scanf("%lf", &w) != EOF){
#endif
		if(w <= 48){
			std::cout << "light fly" << std::endl;
		}
		else if(w <= 51){
			std::cout << "fly" << std::endl;
		}
		else if(w <= 54){
			std::cout << "bantam" << std::endl;
		}
		else if(w <= 57){
			std::cout << "feather" << std::endl;
		}
		else if(w <= 60){
			std::cout << "light" << std::endl;
		}
		else if(w <= 64){
			std::cout << "light welter" << std::endl;
		}
		else if(w <= 69){
			std::cout << "welter" << std::endl;
		}
		else if(w <= 75){
			std::cout << "light middle" << std::endl;
		}
		else if(w <= 81){
			std::cout << "middle" << std::endl;
		}
		else if(w <= 91){
			std::cout << "light heavy" << std::endl;
		}
		else{
			std::cout << "heavy" << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3212
N = int(input())
n_ac = 0
n_wa = 0
n_tle = 0
n_re = 0

for i in range(N):
    s = input()
    if s == "AC":
        n_ac += 1
    elif s == "WA":
        n_wa += 1
    elif s == "TLE":
        n_tle += 1
    else:
        n_re += 1

print("AC x",n_ac)
print("WA x",n_wa)
print("TLE x",n_tle)
print("RE x",n_re)


Measured memory_bytes: 69804
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
def main():
    n,k=map(int,input().split())
    V=list(map(int,input().split()))
    ans=0
    for a in range(min(k+1,n+1)):
        for b in range(min(k-a,n-a)+1):
            cd=k-(a+b)
            H=[]
            sum_V=0
            for i in range(n):
                v=V[i]
                if i+1<=a or i>=n-b:
                    sum_V+=v
                    if v<0:
                        heapq.heappush(H,V[i])
            while H and cd>0:
                sum_V-=heapq.heappop(H)
                cd-=1
            ans=max(sum_V,ans)
    print(ans)


if __name__=='__main__':
    main()

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

int main(){
    vector<int>a(3);
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int cnt=0;
    while(a[1]<a[2]){
        a[0]++;
        a[1]++;
        cnt++;
    }
    if((a[2]-a[0])%2==0){
        cnt+=(a[2]-a[0])/2;
    }else{
        cnt++;
        cnt+=(a[2]+1-a[0])/2;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c<=21) cout<<"win";
    else cout<<"bust";
}

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

int A,B,K;

int main(void)
{
    cin >> A >> B >> K;

    int cnt=0;

    for(int i=min(A,B);i>=1;i--)
    {
        
        if(A%i==0&&B%i==0)
        {
            cnt++;
        }
        if(cnt==K)
        {
            cout << i << endl;
            return 0;
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==5&&B==5&&C==7){
    cout<<"YES"<<endl;
  }else if(A==5&&B==7&&C==5){
    cout<<"YES"<<endl;
  }else if(A==7&&B==5&&C==5){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String N = br.readLine();
	System.out.println(N.contains("7") ? "Yes" : "No");
    }
}

Measured memory_bytes: 25296
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;


int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n;
    a=n/500;
    n%=500;
    a1=n/5;
    sum=a*1000+a1*5;
    cout<<sum;

    return 0;
}





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

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

  int ans = 1000;

  for (int i = 0; i <= s.size() - t.size(); i++)
  {
    int cur = 0;
    for (int j = 0; j < t.size(); j++)
    {
      if (t[j] != s[i + j])
      {
        cur++;
      }
    }
    ans = min(ans, cur);
  }

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


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

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

const int MAXN = 1e5 + 5;

int cnt[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		int a;
		scanf("%d", &a);
		cnt[a]++;
	}
	if (n % 2 == 1){
		if (cnt[0] != 1){
			printf("0\n");
			return;
		}
	}
	ll ans = 1ll;
	for(int i = 1 + n % 2; i < n; i += 2){
		if (cnt[i] != 2){
			printf("0\n");
			return;	
		}
		ans = (ans * 2) % MOD;
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    lis=[1]*n
    rlis=[False]*n
    rlis[0]=True
    for i in range(m):
        x,y=map(int,input().split())
        x-=1
        y-=1
        if lis[x]==1:
            lis[x]-=1
            lis[y]+=1
            if rlis[x]:
                rlis[x]=False
                rlis[y]=True
        else:
            lis[x]-=1
            lis[y]+=1
            if rlis[x]:
                rlis[y]=True
    print(rlis.count(True))


if __name__=='__main__':
    main()

Measured memory_bytes: 4596
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int array[] = new int[26];
        for(int i = 0;i < str.length();i++){
            if(str.charAt(i) >= 'a' && str.charAt(i) <='z')
                array[str.charAt(i) - 'a']++;
        }
        for(int i = 0;i < array.length;i++){
            if(array[i] % 2 == 1){
                System.out.print("No");
                return;
            }
        }
        System.out.print("Yes");

    }
}

Measured memory_bytes: 8148
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x)
#define printl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll p(N+1);
    rep(i, 0, N){
        ll a; cin >> a;
        p[a] = i+1;
    }
    ll c = 1;
    ll mx = 1;
    rep(i, 2, N+1){
        if(p[i] > p[i-1]){
            c++;
            if(i == N){
                mx = max(mx, c);
            }
        }else{
            mx = max(mx, c);
            c = 1;
        }
    }
    cout << N - mx;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, sum = 0, ans = 0;
	bool a; cin >> n;
	for(int h = 0; h < n; h++){
		cin >> a;
		if (a == 0) {
			sum = 0;
		}
		if (a == 1) {
			sum++;
			ans = max(ans, sum);
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{  int n;
   cin>>n;
 int d[n],d2[n];
for(int i=0;i<n;i++)
   cin>>d[i]>>d2[i];
 for(int i=0;i<n-2;i++)
 {
   if(d[i]==d2[i])
  {   if(d[i+1]==d2[i+1]&&d[i+2]==d2[i+2])
     {  cout<<"Yes";
        return 0; }
   }
 }
 cout<<"No";
 return 0;
} 

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    rep(i,3) rep(j,3) cin >> a[i][j];
	int n;
	cin >> n;
    vector<vector<int>> d(3, vector<int>(3));
    rep(i,n) {
        int x;
        cin >> x;
        rep(i,3)rep(j,3) if(a[i][j]==x) d[i][j] = 1;
    }
    bool ans = false;
    rep(i,3) {
        int cnt = 0;
        rep(j,3) cnt += d[i][j];
        if(cnt==3) ans = true;
    }
    rep(i,3) {
        int cnt = 0;
        rep(j,3) cnt += d[j][i];
        if(cnt==3) ans = true;
    }
    {
        int cnt = 0;
        rep(j,3) cnt += d[j][j];
        if(cnt==3) ans = true;
    }
    {
        int cnt = 0;
        rep(j,3) cnt += d[j][2-j];
        if(cnt==3) ans = true;
    }
	if (ans) cout << "Yes" << endl;
    else     cout << "No"  << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
S = [c for c in input()]
ans = 0
i = 0
j = n-1
while i < j:
    if S[i] == "W":
        if S[j] == "R":
            S[i] = "R"
            S[j] = "W"
            j -= 1
            i += 1
            ans += 1
        else:
            j -= 1
    else:
        i += 1
print(ans)

Measured memory_bytes: 10936
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N, A, B;
	cin >> N >> A >> B;
	
	cout << min(A * N, B) << endl;




	/* ABC 125_c
	int N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	vector<ll> Forward(N), Backward(N);
	Forward[0] = A[0];
	int tmp = A[0];
	for (int i = 1; i < N; i++) {
		tmp = gcd(tmp, A[i]);
		Forward[i] = tmp;
	}

	tmp = A[N - 1];
	Backward[N - 1] = tmp;
	for (int i = N - 2; i >= 0; i--) {
		tmp = gcd(tmp, A[i]);
		Backward[i] = tmp;
	}
	*/


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

Measured memory_bytes: 504
#include <stdio.h>
const int MAX_V = 1000000; // 100????????§??´???°??¨?????????
int prime[MAX_V+1];
int main() {
	int k,i,max,min,n; // 1????´???°???0????´???°??§???????
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2??\?????´???°??¨??????
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ?´???°?2?????\?????????°??´???°??§???????
			}
		}
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = 2;i <= n;i++){
			if(prime[i] && prime[i-2]){
				max = i;
				min = max -2;
				//printf("%d %d\n",i-2,i);
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

Measured memory_bytes: 4932
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n % 2 == 1) {
            for (int i = 0; i < m; i++) {
                int p = i + 1;
                int q = n - 1 - i;
                System.out.println(p + " " + q);
            }
        } else {
            for(int i = 0; i< m ; i++) {
                int d = (n/2-1) - i;
                if(d % 2 == 0) {
                    int p = 1 + (i/2);
                    int q = 1 + d + (i/2);
                    System.out.println(p + " " + q);
                } else {
                    int q = n - (i/2);
                    int p = n - d - (i/2);
                    System.out.println(p + " " + q);
                }
            }

        }

    }

}

Measured memory_bytes: 54092
L=[]
for i in range(3):
    a,b=input().split()
    L.append(int(a))
    L.append(int(b))
    
def solve(L):
    for i in range(1,5):
        if L.count(i)==3:
            return 'NO'
    return 'YES'

print(solve(L))


Measured memory_bytes: 2940
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a =  sc.nextInt();
    int b =  sc.nextInt();
    int answer = 0;
    if(a*b>=(a+b)){
      if(a*b>=(a-b)){
        answer=a*b;
      }else{
        answer=a-b;
      }
    }else{
      if((a+b)>=(a-b)){
        answer = a+b;
      }else{
        answer = a-b;
      }
    }
    System.out.println(answer);
  }
}

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

ll imos[1002][1002];

int main()
{
	int n;
	cin >> n;
	for(int i =0;i<n;i++)
	{
		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		//x2++;
		//y2++;
		imos[x1][y1]++;
		imos[x2][y2]++;
		imos[x1][y2]--;
		imos[x2][y1]--;
	}
	ll ans = 0;
	for(int i =0;i<=1000;i++)
		for(int j = 0;j<=1000;j++)
		imos[i+1][j] += imos[i][j];

	for(int i =0;i<=1000;i++)
		for(int j = 0;j<=1000;j++)
		imos[i][j+1] += imos[i][j];
	for(int i =0;i<=1000;i++)
	{
		for(int j =0;j<=1000;j++)
		{
			ans = max(ans,imos[i][j]);
		}
	}
	cout<<ans<<endl;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

const int N = 100005;
vector<int> g[N];
int cnt[N];
P es[N];
int col[N];
int deg[N];

void dfs(ll v,ll pre){
  cnt[v]=1;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
    cnt[v]+=cnt[nv];
  }
}

void ddfs(ll v,ll pre,ll c){
  col[v]=c;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    ddfs(nv,v,c);
  }
}

bool solve(){
  int n,x,y;
  scanf("%d%d%d", &n, &x, &y);
  x--; y--;

  memset(deg,0,sizeof(deg));

  rep(i,n-1){
    int a,b;
    scanf("%d%d", &a, &b);
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
    es[i] = {a,b};
    deg[a]++;
    deg[b]++;
  }

  if(n==2) return true;
  if(n%2==1) return false;

  dfs(0,-1);
  memset(col,-1,sizeof(col));
  rep(i,n-1){
    ll a=es[i].fi, b=es[i].se;
    if(cnt[a]<cnt[b]) swap(a,b);
    if(cnt[b]==n-cnt[b]){
      ddfs(a,b,0);
      ddfs(b,a,1);
      deg[a]--;
      deg[b]--;
      break;
    }
  }

  if(col[x]==col[y]) return false;

  int cnt1[2] = {0,0};
  rep(i,n){
    if(deg[i]>2) return false;
    if(deg[i]==1) cnt1[col[i]]++;
  }

  if(cnt1[0]!=2 || cnt1[1]!=2) return false;

  return (deg[x]==1 && deg[y]==1);
}

int main(){
  if(solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 16884
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();
		int c = sc.nextInt();
		int[] b = new int[m];
		for (int i=0; i<m; i++) {
			b[i] = sc.nextInt();
		}
		int res = 0;
		for (int i=0; i<n; i++) {
			long tRes = 0;
			for (int j=0; j<m; j++) {
				tRes += b[j]*sc.nextInt();
			}
			if (tRes + c > 0) {
				res++;
			}
		}
		System.out.println(res);
		sc.close();
	}

}


Measured memory_bytes: 28032
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
int G[52][52],N,M,a,b;
int visited[52];
using namespace std;
void dfs(int n)
{
  if(visited[n])
    return;
  visited[n] = 1;
  for(int i=1;i<=N;i++)
    if(G[n][i])
      dfs(i);
}

int main()
{
  int count=0,f;
  cin >> N >> M;
  REP(i,M){
    cin >> a >> b;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  for(int i=1;i<=N;i++)
    for(int j=i;j<=N;j++){
      if(G[i][j] == 0)
        continue;
      REP(k,51)visited[k] = 0;
      G[i][j] = 0;
      G[j][i] = 0;
      f = 1;
      dfs(i);
      for(int k=1;k<=N;k++)
        if(!visited[k])
          f = 0;
      if(!f){
        count++;
      }
      G[i][j] = 1;
      G[j][i] = 1;
    }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[110];
int main()
{
	gets(a);
	int ans=0,s; 
	for(int i=0;i<sizeof(a);++i)
	{
		if(a[i]=='C') 
		{ 
			for(int j=i;j<sizeof(a);++j)
			if(a[j]=='F')
			ans++;
		}
	}
	if(ans!=0)
	cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 998244353LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

ll a[N], val[N];
int n;
ll x;

ll func(int c)
{
	int i, z;
	ll ans = 1LL*c*x;
	fo(i,0,c)
	{
		ans += (2LL*a[n-1-i]);
		val[i] = 1;
	}
	for(i = n-1; i >= 0; i--)
	{
		z = i % c;
		ans -= (a[i]*val[z]*val[z]);
		val[z]++;
		ans += (a[i]*val[z]*val[z]);
	}
	return ans;
}

ll tersea(int l, int r)
{
	if(l > r)
		return INFLL;
	int mid1 = l + (r-l)/3;
	int mid2 = l + 2*(r-l)/3;
	ll val1 = func(mid1);
	ll val2 = func(mid2);
	ll vall = func(l);
	ll valr = func(r);
	ll ans = min(vall,min(val1,min(val2,valr)));
	if(val1 <= vall && val2 <= val1)
		return min(ans, tersea(mid1+1,r-1));
	if(val2 <= valr && val1 <= val2)
		return min(ans, tersea(l+1,mid2-1));
	return min(ans, min(tersea(mid1+1,r-1), tersea(l+1,mid2-1)));
}

void solve()
{
	int i;
	ll ans = 0;
	cin >> n >> x;
	fo(i,0,n)
		cin >> a[i];
	ans = tersea(1,n) + 1LL*n*x;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 3328
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


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

	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int res = 0;
	for (int i = 0; i < k; i++)
	{
		res += p[i];
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int h = sc.nextInt();
    static int w = sc.nextInt();
    static char[][] s = new char[h][w];

    public static void main(String[] args){
        for (int i=0; i<h; i++){
            s[i] = sc.next().toCharArray();
        }

        int ans = 0;

        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                if (s[i][j]=='#') continue;
                int tmp = dfs(i, j);
                ans = Math.max(ans, tmp);
            }
        }

        System.out.println(ans);
    }

    public static int dfs(int i, int j){
        int ret = 0;
        int[][] d = new int[h][w];
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};
        for (int a=0; a<h; a++){
            for (int b=0; b<w; b++){
                d[a][b] = Integer.MAX_VALUE;
            }
        }
        d[i][j] = 0;
        Queue<P> queue = new ArrayDeque<>();
        P p = new P(i, j);
        queue.add(p);
        while (!queue.isEmpty()){
            P pp = ((ArrayDeque<P>) queue).pollFirst();
            int first = pp.s;
            int second = pp.t;
            for (int k=0; k<4; k++){
                int ny = first + dy[k];
                int nx = second + dx[k];
                if (ny<0 || h<=ny || nx<0 || w<=nx) continue;
                if (s[ny][nx]=='#') continue;
                if (d[ny][nx]!=Integer.MAX_VALUE) continue;
                d[ny][nx] = d[first][second] + 1;
                P tmpP = new P(ny, nx);
                queue.add(tmpP);
            }
        }
        for (int a=0; a<h; a++){
            for (int b=0; b<w; b++){
                if (d[a][b]==Integer.MAX_VALUE) continue;
                ret = Math.max(ret, d[a][b]);
            }
        }
        return ret;
    }

    public static class P{
        int s;
        int t;

        public P(int s, int t){
            this.s = s;
            this.t = t;
        }
    }
}


Measured memory_bytes: 24916
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAX=1e2+5;

//显示数组 
void showArray(int a[],int n){
	for(int i=0;i<n;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",a[i]);
	}
	printf("\n");
}
//冒泡排序 
void bubbleSort(int bs[],int n){
	int t=0;
	for(int i=n-1;i>0;i--){
		for(int j=n-1;j>n-i-1;j--){
			if(bs[j]<bs[j-1]){
				int temp=bs[j];
				bs[j]=bs[j-1];
				bs[j-1]=temp;
				t++;
			}
		}
	} 
	showArray(bs,n);
	printf("%d\n",t);
}

int main(){
	int n;
	int num[MAX];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	bubbleSort(num,n);
	return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 3004
#define INF 1e9+7

using namespace std;

ll n,mod=1e9+7;
string s;
ll dp[N][N];
ll pre[N][2];

ll get_sum(ll i,ll j,ll id)
{
    if(i > j)
        return 0;

    return (pre[j][id]-pre[i-1][id]+mod)%mod;
}

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

    cin >> n;
    cin >> s;

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

    rep(i,1,n)
    {
        rep(j,1,i+2)
        {
            if(s[i-1] == '>')
            {
                dp[i][j] = get_sum(j,i,(i+1)%2);
            }
            else
            {
                dp[i][j] = get_sum(1,j-1,(i+1)%2);
            }

       //     cout << dp[i][j] << " ";

            pre[j][i%2] = (pre[j-1][i%2]+dp[i][j])%mod;
        }

   //     cout << endl;
    }

    cout << get_sum(1,n,(n+1)%2) << "\n";

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

string MakeStr(int n, int cnt) {
    string ret = "";
    REP(i, cnt) {
        ret += '0' + n;
    }
    return ret;
}

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

    int a, b;
    cin >> a >> b;

    vector<string> v;

    v.push_back(MakeStr(a, b));
    v.push_back(MakeStr(b, a));
    SORT(v);

    printf("%s\n", v[0].c_str());

    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N;
bool ans=true;
cin >> N;vector<int> A(N);
for(int i=0;i<N;i++){cin >> A.at(i);}
for(int i=0;i<N;i++){if(A.at(i)%2==0){if(!(A.at(i)%3==0||A.at(i)%5==0))ans=false;}}
if(ans)cout << "APPROVED";
else cout << "DENIED";
}

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

using namespace std;

int main() {
    
    int N, max=0, count=0;
    cin >> N;

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

    cout << count;

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
  vector<ll> S(N); S[0] = A[0];
  for (int i = 1; i < N; i++) S[i] = S[i-1] + A[i];
  map<ll, ll> kazu;
  for (int i = 0; i < N; i++) kazu[S[i]]++;
  ll ans = 0;
  for (auto x : kazu) {
    ll t = x.second;
    if (x.first == 0) ans += t;
    ans += t * (t-1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
N = int(input())
MOD = 10**9 + 7

chars = "ACGT"
cache = dict()

def is_valid(last4):
    if "AGC" in last4:
        return False
    for i in range(3):
        s = last4[:i] + last4[i + 1] + last4[i] + last4[i + 2:]
        if "AGC" in s:
            return False
    return True

def calc2(idx, last3):
    key = str(idx) + last3
    if key in cache:
        return cache[key]
    if idx == N:
        return 1
    ret = 0
    for c in chars:
        ns = last3 + c
        if is_valid(ns):
            ret = (ret + calc2(idx + 1, ns[1:])) % MOD
    ret = ret % MOD
    cache[key] = ret
    return ret
print(calc2(0, "   "))


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}

int main(){
    ll N, M;
    string S, T;
    cin>>N>>M>>S>>T;
    ll a = gcd(N, M);
    rep(i, a)
    {
        if(S[i*N/a]!=T[i*M/a]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<N*M/a<<endl;
    return 0;


}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
'''
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp
???????¨???????
???????????¶????????????
'''
N, W = map(int, input().split())

class Item():
    def __init__(self, v, w):
        self.v = v
        self.w = w

items = []

for _ in range(N):
    v, w = map(int, input().split())
    item = Item(v, w)
    items.append(item)

C = dict()
for n in range(N+1):
    C[(n, 0)] = 0

for w in range(W+1):
    C[(0, w)] = 0

for n in range(1, N+1):
    for w in range(1, W+1):
        if w-items[n-1].w < 0:
            C[(n, w)] = C[(n-1, w)]
            continue
        C[(n, w)] = max(C[(n-1, w)], C[(n-1, w-items[n-1].w)] + items[n-1].v)

print(C[(n, w)])

Measured memory_bytes: 153944
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int N;
int as[100000+10];
int bs[100000+10];
int xs[100000+10];

int main(void) {
  scanf("%d", &N);
  ll asum = 0;
  REP(i, N) {
    scanf("%d", &as[i]);
    asum += as[i];
  }
  ll bsum = 0;
  REP(i, N) {
    scanf("%d", &bs[i]);
    bsum += bs[i];
  }
  if(asum < bsum) {
    puts("-1");
    return 0;
  }
  REP(i, N) {
    xs[i] = as[i] - bs[i];
  }
  sort(xs, xs + N);
  int res = 0;
  ll cur = 0;
  REP(i, N) {
    if(xs[i] < 0) {
      ++res;
      cur += xs[i];
    }
  }
  for(int i = N-1; cur < 0; --i) {
    ++res;
    cur += xs[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 = 1LL << 60;

int main() {
    double t, x; cin >> t >> x;
    printf("%.10lf\n", t / x);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=50,maxt=2600,maxe=252600<<1;

int n,m,cnt;char pic[maxn+5][maxn+5];
int E,lnk[maxt+5],son[maxe+5],nxt[maxe+5],e[maxe+5],w[maxe+5];
int que[maxt+5],ti,vis[maxt+5],dis[maxt+5],MIN[maxt+5];

#define ID(x,y) (((x)-1)*m+(y))
inline void Add(int x,int y,int z,int c){
	son[E]=y;nxt[E]=lnk[x];lnk[x]=E;e[E]=z;w[E]=c;E++;
	son[E]=x;nxt[E]=lnk[y];lnk[y]=E;e[E]=0;w[E]=-c;E++;
}
void BFS(int X,int Y){
	int Head=0,Tail=0;que[++Tail]=ID(X,Y);vis[ID(X,Y)]=++ti;
	while (Head!=Tail){
		int now=que[++Head],x=(now-1)/m+1,y=(now-1)%m+1;
		if (y<m && vis[ID(x,y+1)]<ti && pic[x][y+1]!='#') que[++Tail]=ID(x,y+1),vis[ID(x,y+1)]=ti;
		if (x<n && vis[ID(x+1,y)]<ti && pic[x+1][y]!='#') que[++Tail]=ID(x+1,y),vis[ID(x+1,y)]=ti;
	}
	Add(cnt,ID(X,Y)+100,1,0);
	for (int i=1,now,x,y;i<=Tail;i++){
		now=que[i];x=(now-1)/m+1;y=(now-1)%m+1;
		if (pic[x][y]!='o') Add(cnt,ID(x,y)+100,1,x-X+y-Y);
	}
}
bool Spfa(int s,int t,int &MC){
	static int fa[maxt+5],ID[maxt+5];
	for (int i=s;i<=t;i++) dis[i]=-2e9;
	int Head=0,Tail=0;que[++Tail]=s;vis[s]=++ti;dis[s]=0;MIN[s]=2e9;
	while (Head!=Tail){
		int x=que[Head=(Head+1)%maxt];vis[x]=0;
		for (int j=lnk[x],u;~j;j=nxt[j])
			if (e[j] && dis[x]+w[j]>dis[u=son[j]]){
				dis[u]=dis[x]+w[j];MIN[u]=min(MIN[x],e[j]);fa[u]=x;ID[u]=j;
				if (vis[u]<ti) que[Tail=(Tail+1)%maxt]=u,vis[u]=ti;
			}
	}
	if (dis[t]<0) return false;MC+=dis[t]*MIN[t];
	for (int x=t,j;x!=s;x=fa[x]) j=ID[x],e[j]-=MIN[t],e[j^1]+=MIN[t];
	return true;
}
int MCMF(int s,int t) {int MC=0;while (Spfa(s,t,MC));return MC;}
int main(){
	scanf("%d%d",&n,&m);memset(lnk,255,sizeof(lnk));
	for (int i=1;i<=n;i++) scanf("%s",pic[i]+1);
	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (pic[i][j]=='o') cnt++,BFS(i,j);
	for (int i=1;i<=cnt;i++) Add(0,i,1,0);for (int i=101;i<=n*m+100;i++) Add(i,n*m+101,1,0);
	printf("%d\n",MCMF(0,n*m+101));return 0;
}

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

int N[1001];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> N[i];
	}
	sort(N, N + n);
	int total = 0;
	for (int i = 0; i < k; i++) {
		total += N[i];
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n) {
        cnt++;
        n /= k;
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 3600
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

#define MOD 1000000007
#define NAX 200005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

void FAST()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //srand(time(NULL));
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);    

}

int main()
{
    FAST();

    ll n;
    cin>>n;

    ll a[n];
    ll b[n];
    FOR(i,0,n)
    cin>>a[i]>>b[i];

    priority_queue<pair<ll,ll> > q;
    FOR(i,0,n)
    {
        q.push(mp(a[i]+b[i],i));
    }

    ll cnt1 = 0;
    ll cnt2 = 0;
    FOR(i,0,n)
    {
        pair<ll,ll> temp = q.top();
        q.pop();

        if(i%2==0)
        {
            cnt1+=a[temp.ss];
        }
        else
        {
            cnt2+=b[temp.ss];
        }
    }

    cout<<cnt1-cnt2<<endl;
    return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int[] m = new int[10];
		int[] h = new int[3];
		
		
		for(int i=0; i<3; i++)
		{
			h[i] = -1;
		}
		
		for(int i=0; i<10; i++)
		{
			m[i] = scanner.nextInt();
			if(h[0] < m[i])
			{		
				h[0] = m[i];
				int r = 0;
				for(int j=1; j<3; j++)
				{
					if(h[j] < h[r])
					{
						int buf = h[r];
						h[r] = h[j];
						h[j] = buf;
						r = j;
					}
				}
			}
		}
		
		for(int i=2; i>=0; i--)
		{
			System.out.println(h[i]+"");
		}
	}
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N;
    cin >> N;
    vec<lint> p_list;
    range(i, 0, N) {
        lint p;
        cin >> p;
        p_list.emplace_back(p - 1);
    }
    lint num_consecutive_bads = 0;
    lint num_swaps = 0;
    range(i, 0, N) {
        lint p = p_list.at(i);
        if (p == i) {
            num_consecutive_bads += 1;
        } else {
            num_swaps += (num_consecutive_bads + 1) / 2;
            num_consecutive_bads = 0;
        }
    }
    num_swaps += (num_consecutive_bads + 1) / 2;
    cout << num_swaps << "\n";
}

Measured memory_bytes: 1400
number=list(map(int,input().split()))
N,M,X=number[0],number[1],number[2]
price=0
nums=[]
for i in range(N):
    tmp=list(map(int,input().split()))
    nums.append(tmp)
target=[0 for i in range(M)]
answer=10000000
for cowmask in range(1<<N):
        price=0
        target=[0 for k in range(M)]
        for x in range(N):
                if (cowmask>>x)&1==0:
                    price+=nums[x][0]
                    for j in range(1,M+1):
                        target[j-1]+=nums[x][j]
        if min(target)>=X:
            answer=min(answer,price)

if answer==10000000:
    print(-1)
else:
    print(answer)

Measured memory_bytes: 74324
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
struct UnionFind {
	vector<int> par;
	vector<int> size;

	UnionFind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		size = vector<int>(n, 1);
	}

	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size[x] < size[y]) {
			par[x] = y;
			size[y] += size[x];
		}
		else {
			par[y] = x;
			size[x] += size[y];
		}
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	UnionFind U(N);
	int ans = N;
	for (int i = 0; i < M; i++) {
		int X, Y, Z;
		cin >> X >> Y >> Z;
		X--; Y--;
		if (!U.same(X, Y)) {
			ans--;
			U.unite(X, Y);
		}
	}
	cout << ans << endl;
}


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

int main(){
    int a, b;
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(int i = 0; i < a; ++i){
            for(int j = 0; j < b; ++j){
                if(i == 0 || i == a - 1 || j == 0 || j == b - 1) cout << "#" << flush;
                else cout << "." << flush;
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    ll N, M;
    cin >> N >> M;
    vl H(N);
    for(ll i=0; i<N; i++){
        cin >> H.at(i);
    }

    ll a, b;
    vl check(N);
    for(ll i=0; i<M; i++){
        cin >> a >> b;
        a--;
        b--;
        if(H.at(a) < H.at(b)){
            check.at(a) = -1;
        }
        else if(H.at(a) > H.at(b)){
            check.at(b) = -1;
        }
        else{
            check.at(a) = -1;
            check.at(b) = -1;
        }
    }
    ll sum = 0;
    for(ll i=0; i<N; i++){
        if(check.at(i) == 0){
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4444
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N;
	int T;
	cin >> N >> T;
	int c[101];
	int t[101];

	for (int i = 0; i <= N - 1; i++) {
		cin >> c[i] >> t[i];
		if (t[i] > T)c[i] = 1001;
	}
	sort(c, c + N);

	if (c[0] == 1001) {
		cout << "TLE";
		return 0;
	}
	cout << c[0];
	return 0;
}

Measured memory_bytes: 256
function Main(s){
  var n = +s;
  var ans = 0;
  while(n){
    ans += n % 10;
    n = Math.floor(n / 10);
  }
  if(ans === 1)ans = 10;
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

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


int main() {
    const long long B = 1000000000000000000;
    int N;
    cin >> N;
    vector<long long> a(N,0);
    long long ans=1;
    for (int i=0; i<N; i++) {
        cin >>a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        
    }
    std::sort(a.begin(),a.end(),std::greater<int>());
    for (int i=0; i<N; i++) {
        // cout << "a is " << log10((double)a[i]) << endl;
        // cout << "ans is " << log10((double)ans) << endl;
        if (log10((double)ans) + log10((double)a[i]) > 19.) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
        if (ans > B){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

ll n,m,par[100010],rnk[100010],nmb[100010],a[100010],b[100010],c[100010],sum=0;

void init(){
  fr(i,n){par[i]=i,rnk[i]=0;nmb[i]=1;}
}

ll find(ll i){
  //cout<<par[i]<<endl;
  if(par[i]==i) return i;
  par[i]=find(par[i]);
  return par[i];
}

bool same(ll i,ll j){
  return find(i)==find(j);
}

bool unit(ll i,ll j){
  i=find(i);
  j=find(j);
  //cout<<i<<" "<<j<<endl;
  if(i==j) return 1;
  sum-=nmb[i]*nmb[j];
  if(rnk[i]>rnk[j]){
    par[j]=i;
    nmb[i]+=nmb[j];
  }
  else{
    par[i]=j;
    nmb[j]+=nmb[i];
    if(i!=j&&rnk[i]==rnk[j]) rnk[j]++;
  }
  return 0;
}

ll qw(ll n){
  if(n%2) return n*((n-1)/2);
  else return (n/2)*(n-1);
}

int main(){
  cin>>n>>m;
  fr(i,m){cin>>a[i]>>b[i];--a[i];--b[i];}
  sum+=qw(n);
  c[m]=sum;
  //fr(i,n) cout<<find(i)<<endl;
  init();
  ifr(i,m){
    unit(a[i],b[i]);
    c[i]=sum;
  }
  Fr(i,m) cout<<c[i]<<endl;
}

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

void trace(int A[], int len)
{
	for(int i = 0; i < len; i++)
	{
		printf("%d", A[i]);
		if(i < len-1)
		{
			printf(" ");
		}
	}
	printf("\n");
}

void selectSort(int A[], int n)
{
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		int mini = i;
		for(int j = i; j < n; j++)
		{
			if(A[j] < A[mini])
			{
				mini = j;
			}
		}
		swap(A[i], A[mini]);
		if (i != mini) {
			cnt++;
		}
	}
	trace(A, n);
	printf("%d\n", cnt);
}


int main(int argc, char *argv[]) {
	int N, A[101];
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	selectSort(A, N);
	return 0;
}


Measured memory_bytes: 3200