akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}

inline void setin(string s) {
    freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
    freopen(s.c_str(), "w", stdout);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}

template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 2e3 + 15;
const int M = 4e6 + 5;
int n, a[N];
bitset <M> dp;

main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // setin("input.txt");
    cin >> n;
    dp[0] = 1;
    int sum = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum += a[i];
        dp |= dp << a[i];
    }
    for(int i = (sum + 1)/2; i < M; ++i) {
        if(dp[i])
            return cout << i << endl, 0;
    }
    return 0;
}

Measured memory_bytes: 5072
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    sort(all(a),greater<int>());
    int sum = a[0];
    int cnt = 0;
    int x = n-1/2;
    vector<int> ans;
    rep(i,1,min((int)x+1,(int)a.size())){
        ans.pb(a[i]);
        ans.pb(a[i]);
    }

    rep(i,0,min((int)ans.size(),(int)n-2)){
        sum += ans[i];
    }
    cout<<sum<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8984
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int n, u, v;
int c1[111111], c2[111111];
vector<int> g[111111];

void rec(int u, int c[], int d) {
  // printf("%d\n", u);
  if (c[u] >= 0) return;
  c[u] = d;
  for (int i = 0; i < int(g[u].size()); i++) {
    rec(g[u][i], c, d + 1);
  }
}

