akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 1e9 + 7;
const int N = 310000;
int a[N];
int zz = 'z' + 1;
string work(pair < int, int > x, int k, string s){
    int l = x.F;
    int r = x.S;
    int len = r - l + 1;
    string t = s;
    int n = s.length();
    for (int i = 0; i < n; i++){
        t[i] = s[n - i - 1];
    }
    t = s + t;
    if (len >= n){
        for (int i = 0; i < n; i++){
            char p = zz;
            cout << p;
        }
        exit(0);
    }
    if (k == 1){
        return t.substr(l, n);
    }
    if (r == n - 1){
        return work({r - 2 * len + 1, r}, k - 1, t.substr(len, n));
    }
    return work({n - len, n - 1}, k - 1, t.substr(n - l, n));
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++){
        if (s[i] < zz){
            zz = s[i];
        }
    }
    vector < pair < int, int > > v;
    for (int i = 0; i < n; i++){
        if (s[i] != zz) continue;
        int l = i;
        int r = i;
        while(r + 1 < n && s[r + 1] == zz){
            r++;
        }
        i = r + 1;
        v.pb({l, r});
    }
    int r = n - 1;
    int l = n - 1;
    while(l > 0 && s[l - 1] == zz) l--;
    if (s[r] == zz) v.pb({l, r});
    string ans = s;
    if (k > 20){
        for (int i = 0; i < n; i++){
            char p = zz;
            cout << p;
        }
        return 0;
    }
    for (auto i: v) ans = min(ans, work(i, k, s));
    cout << ans;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] lo = reader.readLine().split(" ");
		int n = Integer.parseInt(lo[0]);
		int m = Integer.parseInt(lo[1]);
		int k = Integer.parseInt(lo[2]);
		int[] As = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] Bs = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		long[] psumA = new long[n+1];
		long[] psumB = new long[m+1];
		psumA[0] = 0;
		psumB[0] = 0;
		for(int i = 1;i<n+1;i++) psumA[i] = psumA[i-1]+As[i-1];
		for(int i = 1;i<m+1;i++) psumB[i] = psumB[i-1]+Bs[i-1];
		int j = m;
		int res = 0;
		for(int i = 0;i<n+1;i++){
			if(psumA[i]>k) break;
			while(j>=0 && psumB[j]>k-psumA[i]){
				j--;
			}
			if(j>=0 && psumB[j] <= k-psumA[i]) res = Math.max(res,i+j);
			//if(j<0 && (k-psumA[i])>=0) res= Math.max(res,i+1);
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 78656
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf 2147480000
using namespace std;
const int mo=1000000007;
const int N=300005;
int n,A,B,f[25][25],q[25];
int ans[N],tr[25];
void divide(int n,int v){
	if (n==1){
		ans[1]=1;
		return;
	}
	For(i,1,n-1) For(j,0,min(i,n-i-1))
		if (f[n-1][i]&&2*j+1==v){
			//printf("%d %d %d %d\n",n-1,v,i,j);
			divide(n-1,i);
			ans[(1<<(n-1))]=1;
			int cnt=1;
			memset(tr,0,sizeof(tr));
			For(k,1,j) tr[k]=++cnt;
			For(k,1,j) tr[k+i]=++cnt;
			For(k,1,n-1) if (!tr[k]) tr[k]=++cnt;
			For(k,1,(1<<(n-1))-1) ans[k]=tr[ans[k]];
			For(k,1,(1<<(n-1))-1) ans[k+(1<<(n-1))]=(ans[k]<=2*j+1?2*j+3-ans[k]:ans[k]);
			//For(k,1,(1<<n)-1) printf("%d ",ans[k]);
			//puts("");
			return;
		}
}
int main(){
	scanf("%d%d%d",&n,&A,&B);
	f[1][1]=1;
	For(i,1,n-1) For(j,1,i) For(k,0,min(j,i-j)) f[i+1][2*k+1]|=f[i][j];
	int dif=A^B;
	For(i,0,n-1) if (dif&(1<<i)) q[++*q]=i;
	if (!f[n][*q]) return puts("NO"),0;
	puts("YES");
	divide(n,*q);
	For(i,0,n-1) if (!(dif&(1<<i))) q[++*q]=i;
	ans[0]=A;
	For(i,1,(1<<n)-1)
		ans[i]=ans[i-1]^(1<<(q[ans[i]]));
	For(i,0,(1<<n)-1) printf("%d ",ans[i]);
}
/*
1
01
111
001
0111
0001
00111
00001
011111
000111
000001
1111111
0011111
0000111
0000001

*/ 

Measured memory_bytes: 1536
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 5050, mod = 1e9 + 7;
ll n, s, ans = 1ll<<60;
ll f(ll b, ll n) {
	if(n < b) return n;
	return f(b, n/b) + (n%b);
}
void check(ll b) {
	if(b > 1 && f(b, n) == s) {
		ans = min(ans, b);
	}
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> s;
	if(n < s) return cout << -1, 0;
	check(n+1);
	for(ll i = 1; i * i <= n; i++) {
		check(i);
		check((n-s+i)/i);
	}
	if(ans == 1ll<<60) ans = -1;
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if (d * d >= x * x + y * y)
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[55],ans;
int main(void){
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ans=(a[0]+a[1])/2;
	for(int i=2;i<n;i++){
		ans=(ans+a[i])/2;
	}
	cout<<std::setprecision(10)<<ans<<endl;
	    
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
using namespace std;
int main(){
    long long ans=(1<<30);
   int N,M,X;cin>>N>>M>>X;
   vector<vector<int> > V(N,vector<int>(M+1));
   for (int i = 0; i < N; i++) {
    for (int j = 0; j < M+1; j++) {
      cin >> V.at(i).at(j);
    }
  }
  for (int bit=0;bit<(1<<N);bit++){
      int f=0;
      long long now=0;
      vector<int>d(M);
      for(int i=0;i<N;i++){

          if(bit& (1<<i)){
              now+=V[i][0];
              for(int j=1;j<M+1;j++){
                  d[j-1]+=V[i][j];
              }
          }
      }
      for(int i=0;i<M;i++ ){
          //cout<<d[i]<<" ";
          if(d[i]<X)f=1;
      }
      //cout<<" "<<endl;
      if (f==0)ans=min(now,ans);
      //cout<<"ans:"<<ans<<endl;
  }
  if(ans==(1<<30))ans=-1;
  cout<<ans<<endl;
 
}



Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	rep(i, 3) {
		if (s.at(i) == s.at(i + 1)) {
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
x, n = list(map(int, input().split()))
if n > 0:
  p = list(map(int, input().split()))
else:
  p = []
for i in range(0, 100):
  if x - i not in p:
    print(x - i)
    break
  elif x + i not in p:
    print(x + i)
    break

Measured memory_bytes: 9156
#include<iostream>

using namespace std;

int main(){
    int height, width;
    cin >> height >> width;

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

    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(a[i][j]=='.'){
                int counter = 0;
                if(a[i-1][j-1]=='#' && i>0 && j>0)counter++;
                if(a[i-1][j]=='#' && i>0)counter++;
                if(a[i-1][j+1]=='#' && i>0 && j<width-1)counter++;
                if(a[i][j-1]=='#' && j>0)counter++;
                if(a[i][j+1]=='#' && j<width-1)counter++;
                if(a[i+1][j-1]=='#' && i<height-1 && j>0)counter++;
                if(a[i+1][j]=='#' && i<height-1)counter++;
                if(a[i+1][j+1]=='#' && i<height-1 && j<width-1)counter++;
                a[i][j] = char(int('0')+counter);
                //cout << a[i][j] << counter << endl;
            }
        }
    }
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++)cout << a[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a , b , c;
    cin>>a>>b>>c;
    if(b-a==c-b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
def main(n: int, a: int, b: int, s: str):
    _a, _b = 0, 0
    a_b = a + b

    for _s in s:
        if _s == 'c':
            print('No')
            continue

        if _s == 'a':
            if (_a + _b) < a_b:
                print('Yes')
                _a += 1
            else:
                print('No')
        elif _s == 'b':
            if (_a + _b) < a_b and _b < b:
                print('Yes')
                _b += 1
            else:
                print('No')


if __name__ == "__main__":
    n, a, b = map(int, input().split())
    s = input()

    main(n, a, b, s)


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int answer = 0;
  
  if(a<b){
    answer = a;
    if(b<c){
      answer += b;
    }else{
      answer += c;
    }
  }else{
    answer = b;
    if(a<c){
      answer += a;
    }else{
      answer += c;
    }
  }
  
  cout << answer << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    vll A(N),B(N);
    REP(i,N){
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for(int i=N-1; i>=0; i--){
        ll nA = A[i] + ans;
        ll cnt = nA/B[i];
        if(0 != nA%B[i]){
            cnt++;
        }
        ans += B[i]*cnt-nA;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll INF=(1e18)+1;

const ll mod=998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    ll n,s;
    cin >> n >> s;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<vector<vector<mint>>> dp(n+1,vector<vector<mint>>(s+1,vector<mint>(3)));
    dp[0][0][0]=1;
    rep(i,n){
        for(ll j=0;j<=s;j++){
            dp[i+1][j][0]+=dp[i][j][0];
            dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
            dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2];
            if(j+a[i]<=s){
                dp[i+1][j+a[i]][1]+=dp[i][j][0]+dp[i][j][1];
                dp[i+1][j+a[i]][2]+=dp[i][j][0]+dp[i][j][1];
                
            }
        }
    }
    cout << dp[n][s][2] << endl;
    return 0;
}

Measured memory_bytes: 511704
# スペース区切りの整数の入力
my $input = <STDIN>;
chomp $input;
my ($a, $b, $c) = split / /, $input;
$ret = $a.$b.$c;

# 4の除算であまりがあるかどうか調べる
$mod = $ret % 4;

if ($mod == 0) {
 print "YES\n";
}
else
{
 print "NO\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;


int main(void){
  int N, t=0; 
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++) cin >> v[i];
  for(int i=0;i<N;i++){
    for(int j=N-1; j>i;j--){
      if(v[j-1] > v[j]){
        swap(v[j-1], v[j]);
        t++;
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << v[i];
    if(i != N-1)cout << " ";
    else cout << endl;
  }
  cout << t << endl;
  return 0; 
}

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

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

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

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;

    ll c1;
    if (A % C == 0) {
        c1 = A / C;
    } else {
        c1 = A / C + 1;
    }

    ll c2;
    if (B / C == 0) {
        c2 = B / C;
    } else {
        c2 = B / C;
    }

    ll d1;
    if (A % D == 0) {
        d1 = A / D;
    } else {
        d1 = A / D + 1;
    }

    ll d2;
    if (B / D == 0) {
        d2 = B / D;
    } else {
        d2 = B / D;
    }

    ll cd1;
    ll t = lcm(C, D);
    if (A % t == 0) {
        cd1 = A / t;
    } else {
        cd1 = A / t + 1;
    }

    ll cd2;
    if (B / t == 0) {
        cd2 = B / t;
    } else {
        cd2 = B / t;
    }

    ll c3 = c2 - c1 + 1;
    ll d3 = d2 - d1 + 1;
    ll cd3 = cd2 - cd1 + 1;
    cout << B - A + 1 - c3 - d3 + cd3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  int N,k=1,i;
  scanf("%d",&N);
  char S[N][11];
  for(i=0;i<N;i++)
    scanf("%s",&S[i]);
  qsort(S,N,11,strcmp);
  for(i=1;i<N;i++){
    if(strcmp(S[i],S[i-1])!=0)
      k++;
  }
  printf("%d",k);
  return 0;
}

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

using namespace std;

int main() {
  int x, y, s;

  while(cin >> x >> y >> s && x) {
    int ans = 0;
    for(int i = 1; i < s; i++) {
      for(int j = 1; j < s; j++) {
        if((100 + x) * i / 100 + (100 + x) * j / 100 == s) {
          ans = max(ans, (100 + y) * i / 100 + (100 + y) * j /100);
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,k,i,j;
    j=0;
    cin>>n>>k;
    while(n)
    {
        n=n/k;
        j++;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 501000,mod2 = 1000000007,mod1 = 998244353;
ll *p1,_p1[N],*p2,_p2[N],h1[N],h2[N];
int W[N],n;
char s[N];
map<pair<ll,ll>,int> mp;
ll fp(ll a,ll k,ll mod){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	cin>>s+1;
	p1=_p1+n+10;p1[-n]=1;
	for(int i=-n+1;i<=n;i++) p1[i]=p1[i-1]*434783%mod1;
	p2=_p2+n+10;p2[-n]=1;
	for(int i=-n+1;i<=n;i++) p2[i]=p2[i-1]*434783%mod2;
	ll hsh1=0,hsh2=0;
	int w=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='<') w--;
		if(s[i]=='>') w++;
		W[i]=w;
		if(s[i]=='+'){
			h1[i]=p1[w];h2[i]=p2[w];
			hsh1=(hsh1+p1[w])%mod1;
			hsh2=(hsh2+p2[w])%mod2;
		}
		if(s[i]=='-'){
			h1[i]=mod1-p1[w];
			h2[i]=mod2-p2[w];
			hsh1=(hsh1-p1[w]+mod1)%mod1;
			hsh2=(hsh2-p2[w]+mod2)%mod2;
		}
		mp[make_pair(hsh1,hsh2)]++;
	}
	ll now1=0,now2=0,ans=0;
	for(int i=1;i<=n;i++){
		if(W[i-1]>0) ans+=mp[make_pair((hsh1*fp(434783,W[i-1],mod1)+now1)%mod1,(hsh2*fp(434783,W[i-1],mod2)+now2)%mod2)];
		else ans+=mp[make_pair((hsh1*fp(743624691,-W[i-1],mod1)+now1)%mod1,(hsh2*fp(620380746,-W[i-1],mod2)+now2)%mod2)];
		if(s[i]=='-'||s[i]=='+') now1=(now1+h1[i])%mod1,now2=(now2+h2[i])%mod2;
		mp[make_pair(now1,now2)]--;
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;
typedef long long int lint;

void answer()
{
	int n, b, f, r, v;
	int map[8][4][16] = { 0 };
	
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;

		map[b][f][r] += v;
	}

	for (b = 1; b <= 4; b++) {
		if (b != 1) cout << "####################" << endl;
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) {
				cout << " " << map[b][f][r];
			}
			cout << endl;
		}
	}
}

int main()
{
	answer();
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main()  {
	var n, m int
	fmt.Scan(&n, &m)

	a := make([]int, m)
	dp := make([]int, n+2)
	broken := make([]bool, n+2)
	dp[n] = 1
	for i:= range a {
		fmt.Scan(&a[i])
		broken[a[i]] = true
	}
	for i:=n-1; i>=0; i-- {
		if (broken[i]) {
			dp[i] = 0
		} else {
			dp[i] = (dp[i+1] + dp[i+2]) % 1000000007
		}
	}
	fmt.Println(dp[0])
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  map<pair<string, int>, int> m;
  vector<pair<string, int>> list;
  int n;
  cin >> n;

  rep(i,n) {
    string s;
    int num;
    cin >> s >> num;
    list.push_back(make_pair(s, num));
    m.insert(make_pair(make_pair(s, num), i+1));
  }

  sort(list.begin(), list.end());

  list.push_back(make_pair("", INF)); // 番兵

  string before = "";
  vector<int> tmp;
  for (auto x : list) {
    if  (before == x.first) {
      tmp.push_back(x.second);
    } else {
      if (tmp.size() != 0) {
        reverse(tmp.begin(), tmp.end());
        for (auto y : tmp) {
          cout << m.at(make_pair(before, y)) << endl;
        }
        tmp.clear();
      }
      tmp.push_back(x.second);
      before = x.first;
    }
  }
}


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

int main(){
	int n, a, b;
	
	while(cin>>n>>a>>b){
		if(a > b || (n == 1 && a != b)){
			cout<<'0'<<endl;
		}
		else if( n == 1 && a == b){
			cout<<'1'<<endl;
		}
		else{
			cout<<(long long )(b-a)*(n-2)+1<<endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc171/tasks/abc171_b
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n, k;
	cin >> n >> k;
	vector<int> p (n);
	for (auto&x:p) {
		cin >> x;
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <cmath>
#include <iostream>
#include <vector>
#include <string>

int main()
{
    int n,m,i,j,l,on,ans=0,light;
    int s[10][10],k[10],p[10];//[電球番号][スイッチ]
    
    std::cin>>n>>m;
    for(i=0;i<m;i++)
    {
        std::cin>>k[i];
        for(j=0;j<k[i];j++)
        {
            std::cin>>s[i][j];
        }
    }
    for(i=0;i<m;i++)
        std::cin>>p[i];
    
    for(i=0;i<(int)pow(2,n);i++)
    {
        light=0;
        for(j=0;j<m;j++)
        {
            on=0;
            for(l=0;l<k[j];l++)
            {
                if((i%(int)pow(2,s[j][l]))/(int)pow(2,s[j][l]-1)==1)
                {
                    
                    on++;
                }
            }
            if(on%2==p[j])
                light++;
        }
        if(light==m)
            ans++;
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
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();
      if((a*b)%2!=0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }


  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Binary Indexed Tree
//添字は1から始まる！！
//v[a] += w
ll n=500004; //bit[1]~bit[n]を使用するということ
vector<vector<ll>> bit(500005, vector<ll>(26, 0));
void add(ll a, ll w, char c){
    for(ll x=a; x<=n; x+=x&-x) bit[x][c-'a']+=w;
}
//v[1]+...+v[a]
ll sum(ll a, char c){
    if(a==0) return 0;
    ll ret=0;
    for(ll x=a; x>0; x-=x&-x) ret+=bit[x][c-'a'];
    return ret;
}

int main(){
    ll n; cin>>n;
    string s; cin>>s;
    ll q; cin>>q;
    rep(i,n){
        add(i+1, 1, s[i]);
    }
    rep(i,q){
        ll id; cin>>id;
        if(id==1){
            ll iq; cin>>iq;
            char cq; cin>>cq;
            add(iq, -1, s[iq-1]);
            add(iq, 1, cq);
            s[iq-1]=cq;
        }else{
            ll lq, rq; cin>>lq>>rq;
            ll res=0;
            rep(j, 26){
                if(sum(rq, ('a'+j)) - sum(lq-1, ('a'+j)) > 0) res++;
            }
            cout<<res<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 121988
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


int main() { 
	long long init = 100;
	long long x; cin>> x;
	long long ans = 0;
	while (init < x) {
		ans++;
		init += (long long)init*1.0/100;
	}
	cout<<ans;
	return 0;
} 
 



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

int main() {
    string s;
    cin >> s;
    
    if ((s == "AAA") || (s == "BBB")) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
x=int(input())
flag=1
prime=[]
num=2
while flag!=0:
    f=0
    for p in prime:
        if num%p==0:
            f=1
            break
    if f==0:
        prime.append(num)
        if x<=num:
            flag=0
    if flag==0:
        break
    else:
        num+=1
print(num)


Measured memory_bytes: 73340
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    size_t max_idx = std::distance(l.begin(), std::max_element(l.begin(), l.end()));

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i != max_idx) {
            sum += l[i];
        }
    }

    if (l[max_idx] < sum) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;

public class Main {
  public static void main(String[] args) throws Exception {
    int max = 0;
    final Map<String, AtomicInteger> map = new TreeMap<>();

    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      int n = Integer.parseInt(br.readLine());
      for (int i = 0; i < n; i++) {
        String s = br.readLine();
        AtomicInteger c = map.get(s);
        int val = 1;
        if (c == null) {
          map.put(s, new AtomicInteger(1));
        } else {
          val = c.incrementAndGet();
        }
        if (val > max) {
          max = val;
        }
      }
    }
    try (PrintWriter pw = new PrintWriter(System.out)) {
      for (Map.Entry<String, AtomicInteger> e : map.entrySet()) {
        if (e.getValue().get() == max) {
          pw.println(e.getKey());
        }
      }
    }
  }
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int A, B;
  cin >> A >> B;
  if (A < 10 && B < 10) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


const int G = 30000;

using BS = bitset<G*2>;


int main(){
  int H,W;
  while(cin >> H >> W){
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    cin >> A >> B;
    dump(A, B);

    vector<vector<int>> D(H, vector<int>(W));
    REP(i,H){
      REP(j,W){
        D[i][j] = A[i][j] - B[i][j];
      }
    }


    queue<pair<int,int>> q;
    vector<vector<bool>> v(H, vector<bool>(W));
    q.push(make_pair(0, 0));

    vector<vector<BS>> memo(H, vector<BS>(W));
    memo[0][0].set(G);
    
    while(q.size()){
      auto cur = q.front();
      q.pop();

      int i, j; tie(i,j) = cur;

      if(v[i][j]) continue;
      v[i][j] = true;


      if(i < H-1){
        memo[i+1][j] |= memo[i][j] << abs(D[i][j]);
        memo[i+1][j] |= memo[i][j] >> abs(D[i][j]);
        q.push(make_pair(i+1, j));
      }
      
      if(j < W-1){
        memo[i][j+1] |= memo[i][j] << abs(D[i][j]);
        memo[i][j+1] |= memo[i][j] >> abs(D[i][j]);
        q.push(make_pair(i,j+1));
      }
    }

    BS t;

    t |= memo[H-1][W-1] << abs(D[H-1][W-1]);
    t |= memo[H-1][W-1] >> abs(D[H-1][W-1]);

    

    int ans = INT_MAX;
    
    FORE(i,-100,100){
      if(t.test(G+i)){
        chmin(ans, abs(i));
      }
      
    }

    //dump(memo[H-1][W-1]);
    
    cout << ans << endl;
    

    
  }

  return 0;
}


Measured memory_bytes: 48000
#include<cstdio>
#include<iostream>
using namespace std;
long long n,a,b,ans;
int main()
{
	cin>>n>>a>>b;
	ans=n/(a+b)*a;
	b=n-(n/(a+b)*(a+b));
	if(b>a) ans+=a;
	else ans+=b;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

vector <ll> enm_divisorsb(ll N){
    vector <ll> res;
    for (ll i=1; i*i<=N; i++){
        if(N%i==0) res.push_back(i);
        else continue;
    }
    return res;
    }
int main(){
    ll N; cin>>N;
    vector<ll> a=enm_divisorsb(N);
    ll sizea=a.size();
    ll count1=0;
    ll count2=0;
    ll notrest=a[sizea-1];
    while(notrest!=0){
        notrest/=10;
        count1++;
    }
    ll rest=N/a[sizea-1];
    while(rest!=0){
        rest/=10;
        count2++;
    }

    cout<<max(count1,count2)<<endl;




}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

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

int main() {
	int n; cin >> n;
	ll t[103];
	for (int i = 0; i < n; ++i) cin >> t[i];
	ll ans = 1;
	for (int i = 0; i < n; ++i) {
		ans = ans / gcd(ans, t[i]) * t[i];
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
  int i;
  char s[100];
  int x[100];
  for(i=0;i<100;i++){
    x[i]=0;
  }
  i=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x[i-2]=x[i-1]+x[i-2];
      i--;
    }else if(s[0]=='-'){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    }else if(s[0]=='*'){
      x[i-2]=x[i-1]*x[i-2];
      i--;
    }else{
      x[i]=atoi(s);
      i++;
    }
  }
  printf("%d\n",x[i-1]);

  return 0;
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,m;
vi ed[101010];
bool vis[101010];
map<int,map<int,bool> > mm;
void dfs(int x){
	vis[x]=1;
	fo(i,0,ed[x].size()) if(!vis[ed[x][i]])dfs(ed[x][i]);
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m;
	fo(i,0,m){
		int x,y,z;
		cin>>x>>y>>z;
		--x;--y;
		if(!mm[x][y]){
			ed[x].pb(y);
			ed[y].pb(x);
			mm[x][y]=1;
		}
	}
	int ans=0;
	fo(i,0,n) if(!vis[i]){
		dfs(i);
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 21504
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
int n,T,A,ans,x[1100],bes;
int main(){
	scanf("%d%d%d",&n,&T,&A);
	A*=1000;T*=1000;
	fo(i,1,n) scanf("%d",&x[i]);
	ans=1;bes=abs(T-x[1]*6-A);
	fo(i,2,n) if (abs(T-x[i]*6-A)<bes){
		ans=i;
		bes=abs(T-x[i]*6-A);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;

  if(x == 1 || x == 2*N-1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    if(x <= N){
      deque<int> v;
      REP(i,1,N+1) v.push_back(i);
      while(v[v.size()-1] != x){
        int a = v[v.size()-1];
        v.pop_back();
        v.push_front(a);
      }
      rep(i,v.size()) cout << v[i] << endl;
      REP(i,N+1,2*N) cout << i << endl;
    }
    else{
      deque<int> v;
      REP(i,1,N) cout << i << endl;;
      REP(i,N,2*N) v.push_back(i);
      while(v[0] != x){
        int a = v[v.size()-1];
        v.pop_back();
        v.push_front(a);
      }
      rep(i,v.size()) cout << v[i] << endl;
    }
  }
    
  return 0;
}



Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<algorithm>
#include <set>
#include<map>

int main()
{
	/*int a, b;
	std::cin >> a >> b;
	auto ave = (a + b) / 2.0;
	ave = ceil(ave);
	std::cout << ave << std::endl;*/

	//std::string s;
	//std::string t;
	//std::cin >> s >> t;
	//std::vector<int> num0;
	//std::vector<int> num1;
	//for (auto it : s) {
	//	num0.push_back(it);
	//}
	//for (auto it : t) {
	//	num1.push_back(it);
	//}
	//std::sort(num0.begin(), num0.end(), [](int a, int b) {return a < b; });
	//std::sort(num1.begin(), num1.end(), [](int a, int b) {return a < b; });//?
	//auto len = (num0.size() < num1.size() ? num0.size() : num1.size());
	//bool eq = false;
	//for (auto c:num0) {
	//	eq = false;
	//	for (auto r : num1) {
	//		if (c < r) {
	//			std::cout << "Yes" << std::endl;
	//			return 0;
	//		}
	//		else if(c==r)
	//		{
	//			eq = true;
	//		}
	//	}
	//	if (!eq) {
	//		std::cout << "No" << std::endl;
	//		return 0;
	//	}
	//}
	//if (eq&&num0.size() < num1.size()) {
	//	std::cout << "Yes" << std::endl;
	//	return 0;
	//}
	//std::cout << "No" << std::endl;
	std::map<int, int> mp;

	std::set<int> s;
	std::vector<int> num;
	{
		int k;
		std::cin >> k;
		for (int i = 0; i < k; ++i) {
			int n;
			std::cin >> n;;
			mp[n]++;
		}

	}
	int ans = 0;
	for (auto p : mp) {
		if (p.first > p.second) {
			ans += p.second;
		}
		else {
			ans += p.second-p.first;
		}
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<62)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vs s(n);
    cin>>s;
    sort(all(s));
    
    
    vs d(n);
    vl c(n,0);
    vector <pair <int,string> > cd(n);
    ll shift=0,ma=1;
    
    cd[0].fs=1;
    cd[0].sc=s[0];
    range(i,1,n){
        if(s[i]==s[i-1]){
            cd[i-shift-1].fs++;
            shift+=1;
            //if(cd[i-shift-1].fs>ma) ma=cd[i-shift-1].fs;
        }else{
            cd[i-shift].sc=s[i];
            cd[i-shift].fs=1;
        }
    }
    
    rep(i,n){
        if(cd[i].fs>ma) ma=cd[i].fs;
    }
    
    rep(i,n){
        if(cd[i].fs==ma) puta(cd[i].sc);
    }
    
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M), B(M); rep(i, M) cin >> A[i] >> B[i];
    
    vector<pii> x(M);
    rep(i, M) x[i] = make_pair(A[i], B[i]);

    sort(x.begin(), x.end(), [](const pii &a, const pii &b) {
        return a.second < b.second;
    });

    int prev = -INF;
    int cnt = 0;
    rep(i, M) {
        if (prev <= x[i].first) {
            prev = x[i].second;
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int n = 0 ; 
    cin >> n ; 
    int a[n+1] = {0} , b[n+1] = {0} , c[n+1] = {0} , happiness[n+1][3] = {{0}} , maxhappiness = 0 ;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i] >> b[i] >> c[i] ;
    happiness[1][0] = a[1] , happiness[1][1] = b[1] , happiness[1][2] = c[1] ;
    for(int i = 2 ; i <= n ; i++){
        happiness[i][0] = a[i] + max(happiness[i-1][1] , happiness[i-1][2]) ;
        happiness[i][1] = b[i] + max(happiness[i-1][0] , happiness[i-1][2]) ;
        happiness[i][2] = c[i] + max(happiness[i-1][1] , happiness[i-1][0]) ;
    }
    maxhappiness = max(happiness[n][0] , max(happiness[n][1] , happiness[n][2])) ;
    cout << maxhappiness ;
}


Measured memory_bytes: 5900
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
  while(true){
    int n;
    cin >> n;
    if(n==0)
      {break;}

    int s[n];
    double sum = 0;
    double sum_dev = 0.0;
    double dev,mean;

    for(int i=0; i<n; i++){
      cin >> s[i];
      sum += s[i];   }
    //    cout <<"debug1 sum = "<< sum << endl;
    
    mean = sum / n;
    //    cout << "debug2 mean = " << mean << endl;
    for(int i=0; i<n; i++){
      sum_dev += pow( s[i] - mean, 2);  }

    dev = sqrt( sum_dev / n );


    cout << fixed << setprecision(8) << dev << endl;
  }  
  return 0;
}



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

int main()
{
  long long a,b,c,d;
  long long ac, ad, bc, bd;
  long long ans;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  
  ac = a*c;
  ad = a*d;
  bc = b*c;
  bd = b*d;
  
  ans = max({ac,ad,bc,bd});
  cout << ans;
}


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(x);

		int[] y = new int[m - 1];
		for (int i = 0; i < m - 1; i++) {
			y[i] = x[i + 1] - x[i];
		}
		Arrays.parallelSort(y);

		int ans = 0;
		int sub = m - n;
		for (int i = 0; i < sub; i++) {
			ans += y[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50796
/*
Problem 0045 : p_sum and Average
*/
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int bomb[14][14];

int burst(int y , int x){
	int i , buf[6] = {-3 , -2 , -1 , 1 , 2 , 3};
	bomb[y][x] = 0;
	for(i=0;i<6;i++){
		if(bomb[y][x+buf[i]] == 1){
			bomb[y][x+buf[i]] = 0;
			burst(y , x+buf[i]);			
		}
		if(bomb[y+buf[i]][x] == 1){
			bomb[y+buf[i]][x] = 0;
			burst(y+buf[i] , x);			
		}
	}
}

int main(void){
	char buf[9][10];
	int n , i , j , k , x , y;
	scanf("%d" , &n);

	for(i=1;i<=n;i++){
		scanf("\n");
		for(j=0;j<=13;j++){
			for(k=0;k<=13;k++){
				bomb[j][k] = 0;
			}
		}
		for(j=1;j<=8;j++){
			scanf("%s" , &buf[j][1]);
		}
		for(j=3;j<=10;j++){
			for(k=3;k<=10;k++){
				bomb[j][k] = buf[j-2][k-2] - '0';
			}
		}
		scanf("%d" , &x);
		scanf("%d" , &y);
		burst(y+2 , x+2);
		printf("Data %d:\n" , i);
		for(j=3;j<=10;j++){
			for(k=3;k<=10;k++){
				printf("%d" , bomb[j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	static int[][] array;
	public static void main(String[] args) {
		// r = ???, c = ?即?
		int r, c;
		Scanner sc = new Scanner(System.in);
		r = Integer.parseInt(sc.next());
		c = Integer.parseInt(sc.next());
		r += 1;
		c += 1;
		array = new int[r][c];
		for (int i=0; i < r; i++) {
			for (int j=0; j < c; j++) {
				if (i == r-1) {
					array[i][j] = getCsum(j, i);
				} else if (j == c-1) {
					array[i][j] = getRsum(i, j);
				} else {
					array[i][j] = Integer.parseInt(sc.next());
				}
			}
		}
		sc.close();
		for (int i=0; i < r; i++) {
			StringBuilder sb = new StringBuilder();
			for (int j=0; j < c; j++) {
				sb.append(array[i][j]).append(' ');
			}
			sb.deleteCharAt(sb.length()-1);
			System.out.println(sb);
		}
	}
	static final int getRsum(int num, int cSize) {
		int sum = 0;
		for (int i=0; i < cSize; i++) {
			sum = sum + array[num][i];
		}
		return sum;
	}
	static final int getCsum(int num, int rSize) {
		int sum = 0;
		for (int i=0; i < rSize; i++){
			sum = sum + array[i][num];
		}
		return sum;
	}
}

Measured memory_bytes: 30996
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  string w; cin >> w;
  map<char, int> mp;
  for(int i = 0; i < w.size(); i++){
    mp[w[i]]++;
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second % 2 != 0){
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
  return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,y,r,s,t,total_point;
    scanf("%d",&n);
    x=n/500;
    y=x*1000;
    r=n%500;
    s=r/5;
    t=s*5;
    total_point=(y+t);
    printf("%d\n",total_point);
    return 0;
}


Measured memory_bytes: 1736
INF = 10 ** 12

n = int(input())
h = list(map(int,input().split()))
dp = [INF] * (n + 5)
dp[0] = 0
for i in range(n - 1):
	dp[i + 1] = min(dp[i + 1],dp[i] + abs(h[i] - h[i + 1]))
	if i + 2 < n:
		dp[i + 2] = min(dp[i + 2],dp[i] + abs(h[i] - h[i + 2]))
print(dp[n - 1])

Measured memory_bytes: 52208