akhauriyash/Code-Regression huggingface dataset:
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}
int n,ai,bi;

int ncr(int a){
    int nca = 1;
    REP(i,a) nca = nca * (n-i) % mod;
    int inva = 1;
    REPS(i,a) inva = inva * i % mod;
    inva = powll(inva, mod-2);
    
    return nca * inva % mod;
}
signed main (){
    // 2^n -1 - nCa - nCb
    cin >> n >> ai >> bi;
    int ret = powll(2,n) - 1 + mod;
    ret = ret - ncr(ai) + mod - ncr(bi) + mod;

    cerr << powll(2,n) - 1 << " " << ncr(ai) << " " << ncr(bi) << endl;
    cout << (ret % mod) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, c, z;

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

  if(a > b){
    z = a;
    a = b;
    b = z;
  }
  if(b > c){
    z = b;
    b = c;
    c = z;
  }
  if(a > b){
    z = a;
    a = b;
    b = z;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		ArrayList<Double> inputs = new ArrayList<Double>(6);
		ArrayList<Double> resultsX = new ArrayList<Double>(5);
		ArrayList<Double> resultsY = new ArrayList<Double>(5);
		ArrayList<Double> resultsRadius = new ArrayList<Double>(5);
		
		int numLines = sc.nextInt();
		for(int n = 0; n < numLines; n++){
			setInputs(inputs);
			resultsX.add(getPointX(inputs.get(0), inputs.get(1), inputs.get(2), inputs.get(3), inputs.get(4), inputs.get(5)));
			resultsY.add(getPointY(inputs.get(0), inputs.get(1), inputs.get(2), inputs.get(3), inputs.get(4), inputs.get(5)));
			resultsRadius.add(getDistance(inputs.get(0), inputs.get(1), resultsX.get(n), resultsY.get(n)));
			inputs.clear();
		}
		
		for(int n = 0; n < numLines; n++){
			System.out.printf("%.3f %.3f %.3f\n",resultsX.get(n), resultsY.get(n), resultsRadius.get(n));
		}
	}
	
	private static void setInputs(ArrayList<Double> list){		
		list.add(sc.nextDouble());
		list.add(sc.nextDouble());
		list.add(sc.nextDouble());
		list.add(sc.nextDouble());
		list.add(sc.nextDouble());
		list.add(sc.nextDouble());
	}
	
	private static double getPointX(double x1, double y1, double x2, double y2, double x3, double y3){
		double a1 = 2 * (x2 - x1);
		double b1 = 2 * (y2 - y1);
		double c1 = (x1 * x1) - ( x2 * x2) + (y1 * y1) - (y2 * y2);
		double a2 = 2 * (x3 - x1);
		double b2 = 2 * (y3 - y1);
		double c2 = (x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3);
		
		double numerator = b1 * c2 - b2 * c1;
		double denominator = a1 * b2 - a2 * b1;
		
		return numerator / denominator;
	}
	
	private static double getPointY(double x1, double y1, double x2, double y2, double x3, double y3){
		double a1 = 2 * (x2 - x1);
		double b1 = 2 * (y2 - y1);
		double c1 = (x1 * x1) - ( x2 * x2) + (y1 * y1) - (y2 * y2);
		double a2 = 2 * (x3 - x1);
		double b2 = 2 * (y3 - y1);
		double c2 = (x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3);
		
		double numerator = c1 * a2 - c2 * a1;
		double denominator = a1 * b2 - a2 * b1;
		
		return numerator / denominator;
	}
	
	public static double getDistance(double x1, double y1, double x2, double y2){
		double distanceX = getDistanceX(x1, x2);
		double squareX = distanceX * distanceX;
		
		double distanceY = getDistanceY(y1, y2);
		double squareY = distanceY * distanceY;
		
		return Math.sqrt(squareX + squareY);
	}

	private static double getDistanceX(double x1, double x2){
		double distanceX = x1 - x2;
		if(distanceX < 0){
			distanceX = distanceX * (-1);
		}
		return distanceX;
	}
	
	private static double getDistanceY(double y1, double y2){
		double distanceY = y1 - y2;
		if(distanceY < 0){
			distanceY = distanceY * (-1);
		}
		return distanceY;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
struct node
{  string s;
   int t;  
}w[200005];
bool cmp (node a,node b)
{    if(a.t==b.t)
         return a.s<b.s;
        return a.t>b.t;
}
map<string,int> m;
string a[200005];
int main ()
{    int n;
     cin>>n; 
     int p=0;
   for(int i=0;i<n;i++)
   {   string ss;
        cin>>ss;
        if(!m[ss])
           a[p++]=ss;
        m[ss]=m[ss]+1;
   }
   for(int i=0;i<p;i++)
     {    w[i].s=a[i];
         w[i].t=m[a[i]];
	 }
	 sort(w,w+p,cmp);
	 cout<<w[0].s<<endl;
	 for(int i=1;i<p;i++)
	    {   if(w[i].t==w[i-1].t)
	          cout<<w[i].s<<endl;
	          else
	          break;
		 } 
		 return 0;
}

Measured memory_bytes: 29952
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	int n,k;
	cin >> n >> k;
	if(n*500 >= k)cout << "Yes" << endl;
	else cout << "No" << endl;
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc150.contest.atcoder.jp/tasks/abc150_b

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef pair<int,int> pi;

const int N=305,P=1e9+7;

int n,m,dp[N][N][N],ans;
vector<pi> e[N];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,l,r,x;i<=m;i++)scanf("%d%d%d",&l,&r,&x),e[r].pb({l,x});
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++)for(int k=0;k<=j;k++)
			if(int w=dp[i-1][j][k]){
				(dp[i][j][k]+=w)%=P;
				(dp[i][i-1][k]+=w)%=P;
				(dp[i][i-1][j]+=w)%=P;
			}
		for(auto v:e[i]){
			for(int j=0;j<i;j++)for(int k=0;k<=j;k++)
				if(dp[i][j][k]){
					int c=(j>=v.fi)+(k>=v.fi)+1;
					if(c!=v.se)dp[i][j][k]=0;
				}
		}
	}
	for(int j=0;j<n;j++)for(int k=0;k<=j;k++)
		if(dp[n][j][k])(ans+=dp[n][j][k])%=P;
	printf("%d\n",ans);
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

