akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
	int in[2]={0};
	
	int i;
	int count=0;
	int rev=0,num=0;
	scanf("%d %d",&in[0],&in[1]);
	
	
	for(i=in[0];i<=in[1];i++){
		
		num=i;
		rev=0;
		while(num>0){
			rev=rev*10+num%10;
			num/=10;
		}
		
		if(i==rev){
			count++;
		}
	}
	
	printf("%d",count);	
	
	return 0;
}

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


int main(){

  int N;
  cin >> N;

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

  int count = 1;
  sort(x,x+N);

  for(int i=1; i<N; i++){
    if(x[i] != x[i-1]){
      count += 1;
    }
  }
  int ans;
  if(count%2 == 0){
    ans = count-1;
  }
  else if(count%2 == 1){
    ans = count;
  }

  cout << ans << endl;

}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>

using namespace std;
int main() {
  uint64_t n, k;
  cin >> n >> k;

  vector<uint64_t> h(n);
  for(uint64_t i = 0; i < n; ++i) {
    cin >> h[i];
  }

  sort(h.begin(), h.end(), greater<uint64_t>());

  if(k >= n) {
    cout << 0 << endl;
  } else {
    h.erase(h.begin(), h.begin() + k);
    auto count = accumulate(h.begin(), h.end(), (uint64_t)0);
    cout << count << endl;
  }

  return 0;
}

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

const string YES = "Yes";

const string NO = "No";

