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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using pli=pair<ll,int>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)

/*B-Magic 2*/
void Solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(b<=a)
		b*=2,k--;
	while(c<=b)
		c*=2,k--;
	if(k>=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

int main(){
	fast
	Solve();
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

vector<P> factorizer(ll n) {
    vector<P> facts;
    for (ll p=2; p*p<=n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        facts.push_back(P(p, num));
    }
    if (n != 1) facts.push_back(P(n, 1));
    return facts;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> v(n+1, 0);
    for (int i=2; i<=n; ++i) {
        auto res = factorizer(i);
        for (auto prime_exp : res) {
            v[prime_exp.first] += prime_exp.second;
        }
    }
    ll ans = 1;
    for (int i=2; i<=n; ++i) {
        if (v[i] == 0) continue;
        ans *= v[i] + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<utility>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
    int a[100005];
    int b[100005];
	int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++){
        cin>>a[i]; 
		b[i]=0;
        }
        int flag=0; 
		int c=0;
        int i=1;
        while(1){
        if(b[i]==0){
        b[i]=1; 
		c++;
        i=a[i];
        if(i==2){
        flag=1; break;
        }
        }
        else if(b[i]==1){
        flag=0; break;
        }
        }
        if(flag==0)
        cout<<-1<<endl;
        else
        cout<<c<<endl;
        }   
    return 0;
}


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


int main(void) {
  ll n, m;
  cin >> n >> m;

  ll ans = 0;
  if (n < m / 2) {
    ans = n;
    m = m - (n * 2);
    ans += m / 4;
  } else {
    ans = m / 2;
  }

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

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

bool D(pair<ll,ll> A, pair<ll,ll> B, pair<ll,ll> C) {
	return (double)A.ff*(double)B.ss + (double)A.ss*(double)C.ff + (double)B.ff*(double)C.ss -
	((double)B.ss*(double)C.ff + (double)A.ff*(double)C.ss + (double)A.ss*(double)B.ff) < 0;
}

bool cross(pair<ll,ll> A, pair<ll,ll> B, pair<ll,ll> C) {
	pair<ll, ll> D = mp(B.ff-A.ff, B.ss-A.ss);
	pair<ll, ll> E = mp(C.ff-B.ff, C.ss-B.ss);
	return D.ff*E.ss < D.ss*E.ff;
}

vector<pair<ll,ll>> v;

void add(pair<ll,ll> a) {
	while(v.size() >= 2 and cross(v[v.size()-2], v[v.size()-1], a))
		v.pop_back();
	v.push_back(a);
}

ll dot(pair<ll,ll> a, pair<ll,ll> b) {
	return a.ff*b.ff + a.ss*b.ss;
}

ll bisearch(ll x) {
	int l = 0, r = (int)v.size()-1;
	while(l < r) {
		int m = (l+r)/2;
		if(dot(mp(x,1), v[m]) < dot(mp(x,1), v[m+1]))
			r = m;
		else
			l = m+1;
	}
	return dot(mp(x,1), v[r]);
}

int n, h[200005];
ll c, dp[200005];

ll f() {
	for(int i = 0; i < n; i++) {
		if(i == 0) dp[i] = 0;
		else dp[i] = bisearch(h[i]) + (ll)h[i]*h[i] + c;
		add(mp(-2LL*h[i], (ll)h[i]*h[i] + dp[i]));
	}
	return dp[n-1];
}

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

	for(int i = n-1; i >= 0; i--)
		scanf("%d", &h[i]);

	// printf("oi\n");
	printf("%lld\n", f());
	
    return 0;
}

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

int main()
{
    int N,A,M,sum=0,s=0;
    cin>>N>>M;
    for(int i=0; i<M; i++)
    {

        cin>>A;
        sum=sum+A;
    }
    if(N<sum){
        cout<< "-1"<<endl;
    }
    else{
     s=N-sum;
    cout<< s<<endl;

    }

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, m;
	cin >> n >> m;
	set<ll> st;
	rep(i, m){
		ll a;
		cin >> a;
		st.insert(a);
	}

	vector<ll> dp(n + 1);
	dp[0] = 1;
	repn(i, n){
		if(st.find(i) != st.end()) continue;
		dp[i] += dp[i - 1];
		if(i > 1) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}
	co(dp[n]);

	return 0;
}


Measured memory_bytes: 8736
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
# 標準出力による質問 interactive

import sys
count = 0
def query(l):
    global count
    count = count + 1
    if count>210:
        assert False
    print("? %s" % " ".join(map(str, l)))
    sys.stdout.flush()
    return input()

color = query(list(range(1,n+1)))
l = 1
r = n+1
while l<r-1:
    m = (l+r)//2
#     print("hoge")
    if color==query(range(m,m+n)):
        l = m
    else:
        r = m
ans = [None]*(2*n)
# r, ..., r+n-2に同数個
ll = list(range(r, r+n-1))
for i in range(1,2*n+1):
    if r<=i<=r+n-2:
        continue
    color = query(ll + [i])
    ans[i-1] = "B" if color=="Blue" else "R"
ll2 = []
bc = 0
rc = 0
for i in range(1,2*n+1):
    if r<=i<=r+n-2:
        continue
    if ans[i-1]=="R" and rc<n//2:
        rc += 1
        ll2.append(i)
    elif ans[i-1]=="B" and bc<n//2:
        bc += 1
        ll2.append(i)
assert len(ll2)==n-1
for i in range(r,r+n-1):
    color = query(ll2 + [i])
    ans[i-1] = "B" if color=="Blue" else "R"
# n==1のときは?
print("! %s" % "".join(map(str, ans)))

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

using namespace std;

long long power(int x, int y){
  long long n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}

int log(int x, int y){
  int cnt = 0;
  while(y > 1){
    y /= x;
    cnt++;
  }
  return cnt;
}

int main() {
  string a, b;
  cin >> a >> b;
  int c = 0;
  if(a.at(0) == b.at(0))
    c ++;
  if(a.at(1) == b.at(1))
    c ++;
  if(a.at(2) == b.at(2))
    c ++;
  cout << c << endl;
}


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

int GCD(int a,int b);
int LCM(int a,int b);

int main()
{
	int a,b,gcd,lcm;

	while(cin>>a>>b)
	{
		if(a==0 || b==0)
			cout<<"0 0"<<endl;
		gcd=GCD(a,b);
		lcm=LCM(a,b);
		cout<<gcd<<' '<<lcm<<endl;
	}
}

int GCD(int a,int b)
{
	while(a!=b)
		if(a>b) a=a-b;
		else    b=b-a;
	return a;
}
int LCM(int a,int b)
{
	return ((a / GCD(a, b)) * b);/*(a*GCD(a,b)*b);*/
}

//大文字を小文字に変換
/*
for(int i=0;i<inp.size();i++)
if(inp[i]>='A' && inp[i]<='Z')
inp[i]+='a'-'A';
*/

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

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

  rep(i, N)
  {
    int h;
    cin >> h;
    if (h >= K)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

	int N; cin >> N;
	vector<ll> a(N);
	for (ll& i : a) cin >> i;

	ll yen = 1000, stock = 0;
	for (int i = 0; i < a.size(); i++) {
		if (i < a.size() - 1 && a[i] < a[i + 1]) {
			stock +=  yen / a[i];
			yen %= a[i];
		}
		if (i < a.size() - 1 && a[i] > a[i + 1]) {
			yen += a[i] * stock;
			stock = 0;
		}
	}

	if (stock) yen += a.back() * stock;

	cout << yen;

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>

using namespace std;


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

	for (int i = 0; i < S.length(); i++)
	{
		S[i] = 'A' + (S[i] - 'A' + N) % 26;
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
map<P,int> mp;
int n,k,l,x,y;
int fa1[200005],fa2[200005];
int find1(int x){return x==fa1[x]?x:fa1[x]=find1(fa1[x]);}
int find2(int x){return x==fa2[x]?x:fa2[x]=find2(fa2[x]);}

int main(void){
    cin>>n>>k>>l;
    for(int i=1;i<=n;i++){
        fa1[i]=fa2[i]=i;
    }
    for(int i=0;i<k;i++){
        cin>>x>>y;
        x=find1(x),y=find1(y);
        if(x!=y)fa1[y]=x;
    }
    for(int i=0;i<l;i++){
        cin>>x>>y;
        x=find2(x),y=find2(y);
        if(x!=y)fa2[y]=x;
        /*
        for(int i=1;i<=n;i++){
        cout<<fa2[i];
    }
    cout<<" "<<x<<" "<<y<<endl;*/
    }
    for(int i=1;i<=n;i++)fa1[i]=find1(fa1[i]),fa2[i]=find2(fa2[i]);
    for(int i=1;i<=n;i++)mp[P(fa1[i],fa2[i])]++;
    for(int i=1;i<=n;i++)cout<<mp[P(fa1[i],fa2[i])]<<" ";
    cout<<endl;
    
    }


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
const int maxn = 2e5 + 5;
const ll INF = 1e18;
template<class T>
class SegmentTree{
public:
  T t[4*maxn], up[4*maxn];
  void prop(int cur,int L,int R){
    if(up[cur]==0) return;
    t[cur] += up[cur];
    if(L!=R){
      up[2*cur] += up[cur];
      up[2*cur+1] += up[cur];
    }
    up[cur] = 0;
  }
  void update(int l, int r, T x, int cur=1, int L=0, int R = maxn-1){
    prop(cur, L, R);
    if(R < l or L > r) return;
    if(L>=l && R<=r){
      up[cur] += x;
      prop(cur, L, R);
      return;
    }
    int mid = L + R >> 1;
    update(l,r,x, cur*2, L, mid);
    update(l,r,x,cur*2+1, mid+1, R);
    t[cur] = max(t[cur*2], t[cur*2+1]);
  }
  T query(int l, int r, int cur = 1, int L = 0, int R = maxn-1){
    prop(cur, L, R);
    if(R < l or L > r) return INF;
      if(L>=l && R<=r){
        return t[cur];
    }
    int mid = L + R >> 1;
    return max(query(l,r,cur*2, L, mid),query(l,r,cur*2+1, mid+1, R));
  }
};
ll n, m;
vector<pii> qry1[maxn], qry2[maxn];
SegmentTree<ll> tree;
void solve(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		qry1[a].pb({a-1, c});
		qry2[b].pb({a-1, -c});
	}
	tree.update(1, maxn-1, -INF);
	for(int i=1;i<=n;i++){
		for(pii &q : qry1[i]){
			//cout << "OPEN " << q.ff << " " << q.ss << endl;
			tree.update(0, q.ff, q.ss);
		}
		//cout << i << " " << tree.t[1] << endl;
		tree.update(i, i, tree.t[1] + INF);
		for(pii &q : qry2[i]){
			//cout << "CLOSE " << q.ff << " " << q.ss << endl;
			tree.update(0, q.ff, q.ss);
		}
	}
	cout << tree.t[1] << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 33620
c = []
for i in range(3):
	c.append(list(map(int,input().split())))

d = []
for i in range(3):
	d.append([c[i][0]-c[i][1],c[i][1]-c[i][2]])
if d[0]==d[1]==d[2]:
	print("Yes")
else:
	print("No")



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

typedef pair<int, int> P;
const int INF = 1000000000;

int M, N;
vector<int> t;

bool input() {
  cin >> M >> N;
  if (!M && !N) {
    return false;
  }
  t.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> t[i];
  }
  return true;
}

void solve() {
  int time = 0;
  vector<int> answer;
  queue<int> tyusha_machi;
  vector<P> park_id;
  vector<P> park_time;
  park_id.resize(M);
  park_time.resize(M);
  for (int i = 0; i < M; ++i) {
    park_id[i].first = park_id[i].second = -1;
    park_time[i].first = park_time[i].second = -1;
  }

  while (answer.size() < N) {
    if (time % 10 == 0 && time / 10 < N) {
      tyusha_machi.push(time / 10);
    }

    // shukko
    for (int i = 0; i < M; ++i) {
      if (park_id[i].first != -1 && park_time[i].first <= time) {
        answer.push_back(park_id[i].first);
        park_id[i].first = -1;
        park_time[i].first = -1;
      }
      if (park_id[i].first == -1 && park_id[i].second != -1 && park_time[i].second <= time) {
        answer.push_back(park_id[i].second);
        park_id[i].second = -1;
        park_time[i].second = -1;
      }
    }

    // tyusha (try second floor)
    while (!tyusha_machi.empty()) {
      int space_id = -1;
      for (int i = 0; i < M; ++i) {
        if (park_id[i].first == -1 && park_id[i].second == -1) {
          space_id = i;
          break;
        }
      }
      if (space_id == -1) {
        break;
      }
      int car_id = tyusha_machi.front();
      tyusha_machi.pop();
      park_id[space_id].second = car_id;
      park_time[space_id].second = time + t[car_id];
    }

    // tyusha (try first floor)
    while (!tyusha_machi.empty()) {
      int space_id = -1;
      bool b = false;
      int tt = time + t[tyusha_machi.front()];
      for (int i = 0; i < M; ++i) {
        if (park_id[i].first != -1) {
          continue;
        }
        if (tt <= park_time[i].second) {
          b = true;
          break;
        }
      }
      if (b) {
        int min_t = INF;
        for (int i = 0; i < M; ++i) {
          if (park_id[i].first != -1) {
            continue;
          }
          if (tt <= park_time[i].second) {
            if (min_t > park_time[i].second) {
              min_t = park_time[i].second;
              space_id = i;
            }
          }
        }
      } else {
        int max_t = -1;
        for (int i = 0; i < M; ++i) {
          if (park_id[i].first != -1) {
            continue;
          }
          if (max_t < park_time[i].second) {
            max_t = park_time[i].second;
            space_id = i;
          }
        }
      }
      if (space_id == -1) {
        break;
      }
      int car_id = tyusha_machi.front();
      tyusha_machi.pop();
      park_id[space_id].first = car_id;
      park_time[space_id].first = time + t[car_id];
    }
    
    ++time;
  }

  for (int i = 0; i < N; ++i) {
    if (i) cout << " ";
    cout << answer[i] + 1;
  }
  cout << endl;
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> a(N);
    readvec(a);

    SORT(a);

    int A = 0, B = 0;
    REP(i, N){
        if(i % 2 == 0){
            A += a[N - i - 1];
        }else{
            B += a[N - i - 1];
        }
    }

    cout << A - B;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static String Y = "Yes";
    public static String N = "No";
    public static long MOD = (long) (Math.pow(10, 9) + 7);
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        out(ni() + ni() >= ni() ? Y : N);

    }

    /*
     * 以下メソッド集
     */

    static int ketasuu(int n) {

        String str = "" + n;
        return str.length();
    }

    static int abcount(String str) {

        int count = 0;
        int len = str.length();
        for (int i = 0; i < len - 1; i++) {
            if ("AB".equals(str.substring(i, i + "AB".length()))) {
                count++;
            }
        }
        return count;
    }

    static int ni() {

        return sc.nextInt();
    }

    static long nl() {

        return sc.nextLong();
    }

    static double nd() {

        return sc.nextDouble();
    }

    static String n() {

        return sc.next();
    }

    static char[] nc() {

        return sc.next().toCharArray();
    }

    static int kaijo(int n) {

        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * kaijo(n - 1);
        }
    }

    static int fib(int n) {

        return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
    }

    static long lcm(long m, long n) {

        return m * n / gcd(m, n);
    }

    static int lcm(int m, int n) {

        return m * n / gcd(m, n);
    }

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

    static void out(char info) {

        System.out.println(info);
    }

    static void out(Object obj) {

        System.out.println(obj.toString());
    }

    static void outn(String info) {

        System.out.print(info);
    }

    static void outn(int info) {

        System.out.print(info);
    }

    static void outn(double info) {

        System.out.print(info);
    }

    static void outn(long info) {

        System.out.print(info);
    }

    static void outn(char info) {

        System.out.print(info);
    }

    static double max(double d, double e) {

        return Math.max(d, e);
    }

    static long max(long a, long b) {

        return Math.max(a, b);
    }

    static double min(double d, double e) {

        return Math.min(d, e);
    }

    static long min(long a, long b) {

        return Math.min(a, b);
    }
}