int main(void) {
  int n; scanf("%d%d%d", &n, &u, &v); --u; --v;
  for (int i = 0; i < n - 1; i++) {
    int a, b; scanf("%d%d", &a, &b); --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  memset(c1, -1, sizeof(c1));
  memset(c2, -1, sizeof(c2));

  rec(u, c1, 0);
  rec(v, c2, 0);
  
  int res = 0;
  for (int i = 0; i < n; i++) {
    // printf("%d %d %d\n", i, c1[i], c2[i]);
    if (c1[i] <= c2[i] && g[i].size() != 1) {
      res = max(res, c2[i]);
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0;
  double w=0;
  std::cin >> x>>y;
  std::vector<int> v(y);
  rep(i,y){
    std::cin >> v[i];
  }
  rep(i,y){
    if(i!=y-1){
    z=v[i+1]-v[i];
  }else{
    z=x-v[i]+v[0];
  }
      n=max(z,n);
  }
  std::cout << x-n << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()


int main() {
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;
    vector<int> from_front, from_back;

    REP(i, N) {
        if (S[i] == 'o') {
            from_front.push_back(i);
            i += C;
        }
        if (from_front.size() == K) break;
    }
    RREP(i, N) {
        if (S[i] == 'o') {
            from_back.push_back(i);
            i -= C;
        }
        if (from_back.size() == K) break;
    }
    reverse(ALL(from_back));
    REP(i, from_front.size()) {
        if (from_front[i] == from_back[i]) cout << from_front[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[] page = new int[N];
			for (int i = 0; i < N; ++i) {
				page[i] = sc.nextInt();
			}
			int start = 0;
			for (int i = 1; i < N; ++i) {
				if (page[i] == page[i - 1] + 1) {
					continue;
				}
				if (i == start + 1) {
					System.out.print(page[start] + " ");
				} else {
					System.out.print(page[start] + "-" + page[i - 1] + " ");
				}
				start = i;
			}
			if (start == N - 1) {
				System.out.println(page[start]);
			} else {
				System.out.println(page[start] + "-" + page[N - 1]);
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;


void solve(){
    int n;
    cin>>n;
    vector<pair<double,double>>p(n);
    rep(i,n)cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    double sum=0.0;
    do{
        rep(i,n-1){
            sum+=sqrt(pow(p[i].first-p[i+1].first,2)+pow(p[i].second-p[i+1].second,2));
        }
    }
    while(next_permutation(p.begin(),p.end()));
    double all=1.0;
    rep(i,n)all*=(i+1);
    cout<<sum/all<<endl;
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}




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

int main(){
  int N;cin>>N;
  vector<pair<int,int>> pairs(N);
  for(int i=0;i<N;i++){
    cin>>pairs[i].first>>pairs[i].second;
  }
  sort(pairs.begin(),pairs.end());
  int ans=0;
  for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
      pair<int,int> set;

      int cnt=0;
      set.first=pairs[i].first-pairs[j].first;
      set.second=pairs[i].second-pairs[j].second;
      for(int k=1;k<N;k++){
        for(int h=0;h<i;h++){
          pair<int,int> tmp;
          tmp.first=pairs[k].first-pairs[h].first;
          tmp.second=pairs[k].second-pairs[h].second;
          if(set.first==tmp.first&&set.second==tmp.second){
            cnt++;
          }
        }
      }
      ans=max(ans,cnt);
    }
  }
  cout<<(N-ans)<<endl;
}


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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int mn = 3e5 + 5;
const int maxlog = 19;

string s;

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    cin>>s;
    vector<int> cnt(26);
    int n=sz(s);
    for(auto &i:s){
        cnt[i-'a']++;
    }
    sort(all(cnt));
    if (cnt[25]>(n+2)/3) puts("NO");
    else puts("YES");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;
const int N = 2e5 + 100;
int n, a[N + 100], sum[N + 100];
long long cnt;
struct node
{
    int l, r, sum;
} tree[N * 16 + 100];

void push(int num)
{
    tree[num].sum = tree[2 * num].sum + tree[2 * num + 1].sum;
}

void build(int left, int right, int num)
{
    tree[num].l = left;
    tree[num].r = right;
    if (left == right)
    {
        tree[num].sum = 0;
        return;
    }
    build(left, (left + right) / 2, num * 2);
    build((left + right) / 2 + 1, right, 2 * num + 1);
    push(num);
}

void up(int now, int x)
{

    if (tree[now].l == x && tree[now].r == x)
    {
        tree[now].sum++;
        return;
    }
    int mid = (tree[now].l + tree[now].r) / 2;
    if (x <= mid)
        up(2 * now, x);
    else if (x > mid)
        up(2 * now + 1, x);
    tree[now].sum++;
    //cout << tree[now].l << " " << tree[now].r << " " << tree[now].sum << endl;
}

int find(int now, int left, int right)
{
    if (left > right)
        return 0;
    if (tree[now].l >= left && tree[now].r <= right)
    {

        return tree[now].sum;
    }
    int mid = (tree[now].l + tree[now].r) / 2;
    //
    if (right <= mid)
        return find(2 * now, left, right);
    else if (left > mid)
        return find(2 * now + 1, left, right);
    else
    {
        return find(2 * now, left, mid) + find(2 * now + 1, mid + 1, right);
    }
}

bool check(int x)
{
    sum[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > x)
            sum[i] = sum[i - 1] - 1;
        else
            sum[i] = sum[i - 1] + 1;
    }
    for (int i = 0; i <= n; i++)
        sum[i] += n + 1;
    build(1, N, 1);
    long long ans = 0;
    for (int i = 0; i <= n; i++)
    {
        ans += find(1, 1, sum[i] - 1);
        up(1, sum[i]);
    }
    //cout << x << " " << ans << endl;
    return ans >= 1ll * n * (n + 1) / 4 + 1;
}

int main()
{
    scanf("%d", &n);
    int l = 1;
    int r = 1e9;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int mid;
    while (l <= r)
    {
        mid = (l + r) / 2;
        if (check(mid))
        {
            r = mid;
        }
        else
        {
            l = mid + 1;
        }
        if (r - l <= 1)
        {
            mid = check(l) ? l : r;
            break;
        }
    }
    cout << mid << endl;
}


Measured memory_bytes: 10496
h,w,k = map(int,input().split())

ls = [input() for _ in range(h)]
ans = [[None]*w for _ in range(h)]

berry = 0
index = 0
while not "#" in ls[index]:
  index += 1
  
for i in range(index,h):
  s = ls[i]
  if not "#" in s:
    ans[i] = ans[i-1]
  else:
    berry += 1
    bcount = 0
    for j in range(w):
      if s[j] == ".":
        ans[i][j] = berry
      else:
        bcount+=1
        if bcount>1:
          berry +=1
        ans[i][j] = berry
          
for i in range(index):
  ans[i] = ans[index]

for i in range(h):
  print(' '.join(map(str, ans[i])))  

Measured memory_bytes: 7156
#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() {
  int n, m, k, t;
  cin >> n >> m >> k;
  vector<ll> a(n), aa(n + 1), b(m), bb(m + 1);
  rep(i, n) {
    cin >> a[i];
    aa[i + 1] = aa[i] + a[i];
  }
  rep(i, m) {
    cin >> b[i];
    bb[i + 1] = bb[i] + b[i];
  }

  ll ans = 0;
  int b_cnt = m;
  rep(a_cnt, n + 1) {
    if (aa[a_cnt] > k) continue;
    while (aa[a_cnt] + bb[b_cnt] > k) b_cnt--;
    ans = max(ans, ll(a_cnt + b_cnt));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define lch a[n].lc
#define rch a[n].rc
using namespace std;
const int mo=998244353;
const int maxn=1e6+10;
int n,root,topt,nt[maxn];
struct da{int lc,rc,ma;}a[4*maxn];
long long dp[maxn];
struct daa{int x,d;}v[maxn];
inline bool cmp(daa aa,daa bb){return aa.x<bb.x;}
void build_tree(int &n,int l,int r)
{
	n=++topt; a[n].ma=-1; if (l==r) return;
	int mid=(l+r)>>1;
	build_tree(lch,l,mid); build_tree(rch,mid+1,r);
}
inline void updata(int n){a[n].ma=max(a[lch].ma,a[rch].ma);}
void tree_add(int n,int l,int r,int lc,int k)
{
	if (l==r) {a[n].ma=k; return;}
	int mid=(l+r)>>1;
	if (lc<=mid) tree_add(lch,l,mid,lc,k);else tree_add(rch,mid+1,r,lc,k);
	updata(n);
}
int qury(int n,int L,int R,int l,int r)
{
	if (L==l && R==r) return a[n].ma;
	int mid=(L+R)>>1;
	if (r<=mid) return qury(lch,L,mid,l,r);
	else if (l>=mid+1) return qury(rch,mid+1,R,l,r);
	else return max(qury(lch,L,mid,l,mid),qury(rch,mid+1,R,mid+1,r));
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&v[i].x,&v[i].d);
	sort(v+1,v+n+1,cmp); build_tree(root,1,n);
	for (int i=n;i>=1;i--)
	{
		int l=i+1,r=n,lc=-1;
		while (l<=r)
		{
			int mid=(l+r)>>1;
			if (v[mid].x<v[i].x+v[i].d) {lc=max(lc,mid); l=mid+1;}else r=mid-1;
		}
		if (lc==-1) nt[i]=i;else nt[i]=qury(root,1,n,i+1,lc);
		tree_add(root,1,n,i,nt[i]);
	}
	dp[n+1]=1;
	for (int i=n;i>=1;i--) dp[i]=(dp[i+1]+dp[nt[i]+1])%mo;
	printf("%lld\n",dp[1]);
return 0;
}
/*
3
-1 10
3 3
6 5
*/


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 1e5+1;
const int MOD = 1e9+7;

ll n, k;
vi adj[MAX];

ll solve(int v, int a, ll total) {
	ll curr = total, i = 1;
	
	foa(u, adj[v]) {
		if(u == a) continue;
		curr = (curr*solve(u, v, k-(v != 1)-i)) % MOD;
		i++;
	}	
	
	return curr;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		
	cin >> n >> k;	
	fo(i, 1, n-1, 1) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	
	cout << solve(1, 1, k);
}

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

using namespace std;

int main()
{
	int num[5][100]={};
	double t[5][100]={};
	double min1=10000,min2=10000;
	int num1,num2;

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<8;j++)
		cin >> num[i][j] >> t[i][j];
	}

	for(int k=0;k<3;k++)
	{
		for(int i=0;i<8;i++)
		{
			for(int j=i;j<8;j++)
			{
				if(t[k][i]>t[k][j])
				{
					swap(t[k][i],t[k][j]);
					swap(num[k][i],num[k][j]);
				}
			}
		}
	}

	for(int i=0;i<3;i++)
	{
		for(int j=2;j<8;j++)
		{
			if(min1>=t[i][j])
			{
				min1=fmin(min1,t[i][j]);
				num1=num[i][j];
			}
		}
	}
	for(int i=0;i<3;i++)
	{
		for(int j=2;j<8;j++)
		{
			if(min2>=t[i][j] && min1!=t[i][j])
			{
				min2=fmin(min2,t[i][j]);
				num2=num[i][j];
			}
		}
	}

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<2;j++)
		{
			cout << num[i][j] << " " << t[i][j] <<endl;
		}
	}
	cout << num1 << " " << min1 << endl;
	cout << num2 << " " << min2 << endl; 

    return 0;
}

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

def main():
    x = int(input())
    ans = (x // 11) * 2
    x %= 11

    if x > 0:
        if x > 6:
            ans += 2
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int64;
const int N = 2e5+5;
char s[N];
int n, f[26][N];
int64 ans;
int main()
{
    scanf("%s", s+1), n = strlen(s+1);
    for(int i = 1; i <= n; ++i)
        for(int j = 0; j < 26; ++j)
            f[j][i] = f[j][i-1]+(s[i] == j+'a');
    for(int i = 1; i <= n; ++i) ans += (n-i+1)-(f[s[i]-'a'][n]-f[s[i]-'a'][i-1]);
    printf("%lld\n", ans+1);
    return 0;
}

Measured memory_bytes: 20608
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
  int d, n;
  long ans;
  cin >> d >> n;
 

  if(0==d) ans=n;
  else if (1==d) ans = 100*n;
  else ans = 10000*n;
  if(n==100){
  if(0==d) ans++;
  else if (1==d) ans += 100;
  else ans += 10000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <numeric>
#include <cmath>
#include <cctype>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll inf = pow(10,9)+7;
ll comb(ll a,ll b){
  ll r = 1;
  vector<ll> w;
  for(ll i=b;i>=2;--i){ w.push_back(i); }
  for(ll i=0;i<b;++i){
    r *= (a-i);
    for (auto it = w.begin(); it != w.end();) {
      if (r%(*it) == 0) {
        r /= (*it);
        it = w.erase(it);
      } else {
        ++it;
      }
    }
    r %= inf;
  }
  return r;
}

int main(){
  ll N,M; cin>>N>>M;
  umap<ll,ll> mp;
  vector<ll> v;
  ll start = 2;
  while(M>1){
    for(ll i=start;i<=M;++i){
      if(M%i==0){
        M /= i;
        ++mp[i];
        if(mp[i]==1){ v.push_back(i); start=i;}
        break;
      }
    }
  }
  
  ll ans = 1;
  for(ll x:v){
    ans *= comb(mp[x]+N-1,mp[x]);
    ans %= inf;
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include <iostream>

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

    int t = N / 10;
    int ref = N - t * 10;

    switch (ref)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        std::cout << "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        std::cout << "pon";
        break;
    default:
        std::cout << "bon";
        break;
    }
}

Measured memory_bytes: 3632
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/A_input.txt")
else:
    f=sys.stdin
l,h,d=map(int,f.readline().split())
ans=0
for _ in range(l,h+1):
    ans=ans+1 if _%d==0 else ans
print(ans)

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

int main(void){
  int n,count,ans;
  ans=0;
  count=0;
  cin>>n;
  for(int i=1; i<n+1;i+=2){
  	for(int j=1;j<i+1;j++){
  	  if(i%j==0){
  	    count++;
  	  }
    }
    if(count==8){
      ans++;
    }
    count=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
s_min = -1000000
s_max = 1000000
K, X = map(int, input().split())


b_min = X - K + 1
while b_min < s_min:
    b_min += 1

b_max = X + K - 1
while b_max > s_max:
    b_max -= 1


for i in range(b_min, b_max+1):
    if i == b_max:
        print(i)
    else:
        print(i, end=' ')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
signed main(){
	int x,y,t;
	vector<vector<int>> v(14, vector<int>(14,0));
	while( scanf("%lld,%lld,%lld", &x, &y, &t) != EOF ){
		x+=2;
		y+=2;
		switch (t) {
			case 3:
				v[x][y-2]++;
				v[x][y+2]++;
				v[x-2][y]++;
				v[x+2][y]++;
			case 2:
				v[x-1][y-1]++;
				v[x-1][y+1]++;
				v[x+1][y-1]++;
				v[x+1][y+1]++;
			case 1:
				v[x+1][y]++;
				v[x-1][y]++;
				v[x][y-1]++;
				v[x][y+1]++;
				v[x][y]++;
				break;
		}
	}
	int z=0;
	int mx=-1;
	for(int i=2;i<12;i++){
		for(int j=2;j<12;j++){
			if(v[i][j]==0) z++;
			mx = max(mx, v[i][j]);
		}
	}
	cout << z << endl;
	cout << mx << endl;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int A, B;
	cin >> A >> B;

	if( B % A == 0 ) {
		cout << A+B << endl;
	}
	else {
		cout << B-A << endl;
	}

	return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 507;
const int MAXS = 2000007;

int n;
LL a[MAXN][MAXN];
int p[MAXS];
set < LL > s;
bool isp[MAXS];
int prm[MAXS], kp;

void init ();
void input ();
void work ();

LL gcd ( LL x, LL y )
{
	return y ? gcd ( y, x%y ) : x;
}

LL lcm ( LL x, LL y )
{
	return ( ( ~x ) && ( ~y ) ) ? ( x / gcd ( x, y ) * y ) : ( ~x ) ? x : y;
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
	
	INIT ( isp, true );
	isp[0] = isp[1] = false;
	lp ( i, 2, MAXS ){
		if ( isp[i] ) prm[++kp] = i;
		for ( int j = 1; j <= kp && prm[j] * i < MAXS; ++j ){
			isp[prm[j]*i] = false;
			if ( i % prm[j] == 0 ) break;
		}
	}
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
}

void work ()
{
	// main work
	
	lpi ( i, 1, n ){
		lpi ( j, 1, n ){
			if ( ( i & 1 ) == ( j & 1 ) ){
				a[i][j] = prm[i+j+2*n+1] * ( i - j + n );
				s.insert ( a[i][j] );
			}
		}
	}
	
	lpi ( i, 1, n ){
		lpi ( j, 1, n ){
			if ( !a[i][j] ){
				LL g = -1;
				if ( i > 1 ) g = lcm ( g, a[i-1][j] );
				if ( i < n ) g = lcm ( g, a[i+1][j] );
				if ( j > 1 ) g = lcm ( g, a[i][j-1] );
				if ( j < n ) g = lcm ( g, a[i][j+1] );
				LL cg = g + 1;
				while ( s.find ( cg ) != s.end () ) cg += g;
				a[i][j] = cg;
				s.insert ( a[i][j] );
			}
		}
	}
	
	lpi ( i, 1, n ){
		lpi ( j, 1, n ) printf ( "%lld ", a[i][j] );
		putchar ( '\n' );
	}
}

Measured memory_bytes: 22656
a,b,k = map(int,input().split())
G= []

def gcd(a,b):
  while(b > 0):
   a,b = b,a%b
  return a

if(a < b):
  tmp = a
  a = b
  b = tmp
  
#a > b 
if(k > 1):
 for i in range(b+1):
  if(i != 0):
   if((a%i == 0)and(b%i == 0)):
    G.append(i)
 #print(G)
 print(G[-k]) 
elif(k == 1):
  print(gcd(a,b))
   

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

int u, n, tmp;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> u;
        tmp += (u != i);
    }
    cout << (tmp <= 2 ? "YES\n" : "NO\n");
}


Measured memory_bytes: 256
N, M = map(int,input().split())
a = []
b = []
for i in range(M):
    a.append(list(map(int, input().split())))

a=[flatten for inner in a for flatten in inner]
 
for i in range(N):
    b.append((a.count(i+1)))


c = list(map(str, b))

answer = '\n'.join(c)
print(answer)




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

struct Card{
    char suit, value;
};

void BubbleSort(struct Card C[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > i; j--){
            if(C[j].value < C[j-1].value)swap(C[j], C[j-1]);
        }
    }
}

void SelectionSort(struct Card C[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
}

void print(struct Card C[], int N){
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit){
            return false;
        }
    }
    return true;
}

int main(){
    int N;
    struct Card C1[100], C2[100];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i < N; i++){
        C2[i] = C1[i];
    }
    BubbleSort(C1, N);
    print(C1, N);
    cout << "Stable" << endl;
    SelectionSort(C2, N);
    print(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

char t[5005];
string s, s1;
int i, j, k, n, index;
set<string> st;
set<string>::iterator it;

int main() {
scanf("%s", t);
s = t;
n = s.size();
scanf("%d", &k);
st.clear();
for (i=0;i<n;i++) {
	s1 = "";
	for (j=0;j<k;j++) if (i + j < n) {
		s1 += s[i + j];
		st.insert(s1);
	}
}
//printf("%d\n", st.size());
index = 1;
for (it=st.begin();it!=st.end();it++) {
	if (index == k) {
		printf("%s\n", (*it).c_str());
		return 0;
	}
	index++;
}
return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;

	if( k >= 2){
		n -= k;
		cout << n << endl;
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}


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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> c.at(i).at(j);
    }
  }
  vector<vector<int>> y(100,vector<int>(100));
  rep(i,1<<h){
    rep(l,1<<w){
      int t=0;
      rep(j,h){
      // rep(m,w){
          rep(m,w){
            if(i>>j&1 && l>>m&1){
              if(c.at(j).at(m)=='#')++t;
            }
          }
      }
    y.at(i).at(l)=t;
    }
  }
  int z=0;
  rep(i,100){
    rep(j,100){
    if(y.at(i).at(j)==k)++z;
    }
  }
  cout << z << endl;
}

Measured memory_bytes: 3652
n,m = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i]-=1
####################################
#Union Find
par = [] #親
rank = [] #木の深さ