void solve(string S)
{
    for (int i = 0; i < (int)S.size(); i++)
    {
        if ((i % 2 != 0 && S.at(i) == 'R') ||
            (i % 2 == 0 && S.at(i) == 'L'))
        {
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main()
{
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

int n,m,ans=0;
int tri[5001][5001];


int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y,size;
		scanf("%d%d%d",&y,&x,&size);
		tri[x][y]=size+1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			tri[j][i]=max(tri[j][i],max(tri[j-1][i-1],tri[j][i-1])-1);
			if(tri[j][i]>0)ans++;
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 97728
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ans[2]={0},n;
int main()
{
	scanf("%d",&n);
	scanf("%d %d",&ans[0],&ans[1]);
	for(int i=2;i<=n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		if(a>ans[0])
		{
			ans[0]=a,ans[1]=b;
		}
	}
	printf("%d\n",ans[0]+ans[1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W, '0'));
  REP(i, H) REP(j, W) cin >> a[i][j];
  vector<vector<int>> breaked(H, vector<int>(W, 0));
  while (true) {
    bool t = true;
    REP(i, H) {
      int num = -1,cnt=0;
      REP(j, W) {
        if (breaked[i][j] == 1){
          cnt++;
          continue;
      }
        if (a[i][j] != '.') {
          num = j;
          break;
        }
      }
      if (cnt == W) continue;
      if (num == -1) {
        t = false;
        REP(j, W) { breaked[i][j] = 1; }
      }
    }
    REP(i, W) {
      int num = -1,cnt = 0;
      REP(j, H) {
        if (breaked[j][i] == 1) {
          cnt++;
          continue;
        }
        if (a[j][i] != '.') {
          num = j;
          break;
        }
      }
      if (cnt == H) continue;
      if (num == -1) {
        t = false;
        REP(j, H) { breaked[j][i] = 1; }
      }
    }
    if (t) break;
  }
  REP(i, H) {
    bool t = false;
    REP(j, W) {
      
      if (breaked[i][j] != 1){
         cout << a[i][j];
         t = true;
      }
    }
    if (!t) continue;
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    const int NMAX = 85;
    long long n, a[NMAX], sum = 1000, stocks, x, y, nr;
     
    int main()
    {
        cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        int i = 1;
        while(i < n) {
            while(i < n && a[i] >= a[i + 1]) {
                i++;
            }
            x = a[i];
            while(i < n && a[i] <= a[i + 1]) {
                i++;
            }
            y = a[i];
            nr = sum / x;
            stocks += nr;
            sum -= nr * x;
            sum += stocks * y;
            stocks = 0;
        }
        cout << sum;
        return 0;
    }

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int n;
int R[200000];
int maxdR, mdR, dR;

int main(void)
{
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> R[i];
	}
	
	for(int i=0;i<n-1;i++){
		dR = R[n-i-1]-R[n-i-2];
		if (i==0){
			mdR = dR;
			maxdR = mdR;
		}else{
			if (mdR>0){
				mdR += dR;
			}else{
				mdR = dR;
			}
			if (mdR>maxdR){
				maxdR = mdR;
			}
		}
	}
	
	cout << maxdR << endl;
	return 0;
}

Measured memory_bytes: 1940
use std::cmp::Ordering;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(String, usize;n);

    let mut vs = vs.iter().enumerate().collect::<Vec<_>>();
    vs.sort_by(|&(_, v), &(_, v1)| {
        if v.0.cmp(&v1.0) == Ordering::Equal {
            v1.1.cmp(&v.1)
        } else {
            v.0.cmp(&v1.0)
        }
    });
    for v in vs {
        println!("{}", v.0 + 1);
    }
}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))
#define MAXN 110

int v[MAXN];
int n;
map<ll, int> freq;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	vector<ll> div;
	
	ll n, x;
	
	cin >> n >> x;
		
	for(ll i=2; i*i <= x; i++){
		while( (x%i) == 0LL){
			freq[i]++;
			x /= i;
		}
	}
	
	if(x > 1)
		freq[x]++;
	
	ll res = 1LL;
	
	for(auto p : freq){
		for(int i=0; i< (p.second/n); i++)
			res *= p.first;
	}

	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  ;
  cin >> N;
}
void solve() {
  // 6-5-6-5-6-5-...
  int b = (N - 1) / 11 + 1;
  b *= 2;
  int a = N % 11;
  cout << b - (a > 0 && a <= 6) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
a = [int(input())]
i = 0

def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

while True:
    A = f(a[i])
    if A in a:
        break
    else:
        a.append(A)
        i += 1
            
print(i+2)

Measured memory_bytes: 2940
import sys
readline = sys.stdin.readline
from collections import Counter
N = int(readline())
S = [0 if s == 'R' else 1 if s == 'G' else 2 for s in readline().strip()]

MOD = 998244353
R = 0
G = 1
B = 2
nG = 20
nB = 10
nR = 12
non = -1
C = Counter()
C[non] = N
ans = 1
for i in range(3*N):
    s = S[i]
    ns = [nR, nG, nB][s]
    if C[ns]:
        ans = ans*C[ns]%MOD
        C[ns] -= 1
        continue
    if C[(1+s)%3] or C[(2+s)%3]:
        idx = (1+s)%3 if C[(1+s)%3] else (2+s)%3
        ans = ans*C[idx]%MOD
        C[idx] -= 1
        C[[nR, nG, nB][3-idx-s]] += 1
        continue
    ans = ans*C[non]%MOD
    C[non] -= 1
    C[s] += 1
print(ans)

Measured memory_bytes: 61424
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    vector<pll> v(3);
    while(1){
        rep(i,3){
            cin>>v[i].F>>v[i].S;
        }
        if(v[0].F==0) return;
        vll ans(3,0);
        rep(i,3){
            ll pos=1;
            pos=v[i].F*pos%v[i].S;
            ans[i]++;
            while(pos!=1){
                pos=v[i].F*pos%v[i].S;
                ans[i]++;
            }
            // cout<<ans[i]<<" ";
        }
        ll t=ans[0]/__gcd(ans[0],ans[1])*ans[1];
        t=t/__gcd(t,ans[2])*ans[2];
        cout<<t<<endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  else return gcd(b, a % b);
  // return (b == 0) ? a : gcd(b, a % b);
}

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

set<int> yakusu(ll x){
  set<int> yakusu;
  for (int i = 1; i*i <= x; i++) {
    if(x % i == 0){
      yakusu.insert(i);
      yakusu.insert(x / i);
    }
  }
  return yakusu;

}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  sort(ALL(v));
  ll sum = 0;
  rep(i, n) sum += v[i];
  set<int> s = yakusu(sum);
  ll ans = 1;

  for(ll a : s){
    ll need = LLONG_MAX;
    vector<ll> r(n);
    rep(i, n) r[i] = v[i] % a;
    sort(ALL(r));
    ll A = 0, B = 0;
    rep(i,n) B += a-r[i];
    rep(i, n){
     A += r[i];
     B -= a - r[i];
     need = min(need, max(A, B));
    }
    if(need <= k) ans = max(ans, a);
  }
  cout << ans << endl;

}


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


int main() 
{
    ll n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i,n)
    {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i,m)
    {
        int a = q.top();
        q.pop();
        q.push(a / 2);
    }
    ll ans = 0;
    rep(i,n)
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool S[200010];
bool G[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a == 0) S[b] = true;
        if(b == N - 1) G[a] = true;
    }
    rep(i, N) {
        if(S[i] && G[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}


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

int main()
{
    string in;
    int i = 0;
    cin >> in;

    do {
        if (i+1 < in.size() and in[i] == 'h' and in[i + 1] == 'i') {
            i = i + 2;
            if (i == in.size()) {
                break; 
            } else {
                continue;
            }

        } else {
            cout << "No";
            exit(0);
        }
    } while (true);
    cout << "Yes";
}



Measured memory_bytes: 760
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=305;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
int d[N][N],ans[N][N];
int32_t main()
{
    int n=in(),m=in(),L=in();
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=(i==j?0:1e9+1);
    for(int i=1;i<=m;i++){
        int u=in(),v=in(),w=in();
        d[u][v]=min(d[u][v],w);
        d[v][u]=min(d[v][u],w);
    }
    for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) ans[i][j]=i==j?0:d[i][j]<=L?1:1e9;
    for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]);
    int q=in();
    while(q--){
        int u=in(),v=in();
        pf1(ans[u][v]==1e9?-1:ans[u][v]-1);
    }
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 1280
console.log((args=>{
  const [[N,D],...tmp] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  let count = 0;
  for ( let i = 0; i < N; i++ ) {
    let [X,Y] = tmp[i];
    if ( D >= Math.sqrt(X*X+Y*Y) ) count++;
  }
  return count;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 100936
// atcoder/abc176/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s;
  while (cin >> s) {
    int x = 0;
    each (c, s) x = (x + c - '0') % 9;
    cout << (x ? "No" : "Yes") << endl;
  }

  return 0;
}


Measured memory_bytes: 3748
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d})<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	int n,a,b,c;
	while(cin>>n){
		if(n==3){
			cout<<2<<" "<<5<<endl;
		}
		else{
		for(int i=n-1;i>1;i--){
			for(int j=2;j<i;j++){
				c=j;
				if(i%j==0){
					break;
				}
			}
			if(c==i-1){
				a=i;
				break;
				}
		}
		for(int i=n+1;i<100000;i++){
			for(int j=2;j<i;j++){
				c=j;
				if(i%j==0){
					break;
				}
				}
			if(c==i-1){
				b=i;
				break;			
			}
		}
		cout<<a<<" "<<b<<endl;
	}
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1



const int MAX = 100;
char s[MAX];

int main() {
	scanf("%s", s);
	int len = strlen(s);
	int i = 0;
	int ans = 0;
	while(i < len) {
		int j = i;
		if(s[i] == 'R') {
			while(j + 1 < len && s[j + 1] == 'R') j++;
			ans = max(ans, j - i + 1);
		}
		i = j + 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int i,n;
		double sum;
		double rec[];
		double a;

		while(true){
			n = sc.nextInt();
			if(n==0){
				break;
			}
			rec = new double[n];
			sum = 0.0;
			a = 0.0;

			for(i=0;i<n;i++){
				rec[i] = sc.nextDouble();
				sum += rec[i];
			}
			sum /= n;
			for(i=0;i<n;i++){
				a += Math.pow((rec[i]-sum), 2.0);
			}
			a /= n;
			a = Math.sqrt(a);

			System.out.printf("%.8f\n",a);
		}

		sc.close();


	}

}



Measured memory_bytes: 39540
N = int(input())

counter = [0] * N


for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            try:
                counter[n - 1] += 1
            except:
                pass
            
for i in range(N):           
    print(counter[i])

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    int a, b;
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    stack<int> st;
    st.push(0);
    vector<int> par(N, -1);
    par[0] = -1;
    while(!st.empty()){
        int v = st.top(); st.pop();
        for(int w : G[v]){
            if(par[w] == -1){
                par[w] = v;
                st.push(w);
            }
        }
    }

    int d = 0;
    int now = N-1;
    while(now != 0) {
        now = par[now];
        d++;
    }
    d = (d-1) / 2;
    now = N - 1;
    while(d > 0){
        now = par[now];
        d--;
    }
    int m = par[now];

    int cnt = 0;
    vector<bool> used(N, false);
    used[m] = true;
    st.push(now);
    while(!st.empty()){
        int v = st.top(); st.pop();
        cnt++;
        used[v] = true;
        for(int w : G[v]){
            if(used[w]) continue;
            st.push(w);
        }
    }
    if(N - cnt > cnt){
        printf("Fennec\n");
    }
    else{
        printf("Snuke\n");
    }




}

