akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Node{
	int s[3],val,tag;
}t[1<<21];

int nds=0;

void pd(int now){
	if(t[now].tag){
		if(t[now].s[0]){
			t[t[now].s[0]].tag^=1;
			t[t[now].s[1]].tag^=1;
			t[t[now].s[2]].tag^=1;
		}
		swap(t[now].s[1],t[now].s[2]);
		t[now].tag=0;
	}
}

void ops(){
	t[1].tag^=1;
}

void opr(int now=1){
	pd(now);
	if(!t[now].s[0]){
		return;
	}
	swap(t[now].s[1],t[now].s[2]);
	swap(t[now].s[0],t[now].s[1]);
	opr(t[now].s[0]);
}

int n;

int init(int nr=n,int ch=1,int val=0){
	int now=++nds;
	if(nr==1){
		t[now].val=val;
		return now;
	}
	t[now].s[0]=init(nr/3,ch*3,val);
	t[now].s[1]=init(nr/3,ch*3,val+ch);
	t[now].s[2]=init(nr/3,ch*3,val+ch*2);
	return now;
}

int get(int to,int nr=n,int now=1){
	pd(now);
	if(nr==1){
		return t[now].val;
	}
	return get(to/3,nr/3,t[now].s[to%3]);
}

char T[200005];
int p[1<<20];

int main(){
	int N;
	scanf("%d",&N);
	n=1;
	for(int i=0;i<N;i++){
		n*=3;
	}
	init();
	scanf("%s",T);
	for(int f=0;T[f];f++){
		if(T[f]=='S'){
			ops();
		}else{
			opr();
		}
	}
	for(int i=0;i<n;i++){
		p[get(i)]=i;
	}
	for(int i=0;i<n;i++){
		printf("%d%c",p[i]," \n"[i==n-1]);
	}
	return 0;
}

Measured memory_bytes: 21828
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
void print(int num){
	cout<<num<<endl;
}
int main()
{
#ifdef DEBUG
	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
#endif
	int a,b;
	char op;
	while(scanf("%d %c %d",&a,&op,&b)!=EOF&&op!='?'){
		switch(op){
			case '+':
				print(a+b);
				break;
			case '-':
				print(a-b);
				break;
			case '*':
				print(a*b);
				break;
			case '/':
				print(a/b);
				break;
		}
	}
	
	//insert code
	return 0;
}
//aoj1_4.cc

Measured memory_bytes: 1208
#include <cstdio>
#include <vector>
#include <stdint.h>

int64_t as[200002];

int64_t ls[200002];
int64_t rs[200002];
std::vector<int64_t> stk;

int main(){
  int64_t N;
  scanf("%ld",&N);
  for(int64_t i=1;i<=N;i++){
    scanf("%ld",&as[i]);
  }
  stk.push_back(0);
  for(int64_t i=1;i<=N+1;i++){
    while(as[i]<as[stk.back()]){
      rs[stk.back()]=i;
      stk.pop_back();
    }
    ls[i]=stk.back();
    stk.push_back(i);
  }
  int64_t total=0;
  for(int64_t i=1;i<=N;i++){
    total+=(rs[i]-i)*(i-ls[i])*as[i];
    //printf("%ld: %ld to %ld\n",as[i],ls[i],rs[i]);
  }
  printf("%ld\n",total);
  return 0;
}


Measured memory_bytes: 6640
import java.util.Scanner;

class LCM {
    static long lcm(int a, int b){
        return (long)a * b / gcd(a, b);
    }

    private static int gcd(int a, int b){
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();
		System.out.println(antiDivision(b, c, d) - antiDivision(a-1, c, d));
	}

	static long antiDivision(long n, int c, int d){
		return n - (division(n, c) + division(n, d) - division(n, LCM.lcm(c, d)));
	}

	static long division(long n, long d){
		return n / d;
	}
}


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

const int MAX = 100;

int pre[MAX], in[MAX];
int n, pre_idx;