const int C = 35;
const int T = 1e5+345;

bool ch[C][T];

void solve() {
	int n, c; scanf("%d%d", &n, &c);
	for (int i = 0; i < n; ++i) {
		int s, t, c; scanf("%d%d%d", &s, &t, &c);
		--c;
		for (int j = s; j <= t; ++j) ch[c][j] = 1;
	}
	int ans = 0;
	for (int i = 1; i < T; ++i) {
		int cur = 0;
		for (int j = 0; j < c; ++j) {
			cur += ch[j][i];
		}
		ans = max(ans, cur);
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
int main()
{
    int n;
    scanf ("%d",&n);
    long long int sum=0;
    for (int i=1;i<=n;i++)
    {
        if (i%3==0|| i%5==0||i%15==0)
        {

        }
        else{
            sum=sum+i;
        }
    }
    printf ("%lld\n",sum);
}


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

using namespace std;

const int mod = 1e9 + 7;
int n, a[110], k;
long long dp[110][100100];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
		}
		for (int j = 0; j <= k; j++) {
			dp[i + 1][j] = dp[i][j];
			if (j - a[i] - 1 >= 0) dp[i + 1][j] += mod - dp[i][j - a[i] - 1];
			dp[i + 1][j] %= mod;
		}
	}
	
	cout << dp[n][k] << '\n';
}


Measured memory_bytes: 80128
n=int(input())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(n)]+[[0,n-1]]
b.sort(reverse=1)
ans=[0]*n
j=n-1
for i in range(n):
  j=min(b[i][1],j)
  c=b[i][0]-b[i+1][0]
  if c!=0:ans[j]+=c*(i+1)
print(*ans)

Measured memory_bytes: 27228
n, q = map(int, input().split())
ko=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    ko[a-1].append(b-1)
ans=[0]*n
for i in range(q):
    a,b=map(int, input().split())
    ans[a-1]+=b
nex=[0]
while nex:
    p=nex.pop()
    for i in ko[p]:
        ans[i]+=ans[p]
    nex+=ko[p]
