akhauriyash/Code-Regression huggingface dataset:
using System.Linq;

namespace ABC
{
    using static System.Console;
    using static System.Math;
    public class Program
    {
        private const int MOD = 1000000007;
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        public static string Solve()
        {
            var a = ReadLine().Split().Select(int.Parse).ToArray();
            a[0] *= 3;
            return (a.Sum() / 2).ToString();
        }
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):

    def __init__(self, N, mod=10**9+7):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k]*self.finv[n-k] % self.MOD) % self.MOD


def solve(r: "List[int]", c: "List[int]"):

    cmb = Combination(r[1]+c[1]+1, mod=MOD)

    def f(x, y):
        return cmb(x+y, y)

    def g(x, y):
        return f(x+1, y)+f(x, y+1)-1

    ans = g(r[1], c[1])-g(r[0]-1, c[1])-g(r[1], c[0]-1)+g(r[0]-1, c[0]-1)
    print(ans % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = [int()] * (2)  # type: "List[int]"
    c = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        r[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(r, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87536
#include <stdlib.h>
#include <queue>
#include <string>
#include <iostream>
using namespace std;

struct process{
	string name;
	int time;
};

void print_process_queue(queue<process> output, int num);
int main(){
	int num;
	int time;

	cin >> num;
	cin >> time;

	queue<process> works;
	for(int i = 0; i < num; ++i){
		process work;
		cin >> work.name;
		cin >> work.time;
		works.push(work);
	}
	int totalTime = 0;
	queue<process> output;
	while(!works.empty()){
		if(works.front().time > time){
			totalTime += time;
			works.front().time -= time;
			works.push(works.front());
			works.pop();
		}else{
			totalTime += works.front().time;
			works.front().time = totalTime;
			output.push(works.front());
			works.pop();
		}
	}
	print_process_queue(output, num);

	return 0;
}


void print_process_queue(queue<process> output, int num){
	for(int i = 0; i < num; ++i){
		cout << output.front().name << " " << output.front().time << endl;
		output.pop();
	}
}

Measured memory_bytes: 5228
X,N = map(int,input().split())

if N == 0:
  print(X)
  exit()
else:
  P = list(map(int,input().split()))

  for i in range(100):
    if (X-i) not in P:
      print(X-i)
      break
    elif (X+i) not in P:
      print(X+i)
      break

Measured memory_bytes: 9056
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (A, B, C, X, Y) = (input[0], input[1], input[2], input[3], input[4])
let set1 = A*X + B*Y
let set2 = C*max(X,Y)*2
let set3 = C*min(X,Y)*2 + abs(X-Y)*(X>Y ? A:B)
print(min(set1, set2, set3))

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int w;
    scanf("%d", &w);
    if (i % 2 == 1 && w % 2 == 1) {
      ans += 1;
    }
  }
  printf("%d\n", ans);

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3812
program main;
var n, u, t, h : integer;
begin
    readln(n);

    u := n mod 10;
    t := (n div 10) mod 10;
    h := n div 100;

    if (u = 7)or (t = 7) or (h = 7) then
        writeln('Yes')
    else
        writeln('No');
end.

Measured memory_bytes: 1316
S=input()
for i in range(ord('a'),ord('z')+1):
  if chr(i) not in S:
    print(S+chr(i))
    break
else:
  for i in range(len(S)-1,-1,-1):
    for j in range(ord('a'),ord('z')+1):
      if j>ord(S[i]) and chr(j) not in S[:i]:
        print(S[:i]+chr(j))
        exit(0)
  else:
    print(-1)
    


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 100007
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int i,j,k,n,x,y,gx,gy,cnt,ans;
int a[N],b[N],c[N],d[N];
int fa[N];
bool bz[N];
int get(int x){return fa[x]==x?x:fa[x]=get(fa[x]);}
int read(){
	int fh=1,res=0;char ch;
	while((ch<'0'||ch>'9')&&(ch^'0'))ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')res=(res<<3)+(res<<1)+(ch^'0'),ch=getchar(); 
	return fh*res;
}
int main(){
	n=read();
	fo(i,1,n)a[i]=read(),a[n+1]^=a[i];fo(i,1,n)b[i]=read(),b[n+1]^=b[i];
	memcpy(c,a,sizeof(c));memcpy(d,b,sizeof(d));n++;
	sort(c+1,c+n+1);sort(d+1,d+n+1);
	fo(i,1,n)if(c[i]!=d[i]){printf("-1");return 0;}
	cnt=unique(c+1,c+n+1)-c-1;
	fo(i,1,cnt)fa[i]=i;
	fo(i,1,n)a[i]=lower_bound(c+1,c+cnt+1,a[i])-c,b[i]=lower_bound(c+1,c+cnt+1,b[i])-c;
	fo(i,1,n){
		if(a[i]==b[i]&&i<n)continue;
		ans+=(i<n);
		x=a[i],y=b[i];
		gx=get(x);gy=get(y);
		if(gx!=gy)fa[gy]=gx;
		bz[x]=bz[y]=1;
	}
	fo(i,1,cnt)fa[i]=get(fa[i]);
	fo(i,1,cnt)if(bz[i]&&fa[i]==i)ans++;
	if(ans)ans--;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

int main(void) {
	int n;
	cin >> n;
	
	ll ans = 0LL;
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				ans += gcd(gcd(i, j), k);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3636
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
    int calc(C,D){
        int i=0;
        while (C!=i)
        {
            printf("%d",D);
            i++;
        }
    }

int main(){
    int A,B,C,D;
    scanf("%d %d", &A, &B);
    if (A < B)
    {
        calc(B,A);
    }else{
        calc(A,B);
    }

}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;
    vector<pair<string, ll>> shop(n);
    vll shop_id(n);
    iota(shop_id.begin(), shop_id.end(), 0);

    REP(i, n) {
      string name;
      ll point;
      cin >> name >> point;
      shop[i] = paired(name, point);
    }

    sort(shop_id.begin(), shop_id.end(), [&](ll i1, ll i2) {
      if (shop[i1].first == shop[i2].first) {
        return shop[i1].second > shop[i2].second;
      }
      return shop[i1] < shop[i2];
    });

    REP(i, n) {
      COUT(shop_id[i] + 1);
      //cout << shop[shop_id[i]].first << " " << shop[shop_id[i]].second << endl;
    }

}



int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
*/


Measured memory_bytes: 3584
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s[n];
    vector<int> v[n];
    rep(i,0,n){
        cin>>s[i];
        rep(j,0,n){
            if(s[i][j]=='1')v[i].push_back(j);
        }
    }
    int ans=-1;
    rep(i,0,n){
        int d[n];
        fill(d,d+n,-1);
        d[i]=1;
        queue<int> q;
        q.push(i);
        int ma=0;
        while(q.size()>0){
            int now=q.front();q.pop();
            ma=d[now];
            rep(j,0,v[now].size()){
                int ne=v[now][j];
                if(d[ne]==-1){
                    d[ne]=d[now]+1;
                    q.push(ne);
                    continue;
                }
                else{
                    if(abs(d[now]-d[ne])!=1){
                        ma=-1;
                        break;
                    }
                }
            }
            if(ma==-1)break;
        }
        if(ma>=0)ans=max(ans,ma);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100
int INFTY=(1<<21);
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int minv,i,v;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }
}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

  int k,c,u,v;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }

  dijkstra();
  return 0;

}



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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

