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

int main() {
	int N, A, B, C, D;
	string S;

	cin >> N >> A >> B >> C >> D >> S;

	string ans = "No";
	int i = B - 1;
	int flag = 0;
	while( i < D - 1 ) {
		if( S[i + 2] == '.' && i + 1 < D - 1 ) {
			i += 2;
		}
		else if( S[i + 1] == '.' ) {
			i++;
		}
		else {
			flag = 1;
			break;
		}
	}
	if( flag || i != D - 1 ) {
		cout << ans << endl;
		return 0;
	}
	i = A - 1;
	flag = 0;
	while( i < C - 1 ) {
		if( S[i + 2] == '.' && i + 1 < C - 1 ) {
			i += 2;
		}
		else if( S[i + 1] == '.' ) {
			i++;
		}
		else {
			flag = 1;
			break;
		}
	}
	if( flag || i != C - 1 ) {
		cout << ans << endl;
		return 0;
	}

	if( C > D ) {
		i = B - 1;
		flag = 0;
		if( i > 0 && S[i - 1] == '.' && S[i + 1] == '.' ) {
			flag = 2;
		}
		else {
			while( i < D - 1 ) {
				if( S[i] == '.' && S[i + 1] == '.'  && i + 2 < S.size() && S[i + 2] == '.' ||
					S[i + 1] == '.' && i + 2 < S.size() && S[i + 2] == '.'  && i + 3 < S.size() && S[i + 3] == '.' ) {
					flag = 2;
					break;
				}
				if( S[i + 2] == '.' && i + 1 < D - 1 ) {
					i += 2;
				}
				else if( S[i + 1] == '.' ) {
					i++;
				}
				else {
					flag = 1;
					break;
				}
			}
		}
		if( flag != 2 ) {
			cout << ans << endl;
			return 0;
		}
	}
	ans = "Yes";
	cout << ans << endl;

	return 0;
}

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

#define ll long long 
ll a, b, c;

int main()
{
	while (scanf("%lld%lld%lld", &a, &b, &c) != EOF)
	{
		if (c <= a + b + 1) printf("%lld\n", b + c);
		else printf("%lld\n", a + b + b + 1);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, K;
int R, S, P;
string T;

ll dp[100005][3];

ll solve(const string& s){
  rep(i,s.size()) rep(j,3) dp[i][j] = 0;

  if(s[0]=='s') dp[0][0] = R;
  if(s[0]=='p') dp[0][1] = S;
  if(s[0]=='r') dp[0][2] = P;

  REP(i,1,s.size()){
    if(s[i]=='s'){
      dp[i][0] = max(dp[i-1][1] + R, dp[i-1][2] + R);
      dp[i][1] = max(dp[i-1][0], dp[i-1][2]);
      dp[i][2] = max(dp[i-1][0], dp[i-1][1]);
    }
    if(s[i]=='p'){
      dp[i][0] = max(dp[i-1][1], dp[i-1][2]);
      dp[i][1] = max(dp[i-1][0] + S, dp[i-1][2] + S);
      dp[i][2] = max(dp[i-1][0], dp[i-1][1]);
    }
    if(s[i]=='r'){
      dp[i][0] = max(dp[i-1][1], dp[i-1][2]);
      dp[i][1] = max(dp[i-1][0], dp[i-1][2]);
      dp[i][2] = max(dp[i-1][0] + P, dp[i-1][1] + P);
    }
  }


  return max(dp[s.size()-1][0], max(dp[s.size()-1][1], dp[s.size()-1][2]));
}

int main(){
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  ll ret = 0;
  rep(i,K){
    string s;
    int j = i;
    while(j<N){
      s += T[j];
      j+=K;
    }
    ret += solve(s);
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll x, y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << endl;
    }else{
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
    int i, j, k, n, ans=0, po=0, x[5];
    scanf("%d %d", &n, &k);
    int p[n];
    for(i=0; i<n; i++) scanf("%d", &p[i]);
    qsort(p, sizeof(p) / sizeof(int), sizeof(int), asc); 
    for(i=0; i<k; i++) ans += p[i];
    printf("%d", ans);
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,z;
int main()
{
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++)
	{
		cin>>d;
		if(d<b||d>=c)z++;
	}
	cout<<z<<endl;
	return 0;
}

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


def solve(S: str):
    if S == "ABC":
        print("ARC")
    else:
        print("ABC")
    return


# Generated by 1.1.7.1 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()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9020
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define loop(i,n) for(ll i=0;i<n;i++)
#define cloop(i,m,n) for(ll i=m;i<n;i++)
#define Matrix vector<vector<ll>>
#define Point pair<ll,ll>
#define Coordinates vector<Point>
ll global =0;
using namespace std;

ll gcd(ll a, ll b){
    /*
    return gcd of a,b
    */
    if(b>a)return gcd(b,a);
    if(a%b)return gcd(b,a%b);
    return b;
}
void init_matrix( Matrix& graph, ll num){
    /*
    Initialize Matrix elements with num rows 
    */
    loop(i,num) graph.push_back(vector<ll>(1,LLONG_MAX));
}
auto max_mp(map<ll,ll>&mp){
    /*
    return max element of map in form pair<key,val>
    */
    auto max_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second > max_e->second){
            max_e = it;
        }
        it++;
    }
    return *max_e;
}

auto min_mp(map<ll,ll>&mp){
    /*
    return min element of map in form pair<key,val>
    */
    auto min_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second < min_e->second){
            min_e = it;
        }
        it++;
    }
    return *min_e;
}
vector<ll> generate_prime(ll n) { 
    /*
    generate all primes number less than equal to n
    */
    vector<bool> prime(n+1,true);
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    vector<ll> pr;
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          pr.push_back(p);
    return pr;
}



