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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll a,b,c;
 cin>>a>>b>>c;
 if(c!=a&&a==b)
 {
     cout<<"Yes"<<endl;
     return 0;
 }
 if(b!=a&&b==c)
 {
     cout<<"Yes"<<endl;
     return 0;
 }
 if(a!=b&&c==a)
 {
     cout<<"Yes"<<endl;
     return 0;
 }
 cout<<"No"<<endl;

return 0;
}



Measured memory_bytes: 256
#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;
    string S;
    cin >> N >> S;
    vector<int> R(N + 1, 0), G(N + 1, 0), B(N + 1, 0);
    rep(i, N) {
        R[i + 1] = R[i];
        G[i + 1] = G[i];
        B[i + 1] = B[i];
        if (S[i] == 'R') R[i + 1]++;
        if (S[i] == 'G') G[i + 1]++;
        if (S[i] == 'B') B[i + 1]++;
    }
    ll ans = 0;
    rep(i, N - 3) {
        for (int k = i + 3; k < N; k++) {
            if (S[i] == S[k]) continue;
            if ((S[i] == 'R' && S[k] == 'G') || (S[i] == 'G' && S[k] == 'R')) {
                ans += B[k] - B[i];
                if ((i + k) % 2 == 0 && S[(i + k) / 2] == 'B') ans--;
            }
            if ((S[i] == 'R' && S[k] == 'B') || (S[i] == 'B' && S[k] == 'R')) {
                ans += G[k] - G[i];
                if ((i + k) % 2 == 0 && S[(i + k) / 2] == 'G') ans--;
            }
            if ((S[i] == 'G' && S[k] == 'B') || (S[i] == 'B' && S[k] == 'G')) {
                ans += R[k] - R[i];
                if ((i + k) % 2 == 0 && S[(i + k) / 2] == 'R') ans--;
            }
        }
    }
    cout << ans << "\n";
    /*
    rep(i, N + 1) cout << R[i] << " ";
    cout << "\n";
    rep(i, N + 1) cout << G[i] << " ";
    cout << "\n";
    rep(i, N + 1) cout << B[i] << " ";
    cout << "\n";
    */
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

vector<int> v[1000001],g[1000001];
ll a[1000001];
void Main() {
  int n;
  R n;
  int c[n];
  mem(c);
  rep(i,n) {
    int x;
    cin >> a[i] >> x;
    if(x==-1) continue;
    v[i].pb(x);
    g[x].pb(i);
    c[x]++;
  }
  queue<int> que;
  rep(i,n) if(!c[i]) que.push(i);
  ll ans=0;
  while(!que.empty()) {
    int x=que.front();que.pop();
    vector<ll> w;
    rep(i,g[x].size()) w.pb(a[g[x][i]]);
    sort(all(w));
    ll sum=0;
    rep(i,w.size()) {
      ans+=sum;
      sum+=w[i];
    }
    a[x]+=sum;
    rep(i,v[x].size()) {
      int y=v[x][i];
      c[y]--;
      if(!c[y]) que.push(y);
    }
  }
  pr(ans);
}

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


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