// Tip : ceil ( a/b ) = 1 + floor( (a-1)/b ) !

void solve ( int test_case )
{
    int n , m ;
    cin >> n >> m ;

    vi h ( n + 10 ) ;

    ll pen = 0 ;
    int ac = 0 ;

    for ( int i=0 ; i < m ; i ++ )
    {
        int indx ;
        cin >> indx ;

        string ver ; cin >> ver ;
        if ( h[indx] == 1 ) C ;

        if ( ver[0] == 'A' )
        {
            pen -= h[indx] ;
            ac ++ ;

            // cout << "pen : " << pen << " and ac : " << ac ; line

            h[indx] = 1 ;
        }

        else
            h[indx] -- ;
    }

    cout << ac << " " << pen ;
    line
}

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

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

bool cal(pair<ll,ll> A, pair<ll,ll> B){
    return A.second > B.second;
}

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

    ll N , M ;
    cin >> N >> M ;

    vector<ll> A;
    vector<pair<ll,ll> > BC;

    rep(i, N){
        ll inp; cin >> inp;
        A.pb(inp);
    }
    sort(all(A));
    rep(i, M){
        ll B,C;
        cin >> B >> C;
        BC.pb(mp(B,C));
    }
    sort(all(BC), cal);

    ll idx = 0  ;
    rep(i, M){
        if(idx >= N) break;

        rep(j, BC[i].first){
            if(A[idx] < BC[i].second){
                A[idx] = BC[i].second;
                idx++;
            }else break;
        }
    }

    ll ans = 0 ;
    rep(i,N){
        ans += A[i] ;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
N = input()
N = int(N)
s = [[ int(i) for i in input().split()] for i in range(N)]
hoge = []
import collections

for i in s:
    for k in s:
        if k != i:
            hoge1 = (i[0] - k[0],i[1] - k[1])
            if hoge1[0] <= 0:
                hoge1 = (k[0] - i[0],k[1] - i[1])
            if hoge1[0] == 0 and hoge1[1] <= 0:
                hoge1 = (k[0] - i[0],i[1] - k[1])
            hoge.append(hoge1)
if len(hoge) >= 1:
	c = collections.Counter(hoge)
	print(N - c.most_common()[0][1] // 2)
else:
    print(1)

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

set<int>s[200005];
int mm[200005];

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

  int n,k;
  cin>>n>>k;
  int a[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s[a[i]].insert(i);    
  }
  int cnt=1;
  int z=0;
  while (cnt<k && mm[z]==0)
  {
    mm[z]=cnt;
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      if(k==cnt)
        break;
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      cnt++;
      if(z==n)
      {
        z=0;
        cnt++;        
      }
      if(cnt==k)
      {
        break;
      }
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        cnt++;
      }
    }    
  }

  if(cnt==k+1)
    return 0;
  if(mm[z]==0)
  {
    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      
    return 0;
  }
  else
  {
    int per=cnt-mm[z];
    k-=mm[z];
    k%=per;
  }

  while (k>0)
  {
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      k--;
      if(z==n)
      {
        z=0;
        k--;
        if(k==-1)
          return 0;
      }
      if(k==0)
        break;
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        k--;
      }
    }    
  }

    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      

}