#初期化
for i in range(n):
    #par[i]:i rank[i]:0
    par.append(i)
    rank.append(0)

#木の根を求める
def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)



#######################################
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -=1
    unite(x,y,par,rank)

a = [[] for i in range(n)]
b = [[] for i in range(n)]
for i in range(n):
    k = find(i,par)
    a[k].append(i)
    b[k].append(p[i])

res = 0
for i in range(n):
    if len(a[i])!= 0 and len(b[i])!=0:
        res += len(set(a[i])&set(b[i]))
print(res)

Measured memory_bytes: 45536
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	int d;
	cin >> d;
	string s = " Eve";
	string ans = "Christmas";
	for (int i = 0; i < 25 - d; i++) { ans = ans + s; }
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 3 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
vector<int> G[N];
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    ll w,a,b;
    cin >> w >> a >> b;
    ll ans = 0;
    if(a <= b)
        ans = max(0LL,b - (w + a));
    else
        ans = max(a - (w + b),0LL);
    cout << ans << '\n';
    
    return 0;
}   

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#define MAX 101
#define INF 1<<21
#define NIL -1
using namespace std;
int n,A[MAX][MAX];
int Minimum_Spanning_Tree(void){
    int color[MAX],d[MAX],vertices,mincost;
    for(int i=0;i<n;i++){
        color[i] = 0;
        d[i] = INF;
    }
    d[0] = 0;
    while(true){
        mincost = INF;
        vertices = NIL;
        for(int i=0;i<n;i++){
            if(color[i]!=1 & d[i]<mincost){
                mincost = d[i];
                vertices = i; 
            }
        }
        if(vertices == NIL){
            break;
        }
        color[vertices] = 1; 
        for(int i=0;i<n;i++){
            if(color[i]!=1 && A[vertices][i] != INF){
                if(A[vertices][i] < d[i]){
                    d[i] = A[vertices][i];
                }
            }
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += d[i];
    }
    return sum;
}
int main(void){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> A[i][j];
            if(A[i][j] == NIL){
                A[i][j] = INF;
            }
        }
    }
    cout << Minimum_Spanning_Tree() << endl;
    return 0;
}


