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

using namespace std;
inline void
prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
//printf("%.12lf\n",mid);
int mod;

int mymod(int num){
  if (num< 0){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
map<string, vector<int> > cities;
int main ()
{
  prep ();
  
  int n, m;
  cin >> n >> m;
  set<int> have;
  vector<int> arrs[10];
  int odd[10];
  for (int i=0; i<m; i++){
    int k;
    cin >> k;
    for (int j=0; j<k; j++){
      int num;
      cin >> num;
      arrs[i].push_back(num-1);
    }
  }
  for (int i=0; i<n; i++){
    cin >> odd[i];
  }
  int poww = pow(2, n);
  long long combos = 0;
  for (int i=0; i<poww; i++){
    bitset<10> bs(i);
    bool bad = false;
    for (int j=0; j<m; j++){
      int amton = 0;
      int amtneed = odd[j];
      for (int k=0; k<arrs[j].size(); k++){
        if (bs[arrs[j][k]] == 1){
          amton++;
        }
      }
      if (amton%2 != amtneed){
        bad = true;
        break;
      }
    }
    
    if (!bad){
      combos++;
    }
  }
  cout << combos;
  return 0;
}
// in dp problems think: up until here, intervals, or "what if there's 1, 2, 3..."
// in math problems write out equations
// also in math problems to change multiplication/division to addition/subtraction use logs, add/subtract something to make the multiplication easier (like if it's 3*f(x)+2, change it to 3*(f(x)+1)-1)
// if printint pow function, put an (int) or (long long) next to it
// if checked everything check for bugs (like sorting wrong way or not putting a break in a loop)
// if n is 10^7 try brute force if the operations are simple
// if can't do dp do brute force/greedy
// to save time don't copy maps/vectors into variables if it already exists
// only use long long if need to
// if wrong on decimal problem, check if program rounds or if you can round to a certain amt of decimals
// if decimals too, if can subtract instead of divide
// in grid traversal problems check if doing sideways or not
// if TLE try to take away loop
// in recursion looking math problems look at things from the point of view of both sides (the start and the end sections of the recursion)
// think about how many possible answers there are to the problem
// if it makes it easier use +1 indexing
// think twice when writing things down that you're going to use later


Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int abGap = b - a;
        int bcGap = c - b; 
    
		// 出力
		System.out.println(abGap == bcGap ? "YES" : "NO");
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>v[26],u[26];
signed main(){
	string s,t;cin>>s>>t;
	for(char c='a';c<='z';c++){
		rep(i,s.size()){
			if(s[i]==c){
				v[c-'a'].push_back(i);
			}
			if(t[i]==c){
				u[c-'a'].push_back(i);
			}
		}	
	}
	rep(i,26){
		if(v[i].empty())continue;
		int j=t[v[i][0]]-'a';
		if(v[i].size()!=u[j].size()){
			puts("No");return 0;
		}
		rep(k,v[i].size()){
			if(t[v[i][k]]!=t[v[i][0]]){
				puts("No");return 0;
			}
			if(v[i][k]!=u[j][k]){
				puts("No");return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 2640
import java.util.*;

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

    if(n>=10){
      System.out.println(r);
    } else {
      System.out.println(r+1000-100*n);
    }
    
  }
}


Measured memory_bytes: 22612
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    xs,ys,xt,yt=map(int,input().split())
    n=int(input())
    CR=[None]*(n+2) # center, radius
    CR[0]=(xs+ys*1j,0)
    CR[n+1]=(xt+yt*1j,0)
    for i in range(1,n+1):
        x,y,r=map(int,input().split())
        CR[i]=(x+y*1j,r)


    # 各点の距離を求める
    n+=2
    E=[[] for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i>=j): continue
        c0,r0=CR[i]
        c1,r1=CR[j]
        d=max(0,abs(c0-c1)-r0-r1)
        E[i].append((j,d))
        E[j].append((i,d))

    # pure Dijkstra で 0 から n-1 の距離を計算する
    dist=[INF]*n
    dist[0]=0
    used=[0]*n
    for _ in range(n-1):
        v=min((dist[v],v) for v in range(n) if(not used[v]))[1]
        used[v]=1
        for nv,w in E[v]:
            if(dist[nv]>dist[v]+w):
                dist[nv]=dist[v]+w

    print(dist[-1])
resolve()

Measured memory_bytes: 122972
#include <stdio.h>

int main(void)
{
	int sec;
	int h,m,s;
	scanf("%d",&sec);
	h=sec/3600;
	m=sec%3600/60;
	s=sec-h*3600-m*60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

d = {}

for i in range(m):
    p, s = map(str,input().split())
    if not p in d:
        d[p] = [0, 0]
    if s == 'WA' and d[p][1] == 0:
        d[p][0] += 1
    elif s == 'AC':
        d[p][1] = 1

ans = 0
pena = 0

for dict in d.values():
    if dict[1] == 1:
        ans += 1
        pena += dict[0]

print('{} {}'.format(ans, pena))


Measured memory_bytes: 25268
#include <bits/stdc++.h>
using namespace std;
int main() {
    int room[4][3][10] = {{{}}};
    int n;
    cin >> n;
        int a,b,c,d;
    for(int i = 0; i < n; i++) {
        cin >> a >> b >> c >> d;
        room[a-1][b-1][c-1] += d;
    }
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 10; k++) {
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
typedef long long ll;

#define M 1046527
#define NIL (-1)
#define L 14 

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0;
  long long p = 1;
  rep(i, strlen(str)){
    sum += p * getChar(str[i]);
    p *= 5;
  }
  return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + key % (M-1);}

int find(char str[]){
  long long key = getKey(str);
  for(int i=0; ; i++){
    long long h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key = getKey(str);
  for(int i=0; ; i++){
    long long h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

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

  rep(i, n){
    char com[9], str[L];
    scanf("%s %s", com, str);
    if(com[0] == 'i') insert(str);
    else cout << (find(str) ? "yes" : "no") << endl;
  }

  return 0;
}




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

#define f first
#define s second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;

int n;
ll ans1,ans2;
vi a;
deque<int> q;

int main()
{
    IOS
    cin>>n;
    a.resize(n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(all(a));
    int i=0,j=sz(a)-1,cnt=1;
    q.push_front(a[0]);
    while(1)
    {
        if(cnt&1)
        {
            q.push_front(a[j]);
            if(--j==i) break;
            q.push_back(a[j]);
            if(++i==j) break;
        }
        else
        {
            q.push_front(a[i]);
            if(++i==j) break;
            q.push_back(a[i]);
            if(--j==i) break;
        }
        cnt++;
    }
    for(int i=0; i<sz(a)-1; i++)
        ans1+=abs(q[i]-q[i+1]);
    q.clear();
    i=0,j=sz(a)-1,cnt=1;
    q.push_front(a[j]);
    while(1)
    {
        if(cnt&1)
        {
            q.push_front(a[i]);
            if(++i==j) break;
            q.push_back(a[i]);
            if(--j==i) break;
        }
        else
        {
            q.push_front(a[j]);
            if(--j==i) break;
            q.push_back(a[j]);
            if(++i==j) break;
        }
        cnt++;
    }
    for(int i=0; i<sz(a)-1; i++)
        ans2+=abs(q[i]-q[i+1]);
    cout<<max(ans1,ans2);
    return 0;
}


Measured memory_bytes: 1152
<?php

fscanf(STDIN, "%d", $n);
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$a_arr = explode(' ', $a);
$b_arr = explode(' ', $b);
$c_arr = explode(' ', $c);

$count = 0;
$before = 0;
foreach ($a_arr as $x) {
    $count += $b_arr[$x - 1];

    if ($x == $before + 1) {
        $count += $c_arr[$before - 1];
    }

    $before = $x;
}

echo $count;


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int M=20010;
ll dp[M];
int a[M],b[M];
int main(int argc, char const *argv[])
{
	fill(dp,dp+M,inf);
	dp[0]=0;

	int h,n;cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=a[i];j<=M-10;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
	ll ans=inf;
	for(int i=h;i<=M-10;i++)ans=min(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 60;

ll a[N];

int main()
{
    ll k;
    cin >> k;
    cout  << "50" << endl;

    ll x = k / 50 + 50;
    ll y = k % 50;
    ll z = x - y - 1;

    if(y == 0)
    {
        //cout << "z = " << z << endl;
        for (int i = 1; i <= 50; i ++ )
        {
            cout << z << " ";
        }
    }
    else
    {
        for (int i = 1; i <= 50 - y ; i ++ ) cout << z << " ";
        for (int i = 50 - y + 1; i <= 50; i ++ ) cout << x << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll memo[1 << 21];
int N, a[25][25];
ll mod = 1e9 + 7;

int dfs(int state, int c)
{
	if (memo[state] != -1) {
		return memo[state];
	}
	ll r = 0;
	for (int i = 0; i < N; i++) {
		if (state & (1 << i) && a[c][i]) {
			r += dfs(state ^ (1 << i), c + 1);
		}
	}
	r %= mod;
	memo[state] = r;

	return r;
}

int main(int argc, char *argv[])
{
	int state = 1 << 21;

	cin >> N;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < state; i++) {
		memo[i] = -1;
	}
	memo[0] = 1;
	cout << dfs((1 << N) - 1, 0) << endl;

	return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

ll f(ll a, ll b, ll x) {
  return floor((double) a * x / (double) b) - a * floor((double) x / (double) b);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll res = LONG_LONG_MIN;
  ll low = -1;
  ll high = n + 1;
  res = max(res, f(a, b, 0));
  res = max(res, f(a, b, n));
  int cnt = 5000;
  while (cnt--) {
    ll c1 = (low * 2 + high) / 3;
    ll c2 = (low + high * 2) / 3;
    ll c3 = (low + high) / 2;
    ll cc1 = f(a, b, c1);
    ll cc2 = f(a, b, c2);
    ll cc3 = f(a, b, c3);
    if (cc1 >= cc2) {
      high = c2;
    } else {
      low = c1;
    }
    res = max(res, cc1);
    res = max(res, cc2);
    res = max(res, cc3);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, M, V, P;
ll A[100010];

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

/*ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void init()
{
	cin >> N >> M >> V >> P;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
}

void output()
{
	cout << ans << endl;
}

bool jud(ll num)
{
	if (V <= P + N - num - 1)
	{
		return A[P - 1] <= A[num] + M;
	}
	else
	{
		ll l = num - (P - 1);
		ll k = l - (V - (P + N - num - 1));
		vector<ll> vec;
		ll sum = 0;
		for (ll i = P - 1; i < num; i++)
		{
			vec.push_back(A[i] - A[num]);
			sum += A[i] - A[num];
		}
		return max(vec[0], (sum + k - 1) / k) <= M;
	}
}

void solve()
{
	sort(A, A + N);
	reverse(A, A + N);
	ll lb = P - 1, ub = N;
	while (lb + 1 < ub)
	{
		ll mid = (lb + ub) / 2;
		if (jud(mid))
		{
			lb = mid;
		}
		else
		{
			ub = mid;
		}
	}
	ans = lb + 1;
}

int main()
{
	init();
	
	solve();

	

	output();

	cin >> N;
}

Measured memory_bytes: 2824
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int X, Y, Z;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> X >> Y >> Z;

  int ans = floor(((double)X - Z) / ((double)Y + Z));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S, T, U;
  ll A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (S == U)
    cout << (A - 1) << " " << B << endl;
  else
    cout << (A) << " " << (B - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int dp[1005][1005];
const int MOD=1e9+7;

int main()
{jizz
	int n,m;
	char c;
	cin >> n >> m,dp[0][1]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(cin >> c,c=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	cout << dp[n][m] << "\n";
}

Measured memory_bytes: 4224
import java.util.*; 

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

  		String[] s=new String[n];
		for(int c=0;c<n;c++){
    		s[c]=sc.next();
    	}
		Arrays.sort(s); 
  		if(n==1){
        ans=1;
        }else{
  		for(int d=0;d<n-1;d++){
        if(!s[d].equals(s[d+1])){
        ans++;
        }
        }
          ans++;
        }

    	System.out.println(ans);
    }
}

Measured memory_bytes: 70100
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int N;
    int[] h;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        h = IntStream.range(0, N).map(i -> sc.nextInt()).toArray();
    }

    void solve(PrintWriter out) {
        int cnt = h[0];
        for (int i = 1; i < N; i++) {
            cnt += Math.max(0, h[i] - h[i - 1]);
        }
        out.println(cnt);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 28756
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	rep(i, n - 1) {
		if (a + d * i - c * (n - 1 - i) >= b && a + c * i - (n - 1 - i) * d <= b) {
			cout << "YES" << endl; return 0;
		}
	}
	cout << "NO" << endl;
}


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

#define MAX 100000

int N, M;
vector<int> G[MAX + 1];
int dp[MAX + 1] = {0};
int seen[MAX + 1] = {false};

int rec(int now_pos) {
  if (seen[now_pos]) return dp[now_pos];

  seen[now_pos] = true;

  int distance = 0;
  for (int next: G[now_pos]) {
    distance = max(distance, rec(next) + 1 );
  }
  return dp[now_pos] = distance;
}

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

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, rec(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123;
int dp[5][S+5];
int ara[5][S+5];
int n;

int Solve(int i,int j)
{
    if(i==1 && j==n-1)return ara[i][j];
    if(dp[i][j]!=-1)return dp[i][j];
    
    int mx=0;
    if(i+1<=1)mx=Solve(i+1,j);
    if(j+1<n)mx=max(mx,Solve(i,j+1));

    return dp[i][j]=mx+ara[i][j];
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    while(sf("%d",&n)==1)
    {
        for(int i=0;i<2;i++)
        {
            for(int j=0;j<n;j++)sf("%d",&ara[i][j]);
        }

        memset(dp,-1,sizeof dp);
        pf("%d\n",Solve(0,0));
    }
    return 0;
}
 









 




























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

int main() {
	// your code goes here
	int a[100]={0};
	for(int i=0;i<12;i++) cin>>a[i];
	sort(a,a+12);
	for(int i=0;i+3<12;i+=4){
		if(a[i]==a[i+1]&&a[i+1]==a[i+2]&&a[i+2]==a[i+3]) continue;
		else{
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 3116
n, m = gets.split.map(&:to_i)
s, c = m.times.map { gets.split.map(&:to_i) }.transpose

num = Array.new(n, nil)

m.times do |i|
  tmp = num[s[i] - 1]
  if tmp && tmp != c[i] # すでに違う数が決まっている
    puts "-1"
    exit
  end
  num[s[i] - 1] = c[i]
end

# 0は1桁の整数
if n == 1 && num[0] == 0
  puts 0
  exit
end
# 先頭の0連続する0消す
while num[0] == 0
  num.shift
end
if num.size != n
  puts "-1"
  exit
end
if num[0] == nil && n == 1
  puts 0
  exit
elsif num[0] == nil
  num[0] = 1
end
num.map! { |x| x == nil ? 0 : x }
puts num * ""


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

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int res = 0;
  rep(i,N) {
    string t = s.substr(i);
    auto lcp = z_algorithm(t);
    rep(j,t.size()) {
      int l = min(lcp[j],j);
      res = max(res,l);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

        char[] Sarr = S.toCharArray();
        char[] Tarr = T.toCharArray();

        int ans = 0;
        for (int i=0;i<S.length();i++) {
            if (Sarr[i] == Tarr[i]) ans++;
        }

        System.out.println(ans);
    }
}


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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	const int dx[] = {0, 1, 0, -1};
	const int dy[] = {1, 0, -1, 0};
	rep(i, h) rep(j, w){
		if(s[i][j] == '.') continue;
		bool can = false;
		rep(d, 4){
			int x = j + dx[d];
			int y = i + dy[d];
			if(x < 0 || x >= w) continue;
			if(y < 0 || y >= h) continue;
			if(s[y][x] == '.') continue;
			can = true;
		}
		if(!can){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Thu Jan  3 12:23:33 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	ds := make([]int, N)

	for i := range ds {
		fmt.Scan(&ds[i])
	}

	sort.Ints(ds)

	ans := 0
	current := 0
	for i := range ds {
		if current < ds[i] {
			current = ds[i]
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, M;
ll A[100010];

signed main(){
    cin >> N >> M;
    REP(i, N) cin >> A[i];
    ll sum = 0;
    map<ll, ll> mp;
    mp[0]++;
    REP(i, N){
        sum = (sum + A[i]) % M;
        mp[sum]++;
    }
    ll ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second - 1) / 2;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
    int N, a, b;
    int ans = 0;

    scanf("%d%d%d", &N, &a, &b);

    for (int i = 0; N >= i; i++) {
        int tmp = i;
        int c = 0;
        while (0 != tmp) {
            c += tmp%10;
            tmp /= 10;
        }
        if (a <= c && b >= c) {
            ans += i;
        }
    }

    printf("%d\n", ans);
}

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

void solve() {
  int N;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  double avg = (double) sum/N;
  avg = round(avg);
  int cost = 0;
  for (int i = 0; i < N; i++) {
    int dist = abs(a[i] - avg);
    cost += dist*dist;
  }
  cout << cost;
}


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


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if 500*i + 100*j + 50*k == x:
                count +=1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a+b==15) {
    cout << "+" << endl;
  }
  else if(a*b==15) {
    cout << "*" << endl;
  }
  else {
    cout << "x" << endl;
  }
}

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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg int n = read(), cnt = 0, k = read();
    for (reg int i = 1; i <= n; i++) {
        reg int x = read();
        if (x >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    int N;
    cin>>N;
    int ans;
    ans = N/2 - 1 * (N%2==0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int N ;
    cin >> N;
    int a[4];
    for(int j = 0 ; j < 4 ; j++){
         a[j] = 0  ;
    }
    string s ;
    for(int i = 0 ; i < N ; i++){
        cin >> s ;
        if(s == "AC"){
            a[0]++ ;
        }else if(s== "WA"){
            a[1]++ ;
        }else if(s == "TLE"){
            a[2]++ ;
        }else if(s == "RE"){
            a[3]++ ;
        }
    }

    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3636
use proconio::input;

fn main(){
  input! {
    N:i32,
    M:i32,
    A:[i32; M],
  }
  let mut free = N;
  for var in A.iter() {
    free -= var;
  }
  if free < 0 {
    free = -1;
  }
  println!{"{}",free};
}

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

using namespace std;
typedef long long ll;
int _w;

int main() {
	int a, b, c;
	ll k;
	cin >> a >> b >> c >> k;
	if( k & 1 ) cout << b-a << endl;
	else cout << a-b << endl;
	return 0;
}


Measured memory_bytes: 764
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> c;

void mk_c(){
    c.resize(3100);
    for(int i=1;i<2100;i++){
        c[i].resize(3100);
        c[i][0]=1;
        c[i][i]=1;
        for(int t=1;t<i;t++){
            c[i][t]=(c[i-1][t-1]+c[i-1][t])%MOD;
        }
    }
}

int main(){
    ll n,k;
    cin>>n>>k;
    n-=k;
    if(n<0){cout<<0<<endl; return 0;}
    if(n==0){cout<<1<<endl; return 0;}
    mk_c();
    cout<<c[n+k-1][k-1]<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 53748
#include<bits/stdc++.h>
using namespace std;
int main()
  {long int n;
   cin>>n;
   vector<long int> v;
   for(long int i=0;i<n;i++)
   {long int val;
    cin>>val;
    v.push_back(val);
   }
   long int min=v[0],count=0;
   for(long int i=0;i<n;i++)
   {if(v[i]<=min)
   {min=v[i];
    count++;}
   }
   cout<<count;
  }
   

Measured memory_bytes: 2420
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var one = nextIntArray();
	var H = one[0];
	var W = one[1];
	var list = new Array(H);
	for(var i = 0; i < H; i++){
		list[i] = nextCharArray();
	}
	var output = 0;
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	for(var i = 0; i < H; i++){
		for(var j = 0; j < W; j++){
			if(list[i][j] == "."){
				output = Math.max(output, bfs(i,j));
			}
		}
	}
	myout(output);
	function bfs(y,x){
		var ret = 0;
		var access = new Array(H);
		var count = new Array(H);
		for(var i = 0; i < H; i++){
			access[i] = new Array(W).fill(false);
			count[i] = new Array(W).fill(0);
		}
		access[y][x] = true;
		var queue = [[y,x]];
		while(queue.length > 0){
			var tmp = queue.shift();	
			ret = Math.max(ret, count[tmp[0]][tmp[1]]);
			for(var i = 0; i < 4; i++){
				var nextY = tmp[0] + dy[i];
				var nextX = tmp[1] + dx[i];
				if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W){
					if(!access[nextY][nextX] && list[nextY][nextX] == "."){
						access[nextY][nextX] = true;
						count[nextY][nextX] = count[tmp[0]][tmp[1]] + 1;
						queue.push([nextY,nextX]);
					}
				}
			}
		}
		return ret;
	}
}


Measured memory_bytes: 10664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<int> A;

int main() {
	int N;
	cin >> N;
	int x;
	FOR (i, N) {
		cin >> x;
		A.pb(x);
	}
	sort(all(A));
	int a = 0, b = 0;
	for (int i = A.sz - 1; i > 0; i--) {
		if (A[i] == A[i - 1]) {
			if (a == 0)
				a = A[i];
			else if (b == 0)
				b = A[i];
			i--;
		}
	}
	cout << (1LL * a * b) << endl;
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = (b-a)*(b-a+1)/2 - b;
	cout << ans << endl;
	return 0;
}


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

string a, b;
int main(){
	cin >> a >> b;
	int n = b.size();
	for(int i = 0;i < n;i++){
		cout << a[i] << b[i];
	}
	if(a.size() > b.size())cout << a[n];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut gather_indexes = vec![];
    let mut before = 'R';
    for (i, c) in s.chars().enumerate().skip(1) {
        if before == 'R' && c == 'L' {
            gather_indexes.push(i - 1);
        }
        before = c;
    }
    let mut gather_index = 0;
    let mut ans = vec![0; s.len()];
    for (i, c) in s.chars().enumerate() {
        // dbg!(s.clone(), c, i, gather_index, gather_indexes.clone());
        if c == 'L' {
            if (std::cmp::max(gather_indexes[gather_index], i)
                - std::cmp::min(gather_indexes[gather_index], i))
                % 2
                == 0
            {
                ans[gather_indexes[gather_index]] += 1;
            } else {
                ans[gather_indexes[gather_index] + 1] += 1;
            }
        } else {
            if gather_indexes[gather_index] == i {
                ans[gather_indexes[gather_index]] += 1;
            // dbg!("1");
            } else if gather_indexes[gather_index] > i {
                if (std::cmp::max(gather_indexes[gather_index], i)
                    - std::cmp::min(gather_indexes[gather_index], i))
                    % 2
                    == 0
                {
                    ans[gather_indexes[gather_index]] += 1;
                // dbg!("2");
                } else {
                    ans[gather_indexes[gather_index] + 1] += 1;
                    // dbg!("3");
                }
            } else if (std::cmp::max(gather_indexes[gather_index + 1], i)
                - std::cmp::min(gather_indexes[gather_index + 1], i))
                % 2
                == 0
            {
                ans[gather_indexes[gather_index + 1]] += 1;
            // dbg!("2");
            } else {
                ans[gather_indexes[gather_index + 1] + 1] += 1;
                // dbg!("3");
            }
        }
        // dbg!(ans.clone());
        if gather_index == gather_indexes.len() - 1 {
            continue;
        }
        if gather_indexes[gather_index + 1] == i + 1 {
            gather_index += 1;
        }
    }
    println!(
        "{}",
        ans.iter()
            .map(|c| c.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}


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

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

    string s,t;

    cin>>s>>t;

    s+=t[t.size()-1];

    if(s == t){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

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

  string s;
  cin >> s;

  if (s.length() == 2) {
    cout << s << endl;
  } else {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll n,k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
    }else{
        cout << n-k << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[100000];
    char pre;
    int count = 0;
    int i = 1;
    
    scanf("%s", s);

    pre = s[0];
    while(s[i]){
        if(s[i] == pre){
            count++;
            if(pre == '0'){
                s[i] = '1';
            }else{
                s[i] = '0';
            }
        }
        
        pre = s[i];
        i++;
    }
    
    printf("%d", count);
    
    return 0;
}

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

int main(){
  int n,m,sum=0;
  cin>>n>>m;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  sort(arr,arr+n);
  for(int i=0;i<m;i++){
    sum+=arr[i];
  }
  cout<<sum<<"\n";
}

Measured memory_bytes: 3612
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;


//
// DSU
//

#[derive(Debug, Clone)]
struct DSU {
    v: Vec<usize>,
    n: usize,
}

#[allow(dead_code)]
impl DSU {
    fn new(size: usize) -> DSU {
        let mut v = vec![0; size];
        for i in 0..size {
            v[i] = i;
        }
        DSU { v: v, n: size }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.v[x] == x {
            x
        } else {
            self.v[x] = self.find(self.v[x]);
            self.v[x]
        }
    }

    fn is_same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

    fn unify(&mut self, x: usize, y: usize) {
        let xx = self.find(x);
        let yy = self.find(y);
        if xx != yy {
            self.v[yy] = xx;
        }
    }
}



//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        m:usize,
        ab:[(Usize1,Usize1);m],
    }

    let mut d = DSU::new(n);
    for x in &ab {
        d.unify(x.0,x.1);
    }

    let mut group_size = vec![0;n];
    for i in 0..n {
        group_size[d.find(i)] += 1;
    }
    let mut ans = 0;
    for i in 0..n {
        ans = max(ans, group_size[i]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 9836
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int, int>> v;
	for (int i = 0; i < n; ++i) {
		int x, l;
		scanf("%d%d", &x, &l);
		v.emplace_back(x + l, x - l);
	}
	sort(v.begin(), v.end());
	int en = INT_MIN;
	int ans = 0;
	for (auto& x : v) {
		if (x.second >= en) {
			++ans;
			en = x.first;
		}
	}
	printf("%d\n", ans);
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0LL, c - (a - b)) << endl;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
li2 = li.copy()
so0 = sorted(li)

diffs = dict()
for i in range(len(li)-1):
    diffs[i]= so0[i+1]-so0[i]
soDiffs = sorted(diffs.items(),key=lambda pair: pair[1])
# print(soDiffs)
ma = 0
for idx,diff in soDiffs:
    so= so0.copy()
    d=so[idx]
    c=so[idx+1]
    # print(c,d)
    so.remove(c)
    so.remove(d)
    a,b = so[-2:]
    exp = (a+b)/(c-d)
    # print(exp)
    if exp > ma:
        ma = exp
    else:
        print(ma)
        break



Measured memory_bytes: 5720
H, W = map(int, input().split())
A_list = []
for i in range(H):
    A = input()
    A_list.append(A)
str1 = ["#" for _ in range(W+2)]
str1 = "".join(str1)
for i in range(H+2):
    if i==0 or i==H+1:
        print(str1)
    else:
        print("#"+A_list[i-1]+"#")

Measured memory_bytes: 3060