Measured memory_bytes: 24432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

const int LLINF = 1LL << 60;

signed main()
{
  int N;
  int A[100005];
  
  cin >> N;
  Rep(i, N) cin >> A[i];

  sort(A, A + N);

  int sum = 0;
  int p = 0;
  
  Rep(i, N - 1) {
    sum += A[i];
    if(sum * 2 < A[i + 1]) p = i + 1;
  }

  cout << N - p << endl;

  return 0;
}
  


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define int long long
#define FOR(a, b, c) for(int a = b, _c = c; a <= _c; ++a)
#define ROF(a, b, c) for(int a = b, _c = c; a >= _c; --a)
#define REP(a, b, c) for(int a = b, _c = c; a < _c; ++a)
#define VEC(a, b) for(auto &a : b)
#define ii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define sz(x) (int)(x.size())
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))

template <class T> void Max(T &x, T y) { x = (x > y) ? x : y;}
template <class T> void Min(T &x, T y) { x = (x < y) ? x : y;}

#define debug(x) cerr << #x << '=' << x << '\n'
#define debugn(a, n) FOR(i, 1, n) cerr << a[i] << ' '
#define debugv(a) VEC(v, a) cerr << v << ' '

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, k;
int e[N], add[N], f[N];

int pw(int x, int i) {
  int b = 1;
  for(; i; i >>= 1, x = x * x % mod) if(i & 1) b = b * x % mod;
  return b;
}

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> k;
  FOR(i, 1, 1e5) add[i] = 1;
  FOR(i, 2, 1e5) {
    if(e[i]) continue;
    for(int j = i; j <= 1e5; j += i) {
      e[j]++;
      if(j % (i * i) == 0) add[j] = 0;
    }
  }
  FOR(i, 1, 1e5) if(add[i] && e[i] % 2) add[i] = -1;
  FOR(i, 1, k) f[i] = pw(k / i, n);
  int tot = 0;
  FOR(i, 1, k) {
    int cnt = 0;
    for(int j = i; j <= k; j += i) cnt = (cnt + add[j / i] * f[j] + mod) % mod;
    tot = (tot + cnt * i % mod) % mod;
  }
  cout << tot << '\n';
}