Measured memory_bytes: 3120
import sys
import operator
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    teams = [f.readline().split() for i in range(n)]
    
    teams = [(t[0], -t.count('0'), t.count('1'), i) for i, t in enumerate(teams)]
    
    teams.sort(key=operator.itemgetter(1,2,3))
    
    print('\n'.join([t[0] for t in teams]))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


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

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0;
    int cnt = 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    for (int i = 0; i < N - 1; i++) {
      if (list.get(i) >= list.get(i + 1)) {
        cnt++;
      } else {
        max = Math.max(max, cnt);
        cnt = 0;
      }
    }
    if (cnt > max) {
      max = cnt;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 59560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N; cin >> N;
    int u = 0;
    for(int i=1; i<=N; i++){
        if((i+1)*i/2>=N){
            u = i;
            break;
        }
    }

    for(int i=1; i<=u; i++){
        if((u+1)*u/2 - i == N) continue;
        else cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){

  long long cnt=0;
  int n,x,flg;
  char p;
  short a=0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p >> x;
    if(p=='(')cnt+=x;
    else cnt-=x;

    if(cnt<0)a=1;
  }
  if(cnt!=0 || a==1)cout << "NO" << endl;
  else cout << "YES" << endl;
   
}

Measured memory_bytes: 1160
n = int(input())
counter = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
counter[0][3][3][3] = 1
mod = 10**9 + 7

