akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Optional;
import java.util.Scanner;

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

        //        ArrayList<Integer> all = new ArrayList<Integer>();
        //        ArrayList<Integer> total = new ArrayList<Integer>();
        ArrayList<Object> aveAll = new ArrayList<Object>();

        Scanner scanner = new Scanner(System.in);

        while (true) {
            ArrayList<Integer> all = new ArrayList<Integer>();
            ArrayList<Integer> total = new ArrayList<Integer>();
            //            ArrayList<Integer> aveAll = new ArrayList<Integer>();

            String num = scanner.next();
            int conNum = Integer.parseInt(num);

            String max = scanner.next();
            int maxBuy = Integer.parseInt(max);

            if (conNum == 0 && maxBuy == 0) {
                break;
            }

            for (int i = 0; i < conNum; i++) {
                String each = scanner.next();
                int eachPrice = Integer.parseInt(each);
                all.add(eachPrice);
            }

            for (int i = 0; i < all.size(); i++) {
                for (int j = i + 1; j < all.size(); j++) {
                    int priceTotal = all.get(i) + all.get(j);
                    if (priceTotal <= maxBuy) {
                        total.add(priceTotal);
                    }
                }
            }

            if(total.size() == 0) {
                aveAll.add("NONE");
            } else {

                Optional<Integer> maxTotal = total.stream()
                        .max((a, b) -> a.compareTo(b));
                aveAll.add(maxTotal.get());
            }

            //            System.out.println(maxTotal.get());
        }
        //        Optional<Integer> maxTotal = total.stream()
        //                .max((a, b) -> a.compareTo(b));

        for (int i = 0; i < aveAll.size(); i++) {
            System.out.println(aveAll.get(i));

        }
    }

}



Measured memory_bytes: 73276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  string a,b;
  cin >> a >> b;
  b.pop_back();
  if(a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,t;

int main(){
	cin>>a>>b>>t;
	cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}

int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	string s;
	cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC");
}


Measured memory_bytes: 3644
def main():
    N = int(input())
    A = list(map(int, input().split()))
    avg = sum(A)/len(A)
    diff = 300000
    ans = 0
    for i in range(len(A)):
        if abs(A[i]-avg) < diff:
            diff = abs(A[i]-avg)
            ans = i
        else:
            pass
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
 
int main(){
    int x,y,z;
    while(1){
        cin>>x>>y>>z;
 
        if(x==0&&y==0&&z==0)break;
 
 
        int a[114514];
        int b[114514];
 
        rep(i,x){
            cin>>a[i];
        }

        rep(i,z-y+1){
            b[i]=a[i+y-1]-a[i+y];
        }

        rep(i,z-y+1){
            // cout<<i<<" "<<b[i]<<endl;
        }

        int count=0;
        int tmp=0;
        int ans=0;

        for(int i=0;i<z-y+1;i++){
            if(tmp<=b[i]){
                tmp=b[i];
                ans=i+y;
            }
        }
        cout<<ans<<endl;
 
       
    //     repi(i,y-1,z){
    //         // cout<<a[i]<<endl;
    //         // cout<<a[i+1]<<endl;
             
    //         if(tmp<=a[i]-a[i+1]){
    //             tmp=max(tmp,a[i]-a[i+1]);
    //             ans=i-1+y;
    //         }
 
    //         // cout<<"tmp:"<<tmp<<endl;
    //         // cout<<"ans:"<<ans<<endl;
 
    //         count++;
    //     }
    //     // cout<<count<<endl;
    //     // cout<<"tmp:"<<tmp<<endl;
    //     // cout<<"ans:"<<ans<<endl;
    //     if(y==1){
    //         cout<<ans+1<<endl;
    //     }else{
    //         cout<<ans<<endl;
    //     }
 
    }
     
}

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