int main() {
    int m, r, f;
    int total;
    
    while(1) {
        cin >> m >> r >> f;
        total = m + r;
        if (m == -1 && r == -1 && f == -1) {
            break;
        } else if (total < 30 || m == -1 || r == -1) {
            cout << "F";
        } else if (total >= 80) {
            cout << "A";
        } else if (total >= 65 && total < 80) {
            cout << "B";
        } else if (total >= 50 && total < 65 || f >= 50) {
            cout << "C";
        } else if (total >= 30 && total < 50) {
            cout << "D";
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        Map<Character, Integer[]> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if (map.containsKey(s[i])) {
                Integer[] range = map.get(s[i]);
                range[1] = Math.max(range[1], i);
            } else {
                map.put(s[i], new Integer[]{i, Integer.MIN_VALUE});
            }
        }
        int max = 0;
        Map<Integer, Integer> countMap = new HashMap<>();
        for (Map.Entry<Character, Integer[]> item : map.entrySet()) {
            Integer[] range = item.getValue();
            if (range[0] > range[1]) {
                continue;
            }
            for (int i = range[0]; i <= range[1]; i++) {
                int count = countMap.getOrDefault(i, 0) + 1;
                countMap.put(i, count);
                max = Math.max(max, count);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>

int main(){
    int number;//学籍番号
    double height,weight;//身長と体重
    double bmi;//BMIの値
    
    while(scanf("%d,%lf,%lf",&number,&height,&weight)!=EOF){
        bmi=height/weight/weight;
        if(bmi>=25){
            printf("%d\n",number);
        }
    }
    
    return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

int main()
{
	string s;
	char m[13]={0},p=0,d,pm;
	cin>>s;

	for(unsigned int i=0;i<s.size();i++){
		d=s[i]/10-p;

		for(int j=0;j<abs(d);j++){
			if(d>0) cout<<">";
			else cout<<"<";
		}
		if(m[d+p]==0){
			for(int j=0;j<(d+p)*10;j++) cout<<"+";
			m[d+p]=(d+p)*10;
		}

		pm=(s[i]>m[d+p]) ? '+' : '-';
		for(char j=0;j<abs(s[i]-m[d+p]);j++){cout<<pm;}
		cout<<"."; m[d+p]=s[i]; p+=d;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int left = 1, right = N;
		for(int i = 1; i <= M; i++){
			int li = sc.nextInt();
			int ri = sc.nextInt();
			left = Math.max(left, li);
			right = Math.min(right, ri);
		}
		
		if(right < left) System.out.println(0);
		else System.out.println(right - left + 1);
	}
}

Measured memory_bytes: 65100
//dhruv
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
const int inf = 1e18 + 5;
 
template<typename T>
T binpow(T a,T b,T modi){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a)%modi;
		}
		b /= 2;
		(a *= a) %= modi;
	}
	return res;
}
 
 
template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a);
		}
		b /= 2;
		a *= a;
	}
	return res;
}
 
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}
template<typename T>
T inv(T a){
	return binpow(a,mod - 2,mod);
}

int make_int(string s){
	int x = 0;
	reverse(s.begin(),s.end());
	string tmp = s;
	for(int i = 0;i < s.length(); ++i){
		x *= 10;
		x += (int)(tmp.back() - '0');
		tmp.pop_back();
	}
	return x;
}
 
string make_string(int s){
	string x;
	while(s){
		x.push_back(char(s%10 + '0'));
		s /= 10;
	}
	reverse(x.begin(),x.end());
	return x;
}

random_device rd;
mt19937 g(rd());

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



const int N = 100;
int lp[N + 1];
vector<int> pr;
void ls(){
	for(int i = 2;i <= N; ++i){
		// means prime
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(int j = 0;j < pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; j++){
			lp[i*pr[j]] = pr[j];
		}
	}
}


// getting the prime factorisation

vector<int> getfc(int n){
	vi fact;
	while(n != 1){
		int x = lp[n];
		fact.push_back(x);
		while(n%x == 0){
			n /= x;
		}
	}
	return fact;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vi cnt(n + 1);
	int tot = 1;
	fro(i,2,n + 1){
		for(int j = i;j <= n;j += i){
			cnt[j]++;
		}
		cnt[i]++;
		tot += (i*cnt[i]);
	}
	cout << tot;
	// shuffle(all(a),g);
	return 0;
}