for i in range(n):
    for b1 in range(4):
        for b2 in range(4):
            for b3 in range(4):
                for now in range(4):
                    if counter[i][b1][b2][b3] == 0:
                        continue
                    elif b1 == 0 and b3 == 1 and now == 2:
                        continue
                    elif b2 == 1 and b3 == 0 and now == 2:
                        continue
                    elif b2 == 0 and b3 == 2 and now == 1:
                        continue
                    elif b1 == 0 and b2 == 1 and now == 2:
                        continue
                    elif b2 == 0 and b3 == 1 and now == 2:
                        continue
                    else:
                        counter[i+1][b2][b3][now] += counter[i][b1][b2][b3]
                        counter[i+1][b2][b3][now] = counter[i+1][b2][b3][now] % mod

answer = 0
for b1 in range(4):
    for b2 in range(4):
        for b3 in range(4):
            answer += counter[n][b1][b2][b3]

print(answer % mod)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc2(n,m);
    M[0] = 1;
    curr = 0;
    ans = 0;
    rep(i,1,n) {
        sc(k);
        curr = (curr + k) % m;
        ans += M[curr];
        M[curr]++;
    }
    prL(ans);
    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int valLen = String.valueOf(a).length(); 
        String s = String.valueOf(a);
        String i = s.substring(valLen-1);
        int c = Integer.parseInt(i);
        if(c == 3){
            System.out.println("bon");
        }else if(c == 0 || c == 1 || c == 6 || c == 8){
            System.out.println("pon");
        }else{
            System.out.println("hon");
        }
    }
}

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

