akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
const int mod=1e9+7;
const int nf=1e9+7;

const int maxn=1e5+10;

int num[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
		cin>>num[i];
	
	if(n==1)
	{
		return cout<<"Yes"<<endl,0;
	}
	
	bool flag=true;
	
	for(int i=1;i<n;i++)
	{
		if(num[i]>num[i-1])
			num[i]--;
		
		if(num[i]<num[i-1])
		{
			flag=false;
			break;
		}
	}
	
	if(flag==true)
		return cout<<"Yes"<<endl,0;
	else
		return cout<<"No"<<endl,0;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a[7],b[7],c[7],d;
	for(d=0;d<7;d++){
		scanf("%d %d",&a[d],&b[d]);
		c[d]=a[d]-b[d];
	}
	for(d=0;d<7;d++){
		printf("%d\n",c[d]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    string s, t, s0;
    cin >> s >> t;
    s0 = s;
    while(s != t){
        s = s[s.length()-1] + s;
        s.pop_back();
        if(s == s0){
            break;
        }
    }
    if(s == t){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

const int kN = 18;
const int kC = 50 + 5;
const int kInf = 1'000'000'000;
int a[kN][2], dp[1 << kN][kC];

int main() {
    int n; scanf("%d", &n);
    for (int j = 0; j < 2; ++j) {
        for (int i = 0; i < n; ++i) scanf("%d", &a[i][j]);
    }
    for (int s = 0; s < (1 << n); ++s) {
        for (int p = 0; p < kC; ++p) dp[s][p] = kInf;
    }
    dp[0][0] = 0;
    for (int s = 0; s < (1 << n); ++s) {
        for (int p = 1; p < kC; ++p) dp[s][p] = min(dp[s][p], dp[s][p - 1]);
        vector<int> v, w;
        for (int i = 0; i < n; ++i) {
            if ((s >> i & 1) == 0) v.push_back(i);
            else w.push_back(i);
        }
        for (int i = 0, j = 0; i < v.size(); ++i) {
            while (j < w.size() && w[j] < v[i]) ++j;
            int f = (w.size() - j + i) & 1;
            int &ud = dp[s ^ (1 << v[i])][a[v[i]][f]];
            ud = min(ud, dp[s][a[v[i]][f]] + i);
        }
    }
    int ans = dp[(1 << n) - 1][kC - 1];
    if (ans == kInf) ans = -1;
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main(){
  int N, M;
  while(scanf("%d%d", &N, &M) > 0){
    int total_assign = 0;

    while(M--){
      int A;
      scanf("%d", &A);
      total_assign += A;
    }

    printf("%d\n", max(-1, N - total_assign));
  }
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    double r ; cin >> r;
    cout << 2 *  r * 3.14;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count=0;
    for (int i=0; i<=A; i++) {
        for (int j=0; j<=B; j++) {
            for (int k=0; k<=C; k++) {
                int sum = 0;
                sum = 500*i + 100*j + 50*k;
                if (sum==X) count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3460
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
const int N = 1e6 + 10;
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int cnt = 0;

vector<vi> g(110, vi(110, 1));

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/
	
	cin >> n >> k;

	if (k > (n - 1)*(n - 2) / 2)
	{
		return cout << "-1", 0;
	}

	cnt = 0;
	for (int i = 2; i <= n && cnt < k; i++)
	{
		for (int j = i+1; j <= n && cnt < k; j++)
		{
			g[i][j] = false;
			cnt++;
		}
	}

	cout << n*(n - 1) / 2 - cnt << endl;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (g[i][j])
			{
				cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100100
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, A;
    cin >> N >> A;
    ll x[55];
    ll i, j, k;
    for(i=0; i<N; i++) {
        cin >> x[i];
    }
    
    
    ll dp[N+5][N*A+5][N+5];
    memset(dp, 0, sizeof(dp));
    
    dp[0][0][0]=1;
    for(i=1; i<=N; i++) {
        for(j=0; j<=N*A; j++) {
            for(k=1; k<=i; k++) {
                if(j>=x[i-1])
                    dp[i][j][k]+=dp[i-1][j][k]+dp[i-1][j-x[i-1]][k-1];
                else
                    dp[i][j][k-1]+=dp[i-1][j][k-1];
            }
        }
    }
    
    
    ll ans=0;
    for(k=1; k<=N; k++) {
        ans+=dp[N][k*A][k];
    }
    
    pr(ans);
}













Measured memory_bytes: 59392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MM=1000000007;
 
int main() {
  ll N;
  ll K;
  cin >> N;
  cin >> K;
 
  ll A[N];
  rep(i,N){
    cin >> A[i];
  }
 
  ll b[N]={};
  ll c[N]={};
 
  rep(i,N){
    b[i] = c[i] = 0;
  }
 
  rep(i,N){
    rep(j,N){
      if(A[i] > A[j] && i > j ){
        b[i]++;
      }
      if(A[i] > A[j] && i < j ){
        c[i]++;
      }
    }
  }
 
 
  /*rep(i,N){
    cout << b[i] << " " << c[i] << endl;
  }*/
 
  ll ans = 0;
 
  rep(i,N){
    ll res1 = K * (K + 1) / 2 % MM;
    ll x = c[i] * res1 % MM;
    ll res2 = K * (K - 1) / 2 % MM;
    ll y = b[i] * res2 % MM;
    ll z = (x + y) % MM;
    ans = (ans + z) % MM;
  //  cout << x << " " << y << " " << ans << endl;    
  }
 
 
  cout << ans << endl;
 
 
}

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

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;

    vector<int> lens(N);

    for(int i=1;i<N;i++){
        lens.at(i) = 0;
    }
    int len;

    for(int i=1;i<N;i++) {
        for(int j=i+1;j<N+1;j++){
            len = min(j-i, abs(X - i) + 1 + abs(Y - j));
            lens.at(len)++;
        }
    }

    for(int i=1;i<N;i++){
        cout << lens.at(i) << endl;
    }
    
    return 0;
}

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

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;

	cin >> n;

	vector<ll> d(n);
	ll sz = 1000001;
	vector<bool> arr(sz, true);
	unordered_set <ll> st;

	for (int i = 0; i < n; i++) {
		cin >> d[i];
		
		if (st.find(d[i]) == st.end()) {
			st.insert(d[i]);

			for (ll j = d[i] * 2; j < sz; j += d[i]) {
				arr[j] = false;
			}
		}
		else {
			arr[d[i]] = false;
		}
	}

	ll ans = 0;
	
	for (ll i = 0; i < (ll)(d.size()); i++) {
		if (arr[d[i]]) {
			ans++;
		}
	}


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

Measured memory_bytes: 12996
#include<stdio.h>
int main()
{
    int A, B, C, D, t=1;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    C=C-B;
    while(C>0){
        A=A-D;
        if(A<1){
            t=0;
            break;
        }
        else{
            C=C-B;
        }
    }
    if(t==1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    vector<vector<ll>> dp(3, vector<ll>(100009, 0));
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, n) {
        dp[0][i+1] = max(dp[1][i], dp[2][i]) + a[i];
        dp[1][i+1] = max(dp[2][i], dp[0][i]) + b[i];
        dp[2][i+1] = max(dp[1][i], dp[0][i]) + c[i];
    }

    ll ans = max({dp[0][n], dp[1][n], dp[2][n]});
    cout << ans << endl;
}


Measured memory_bytes: 5760
divableN :: Integral a => a -> a -> a
divableN n x
  | x `rem` n /= 0 = 0
  | otherwise      = 1 + divableN n (x `div` n)

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    print . sum . map (divableN 2) $ a


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
T expt(T a, std::int64_t n){
    T power {1};
    while(n > 0){
        if(n & 1){power *= a;}
        a *= a;
        n >>= 1;
    }
    return power;
}

constexpr ll MAX = 3234566667ll;
std::vector<ll> v;

void rec(int i, int p, ll n){
    if(i < 0){
        if(n > 0){
            v.emplace_back(n);
        }
        return;
    }

    if(p == -1){
        rec(i - 1, p, n);
    }

    int mn = (p == -1) ? 1 : 0;

    for(int c=mn;c<=9;++c){
        if(p == -1 || std::abs(c - p) <= 1){
            ll m = expt<ll>(10, i) * c + n;
            
            if(m <= MAX){
                rec(i - 1, c, m);
            }
        }
    }
}

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

    rec(9, -1, 0);

    // for(ll n : v){
    //     std::cout << n << std::endl;
    // }

    int K;
    std::cin >> K;

    std::cout << v[K-1] << std::endl;
}


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

int main() {

	int N;
	int pInput[30];
	int** p;
	int pRowIndex;
	int i;
	int j;
	int k;
	int l;
	int pat;
	int pMovingType[5];
	int t[5];
	int curRow;
	int kai[30] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3 };

	p = (int**)malloc(sizeof(int*) * 65536);
	for (i = 0; i < 65536; i++) p[i] = (int*)malloc(sizeof(int) * 30);

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		for (j = 0; j < 30; j++) scanf("%d", &pInput[j]);
		for(j = 0; j < 30; j++) if(pInput[j] != kai[j]) break;
		if(j == 30){
			printf("0\n");
			goto next;
		}
		for (j = 0; j < 65536; j++) for (k = 0; k < 30; k++) p[j][k] = pInput[k];
		pRowIndex = 65536;
		pat = 1;
		for (j = 1; j <= 8; j++) {
			for (k = 1; k <= pat * 4; k++) {
				for (l = 1; l <= pRowIndex / 4; l++) {
					if (k % 4 == 1) {
						pMovingType[0] = 1;
						pMovingType[1] = 2;
						pMovingType[2] = 3;
						pMovingType[3] = 15;
						pMovingType[4] = 19;
					}
					else if (k % 4 == 2) {
						pMovingType[0] = 9;
						pMovingType[1] = 6;
						pMovingType[2] = 3;
						pMovingType[3] = 12;
						pMovingType[4] = 13;
					}
					else if (k % 4 == 3) {
						pMovingType[0] = 7;
						pMovingType[1] = 8;
						pMovingType[2] = 9;
						pMovingType[3] = 13;
						pMovingType[4] = 10;
					}
					else if (k % 4 == 0) {
						pMovingType[0] = 7;
						pMovingType[1] = 4;
						pMovingType[2] = 1;
						pMovingType[3] = 10;
						pMovingType[4] = 16;
					}

					curRow = l + (pRowIndex / 4) * (k - 1) - 1;

					t[0] = p[curRow][pMovingType[0] - 1];
					t[1] = p[curRow][pMovingType[1] - 1];
					t[2] = p[curRow][pMovingType[2] - 1];
					t[3] = p[curRow][pMovingType[3] - 1];
					t[4] = p[curRow][pMovingType[4] - 1];
					p[curRow][pMovingType[0] - 1] = p[curRow][30 - pMovingType[2]];
					p[curRow][pMovingType[1] - 1] = p[curRow][30 - pMovingType[1]];
					p[curRow][pMovingType[2] - 1] = p[curRow][30 - pMovingType[0]];
					p[curRow][pMovingType[3] - 1] = p[curRow][30 - pMovingType[3]];
					p[curRow][pMovingType[4] - 1] = p[curRow][pMovingType[4] + 1];
					p[curRow][30 - pMovingType[0]] = t[2];
					p[curRow][30 - pMovingType[1]] = t[1];
					p[curRow][30 - pMovingType[2]] = t[0];
					p[curRow][30 - pMovingType[3]] = t[3];
					p[curRow][pMovingType[4] + 1] = t[4];

				}
				for(l = 0; l < 30; l++) if(p[curRow][l] != kai[l]) break;
				if(l == 30){
					printf("%d\n", j);
					goto next;
				}
			}
			pRowIndex /= 4;
			pat *= 4;
		}
		next:
		;
	}
	for (i = 0; i < 65536; i++) free(p[i]);
	free(p);

	return 0;
}


Measured memory_bytes: 10048
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

    ll A,B,K;
    cin>>A>>B>>K;
    if(A>=K){
        A-=K;
        K=0;
    }
    else{
        K-=A;
        A=0;
        if(B>=K){
            B-=K;
            K=0;
        }
        else{
            K-=B;
            B=0;
        }
    }


cout<<A<<" "<<B<<endl;
return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)

   int main(){
        ll n,m;
        cin>>n>>m;
      ll r=min(n,m);
      ll rr=max(n,m);
      for(ll i=0; i<rr; i++)cout<<r;
        cout<<endl;

     }
   

Measured memory_bytes: 3556
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<limits>
#include<bitset>
#include<unordered_map>
#include<functional>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define Sort(a) sort(all(a))
#define Qsort(a,size) qsort(a,size,sizeof(*a),compare_int)
#define DEBUG
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
bool compare_int(const void *a,const void *b) { return *(int *)a-*(int *)b; }
bool compare_by_second(II a,II b) { return a.second!=b.second?a.second<b.second:a.first<b.first; }

const int INF = 1e+9;
const int MAX_N = 5e+2;

int N;
double res = 0;
vector<double> rad;
vector<double> cood;

void solve();

int main() {

  cin>>N;
  rad.resize(N);
  cood.resize(N);
  rep(i,0,N) cin>>rad[i];
  solve();

  return 0;
}

void solve() {

  rep(i,0,N) cood[i] = 0.0;
  cood[0] = rad[0];
  rep(i,1,N) {
    rep(j,0,i) {
      cood[i] = max(cood[i],2*sqrt(rad[i]*rad[j])+cood[j]);
    }
    cood[i] = max(cood[i],rad[i]);
  }

  rep(i,0,N) res = max(res,cood[i]+rad[i]);
  cout<<fixed<<setprecision(8)<<res<<endl;
  return ;
}



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

int main() {
  int x, y;
  cin >> x >> y;
  vector <int> vec = { 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  
  if ( vec.at(x-1) == vec.at(y-1) ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
 
int A[N],n;
 
int partition(int p, int r){
  int x,i,j,copy;
  x = A[r];
  i = p-1; 
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i += 1;
      copy = A[i];
      A[i] = A[j];
      A[j] = copy;
    }
  }
  copy = A[i+1];
  A[i+1] = A[r];
  A[r] = copy;
  return i+1;
}
int main(){
  int i,q;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  q = partition(0, n-1);
  for(i = 0; i < q; i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[q]);
  for(i = q+1; i < n-1; i++){
    printf("%d ",A[i]);
  } 
  printf("%d\n",A[n-1]);
  return 0;
}

Measured memory_bytes: 988
a=input().split()
b=int(a[0])
c=int(a[1])
d=[c]*(b-1)
e=str(c)
for i in d:
  e=e+str(c)
f=[b]*(c-1)
g=str(b)
for i in f:
  g=g+str(b)
if e<g :
  print(e)
else:
  print(g)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
int main(){
	int n;
	while(cin>>n,n){
		int N=n*(n+1)/2;
		vi odd,even,in(N);
		rep(i,N){
			cin>>in[i];
			if(in[i]%2)odd.pb(in[i]);
			else even.pb(in[i]);
		}
		sort(all(odd));
		sort(all(even));
		ll a=gcd(even[0],odd[0]);
		ll x=(long long)sqrt(even[0]/a*(even[1]/(odd[0]/a)));
		cout<<x<<endl;
		int cnt=0;
		rep(i,even.size()){
			if(cnt)cout<<" ";
			cout<<even[i]/x;
			cnt++;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = (int) 1e9 + 7;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

using namespace std;

const int MAXN = 2e5;

int last[MAXN + 1];

int main() {
    //ifstream cin("B.in");
    //ofstream cout("B.out");
    int i, n;
    ll k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;

    vector <int> a(n + 1);
    for(i = 1; i <= n; i++) {
        cin >> a[i];
    }

    vector < vector <int> > nxt(n + 2, vector <int>(20));
    for(i = n; i >= 1; i--) {
        nxt[i][0] = last[a[i]];
        if(nxt[i][0] != 0) {
            nxt[i][0]++;
        }
        last[a[i]] = i;
    }

    for(int bit = 1; bit < 20; bit++) {
        for(i = 1; i <= n; i++) {
            nxt[i][bit] = nxt[nxt[i][bit - 1]][bit - 1];
        }
    }

    vector < vector <int> > anc(n + 2, vector <int>(60));

    for(i = 1; i <= n; i++) {
        int cur = i;
        for(int bit = 19; bit >= 0; bit--) {
            if(nxt[cur][bit] != 0) {
                cur = nxt[cur][bit];
            }
        }
        if(cur == n + 1) {
            anc[i][0] = 1;
        }
        else {
            anc[i][0] = last[a[cur]] + 1;
        }
    }
    anc[n + 1][0] = 1;

    for(int bit = 1; bit < 60; bit++) {
        for(i = 1; i <= n + 1; i++) {
            anc[i][bit] = anc[anc[i][bit - 1]][bit - 1];
        }
    }

    int pos = 1;
    k--;
    for(int bit = 0; bit < 60; bit++) {
        if(k & (1LL << bit)) {
            pos = anc[pos][bit];
        }
    }


    stack <int> stk;
    fill(last, last + MAXN + 1, 0);

    for(i = pos; i <= n; i++) {
        if(last[a[i]] == 0) {
            stk.push(a[i]);
            last[a[i]] = 1;
        }
        else {
            while(last[a[i]] == 1) {
                last[stk.top()] = 0;
                stk.pop();
            }
        }
    }

    vector <int> sol;
    while(stk.size()) {
        sol.push_back(stk.top());
        stk.pop();
    }

    reverse(sol.begin(), sol.end());
    for(auto it : sol) {
        cout << it << " ";
    }

    //cin.close();
    //cout.close();
    return 0;
}


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

int main()
{
	int a[3];
	for(int i = 0 ; i < 3 ; i++)
		cin >> a[i];
	sort(a,a+3);
	int ans = a[1]+a[0];
	if(a[1]+a[0] >= 10)
		cout << a[2]+1 << ans%10;
	else 
		cout << a[2] << ans; 
}

Measured memory_bytes: 256
W=87,i,n;char a[100001],s[100001];f(x,y){*a=x;a[1]=y;for(i=1;i<n-1;i++)a[i+1]=a[i]==W^a[i-1]==W^s[i]=='o'?83:W;if(*a!=W^*s=='o'^a[n-1]==a[1]&&a[n-1]!=W^s[n-1]=='o'^a[n-2]==*a)puts(a),exit(0);}main(){scanf("%d%s",&n,&s);f(83,83);f(83,W);f(W,83);f(W,W);puts("-1");}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        String S = sc.next();
        String T = sc.next();
        System.out.println(T.substring(0,T.length()-1).equals(S)&&T.length() == S.length()+1?"Yes":"No");
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35572
#include<stdio.h>
int main(void){
  int x;
  int a,b;
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  x=x-a;
  while(1){
  if(x>=b){
    x-=b;
  }
    else if(x<b){
    break;
    }
  }
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////

//bool pos[3][N+1];
//bool now[3][N+1];
#define N 50
int main(){fastio;
    ll n;cin>>n;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i];rep(i,0,n-1)cin>>b[i];
    bool pos[n][N+1];
    memset(pos,0,sizeof(pos));
    rep(i,0,n-1)pos[i][a[i]]=true;
    ll ans=0;
    for(ll s=N+1;s>=0;){
        bool now[n][N+1];
        rep(i,0,n-1)rep(j,0,N)now[i][j]=pos[i][j];
        bool fla=true;
        rep(i,0,n-1)if(!now[i][b[i]])fla=false;
        if(fla)break;
        rep(last,1,s){
            bool noww[n][N+1];rep(i,0,n-1)rep(j,0,N)noww[i][j]=now[i][j];
            if(last==N+1){
                cout<<-1<<endl;return 0;
            }
            for(ll x=last;x>=1;x--){
                rep(i,0,n-1){
                    rep(j,0,N){
                        noww[i][j%x]|=noww[i][j];
                    }
                }
            }
            bool infla=true;
            rep(i,0,n-1)if(!noww[i][b[i]])infla=false;
            if(infla){
                rep(i,0,n-1){
                    rep(j,0,N){
                        pos[i][j%last]|=pos[i][j];
                    }
                }
                ans+=1ll<<last;
                s=last-1;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



/*
 9
 18 18 18 18 18 18 18 18 18
 0 1 2 3 4 5 6 7 8
 */



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)	  for(int i=b-1;i>=a;i--)
#define trav(it,v)	  for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mpr            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;

map<int,int> mp;

bool sortinrevp(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 

bool sortinrev(const int &a,  
               const int &b) 
{ 
       return (a > b); 
} 

int power(int x, unsigned int y, int p) 
{ 
    int res = 1; 
  
    x = x % p;  
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int isPrime(int n) 
{ 

    if (n <= 1) 
        return 0; 
  
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return 0; 
  
    return 1; 
} 



void solve()
{
	int n,ans=0;
	cin>>n;
	int a[n];
	arr(a,n);
	sort(a,a+n);
	repr(i,2,n)
	{
		rep(j,0,i)
		{
			rep(k,j+1,i)
			{
				if(a[j]+a[k]>a[i])
				{
					ans+=i-k;
					break;
				}
			}
		}
	}
	cout<<ans;
}


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int n;
    cin >> n;
    cout<<n*n*n;
    return 0;
    // Bye Bye 2019
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid& unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid& x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid& x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

struct Event {
  int l, r;
  bool is_query;
  int index;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, q;
  cin >> n >> m >> q;
  vector<Event> events;
  REP(i, m) {
    int l, r;
    cin >> l >> r;
    events.push_back({l, r, false, i});
  }
  REP(i, q) {
    int p, q;
    cin >> p >> q;
    events.push_back({p, q, true, i});
  }
  sort(events.begin(), events.end(), [](const Event& x, const Event& y) {
    if (x.r != y.r) return x.r < y.r;
    if (x.is_query != y.is_query) return x.is_query < y.is_query;
    return x.l < y.l;
  });

  SegTree<int> st(
      n + 5, [](int x, int y) { return x + y; }, 0);

  V<int> ans(q);
  for (const auto& event : events) {
    if (event.is_query) {
      int a = st.fold(event.l, n + 1);
      ans[event.index] = a;
    } else {
      st.update(event.l, st[event.l] + 1);
    }
  }
  REP(i, q) { cout << ans[i] << '\n'; }
}


Measured memory_bytes: 11620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int a,b;
  cin >> a >> b;
  cout << (a <= 5? 0:(a <= 12? b/2:b)) << endl;
}

int main(){
  int testcase = 1;
  bool multicase = 0;
  if (multicase) cin >> testcase;
  REP(case_no, testcase) {
    cerr << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define ROW_MAX 1000
#define COL_MAX ROW_MAX
#define BUF_SIZE (ROW_MAX+20)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct point2d {
    int row;
    int col;
};

struct point2d dist[4] = {
    {0, 1}, // right direction
    {1, 0}, // bottom direction
};

static char map[ROW_MAX+1][COL_MAX+1];
static char outd[ROW_MAX+1][COL_MAX+1]; // outdegree
static uint64_t ans[ROW_MAX+1][COL_MAX+1];
#define DIVISOR 1000000007

void dfs(struct point2d p, uint64_t cnt) {
    ans[p.row][p.col] = (ans[p.row][p.col]+cnt)%DIVISOR;
#ifdef DEBUG
    printf("(%d %d) -> %d [prev_dst: %d]\n", p.row, p.col, (int)ans[p.row][p.col], outd[p.row][p.col]);
#endif
    int i;
    // wait until all previous path were analyzed
    if(outd[p.row][p.col]) return;
    // no longer needed
    map[p.row][p.col] = 0;
    for(i = 0; i < 2; i++) {
        struct point2d np = {
            p.row + dist[i].row,
            p.col + dist[i].col
        };
        if(map[np.row][np.col]) {
            outd[np.row][np.col]--;
            dfs(np, ans[p.row][p.col]);
        }
    }
}

int main(void) {
    int row, col;
    static char buf[BUF_SIZE];
    get_int2(&row, &col);
    int i, j;
    for(i = 1; i <= row; i++) {
        get_str(&buf[1], BUF_SIZE-1);
        for(j = 1; j <= col; j++) {
            map[i][j] = buf[j] == '.';
        }
    }
    for(i = 1; i <= row; i++) {
        for(j = 1; j <= col; j++) {
        }
    }
    // delete unused mass
    for(i = 1; i <= row; i++) {
        for(j = 1; j <= col; j++) {
            // assume that (1,1) should be empty.
            if(i==1 && j==1) continue;
            int cnt = 0;
            if(i!=1 && map[i-1][j]) cnt++;
            if(j!=1 && map[i][j-1]) cnt++;
            if(cnt==0) map[i][j]=0;
            outd[i][j] = cnt;
        }
    }
    struct point2d start = {1, 1};
    dfs(start, 1);
    printf("%d\n", (int)ans[row][col]);
    return 0;
}

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

int main()
{
    int n,c=0;
    string s;
    map<string,int>m;

    cin>>n;

    while(n--){
        cin>>s;
        m[s]++;
        if(m[s]==1){
            c++;
        }
    }
    cout<<c<<endl;

    return 0;
}



Measured memory_bytes: 19216
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな

signed main() {
    int n;cin>>n;
    int a[314514];
    int sum[214514];
    int bitsum[214514];
    rep(i,1,n+1){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];bitsum[i]=bitsum[i-1]^a[i];
    }
    
    int s=1,t=1;
    int ans=0;
    while(t<=n){
        if(sum[t]-sum[s-1]==(bitsum[t]^bitsum[s-1])){
            ans+=t-s+1;
            t++;
        }
        else {
            while(s<t){
                if(sum[t]-sum[s-1]==(bitsum[t]^bitsum[s-1]))break;
                else s++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

//約数列挙O(root n)
vector<ll> divisor(ll n){
  vector<ll> v;
  for(int i=1; i<=sqrt(n); i++){
    if(n%i == 0){
      v.push_back(i);
      if(i!=n/i) v.push_back(n/i);
    }
  }
  sort(all(v));
  return v;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,K;cin >> N >> K;
  vector<int> v(N);
  ll sum = 0;
  rep(i,N){
    cin >> v[i];
    sum += v[i];
  }
  vector<ll> div = divisor(sum);
  sort(all(v));
  ll ans = 0;
  for(const int & d : div){
    vector<ll> vd(N);
    rep(i,N) vd[i] = v[i]%d;
    sort(all(vd));
    vector<ll> pre(N+1);
    vector<ll> suf(N+1);
    pre[0] = 0;
    suf[N] = 0;
    rep(i,N){
      pre[i+1] = pre[i]+vd[i];
      suf[N-(i+1)] = suf[N-i] + d - vd[N-(i+1)];
    }
    rep(i,N+1){
      if((pre[i]-suf[i])%d==0){
        if(max(pre[i],suf[i])<=K){
          ans = d;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
def main():

    N = int(input())
    S = input()
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    ans = 0

    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if S[i-1] == S[j-1] and dp[i-1][j-1] < (j-i):
                dp[i][j] = dp[i-1][j-1] + 1
                ans = max(ans, dp[i][j])
            else:
                dp[i][j] == 0
    return ans

if __name__ == '__main__':
    print(main())

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

int main(){
	int N;
	cin >> N;
	if(N == 1){
		cout << "Hello World" << endl;
	}
	if(N == 2){
		int A, B;
		cin >> A;
		cin >> B;
		cout << A+B << endl;
	}
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main(){
    int n,s[1005],i;
    double a,x;
    while(scanf("%d",&n),n){
        for(i=a=0;i<n;a+=s[i++]) scanf("%d",&s[i]);
        a/=n;
        for(i=x=0;i<n;i++) x+=(s[i]-a)*(s[i]-a);
        printf("%.8f\n",sqrt(1.00*x/n));
    }
    return 0;
}


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

using namespace std;

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

    int x[5];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0){
            cout << i + 1 << '\n';
            return 0;
        }
    }


    return 0;
}

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

int count=0;


void permute(vector<int>a,int index,vector<vector<int>>edges){
    
    if(index==a.size())
    {
        bool no=false;
        for(int i=0;i<a.size()-1;i++)
        {
            if(edges[a[i]][a[i+1]]==false)
            {
                no=true;
                break;
            }
        }
        if(!no){
            count++;
        }
        return;
    }
    for(int i=index;i<a.size();i++)
    {
        int temp=a[i];
        a[i]=a[index];
        a[index]=temp;
        permute(a,index+1,edges);
        temp=a[i];
        a[i]=a[index];
        a[index]=temp;
    }
}



int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>>edges(n,vector<int>(n,false));
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        edges[a-1][b-1]=true;
        edges[b-1][a-1]=true;
    }
    vector<int>arr;
    for(int i=0;i<n;i++)
    {
        arr.push_back(i);
    }
    permute(arr,1,edges);
    cout<<count;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, m, sum, i, j, k, d, c, ans;
	cin >> m;
	n = 0; sum = 0;
	while (m--) {
		cin >> d >> c;
		n += c;
		sum += c * d;
	}

	ans = n + (sum - 1) / 9 - 1;
	cout << ans << "\n";

	return 0;
}



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

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

    map<int, int> mp;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        mp[a]++;
    }

    ll ans = 0;
    for(auto& p : mp){
        if(p.first < p.second){
            ans += p.second - p.first;
        }else if(p.first > p.second){
            ans += p.second;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

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

        char[] re = str.toCharArray();

        for(int i=0;i<str.length();i++){
            if(Character.isUpperCase(re[i])){
                re[i]=Character.toLowerCase(re[i]);
            }else{

                re[i]=Character.toUpperCase(re[i]);
            }
        }

        String ans = new String(re);

        System.out.println(ans);


        scn.close();


    }


}



Measured memory_bytes: 26100
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n,t;scanf("%d%d",&n,&t),n;){
		double dp[2][12001]={};
		dp[0][0]=1;
		for(int i=1;i<=t;i++){
			for(int j=0;j<=6*i;j++){
				dp[i%2][j]=0;
				for(int k=1;k<=6;k++){
					if(0<=j-k && j-k<=6*(i-1))	dp[i%2][j]+=dp[(i+1)%2][j-k];
				}
				dp[i%2][j]/=6;
			}
		}

		char ring[2001];	scanf("%s",ring);

		double pr[2000]={};
		for(int i=1;i<=6*t;i++)	pr[i%n]+=dp[t%2][i];

		double prmax=0;
		rep(d,n){
			double prtmp=0;
			rep(i,n)if(ring[i]=='R'){
				prtmp+=pr[(i+d)%n];
			}
			prmax=max(prmax,prtmp);
		}
		printf("%.9f\n",prmax);
	}

	return 0;
}

Measured memory_bytes: 1008
#include <iostream>
#include<vector>
#include<algorithm>
#include <functional>
int main()
{
	int N = 0, ans = 0;
	std::cin >> N;

	std::vector<int> V(N, 0);
	std::vector<int> C(N, 0);
	std::vector<int> B(N, 0);

	for (int i = 0; i < N; i++) std::cin >> V[i];
	for (int i = 0; i < N; i++) std::cin >> C[i];

	for (int i = 0; i < N; i++) B[i] = V[i] - C[i];
	std::sort(B.begin(), B.end(), std::greater<int>());

	for (int i = 0; i < N; i++){
		if (B[i] >= 0){ ans += B[i]; }
		else{ break; }
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        if((b+a)%2==0){
            System.out.println((b+a)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

map<vector<int>, int> mp;

void init() {
   vector<int> v(8);
   iota(all(v), 0);
   mp[v] = 0;
   queue<vector<int>> que;
   que.push(v);

   while (que.size()) {
      vector<int> cur = que.front(); que.pop();
      int idx = find(all(cur), 0) - cur.begin();
      int y = idx / 4, x = idx % 4;
      rep (i, 4) {
         int ny = y + dy[i], nx = x + dx[i];
         if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
         vector<int> next = cur;
         int nc = ny * 4 + nx;
         swap(next[idx], next[nc]);
         if (mp.count(next)) continue;
         mp[next] = mp[cur] + 1;
         que.push(next);
      }
   }
}

int main() {
   init();
   vector<int> v(8);
   while (cin >> v[0]) {
      repp (i, 1, 8) cin >> v[i];
      cout << mp[v] << endl;
   }

   return 0;
}


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

int main() {
    double n, k, ans = 0;
    cin >> n >> k;
    rep(i, n) {
        int cnt = 0, num = i + 1;
        double tmp = 1;
        while(num < k) {
            cnt++;
            num *= 2;
            tmp *= 0.5;
        }
        tmp /= n;
        ans += tmp;
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int arr[100005];
map<int,int> ff;
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
        cin >> arr[i],arr[i] %= m;
    long long s = 0;
    for(int i = 1;i <= n;i++)
    {
        s += arr[i];
        s %= m;
        ff[s]++;
    }
    s = 0;
    long long ans = 0;
    for(int i = 0;i <= n;i++)
    {
        s += arr[i];
        s %= m;
        ans += ff[s];
        ff[s]--;
        if(s != 0)
            ans--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3584
#include<cstdio>

int main() {
    int a,b;
    std::scanf("%d %d",&a,&b);
        if(a < b) {
        std::printf("a < b");
    }
    else if(a > b ) {
        std::printf("a > b");
    }
    else if(a == b){
        std::printf("a == b");
    }
    std::printf("\n");
    return 0;
    }


Measured memory_bytes: 2668
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int L, R, d; cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; ++i){
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3548
n=int(input())
p=list(map(int,input().split()))
a=[i for i in range(1,n+1)]
c=[0]*n

for i in range(n):
    if a[i]==p[i]:
        c[i]=1
#print(c)
ans=0
z=0
for i in range(n-1):
    if c[i]==c[i+1]==1:
        z+=1
    else:
        if z>=1:
            ans+=z//2+1
        z=0
if z>=1:ans+=z//2+1
for i in range(n-2):
    if c[i]==c[i+2]==0 and c[i+1]==1:
        ans+=1
if c[0]==1 and c[1]==0:
    ans+=1
if c[-1]==1 and c[-2]==0:
    ans+=1
print(ans)

Measured memory_bytes: 14008