Measured memory_bytes: 81348
#include <iostream>
using namespace std;
int main (void) {
    int n;
    int y;

    cin >> n >> y;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y && 0 <= k && k <= n) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N+10];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int n,w;
      cin>>n>>w;
      int val[n];
      int wt[n];
      rep(i,0,n)
      {
          cin>>wt[i]>>val[i];
      }
      dp[0] = 0;
      rep(i,0,n)
      {
          bep(j,w,wt[i])
          {
                 dp[j] = max(dp[j],dp[j-wt[i]]+val[i]);

          }
      }
      cout<<dp[w]<<el;



    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int h_max = 0;
    for (int i = 0; i < n; i++) {
        h_max = (h_max < h[i]) ? h[i] : h_max;
    }
    int cnt = 0;
    bool zero = true;
    for (int i = 0; i < h_max; i++) {
        for (int j = 0; j < n; j++) {
            if (zero) {
                if (h[j]) {
                    cnt++;
                    h[j]--;
                    zero = false;
                }
            } else {
                if (h[j]) {
                    h[j]--;
                } else {
                    zero = true;
                }
            }
        }
        zero = true;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
/*
仮にXorY座標だけを1変化させることを考えたとき、すべての奇数秒に対してそれを満たす経路が存在する。
逆に偶数秒で1変化させる経路は存在しない。
奇数秒で奇数分移動したら合計時間は奇数、奇数秒で偶数分移動したら合計時間は偶数
Xの移動量+Yの移動量をn、かかる時間をtとする。
n < t　で　tとｎの偶奇が一致するなら移動経路が存在する
*/

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  
  int t, x, y;
  t = x = y = 0;
  
  for(int i = 0; i < N; ++i)
  {
    int ti, xi, yi;
    cin >> ti >> xi >> yi;
    
    int deltaMove = abs(xi - x) + abs(yi - y);
    int deltaTime = ti - t;
    
    // 移動量0は偶数だけど最低でも4秒になる
    if(deltaMove == 0 && deltaTime > 4 && deltaTime % 2 == 0)
    {
      t = ti;
      x = xi;
      y = yi;
      continue;
    }
    
    if(deltaTime >= deltaMove && deltaTime % 2 == deltaMove % 2)
    {
      t = ti;
      x = xi;
      y = yi;
    }
    else if(deltaTime < deltaMove || deltaTime % 2 != deltaMove % 2)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    int odd = 0,even = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a%2) odd++;
        else even++;
    }
    cout << (odd%2 ? "NO" : "YES") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x[5];
	int i;

	for (i = 0; i < 5; i++) {
		scanf("%d", &x[i]);
	}

	for (i = 0; i < 5; i++) {
		if (x[i] == 0) {
			printf("%d\n", i + 1);
		}
	}



	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sum=0;
  string s;
  cin>>s;
  for(int i=0;i<(1<<4);i++){
    sum=0;
    for(int j=0;j<4;j++){
      if(i&(1<<j)&&j!=0){
        sum-=s[j]-'0';
      }
      else{
        sum+=s[j]-'0';
      }
    }
    if(sum==7){
      for(int j=0;j<4;j++){
        if(i&(1<<j)&&j!=0){
          cout<<"-";
        }
        else if(j!=0) cout<<"+";
        cout<<s[j];
      }
      cout<<"=7\n";
      break;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,k,n,m,l,a[100][100],b[100][100];
	long int c[100][100]={0};
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j>0){
				printf(" ");
			}
			printf("%ld",c[i][j]);
		}
		printf("\n");
	}
	return 0;
}


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

int main() {
  int N;
// N番目のリュカ数を求める
  cin >> N;

  vector<long> vec(N+1);

  vec.at(0) = 2;
  vec.at(1) = 1;
  
  for(int i=2; i<N+1; i++) {
    vec.at(i) = vec.at(i-1) + vec.at(i-2);    
  }
  
  cout << vec.at(N) << endl;
}


Measured memory_bytes: 256
s = require("fs").readFileSync("/dev/stdin","utf8").split('\n')
n = s[0].split(' ')[0] | 0
k = s[0].split(' ')[1] | 0
s.shift()
s = s.map(n => n | 0).sort((a, b) => b - a)
a = 1000000000;
[...Array(n - k + 1)].forEach((_, i) => (t = s[i] - s[i + k - 1], t < a ? a = t : 0))
console.log(a)