int main() {
  long long H,K,ko;
  cin >>H;
  K=0;
  ko=1;
  long long ans;
  while(H>0){
    H/=2;
    ans+=ko;
    ko*=2;
  }

  cout <<ans<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
vector<int> v[200050];
int32_t main()
{
	int t=1;
	while(t--)
	{
		int n,k,c;
		cin >> n >> k >> c;
		string str;
		cin >> str;
		vector<int> v,v2;
		int i=0,cnt=0;
		while(i<n && cnt<k)
		{
			if(str[i]=='o')
			{
				v.push_back(i);
				i+=c;
				cnt++;
			}
			i++;
		}
		i=n-1,cnt=k-1;
		while(i>=0 && cnt>=0)
		{
			if(str[i]=='o')
			{
				v2.push_back(i);
				i-=c;
				cnt--;
			}
			i--;
	
		}
		reverse(v2.begin(),v2.end());
		for(int i=0;i<k;i++)
		{
			//cout << v[i] << " " <<  v2[i] << endl;
			if(v[i]==v2[i])
			cout << v[i]+1 << endl;
		}
	}
	
}




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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    ll n, m; cin >> n >> m;
    ll ac_num = 0, penalty_num = 0;
    vector<bool> isAccepted(n, false);
    vl penalty(n, 0);
    rep(i,m) {
        ll p; cin >> p; p--;
        string s; cin >> s;
        if (isAccepted[p]) continue;
        if (s == "AC") {
            isAccepted[p] = true;
            penalty_num += penalty[p];
            ac_num++;
        } else {
            penalty[p]++;
        }
    }
    cout << ac_num << " " << penalty_num << endl;
    return 0;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	map<int, int> has;
	int x, n; read(x, n);
	rep(i, 0, n) {
		int t; read(t);
		has[t] = 1;
	}

	int ans = 0x3f3f3f3f;
	rep(i, -102, 102) if (!has[i]&&abs(i - x) < abs(ans - x)) ans = i;
	write(ans);
}


Measured memory_bytes: 3664
N = int(input())
a = list(map(int,input().split()))

cum_sum = [0]*N
cum_sum[0] = a[0]

for i in range(1,N):
	cum_sum[i] = cum_sum[i-1] + a[i]

res = 10**15
for i in range(N-1):
	x = cum_sum[i]
	y = cum_sum[N-1] - cum_sum[i]
	res = min(res, abs(x-y))

print(res)

Measured memory_bytes: 24832
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)

int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	
	if (b % a == 0) cout << a+b;
	else cout << b-a;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

struct N {
  int a, b, c;
};

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