int main(){
    ll n, x,y;
    cin >> n >> x >>y;
    if(x > y){
        ll t = x;
        x = y;
        y = x;
    }
    ll dist[n];
    memset(dist,0,sizeof(dist));
    cloop(i,1,n+1){
        cloop(j,i+1,n+1){
            dist[min(j-i,abs(j-y)+1+abs(x-i))]++;
        }
    }
    cloop(i,1,n){
        cout << dist[i] << endl;
    }

}
	
/*
input:

*/

/*
output:

*/	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <string>
#define p pair<int, int>
using namespace std;

int main(){

  stack<int> s1;
  stack<p> s2;
  string m;
  int sum = 0, a;

  cin >> m;

  for(int i = 0; i < m.size(); i++){
    if(m[i] == '\\'){
      s1.push(i);
    }else if(m[i] == '/' && s1.size() > 0){
      int j = s1.top(); s1.pop();
      sum += i - j;
      a = i - j;
      while(s2.size() > 0 && s2.top().first > j){
        a += s2.top().second; s2.pop();
      }
      s2.push(p(j, a));
    }
  }
  vector<int> ans;
  while(!s2.empty()){
    ans.push_back(s2.top().second);
    s2.pop();
  }
  cout << sum << endl;
  cout << ans.size();
  for(int i = ans.size()-1; i >= 0; i--){
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}


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

int main(){

    int n;

    cin >> n;

    int p[n],t[n],count=0,tcount;

    for(int i=0;i<n;i++){
      cin >> p[i];
      t[i] = p[i];
      //count += p[i];
    }

    if(p[0] > p[1]){
      count += p[0] + p[1];
      p[1] = 0;
    }
    else{
      count += p[0]*2;
      p[1] -= p[0];
    }

    for(int i=1;i<n-1;i++){
      count += p[i] * 2;
      if(p[i] > p[i+1] ){
        p[i+1] = 0;
      }
      else{
        p[i+1] -= p[i];
      }
    }

    if(p[n-1] != 0){
      count += p[n-1];
    }




    tcount = t[0];

    for(int i=1;i<n-1;i++){
      tcount += t[i] * 2;
      if(t[i] > t[i+1] ){
        t[i+1] = 0;
      }
      else{
        t[i+1] -= t[i];
      }
    }

    if(t[n-1] != 0){
      tcount += t[n-1];
    }



    /*int maxp = max(p[0],p[1]);

    if(maxp == p[0]){
      count += p[0] + p[1];
      p[0] = p[1] = 0;
    }
    else{
      count += p[0] * 2;
      p[1] -= p[0];
    }



    maxp = max(p[n-2],p[n-1]);

    if(maxp == p[n-2]){
      count += p[n-2] * 2;
    }
    else{
      count += p[n-2] + p[n-1];
    }*/

    cout << min(count,tcount) << endl;

    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
vector<int> g[100005];
LL dp[100005][2];
void dfs(int u, int p){
    dp[u][0] = 1;
    dp[u][1] = 1;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p) continue;
        dfs(v, u);
        dp[u][0] = (dp[u][0]*(dp[v][0] + dp[v][1])%mod)%mod;
        dp[u][1] = (dp[u][1]*dp[v][0])%mod;
    }
}
int main(){
    int n, a, b;
    scanf("%d", &n);
    for(int i=2;i<=n;i++){
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 0);
    printf("%lld\n", (dp[1][0] + dp[1][1])%mod);
}

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