Measured memory_bytes: 29368
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=2e6+5,YL=1e9+7;
inline int MO(const int &x){return x>=YL?x-YL:x;}
inline void add(int &x,int y){if((x+=y)>=YL)x-=YL;}
int dep[N],a[N],bj[N],Q[N],len,top,b[N],tot,du[N],o[N],st[N],f[N],fa[N];
void check_circle()
{
	for(int i=1;i<=len;++i)if(du[Q[i]]^1)return;
	for(int i=1;i<=len;++i)bj[Q[i]]=3;b[++tot]=len;
}
void dfs(int u)
{
	bj[u]=1,o[u]=1;
	if(!bj[a[u]])return fa[a[u]]=u,dfs(a[u]),o[u]=0,void();
	if(o[a[u]])
	{
		len=0;
		for(int now=u;;now=fa[now])
		{Q[++len]=now,bj[now]=2;if(now==a[u])break;}
		check_circle();
	}
	o[u]=0;
}
void Dfs(int u){dep[a[u]]=dep[u]+1;if(bj[a[u]]>1)return;Dfs(a[u]);}
int solve(int x)
{
	int ans=1;Q[len=1]=x;
	for(int now=a[x];now^x;now=a[now])Q[++len]=now;
	std::reverse(Q+1,Q+len+1);
	for(int i=1;i<=len;++i)bj[Q[i]]=4,Q[len+i]=Q[i];
	for(int i=1,j;i<=len;++i)
		if(dep[Q[i]])
		{
			for(j=i+1;j<=(len<<1)&&!dep[Q[j]];++j);
			if(dep[Q[i]]>j-i)puts("0"),exit(0);
			if(dep[Q[i]]<j-i)add(ans,ans);i=j-1;
		}
	return ans;
}
int main()
{
	int n=in();for(int i=1;i<=n;++i)++du[a[i]=in()];
	for(int i=1;i<=n;++i)if(!du[i])dfs(i);
	for(int i=1;i<=n;++i)if(!bj[i])dfs(i);
	for(int i=1;i<=n;++i)
		if((bj[i]>1&&du[i]>2)||(bj[i]==1&&du[i]>1))return puts("0"),0;
	std::sort(b+1,b+tot+1);int ans=1;
	for(int i=1,j;i<=n;i=j)
	{
		for(j=i;j<=n&&b[i]==b[j];++j);f[i-1]=1;
		for(int k=i;k<j;++k)
		{
			f[k]=f[k-1];
			if(b[i]>1&&(b[i]&1))add(f[k],f[k-1]);
			if(k>i)f[k]=(1ll*f[k-2]*b[i]%YL*(k-i)+f[k])%YL;
		}
		ans=1ll*ans*f[j-1]%YL;
	}
	for(int i=1;i<=n;++i)if(bj[i]==1)bj[i]=0;
	for(int i=1;i<=n;++i)if(!du[i])Dfs(i);
	for(int i=1;i<=n;++i)if(bj[i]==2)ans=1ll*ans*solve(i)%YL;
	return printf("%d\n",ans),0;
}


Measured memory_bytes: 21504
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,q,a[100005]={},l,r;
  cin >> n >> q;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  while(q--) {
    cin >> l >> r;
    int L,R;
    L=lower_bound(a,a+n,l)-a;
    R=upper_bound(a,a+n,r)-a-1;
    cout << R-L+1 << endl;
  }
}




Measured memory_bytes: 3536
#include <stdio.h>

int main (void){
    int n, i, j, temp, count = 0;
    scanf("%d", &n);
    int r[n];
    
    for(i = 0; i < n; i++){
        scanf("%d", &r[i]);
    }
    
    for(i = 0; i < n-1; i++){
        for(j = n-1; j > i; j--){
            
            if(r[j] < r[j-1]){
                temp = r[j];
                r[j] = r[j-1];
                r[j-1] = temp;
                count = count + 1;
            }    
        }
    }
    
    for(i = 0; i < n; i++){
        printf("%d", r[i]);
        if(i != n-1) printf(" ");
        
    }
    
    puts("");
    printf("%d\n", count);

    return 0;    
}