ll dp[41][401][401] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<N> ns(n);
  for (int i = 0; i < n; i++) cin >> ns[i].a >> ns[i].b >> ns[i].c;
  ll INF = 1LL << 50;
  for (int i = 0; i <= n; i++) for (int j = 0; j < 401; j++) for (int k = 0; k < 401; k++) dp[i][j][k] = INF;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 401; j++) {
      for (int k = 0; k < 401; k++) {
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        if (j + ns[i].a < 401 && k + ns[i].b < 401) {
          dp[i + 1][j + ns[i].a][k + ns[i].b] = min(dp[i + 1][j + ns[i].a][k + ns[i].b], dp[i][j][k] + ns[i].c);
        }
      }
    }
  }
  ll ans = INF;
  for (int i = 0; i < 401; i++)
    for (int j = 0; j < 401; j++) {
      if (i == 0 && j == 0) continue;
      if (i * mb == j * ma) {
        ans = min(ans, dp[n][i][j]);
      }
    }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 51712
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int ans[N];
int visited[N];
int n, m;
vector<int> graph[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> q;
    memset(visited, 0, sizeof(visited));
    q.push(0);
    ans[0] = 0;
    visited[0] = 1;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        if(visited[p] == 1)
        for(int i = 0; i < graph[p].size(); i++){
            if(visited[graph[p][i]] == 0){
                q.push(graph[p][i]);
                ans[graph[p][i]] = p;
                visited[graph[p][i]] = 1;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(visited[i] == 0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i = 1; i < n; i++){
        cout<<ans[i]+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 10812
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
int n,x =0; string s;
cin>>n>>s;
if(n>=3&&n<=50 && s.size()<=n){
    for(int i=0; i<n; i++){
    if(s[i] == 'A'){
        if(s[i+1] == 'B'){
            if(s[i+2] == 'C'){
                x++;
            }
        }
    }
    }
cout<<x;
}
}



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

using namespace std;

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

lli max2(lli a,lli b){
	return a>b?a:b;
}
lli min2(lli a,lli b){
	return a<b?a:b;
}

int main(){

	lli n,k;
	cin>>n>>k;
	vector<lli> h;
	REP(i,n){
		lli tmp;
		cin>>tmp;
		h.push_back(tmp);
	}
	sort(h.begin(),h.end());

	lli minAns = 1000000000000;
	for(lli i=0;i<n-k+1;i++){
		lli diff = h[i+k-1] - h[i];
		minAns = min2(minAns,diff);
	}
	cout<<minAns<<endl;
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << x+y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	m := make(map[string]bool)
	x := getString()
	m[x] = true
	ans := true
	for i := 1; i < N; i++ {
		y := getString()
		if m[y] == true {
			ans = false
			break
		}
		if x[len(x)-1] != y[0] {
			ans = false
			break
		}
		x = y
		m[x] = true
	}
	if ans {
		out("Yes")
		return
	}
	out("No")
}


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

using namespace std;

int main() {
    char x, y;
    cin >> x >> y;
    
    if (x < y) {
        cout << "<" << endl;
    } else if (x > y) {
        cout << ">" << endl;
    } else if (x == y) {
        cout << "=" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
    ll u,v,t,n,i,j,k,l,mnx=1e18, mxx=-1e18,mny=1e18, mxy=-1e18;;

    sl(n);
    for(int i=0; i<n; i++)
    {
        sl2(u,v);
        mxx=max(mxx, u+v);
        mnx=min(mnx, u+v);

        mxy=max(mxy, u-v);
        mny=min(mny, u-v);
    }
    ll ans=max(abs(mxx-mnx), abs(mxy-mny));
    printf("%lld\n", ans);

}




Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		int X = scn.nextInt();
		int Y = scn.nextInt();
		for(int i = 0;i < N;i++) {
			X = Math.max(X, scn.nextInt());
		}
		for(int i = 0;i < M;i++) {
			Y = Math.min(Y, scn.nextInt());
		}
		System.out.println(!(X<Y)?"War":"No War");
		scn.close();
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    IOS
    int n,x;
    cin>>n>>x;
    cout<<n-x+1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> wa(n, 0);
	vector<bool> ac(n, false);

	for (int i = 0; i < m; i++) {
		int p;
		string result;
		cin >> p >> result;
		if (result == "AC") {
			ac[p - 1] = true;
		} else {
			if (ac[p - 1] == false) {
				wa[p - 1]++;
			}
		}
	}

	int w = 0, a = 0;

	for (int i = 0; i < n; i++) {
		if (ac[i]) {
			a++;
			w += wa[i];
		}
	}

	printf("%d %d", a, w);

	return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_H 1000
#define MAX_W 1000
#define INF 1152921504606846976

typedef pair<i64, i64> P;

i64 H, W;
char G[MAX_H][MAX_W];
i64 d[MAX_H][MAX_W];
vector<P> start;

i64 dy[] = {1, 0, -1,  0};
i64 dx[] = {0, 1,  0, -1};

bool inside(i64 y, i64 x) {
  return (0 <= y && y < H && 0 <= x && x < W);
}

void solve() {
  REP(y, H) {
    REP(x, W) {
      d[y][x] = INF;
    }
  }

  queue<P> que;
  for (auto it = start.begin(); it != start.end(); it++) {
    que.push(*it);
    d[(*it).F][(*it).S] = 0;
  }

  i64 ny, nx;
  while (!que.empty()) {
    P yx = que.front(); que.pop();
    
    REP(i, 4) {
      ny = yx.F + dy[i];
      nx = yx.S + dx[i];
      if (inside(ny, nx) && d[ny][nx] == INF && G[ny][nx] == '.') {
        que.push(mp(ny, nx));
        d[ny][nx] = d[yx.F][yx.S] + 1;
        G[ny][nx] = 'o';
      }
    }
  }

  i64 maxd = 0;
  REP(y, H) {
    REP(x, W) {
      if (G[y][x] == 'o') {
        chmax(maxd, d[y][x]);
      }
    }
  }
  cout << maxd << endl;
}

int main() {
  cin >> H >> W;
  REP(y, H) {
    REP(x, W) {
      cin >> G[y][x];
      if (G[y][x] == '#') {
        start.pb(mp(y, x));
      }
    }
  }

  solve();

  return 0;
}

Measured memory_bytes: 41060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	unordered_set<int> r,g,b;
	rep(i,0,sz(s)){
		if(s[i]=='R'){
			r.insert(i);
		}else if(s[i]=='G'){
			g.insert(i);
		}else{
			b.insert(i);
		}
	}
	ll ans = 1LL * sz(r)*sz(g)*sz(b);
	
	if(ans==0){
		cout<<0;
		return ;
	}
	
	for(auto i:r){
		for(auto k:g){
			if(((i+k)%2==0)&&b.find((i+k)/2)!=b.end()){
				//cout<<i<<" "<<k<<" "<<(i+k)/2<<endl;
				ans--;
			}
		}
	}
	for(auto i:r){
		for(auto k:b){
			if(((i+k)%2==0)&&g.find((i+k)/2)!=g.end()){
			//	cout<<i<<" "<<k<<" "<<(i+k)/2<<endl;
				ans--;
			}
		}
	}
	for(auto i:b){
		for(auto k:g){
			if(((i+k)%2==0)&&r.find((i+k)/2)!=r.end()){
			//	cout<<i<<" "<<k<<" "<<(i+k)/2<<endl;
				ans--;
			}
		}
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    vector<pair<int, int>> E_in;

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        E_in.push_back({a, b});
    }

    queue<int> q;
    vector<bool> used(n, false);
    vector<int> parent(n, 0);
    int max_color = 0;
    map<pair<int, int>, int> E_num;
    q.push(0);
    used[0] = true;

    while (q.size() != 0) {
        int state = q.front();
        q.pop();

        int color_num = 0;
        for (auto next: G[state]) {
            if (!used[next]) {
                color_num++;
                used[next] = true;
                if (color_num == parent[state]) color_num++;
                pair<int, int> p = make_pair(state, next);
                E_num[p] = color_num;
                parent[next] = color_num;
                q.push(next);
            }
        }
        max_color = max(max_color, color_num);
    }

    cout << max_color << endl;
    for (auto i: E_in) {
        cout << E_num[i] << endl;
    }
}

Measured memory_bytes: 13428
#include "bits/stdc++.h"
 
using namespace std;
 
#define int long long
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FORR(i, a, b) for (int i = (a); i >= (b); i--)
 
#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()
 
#define INT_INF 200000000
 
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)
 
typedef long long ll;
typedef pair<int, int> PINT;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

//the end of library zone



signed main(){
	double T, X;
	cin >> T >> X;

	cout << T / X << endl;

    return 0;
}


Measured memory_bytes: 256
def is_left_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i < 0:
      return True
    if i >= N:
      return False
  return False
def is_right_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i >= N:
      return True
    if i < 0:
      return False
  return False

N, Q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(Q)]

# left
l = 0
r = N - 1
l_res = -1
while (l <= r):
  target = (r + l) / 2
  if is_left_removed(target, s, td):
    l = target + 1
    l_res = target
  else:
    r = target - 1

# right
l = 0
r = N - 1
r_res = N
while (l <= r):
  target = (r + l) / 2
  if is_right_removed(target, s, td):
    r = target - 1
    r_res = target
  else:
    l = target + 1

print N - min(N, l_res + 1 + N - r_res)

Measured memory_bytes: 47336
import std.c.stdio;

const int MOD = 100000;

const int MAX_H = 105;
const int MAX_W = 105;

int H, W;

int dp[MAX_H][MAX_W][4];

int main()
{
	while (true)
	{
		scanf("%d", &W);
		scanf("%d", &H);

		if (W == 0 && H == 0) { break; }

		for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { dp[i][j] = 0; } }

		for (int i = 0; i < H; i++)
			dp[i][0][2] = 1;

		for (int j = 0; j < W; j++)
			dp[0][j][3] = 1;

		for (int i = 1; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				dp[i][j][0] = dp[i - 1][j][3];
				dp[i][j][1] = dp[i][j - 1][2];
				
				for (int k = i - 1; k >= 1; k--)
				{
					dp[i][j][2] += dp[k][j][0];
				}

				dp[i][j][2] %= MOD;

				for (int k = j - 1; k >= 1; k--)
				{
					dp[i][j][3] += dp[i][k][1];
				}

				dp[i][j][3] %= MOD;
			}
		}

		printf("%d\n", (dp[H - 1][W - 1][0] + dp[H - 1][W - 1][1] + dp[H - 1][W - 1][2] + dp[H - 1][W - 1][3]) % MOD);
	}

	return 0;
}