print(*ans)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, k;
li a[100100];

inline bool solve() {
    li ggcd = a[0];
    li ma = a[0];
    repp(i, 1, n) {
        ggcd = __gcd(ggcd, a[i]);
        ma = max(ma, a[i]);
    }
    if (k > ma) {
        return false;
    }
    if (ggcd == 1) {
        return true;
    }
    if (k % ggcd > 0) {
        return false;
    }
    rin{
        a[i] /= ggcd;
    }
    k /= ggcd;
    return solve();
}

int main() {
    cin >> n >> k;
    rin{
        cin >> a[i];
    }
    cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;


    return 0;
}

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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int> > v;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        v.PB(MP(b, a));
    }
    sort(ALL(v));
    int sum = 0;
    bool ok = true;
    for(auto &i : v){
        sum += i.S;
        ok &= (i.F >= sum);
    }
    cout << (ok ? "Yes" : "No");
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 2420
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int a,b; cin>>a>>b;
    int tmp = (b-a-1)*(b-a)/2;
    cout<<tmp-a<<endl;

    return 0;
}

Measured memory_bytes: 256
import Data.Char

main = interact $ unlines . map (show . rp [] . words) . lines

rp acc [] = head acc
rp acc (x:xs)
 | any isDigit x = rp (read x : acc) xs
 | otherwise = rp ((op x) (head (tail acc)) (head acc) : (tail (tail acc))) xs
 where op x = case x of {"+" -> (+); "-" -> (-); "*" -> (*); "/" -> (/)}

Measured memory_bytes: 4388
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

typedef pair<double,double> P;
double EPS = 1e-5;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
};


struct circle{
  point p;
  double r;
};

vector<point> circles_cross(circle a, circle b){
    vector<point> ret;
     
    double x = a.p.x - b.p.x , y = a.p.y - b.p.y;
    double L = x * x + y * y;
    if(L > pow(a.r+b.r,2))return ret;
     
    L = sqrt(L);
    double C = atan2(b.p.y-a.p.y,b.p.x-a.p.x);
    double alpha = acos((L*L+a.r*a.r-b.r*b.r)/(2*L*a.r));
     
    point r1,r2;
    r1.x = a.p.x + cos(C+alpha) , r1.y = a.p.y + sin(C+alpha);
    r2.x = a.p.x + cos(C-alpha) , r2.y = a.p.y + sin(C-alpha);
     
    ret.push_back(r1) , ret.push_back(r2);
     
    return ret;
}

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

  while(cin >> n,n){
    vector<P>d;

    for(int i=0;i<n;i++){
      scanf("%lf,%lf",&a[i].p.x,&a[i].p.y);
      a[i].r=1;
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	vector<point> p=circles_cross(a[i],a[j]);
	for(int k=0;k<p.size();k++){
	  d.push_back(make_pair(p[k].x,p[k].y));
	}
      }
    }

    int count,ans=1;
    for(int i=0;i<d.size();i++){
      count=0;
      
      for(int j=0;j<n;j++){
	if(pow(d[i].first-a[j].p.x,2)+pow(d[i].second-a[j].p.y,2)<=1+EPS)count++;
      }
	ans=max(ans,count);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
from copy import deepcopy
N = int(input())
alp = list('abcdefghij')
ans = ['a']
for _ in range(2, N+1):
    m = len(ans)
    tmp = []
    for i in range(m):
        a = ans[i]
        n = len(set(a))
        for s in alp[:n+1]:
            tmp.append(a+s)
    tmp.sort()
    ans = deepcopy(tmp)
for a in ans:
    print(a)

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n, q; cin >> n >> q;
    if(n == 0 && q == 0) break;
    map<int, int> mp;
    for(int i=0;i<n;++i) {
      int m; cin >> m;
      for(int j=0;j<m;++j) {
        int tmp; cin >> tmp;
        mp[tmp]++;
      }
    }

    int ans = 0;
    int ma = 0;
    for(const auto &i: mp) {
      if(i.second > ma) {
        ans = i.first;
        ma = i.second;
      }
    }
    if(ma < q) {
      cout << 0 << endl;
    } else {
      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 3020
n = int(input())
h = list(map(int, input().split()))
cnt = 0
cnt_tmp = 0
num = h[0]

for i in range(1, n):
    if num >= h[i]:
        cnt_tmp += 1
        num = h[i]
    else:
        num = h[i]
        cnt_tmp = 0
    cnt = max(cnt, cnt_tmp)

print(cnt)

Measured memory_bytes: 20420
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < b)
        for (int i=0 ; i<b ; i++)
            cout << a;
    else
        for (int i=0 ; i<a ; i++)
            cout << b;
    return 0;
}


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

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