Measured memory_bytes: 5904
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();// 几个500
		int B = sc.nextInt();// 几个100
		int C = sc.nextInt();// 几个50
		int X = sc.nextInt();
		int ans = 0;
		int i,j,k;
		for (i = 0; i <= A; i++) {
			for (j = 0; j <= B; j++) {
				for (k = 0; k <= C; k++) {
					if (500 * i + 100 * j + 50 * k == X)
						ans+=1;
				}
			}
		}
		System.out.println(ans);

		
	}
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  string a="abcdefghijklmnopqrstuvwxyz";
  string ra="zyxwvutsrqponmlkjihgfedcba";
  if(s==ra){
    cout<<-1<<endl;
    return 0;
  }
  else if(s.size()<a.size()){
    map<char,int>m;
    for(auto it:s)m[it]++;
    for(int i=0;i<a.size();i++){
      if(m[a[i]]==0){
        s=s+a[i];
        cout<<s<<endl;
        return 0;
      }
    }
  }
  else{
    char memo;
    for(int i=s.size()-2;i>=0;i--){
      if(s[i]<s[i+1]){
        memo=s[i];
        s=s.substr(0,i);
        break;
      }
    }
    map<char,int>m;
    for(auto it:s)m[it]++;
    for(int i=0;i<a.size();i++){
      if(m[a[i]]==0&&a[i]>memo){
        s=s+a[i];
        cout<<s<<endl;
        return 0;
      }
    }
  }
  return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string a, b, ans ;
  cin >> a >> b ;

  for(int i =0 ;i<b.length() ;i++){
    ans+=a[i];
    ans+=b[i] ;
  }
  if(a.length() > b.length())
    ans+=a[a.length()-1] ;
  cout << ans << endl ;

	
  return 0 ;
}



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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

bool eq(const string& s, int i, const string& sub) {
  int n = sz(sub);
  if (i + n - 1 >= sz(s)) return false;
  rep(j, n) {
    if (s[i + j] != sub[j]) {
      return false;
    }
  }
  return true;
}

bool solve() {
  string s = read<decltype(s)>();
  int n = sz(s);

  vb dp(n+1);
  dp[0] = 1;

  rep(i, n) if (dp[i]) {
    if (eq(s, i, "erase")) {
      dp[i + 5] = true;
    }
    if (eq(s, i, "eraser")) {
      dp[i + 6] = true;
    }
    if (eq(s, i, "dream")) {
      dp[i + 5] = true;
    }
    if (eq(s, i, "dreamer")) {
      dp[i + 7] = true;
    }
  }
  return dp[n];
}