Measured memory_bytes: 2496
#include <stdio.h>
int min(int a,int b){
	if(a<b){
		return a;
	}else return b;
}

int main(void){
	int busfare[2],trainfare[2],ans;
	scanf("%d",&busfare[0]);
	scanf("%d",&busfare[1]);
	scanf("%d",&trainfare[0]);
	scanf("%d",&trainfare[1]);
	ans=min(busfare[0],busfare[1])+min(trainfare[0],trainfare[1]);
	printf("%d\n",ans);
}


Measured memory_bytes: 128
a, b = map(int, input().split())

import math

def prime(n):
  if n == 1:
    return False
  i = 1
  while i < int(math.sqrt(n)):
    i += 1
    if n%i == 0:
      return False
  else:
    return True

#print(prime(1))

if prime(a) and prime(b) and a==b:
  print(2)
  exit()
  
if a-b == 1 or b-a == 1:
  print(1)
  exit()

l = []
for i in range(1, max(int(math.sqrt(a))+2, int(math.sqrt(b))+2)):
  if i == 1:
    l.append(i)
  else:
    if a%i == 0 and b%i == 0 and prime(i):
      l.append(i)
    j = a//i
    if j != 0:
      if b%j == 0 and prime(j):
        l.append(j)
    k = b//i
    if k != 0:
      if a%k == 0 and prime(k):
        l.append(k)