const int MN = 200010;

int N;
int A[MN], D[MN];
ll dp1[MN], dp2[MN];
vector<pii> seg;

void solve(ll *dp) {
    for(int i = 1; i < N; i++) {
        ll p = 4;
        while(p * A[i - 1] <= A[i]) {
            D[i]++;
            p *= 4;
        }
    }

    seg.clear();

    dp[N - 1] = 0;
    seg.push_back(pii(N - 1, N - 1));
    for(int i = N - 2; i >= 0; i--) {
        dp[i] = dp[i + 1];

        if(A[i + 1] < A[i]) {
            ll p = 1;
            int cnt = 0;
            while(p * A[i + 1] < A[i]) {
                cnt++;
                p *= 4;
            }

            pii tmp = pii(i, i);
            while(seg.size()) {
                if(cnt < D[ seg.back().first ]) {
                    D[ seg.back().first ] -= cnt;
                    break;
                }
                dp[i] += (cnt - D[ seg.back().first ]) * (seg.back().second - seg.back().first + 1);
                cnt -= D[ seg.back().first ];
                D[ seg.back().first ] = 0;
                tmp.second = seg.back().second;
                seg.pop_back();
            }
            seg.push_back(tmp);
        }
        else {
            if(D[ seg.back().first ]) seg.push_back(pii(i, i));
            else seg.back().first = i;
        }
    }
}

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

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

    solve(dp1);
    reverse(A, A + N);
    solve(dp2);

    ll ans = 1e18;
    for(int i = 0; i <= N; i++) {
        ans = min(ans, 2 * dp1[i] + 2 * dp2[N - i] + i);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int x;
int a[100001];
int b[5002],c[5002];
string s;
main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        x=(s[0]-'0')*1000+(s[2]-'0')*100+(s[3]-'0')*10+(s[4]-'0');
        a[i]=x;
        b[a[i]]++;
    }
    for(int i=0;i<=4000;i++) c[i]=b[i];
    for(int i=1;i<=4000;i++) b[i]+=b[i-1];
    for(int i=0;i<n;i++){
      int sum=0;
      if(a[i]>0)sum+=b[a[i]-1]*3;
      sum+=c[a[i]]-1;
      cout<<sum<<endl;
    }
}

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

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

bool countdiv(int n){
    int count=0;
    for(int i=1; i<=n; i++){
        if(n%i==0) count++;
    }
    if(count==8) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    int count=0;
    for(int i=1; i<=n; i+=2){
        if(countdiv(i)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 25
#define NIL -1
struct node{
  int parent,left,right;
};
struct node T[MAX];
int n,D[MAX],H[MAX];

void depth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  if(T[u].left!=NIL) depth(T[u].left,d+1);
  if(T[u].right!=NIL) depth(T[u].right,d+1);
}
int height(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=height(T[u].left)+1;
  if(T[u].right!=NIL) h2=height(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int sibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(u!=T[T[u].parent].left&&T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
  if(u!=T[T[u].parent].right&&T[T[u].parent].right!=NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  int deg=0,flag;
  printf("node %d: parent = %d, ",u,T[u].parent);
  printf("sibling = %d, ",sibling(u));
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].parent==NIL) printf("root\n");
  else if(deg==0) printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i,u,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].parent=T[i].left=T[i].right=NIL;

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&l);
    scanf("%d",&r);
    T[u].left=l;
    T[u].right=r;
    if(l!=NIL) T[l].parent=u;
    if(r!=NIL) T[r].parent=u;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }

  depth(root,0);
  height(root);
  for(i=0;i<n;i++) print(i);
  return 0;
}