Measured memory_bytes: 616
#include<stdio.h>
int main()
{
    double a,b,t,i,s=0;
    scanf("%lf %lf %lf",&a,&b,&t);
    t+=0.5;
    for(i=a;i<=t;i+=a)
        s+=b;
    printf("%.0lf\n",s);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a, b, c;
      a = sc.nextInt();
      b = sc.nextInt();
      c = sc.nextInt();
      
      int arr[] = {a, b, c};
             
    int n = arr.length;
      
      for(int i = 1; i<n; i++){
      int j = i-1;
      
      int key = arr[i];
      while(j>=0 && key<arr[j]){
      arr[j+1] = arr[j];
      j--;
      }
      arr[j+1] = key;
      }
      System.out.println( arr[0]+ " " +arr[1]+ " " +arr[2]);
      
    }
    }


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int x, y;
    cin >> x >> y;
    if(2*x<=y&&y<=4*x){
        if(y%2==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 3628
import math
n,h = map(int ,raw_input().split())
ais = [map(int, raw_input().split()) for _ in range(n)]
ais.sort(key = lambda x: (-x[1],x[0]))
cumul = 0
r = +float('inf')
m = max(ais)[0]
for i in range(-1,len(ais)):
	if i >= 0:
		cumul += ais[i][1]

	if cumul >= h:
		r = min(r, (i+1))
		break
	else:
		r = min(r, i+1 + math.ceil(abs(h - cumul) /  float(m)))
print int(r)

Measured memory_bytes: 94640
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N,M,K;
Int inv[200000+10];
Int fact[200000+10];
Int invfact[200000+10];

Int comb(Int n,Int r) {
    if(r > n)
        return 0;
    if(n == 0 || r == 0)
        return 1;

    return ((fact[n] * invfact[n-r] % MOD) * invfact[r]) % MOD;
}

void solve(void) {
    fact[0] = fact[1] = 1;
    inv[1] = 1;
    invfact[0] = invfact[1] = 1;

    for(Int i = 2;i <= 200000+5;i++) {
        fact[i] = fact[i-1]*i % MOD;
        inv[i] = MOD - (MOD / i)*inv[MOD % i] % MOD;
        invfact[i] = inv[i]  * invfact[i-1] % MOD;
    }

    Int sum = 0;
    for(Int i = 1;i <= N;i++) {
        sum = (sum + comb(N*M-2,K-2)*i*(N-i)*M*M) % MOD;
    }
    for(Int i = 1;i <= M;i++) {
        sum = (sum + comb(N*M-2,K-2)*i*(M-i)*N*N) % MOD;
    }

    cout<<sum<<endl;

    return;
}
int main(void) {
    cin>>N>>M>>K;

    solve();

    return 0;
}




Measured memory_bytes: 4992
N, K = map(int, input().split(' '))
P = tuple(map(int, input().split(' ')))

values = [0]

for p in P:
    values.append(values[-1] + (p * (p + 1) // 2 / p))

ans = 0
for i in range(K, N + 1):
    ans = max(ans, values[i] - values[i - K])

print(ans)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int MAX_N = 110000;

int dp[MAX_N];

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

    rep(i, MAX_N) dp[i] = N;
    dp[0] = 0;

    for (int n = 1; n <= N; n++) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            chmin(dp[n], dp[n - pow6] + 1);
        }

        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            chmin(dp[n], dp[n - pow9] + 1);
        }
    }

    cout << dp[N] << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> p(M);
  vector<string> S(M);
  
  vector<int> AC(N), WA(N);
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }
  
  for (int i = 0; i < M; i++) {
    if(AC[p[i]-1] > 0) continue;
    if(S[i] == "WA") {
      WA[p[i]-1]++;
 	} else {
      AC[p[i]-1]++;
    }
  }
  
  int ac = 0, wa = 0;
  for (int i = 0; i < N; i++) {
    ac += AC[i];
    if (AC[i]) wa += WA[i];
  }
  
  cout << ac << ' ' << wa << endl;

  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n; cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i) cin >> c[i];

  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] > c[i]) res += v[i] - c[i];
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
using namespace std;

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