Measured memory_bytes: 8992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    ll n;
    cin >> n;
    deque<int> d;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (i & 1) d.push_back(x);
        else d.push_front(x);
    }
    while (!d.empty()) {
        if (n & 1) {
        cout << d.back() << ' ';
        d.pop_back();
        }
        else {
            cout << d.front() << ' ';
        d.pop_front();
        }
    }
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 101; //N+1
int W_MAX = 100001; //W+1
typedef long long ll;
typedef pair<int,ll> P;
int main()
{
  int n,w,i,j;
  ll v[N_MAX][W_MAX];
  P ww[N_MAX]; //(w,v)
  cin >> n >> w;
  for(i=1;i<=n;i++)
    cin >> ww[i].first >> ww[i].second;
  fill(v[0],v[0]+w+1,0);
  for(i=1;i<=n;i++)
    for(j=0;j<=w;j++)
      if(j<ww[i].first){
        v[i][j]=v[i-1][j];
      }else{
        v[i][j]=max(v[i-1][j],v[i-1][j-ww[i].first]+ww[i].second);
      }
  cout << v[n][w] << endl;
  return 0;
}

Measured memory_bytes: 82432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String ns = sc.nextLine();
		String[] array = sc.nextLine().split(" ");
		int[] iarray = new int[Integer.parseInt(ns)];
		for (int i = 0; i < array.length; i++) {
			iarray[i] = Integer.parseInt(array[i]);
		}
		long min = iarray[0];
		long max = iarray[0];
		long sum = 0;
		for (int i : iarray) {
			if (min > i) {
				min = i;
			}
			if (i > max) {
				max = i;
			}
			sum += i;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 31512
S = input()
N = len(S)
R = S[::-1]
dic = ['maerd','remaerd','esare','resare']
i = 0
while i < N:
    for w in dic:
        if R[i:].startswith(w):
            i += len(w)
            break
    else:
        print('NO')
        exit()
print('YES')


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N =  sc.nextInt();
        int K =  sc.nextInt();
        int[] h = new int[N];
        for(int i = 0; i < N; i++){
            h[i] = sc.nextInt();
        }

        System.out.println(Arrays.stream(h).filter(x -> x >= K).count());

    }
}


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