Measured memory_bytes: 2108
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int n, count, i, j, k, l;
        StringBuilder sb = new StringBuilder("");

        while (sc.hasNextInt()) {
            n = sc.nextInt();

            count = 0;
            for (i = 0; i < 10; i++) {
                if (i > n) break;

                for (j = 0; j < 10; j++) {
                    if (i + j > n) break;

                    for (k = 0; k < 10; k++) {
                        if (i + j + k > n) break;

                        for (l = 0; l < 10; l++) {
                            if (i + j + k + l > n) break;

                            if (i + j + k + l == n) count++;
                        }
                    }
                }
            }

            sb.append(count);
            sb.append('\n');
        }
        System.out.print(sb);
    }
}

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

int main() {
  string N;
  cin >> N;
  bool fl = false;
  rep(i, 3) {
    if (N.at(i) == '7') {
      fl = true;
      break;
    }
  }
  if (fl) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();
    
    if (n % 2 == 1) {
      os.println(0);
      return;
    }
    
    long ans = 0;
    
    long base = 10;
    
    while (base <= n) {
      ans += n / base;
      base *= 5;
    }
    
    os.println(ans);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int i,number;
   long long int ans=0;
    scanf("%d", &number);

  for (i=1;i<=number;i++){
    if (i%3!=0 && i%5!=0){
        ans=ans+i;
    }
  }
  printf("%lld\n",ans);
    return 0;
}


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

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

    int n, a;
    cin >> n >> a;
    while (n >= 500) {
        n -= 500;
    }
    if (a >= n) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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