int main(){
  int n;
  cin>>n;
  int a;
  bool f=true;
  rep(i,n){
    cin>>a;
    if(a%2==0){
      if(a%3!=0&&a%5!=0)f=false;
    }
  }
  if(f)cout<<"APPROVED";
  else cout<<"DENIED";
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

	ll n; cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	map<ll,ll> mp;
	rep(i,n) mp[a[i]]++;

	ll b = 0;
	for (auto m : mp) {
	  b += m.second*(m.second-1)/2;
	}
	vector<ll> c(n);
	rep(i, n) {
		c[i] = mp[a[i]]-1;
	}
	rep(i, n) {
		cout << b - c[i] << endl;
	}
	
	
} 


Measured memory_bytes: 12672
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

const int MAX_N = 1e5 + 1;
int N, M;
int par[MAX_N];
int UFTrank[MAX_N];

void init(int n) {
   for (int i = 0; i < n; i++) {
      par[i] = i;
      UFTrank[i] = 0;
   }
}

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

void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;

   if (UFTrank[x] < UFTrank[y]) {
      par[x] = y;
   } else {
      par[y] = x;
      if (UFTrank[x] == UFTrank[y]) UFTrank[x]++;
   }
}

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

struct edge { int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
   return e1.cost < e2.cost;
}

edge es[MAX_N * 2];