void Main() {
  cout << (solve() ? "YES" : "NO") << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    print(YES if N == M else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
vector<bool> ch(maxn);
vector<ll> primes;
vector<ll> help;
void gen(){
    for(int i = 0; i <= 100; i++)
        help.push_back((i * (i + 1)) / 2);
    primes.push_back(2);
    for(int i = 3; i * i < maxn; i++){
        if(!ch[i]){
            for(int j = i * i; j < maxn; j += 2 * i)
                ch[j] = true;
        }
    }
    for(int i = 3; i < maxn; i += 2)
        if(!ch[i]) primes.push_back(i);
}
int main() {
    gen();
    IO;
    ll n;
    cin >> n;
    vector<pair<ll, ll> > v;
    for(int i = 0; primes[i] * primes[i] <= n; i++){
        int cnt = 0;
        while(n % primes[i] == 0)
            n /= primes[i], cnt++;
        if(cnt != 0)
            v.emplace_back(primes[i], cnt);
    }
    if(n > 1) v.emplace_back(n, 1);
    ll ans = 0;
    for(auto &x: v){
        int to_search = x.second;
        int pos = upper_bound(help.begin(), help.end(), to_search) - help.begin();
        ans += pos - 1;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
long long n,W;
long long w[109],v[109];
long long dp[109][100009];
long long sum(long long x,long long ww)
{
    if(x==n-1)
{
    if(ww+w[x]<=W)
return v[x];
else
    return 0;
}
if(dp[x][ww]!=-1)
    return dp[x][ww];
    long long s=0;
    if(ww+w[x]<=W)
        s=max(sum(x+1,ww+w[x])+v[x],sum(x+1,ww));
    else
        s=sum(x+1,ww);
dp[x][ww]=s;
    return s;
}
int main()
{
    memset(dp,-1,sizeof dp);
cin >>n>>W;
for(int i=0;i<n;i++)
    cin>>w[i]>>v[i];

cout<<sum(0,0);
}


Measured memory_bytes: 85376
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;
 
int main(){
    double w, h, x ,y;
    cin >> w >> h >> x >> y;
    cout << (w*h)/2 << " ";
    if(w/x==2 && h/y == 2){
        cout << "1";
    }else{
        cout << "0";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main(){
	fast_io;
	int k;
	int *arr=new int[5];
	cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4]>>k;
	bool r=true;
	for(int i=0;i<5&&r==true;i++){
		for(int j=i+1;j<5&&r==true;j++){
			if(arr[j]-arr[i]>k)r=false;
		}
	}
	if(r) cout<<"Yay!";
	else cout<<":(";
	return 0;
}


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

int main() {
	int k, s;
	cin >> k >> s;
	int a = 0;

	for (int i = 0;i <= k;i++) {
		for (int j = 0;j <= k;j++) {
			int l = s - i - j;
			if (l <= k&&0<=l)a++;
		}
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
#include <iomanip>
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;
double pi = 3.14159265358979;

int main(){

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    double theta = (5.5 * m - 30.0 * h) * pi / 180;
    
    double c = a * a + b * b - 2 * a * b * cos(theta);

    double min = abs(a - b);
    double max = a + b;
    double mid;
    
    rep(i,200){
        mid = (min + max) / 2;
        if(mid * mid > c){
            max = mid;
        } else {
            min = mid;
        }
    }
    
    cout << setprecision(15) << max << "\n";
        
    return 0;
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll n,m,i,j,k,l,t,a,b,c,d,arr[100009];
map<ll,ll>mp;
vector<ll>v;
string cc[100009];
int main()
{
    scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
    for(i=1;i<=n;i++)
        cin >> cc[i];
    for(i=1;i<=n;i++)
    {
        if(cc[i]=="AB")
        {
            if(a>b)
            {
                arr[i]=2;
                a--;
                b++;
            }
            else if(b>a || i==n || cc[i+1]==cc[i])
            {
                arr[i]=1;
                a++;
                b--;
            }
            else
            {
                if(cc[i+1]=="AC")
               {
                   arr[i]=1;
                a++;
                b--;
               }
               else
               {
                   arr[i]=2;
                b++;
                a--;
               }
            }
        }
        else if(cc[i]=="AC")
        {
            if(a>c)
            {
                arr[i]=3;
                a--;
                c++;
            }
            else if(c>a || i==n || cc[i+1]==cc[i])
            {
                arr[i]=1;
                a++;
                c--;
            }
            else
            {
               if(cc[i+1]=="AB")
               {
                   arr[i]=1;
                a++;
                c--;
               }
               else
               {
                   arr[i]=3;
                c++;
                a--;
               }
            }
        }
        else
        {
            if(c>b)
            {
                arr[i]=2;
                c--;
                b++;
            }
            else if(b>c || i==n || cc[i+1]==cc[i])
            {
                arr[i]=3;
                c++;
                b--;
            }
            else
            {
               if(cc[i+1]=="AB")
               {
                   arr[i]=2;
                b++;
                c--;
               }
               else
               {
                   arr[i]=3;
                c++;
                b--;
               }
            }
        }
        if(a<0 || b<0 || c<0)
        {
            printf("No\n");
            return 0;
        }
    }
    for(i=1;i<=n;i++)
        arr[i]--;
    printf("Yes\n");
   for(i=1;i<=n;i++)
    printf("%c\n",arr[i]+'A');
}


Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e14;
int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N + 1), v(N + 1);
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    ll dp[N + 1][sum + 1];
    fill(dp[0], dp[N], INF);
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= sum; j++) {
            if (j < v[i])
                dp[i][j] = dp[i - 1][j];
            else
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }

    ll ans;
    for (int i = 0; i <= sum; i++) {
        if (dp[N][i] <= W) ans = i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
long long m,n,g,cnt = 1;
long long gcd(long long m,long long n) {
	if (m % n == 0)
		return n;
	else
		return gcd(n,m % n);
}
int main() {
	cin >> m >> n;
	g = gcd(m,n);
	for(long long i = 2; i * i <= g; i++) {
		if (g % i == 0) {
			cnt++;
			while(g % i == 0)
				g = g / i;
		}
	}
	if (g > 1)
		cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)


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

g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
print(g)

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for(int i = 1; i < n; i++) {
		if(arr[i - 1] > arr[i]) {
			arr[i]++;
			if(arr[i - 1] > arr[i]) {
				cout << "No";
				return;
			}
		}
	}
	cout << "Yes";

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 4036
#156_c
n = int(input())
x_lis = [int(x) for x in input().split()]
 

s = []
for pos in range(min(x_lis),max(x_lis)+1):

    tir = []
    for x in x_lis:
        tir.append((x - pos)**2)
    s.append(sum(tir))
        

print(min(s))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int x,d;
int main()
{
	int a,b,c;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	if(i*500+j*100+k*50==x)d++;
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
const int INF = 1 << 30;
using namespace std;

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

  int n, l; cin >> n >> l;
  vector<int> taste(n);
  int allTaste = 0;
  rep(i, n) {
    taste[i] = l + i;
    allTaste += taste[i];
  }

  int ans = INF;
  rep(i, n) {
    int t = allTaste - taste[i];
    if(abs(allTaste - t) < abs(allTaste - ans)) ans = t;
  }
  cout << ans << '\n';
  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    int K, S; cin >> K >> S;
    int ans = 0;
    REP(x, K+1)
    {
        REP(y, K+1)
        {
            int z = S - (x+y);
            if(0 <= z && z <= K) ans++;
        }
    }

    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<vector>
using namespace std;
const int N=100003;
struct node{
    int v,w;
    node(int _v,int _w){
        v=_v;
        w=_w;
    }
};
vector<node> g[N];
int n,m,vis[N],dis[N];
void spfa(int s){
    queue<int> q;
    for(int i=1;i<=n;i++) dis[i]=N<<2;
    memset(vis,0,sizeof vis);
    q.push(s);
    dis[s]=0;
    vis[s]=1;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i].v;
            if(dis[v]>dis[u]+g[u][i].w){
                dis[v]=dis[u]+g[u][i].w;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    cout<<-dis[n]<<endl;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<n;i++) g[i].push_back(node(i+1,0));
    for(int i=n;i>1;i--) g[i].push_back(node(i-1,1));
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(node(v,-1));
    }
    spfa(1);
    return 0;
}


Measured memory_bytes: 10624
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(auto i:s)
    {
        if(i=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3628
N,A,B = map(int,input().split())
S = str(input())
j = f = 0
for i in range(N):
    if S[i]=="a" and j+f<A+B:
        print("Yes")
        j += 1
    elif S[i]=="b" and j+f<A+B and f<B:
        print("Yes")
        f += 1
    else:
        print("No")


Measured memory_bytes: 4016
#include <cstdio>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

ll H, W, N;
std::map<P, ll> mp;
ll ans[10];

int main()
{
  scanf( "%lld%lld%lld", &H, &W, &N );

  rep( i, N )
  {
    ll a, b;
    scanf( "%lld%lld", &a, &b );
    --a; --b;

    repi( d1, -2, 1 ) repi( d2, -2, 1 ) if( a+d1 >= 0 && a+d1 < H-2 && b+d2 >= 0 && b+d2 < W-2 )
      ++mp[P(a+d1,b+d2)];
  }

  ll sum = 0;

  for( auto it = mp.begin(); it != mp.end(); ++it )
  {
    ++ans[it->second];
    ++sum;
  }

  ans[0] = (H-2)*(W-2)-sum;

  rep( j, 10 )
    printf( "%lld\n", ans[j] );

  return 0;
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=1,now=0,mod=1e9+7,res=1;char s[212345];scanf("%d%s",&n,s);
    for (int i=1;i<n+n;++i) (now^=(s[i]==s[i-1]))?(res=1ll*res*c%mod,--c):(++c);
    for (int i=2;i<=n;++i) res=1ll*res*i%mod;
    return 0*printf("%d",(s[0]=='W'||c)?0:res);
}


Measured memory_bytes: 512
n = int(input())
*A, = map(int, input().split())
 
ans = 0
for i in range(n):
    for j in range(n-1):
        if A[j+1] < A[j]:
            A[j], A[j+1] = A[j+1], A[j]
            ans += 1
print(*A)
print(ans)


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


int main(){

    int M1,D1,M2,D2;

    cin >> M1 >> D1;
    cin >> M2 >> D2;

    if (M2 - M1 == 1 || M2 - M1 == -11){
        cout << "1" << endl; 
    }
    else{
        cout << "0" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, a[100];

    scanf("%d", &n);

    int i;
    for(i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
    }

    for(i = n - 1; i >= 0; --i)
    {
        printf("%d%s", a[i], i == 0 ? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, t, ans=10000000, i;
    cin >> n >> t;
    for(i=0;i<n;i++){
        long long cost, time;
        cin >> cost >> time;
        if(time<=t) ans=min(cost, ans);
    }
    if(ans==10000000) cout << "TLE" <<endl;
    else cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    int vv[4][3][10] = {{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},}};
    rep(i,n) {
        int b,f,r,v; cin>> b>>f>>r>>v;
        vv[b-1][f-1][r-1] += v;
    }
    rep(i,4) {
        rep(j,3){
            rep(k,10) {
                cout << " " << vv[i][j][k];
            }
            cout << "\n";
        }
        if (i<3) {
        cout << "####################" << "\n";
        }
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define debug(x)  cout<<#x<<" " <<x<<endl;
#define dbg(x,y)  cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define si(x) x.size()

const int e = 100005;
const ll INF = 1e18+5;
template<typename T>void show2(T& dp)
{
    for( auto row:dp)
    {
        for(auto col:row)
            cout<<col<<" ";
        cout<<endl;
    }
}
template<typename T>void show1(T &a)
{
    for(auto x:a)
        cout<<x<<" ";
    cout<<endl;
}
void solve()
{
    ll n ;
    cin>>n;
    unordered_set<ll>s;
    for(ll i = 2 ;i*i<=n ; i++)
    {
        ll x= n;    
        if(x%i==0)
        {
            while(x%i==0)
            x=x/i;
            if(x%i==1)
            s.insert(i);
        }
    }
    //s.insert(n-1);
    for(ll i = 1 ; i*i<=n-1 ;i ++)
    {
        if((n-1)%i==0)
        {
            s.insert(i);
            s.insert((n-1)/i);
        }
    }
    cout<<s.size();
}
int main() {
	// your code goes here
	io;
	
    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    vector<int> antenna(5);
    rep(i, 5) cin >> antenna.at(i);
    sort(antenna.begin(), antenna.end());

    int dist;
    cin >> dist;
    if (dist >= antenna.back() - antenna.front())
        cout << "Yay!";
    else
        cout << ":(";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define repr(i,a,n) for (int i=a;i<n;i++)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define fi first
#define se second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;

void solve() {
	int n;
	cin >> n;
	int tot = ((n)*(n + 1)) / 2;
	int div3 = ((n / 3)*(3 + 3 * (n / 3))) / 2;
	int div5 = ((n / 5)*(5 + 5 * (n / 5))) / 2;
	int div15 = ((n / 15)*(15 + 15 * (n / 15))) / 2;
	cout << tot - div5 - div3 + div15;
}

signed main()
{
	int tc;
	tc = 1;
	//	cin >> tc;
	while (tc--) {
		solve();
	}


}

Measured memory_bytes: 3676
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

const int M=55;
int v[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&v[i]);
	sort(v,v+n);
	double ans=v[0];
	for(int i=1;i<n;i++)
		ans=(ans+v[i])/2;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256