typedef long long ll;

int main(void)
{
    int N;
    cin >> N;

    int abc[N][3];
    ll dp[N][3];
    rep(i,N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    
    rep(i,N) {

        if (i==0) {
            dp[i][0] = abc[i][0];
            dp[i][1] = abc[i][1];
            dp[i][2] = abc[i][2];
            continue;
        }

        dp[i][0] = max(
            //前日b
            dp[i-1][1] + abc[i][0],
            //前日c
            dp[i-1][2] + abc[i][0]
        );

        dp[i][1] = max(
            //前日a
            dp[i-1][0] + abc[i][1],
            //前日c
            dp[i-1][2] + abc[i][1]
        );

        dp[i][2] = max(
            //前日a
            dp[i-1][0] + abc[i][2],
            //前日b
            dp[i-1][1] + abc[i][2]
        );

        //rep(j,N) cout << dp[j] << ",";
        //cout << endl;
    }

    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int  mod = 1e9+7;
int A, B;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main(void) {
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(0,min(b,d)-max(a,c))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, q;

int f(int a) {
	int c = 0;
	while(a != 0) {
		a = (a - 1) / n;
		c++;
	}
	return c;
}

int main() {
	cin >> n >> q;
	inc(qq, q) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		
		if(n == 1) {
			cout << min(a, b) + 1 << "\n";
		} else {
			int aa = f(a);
			int bb = f(b);
			if(aa > bb) { inc(i, aa - bb) { a = (a - 1) / n; } }
			if(aa < bb) { inc(i, bb - aa) { b = (b - 1) / n; } }
			while(a != b) {
				a = (a - 1) / n;
				b = (b - 1) / n;
			}
			cout << a + 1 << "\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 1280
//*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <cctype>
#include <complex>

#define N 200005
#define M 1000005

using namespace std;

typedef long long int lld;

int primeLength = 0;
int sieveArray[M];

void sieve(int limit) {
	sieveArray[1] = 1;
	for (int i = 2; i <= sqrt(limit); i++) {
		if (sieveArray[i] == 0) {
			sieveArray[i] = i;
			for (int j = i * i; j <= limit; j += i) {
				sieveArray[j] = i;
			}
		}
	}
	for (int i = sqrt(limit); i <= limit; i++) {
		if (sieveArray[i] == 0) {
			sieveArray[i] = i;
		}
	}
}

bool has[M];
bool multiple[M];
int vals[N];


int divs_fact[10];
int divs_cnt[10];

bool testVal(int n, int curr = 1, int pos = 0) {
	if (pos == n) {
		return has[curr];
	}
	int nouv = curr;
	for (int i = 0; i <= divs_cnt[pos]; i++) {
		if (testVal(n, nouv, pos + 1)) {
			return true;
		}
		nouv *= divs_fact[pos];
	}
	return false;
}

int main() {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	sieve(M - 2);

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> vals[i];
		has[vals[i]] = true;
	}

	sort(vals, vals + n);
	for (int i = 0; i < n-1; i++) {
		if (vals[i] == vals[i + 1]) {
			multiple[vals[i]] = true;
		}
	}

	auto last = unique(vals, vals + n);
	n = last - vals;
	int total = 0;
	for (int i = 0; i < n; i++) {
		int val = vals[i];
		if (multiple[val])continue;
		map<int, int> divs;
		int curr = val;
		while (curr != 1) {
			int div = sieveArray[curr];
			if (divs.count(div) == 0) {
				divs[div] = 1;
			}
			else {
				divs[div]++;
			}
			curr /= div;
		}
		int nb = 0;
		for (const auto& paire : divs) {
			divs_fact[nb] = paire.first;
			divs_cnt[nb++] = paire.second;
		}
		has[val] = false;
		if (!testVal(nb)) {
			total++;
		}
		has[val] = true;
	}

	cout << total << endl;

	return 0;
}

//*/ 

Measured memory_bytes: 10148
W,H,N = map(int,input().split())
X0 = 0
X = W
Y0 = 0
Y = H
for _ in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        X0 = max(X0,x)
    elif a == 2:
        X = min(X,x)
    elif a == 3:
        Y0 = max(Y0,y)
    else: # a == 4
        Y = min(Y,y)

if X0 >= X or Y0 >= Y:
    print (0)
else:
    print ((X-X0)*(Y-Y0))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>

class Permutation{
public:
    int n;
    std::vector<int> used, tmp;
    std::vector<std::vector<int>> perm_vector;
    int k;
    int total;

    Permutation(int _n, int _k) : n(_n), k(_k), used(n) {
	total = 0;
	permutation(0);
    }

    void permutation(int cnt){
	if(cnt == k){
	    total++;
	    perm_vector.push_back(tmp);
	    return;
	} 
	
        for(int i = 0; i < n; i++){
	    if(used[i] != 1){
		tmp.push_back(i);
	    	used[i] = 1;
	    	permutation(cnt+1);
		used[i] = 0;
		tmp.pop_back();
	    }
	}
    }
};

// 
// }

int main(void){
    // int n;
    // a.resize(k);
    // permutation()
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> coordinate(n);
    for(int i = 0; i < n; i++){
	std::cin >> coordinate[i].first >> coordinate[i].second;
    }

    Permutation all_index = Permutation(n, n);
    double total, ans, tmp;
    for(int i = 0; i < all_index.perm_vector.size(); i++){
        tmp = 0;
        for(int j = 1; j < all_index.perm_vector[i].size(); j++){
	    int before = all_index.perm_vector[i][j-1];
	    int after = all_index.perm_vector[i][j];
	    int ax = coordinate[before].first;
	    int ay = coordinate[before].second;
	    int bx = coordinate[after].first;
	    int by = coordinate[after].second;
            tmp += std::sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
        }
	total += tmp;
    }
    ans = total / all_index.total;
    std::cout << std::fixed << std::setprecision(15) << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6404
#include <iostream>
#include <string>

using namespace std;

int main()	{
  string a, b;
  cin >> a >> b;
  if (a.length() < b.length())	{
    cout << "LESS" << endl;
    return 0;
  }
  else if (a.length() > b.length())	{
    cout << "GREATER" << endl;
    return 0;
  }
  for (int i = 0; i < a.length(); i++)	{
    if (a[i] < b[i])	{
      cout << "LESS" << endl;
      return 0;
    }
    else if (a[i] > b[i])	{
      cout << "GREATER" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X, Y;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> Y;

	map<int, int> reward;
	reward[1] = 300000;
	reward[2] = 200000;
	reward[3] = 100000;

	int ans = 0;
	ans += reward[X];
	ans += reward[Y];
	if (X == 1 and Y == 1) ans += 400000;

	cout << ans << endl;
}







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

void trace(int A[], int N)
{
	cout << A[0];
	for (int i = 1; i < N; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;

	return;
}

void BubbleSort(int N, int A[]) {
	int count = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj])minj = j;
		}
		if (A[minj] != A[i])count++;
		swap(A[minj], A[i]);
	}
	trace(A, N);
	cout << count << endl;
	}


int main() {
	int N;
	cin >> N;
	int A[100];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	BubbleSort(N, A);
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<ll> vec(80000);
  for(int x=1;x<=100;x++)
  {
    for(int y=1;y<=100;y++)
    {
      for(int z=1;z<=100;z++)
      {
        vec[(x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x)] ++;
      }
    }
  }
  for(int i=1;i<N+1;i++)
  {
    cout << vec[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n;
cin >> n;
if(n==1){
    cout << 1 << endl;
    return 0;
}
vector<pair<int, int> > pa(n);
rep(i, n){
    ll a,b;
    cin >> a>> b;
    pa[i]=make_pair(a,b );
}
sort(pa.begin(),pa.end());

for(ll i=0;i<n-1;i++)for(ll j=i+1;j<n;j++){
    ll p,q;
    p=pa[j].first-pa[i].first;
    q=pa[j].second-pa[i].second;
    bool ch[n]={};
    
    ll an=0;
    rep(k,n){
        if(ch[k]==0){
            ch[k]=1;
            an++;
            ll seex=pa[k].first;
            ll seey=pa[k].second;
            for(ll l=k+1;l<n;l++){
                if(seex+p==pa[l].first&&seey+q==pa[l].second){
                    ch[l]=1;
                    seex+=p;
                    seey+=q;
                }
            }
        }
    }
    ans=min(ans,an);
    

}

cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int x; cin >> x;
  int d[n+10] = {0};
  d[0] = 0;
  int l[n + 10] = {0};
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(d[i] <= x)ans += 1;
    cin >> l[i];
    d[i+1] = d[i] + l[i]; 
  }
  if(d[n] <= x)ans += 1;
  cout << ans <<endl;

}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, m; cin >> n >> m;
    vector<P> q(m);

    rep(i, m) {
        ll a, b; cin >> a >> b;
        q[i] = MP(b, a);
    }
    sort(ALL(q));

    ll ans = 0, now = 0; // 答え、どこまで橋が架かっているか
    rep(i, m) {
        ll a = q[i].second, b = q[i].first;
        if(now < a) {
            ans++;
            now = b-1;
        }
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
signed main()
{   //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++)
    	{cin>>a[i];
    		b[i]=a[i];}

    sort(b,b+n);
    
    int c=0;

    for(int i=0;i<n;i++)
    {
    	if(a[i]!=b[i])c++;
    }		
  if(c>2)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;


    return 0;
}

Measured memory_bytes: 384
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [k,s] <- map read . words <$> getLine :: IO [Int]                                                                        
                                                                                                                           
  print $ length ['0'|x<-[(max 0 (s-2*k))..k],y<-[(max 0 (s-2*k))..k],x+y>=s-k,x+y<=s] 

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

Measured memory_bytes: 3628
while True:

  m = int(input())
  n = int(input())
  if m==n==0: exit()
  graph = []
  for _ in range(n):
    graph.append(list(map(int,input().split())))

  res = 0
  def dfs(r,c,ice):
    global res
    ice += 1
    graph[r][c] = 0

    for x,y in [(0,1), (1,0), (0,-1), (-1,0)]:
      nr,nc = r+x,c+y
      if nr<0 or nc<0 or nr>=n or nc>=m: continue
      if graph[nr][nc] == 1:
        dfs(nr,nc,ice)
    else:
      graph[r][c] = 1
      res = max(res, ice)

  for i in range(n):
    for j in range(m):
      if graph[i][j] == 1:
        dfs(i,j,0)

  print(res)


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int n;
	cin >> n;
	ll h[n];
	int count = 0;
	int maxi = 0;
	cin >> h[0];
	for(int i = 1; i < n; i++){
		cin >> h[i];
		if(h[i - 1] >= h[i])count++;
		else if(h[i - 1] < h[i]){
			maxi = max(maxi,count);
			count = 0;
		}

		 if(i == n - 1){
			maxi = max(maxi,count);
			count = 0;
		}
	}
	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll dp[3100][3100];

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  rep(i,n) dp[i][i] = 0;
  for (int len = 1; len <= n; ++len) {
    for (int i = 0; i+len <= n; ++i) {
      int j = i + len;
      if ((n-len)%2 == 0) {
        dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
      }
      else {
        dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
      }
    }
  }

  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 73984
import std.stdio;

int main() {
	int list[30];

	foreach(n; 0..28) {
		int idx;
		readf("%d\n", &idx);
		list[idx-1]=1;
	}
	foreach(idx, n; list[0..30]) {
		if(n==0) writeln(idx+1);
	}

	return 0;
}

Measured memory_bytes: 2468