int main(){
	string S;
	cin >> S;
	int ans = 0;
	for(int i=0;i<3;i++){
		if(S[i] == 'R') ans = 1;
	}
	if(S[0] == S[1] && S[0] == 'R') ans = 2;
	if(S[1] == S[2] && S[1] == 'R') ans = 2;
	if(S[0] == S[1] && S[1] == S[2] && S[0] == 'R') ans = 3;
	cout << ans <<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int n;
    cin>>n;
    string arr[n];
    lli ans = 0;
    int startb=0,enda=0,both=0;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        int l = str.length();
        for(int j=1;j<l;j++){
            if(str[j]=='B' && str[j-1]=='A'){
                ans++;
            }
        }
        if(str[0]=='B' && str[l-1]=='A'){
            both++;
        }else if(str[0]=='B'){
            startb++;
        }else if(str[l-1]=='A'){
            enda++;
        }
    }
    if(both == 0){
        ans+=min(startb,enda);
    }else{
        ans+=(both-1);
        if(enda > 0){
            enda--;
            ans++;
        }
        if(startb > 0){
            startb--;
            ans++;
        }
        ans+=min(startb,enda);
    }
    cout<<ans<<"\n";
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = 0;
        long[] A = new long[n + 1], B = new long[n];
        Arrays.setAll(A, i -> Integer.parseInt(sc.next()));
        Arrays.setAll(B, i -> Integer.parseInt(sc.next()));
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= 1; j++) {
                long t = A[i + j] < B[i] ? A[i + j] : B[i];
                B[i] -= t;
                A[i + j] -= t;
                res += t;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 61252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n, x;
	cin >> n >> x;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	REP(i, 1, n) {
		int d = a[i - 1] + a[i];
		int m = max(0, d - x);
		ans += m;
		if (a[i] < m) a[i] = 0;
		else a[i] -= m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;

LL n, k;

int main() {

  
    cin >> n >> k;

    LL ans = n % k;
    cout << min (ans, k - ans) << endl;

}

Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    string T;
    cin >> T;
    int n=T.size();
    rep(i,n){
        if(T[i]=='?'){
            T[i]='D';
        }
    }
    cout<<T<<endl;
    return 0;
}

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

int main(){
  int a,b,c,x,ans,temp;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  ans = 0;

  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        temp = (500*i)+(100*j)+(50*k);
        if(temp == x){
          ans = ans+1;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		int k = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		    int min = Integer.MAX_VALUE;
		    for(int j = 1; i - j >= 0 && j <= k; j++)
		    min = Math.min(dp[i - j] + Math.abs(h[i] - h[i - j]), min);
		    dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n, d, x; cin >> n >> d >> x;
    int ans = x;
    rep(i, n){
        int a; cin >> a;
        int sum = 1;
        for(int i = 1; i < d; i++){
            int tmp = i * a + 1;
            if(tmp > d) break;
            sum++;
        }
        ans += sum;
    }
    cout << ans << endl;
}


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

using namespace std;

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

    for(int i=0;i<K;i++) {
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            return 0;
        }
    }

    cout<<'1'<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  int p[n];
  int q[n];//各数字iが先頭から何番目にあるかを記録する配列
  REP(i,n){
    cin>>p[i];
    p[i]--;//修正点
    q[p[i]]=i;
  }
  int len=0;
  int temp=1;
  REP(i,n){
    if(i==n-1){
      len = max(len,temp);
    }else{
      if(q[i]<q[i+1]){
        temp++;
      }else{
        len = max(len,temp);
        temp = 1;
      }
    }
  }
  
  int ans;
  ans = n -len;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    char c;
    cin >> c;
    if(c=='A') cout << 'T';
    if(c=='T') cout << 'A';
    if(c=='C') cout << 'G';
    if(c=='G') cout << 'C';
    cout << endl;
    return 0;
}

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