#print(set(l))
print(len(set(l)))
               

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long a, b;
    cin >> a >> b;
    long c = b - a;
    long s = c * (c + 1) / 2;
    cout << s - b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
    char s1[101],s2[101];
    int i,per1=0,per2=0,n,f;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",s1,s2);
        f=strcmp(s1,s2);
        if(f>0){
            per1+=3;
        }else if(f<0){
            per2+=3;
        }else{
            per1++;
            per2++;
        }
    }
    printf("%d %d\n",per1,per2);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

struct edge{
    ll to,id;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<ll> D(N),id(N);
    iota(id.begin(),id.end(),0);
    for(int i=0;i<N;i++) cin >> D[i];
    sort(id.begin(),id.end(),[&](int a,int b){
        return D[a]<D[b];
    });
    vvec<edge> g(N);
    ll inf = 1e9;
    vec<char> ansv(N,'A');
    vec<ll> anse(M,inf);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back({b,i});
        g[b].push_back({a,i});
    }
    
    auto bfs = [&](int s){
        queue<int> Q;
        Q.push(s);
        while(!Q.empty()){
            int now = Q.front(); Q.pop();
            for(auto& e:g[now]) if(ansv[e.to]=='A' && D[s]==D[e.to]){
                if(now==s) ansv[now] = 'B';
                anse[e.id] = D[s];
                ansv[e.to] = (ansv[now]=='W'? 'B':'W');
                Q.push(e.to);
            }
        }
    };

    for(int i=0;i<N;i++) if(ansv[i]=='A') bfs(i);

    for(int i=0;i<N;i++){
        int now = id[i];
        if(ansv[now]!='A') continue;
        sort(g[now].begin(),g[now].end(),[&](edge& a,edge& b){
            return D[a.to]<D[b.to];
        });
        bool ok = false;
        for(auto& e:g[now]){
            if(ansv[e.to]!='A' && D[e.to]<D[now]){
                anse[e.id] = D[now]-D[e.to];
                ansv[now] = ansv[e.to];
                ok = true;
                break;
            }
        }
        if(!ok){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=0;i<N;i++){
        cout << ansv[i];
    }
    cout << endl;
    for(int i=0;i<M;i++) cout << anse[i] << endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		if (n == 2) {
			System.out.println(Math.max(a[0], a[1]));
			return;
		}

		long ans = Long.MIN_VALUE;
		long[][] dp = new long[n][3];
		dp[0][0] = a[0];
		dp[1][0] = a[0];
		dp[2][0] = a[0] + a[2];
		dp[1][1] = a[1];
		dp[2][1] = a[1];
		dp[2][2] = a[2];
		for (int i = 3; i < n; i++) {
			if (i % 2 == 0) {
				dp[i][0] = dp[i - 2][0] + a[i];
				dp[i][1] = dp[i - 1][1];
				dp[i][2] = Math.max(dp[i - 2][2], dp[i - 3][1]) + a[i];
			} else {
				dp[i][0] = dp[i - 1][0];
				dp[i][1] = Math.max(dp[i - 2][1], dp[i - 3][0]) + a[i];
				dp[i][2] = dp[i - 1][2];
			}
		}
//		for (int i = 0; i < dp.length; i++) {
//			for (int j = 0; j < dp[i].length; j++) {
//				System.out.print(dp[i][j] + "\t");
//			}
//			System.out.println();
//		}
		if (n % 2 == 0) {
			ans = Math.max(ans, dp[n - 2][0]);
			ans = Math.max(ans, dp[n - 1][1]);
		} else {
			ans = Math.max(ans, dp[n - 3][0]);
			ans = Math.max(ans, dp[n - 2][1]);
			ans = Math.max(ans, dp[n - 1][2]);
		}
		System.out.println(ans);
	}
}


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