int main(){
    string s;
    cin >> s;
    if(s=="a" || s=="e" || s=="i" || s=="o" || s=="u"){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

int min(int a,int b){
    if(a-b>0) return b;
    return a;
}

int max(int a,int b){
    if(a-b>0) return a;
    return b;
}

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

Measured memory_bytes: 256
S = list(input())
N = len(S)
flag = "Yes"
for i in range((N-1)//2):
    if S[i] != S[-i-1]:
        flag = "No" 
# print((N-1)//2)   

N2 = (N-1)//2
if N2 == 2:
    n = 1
else:
    n = N2
if flag == "Yes":
    for k in range(n):
        if S[k] != S[N2 -1 -k]:
            flag = "No"

if flag == "Yes":
    for k in range(n):
        if S[-k-1] != S[-(N2 -1 -k)-1]:
            flag = "No"

print(flag)

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int main(){
  int a,b,c[1000],d[1000],i;
  scanf("%d %d",&a,&b);
  while(a!=0||b!=0){
    for(i=1;i<=a;i++){
      scanf("%d",&c[i]);
    }
    for(i=1;i<=b;i++){
      scanf("%d",&d[i]);
    }
    int ans=0,e=1,f=1;
    for(i=1;i<=b;i++){
      e+=d[i];
      e+=c[e];
      if(e>=a){
	ans=f;
	break;
      }
      f++;
    }
    printf("%d\n",ans);
    scanf("%d %d",&a,&b);
  }
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

  int N,M;
  cin>>N>>M;
  int maxl=1,minr=N;
  rep(i,0,M) {
    int l,r;
    cin>>l>>r;
    maxl=max(maxl,l);
    minr=min(minr,r);
  }
  cout<<max(0,minr-maxl+1)<<"\n";
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	string s;
	cin >> s;
	int n = s.size();

	VI v(n,0);

	bool b = true;
	int cnt = 0;
	int a;


	REP(i, n) {
		if (b) {
			if (s[i] == 'R')cnt++;
			else {
				b = false;
				if (cnt % 2 == 0) {
					v[i] += cnt / 2;
					v[i - 1] += cnt / 2;
				}
				else {
					v[i - 1] += cnt / 2 + 1;
					v[i] += cnt / 2;
				}
				cnt = 1;
				a = i;
			}
		}
		else {
			if (s[i] == 'L')cnt++;
			else {
				b = true;
				if (cnt % 2 == 0) {
					v[a] += cnt / 2;
					v[a - 1] += cnt / 2;
				}
				else {
					v[a] += cnt / 2 + 1;
					v[a - 1] += cnt / 2;
				}
				cnt = 1;
			}
		}
	}

	if (cnt % 2 == 0) {
		v[a] += cnt / 2;
		v[a - 1] += cnt / 2;
	}
	else {
		v[a] += cnt / 2 + 1;
		v[a - 1] += cnt / 2;
	}



	REP(i, n)cout << v[i] << ' ';


	
}

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

using namespace std;

int n,m;

int main() {
    cin >> n >> m;
    
    priority_queue<int> q;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        q.push(x);
    }
    
    while(m--) {
        int u = q.top();
        q.pop();
        q.push(u / 2);
    }
    
    long long ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

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

  int n,x,y; cin >> n >> x >> y;
  vector<int> ans(n);

  rep1(i, n) {
    for(int j = i + 1; j <= n; ++j) {
      if(i == j) continue;
      int dis = min(j-i, abs(i-x)+1+abs(j-y));
      ans[dis]++;
    }
  }

  rep1(i, n-1) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

uint32_t pow(uint32_t a, uint32_t p) {
  uint32_t ans = 1;
  for (size_t i = 0; i < p; i++) ans *= a;
  return ans;
}

int main() {
  uint32_t N = 0, K = 0;
  std::cin >> N >> K;
  std::cout << K * pow(K - 1, N - 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n) cin >> a[i+1];

    vector<int> box(n+1, 0);
    for (int i = n; i >= 1; i--) {
        int cnt = 0;
        for (int j = 2; i * j <= n; j++) {
            cnt += box[i * j];
        }
        if ((cnt % 2) != a[i]) {
            box[i] = 1;
        }
    }

    int m = 0;
    vector<int> b;
    rep(i, n) {
        if (box[i + 1] == 1) {
            m++;
            b.push_back(i + 1);
        }
    }

    cout << m << endl;
    rep(i, m) {
        cout << b[i] << endl;
    }
    return 0;
}


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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, t = 0;
    cin >> N;
    vector<int> a(N + 1), b(N / 2 + 1, 0), ans(N + 1);
    rep(i, N) cin >> a[i + 1];
    for (int i = N; i > 0; i--) {
        int s = 0;
        for (int j = i * 2; j <= N; j += i) {
            s += ans[j];
        }
        //cout << "i=" << i << " s=" << s << endl;
        ans[i] = (a[i] + s) % 2;
        t += ans[i];
    }
    cout << t << endl;
    rep(i, N) {
        if (ans[i + 1] == 1) {
            cout << i + 1;
            t--;
            if (t == 0) cout << endl;
            else cout << " ";
        }
    }
    //rep(i, N) cout << ans[i + 1] << " ";
    //cout << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

const int nmax=100010;
ll DP[nmax];
string s;
 
ll isGu(int i){
    ll n;
    n = s.length();
    // cout << "isDu" << i; 
    // cout << " " << (s[i-1] == 'g' ? 1 : 0) << endl;
    return (s[i-1] == 'g' ? 1 : 0);
}

void solve(void){
    int n;
    // cout << isGu(1);
    n = s.length();
    ll ans = 0; 
    rep(i,n){
        if (i % 2 == 0){
            if(s[i] == 'p') { ans --;}
        } else {
            if(s[i] == 'g') { ans ++;}
        }
    }
    cout << ans << endl;
}
int main() {
    int i,j; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    // cout << s << endl;
    solve();
    
}


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

using namespace std;

typedef long long ll;

constexpr int N{100}, M{1000000000};
constexpr int di[]{1, -1, 0, 0}, dj[]{0, 0, 1, -1};

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

    int n, k;
    // array<int, N> a;
    // string s, t;
    // bool can;

    cin >> n >> k;
    // for (int i = 0; i < n; i++)
    // cin >> a[i];

    int ans = n - k + 1;

    cout << ans << endl;
    // if (can)
    //     cout << "Yes" << endl;
    // else
    //     cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,a;

int main(){
	cin>>n>>a;
	if(n%500<=a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  for(int i=0;i<m;i++) cin >> p[i].first >> p[i].second;
  for(int x=0;x<1000;x++) {
    int keta = 1;
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      keta++;
      d.push_back(nx%10);
      nx /= 10;
    }
    if (keta != n) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    for(int i=0;i<m;i++) {
      if (d[p[i].first-1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclidalgo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) {
        return a;
    } else {
        return euclidalgo(b,a % b);
    }
}
bool coprime(ll int a, ll int b) {
    if (euclidalgo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int nCrModP(ll int n, ll int r, ll int p) {
    if (r == 0) return 1;
    ll int fac[n + 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return (fac[n] * BtoPmodM(fac[r], p - 2, p) % p * BtoPmodM(fac[n - r], p - 2, p) % p) % p;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n;
    cin >> n;
    ll int a[n];
    for (ll int i = 0;i < n;i++) cin >> a[i];
    map <ll int, ll int> m;
    for (ll int i = 0;i < n;i++) m[a[i]]++;
    ll int b[n];
    ll int cnt = 0;
    map <int, bool> c;
    for (ll int i = 0;i < n;i++) {
    	c[a[i]] = true;
	}
	for (ll int i = 1;i <= 200000;i++) {
		if (c[i] == true) {
			b[cnt] = i;
			cnt++;
		}
	}
	ll int sum = 0;
	for (ll int j = 0;j < cnt;j++) {
		if (m[b[j]] == 0 || m[b[j]] == 1) continue;
		else sum += m[b[j]] * (m[b[j]] - 1) / 2;
	}
//	debug(cnt);
//	for (int i = 0;i < cnt;i++) cout << b[i];
	for (ll int i = 0;i < n;i++) {
		int x = a[i];
		if (m[x] == 1) {
			cout << sum << endl;
		} else {
			cout << sum - m[x] + 1 << endl;
		}
	}
}

Measured memory_bytes: 21504
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define lint long long int
#define INF 99999999



int main()
{
    string s;
    cin >> s;
    
    if (s == "SSS") cout << '0' << endl;
    if (s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR") cout << '1' << endl;
    if (s == "SRR" || s == "RRS") cout << '2' << endl;
    if (s == "RRR") cout << '3' << endl;
}





Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
// #define endl "\n"

using namespace std;

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


int main(){
    ll N, K;   cin >> N >> K;
    vector<vector<int>> doub(64, vector<int>(N));
    for(int i = 0; i < N; i++){
        int a;  cin >> a;
        a--;
        doub[0][i] = a;
    }


    for(int i = 1; i < 64; i++){
        for(int j = 0; j < N; j++){
            int next = doub[i-1][j];
            doub[i][j] = doub[i-1][next];
        }
    }

    int res = 0;
    for(int i = 63; i >= 0; i--){
        if((K >> i) % 2 == 1){
            res = doub[i][res];
        }
    }

    cout << res + 1 << endl;


    return 0;
}


Measured memory_bytes: 54180
while True:
    try:
        s = input()
        if s[4] != "s":
            if (s[0] == s[4] and s[0] == s[8]) or (s[2] == s[4] and s[2] == s[6]):
                print(s[4])
                continue
        for i in range(3):
            if s[i] != "s" and s[i] == s[i + 3] and s[i] == s[i + 6]:
                print(s[i])
                break
            elif s[3*i] != "s" and s[3*i] == s[3*i + 1] and s[3*i] == s[3*i + 2]:
                print(s[3*i])
                break
        else:
            print("d")
    except:
        break



Measured memory_bytes: 5560
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int K = 12;
const int KM = 1 << (K - 1);
ll dat[1 << K];

void update(int A) {
	dat[A] = min(dat[A * 2], dat[A * 2 + 1]);
	if (A != 1) update(A >> 1);
}

void add(int A, ll B) {
	int C = A + KM;
	dat[C] = B;
	update(C >> 1);
}

ll check(int L, int R, int A, int l, int r) {
	if (L <= l && r <= R) return dat[A];
	if (r <= L || R <= l) return 1ll << 60;
	return min(check(L, R, A * 2, l, (l + r) >> 1), check(L, R, A * 2 + 1, (l + r) >> 1, r));
}

ll query(int L, int R) {
	return check(L, R, 1, 0, KM);
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002];
	rep(i, 1 << 12) dat[i] = 1ll << 60;
	rep1(i, N) {
		A[i] = ((ll)getint() << 11) + i;
		add(i, A[i]);
	}
	rep(i, N + 2) LR[i] = -1;

	priority_queue<int> q;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 11) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 11;
		int k = A[i] & m;

		int l = (LR[k - 1] == -1) ? k : LR[k - 1];
		int r = (LR[k + 1] == -1) ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		int kosuu = min(K - 1, r - k) + min(K - 1, k - l) + 1;
		int abureta = max(0, kosuu - K + 1);

		rep(i, abureta) {
			ll tmp = query(l, r + 1);
			q.push(tmp >> 11);
			add(tmp & m, 1ll << 60);
		}

		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back

typedef long long ll;
typedef queue <int> qi;
typedef vector <int> vi;
typedef vector <char> vc;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef map <string, int> msi;
typedef pair <string, int> psi;
typedef map <string, string> mss;
typedef unsigned long long ull;

const ll mod = 10e9+7;
const double eps = 1e-11;
const double PI = 2 * acos(0.0);

/*
string ToString(int n) { // Integer -> String
    stringstream convert;
    convert << n;
    return convert.str();
}

int ToInt(string s) { // String -> Integer
    istringstream sin(s);
    int x = 0;
    sin >> x;
    return x;
}

ll BigMod(ll b, ll p, ll m) {
    if (p == 0) return 1;
    ll r = bigmod(b, p / 2, m);
    r = (r * r) % m;
    if (p & 1) r = (r * b) % m;
    return r;
}
*/

int main() {
    int b, r;
    cin >> b;

    string s;
    vector <string> vs;
    map <string, int> B, R;

    for (int i = 0; i < b; i++) {
        cin >> s;
        if (B[s] == 0) {
            vs.pb(s);
            B[s] += 1;
        }
        else B[s] += 1;
    }

    cin >> r;
    for (int i = 0; i < r; i++) {
        cin >> s;
        R[s]++;
    }

    vi ans;
    for (int i = 0; i < vs.size(); i++) {
        int x = B[ vs[i] ] - R[ vs[i] ];
        ans.pb( x );
    }
    sort(ans.begin(), ans.end());

    if (ans[ans.size() - 1] < 0) puts("0");
    else cout << ans[ans.size() - 1] << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M = map(int, input().split())
# gx, gy, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

if N >= 10 or M >= 10:
    print(-1)
else:
    print(N * M)

Measured memory_bytes: 3316
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
num1, num2 = 0, 0
for i in range(n):
    if i in a:
        if i < x:
            num1 += 1
        else:
            num2 += 1

print(min(num1, num2))

Measured memory_bytes: 3060
/**
 * Created by karayuu on 2019/05/23
 */
fun main(arg: Array<String>) {
    var word = readLine()!!
    val q = readLine()!!.toInt()

    (1..q).forEach {
        val args = readLine()!!.split(" ")

        val action = args[0]
        val a = args[1]
        val b = args[2]
        when (action) {
            "replace" -> {
                word = word.replaceRange(a.toInt(), b.toInt() + 1, args[3])
            }

            "reverse" -> {
                word = word.replaceRange(a.toInt(), b.toInt() + 1,
                        word.subSequence(a.toInt(), b.toInt() + 1).reversed())
            }

            "print" -> {
                println(word.subSequence(a.toInt(), b.toInt() + 1))
            }
        }
    }
}


Measured memory_bytes: 32716
#include<iostream>

bool sosuu[50001];

void init(){
	for (int i = 0; i < 50001; i++)sosuu[i] = true;

	sosuu[0] = sosuu[1] = false;
	
	for (int i = 2; i*i < 50001; i++){
		if (sosuu[i]){
			for (int j = i * 2; j < 50001; j += i)sosuu[j] = false;
		}
	}
}

int main(){

	init();

	int n;
	while (std::cin >> n, n){

		int cnt = 0;

		for (int i = 2; i <= n / 2; i++){
			if (sosuu[i] && sosuu[n - i])cnt++;
		}

		std::cout << cnt << std::endl;

	}

	return 0;
}

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

int main(){
  int N;
  char c;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> c;
    if(c=='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256