void reconstruction(int l, int r) {
	if (l >= r) return;
	int node = pre[pre_idx];
	pre_idx++;
	int m = 0;
	for (int i = 0; i < n; i++) {
		if (node != in[i]) continue;
		m = i;
		break;
	}
	reconstruction(l, m);
	reconstruction(m+1, r);
	cout << node;
	if (node != pre[0]) cout << ' ';
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> pre[i];
	for (int i = 0; i < n; i++) cin >> in[i];
	pre_idx = 0;
	reconstruction(0, n);
	cout << endl;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(void) {
  int A, B;
  scanf("%d%d",&A,&B);

  if(A%3==0){
   printf("Possible");
  }
  else if(B%3==0){
   printf("Possible");
  }

  else if((A+B)%3==0){
   printf("Possible");
  }
  else{
    printf("Impossible");
    
  }

  
  return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
bnum=[1]*n
red=[True]+[False]*(n-1)
for i in range(m):
    x,y=map(int,input().split())
    x-=1;y-=1
    if bnum[x]==1 and red[x]:
        red[x]=False
        bnum[x]-=1
        bnum[y]+=1
        red[y]=True
    elif red[x]:
        bnum[x]-=1
        red[y]=True
        bnum[y]+=1
    else:
        bnum[x]-=1;bnum[y]+=1
print(sum(1 for i in red if i))


Measured memory_bytes: 5364
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		boolean isC=false,ok=false;
		String s=sc.next();
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='C'){
				isC=true;
			}
			if(isC&&s.charAt(i)=='F'){
				ok=true;
			}
		}
		if(ok==true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

ll power(ll x, unsigned ll y, unsigned ll m=MOD) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2, m) % m; 
	p = (p * p) % m; 

	return (y%2 == 0)? p : (x * p) % m; 
} 


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	cin>>n;
	vi c;
	in(c,n);
	sort(all(c));
	ll ans = 0;
	for(int i=1;i<=n;i++){
	    ans = ans + ((((n-i+2)*power(2,2*n-2))%MOD)*c[i-1])%MOD;
	    ans%=MOD;
	}
	cout<<ans;
	

	return 0;
}






Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N,K,Q;
    cin >> N >> K >> Q;
    //
    vector<int> point(N,(K-Q));
    for(int i=0;i<Q;i++){
        int A;
        cin >> A;
        point[A-1]+=1;
    }
    for(int i=0;i<N;i++){
        if(point[i]>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3792
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
int c[maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<1000;i++){
        int id=1;
        c[1]=i/100;
        c[2]=(i/10)%10;
        c[3]=i%10;
        for(int j=0;j<n;j++){
            if(s[j]-'0'==c[id]){
                id++;
            }
            if(id==4){
                break;
            }
        }
        if(id==4){
            ans++;
        }
    }
    cout<<ans;
	exit(0);
}


Measured memory_bytes: 384
N=int(input())
h_list=[int(x) for x in input().split()]
now=0
count_now=0
count_max=0
for i in range(N-1):
    if h_list[i]>=h_list[i+1]:
        count_now+=1        
    else:
        count_now=0
    if count_now>count_max:
        count_max=count_now  
print(count_max)

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

int main() {
    string s; cin >> s;
    int n = s.length();
    s = " " + s;
    if (s[1] == '0' || s[n] == '1') return !(cout << -1 << endl);
    for (int i = 1; i < n; i++) {
        if (s[i] != s[n - i]) return !(cout << -1 << endl);
    }
    int p = 1;
    for (int i = 2; i <= n; i++) if (s[i] == '1') {
        while (p < i) cout << p << " " << i << endl, p++;
    }
    cout << n - 1 << " " << n << endl;
    return 0;
}


Measured memory_bytes: 1660
n=int(input())
tarou,hanako=0,0
for i in range(n):
    lis=list(input().split())
    lis_1=sorted(lis)
    if lis[0]==lis[1]:
        tarou+=1
        hanako+=1
    elif lis[0]==lis_1[0]:
        hanako+=3
    else:
        tarou+=3
print(str(tarou)+" "+str(hanako))


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	print((H - h)*(W - w));






	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int probA()
{
    int a,b;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    // スペース区切りの整数の入力
    scanf("%d",&b);
    // 文字列の入力
    scanf("%s",s);
    // 出力
    if(s[b-1]=='A'){s[b-1]='a';}
    if(s[b-1]=='B'){s[b-1]='b';}
    if(s[b-1]=='C'){s[b-1]='c';}
    
    printf("%s\n",s);
    return 0;
}

int probB(){
    int S,AA,BB;
    scanf("%d", &S);
    AA=S/100;
    BB=S%100;
    if(1<=AA && AA<=12){
        if(1<=BB && BB<=12){printf("AMBIGUOUS\n");}
        else{printf("MMYY\n");}
    }
    else{
        if(1<=BB && BB<=12){printf("YYMM\n");}
        else{printf("NA\n");}
    }
    
    
    
    return 0;
}

int Ipow2XK(int i,int K){
    int X;
    for(X=0;i*pow(2,X)<K;X++){
    }
    
    return X;
}

int probC(){
    
    int N,K;
    double R=0;
    scanf("%d %d", &N,&K);
    for(int i=1;i<=N;i++){
        R+=(double)1/(N*pow(2,Ipow2XK(i,K) )  );
    }
    
    
    printf("%1.12lf\n",R);
    return 0;
}

int Ap(){
    int a,b;
    // 整数の入力
    scanf("%d", &a);
    // スペース区切りの整数の入力
    scanf("%d",&b);
    // 文字列の入力
    
    // 出力
    if(a>=13){b=b;}
    else if(6<=a && a<=12){b=b/2;}
    else if(a<=5){b=0;}
    
    printf("%d\n",b);
    
    
    
    return 0;
}


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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,b;
	cin>>n>>b;
	if(b==1||b==2*n-1){
		cout << "No";
		return 0;
	}
	ll a=b-1,c=b+1;
	ll now=1;
	cout << "Yes"<<endl;
	ll mid=(2*n)/2;
	for(ll i=1;i<=2*n-1;i++){
		if(i==mid-1){
			cout <<a;
		}
		else if(i==mid){
			cout << b;
		}
		else if(i==mid+1){
			cout << c;
		}
		else{
			if(now==a){
				now=a+3;
			}
			cout << now;
			now++;
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;
string s,t;
ll dp[3004][3004];
ll lcs(ll i,ll j)
{
    if(i>=zz(s)||j>=zz(t))
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s[i]==t[j])
        return 1+lcs(i+1,j+1);

    return dp[i][j]=max(lcs(i+1,j),lcs(i,j+1));
}

void P(ll i,ll j)
{
    if(i>=zz(s)||j>=zz(t))
        return ;
    if(s[i]==t[j])
    {
        cout<<s[i];
        P(i+1,j+1);
    }
    else if(lcs(i+1,j)>lcs(i,j+1))
    {
        P(i+1,j);
    }
    else
        P(i,j+1);
}



int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>s>>t;
    P(0,0);


}



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

int n,a[200010];

template <typename T> inline void read(T &a) {
	a = 0;char c = getchar();int f = 1;
	while(!isdigit(c)) {if(c == '-') f = -1; c = getchar();}
	while(isdigit(c)) {a = (a<<3) + (a<<1) + (c ^ 48); c = getchar();}
	a*=f;
}

inline bool check (int k) {
	if((a[n-1] <= k && a[n] <= k) || (a[n] <= k && a[n+1] <=k)) 
		return true;
	if((a[n-1] > k && a[n] > k) || (a[n] > k && a[n+1] > k)) 
		return false;
	for(int i = 1;i < n-1 ;++i) {
		if((a[n + i] <= k && a[n + i + 1] <= k) || (a[n - i] <= k && a[n - i -1] <=k))
			return true;
		if((a[n + i] > k && a[n + i +1] > k) || (a[n - i] > k && a[n - i -1] > k))
			return false;
	}
	return a[1] <= k;
}

int main () {
	read(n);
	for(int i=1;i<(n << 1);++i)
		read(a[i]);
	int l = 1, r =(n << 1) - 1;
	while (l < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int yes(){
	cout << "YES" << endl;
	return 0;
}

int no(){
	cout << "NO" << endl;
	return 0;
}

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	ll acc = accumulate( a.begin(), a.end(), 0ll );
	ll sum = (n*(n+1))/2;
	if( acc % sum != 0 ) return no();
	ll k = acc / sum;
	vector<ll> d(n);
	for( int i = 0; i < n; ++i ){
		if( i == n-1 ){
			d[i] = a[0] - a[i];
		} else {
			d[i] = a[i+1] - a[i];
		}
	}
	ll ycnt = 0;
	for( auto p : d ){
		if(
			(k-p)%n != 0 || ((n-1)*k+p)%n != 0
			||
			(k-p)/n < 0 || ((n-1)*k+p)/n < 0
		){
			return no();
		}
		ycnt += (k-p)/n;
	}
	( ycnt == k ) ? yes() : no();
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int M = N;
    int d = 1;
    while (M/ 10 > 0)
    {
        d++;
        M /= 10;
    }

    int ans = 0;
    for (int i = 1; i <= d; i++)
    {
        if (i % 2 == 1)
        {
            if (i != d)
            {
                ans += pow(10, i) - pow(10, i - 1);
            } else
            {
                ans += N - pow(10, i - 1) + 1;
            }    
        }
        
    }
    cout << ans << endl;

  return 0;
}


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

using namespace std;
using namespace atcoder;

int main()
{
  int n, m;
  cin >> n >> m;
  scc_graph g(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    g.add_edge(a, b);
  }
  vector<vector<int> > s = g.scc();
  cout << s.size() << "\n";
  for (int i = 0; i < s.size(); i++)
  {
    cout << s[i].size() << " ";
    for (int j = 0; j < s[i].size(); j++)
    {
      cout << s[i][j] << " ";
    }
    cout << "\n";
  }
}

Measured memory_bytes: 40572
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		pr.print("AB");
		pr.println((char)('C' + n / 1000));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int x = Integer.parseInt(strArr[0]);
            int y = Integer.parseInt(strArr[1]);
            if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
                    && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
                System.out.println("Yes");
            } else if ((x == 4 || x == 6 || x == 9 || x == 11)
                    && (y == 4 || y == 6 || y == 9 || y == 11)) {
                System.out.println("Yes");
            } else if (x == 2 && y == 2) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 21076
import itertools

nmr = list(map(int,input().split()))
N,M,R = nmr[0],nmr[1],nmr[2]
perm = list(map(int,input().split()))
perm.sort()
dist = [[int(1e9) for i in range(N+1)] for j in range(N+1)]
res = int(1e11)

# 各距離を代入する
for i in range(M):
    abc = list(map(int,input().split()))
    a,b,c = abc[0],abc[1],abc[2]
    dist[a][b] = c
    dist[b][a] = c

# Warshall–Floyd Algorithm
for k in range(1,N+1):
    for i in range(1, N+1):
        for j in range(1,N+1):
            if(dist[i][j] > dist[i][k] + dist[k][j]):
                dist[i][j] = dist[i][k] + dist[k][j]

# 各順列について,距離の総和を求める
for dir in itertools.permutations(perm):
    direction = list(dir)
    tmpdir = 0
    for i in range(len(direction) - 1):
        tmpdir += dist[direction[i]][direction[i+1]]
    res = min(tmpdir,res)

print(res)

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

int main(){
    long long a,b,x;
    cin >> a >> b >> x;
    /*
    for(long long i=a; i<=b; i++){
        if( i % x == 0){
            count++;
        }
    }
    */
    long long left = a/x;
    if(left*x < a){
        if((left+1)*x > b){
            cout << 0 << '\n';
        }else{
            if( b % x == 0 ){
                cout << (1 + (b-a)/x) << '\n';
            }else{
                long long temp = (left+1)*x;
                cout << (1 + (b-temp)/x) << '\n';
            }
        }
    }else{
        cout << (1 + (b-a)/x) << '\n';
    }
}


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<string>
#define int long long int
using namespace std;
int i,j, a, b, c, d,p[26],n;
signed main() {
	string s;
	cin >> a >> b;
	for (i = 0; i < a; i++) {
		cin >> s;
		p[s[0] - 'A']++;
	}
	for (i = 0;; i++) {
		c = 0;
		sort(p, p + 26, [](int a, int b) {return a > b; });
		for (j = 0; j < 26&&c<b; j++) {
			if (p[j] != 0) {
				c++;
				p[j]--;
			}
		}
		if (c < b)
			break;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    ll max_n, min_n, sum_n;
    max_n = -1000010; min_n = 1000010; sum_n = 0;
    for(int i=0; i<n; i++){
        ll ai;
        cin >> ai;
        if(max_n<ai) max_n = ai;
        if(min_n>ai) min_n = ai;
        sum_n += ai;
    }
    printf("%d %d %ld\n", min_n, max_n, sum_n);
}


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

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < 5;i++){
    cout << s[i];
  }
  cout << " ";
  for(int i = 6;i < 13;i++)
    cout << s[i];
  cout << " ";
  for(int i = 14;i < 19;i++)
    cout << s[i];
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A;
    ll i;
    ll dp[N+1][3][2];
    dp[0][0][0]=0;
    dp[0][0][1]=0;
    dp[0][1][0]=0;
    dp[0][1][1]=0;
    dp[0][2][0]=0;
    dp[0][2][1]=0;
    for(i=1;i<=N;i++){
        cin >> A;
        dp[i][0][0]=dp[i-1][0][1];
        dp[i][0][1]=dp[i-1][0][0]+A;
        dp[i][1][0]=max(dp[i-1][1][1],dp[i-1][0][0]);
        dp[i][1][1]=dp[i-1][1][0]+A;
        dp[i][2][0]=max(dp[i-1][2][1],dp[i-1][1][0]);
        dp[i][2][1]=dp[i-1][2][0]+A;
    }
    if(N%2==0){
        cout << max(dp[N-1][0][1],dp[N][1][1])<<endl;
    }else{
        cout << max(dp[N-2][0][1],max(dp[N-1][1][1],dp[N][2][1]))<<endl;
    }
    return 0;
}