int main() {
  int number;
  int check=0;
  cin >> number;
  int n[4];
  n[0]=number%10;
  n[1]=(number%100-number%10)/10;
  n[2]=(number%1000-number%100)/100;
  n[3]=(number-number%1000)/1000;
  for(int i=0;i<3;i++){
    if(n[i]==n[i+1]){
      cout << "Bad" << endl;
      check=1;
      break;
    }
  }
  if(check==0){
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque


MOD = 1000000007  # type: int

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    adj = [[] for _ in range(N)]
    for aa, bb in zip(a, b):
        adj[aa-1].append(bb-1)
        adj[bb-1].append(aa-1)
    
    color = [K for _ in range(N)]
    visited = [False for _ in range(N)]
    Q = deque([])

    visited[0] = True
    Q.append((0, 0))

    while len(Q) > 0:
        u, x = Q.popleft()
        for v in adj[u]:
            if visited[v]:
                continue
            x += 1
            color[v] -= x
            Q.append((v, 1))
            visited[v] = True

    res = 1
    for c in color:
        res = (res * c) % MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64348
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int order(ll x){
    int rev=0;
    while(x%2==0){
        x/=2;
        rev++;
    }
    return rev;
}

ll gcd(ll a,ll b){
    if(a==0)return b;
    if(b==0)return a;

    ll M=max(a,b);
    ll m=min(a,b);
    return gcd(m,M%m);
}

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

int main(){
    int N;ll M;cin>>N>>M;
    vec a(100010);
    for(int i=0;i<N;i++){
        cin>>a[i];
        a[i]/=2;
    }
    int x=order(a[0]);
    for(int i=1;i<N;i++){
        if(x!=order(a[i])){
            cout<<0<<endl;
            return 0;
        }
    }
    ll l=1;
    for(int i=0;i<N;i++){
        l=lcm(l,a[i]);
        if(l>M){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<(M/l+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 1152
// D - Flipping Signs
#include <bits/stdc++.h>
using namespace std;

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

	long long sum = 0;
	int mini = 1e9, minus_count = 0;

	for(int i=0; i<N; ++i){
		int a; cin>>a;
		if(a<0){ a = -a; ++minus_count; }
		mini = min(mini, a);
		sum += a;
	}

	cout<< sum - minus_count%2 * mini*2 <<endl;
}

Measured memory_bytes: 384
import java.io.*
import java.util.*

fun solve(a: Long, s: String){
    if (a>=3200L) println(s)
    else println("red")
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next().toLong()
    val s = sc.next()
    solve(a, s)
}



Measured memory_bytes: 31636
import java.util.Scanner;

public class Main {

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

		    int r = sc.nextInt();
		    int g = sc.nextInt();
		    int b = sc.nextInt();
		    
		    if((10 * g + b) % 4 == 0) {
		    	System.out.println("YES");
		    }
		    else {
		    	System.out.println("NO");
		    }
		    
		    sc.close(); }
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  ll N,M;
  cin >> N >> M;

  if(N >= 2 && M >= 2)cout << (N-2)*(M-2) << endl;
  else{
    if(N == 1 && M == 1)cout << 1 << endl;
    else cout << max(N,M) - 2 << endl;
  }
  
}


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

int main() {
  char hinaarare;
  int N;
  int flag = 0; //flag = 0ならばthree 1ならばfourを出力 それ以外は2
  
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> hinaarare;
    //黄色の雛霰がある場合
    if(hinaarare == 'Y') 
      flag = 1;
    else if (hinaarare != 'Y' && hinaarare != 'W' && hinaarare != 'G' && hinaarare != 'P')
      flag = 2;
  }
    
  if(flag == 0) cout << "Three" << endl;
  else if(flag == 1) cout << "Four" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from itertools import combinations


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M, X = map(int, input().split())
    CA = [[] for _ in range(N)]
    for n in range(N):
        CA[n] = list(map(int, input().split()))

    COSTS = []
    for n in range(N):
        for c in combinations(CA, n+1):
            SUM = [0 for _ in range(M)]
            COST = 0
            for ca in c:
                COST += ca[0]
                for m in range(M):
                    SUM[m] += ca[m+1]
            if all(list(map(lambda x: x >= X, SUM))):
                COSTS.append(COST)
    if COSTS:
        print(min(COSTS))
        return
    print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9352
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
char s[1010100];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int N=0,S=0,W=0,E=0;
	for(rint i=1;i<=len;++i) {
		if(s[i]=='S') S=1;
		if(s[i]=='N') N=1;
		if(s[i]=='W') W=1;
		if(s[i]=='E') E=1;
	}
	if(N!=S||W!=E) {
		cout<<"No";
	}else cout<<"Yes";
	return 0;
} 

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

int main() {
	
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n){
		int l, r;
		cin >> l >> r;
		ans += (r - l) + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var input = Console.ReadLine();
            int i = 0;
            int max = input.Length - 1;
            int cnt = 0;
            while(i < max)
            {
                if (input[i] != input[max]) cnt += 1;
                i += 1;
                max -= 1;
            }

            Console.Write(cnt);
        }
    }


Measured memory_bytes: 13140
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
using P=pair<int,int>;
int main(){
    int N,M,s,t;
    cin>>N>>M>>s>>t;
    s--;t--;
    vector<int> G[N];
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int dist_s[N],dist_t[N];
    fill(dist_s,dist_s+N,1000000000);
    fill(dist_t,dist_t+N,1000000000);
    queue<int> Q;
    dist_s[s]=0;
    Q.push(s);
    while(!Q.empty()){
        int v=Q.front(); Q.pop();
        for(auto to:G[v]){
            if(dist_s[to]==1000000000){
                dist_s[to]=dist_s[v]+1;
                Q.push(to);
            }
        }
    }
    dist_t[t]=0;
    Q.push(t);
    while(!Q.empty()){
        int v=Q.front(); Q.pop();
        for(auto to:G[v]){
            if(dist_t[to]==1000000000){
                dist_t[to]=dist_t[v]+1;
                Q.push(to);
            }
        }
    }
    int64_t cnt_s[N],cnt_t[N];
    fill(cnt_s,cnt_s+N,0);
    fill(cnt_t,cnt_t+N,0);
    for(int i=0;i<N;i++){
        if(dist_s[i]!=1000000000)cnt_s[dist_s[i]]++;
        if(dist_t[i]!=1000000000)cnt_t[dist_t[i]]++;
    }
    int64_t ans=0;
    int dist=dist_s[t];
    for(int i=0;i<=dist-2;i++){
        ans+=cnt_s[i]*cnt_t[dist-2-i];
    }
    cout<<ans<<endl;

    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;

signed main(){
    cin>>N>>M;
    UnionFindTree uf(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }

    int cnt=0;
    rep(i,N)if(uf.find(i)==i)cnt++;
    cout<<M-N+cnt<<endl;
    return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	
	if(a>b){
		printf("a > b\n");
	}
	if(a<b){
		printf("a < b\n");
	}
	if(a==b){
			printf("a == b\n");
			}
		return 0;
	}
		
		
		


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

int main() {
	double a,b;
  	int c;
 	cin >> a >> b;
	c = ((a + b) / 2) + 0.9; /*  ((1+2)/2)+0.9=1.5+0.9=2.4 */
    cout << c << endl; /*  2.4➡2 */
}

Measured memory_bytes: 3696
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 19204
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

L = ni()
# odd => 0, even => 1
A = [ni() for _ in range(L)]
assert len(A) == L

INF = 1 << 60
S = 5  # num of states


def solve():
    dp = [[INF] * S for _ in range(L + 1)]
    for s in range(S):
        dp[0][s] = 0
    for i in range(1, L + 1):
        a = A[i - 1]
        dp[i][0] = dp[i - 1][0] + a
        tm = min(dp[i - 1][0], dp[i - 1][1])
        dp[i][1] = tm + (2 if a == 0 else a % 2)
        tm = min(tm, dp[i - 1][2])
        dp[i][2] = tm + (1 - a % 2)
        tm = min(tm, dp[i - 1][3])
        dp[i][3] = tm + (2 if a == 0 else a % 2)
        tm = min(tm, dp[i - 1][4])
        dp[i][4] = tm + a
    # print(*dp, sep="\n", file=sys.stderr)
    return min(dp[L])


print(solve())


Measured memory_bytes: 77140
class SqrtDecomposition():
    def __init__(self, array, f):
        self.dat = array
        self.f = f
        m = int(pow(len(array), 0.5))
        if m**2 < len(array):
            m += 1
        self.m = m
        self.dat2 = []
        for i in range(m):
            if i * m >= len(array):
                break
            self.dat2 += [f(self.dat[m * i:m * (i + 1)])]

    def update(self, a, x):
        m = self.m
        dat = self.dat
        dat2 = self.dat2
        f = self.f
        dat[a] = x
        a2 = a // m
        al = m * a2
        ar = al + m
        dat2[a2] = f(dat[al:ar])

    def query(self, a, b):
        dat = self.dat
        dat2 = self.dat2
        f = self.f
        m = self.m
        a2 = a // m
        ar = a2 * m + m
        b2 = b // m
        bl = b2 * m
        if ar > bl:
            return f(dat[a:b])
        else:
            return f(dat[a:ar] + dat2[a2 + 1:b2] + dat[bl:b])


N, Q = [int(_) for _ in input().split()]
Query = [[int(_) for _ in input().split()] for _ in range(Q)]
SD = SqrtDecomposition(array=[2**31 - 1] * N, f=min)
for query in Query:
    if query[0]:
        query[2] += 1
        print(SD.query(*query[1:]))
    else:
        SD.update(*query[1:])



Measured memory_bytes: 23796
D, G = gets.split.map(&:to_i)
PC = D.times.map { gets.split.map(&:to_i) }

MAX = (1 << D) - 1
ans = 1 << 60
(0..MAX).each do |completed|
  score = 0
  solved_count = 0
  D.times do |i|
    if completed[i] == 1
      p_count, bonus = PC[i]
      base_score = (i + 1) * 100
      solved_count += p_count
      score += base_score * p_count + bonus
    end
  end
  rest_score = [G - score, 0].max
  if rest_score == 0
    ans = solved_count if solved_count < ans
  else
    (D - 1).downto(0) do |i|
      next if completed[i] == 1
      p_count = PC[i][0]
      base_score = ((i + 1) * 100)
      count = (rest_score + base_score - 1) / base_score
      next if count >= p_count
      solved_count += count
      ans = solved_count if solved_count < ans
    end
  end
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  int multi=1,i=N;
  int denomi[N];
  long double nume=0;
  while (i>0){
    denomi[i-1]=0;
    while (K>multi*i){
      multi*=2;
    }
    denomi[i-1]+=multi*N;
    i--;
  }

  for (int j = 0; j < N; j++)
  {
    nume+=denomi[0]/denomi[j];
  }
  

  printf("%.12Lf",nume/denomi[0]);
  

  return 0;
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
//const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
COMinit();
ll S;
  cin >>S;
  if(S<3) {
    cout<<0<<endl;
  }
else if(S==3) {
cout<<1<<endl;
}
else {

  ll c=S/3;
  vl vec(c);
  rep(i,c) {
    if(i!=0){
ll a=i+1;
    ll b=S-a*3;
    ll d=a-1;
    
    //b+dCb
    vec.at(i)=COM(b+d,b);
    }
    else if(i==0) {
      vec.at(i)=1;
    }
  }
  
  ll sum=0;
  rep(i,c) {
sum=(sum+vec.at(i))%MOD;
  }
  cout<<sum<<endl;
  //cout<<"A"<<vec.at(0)<<vec.at(1)<<endl;
}
  
  
}
   

Measured memory_bytes: 15516
import java.util.*;
import java.io.*;

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

		while( n!= 0){
			int d = n % 10;
			n/=10;

			if( d == 9){
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}


Measured memory_bytes: 21844