class XY {

    int h;
    int c;

    XY(int h, int c) {
        this.h = h;
        this.c = c;
    }
}


Measured memory_bytes: 35828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int M;
    String[] A;
    String[] B;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.M = sc.nextInt();
        A = new String[N];
        B = new String[M];
        for (int i=0; i<N; i++) {
        	A[i] = sc.next();
        }
        for (int i=0; i<M; i++) {
        	B[i] = sc.next();
        }
    }
    
    //解答処理
    private String solve() {
        String answer = "No";
        boolean judge = false;
        
        for (int i=0; i<N-M+1; i++) {
        	for (int j=0; j<N-M+1; j++) {
              int count = 0;
        		for (int k=0; k<M; k++) {
        			String tmp = A[k+i].substring(j, j+M);
        			if (B[k].equals(tmp)) {
        				count++;
        			} else {
        				break;
        			}
        		}
        		if (count == M) {
        			judge = true;
        			break;
        		}
        	}
        }
        
        if (judge) {
        	answer = "Yes";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35824
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int NMAX =200005;

int p[NMAX];
int sz[NMAX];
int m[NMAX];
int pos[NMAX];

int par(int i)
{
    if(p[i]==i)
        return i;
    else return p[i] = par( p[i] );
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>m[i];
    for(int i=1;i<=n;i++){
        p[i] = i;
        sz[i] = 1;
    }
    for(int i=1;i<=n;i++){
        pos[ m[i] ] = i;
    }
    unsigned long long ans = 0;
    for(int i=n;i>=1;i--){
        int post = pos[i];
        if( m[ post+1 ]>i && m[ post-1 ] > i ){
            int a1 = par( post+1 );
            int a2 = par( post-1 );
            ans+=( (long long )sz[a1]+1LL )*( (long long )sz[a2]+1LL )*i;
            p[a2] = a1;
            sz[a1]+=sz[a2];
            p[post] = a1;
            sz[a1]++;
        }
        else if( m[ post+1 ]>i ){
            int a1 = par(post+1);
            ans+=((long long )sz[ a1 ]+1LL)*i;
            p[post] = a1;
            sz[a1]++;
        }
        else if( m[ post-1 ]>i ){
            int a1 = par(post-1);
            ans+=((long long )sz[ a1 ]+1LL)*i;
            p[post] = a1;
            sz[a1]++;
        }
        else{
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

struct SCC      //StronglyConnectedComponents
{
    int n;
    int k;
    vector<vector<int>> g, rg;
    vector<bool> used;
    vector<int> cmp;
    vector<int> vs;
    
    void add_edge(int from, int to){
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    
    SCC(){}
    
    SCC(int n) : n(n){
        g.resize(n);
        rg.resize(n);
        used.resize(n);
        cmp.resize(n);
        vs.resize(n);
    }
    
    void dfs(int u, int &l){
        used[u] = true;
        for(int v : g[u]){
            if(!used[v]) dfs(v, l);
        }
        vs[l] = u;
        l++;
    }
    
    void rdfs(int u, int k){
        used[u] = true;
        cmp[u] = k;
        for(int v : rg[u]){
            if(!used[v]) rdfs(v, k);
        }
    }
    
    int decomposition(){
        int l = 0;
        for(int i = 0; i < n; i++){
            if(!used[i]) dfs(i, l);
        }
        fill(used.begin(), used.end(), false);
        k = 0;
        for(int i = n - 1; i >= 0; i--){
            if(!used[vs[i]]){
                rdfs(vs[i], k);
                k++;
            }
        }
        return k;
    }
};

struct TwoSAT
{
    int n;
    SCC g;
    vector<bool> f;
    
    TwoSAT(int n) : n(n){
        g.n = n * 2;
        g.g.resize(n * 2);
        g.rg.resize(n * 2);
        g.used.resize(n * 2);
        g.cmp.resize(n * 2);
        g.vs.resize(n * 2);
        f.resize(n);
    }
    
    void add_edge(int a, bool fa, int b, bool fb){
        g.add_edge(a + int(!fa) * n, b + int(fb) * n);
        g.add_edge(b + int(!fb) * n, a + int(fa) * n);
    }
    
    bool judge(){
        g.decomposition();
        for(int i = 0; i < n; i++){
            if(g.cmp[i] == g.cmp[i + n]) return false;
            if(g.cmp[i] > g.cmp[i + n]) f[i] = false;
            else f[i] = true;
        }
        return true;
    }
};

int main()
{
    int n, d;
    cin >> n >> d;
    int x[1005], y[1005];   // x : false, y : true
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    TwoSAT sat(n);
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(abs(x[i] - x[j]) < d) sat.add_edge(i, true, j, true);
            if(abs(x[i] - y[j]) < d) sat.add_edge(i, true, j, false);
            if(abs(y[i] - x[j]) < d) sat.add_edge(i, false, j, true);
            if(abs(y[i] - y[j]) < d) sat.add_edge(i, false, j, false);
        }
    }
    if(!sat.judge()){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for(int i = 0; i < n; i++){
        if(!sat.f[i]) cout << x[i] << endl;
        else cout << y[i] << endl;
    }
}


Measured memory_bytes: 3856
n,x,m=map(int, input().split())
a=x
ans=a
flg=[0]*m
flg[a]=1
l=[a]
lp=-1

for i in range(1,n):
    tmp=(a*a)%m
    a=tmp
    if flg[a]==1:
        lp = l.index(a)
        break
    else:    
        ans+=tmp
        l.append(a)
        flg[a]=1

if lp != -1:
    l2 = l[lp:]
    tmp = sum(l2)
    b=(n-len(l))//len(l2)
    c=n-len(l)-b*len(l2)
    ans=ans+(b*tmp)+sum(l2[:c])

print(ans)

Measured memory_bytes: 12172
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
ll f[40];
int main()
{
	int a, b, c;cin >> a >> b >> c;
	printf("%d %d %d\n", c, a, b);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	ll x, y;
	cin >> x >> y;

	ll count = 0;

	// 正 * 正 
	if (x >= 0 && y >= 0) {
		if (x > y && y == 0) {
			count += 1;
		}	else if (x > y) {
			count += 2;
		}
	} else if (x < 0 && y < 0) { 
		if (x > y) count += 2;
	}else if (x >= 0 && y < 0){
		count += 1;
	} else if (x < 0 && y > 0) {
		count += 1;
	}
	count += abs(abs(y) - abs(x));

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


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    string s, t;
    cin >> s >> t;
    int n = s.size();

    vector<vi> jump(n, vi(26, -1));
    jump[n - 1][s[n - 1] - 'a'] = n - 1;
    for (int i = n - 2; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            jump[i][j] = jump[i + 1][j];
        }
        jump[i][s[i] - 'a'] = i;
    }

    int m = t.size();
    int p = 0;
    int k = 0;
    for (int i = 0; i < m; ++i) {
        int c = t[i] - 'a';
        if (jump[p][c] == -1) {
            if (jump[0][c] == -1) {
                cout << "-1\n";
                return 0;
            }

            ++k;
            p = jump[0][c] + 1;
        } else {
            p = jump[p][c] + 1;
        }

        if (p > n - 1) {
            p = 0;
            ++k;
        }
    }

    ll ans = 1LL * n * k + p;

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


Measured memory_bytes: 13776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;

  double a, b, h,m;
  cin >> a >> b >> h >> m;
  double mD = m/60        * M_PI * 2;
  double hD = (h+m/60)/12 * M_PI * 2;

  // cout << "mD:" << mD / (2*M_PI) << endl;
  // cout << "hD:" << hD / (2*M_PI) << endl;

  double deg = abs(hD - mD);
  // if (deg > M_PI) {
  //   deg -= M_PI;
  // }
  // cout << "deg/(2PI):" << deg / (2*M_PI) << endl;
  // cout << "deg/(PI):" << deg / (M_PI) << endl;
  // cout << "deg:" << deg << endl;
  // // cout << "2PI/6:" << (2*M_PI) / 6.0  << endl;

  // // Here, deg is smaller degree.

  // cout << "cos(60/180): " << cos(60/180 * M_PI) << endl;
  // cout << "cos(deg): " << cos(deg) << endl;
  // cout << "a: " << a << endl;
  // cout << "b: " << b << endl;

  double c2 = (double)(a*a) + (double)(b*b) - (double)2*a*b* cos(deg);
  // cout << "c2:" << c2 << endl;
  double ans = sqrt(c2);
  cout << ans << endl;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
long long prime_wa(long long n){
    long long res=n+100;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res=min(res,i+(n/i));
        }
    }
    return res;
}

int main(){
    long long N;cin>>N;
    cout<<prime_wa(N)-2<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();

		int AplusB = A + B;
		int AminusB = A - B;
		int AmultiB = A * B;

		int sum = Math.max(AplusB, AminusB);
		sum = Math.max(sum, AmultiB);

		System.out.println(sum);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M;
    cin >> N >> M;
    int s[N], c[N];
    for (int i = 0; i < M; i++) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    int d[N]{};
    fill(d, d + N, -1);
    for (int i = 0; i < M; i++) {
        if (N != 1 && s[i] == 0 && c[i] == 0) {
            cout << "-1\n";
            return 0;
        }
        if (d[s[i]] == -1) {
            d[s[i]] = c[i];
        } else if (d[s[i]] != c[i]) {
            cout << "-1\n";
            return 0;
        }
    }
    if (N == 1 && d[0] == -1) {
        cout << "0\n";
        return 0;
    }
    if (d[0] == -1) d[0] = 1;
    for (int i = 1; i < N; i++) {
        if (d[i] == -1) d[i] = 0;
    }
    for (int i : d) {
        cout << i;
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int s_length = s.length();
		int i = 0;
		int str = 0;
		for(i = 1; i < s_length; i++) {
			if((s_length - i) % 2 == 0) {
				if(s.substring(0, (s_length - i) / 2).equals
						(s.substring(((s_length - i) / 2), s_length - i))) {
					str = s_length - i;
					break;
				}
			}
		}
		System.out.println(str);
	}
}


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

int main() {
    string s;
    cin >> s;
    set<char> st(s.begin(), s.end());
    if (st.size() == 2 && count(s.begin(), s.end(), s.at(0)) == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
    int n, m, p, x;
    cin >> n;
    int t[n+2] = {};
    for(int i = 1; i <= n; i++) cin >> t[i];
    cin >> m;
    while(m--)
    {
        int sum = 0;
        cin >> p >> x;
        for(int i = 1; i <= n; i++){
            if(i == p) sum += x;
            else sum += t[i];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
from itertools import combinations

h,w,k = map(int,input().split())
cli = [list(input()) for _ in range(h)]

black = 0
for wli in cli:
    black += wli.count('#')


answer = 0
for i in range(h+w+1):
    combis = list(combinations(range(1,h+w+1),i))

    # 1パターン
    for combi in combis:
        tmp_black = black
        red_row = []
        red_column = []
        for red in combi:
            if 1 <= red <= h:
                red_row.append(red-1)
            elif h+1 <= red <= h+w:
                red_column.append(red-h-1)

        for j, wli in enumerate(cli):
            if j in red_row:
                tmp_black -= wli.count('#')
                continue

            for r in red_column:
                if wli[r] == '#':
                    tmp_black -= 1
            
        if tmp_black == k:
            answer += 1

print(answer)

Measured memory_bytes: 9300
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while (cin.hasNextInt()) {
			int n = cin.nextInt(), l = cin.nextInt();
			if (n == 0) break;
			int dir[] = new int[n];
			int pos[] = new int[n];
			boolean in[] = new boolean[n];
			//System.out.println("ffff");
			for (int i = 0; i < n; ++ i) {
				in[i] = true;
				String s = cin.next();
				if (s.charAt(0) == 'L') dir[i] = -1;
				else dir[i] = 1;
				pos[i] = cin.nextInt();
			}
			int ltime = -1, rtime = -1, lid = -1, rid = -1;
			for (int t = 1, rest = n; rest > 0; ++ t) {
				for (int i = 0; i < n; ++ i) {
					pos[i] += dir[i];
				}
				for (int i = 0; i < n; ++ i) {
					if (!in[i]) continue;
					if (pos[i] == 0) {
						in[i] = false; -- rest;
						ltime = t; lid = i + 1;
					}
					if (pos[i] == l) {
						in[i] = false; -- rest;
						rtime = t; rid = i + 1;
					}
				}
				for (int i = 0; i < n; ++ i) {
					for (int j = 0; j < n; ++ j) {
						if (i != j && in[i] && in[j] && pos[i] == pos[j]) {
							dir[i] = -dir[i];
						}
					}
				}
			}
			if (ltime >= rtime) System.out.println(ltime + " " + lid);
			else System.out.println(rtime + " " + rid);
		}
	}
}

Measured memory_bytes: 25228
# coding: utf-8
S = input()
even= list(set(S[0::2]))
odd = list(set(S[1::2]))
E = ["R", "U", "D"]
O = ["L", "U", "D"]
cnt = 0
for i in range(len(even)):
    if even[i] in E:
        cnt += 1
if cnt == len(even):
    flag_e = True
else:
    flag_e = False
cnt = 0
for i in range(len(odd)):
    if odd[i] in O:
        cnt += 1
if cnt == len(odd):
    flag_o = True
else:
    flag_o = False
print("Yes" if flag_o and flag_e else "No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>

using namespace std;
#include<string.h>
int w,h,sx,sy;
int dx[4]={1,0,-1,0},dy[4] = {0,1,0,-1};
char fruit[1000][1000];
//int flag[1000][1000];
int num;

void dfs(int x,int y,char c){
    fruit[x][y]='.';
    for(int i = 0; i < 4;i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx<h&&nx>=0&&ny<w&&ny>=0&&fruit[nx][ny]==c)
                dfs(nx,ny,fruit[nx][ny]);
     }
  //   return ;
}

void solve(){
    while(cin>>h>>w&&w&&h){
        num = 0;
     //2   memset(flag,0,sizeof(flag));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w;j++)
                cin>>fruit[i][j];
                //scanf("%c",&fruit[i][j]);
        }//for
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w;j++)
            {
                if(fruit[i][j]!='.'){
                dfs(i,j,fruit[i][j]);
                  num++;
    }

        }
        }
        printf("%d\n",num);
        }
  //  return ;

}int main(void){
    solve();
    return 0 ;
}



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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;
int a[100010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] - 1 == i){
            swap(a[i], a[i + 1]);
            ans++;
        }
    }
    if(a[n - 1] == n) ans++;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll A, B; scanf("%lld %lld", &A, &B);
  int ans = 0;
  while (A <= B) {
    ++ans;
    A *= 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int d, e;
        while(scanf("%d%d", &d, &e) && d){
                double ans=INF;
                for(int i=0; i<=d-i; ++i){
                        chmin(ans, abs(e-sqrt(i*i+(d-i)*(d-i))));
                }
                printf("%.20lf\n", ans);
        }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{   
    int a[3]={0};
    string s;cin>>s;
    REP(i,s.size())a[s[i]-'a']++;
    (max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]}))<=1?s="YES":s="NO";
    cout<<s<<endl;
}

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


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	if abs(a-b) > 1e18 {
		fmt.Println("Unfair")
		return
	}

	if k%2 == 0 {
		fmt.Println(a - b)
	} else {
		fmt.Println(b - a)
	}
}

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


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt() * 2 + 1;
    int cnt = 0;
    while (A > 0) {
      cnt++;
      A -= B;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, K, ans;
std::vector<int>A(212345), cou(212345);
std::set<int>list;

int main()
{
	in >> N >> K;
	rep(i, N) { in >> A[i]; }

	rep(i, N) { list.insert(A[i]); }
	rep(i, N) { cou[A[i]]++; }
	if (list.size() > K)
	{
		int tmp = 0;
		std::vector<std::pair<int, int>>res;
		rep(i, N) { res.push_back(std::make_pair(cou[i + 1], i + 1)); }
		std::sort(res.begin(), res.end());
		while (res[tmp].first == 0) { ++tmp; }
		rep(i, list.size() - K)
		{
			ans += res[i + tmp].first;
		}
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s.compare("Sunny")==0)
  {
    cout<<"Cloudy"<<endl;
  }
  else if(s.compare("Cloudy")==0)
  {
    cout<<"Rainy"<<endl;
  }
  if(s.compare("Rainy")==0)
  {
    cout<<"Sunny"<<endl;
  }
  return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long a, b, n;
    cin >> a >> b >> n;


    n = min(b - 1, n);

    long long res = a * n / b;
    cout << res << '\n';

    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  int counter = 36;
  
  for (int i = 0; i < N; i++) {
    
    int A; 
    cin >> A;
    
    int x = 0;
    
    while (A % 2 == 0) {
      x++;
      A /= 2;
    }
    
    if (x < counter) counter = x;
  
  }
  
  cout << counter << endl;
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int K = sc.nextInt();
        int[] mons = new int[M];
        for(int i=0; i<M; i++){
            mons[i] = sc.nextInt();
        }
        long ans = 0;
        Arrays.sort(mons);
        for(int j=0; j<(M-K); j++){
            ans += mons[j];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 65180
n = gets.chomp.split(" ").map(&:to_i)[0]

candies = []

2.times do
    line = gets.chomp.split(" ").map(&:to_i)
    candies.push(line)
end

max = 0

sum1 = 0

n.times do |i|
    total = 0
    for line1 in 0..i
        total += candies[0][line1]
    end
    for line2 in i..(n - 1)
        total += candies[1][line2]
    end
    max = total if total > max
end

puts max


Measured memory_bytes: 1788