Measured memory_bytes: 12524
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define pi 3.14159265358979323846264338327950L
#define modd 1000000000
#define k 100000000

vector<int> a(0);
vector<int> b(0);
vector<int> c(0);
vector<int> d(0);
int ans=0;
int n,m,q;

void dfs(vector<int> arr)
{
        if(arr.size()==n)
        {
                int num=0;
                rep(i,q)
                {
                        if(arr[b[i]-1] - arr[a[i]-1] == c[i])
                                num+=d[i];
                }
                ans=max(ans,num);
        }
        else
        {
                int num=1;
                if(arr.size()!=0)
                        num=arr[arr.size()-1];

                for(int i=num;i<=m;i++)
                {
                        arr.emplace_back(i);
                        dfs(arr);
                        arr.erase(arr.begin()+arr.size()-1);
                }
        }
}
int main()
{
        fast;
        int t=1;
        //cin>>t;
        while(t--)
        {
                cin>>n>>m>>q;
                rep(i,q)
                {
                        int ai,bi,ci,di;
                        cin>>ai>>bi>>ci>>di;
                        a.emplace_back(ai);
                        b.emplace_back(bi);
                        c.emplace_back(ci);
                        d.emplace_back(di);

                }
                vector<int> arr(0);
                dfs(arr);
                cout<<ans<<endl;
                return 0;
         }

}

Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<int> row_target = vector<int>(H, A);
    vector<int> col_target = vector<int>(W, B);

    vector<int> row_num_1 = vector<int>(H, 0);
    vector<int> col_num_1 = vector<int>(W, 0);
    
    vector<vector<int>> ans(H, vector<int>(W, 0));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j) {
            if( (((min(row_num_1[i], W - row_num_1[i]) < A) || A==0)
            && ((min(col_num_1[j], H - col_num_1[j]) < B) || B==0))
            || ((min(row_num_1[i]+1, W - row_num_1[i]-1) >= A) && (min(col_num_1[j], H - col_num_1[j]) < B))
            || ((min(row_num_1[i], W - row_num_1[i]) < A) && (min(col_num_1[j]+1, H - col_num_1[j]-1) >= B))
            || ((min(row_num_1[i]+1, W - row_num_1[i]-1) >= A) && (min(col_num_1[j]+1, H - col_num_1[j]-1) >= B))
            )
            {
                cerr << "debug " << row_num_1[i] << " " << row_target[i] << endl;
                ans[i][j] = 1;
                row_num_1[i]++;
                col_num_1[j]++;
            }
        }
        if((min(row_num_1[i], W - row_num_1[i]) < A) && A!=0){
            cout << "No" << endl;
            return 0;
        }
    }

    cerr << "col condition" << endl;
    for(int j=0; j<W; j++) if((min(col_num_1[j], H - col_num_1[j]) < B) && B!=0){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) cout << ans[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define re register
#define LL long long
#define MOD 1000000007
#define MAXN 500005
#define lson (now<<1)
#define rson ((now<<1)|1)
using namespace std;
struct Edge{
	int to,nex;Edge(int _=0,int __=0){to=_,nex=__;}
}e[MAXN<<1];
int n,k,cnt,tot,hd[MAXN],du[MAXN],p[MAXN],ans[MAXN],t[MAXN<<2];
priority_queue<int,vector<int>,greater<int> >q;
int rd(){
	int x=0,tp=1;char c;c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
void adde(int x,int y){
	e[++cnt]=Edge(y,hd[x]);
	hd[x]=cnt,du[y]++;
}
void update(int now,int l,int r,int pos,int V){
	if(l==r){t[now]=V;return;}
	int mid=(l+r)>>1;
	if(pos<=mid)update(lson,l,mid,pos,V);
	else update(rson,mid+1,r,pos,V);
	t[now]=min(t[lson],t[rson]);
}
int query(int now,int l,int r,int L,int R){
	if(L<=l && r<=R)return t[now];
	int mid=(l+r)>>1,res=INF;
	if(L<=mid)res=query(lson,l,mid,L,R);
	if(mid<R)res=min(res,query(rson,mid+1,r,L,R));
	return res;
}
void topo(){
	for(int i=1;i<=n;i++)if(!du[i])q.push(i);
	while(!q.empty()){
		int now=q.top();q.pop();
		ans[now]=++tot;
		for(int i=hd[now];i;i=e[i].nex){
			du[e[i].to]--;
			if(!du[e[i].to])q.push(e[i].to);
		}
	}
}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("shit.out","w",stdout);
	int tmp;
	memset(t,INF,sizeof(t));
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)p[rd()]=i;
	for(int i=n;i>=1;i--){
		tmp=query(1,1,n,p[i],min(n,p[i]+k-1));
		if(tmp<INF)adde(p[i],p[tmp]);
		tmp=query(1,1,n,max(1,p[i]-k+1),p[i]);
		if(tmp<INF)adde(p[i],p[tmp]);
		update(1,1,n,p[i],i);
	}
	topo();
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 27764
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	for(int i=1;i<=5;i++){
		int x;
		cin>>x;
		if(x==0){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define lo long
const long long lmax=1999999999;
const long long lmx=1999999999999999999;
long long a,b,c;
int main(){std::ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    int ans=min(abs(a-b)+abs(a-c),min(abs(b-c)+abs(a-b),abs(a-c)+abs(b-c)));
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[4], b[4];
	int i, j, hit, blow;

	while(scanf("%d %d %d %d\n%d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF){
		hit = 0;
		blow = 0;
		for(i = 0;i < 4;i++){
			if(a[i] == b[i]){
				hit++;
			}

			for(j = 0;j < 4;j++){
				if((a[i] == b[j]) && (i != j)){
					blow++;
				}
			}
		}

		printf("%d %d\n", hit, blow);
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }
    else if(a<k&&k<=a+b){
        cout << a << endl;
    }
    else{
        cout << 2*a+b-k << endl;
    }
}

Measured memory_bytes: 3188
import sys

import numpy as np


class Graph:
    def __init__(self, N):
        self.townarrow = [i for i in range(N)]

    def find(self, x):
        if x == self.townarrow[x]:
            return x
        else:
            self.townarrow[x] = self.find(self.townarrow[x])
            return self.townarrow[x]

    def union(self, x, y):
        self.link(self.find(x), self.find(y))

    def link(self, x, y):
        self.townarrow[y] = x


N = int(input())
x = []
y = []
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

useful_road = []

l = sorted(range(N), key=lambda j: x[j])
for i in range(len(l) - 1):
    cost = min(abs(x[l[i]] - x[l[i + 1]]), abs(y[l[i]] - y[l[i + 1]]))
    useful_road.append((cost, l[i], l[i + 1]))

l = sorted(range(N), key=lambda j: y[j])
for i in range(len(l) - 1):
    cost = min(abs(x[l[i]] - x[l[i + 1]]), abs(y[l[i]] - y[l[i + 1]]))
    useful_road.append((cost, l[i], l[i + 1]))


m = 0
cost = 0
towngroup = Graph(N)
for c, i, j in sorted(useful_road):
    if towngroup.find(i) == towngroup.find(j):
        continue
    cost += c
    m += 1

    towngroup.union(i, j)

    if m == N - 1:
        print(cost)
        sys.exit()


Measured memory_bytes: 55484
while True:
    a, op, b = input().split()
    x = int(a)
    y = int(b)

    if op == '?':
        break
    elif op == '+':
        print(x + y)
    elif op == '-':
        print(x - y)
    elif op == '*':
        print(x * y)
    elif op == '/':
        print(x // y)
    



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<ll> X(N),Y(M);
    for(int i=0;i<N;i++) cin >> X[i];
    for(int i=0;i<M;i++) cin >> Y[i];
    mint x = 0,y = 0;
    for(int i=0;i<N;i++){
        x -= X[i]*(N-i-1);
        x += X[i]*i;
    }
    for(int i=0;i<M;i++){
        y -= Y[i]*(M-i-1);
        y += Y[i]*i;
    }
    cout << x*y << "\n";
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
int x[10000],a,k=0,i;
double b,c;
while(scanf("%d,%lf,%lf",&a,&b,&c)!=EOF){
if(b/c/c>=25)
x[k++]=a;
}
for(i=0;i<k;i++)
printf("%d\n",x[i]);
return 0;
}

Measured memory_bytes: 0
n= int(input())
li=list(map(int,input().split()))
li2=li.copy()
b=0
d=0
e=[]
for i in range(n+1):
  if b<=d:
    b=sum(li[:i+1])
    d=sum(li[i+1:])
    e.append(abs(b-d))
  else:
    print(min(e))
    break


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

#define print(x) cerr << #x << " is " << x << endl;
#define int long long int
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define all(v) (v).begin(), (v).end()   
#define pii pair<int, int>
#define pb push_back
#define PI 3.1415926535897932384626
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define out cout << fixed << setprecision(15)

#define radian2degree(a) (a * 57.295779513082)
#define degree2radian(a) (a * 0.017453292519)

const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const double lifeofpi = acos(-1);


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double theta1 = h * 30 + (m / 60) * 30;
    double theta2 = m * 6;
    const double halfC = lifeofpi / 180;
    // theta1 *= 0.017453292519;
    // theta2 *= 0.017453292519;
    
    theta1 *= halfC;
    theta2 *= halfC;

    double ans1 = (a * cos(theta1) - b * cos(theta2));
    double ans2 = (a * sin(theta1) - b * sin(theta2));

    double ans = ans1 * ans1 + ans2 * ans2;
    ans = sqrt(ans);

    out << ans << '\n';
    return 0;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define AB_BHI_NI_DEGI                \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

int power(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * a) % mod;
        n = n / 2;
        a = (a * a) % mod;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int32_t main()
{
    AB_BHI_NI_DEGI
    int Test = 1;
    //cin >> Test;
    while (Test--)
        solve();
    return 0;
}

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

int main(){
 	int n;
  	cin >> n;
  	vector<int> a(n);
  	for(int i = 0; i < n; i++) {
      	cin >> a[i]; 
  		a[i]--;
	}	
  	vector<bool> check(n);
	int count=0, now = 0;
    while(true) {
      if(check[now] == true)
      		break;
      check[now] = true;
      count++;
      if(a[now] == 1) {
      	cout << count << endl;
        return 0;
      }
      now = a[now];
      
    }
  	
  	cout << -1 << endl;
}


Measured memory_bytes: 640
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

H, W = MAP()
M = [[]*W for _ in range(H)]
odds = [-1] * H
for i in range(H):
	M[i] = MAP()
	odds[i] = sum([1 for m in M[i] if m%2])

ans = []
for i in range(H):
	for j in range(W):
		if odds[i] % 2 == 0:
			if M[i][j] % 2:
				if j+1 <= W-1:
					M[i][j] -= 1
					M[i][j+1] += 1
					ans.append([i, j, i, j+1])
				elif i+1 <= H-1:
					M[i][j] -= 1
					M[i+1][j] += 1
					ans.append([i, j, i+1, j])
					odds[i] -= 1
					odds[i+1] += 1
		else:
			if M[i][j] % 2:
				if j+1 <= W-1:
					M[i][j] -= 1
					M[i][j+1] += 1
					ans.append([i, j, i, j+1])
				elif i+1 <= H-1:
					M[i][j] -= 1
					M[i+1][j] += 1
					ans.append([i, j, i+1, j])
					odds[i] -= 1
					odds[i+1] += 1

print(len(ans))
for a in ans:
	print(' '.join(list(map(str, [i+1 for i in a]))))

Measured memory_bytes: 68316
n, t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

h = Hash.new(0)
min = max = a[0]
a.each do |e|
    if e < min
        h[max - min] += 1
        min = max = e
    else
        max = [max, e].max
    end
end
h[max - min] += 1

p h.max_by{|k,v| k}[1]

Measured memory_bytes: 20836
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int x;
	cin>>x;
	double dx=x;
	dx=dx/3.0;
	dx=dx*dx*dx;
	cout<<fixed<<setprecision(8)<<dx;
	return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split.map!(&:to_i)
sum = 0
(1..input[0]).each{ |i|
  i_s = i.to_s
  sum_2 = 0
  (1..i_s.length).each{ |j|
    sum_2 += i_s[j-1].to_i
  }
  if sum_2 >= input[1] && sum_2 <= input[2] then
    sum += i
  end 
}
puts sum

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int a[100][100],b[100],c[100];
  cin >> n >> m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      c[i]+=a[i][j]*b[j];
    }
    cout<<c[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>

static 
void printfig(int h, int w, int y, int x)
{
  if (x == 0 || y == 0 || x == (w - 1) || y == (h - 1))
    printf("#");
  else
    printf(".");
}

int main(int argc, char *argv[])
{
  int w[300], h[300];
  int i, j;

  for (i = 0; i < 300; i++) {
    scanf("%d %d", &h[i], &w[i]);
    if (w[i] == 0 && h[i] == 0)
      break;
  }

  for (j = 0; j < i; j++) {
    int k, n;
    for (k = 0; k < h[j]; k++) {
      for (n = 0; n < w[j]; n++) {
	printfig(h[j], w[j], k, n);
      }
      
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

ld d(ld x, ld y, ld a, ld b){
  return sqrt(pow(x - a, 2) + pow(y - b, 2));
}

void solve(){
  int n;
  cin >> n;
  vector<ld> x(n);
  vector<ld> y(n);
  forn(i,n){
    cin >> x[i] >> y[i];
  }
  ld ans = 0;
  forn(i, n){
    ld sm = 0;
    forn(j, n){
      if (i != j)
        sm += d(x[i], y[i], x[j], y[j]);
    }
    ans += sm / (ld)(n);
  }
  cout << fix(7) << ans;
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

k (k-1) (k-1)

2 6 3
4 6 5
6 6 7
7 7 7

*/

Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                if (i == 0){
                    for(int k = 0; k < W; k++){
                    System.out.printf("#");
                    }
                }else{
                    for (i = 1; i < H-1; i++) {
                        System.out.printf("#");
                        for (int k = 1; k < W-1; k++) {
                            System.out.printf(".");
                        }
                        System.out.printf("#");
                        System.out.printf("\n");
                    }
                }
                if (i == H-1){
                    for(int k = 0; k < W; k++){
                        System.out.printf("#");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 58144
#define ljt return 0;
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define Rint register int
char a[105];
int len;
int main()
{
    ios::sync_with_stdio(false);
    while(cin)
    {
        len++;
        cin>>a[len];
    }
    for(Rint i=1;i<=len;i++)
    {
        if(a[i]=='C')
        {
            for(Rint j=i+1;j<=len;j++)
            {
                if(a[j]=='F')
                {
                    cout<<"Yes";
                    ljt
                }
            }
        }
    }
    cout<<"No";
    ljt
}


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

int D;
double V[100];

double interpolate( int n, int E ) {

	double sum = 0.0;
	
	for ( int k = 0; k < D + 3; k++ ) {
	
		if ( k == n || k == E ) { continue; }
		
		double p = V[k];
		
		for ( int i = 0; i < D + 3; i++ ) {
		
			if ( i != k && i != n && i != E ) { p *= ( n - i ) / (double) ( k - i ); }
		
		}
		
		sum += p;
	
	}
	
	return sum;

}

bool outlier( int E ) {

	for ( int i = 0; i < D + 3; i++ ) {
	
		if ( i == E ) { continue; }
		
		double p = interpolate( i, E );
		
		if ( abs( p - V[i] ) > 0.1 ) { return false; }
	
	}
	
	return true;

}

int main() {

	while ( cin >> D && D != 0 ) {
	
		for ( int i = 0; i < D + 3; i++ ) { cin >> V[i]; }
		
		for ( int i = 0; i < D + 3; i++ ) {
		
			if ( outlier( i ) ) {
			
				cout << i << endl;
				break;
			
			}
		
		}
	
	}

}

Measured memory_bytes: 1232
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll
int visited[200000];
string s;
pair<int, int> calc(int now) {
	int now_l = now - 1;
	int now_r = now + 1;
	int cnt = 0;
	while (now >= 0 && now < s.length()) {
		if (s[now] == '>') {
			now = now_r;
			now_r++;
		}
		else if(s[now] == '<') {
			now = now_l;
			now_l--;
		}
		cnt++;
	}
	if (now < 0) {
		return mp(1, cnt);
	}
	else {
		return mp(0, cnt);
	}
}
void solve(){
	int n;
	cin >> n >> s;
	int bot = -1;
	int top = s.length();
	while (top - bot > 1) {
		int mid = (top + bot) / 2LL;
		if (calc(mid).first == 1) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	cout << max(calc(bot).second, calc(bot + 1).second) << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3336
import java.util.Scanner;

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

		while(true){
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();

			int a = m+f;//コードを短くするため変数aを作る
			if((a+r) <= -3){//終了条件の明記
				break;}
			if((m == -1)||(f == -1)){//－１が出た時点でF
				System.out.println("F");
			}
			else if(a >= 80){
				System.out.println("A");
			}
			else if(a >=65){
				System.out.println("B");
			}
			else if((a >=50)||(r >=50) ){
				System.out.println("C");
			}
			else if(a >=30){
				System.out.println("D");
			}
			else if(a < 30){
				System.out.println("F");
			}
		
		}
		scanner.close();
	}
}




Measured memory_bytes: 26280
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	d := make([]int, n)

	for i := range d {
		d[i] = -1
	}
	for i := 0; i < m; i++ {
		s := nextInt() - 1
		c := nextInt()
		if d[s] >= 0 && d[s] != c {
			_, _ = fmt.Fprint(writer, "-1")
			return
		}
		if n > 1 && s == 0 && c == 0 {
			_, _ = fmt.Fprint(writer, "-1")
			return
		}
		d[s] = c
	}

	for i := range d {
		if i == 0 && n > 1 {
			if d[i] > 0 {
				_, _ = fmt.Fprintf(writer, "%d", d[i])
			} else {
				_, _ = fmt.Fprintf(writer, "%d", 1)
			}
		} else {
			if d[i] > 0 {
				_, _ = fmt.Fprintf(writer, "%d", d[i])
			} else {
				_, _ = fmt.Fprintf(writer, "%d", 0)
			}
		}
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
N = int(input())
B = list(map(int,input().split()))
ans = []
i = N-1
while i != 0:
    x = len(B)
    for j in range(i,-1,-1):
        if B[j] == j+1:
            B.pop(j)
            ans.append(j+1)
            i -= 1
            break
    if x == len(B):
        break
if len(B) == 1 and B[0] == 1:
    ans.append(1)
    print(*ans[::-1],sep="\n")
else:
    print(-1)



Measured memory_bytes: 3064