int main() {
   cin >> N >> M;
   int tmp1, tmp2;
   for (int i = 0; i < M; i++) {
      cin >> tmp1 >> tmp2;
      tmp1--;
      tmp2--;
      es[i].u = tmp1;
      es[i].v = tmp2;
      es[i].cost = 1;
   }
   int V = N;
   int ans = 0;
   for (int i = 0; i < M; i++) {
      init(V);
      for (int j = 0; j < M; j++) {
         if (j == i) continue;
         edge e = es[j];
         if (!same(e.u, e.v)) {
            unite(e.u, e.v);
         }
      }
      edge e = es[i];
      if (!same(e.u, e.v)) ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int border;
	int n, l;
	int v, w, h;

	while (scanf("%d%d%d", &v, &w, &h), v){
		
		border = fmin(hypot(v,w), hypot(v,h));
		border = fmin(hypot(w,h), border);

		scanf("%d", &n);
		while (n--) {
			scanf("%d", &l);
			puts(l * 2 > border ? "OK" : "NA");
		}
	}
	return (0);
}

Measured memory_bytes: 600
#ifdef _WIN32
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#define DEBUGBREAK() ::DebugBreak()
#else
#define DEBUGBREAK() static_cast<void>(0)
#endif

#include <iostream>
#include <sstream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <queue>
#include <array>
#include <functional>
#include <stack>
#include <bitset>
#include <random>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int dx4[4] = { 0, -1, 1, 0 };
const int dy4[4] = { -1, 0, 0, 1 };
const int dx5[5] = { 0, -1, 0, 1, 0 };
const int dy5[5] = { -1, 0, 0, 0, 1 };
const int dx8[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy8[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dx9[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int dy9[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

#define REP(i, K) for (int i = 0; i < K; ++i)
#define REPYX() for (int y = 0; y < H; ++y) for (int x = 0; x < W; ++x)
#define REPX() REP(x, W)
#define REPY() REP(y, H)
#define INSIDE(x_, y_) (0 <= (x_) && 0 <= (y_) && (x_) < W && (y_) < H)
#define INSIDE_MARGIN(x_, y_, m_) ((m_) <= (x_) && (m_) <= (y_) && (x_) < W - (m_) && (y_) < H - (m_))

int get_assert_level() {
    const char* s = getenv("ASSERT_LEVEL");
    if (s) { return atoi(s); }
    return 0;
}
static int g_assert_level = get_assert_level();

#define LV_1() if (g_assert_level >= 1)
#define LV_2() if (g_assert_level >= 2)
#define LV_3() if (g_assert_level >= 3)
#define ASSERT_1(expr) do { const bool b = bool(expr); if (g_assert_level >= 1 && !b) { std::cerr << "[ASSERT 1] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_2(expr) do { const bool b = bool(expr); if (g_assert_level >= 2 && !b) { std::cerr << "[ASSERT 2] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_3(expr) do { const bool b = bool(expr); if (g_assert_level >= 3 && !b) { std::cerr << "[ASSERT 3] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)

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

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

    return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>

int main()
{
    int n,ara[100000],i,count=0,l=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&ara[i]);
    }
    for(i=1;i<n;i++){
        if(ara[i]<=ara[i-1]) count++;
        else count=0;
        if(count>l) l=count;
    }
    printf("%d\n",l);
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,q; string s; cin>>n>>q>>s;
	vector<int>v(n,0);
	for(int i=1;i<n;++i){
		v.at(i)+=v.at(i-1);
		if(s.at(i-1)=='A'&&s.at(i)=='C')++v.at(i);
	}
	for(int i=0;i<q;++i){
		int l,r; cin>>l>>r;
		cout<<v.at(r-1)-v.at(l-1)<<"\n"s;
	}
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	int n; scanf("%d", &n);
	ll c[55][55];
	for (int i = 0; i <= n; ++ i) {
		for (int j = 0; j <= n; ++ j) {
			c[i][j] = 0;
		}
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j < i; ++ j) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
	int a, b; scanf("%d%d", &a, &b);
	ll v[55];
	for (int i = 0; i < n; ++ i) scanf("%lld", &v[i]);
	sort(v, v + n); reverse(v, v + n);
	ll ans = 0;
	for (int i = 0; i < a; ++ i) ans += v[i];
	printf("%.10Lf\n", (long double) ans / a);
	if (v[0] == v[a - 1]) {
		int lst = 0;
		for (int i = 0; i < n; ++ i) if (v[i] == v[0]) lst = i + 1;
		ll cnt = 0;
		for (int i = a; i <= b; ++ i) cnt += c[lst][i];
		printf("%lld\n", cnt);
	} else {
		int fst = -1, lst = 0;
		for (int i = 0; i < n; ++ i) if (v[i] == v[a - 1]) {
			if (!~fst) fst = i;
			lst = i + 1;
		}
		printf("%lld\n", c[lst - fst][a - fst]);
	}
	return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {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;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e5 + 1;
int n , m;
int a[N];
string s;

main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0 , j = sz(s) - 1 ; i < j ; i++ , j--){
		ans +=	s[i] != s[j];
		s[i] = s[j];
	}	
	ret(ans);
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
int ses=1;
int r=0,c=0,cnt=0,x;
map<int,int>vis;
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    set<int>s;
    f(i,1,n)
    {
        cin>>x;
        if(s.find(x)!=s.end())
        {
            cout<<"0"<<endl;return 0;
        }
        s.insert(x);
        vis[x]=1;
    }
    s.clear();
    f(i,1,m)
    {
        cin>>x;
        if(s.find(x)!=s.end())
        {
            cout<<"0"<<endl;return 0;
        }
        s.insert(x);
        if(vis[x]==0)vis[x]=2;
        else vis[x]=3;
    }
    rf(i,n*m,1)
    {
        if(vis[i]==1)
        {
            ses=gun(ses,c);
            r++;
        }
        else if(vis[i]==2)
        {
            ses=gun(ses,r);
            c++;
        }
        else if(vis[i]==3)
        {
             r++;c++;
        }
        else
        {
            ses=gun(ses,sub(r*c,cnt));
        }
        cnt++;
    }
    cout<<ses<<endl;
    return 0;

}





































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

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

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

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

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }

// 自明なものに対する事前チェック
// first: pre_check で結果がわかったなら true
// second: 無限ループできる(Yes)なら true, first が false なら意味なし
pair<bool, bool> pre_check(ll A, ll B, ll C, ll D) {
    if(A < B || D < B) { return make_pair(true, false); }
    if(A % B > C) { return make_pair(true, false); }
    if(B <= C) { return make_pair(true, true); }
    if(B == D || D % B == 0) { return make_pair(true, true); }
    if(B-1 == C) { return make_pair(true, true); }

    // 初期位置
    ll X = A % B;
    ll Y = (D - B) % B;
    Y = gcd(Y, B);
    // C に一番接近するとき
    ll Z = X + ((C - X) / Y) * Y;
    if(Z + Y < B && Z + Y > C) {
        return make_pair(true, false);
    }
    else {
        return make_pair(true, true);
    }

    return make_pair(false, false);
}

// 愚直な解放で解く
// 無限ループできる(Yes)なら true
bool solve(ll A, ll B, ll C, ll D) {
    //pair<bool, bool> pre_result = pre_check(A, B, C, D);
    //if(pre_result.first) { return pre_result.second; }

    map<ll, bool> exist;
    ll cur = A;
    exist[A] = true;
    for(;;) {
        cur -= B;
        if(cur < 0) { return false; }
        if(cur <= C) { cur += D; }
        if(exist.count(cur) != 0) { break; }
        exist[cur] = true;
    }
    return true;
}

signed main()
{
#if 0
    // ABCD の全組み合わせを与える
    const ll max_abcd = 50;
    for(ll a = 1; a <= max_abcd; ++a) {
        for(ll b = 1; b <= max_abcd; ++b) {
            for(ll c = 1; c <= max_abcd; ++c) {
                for(ll d = 1; d <= max_abcd; ++d) {
                    pair<bool, bool> pre_result = pre_check(a, b, c, d);
                    if(pre_result.first) {
#  if 0
                        continue;
#  else
                        bool ret = solve(a, b, c, d);
                        if(pre_result.second != ret) {
                            DBG("%3lld %3lld %3lld %3lld pre_check: %s solve: %s\n",
                                    a, b, c, d, pre_result.second ? "Yes" : "No",
                                    ret ? "Yes" : "No");
                            assert(false);
                        }
#  endif
                    }
                    /*
                    if(!solve(a, b, c, d)) {
                        DBG("%3lld %3lld %3lld %3lld\n", a, b, c, d);
                    }
                    */
                }
            }
        }
    }
#else
    ll T;
    cin >> T;
    REP(t, T) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        pair<bool, bool> pre_result = pre_check(A, B, C, D);
        if(pre_result.second) { printf("Yes\n"); }
        else { printf("No\n"); }
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N;
int cnt, ans = INF, id, diff;
string S;

// int count_diff(string s1, string s2){

// }

int assign_leader(int id){
    int tmp = 0;

    rep(i,N){
        if(i < id){
            if(S[i]!='E')
                tmp++;
        } else if (i > id){
            if(S[i]!='W')
                tmp++;
        }
    }

    return tmp;
}

void solve(){
    cnt = assign_leader(0);
    ans = min(cnt, ans);

    for(int id = 0; id < N-1; id++){
        diff = (int)(S[id]!='E') - (int)(S[id+1]!='W');
        cnt += diff;
        ans = min(cnt, ans);
    }

    cout << ans << endl;
}

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

    solve();
}


Measured memory_bytes: 900
# ABC169 D

import math


def factorization(n):
    """
    素因数分解した結果を[(要素, 数)]のリストで返す
    """
    arr = []
    temp = n
    for i in range(2, int(math.ceil(n ** 0.5))):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


n = int(input())

if n == 1:
    print(0)
    exit(0)

fact_li = factorization(n)

res = 0
for _, num in fact_li:
    temp_num = 1
    while temp_num <= num:
        res += 1
        num -= temp_num
        temp_num += 1

print(res)


Measured memory_bytes: 63616
n=int(input())
s=input()
x=""
y=""
saidai=0
for i in range(n):
    x=s[:i+1]
    y=s[i+1:]
    #print(x,y)
    x_y_and=set(x)&set(y)
    if len(x_y_and)>saidai:
        saidai=len(x_y_and)
    x=""
    y=""
    x_y_and=""
print(saidai)

Measured memory_bytes: 3064
S = input()
Q = int(input())

prefix = ''
surfix = ''
cnt_reverse = 0

for i in range(Q):
    q = input()
    if q == '1':
        cnt_reverse += 1
    else:
        _, f, c = q.split()
        if (f=='1' and cnt_reverse%2==0):
            prefix = c + prefix
        elif (f=='2' and cnt_reverse%2==1):
            prefix = c + prefix
        elif (f=='1' and cnt_reverse%2==0):
            surfix = surfix + c
        else:
            surfix = surfix + c
if cnt_reverse % 2 == 0:
    S = prefix + S + surfix
else:
    S = surfix[::-1] + S[::-1] + prefix[::-1]
print(S)

Measured memory_bytes: 224616
def white_cells(H, M, h, m):
    return H*M - h*M - m*H + h*m


if __name__ == "__main__":
    HM = list(map(int, input().split()))
    H = HM[0]
    M = HM[1]
    hm = list(map(int, input().split()))
    h = hm[0]
    m = hm[1]

    ret = white_cells(H, M, h, m)
    print(ret)

Measured memory_bytes: 3064
n, m, k = map(int, input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n-r)
    return fact[n] *factinv[r]* factinv[n-r] %p

p = 998244353
N = 2 * 10**5 + 2

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

y = [0,m]
for i in range(n):
    y.append((y[-1]*(m-1))%p)
r = 0
for i in range(k+1):
    r += (y[n-i]*cmb(n-1, i, p))%p
print(r%p)

Measured memory_bytes: 126368
#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


ll ipow(ll b, ll p) {
	if (p == 0) return 1;
	return b * ipow(b, p - 1);
}

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

	ll n; read(n);
	string s;
	ll len = 1;
	--n;
	while (n >= ipow(26, len)) {
		n -= ipow(26, len);
		len++;
	}
	rep(i, 0, len) {
		s += 'a' + n % 26;
		n /= 26;
	}
	reverse(all(s));
	write(s);
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(){
  char *p;
  int c;
  char s[1001];
  scanf("%s",s);
  int a = strrchr(s, 's');
  int b = strrchr(s, '\0');
  if(b-a==1){
    printf("%ses",s);
  }else{
    printf("%ss",s);
  }
  return 0;
}

Measured memory_bytes: 1736
def sum_from_1_to_n(n):
    return n * (n + 1) // 2


def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    answer = 1  # N = Kのとき
    max_num = sum_from_1_to_n(n)
    for i in range(k, n + 1):
        answer += max_num - sum_from_1_to_n(n - i) - sum_from_1_to_n(i - 1) + 1
        answer %= mod
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9188
a, b, c, d = map(int, list(input()))
Lis = ["+", "-"]
for k in range(8):
    bi = list(map(int, bin(k).replace('b', '0')))
    bi.reverse()
    res = a+b if not bi[0] else a-b
    res += c if not bi[1] else -c
    res += d if not bi[2] else -d
    if res == 7:
        print(str(a)+Lis[bi[0]]+str(b)+Lis[bi[1]] +
              str(c)+Lis[bi[2]]+str(d)+"=7")
        break


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int dp[101][10001];
int value[100];
int weight[100];
int NEGA_INF = -10000000;

int main() {
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; ++i) {
        cin >> value[i] >> weight[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = max(
                    dp[i - 1][j],
                    j - weight[i - 1] >= 0 ? dp[i - 1][j - weight[i - 1]] + value[i - 1] : 0);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 7000
#include<stdio.h>
#define N 100000
int main(){
  int i,j=0,a[N],n,tmp,p,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
    for(i=0;i<n;i++){
      if(a[i]<=a[n-1]){
	if(i==n-1){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
	p = j-1;
	q = p+1;
	break;
	}
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
	j++;
      }
    }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i==p)printf(" [");
    if(i==q)printf("] ");
    if(i!=n-1 && i!=p && i!=q)printf(" ");
    else if(i==n-1) printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2156
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    ll x,y;
    scanf("%lld%lld",&x,&y);
    if(abs(x-y)<=1)
    cout<<"Brown"<<endl;
        else
        cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{};
	cin>>n;
	string s;
	cin>>s;
	int l{},r=s.size()-1,ans{};
	while(l<r)
	{
		while(s[l]=='W' &&s[r]=='R' && l<r){
			swap(s[l],s[r]),ans++;
			l++,r--;
		}
		if(s[r]=='W')r--;
		if(s[l]=='R')l++;
	}
	cout<<ans<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3736
import java.util.Scanner;
public class Main {
	
    public static void main(String[] args) {
    	Scanner scan=new Scanner(System.in);
    	int a=scan.nextInt();
    	int b=scan.nextInt();
    	if(a%b==0) {
    		System.out.println(-1);
    	}
    	else {
    		System.out.println(a);
    	}
    }
}

Measured memory_bytes: 22996
import sys, itertools
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
N, K = inpl()
Sushi = []
Neta = set()
ans = 0
for _ in range(N):
    t, d = inpl()
    Sushi.append((d, t))
Sushi.sort(reverse = True)
Db = []
Nd = []
for i in range(K):
    d, t = Sushi[i]
    if t not in Neta:
        Neta.add(t)
        ans += d
    else:
        Db.append(d)
neta = len(Neta)
Db = [0] + list(itertools.accumulate(Db))
Db.reverse()
for i in range(N-K):
    d, t = Sushi[K+i]
    if t not in Neta:
        Neta.add(t)
        Nd.append(d)
Nd = [0] + list(itertools.accumulate(Nd))
print(ans + max([(neta + i)**2 + j + k for i, (j, k) in enumerate(zip(Db, Nd))]))

Measured memory_bytes: 23856
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int a,b,c,d;

  while(1){
    cin>>a>>b>>c>>d;
    if(a+b+c+d==0)break;
    int ans;
    if(b*c<=a)ans=0;
    else if((b*c-a)%d==0)ans=(b*c-a)/d;
    else ans=(b*c-a)/d+1;
    cout<<max(0,ans)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forn1(i, n) for (ll i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second

//#define DEBUG
int main()
{
  //FastIO;
  #ifdef DEBUG
    freopen("input.txt", "r", stdin);
  #endif
  ll n;
  cin >> n;
  ll ans = 1e18;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0){
      ans = min(ans, i - 1 + n / i - 1);
    }
  }
  cout << ans << "\n";
  return 0;
}


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

ll solve() {
    ll X, N, p;
    cin >> X >> N;
    vector<ll> n(102);
    for ( int i = 0; i < N; i++ ) {
        cin >> p;
        n[p]++;
    }
    ll ans = 10000;
    for ( int i = X; i < 102; i++ ) {
        if ( n[i] == 0 ) {
            ans = i;
            break;
        }
    }
    for ( int i = X; i >= 0; i-- ) {
        if ( n[i] == 0 ) {
            if ( X - i <= ans - X ) {
                ans = i;
                break;
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>

using namespace std;

int main()	{
	int a;
  	map<int, int> freq;
  	for (int i = 0; i < 3; i++)	{
    	cin >> a;
      	freq[a]++;
    }
  	if ((freq[5] != 2 || freq[7] != 1))	{
    	cout << "NO" << endl;
    }
  	else	{
      	cout << "YES" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }


int main() {
  i64 N, M;
  cin >> N >> M;
  vector<vector<i64>> g(N);
  for(int c: ran(M)) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
  }
  i64 s, t;
  cin >> s >> t;
  s--;
  t--;
  
  queue<int> que[3];
  vector<i64> dist[3];
  for(int i: ran(3)) dist[i].assign(N, 1e9);
  que[0].push(s);
  dist[0][s] = 0;
  while(true) {
    for(int i = 0;i < 3;i++) {
      if(que[i].empty()) {
        cout << -1 << endl;
        return 0;
      }
      while(!que[i].empty()) {
        int v = que[i].front();
        que[i].pop();
        if(i == 0 && v == t) {
          cout << dist[0][t] / 3 << endl;
          return 0;
        }
        for(int to: g[v]) {
          if(dist[(i + 1) % 3][to] > dist[i][v] + 1) {
            dist[(i + 1) % 3][to] = dist[i][v] + 1;
            que[(i + 1) % 3].push(to);
          }
        }
      }
    }
  }
}


Measured memory_bytes: 8064
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  _  <- getLine 
  as <- readInts
  print $ counter as

counter
  :: [Int] -> Int
counter ns = helper ns 0

helper :: [Int] -> Int -> Int
helper ms k
  | all even ms = helper ms' (k+1)
  | otherwise   = k
  where
    ms' = map (`div` 2) ms


Measured memory_bytes: 1020
using System.Collections.Generic;
using System.Linq;
using System;

public class  Chara
{
    public string name { get; set; }
    public List<int> mv { get; set; }
    public int point { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var charas = new List<Chara>();
            var point = new int[30];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Trim().Split(' ');
                var te = new Chara();
                te.mv = new List<int>();
                te.name = s[0];
                for (int j = 0; j < int.Parse(s[1]); j++)
                {
                    var temp2 = int.Parse(s[j + 2]);
                    te.mv.Add(temp2);
                    point[temp2]++;
                }
                charas.Add(te);
            }
            GetPoint(charas, point);
            var w1 = charas.Min(x => x.point);
            var ans = charas.Where(x => x.point == w1).OrderBy(y => y.name).First();
            Console.WriteLine("{0} {1}", ans.point, ans.name);
        }
    }
    public static void GetPoint(List<Chara> c, int[] p)
    {
        var n = c.Count();
        foreach (var x in c)
        {
            var pcount = 0;
            foreach (var y in x.mv)
                pcount += n - p[y] + 1;
            x.point = pcount;
        }
    }
}

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

int a[110];

int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  int ans=0;
  int cnt;
  for (int i=0; i<n; i++) {
    cnt=1;
    while (a[i]==a[i+1]) {
      cnt++;
      i++;
    }
    ans+=cnt/2;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


/*template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
*/
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c,d;
    cin>>a;
    vector<ll>v;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
    }
    ll sum=1;
    ll mini=v[0];
    for(int i=1; i<a; i++)
    {
        if(v[i]<mini)
        {
            sum++;
            mini=v[i];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] a = new char[H][W];
    for (int i = 0; i < H; i++) {
      a[i] = sc.next().toCharArray();
    }
    for (int i = 0; i < W + 2; i++) {
      System.out.print("#");
    }
    System.out.println();
    for (int i = 0; i < H; i++) {
      System.out.print("#");
      for (int j = 0; j < W; j++) {
        System.out.print(a[i][j]);
      }
      System.out.println("#");
    }
    for (int i = 0; i < W + 2; i++) {
      System.out.print("#");
    }
    System.out.println();
  }
}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    double n, x, t; cin >> n >> x >> t;
    cout << fixed << setprecision(0) << ceil(n / x) * t << NL;
}

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

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

using namespace std;

int n,m;

vector<vector<int> > graph;

vector<int> dp;
vector<bool> vis;

void dfs(int cur){
	vis[cur] = true;
	for(int child : graph[cur]){
		if(vis[child]){
			dp[cur] = max(dp[cur],dp[child]+1);
			continue;
		}
		dfs(child);
		dp[cur] = max(dp[cur],dp[child]+1);
	}	
}



int main(){
	cin >> n >> m;
	graph.resize(n+1);
	dp.resize(n+1,0);
	vis.resize(n+1,false);
	for(int i = 0; i < m; i++){
		int u,v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	for(int i = 1; i<= n; i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	int ans = *max_element(dp.begin(),dp.end());
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 8192
// --------------
// Tejas Pandey  |
// 12 - 01 - 20  |
// ABC #151      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll fact[100007];

void pre(){
	fact[0] = fact[1] = 1;
	for(ll i = 2;i < 100007;i++)
		fact[i] = (fact[i - 1]*i)%mod;
}

ll mpow(ll a, ll b){
	ll res = 1;
	while(b){
		if(b&1)
			res *= a, res %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return res;
}

ll comb(ll a, ll b){
	ll deno = mpow((fact[b]*fact[a - b])%mod,mod - 2);
	deno = (fact[a]*deno)%mod;
	return deno;
}


int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	pre();
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll n,k;
		cin >> n >> k;
		ll a[n];
		for(int i = 0;i < n;i++)
			cin >> a[i];
		sort(a,a+n);
		ll ans = 0;
		for(int i = n - 1;i >= k - 1;i--){
			ans += (a[i]*comb(i,k - 1))%mod;
			ans %= mod;
		}
		for(int i = 0;i < n;i++){
			if(n - 1 - i < k - 1) break;
			ans -= (a[i]*comb(n - 1 - i,k - 1))%mod;
			ans += mod;
			ans %= mod;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back


int main() {
  ll N, K, sum = 0;
  cin >> N >> K; 
  vector<ll> a(N);
  vector<ll> b; 

  rep(i, N){
    cin >> a[i];
  }

  // 累積和作成
  b.push_back(0);
  rep(i, N - 1){
    sum += abs(a[i]-a[i+1]);
    b.push_back(sum); 
  }

  // 解説見たけど、場合分けしなくても確かにいいですね
  ll min_length = pow(10, 13), tmp;
  for(int i = 0; i < N-K+1; i++) {
    tmp = b[K+i-1] - b[i] + min(abs(a[K+i-1]), abs(a[i]));
    // cout << tmp << endl;
    min_length = min(tmp, min_length);
  }
  
  cout << min_length << endl;

}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>

int main(){
	int A, B, C;
	std::cin >> A >> B >> C;
	int D;
	D = A*B/2;
	std::cout << D << std::endl;
	return 0;
}


Measured memory_bytes: 384
import sys
import os
sys.setrecursionlimit(1000000)
from collections import defaultdict
adj = defaultdict(list)
dis =[0 for i in range(1000000)]
def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u)
def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i])
if __name__ =="__main__":
	main()

Measured memory_bytes: 216808
package main

import (
    "fmt"
    "sort"
)

func main() {
    a := make([]int, 3)
    for i := range a {
        fmt.Scan(&a[i])
    }

    sort.Ints(a)                                                                                                   

    diffAc := (a[2] - a[0])
    diffBc := (a[2] - a[1])
    count := diffAc/2 + diffBc/2

    if (diffAc%2 + diffBc%2) == 1 {
        count += 2 
    } else if (diffAc%2 + diffBc%2) == 2 {
        count += 1
    }   
    fmt.Println(count)
}   
                                                                                                                   


Measured memory_bytes: 512