akhauriyash/Code-Regression huggingface dataset:
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((100*a + 10*b + c) % 4 == 0  ? "YES" : "NO")  << endl;
}

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

int r, g, b;

int main() {

    scanf("%d %d %d\n", &r, &g, &b);

    int rgb = 100*r + 10*g + b;

    if (rgb % 4) {
        // 余りがあるとき => true
        printf("NO\n");
    } else {
        // 余りがないとき0 => False
        printf("YES\n");
    }

    return 0;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict, Counter

n = ni()
s = ns()

ans = 0
for i in range(n - 1):
    d = defaultdict(int)
    b = defaultdict(int)
    cnt = 0
    for j in range(i + 1):
        d[s[j]] += 1
    for j in range(i + 1, n):
        b[s[j]] += 1
    for k, j in d.items():
        if b[k] >= 1:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const int MAX_N=100000;
int n,k;
int h[MAX_N+1];
int dp[MAX_N];

void solve(){
    dp[0]=0;
    
    FOR(i,1,n){
        dp[i]=1e9;
        for(int j=1;j<=k;j++){
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}

int main(void){
    cin >> n >> k;
    REP(i,n)
        cin >> h[i];
    solve();
    return 0;
}

Measured memory_bytes: 4376
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  startupcpp();
  int i,j,N,K,Q,ans;
  cin>>N>>K>>Q;
  vector<int> v(N),a(N);
  rep(i,N){
    cin>>v[i];
    a[i]=v[i];
  }
  vsort(v);
  ans=v[Q-1]-v[0];
  v.erase(unique(all(v)),v.end());
  rep1(j,v.size()){
    int ok=v.size(),ng=j-1,mid;
    //v[j]<=x<=v[ok] => cnt>=Q;
    while(ok-ng>1){
      int bf=-1,cnt=0,res=0;
      mid=(ok+ng)>>1;
      rep(i,N){
        if(a[i]<v[j]){
          res+=max(min(cnt,i-bf-K),0);
          bf=i;
          cnt=0;
        }else if(a[i]<=v[mid]){
          ++cnt;
        }
      }
      res+=max(min(cnt,i-bf-K),0);
      if(res>=Q){
        ok=mid;
      }else{
        ng=mid;
      }
    }
    if(ok==(int)v.size())break;
    chmin(ans,v[ok]-v[j]);
  }
  print(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm> //min, max, sort, unique, fill
#include <utility>  //pair, swap,
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>


#define REP(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


vector<ll> vi;



int main(){
  ll n;
  ll temp;
  string  s;
  cin >> n >> s;
  int min,now;
  min = 400000;
  now = 0;
  for(int i = 0; i < n; i ++){
    if(s[i]=='E') min++;
    if( min > now ) min = now;
    if(s[i] == 'W') now++;
  } 
  
  cout << min << endl;
  



  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}
template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; vi v(3); cin >> n >> m >> v[0] >> v[1] >> v[2];
  vvi g(n);
  for(int i=0;i<m;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }
  vector<vector<set<int>>> V(3, vector<set<int>>(n));
  vector<set<int>> tmp(n);
  for(int i=0;i<n;++i) {
    tmp[i].insert(i);
  }
  int now = 0;
  while(now <= max(v[0], max(v[1], v[2]))) {
    vector<set<int>> nxt(n);
    for(int i=0;i<n;++i) {
      for(auto &e: tmp[i]) {
        for(int j=0;j<(int)(g[e].size());++j) {
          nxt[i].insert(g[e][j]);
        }
      }
    }
    now++;
    if(now == v[0]) {
      V[0] = nxt;
    }
    if(now == v[1]) {
      V[1] = nxt;
    }
    if(now == v[2]) {
      V[2] = nxt;
    }
    tmp = nxt;
  }
  vector<int> d(n, -1);
  d[n-1] = 0;
  for(int i=0;i<n;++i) {
    vi nxt(n, -1);
    for(int j=0;j<n;++j) {
      for(int k=0;k<3;++k) {
        int tmp = INF;
        for(auto &e: V[k][j]) {
          if(d[e] == -1) continue;
          chmin(tmp, d[e] + 1);
        }
        chmax(nxt[j], tmp);
      }
      if(nxt[j] == -1) nxt[j] = d[j];
      else if(d[j] != -1) chmin(nxt[j], d[j]);
      if(nxt[j] == INF) nxt[j] = -1;
    }
    d = nxt;
  }
  if(d[0] == -1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << d[0] << endl;
  }
}



Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin >> a >> b >> x;
    bool ans = false;
    if(a + b >= x && a <= x){
        ans = true;
    }
    
    if(ans){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;

int main(){
    IOS
    ll a , b, n; 
    cin>>n>>a>>b;
    ll x = n/(a+b); ll y = n%(a+b);
    if(y<=a)cout<<x*a+y<<endl;
    if(y>a)cout<<x*a+a<<endl;    
    return 0 ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int main () {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int n, m, q;
	cin >> n >> m >> q;
	
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			a[i][j] = s[j] - '0';
		}
	}

	vector<vector<vector<int>>> sum(5, vector<vector<int>>(n, vector<int>(m)));

	for (int x = 0; x < n; ++x) {
		for (int y = 0; y < m; ++y) {
			for (int t = 0; t < 5; ++t) {
				int new_x = x + dx[t];
				int new_y = y + dy[t];
				int cur = 0;
				if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && a[x][y] == 1 && a[new_x][new_y] == 1) {
					cur = 1;
				}
				
				sum[t][x][y] = cur;
				if (x > 0) {
					sum[t][x][y] += sum[t][x - 1][y];
				}
				if (y > 0) {
					sum[t][x][y] += sum[t][x][y - 1];
				}
				if (x > 0 && y > 0) {
					sum[t][x][y] -= sum[t][x - 1][y - 1];
				}
			}			
		}
	}

	for (int i = 0; i < q; ++i) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		--x1, --y1, --x2, --y2;

		int num_v = sum[0][x2][y2];
		if (x1 > 0) {
			num_v -= sum[0][x1 - 1][y2];
		}
		if (y1 > 0) {
			num_v -= sum[0][x2][y1 - 1];
		}
		if (x1 > 0 && y1 > 0) {
			num_v += sum[0][x1 - 1][y1 - 1];
		}

		int num_edge = 0;
		for (int t = 1; t < 5; ++t) {
			int new_x1 = x1;
			int new_y1 = y1;
			int new_x2 = x2;
			int new_y2 = y2;
			if (t == 1) {
				--new_x2;
			} else if (t == 2) {
				++new_x1;
			} else if (t == 3) {
				--new_y2;
			} else if (t == 4) {
				++new_y1;
			}

			if (new_x2 < new_x1 || new_y2 < new_y1) {
				continue;
			}

			num_edge += sum[t][new_x2][new_y2];
			if (new_x1 > 0) {
				num_edge -= sum[t][new_x1 - 1][new_y2];
			}
			if (new_y1 > 0) {
				num_edge -= sum[t][new_x2][new_y1 - 1];
			}
			if (new_x1 > 0 && new_y1 > 0) {
				num_edge += sum[t][new_x1 - 1][new_y1 - 1];
			}
		}

		num_edge /= 2;

		cout << num_v - num_edge << "\n";
	}

	return 0;
}


Measured memory_bytes: 112384
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

void request(vector<vector<pair<int, int>>> v, int q){
    int s, l, m;
    rep(i,q){
        int t[1260 - 540] = {0};
        cin >> s >> l >> m;
        s-=540; l-=540; m--;
        rep(j,v[m].size()){
            t[v[m][j].first - 540]++;
            t[v[m][j].second - 540]--;
        }
        int c = 0, cnt = 0;
        rep(j,1260 - 540){
            c+=t[j];
            if(j >= s && j < l && c > 0) cnt++;
        }
        cout << cnt << endl;
    }
}

void inputData(vector<vector<pair<int, int>>> &v, int r){
    int pc[1001][2] = {0};
    rep(j,r){
        int t, n, m, s;
        cin >> t >> n >> m >> s;
        n--; m--;
        if(s){
            pc[n][0] = t;
        }else if(pc[n][0] != 0){
            bool f = true;
            rep(i,v[m].size()){
                if(v[m][i].first <= pc[n][0] && v[m][i].second >= pc[n][0]){
                    if(v[m][i].second < t){
                        v[m][i].second = t;
                    }
                    f = false;
                    break;
                }else if(v[m][i].first <= t && v[m][i].second >= t){
                    if(v[m][i].first > pc[n][0]){
                        v[m][i].first = pc[n][0];
                    }
                    f = false;
                    break;
                }else if(v[m][i].first >= pc[n][0] && v[m][i].second <= t){
                    v[m][i].first = pc[n][0];
                    v[m][i].second = t;
                    f = false;
                    break;
                }
            }
            if(f) v[m].emplace_back(make_pair(pc[n][0], t));
            pc[n][0] = 0;
        }
    }
}

int main(){
    int n, m, r, q;
    while(cin >> n >> m, n||m){
        vector<vector<pair<int, int>>> v(10001);
        cin >> r;
        inputData(v, r);
        cin >> q;
        request(v, q);

        //rep(i,m){ rep(j,v[i].size()){ cout << v[i][j].first << ' ' << v[i][j].second << endl; } cout << endl; }
    }
}

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

int main() {

    int N;
    int Y;

    int x = 0;
    int y = 0;
    int z = 0;

    int x10000 = 10000;
    int y5000  = 5000;
    int z1000  = 1000;

    cin >> N >> Y;

    for (int i = 0; i <= N; i++) {

        if ((x10000 * i) == Y && i == N){
            x = i;
            y = 0;
            z = 0;

            cout << x << " " << y << " " << z << endl;
            return 0;
        }

        for (int j = 0; j <= N - i; j++) {
            x = i;
            y = j;
            z = N - i - j;

             if ((x10000 * x) + (y5000 * y) + (z1000 * z) == Y && x + y + z == N) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define BE(c) c.begin(),c.end()
#define PB push_back
#define F first
#define S second
#define BEB(s) s
using namespace std;
int main(){
	char com;
	double BMI,b,c;
	int a;
	while(cin>>a>>com>>b>>com>>c){
		if(25<=b/(c*c))cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7 << endl;
    } else if (s == "MON") {
        cout << 6 << endl;
    } else if (s == "TUE") {
        cout << 5 << endl;
    } else if (s == "WED") {
        cout << 4 << endl;
    } else if (s == "THU") {
        cout << 3 << endl;
    } else if (s == "FRI") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict, Counter

S = input()
T = input()

d_s = defaultdict(int)
d_t = defaultdict(int)

no_flag = False
for s, t in zip(list(S), list(T)):
    d_s[s] += 1
    d_t[t] += 1

if sorted(d_s.values()) == sorted(d_t.values()):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 72796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int d = abs(a - b);
    cout << (d%2==0? "Alice\n":"Borys\n");
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
T = tuple(map(int, input().split()))
C = Counter(T)
d = dict()
sum = 0
for c in C.most_common():
  if c[1] == 0:
    break
  if d.get(c[1]):
    sum += d[c[1]]
  else:
    x = (c[1] * (c[1] - 1)) // 2
    d[c[1]] = x
    sum += x
for t in T:
  x = C[t]
  if x >= 2:
    if d.get(x):
      minus = d[x]
    else:
      minus = (x * (x - 1)) // 2
      d[x] = minus
    if d.get(x-1):
      plus = d[x - 1]
    else:
      plus = ((x - 1) * (x - 2)) // 2
      d[x - 1] = plus
    print(sum - minus + plus)
  else:
    print(sum)

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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  //cout << s << " " << t << endl;
  for(int i=0;i<min(s.length(),t.length());i++){
    if(s.at(i) > t.at(i)){
      cout << "No" << endl;
      return(0);
    }else if(s.at(i) < t.at(i)){
      cout << "Yes" << endl;
      return(0);
    }
  }
  
  if(s.length() < t.length()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const double pi=acos(-1.0);
int main()
{
	ll a,c,d;
	float b;
	scl(a);scanf("%f",&b);
	c=(long long)b;
	d=a*c;
	c=((long long)(b*100+0.5))%100;
	d+=a*c/100;
	pf("%lld\n",d);
}

Measured memory_bytes: 3808
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 998244353
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


def combination_mod(n, r, mod=MOD):
    # mod取りながらcombination
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


def ret_list_comb_r(n, r, mod=MOD):
    '''nC[0:r+1]を返す。for とかで再計算せずに済むように'''
    ret = [1]
    if r > n:
        raise ValueError('rがnより大きいけど大丈夫か？(0通り？)')
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
        ret.append(nf * pow(rf, mod - 2, mod) % mod)
    return ret


N, M, K = read_ints()
N_1C = ret_list_comb_r(N - 1, K)


def ret_ans_when_k(k):
    ret = M
    ret *= pow(M - 1, N - k - 1, MOD)
    ret %= MOD
    ret *= N_1C[k]  # ここの計算量が大きい

    return ret % MOD


ans = 0
for i in range(0, K + 1):
    ans += ret_ans_when_k(i)
    ans %= MOD
print(ans)


Measured memory_bytes: 81948
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

map <int,int> mp;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int d;
		scanf("%d",&d);
		mp[d]++;
	}
	int m;
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		int x;
		scanf("%d",&x);
		if(mp[x]==0)
		{
			puts("NO");
			return 0;
		}
		mp[x]--;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

const int MAX_N = 110;
const int MAX_M = 110;

char maze[MAX_N][MAX_M + 1];

int main() {
  string s;
  cin >> s;
  if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

int w,h,i,j,x,y;
char s[105][105],pan;

int main(void){
	while(scanf("%d %d",&h,&w)*(w+h)){
		for(i=0;i<h;i++)scanf("%s",s[i]);
		
		x=0;y=0;

		while(1){
			pan=s[y][x];
			s[y][x]='#';
			switch(pan){
				case '>':
					x++;
					break;
				case '<':
					x--;
					break;
				case 'v':
					y++;
					break;
				case '^':
					y--;
					break;
				case '#':
					printf("LOOP\n");
					goto exit;
					break;
				default:
					printf("%d %d\n",x,y);
					goto exit;
			}
		}

		exit:;

	}
	return 0;
}

Measured memory_bytes: 624
#include <stdio.h>

// 15min
int main(void){
  int n = 0;
  int a[201];
  int ans = 0;

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    if(a[i] % 2 != 0){
      printf("0\n");
      return 0;
    }
  }

  while(1){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
	printf("%d\n", ans);
	return 0;
      }else{
	a[i] = a[i] / 2;
      }
    }
    ans++;
  }

  return 0;
  
}


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

int main() {
    int H, W; std::cin >> H >> W;
    std::vector<std::vector<char>> m(H, std::vector<char>(W));
    for (int i =0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            std::cin >> m[i][j];
        }
    }

    std::vector<bool> h(H, false);
    for (int i = 0; i < H; i++) {
        bool all = true;
        for (int j = 0; j < W; j++) {
            if (m[i][j] == '#') {
                all =false;
                break;
            }
        }
        if (all) {
            h[i] = true;
        }
    }
    std::vector<bool> w(W, false);
    for (int j = 0; j < W; j++) {
        bool all = true;
        for (int i = 0; i < H; i++) {
            if (m[i][j] == '#') {
                all = false;
                break;
            }
        }
        if (all) {
            w[j] = true;
        }
    }

    for (int i =0; i < H; i++) {
        if (h[i]) {
            continue;
        }
        for (int j = 0; j < W; j++) {
            if (w[j]) {
                continue;
            }
            std::cout << m[i][j];
        }
        std::cout << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a[101];
double ans;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		ans+=1.0/a[i];
	}
	printf("%.14lf",1/ans);
	return 0;
}


Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;


int main(){
    string S, T;
    cin >> S >> T;
    int a = S.size();
    int ans = a;
    rep(i, 0, a){
        if(S.at(i) == T.at(i)) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;

//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

//約数列挙 累乗の関数とともに用いる。
long long int soinnsuu[2100000] = {}, yakusuu[2100000] = {1}, kosuu = 1;
int yakusuu_rekkyo(long long int n) {
	long long int N = n;
	for (int i = 2; i * i <= N; i++) {
		int tmp = 1;
		while (n % i == 0) {
			soinnsuu[i]++;
			n /= i;
			tmp++;
		}
		int tmp2 = tmp;

		while (tmp!=1) {
			for (int j = 0; j < kosuu; j++) {
				yakusuu[j + (tmp - 1) * kosuu] = rui(i, tmp - 1, mod)*yakusuu[j];
			}
			tmp--;
		}
		kosuu *= tmp2;

	}
	if (n != 1) {
		for (int j = 0; j < kosuu; j++) {
			yakusuu[j + kosuu] = rui(n, 1, mod) * yakusuu[j];
		}
		kosuu *= 2;
	}
    return 0;
}


long long int n,k,a[2000],sum=0,up=0,down=0,res=1;
int main() {
    long long int count=0;
    string str,str2;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    yakusuu_rekkyo(sum);
    for(int i=0;i<kosuu;i++){
        long long int p[550]={},ruiseki[550]={};
        count=0;
        up=0;
        down=0;
        for(int j=1;j<=n;j++){
            p[j]=a[j]%yakusuu[i];
        }
        sort(p+1,p+n+1);
        for(int j=1;j<=n;j++){
            ruiseki[j]=ruiseki[j-1]+p[j];
        }
        for(int j=0;j<=n;j++){
            count=max(ruiseki[j],(n-j)*yakusuu[i]-(ruiseki[n]-ruiseki[j]));
            //cout<<count<<endl;
            if(count<=k){res=max(res,yakusuu[i]);}
        }
        //cout<<endl;
    }
    cout<<res;
} 


Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var datas = read.Split(new char[] { ' ' });
            string a = datas[0];
            string b = datas[1];

            string c = a + b;
            int d = Convert.ToInt32(c);
            var e = Math.Sqrt(d);
            if (e - Math.Floor(e) != 0 )
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }

Measured memory_bytes: 11220
x = int(input())

lim = int(x**0.25)

for a in range(0,lim+1):
    b5 = (pow(a,5)-x)
    if b5 <0:
        fugou=-1
    else:
        fugou=+1
    b5 = abs(b5)
    if pow(int(b5 ** 0.2),5)==b5:
        break

print(a, fugou*int(b5**0.2))

Measured memory_bytes: 62248
#include <iostream>
#include <vector>
#include <limits>

int main()
{
  int N,M,X;
  std::cin>>N>>M>>X;
  
  std::vector<int> cVec(N);
  std::vector<std::vector<int>> aVec(N,std::vector<int>(M));
  
  for(size_t i=0;i!=N;i++)
  {
    std::cin>>cVec[i];
    for(auto &e:aVec[i])
      std::cin>>e;
  }
  
  int result=std::numeric_limits<int>::max();
  for(size_t i=1,end=1<<N;i!=end;i++)
  {
    int c=0;
    bool understood=true;
    for(size_t j=0;j!=M;j++)
    {
      int a=0;
      for(size_t k=0;k!=N;k++)
      {
        if(i>>k&1)
        {
          if(j==0)
            c+=cVec[k];
          a+=aVec[k][j];
        }
      }
      if(a<X)
      {
        understood=false;
        break;
      }
    }
    if(understood)
    {
      if(c<result)
        result=c;
    }
  }
  
  if(result==std::numeric_limits<int>::max())
    result=-1;
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    s += "##";

    if (c > d){
        bool found = false;
        FOR(i,b,d){
            if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') found = true;
        }
        if (!found){
            cout << "No" << endl;
            return 0;
        }
    }

    while (b < d){
        if (s[b + 1] == '.') b++;
        else if (s[b + 2] == '.') b += 2;
        else break;
    }
    while (a < c){
        if (s[a + 1] == '.') a++;
        else if (s[a + 2] == '.') a += 2;
        else break;
    }

    cout << (a == c && b == d ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 640
def main():
    H, W = map(int, input().split())
    S = list(input() for _ in range(H))

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    # Lをカウント
    for i in range(H):
        cnt = 0
        for j in range(W):
            if S[i][j] == '#':
                cnt = 0
                continue
            else:
                cnt += 1
                L[i][j] = cnt

    for i in range(H):
        cnt = 0
        for j in range(W-1, -1, -1):
            if S[i][j] == '#':
                cnt = 0
                continue
            else:
                cnt += 1
                R[i][j] = cnt

    for j in range(W):
        cnt = 0
        for i in range(H):
            if S[i][j] == '#':
                cnt = 0
                continue
            else:
                cnt += 1
                U[i][j] = cnt

    for j in range(W):
        cnt = 0
        for i in range(H-1,-1,-1):
            if S[i][j] == '#':
                cnt = 0
                continue
            else:
                cnt += 1
                D[i][j] = cnt

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                continue
            tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
            ans = max(ans,tmp)

    print(ans)

main()

Measured memory_bytes: 180740
import sys
input = sys.stdin.buffer.readline


def convolve(a, b):
    """配列a, bの畳み込みをNTT(number-theoretical transform)によって計算する。
    res[k] = (sum{i = 0..k} a[i] * b[k - i]) % MOD
    """
    MOD = 998244353
    ROOT = 5

    def ntt(a, inverse=False):
        # バタフライ演算用の配置入れ替え
        for i in range(n):
            j = 0
            for k in range(log_sz):
                j |= (i >> k & 1) << (log_sz - 1 - k)
            if i < j:
                a[i], a[j] = a[j], a[i]

        h = pow(ROOT, (MOD - 1) * pow(n, MOD - 2, MOD) % MOD, MOD)
        if inverse:
            h = pow(h, MOD - 2, MOD)

        # バタフライ演算
        m = 1
        while m < n:
            zeta_pow = 1
            zeta = pow(h, n // (2 * m), MOD)
            for j in range(m):
                for k in range(0, n, 2 * m):
                    s = a[j + k]
                    t = a[j + k + m] * zeta_pow
                    a[j + k] = (s + t) % MOD
                    a[j + k + m] = (s - t) % MOD
                zeta_pow *= zeta
                zeta_pow %= MOD
            m <<= 1

        # 逆変換時には配列のサイズの逆元をかける
        if inverse:
            n_inv = pow(n, MOD - 2, MOD)
            for i in range(n):
                a[i] *= n_inv
                a[i] %= MOD
        return a

    def intt(a):
        return ntt(a, inverse=True)

    n = 1 << (len(a) + len(b) - 1).bit_length()
    log_sz = n.bit_length() - 1
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))

    # in-placeで計算を進めることに注意
    ntt(a), ntt(b)
    for i, val in enumerate(b):
        a[i] *= val
        a[i] %= MOD
    intt(a)

    return a


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


print(*convolve(a, b)[:n + m - 1])

Measured memory_bytes: 207520
#include<cstdio>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b)
        printf("Draw\n");
    else
    {
        if(a==1)
            printf("Alice\n");
        else if(b==1)
            printf("Bob\n");
        else if(a>b)
            printf("Alice\n");
        else if(b>a)
            printf("Bob\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3;
int cnt=0,cnt1=0,cnt2=0,n,lim[2],col[maxn][maxn];
bool ex[maxn][maxn];
struct cp{
	int x,y;
}p[maxn];
vector <cp> s[2];
long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-') f*=-1;}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
void dfs(int x,int y,int coll){
	col[x][y]=coll;
	if(coll==1){cnt1++;}
	if(coll==2){cnt2++;}
	for(int k=1;k<=cnt;k++){
		int tox=p[k].x+x,toy=p[k].y+y;
		if(tox>=0&&tox<2*n&&toy>=0&&toy<2*n){
			if(col[tox][toy]==0) dfs(tox,toy,coll%2+1);
		}
	}
}
void work(int lim){
	cnt=0,cnt1=0,cnt2=0;
	for(int i=0;i<2*n;i++){for(int j=0;j<2*n;j++){col[i][j]=0;}}
	for(int i=0;i*i<=lim;i++){
		int ss=(int(sqrt(lim-i*i))*int(sqrt(lim-i*i))+i*i);
		if(ss==lim){
			++cnt;p[cnt].x=i;p[cnt].y=sqrt(lim-i*i);
			++cnt;p[cnt].x=i;p[cnt].y=-sqrt(lim-i*i);
			++cnt;p[cnt].x=-i;p[cnt].y=sqrt(lim-i*i);
			++cnt;p[cnt].x=-i;p[cnt].y=-sqrt(lim-i*i);
		}
	}
	for(int i=0;i<2*n;i++){
		for(int j=0;j<2*n;j++){
			if(ex[i][j]&&(col[i][j]==0)){dfs(i,j,1);}
		}
	}
	if(cnt1>=cnt2){
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2*n;j++){
				ex[i][j]=(ex[i][j]&&(col[i][j]==1));
			}
		}
		return;
	}
	if(cnt2>=cnt1){
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2*n;j++){
				ex[i][j]=(ex[i][j]&&(col[i][j]==2));
			}
		}
		return;
	}
}

int main(){
	n=read();
	lim[0]=read();
	lim[1]=read();
	for(int i=0;i<2*n;i++){for(int j=0;j<2*n;j++){ex[i][j]=true;}}
	work(lim[0]);
	work(lim[1]);
	int tot=0;
	for(int i=0;i<2*n;i++){
		for(int j=0;j<2*n;j++){
			if(ex[i][j]&&tot<n*n){
				tot++;
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 21504
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.MaxCount = inpt[1];

        Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToList().ForEach(a => Pricce.Add(Pricce.Count, a));
        long[] saidai = new long[Pricce.Count];
        long max = 0;
        for (int i = Pricce.Count - 1; i >= 0; i--)
        {
            max = Math.Max(max, Pricce[i]);
            saidai[i] = max;
        }

        long maxRieki = long.MinValue;

        int ans = 0;
        for (int i = 0; i <Pricce.Count-1; i++)
        {
            long mx = saidai[i + 1];
            long tmp = mx - Pricce[i];
            if (tmp > maxRieki)
            {
                ans = 0;
                maxRieki = tmp;
            }
            if (tmp >= maxRieki)
            {
                ans += 1;
            }
        }

        Console.WriteLine(ans);
    
    }



    private long MaxCount;


    private Dictionary<int, long> Pricce = new Dictionary<int, long>();


    


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

10 100
7 10 4 5 9 3 6 8 2 1



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# FFT
import numpy as np
M = 998244353
a = np.array(a, dtype=np.int64)
b = np.array(b, dtype=np.int64)
def fft(a,b):
    l = 1
    while 2 * l < len(a) + len(b) - 1:
        l *= 2
    l *= 2
    c = np.fft.irfft((np.fft.rfft(a,l))*(np.fft.rfft(b,l)),l)
    c = np.rint(c).astype(np.int64)
    return c
def fft_large(a,b):
    d = 30000
    a1, a2 = np.divmod(a,d)
    b1, b2 = np.divmod(b,d)
    aa = fft(a1,b1) % M
    bb = fft(a2,b2) % M
    cc = (fft(a1+a2, b1+b2) - (aa+bb)) % M
    h = (((aa*d)%M)*d  + cc*d + bb) % M
    return h
def fft_large(a,b):
    d = 1<<10
    a1, a2 = np.divmod(a,d*d)
    a2, a3 = np.divmod(a2,d)
    b1, b2 = np.divmod(b,d*d)
    b2, b3 = np.divmod(b2,d)
    aa = fft(a1,b1) % M
    bb = fft(a2,b2) % M
    cc = fft(a3,b3) % M
    dd = (fft(a1+a2, b1+b2) - (aa+bb)) % M
    ee = (fft(a2+a3, b2+b3) - (bb+cc)) % M
    ff = (fft(a1+a3, b1+b3) - (aa+cc)) % M
    h = (((aa*d*d)%M)*d*d + ((dd*d*d)%M)*d + (bb+ff)*d*d + ee*d + cc) % M
    return h

c = fft_large(a,b)[:n+m-1]
write(" ".join(map(str, c)))

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

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

  bool ok = false;
  int ans = 0;
  rep(i, (N * 100 + 108 - 1) / 108 + 1) {
    int tmp = i * 108 / 100;
    if (tmp == N) {
      ans = i;
      ok = true;
      break;
    }
  }

  if (ok)
    cout << ans << endl;
  else
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#ABC047 C - 一次元リバーシ / 1D Reversi
S = input()
cur_s = ''
SS=[] 
for i,s in enumerate(S):
    if i==0:
        cur_s = s
        SS.append(s)
        continue
    if i==len(S):
        if cur_s == s:
            continue
        else:
            SS.append(s)
            continue

    if cur_s == s:
        continue
    else:
        SS.append(s)
        cur_s = s

n = len(SS)
m = n//2
if n==1:
    print(0)
    exit()

if n%2==1:
    print(m*2)
else:
    print(((n//2)*2)-1)


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int have[n];
    for(int i = 0; i < n; i++) {
        have[i] = 0;
    }

    int d;
    int temp;
    for(int i = 0; i < k; i++) {
        cin >> d;
        for(int j = 0; j < d; j++) {
            cin >> temp;
            have[temp-1] = 1;
        }
    }

    int counter = 0;
    for(int i = 0; i < n; i++) {
        if(have[i] == 0) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 3624
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long n = scanner.nextInt(), m = scanner.nextInt();
        System.out.println(n == 2 || m == 2 ? 0 : n == 1 || m == 1 ? n == 1 ? m == 1 ? 1 : m - 2 : n - 2 : (n - 2) * (m - 2));
    }
}

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

int main(){
    int n,A,B,a=0,b=0,c=0,rta;
    cin >> n >> A >> B;
    int x[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        if(x[i]<=A)a++;
        else if(x[i]>B)c++;
        else b++;
    }
    rta=min({a,b,c});
    cout << rta << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,sum=0;
	cin>>x;
	for(int i=1;i<=x;i++){
		int a,b;
		for(int j=1;j<=x;j++){
			int n,m,zz,sb;
			n=i>j?i:j;
			m=i<j?i:j;
			while((a=n%m)!=0)
	{
		n=m;
		m=a;
	}
			for(int t=1;t<=x;t++){
			zz=m>t?m:t;
			sb=m<t?m:t;
			while((b=zz%sb)!=0)
	{
		zz=sb;
		sb=b;
			}
			sum+=sb;
		}
	}
}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3632
N, X = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

ans = 0
ttl = sum(a)

if ttl < X:
    ans = N - 1
elif ttl == X:
    ans = N
else:
    s = 0
    for ax in a:
        if s + ax <= X:
            s += ax
            ans += 1
        else:
            break
print(ans)

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

int main() 
{
    int n, m; cin >> n >> m;
    vector<int> h(n);
    vector<vector<int>> adj(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool flag = true;
        for (int j: adj[i]) {
            if (h[j] >= h[i]) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << '\n';
}


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

using namespace std;

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

    if ((N+1)/2 < K)
    {
        cout<<-1<<endl;
        return 0;
    }

    vector<int> A(N), B(N), C(N);

    int K2 = (N+1)/2;
    for (int i=0; i<N; i++)
        C[i] = K2+2*N+i;

    if (N%2==0)
    {
        A[0] = K2;
        for (int i=0; i<N/2-1; i++)
        {
            A[i+1] = K2+i*2+1;
            A[i+N/2+1] = K2+i*2+2;
        }
        A[N/2] = K2+(N/2-1)*2+1;

        for (int i=0; i<N; i++)
            B[i] = C[i]-A[i];
        B[0] = K2+N;
    }
    else
    {
        for (int i=0; i<N/2; i++)
        {
            A[i] = K2+i*2;
            A[i+N/2+1] = K2+i*2+1;
        }
        A[N/2] = K2+N/2*2;

        for (int i=0; i<N; i++)
            B[i] = C[i]-A[i];
    }

    for (int i=0; i<N; i++)
    {
        A[i] += K-K2;
        B[i] += K-K2;
        C[i] += K-K2;
    }
    for (int i=0; i<N; i++)
        cout<<A[i]<<" "<<B[i]<<" "<<C[i]<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n, k;    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    while(0<k--){
        vector<ll> work = a;
        a = vector<ll>(n, 0);
        REP(i, n){
            ll st=max(0LL, i-work[i]);
            ll ed=min(i+work[i], n)+1;
            a[st] += 1;
            if(ed<n) a[ed] -= 1;
        }
        bool flag=true;
        REP(i, n){
            if(i<n-1) a[i+1] += a[i];
            if(a[i]<n) flag = false;
        }
        if(flag) break;
    }
    REP(i, n)   cout << a[i] << ' ';

}


Measured memory_bytes: 7988
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi vec(n);
    set<int> s;
    int over3200 = 0;
    rep(i, n){
        cin >> vec[i];
        int unko = vec[i] / 400;
        if(unko >= 8){
            s.insert(8);
            over3200++;
        }else{
            s.insert(vec[i] / 400);
        }
    }
    if(over3200 == 0){
        cout << s.size() << ' ' << s.size() << endl;
    }else{
        if(s.size() == 1){
            cout << s.size() << ' ';
        }else{
            cout << s.size() - 1 << ' ';
        }
        int tmp = s.size() + over3200 - 1;
        cout << tmp << endl;

    }

    return 0;
}

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

int main() {
    int n; scanf("%d", &n);
    int a[n]; for (int i = 0; i < n; ++i) scanf("%d", a + i);
    int num_query; scanf("%d", &num_query);
    int begin, end, k;
    for (int i = 0; i < num_query; ++i) {
        scanf("%d%d%d", &begin, &end, &k);
        printf("%d\n", count(a + begin, a + end, k));
    }
    return 0;
}


Measured memory_bytes: 2764
card_A = input()
card_B = input()
card_C = input()

def changeTarget(target):
  ans = 'default'
  if(target == 'A'):
    ans = card_A
  elif(target == 'B'):
    ans = card_B
  elif(target == 'C'):
    ans = card_C

  return ans

target = [card_A, 'A', '']
while target[0] != '':
  if(target[0][0] == 'a'):
    target[2] = 'A'
  elif(target[0][0] == 'b'):
    target[2] = 'B'
  elif(target[0][0] == 'c'):
    target[2] = 'C'

  if(target[1] == 'A'):
    card_A = card_A[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])
  elif(target[1] == 'B'):
    card_B = card_B[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])
  elif(target[1] == 'C'):
    card_C = card_C[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])

print(target[1])


Measured memory_bytes: 38384
# -*- coding: utf-8 -*-


[P, Q, R] = [int(i) for i in input().split()]

min_distance = 10000

# ABC
distance = P + Q
if distance < min_distance:
    min_distance = distance

# ACB
distance = R + Q
if distance < min_distance:
    min_distance = distance

# BAC
distance = P + R
if distance < min_distance:
    min_distance = distance

# BCA
distance = Q + R
if distance < min_distance:
    min_distance = distance

# CAB
distance = R + P
if distance < min_distance:
    min_distance = distance

# CBA
distance = Q + P
if distance < min_distance:
    min_distance = distance

print(min_distance)

Measured memory_bytes: 3064