int main(){
	int n, l, i;
	string s[110];
	cin>>n>>l;
	for(i=0; i<n; i++) cin>>s[i];
	sort(s, s+n);
	for(i=0; i<n; i++) cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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 brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vout(a) erep(qxqxqx,a)std::cout << qxqxqx << ' ';std::cout  << std::endl;
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
//const ll INF64 = 9223372036854775ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;
int main(){
    int n;
    std::cin >> n;
    int k;
    std::cin >> k;
    std::vector<int> a(n+1);

    rep(i,n){
        int d;
        std::cin >> d;
        a[d]++;
    }
     sort(all(a),greater<int>());
//    vout(a);
    std::cout << n-accumulate(a.begin(),a.begin()+k,0)<< std::endl;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            int[] c = new int[3];

            long ans = 1;

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

                bool f = false;
                int b = int.Parse(s[i]);

                for (int j = 0; j < 3; j++)
                {
                    if(c[j] == b)
                    {
                        count++;

                        if(!f)
                        {
                            c[j]++;
                            f = true;
                        }
                    }
                }

                ans *= count;
                ans %= 1000000007;
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	VI C(N - 1);
	LL count = 0;
	REP(i, N - 1) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			count++;
		}
		C[i] = count;   // count when i-(i+1) is in
	}
	VI l(Q), r(Q);
	REP(i, Q) {
		cin >> l[i] >> r[i];
	}
	LL rs, ls;
	LL rr, ll;
	REP(i, Q) {
		if (r[i] == 1) {
			cout << "0" << endl;
			continue;
		} else {
			rr = C[r[i] - 2];
		}
		if (l[i] == 1) {
			ll = 0;
		} else {
			ll = C[l[i] - 2];
		}
		cout << rr - ll << endl;
	}
	
	
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	string s;
	int count = 0;
	cin >> s;
	if (s[0] == '1')count++;
	if (s[1] == '1')count++;
	if (s[2] == '1')count++;
	cout << count << endl;
}

Measured memory_bytes: 256
#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 int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int n;
	cin>>n;

	string s;
	cin>>s;

	vector<int> R,G,B;
	for(int i=0;i<n;i++){
		if(s[i]=='R') R.pb(i);
		if(s[i]=='G') G.pb(i);
		if(s[i]=='B') B.pb(i);
	}

	int cnt=R.size()*G.size()*B.size();
	for(int i=0;i<n;i++){
		for(int k=i+1;k<n;k++){
			int j=k+i;
			if(j%2==0){
				if(s[i]!=s[j/2] && s[j/2]!=s[k] && s[i]!=s[k]) cnt--;
			} 
		}
	}

	cout<<cnt<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3712