using namespace std;

main(){
	int a;
	cin >> a;
	int b=0;
	long long c=a;
	int d=a;
	long long s=1;
	while(a > b+1){
		b=b+1;
		s=c*s;
		c=c-1;
	}
	printf("%lld\n",s);
}



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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n,k; cin >> n >> k;
    vector<int> d(k);
    vector<vector<int>> a;
    set<int> sunuke;
    a.resize(k);
    rep(i,k){
        cin >> d[i];
        int temp;
        rep(j,d[i]){
            cin >> temp;
            sunuke.insert(temp);
        }
    }
    cout<<n-sunuke.size()<<endl;
    
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define ll long long

using namespace std;

ll mod = 1e9 + 7;

ll
fact(int n) {
  ll ans = 1;
  for (int i=1; i<=n; i++) {
    ans *= i;
    ans %= mod;
  }

  return ans;
}

ll
modpow(ll n, ll v) {
  ll current = v;
  ll ans = 1;
  ll now = n;
  while (current > 0) {
    if (current & 1) {
      ans *= now;
      ans %= mod;
    }
    now *= now;
    now %= mod;
    current /= 2;
  }

  return ans;
}

ll
select(int n, int k) {
  if (k < 0 || k > n) return 0;
  if (k == 0 || k == n) return 1;


  ll ans = 1;
  ans *= fact(n);
  ans %= mod;
  ans *= modpow(fact(k), mod-2);
  ans %= mod;
  ans *= modpow(fact(n-k), mod-2);
  ans %= mod;
  return ans;
}

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

  if ((x + y) % 3 != 0) {
    cout<<0<<endl;
  }
  else {
    int level = (x + y) / 3;
    int index = level * 2 - x;
    cout<<select(level, index)<<endl;
  }

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int out1,out2;
        int i;
        int[] num = new int[8];
        int others = 0;

        for (i = 0; i < N; i++)
        {  
            int n = (NX[i] / 400) > 7 ? others = others + 1 : num[NX[i] / 400] = 1;
        }

        out1 = num.Sum();
        if (out1 == 0) out1 = 1;
        out2 = num.Sum() + others;

        Console.WriteLine(out1 + " " + out2);
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e7;
const int inf=1e9;
bool calc(char a,char b){
    return (a == '.') & (b == '#');
}
int main(){
	int H,W;cin>>H>>W;
	string s[H];
	rep(i,0,H) cin>>s[i];
	int dist[H][W]={};
	rep(j,1,W) dist[0][j] = dist[0][j-1] + calc(s[0][j-1],s[0][j]);
	rep(i,1,H){
		dist[i][0] = dist[i-1][0] + calc(s[i-1][0],s[i][0]);
		rep(j,1,W){
			dist[i][j] = min(dist[i-1][j] + calc(s[i-1][j],s[i][j]) , dist[i][j-1] + calc(s[i][j-1],s[i][j]));
		}
	}cout<<dist[H-1][W-1] + (s[0][0] == '#')<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int c = 1;
  int key = a[0];
  vector<int> d;
  for (int i = 1; i < n; i++){
    if (a[i] == key) c++;
    else {
      d.push_back(c);
      c = 1;
      key = a[i];
    }
  }
  d.push_back(c);

  sort(ALL(d));
  int ans = 0;
  if (d.size() > k){
    rep(i, d.size() - k){
      ans += d[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,x,m,l,r;
int a[1000005],pre[1000005];

map<int,int> ma;

signed main()
{
	cin>>n>>x>>m;
	a[1]=x;
	pre[1]=x;
	ma[x]=1;
	for (int i=2;i<=10*m;i++)
	{
		a[i]=(a[i-1]*a[i-1])%m;
		if (ma[a[i]])
		{
			l=ma[a[i]];
			r=i-1;
			break;
		}
		ma[a[i]]=i;
		pre[i]=pre[i-1]+a[i];
	}
	int ans=0,tim,lef,tot=0,tot2=0;
	ans=pre[l-1];
	tim=(n-(l-1))/(r-l+1);
	lef=n-(l-1)-tim*(r-l+1);
	
	for (int i=l;i<=l+lef-1;i++)  tot+=a[i];
	for (int i=l;i<=r;i++)  tot2+=a[i];
	cout<<ans+tot2*tim+tot<<endl;
	
	return 0;
}

Measured memory_bytes: 7536
n=int(input())
a=[list(map(int,input().split())) for i in range(2)]
tot=0
amo=0
for i in range(n):
    for j in range(i+1):
        tot+=a[0][j]
    for j in range(1,n-i+1):
        tot+=a[1][-j]
    amo=max(tot,amo)
    tot=0
print(amo)

Measured memory_bytes: 3064
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N>>s) {
		auto cnt = [](string s) {
//			DD(s);
			VI h(26);
			REP(i, s.size()) h[s[i]-'a']++;
			return h;
		};
		ll ans=0;
		REP(i, N) {
			VI a=cnt(s.substr(0, i));
			VI b=cnt(s.substr(i, N));
			ll c=0;
			REP(i, 26) if(a[i]&&b[i]) c++;
			maxUpdate(ans, c);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256