akhauriyash/Code-Regression huggingface dataset:
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	int n, k[105], ans = 999;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		if (i) { k[i] += k[i - 1]; }
	}

	for (int i = 0; i < n; ++i) {
		ans = min(ans, k[i] / (i + 1));
	}
	cout << ans << endl;
}

//4 6 11 14 15


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int N,M,K,T;
int a[100],b[100],c[100];
int dp[50][500][500];
int main(void){
	int Ma,Mb;
	geti(N,Ma,Mb);
	repp(i,N){
		geti(a[i],b[i],c[i]);
	}
	rep(i,45)rep(j,450)rep(k,450) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	for(int n=1;n<=N;n++){
		for(int i=0;i<=400;i++){
			for(int j=0;j<=400;j++){
				dp[n][i][j] = dp[n-1][i][j];
				if( i - a[n] >= 0 && j - b[n] >= 0 ) dp[n][i][j] = min(dp[n][i][j], dp[n-1][i-a[n]][j-b[n]] + c[n] );
			}
		}
	}
	int mn = INF;
	/*
	for(int n=1;n<=3;n++){
		for(int i=1;i<=10;i++){
			for(int j=1;j<=10;j++) printf("%d ",dp[n][i][j]==INF?0:dp[n][i][j]);
			printf("\n");
		}
		printf("``````````````````\n");
	}
	*/
	repp(i,400) repp(j,400){
		if( i%Ma != 0 || j%Mb != 0 ) continue;
		if( i/Ma == j/Mb ) mn = min(dp[N][i][j],mn);
	}
	if( mn == INF ){
		cout << -1 << endl; return 0;
	}
	cout << mn << endl;

}

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

const int mod=1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll>dp(n+1);
    vector<bool>ng(n+1,false);
    rep(i,m){
        int a; cin>>a;
        ng[a]=true;
    }
    dp[n]=dp[n-1]=1;
    for(int i=n-2; i>=0; --i){
        if(ng[i])continue;
        if(!ng[i+1]&!ng[i+2])dp[i]=(dp[i+1]+dp[i+2])%mod;
        else if(ng[i+1]&ng[i+2])dp[i]=0;
        else if(!ng[i+1]&ng[i+2])dp[i]=dp[i+1];
        else dp[i]=dp[i+2];
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  int f = 4, s = 7;

  cin >> n;

  for (int i = 0; i <= n+5; i += f) {
    for (int j = 0; j <= n+5; j += s) {
      if (i + j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int n;
	string s, x;
	cin >> n >> s;
	vector<string> a(n);

	for (int i = 0; i < n; i++) {
		a[i] = s.substr(i, 1);
		if (i == 0) {
			x += s.substr(i, 1);
		}
		else {
			if (a[i] != a[i-1]) {
				x+= s.substr(i, 1);
			}
		}
	}
		cout << x.length();
}

Measured memory_bytes: 5888
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			ans += i - cnt;
			cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
n,k=map(int,input().split())
a=list(map(int,input().split()))

for _ in range(k):
    imos=[0]*(n+1)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n,1+i+a[i])]-=1
    
    a[0]=imos[0]
    if a[0]==n:
        flag=0
    else:
        flag=1

    for i in range(1,n):
        a[i]=a[i-1]+imos[i]
        if a[i]!=n:
            flag=1
    
    if flag==0:
        break

print(" ".join(list(map(str,a))))
        



Measured memory_bytes: 157772
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b");
    }else if(a>b){
        printf("a > b");
    }else{
        printf("a == b");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string s;
    cin >> s;
    bool ok = true;
    if(C < D) {
        rep(i, A - 1, D - 1) {
            if(s[i] == '#' && s[i + 1] == '#') ok = false;
        }
        if(ok) output("Yes");
        else output("No");
    }
    else {
        rep(i, A - 1, C - 1) {
            if(s[i] == '#' && s[i + 1] == '#') ok = false;
        }
        int ook = false;
        if(B + 1 == D && s[B - 1] == '.' && s[D - 1] == '.') ook = true;
        
        rep(i, B - 2, D - 1) {
            if(B - 2 >= 0 && D + 1 < N && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ook = true;
        }
        if(ok && ook) output("Yes");
        else output("No");
    }
    
    
    return 0;
}


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

int main(){
  
    long long int N,M;
    cin>>N>>M;
    long long int ans;
    if(N==1){
        if(M==1) ans=1;
        if(M==2) ans=0;
        if(M>=3) ans=M-2;
    }
    if(N==2) ans=0;
    if(N>=3){
        if(M==1) ans=N-2;
        if(M==2) ans=0;
        if(M>=3) ans=(M-2)*(N-2);
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int d,n;
    cin>>d>>n;
    int p = 1;
    if (d){
    for (int i=0;i<d;i++){
        p*=100;
    }}
    if (n!=100){
        cout<<n*p<<endl;
    }
    else{
        cout<<(n+1)*p<<endl;
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n, a[10], b[10];
double ans;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			ans += sqrt((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]));
		}
	}
	cout << fixed << setprecision(6) << ans / n << endl;
	return 0;
}

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

int dp[100001][3];

int maxHapp(int **arr,int n,int idx,int last)
{
	if(idx==n)
	return 0;
	
	if(dp[idx][last]!=-1)
	return dp[idx][last];
	
	
	int ans=INT_MIN;
	for(int k=0;k<3;k++)
	{
		if(idx==0||k!=last)
		ans=max(ans,arr[idx][k]+maxHapp(arr,n,idx+1,k));
		
	}
	dp[idx][last]=ans;
	return ans;
}

int main()
{
	int n;
	cin>>n;
	
	int ** arr=new int *[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=new int[3];
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	
	cout<<maxHapp(arr,n,0,0);
}


Measured memory_bytes: 18036
a={0:0,1:0,2:0,3:0,4:0,5:0}
for _ in range(int(input())):
    b=int(float(input()))
    if b<165:b=160
    elif b>185:b=185
    a[b//5-32]+=1
for i in a:print('%d:'%(i+1)+'*'*a[i])

Measured memory_bytes: 7516
using System;

namespace ABC059_A_Three_letter_acronym
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			Console.Write(input[0].Substring(0, 1).ToUpper());
			Console.Write(input[1].Substring(0, 1).ToUpper());
			Console.Write(input[2].Substring(0, 1).ToUpper());
		}
	}
}

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

ll a,b,n;

int main(){
	cin>>a>>b>>n;
	ll x=(n>=b-1?b-1:n);
	cout<<(a*x)/b-x/b*a<<endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
    }
//    sort(P.begin(), P.end());

    int ret = 0;
    while(1) {
        int cand1 = X - ret;
        auto result = find(P.begin(), P.end(), cand1);
        if (result == P.end()) {
            cout << cand1 << endl;
            return 0;
        }

        int cand2 = X + ret;
        result = find(P.begin(), P.end(), cand2);
        if (result == P.end()) {
            cout << cand2 << endl;
            return 0;
        }
        ret++;
    }

    return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int MAX = 110'000;
	vector<int> con(MAX);
	vector<int> A;
	int sum = 0;
	int N, Q;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		con[A[i]]++;
	}
	
	cin>>Q;
	
	
	for(int i = 0; i < con.size(); i++){
		sum += con[i] * i;
	}
	
	for(int i = 0; i < Q; i++){
		int B, C;
		
		cin>>B>>C;
		
		sum += (C - B) * con[B];
		
		con[C] += con[B];
		
		con[B] = 0;
		
		cout<<sum<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
#define ceil(a,b) (a+b-1)/b
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
    cin>>n>>m;
    int l;
    cin>>l;
   // vector<int>adj[n+1];
    int d[n+1][n+1];
    int dis[n+1][n+1];
    for(int x=1;x<=n;x++){
        for(int y=1;y<=n;y++){
            d[x][y]=inf;
            dis[x][y]=inf;
            if(x==y){
                d[x][y]=0;
            }
        }
    }
    for(int x=0;x<m;x++){
        int a,b,c;
        cin>>a>>b>>c;
        //adj[a].pb(b);
        //adj[b].pb(a);
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
   // vector<int>e[n+1];
    for(int x=1;x<=n;x++){
        for(int y=1;y<=n;y++){
            if(x==y){
                dis[x][y]=0;
                dis[y][x]=0;
            }
            if(d[x][y]<=l){
                //e[x].pb(y);
                //e[y].pb(x);
                if(x!=y){
                dis[x][y]=1;
                dis[y][x]=1;}else{
                    dis[x][y]=0;
                    dis[y][x]=0;
                }
            }
        }
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    int q;
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        if(dis[s][t]!=inf){
            cout<<dis[s][t]-1<<"\n";
        }else{
            cout<<-1<<"\n";
        }
    }









	
return 0;
}


Measured memory_bytes: 1920
n = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, 5):
    if i==4: print(max(list(map(lambda x,y: abs(x-y), a, b))))
    else: print(sum(list(map(lambda x,y: abs(x-y)**i, a, b)))**(1/i))


Measured memory_bytes: 5636
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int R = sc.nextInt();
			int C = sc.nextInt();
			if (R == 0) break;
			sc.nextLine();
			BitSet[] bs = new BitSet[R];
			for (int i = 0; i < R; ++i) {
				bs[i] = new BitSet(C);
				String line = sc.nextLine();
				for (int j = 0; j < C; ++j) {
					bs[i].set(j, line.charAt(2 * j) == '1');
				}
			}
			int ans = 0;
			for (int i = 0; i < (1 << R) - 1; ++i) {
				int sum = 0;
				for (int j = 0; j < C; ++j) {
					int count = 0;
					for (int k = 0; k < R; ++k) {
						if (bs[k].get(j) ^ (i & (1 << k)) > 0) ++count;
					}
					sum += Math.max(count, R - count);
				}
				ans = Math.max(ans, sum);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int ans = min(A * N, B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k){
    cout << ":(";
  }else{
    cout << "Yay!";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int a,b,c;
    int ans;
    cin >> a >> b >> c;
    if(a<b+c){
         ans = b+c-a;
    }else{
         ans = 0;
    }
    cout << min(c,b) << " " << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long n = sc.nextLong();
			long k = sc.nextLong();
			// 出力(整数)
			long cand = n % k;
			long cand2 = Math.abs(cand - k);
			System.out.println(cand < cand2 ? cand : cand2);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main(){
  int s[5];
  int a[5];
  int b[5];
  int i,j;
  int f = 0;
  int sum = 4;
  int p = 9;
  int flag = 0;
  for(i=0;i<5;i++){
    scanf("%d",&s[i]);
  }
  for(i=0;i<5;i++){
    a[i] = (s[i]%10);
    if(a[i] == 0){
      sum -= 1;
    }
    b[i] = (s[i]/10);
    sum += b[i];
  }
  for(i=0;i<5;i++){
    if(a[i] == 0){
      f += 1;
    }
    if((a[i]<=p)&&(a[i]!=0)){
      p = a[i];
      flag = a[i];
    }
  }
  
  if(f == 5){
    sum += 1;
  }
  sum = sum*10;
  sum = sum + flag;
  
  printf("%d\n",sum);
    
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int main()
{
	int n,k;sca(n);sca(k);
	int a[1005];
	for(int i=0;i<n;i++)
	sca(a[i]);
	sort(a,a+n); 
	int ans=0;
	for(int i=0;i<k;i++)
	ans+=a[i];
	cout<<ans<<endl;
 } 

Measured memory_bytes: 3700
n = int(input())

A = input()
B = input()
C = input()

cnt = 0

for i in range(n):
    a,b,c = A[i],B[i],C[i]
    if a == b and b == c:
        pass
    else:
        if a == b or b == c or c == a:
            cnt += 1
        else:
            cnt += 2

print(cnt)


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

int main(){
  string atc, s, con;
  cin >> atc >> s >> con;
  //cin >> s;
  //cout << s << endl;
  string name;
  char A = s.at(0);
  name = 'A';
  name += A;
  name += 'C';

  //name = 'A' + A + 'C';
  cout << name << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=0;i<n;i+=2)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
ll fact(ll n) {
  ll r;
  if(n<2) r=1;
  else r=2*fact(n/2);
  return r;
}
int main() {
  llc(h);
  ll a=fact(h);
  cout << 2*a-1 << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = sorted(list(map(int, input().split())))

if lis[int(n/2)-1] == lis[int(n/2)]:
    print(0)
else:
    a = list(range(lis[int(n/2)-1]+1, lis[int(n/2)]+1))
    print(len(a))

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long A,B;
	int K;
	cin >> A >> B;
	cin >> K;
	if(2 * K <= (B-A)){
		for (int i = 0; i < K; ++i)
		{
			cout << A + i << endl;
		}
		for (int i = K-1; i >= 0; --i)
		{
			cout << B - i << endl;
		}
	}else{
		for (int i = A; i <= B; ++i)
		{
			cout << i << endl;
		}
	}

}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b;
  	cin >> a >> b;
  	vvi data = {{4,6,9,11}, {2}};
  	int tempa = 2;
  	int tempb = 2;
  	rep(i,2) {
      	auto res = find(all(data[i]), a);
      	if(res != data[i].end()) {
          	tempa = i;
        	break;
        }
    }
  	rep(i,2) {
      	auto res = find(all(data[i]), b);
      	if(res != data[i].end()) {
          	tempb = i;
          	break;
        }
    }
  	
  	if(tempa == tempb) puts("Yes");
  	else puts("No");
	return;
}

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

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

long long d[100001];
int n;
struct edge { int to; long long cost; };
std::vector<edge> e[100001];


void dfs(int v, int p, long long D) {
	d[v] = D;
	for (int i = 0; i < e[v].size(); i++) {
		if (e[v][i].to == p)continue;
		dfs(e[v][i].to, v, D + e[v][i].cost);
	}
}

int main() {
	std::cin >> n;
	int a, b;
	long long c;
	for (int i = 0; i < n-1; i++) {
		std::cin >> a >> b >> c;
		e[a].emplace_back(edge{ b,c });
		e[b].emplace_back(edge{ a,c });
	}
	int q, k;
	std::cin >> q >> k;
	for (int i = 0; i < 100000; i++)d[i] = INF;
	dfs(k, -1, 0);
	for (int i = 0; i < q; i++) {
		std::cin >> a >> b;
		std::cout << d[a] + d[b] << std::endl;
	}
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <string.h>

main() {
  char moji[201];
  char str[201];
  int i,m, n;

  while (1) {
    scanf("%s", moji);
    if (strcmp(moji, "-") == 0) break;
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%d", &n);
      strcpy(str, &moji[n]);
      strncat(str, moji, n);
      strcpy(moji, str);
    }
    printf("%s\n", moji);
  }
  return 0;
}

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


bool Search(vector<int>& p, int x)
{
    int np = p.size();

    for (int i = 0; i < np; i++)
    {
        if (x == p[i])
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int x, n;
    cin >> x >> n;

    vector<int> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];

    if (Search(p, x))
    {
        cout << x << endl;
        return 0;
    }
    int j = 1;
    while (true)
    {
        if (Search(p, x - j))
        {
            cout << x - j << endl;
            break;
        }
        if (Search(p, x + j))
        {
            cout << x + j << endl;
            break;
        }
        j++;
    }
}



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	char d;
	while(cin>>n) {
		if(n == 0){
			break;
		}
		vector<P> t(n);
		int h[2],m[2],s[2];
		for(int i= 0;i < n;i++){
			cin >> h[0]>> d >> m[0] >> d >> s[0] >> h[1] >> d >>m[1]>> d >>s[1];
			t[i].first= h[0]*3600+m[0]*60+s[0];
			t[i].second= h[1]*3600+m[1]*60+s[1];
		}
		for (int i =n-1; i> 0; i--) {
			for (int j =0; j < i; j++){
				if (t[j].first > t[j+1].first) {
					swap(t[j], t[j+1]);
				} else if (t[j].first == t[j+1].first){
					if (t[j].second > t[j+1].second) {
						swap(t[j], t[j+1]);
					}
				}
			}
		}
		queue<P> t1;
		priority_queue<int, vector<int>, greater<int> > t2;
		for (int i=0; i< n; i++) {
			t1.push(t[i]);
		}
		int train =0;
		P p = t1.front();
		t1.pop();
		t2.push(p.second);
		train++;
		for (int i= 1; i < n; i++){
			p = t1.front();
			t1.pop();
			if (!t2.empty() && t2.top() <= p.first) {
				t2.pop();
			} else {
				train++;
			}
			t2.push(p.second);
		}
		cout<<train << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
s = input().split()
i = s[0]
m = int(s[1])
count = 0
sun = 0
el = input().split()
for p in el:
    sun += int(p)
for k in el:
    if int(k) >= sun / (4 * m):
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<128>>;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
const int INF = 2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = 1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
void print() { cout << endl; }
template <class T, class... A> void print(const T &first, const A &... rest) {
    cout << first;
    print(rest...);
}
template <class... A> void print(const A &... rest) { print(rest...); }
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(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int modulo(int a, int b, int n) {
    long long x = 1, y = a;
    while(b > 0) {
        if(b % 2 == 1) {
            x = (x * y) % n; // multiplying with base
        }
        y = (y * y) % n; // squaring the base
        b /= 2;
    }
    return x % n;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    int MAXN = 3000;
    int N = in();
    vector<vector<double>> dp(MAXN + 10, vector<double>(MAXN + 10, 0.0));
    vector<double> p(N + 10);
    rep(i, 1, N + 1) { cin >> p[i]; }
    dp[0][0] = 1;
    rep(i, 1, N + 1) {
        rep(j, 0, i + 1) {
            if(j > 0) {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
            } else {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            }
        }
    }
    double ans = 0;
    rep(j, N / 2 + 1, N + 1) { ans += dp[N][j]; }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 71168
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    cost = []
    for i in range(-100, 101):
        ramen = 0
        for j in range(n):
            ramen += abs(a[j]-i)**2
        cost.append(ramen)
    print(min(cost))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10260
import sys
N,Y=list(map(int,open(0).read().split()))


for x in range(N+1):
  for y in range(N+1):
    if sum([x,y])<=N:
      z = N - (x + y)
      if x*10000+y*5000+z*1000 == Y:
        print(x,y,z)
        sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int dp[200][200][200];
int zero[200] , one[200];
int N;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  int n = sz(s);
  int m = sz(t);
  int ans = inf;
  for(int i = 0; i <= n - m; i++) {
    int cnt = 0;
    for(int j = 0; j < m; j++) {
      if(t[j] != s[i + j]) cnt++;
    }
    ans = min(ans , cnt);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3656
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)


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

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

const int INF = 100000000;
const double PI=acos(-1);

bool comp(P p1, P p2){
    if (p1.first != p2.first) {
        return p1.first < p2.first;
    }
    else if (p1.second != p2.second) {
        return p1.second > p2.second;
    }
    else {
        return true;
    }
}

int dp[150][2][2][6];

int main () {
    string N;
    int K;
    cin >> N >> K;
    vector<int> X(0);
    rep(i,N.size()) {
        X.push_back(N[i]-'0');
    }

    dp[0][0][0][0] = 1;

    for (int i=0; i<X.size(); i++) {
        for (int smaller=0; smaller<2; smaller++) {
            for (int m = 0; m<2 ; m++) {
                for (int k = 0; k<=K; k++) {
                    for (int x = 0; x<= (smaller ? 9 : X[i]); x++) {
                        if (m==0) {
                            dp[i+1][smaller || x < X[i]][m || x!=0][k+(x!=0)] += dp[i][smaller][m][k];
                        }
                        else {
                            dp[i+1][smaller || x < X[i]][m][k+(x!=0)] += dp[i][smaller][m][k];
                        }
                    }
                }
            }
        }
    }
	
    ll ans = dp[X.size()][0][0][K] + dp[X.size()][1][0][K] +dp[X.size()][0][1][K] + dp[X.size()][1][1][K];
    cout << ans << endl;

}


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

//#define loop(i, n) for(int i = 0;i < int(n);i++)
//#define rloop(i, n) for(int i = int(n);i >= 0;i--)
//#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
//#define sz(c) int(c.size())
//#define clr(v, d)   memset(v, d, sizeof(v))
//#define ALL(c) c.begin(), c.end()
//#define RALL(c) c.rbegin(), c.rend()
//#define PI acos(-1)
//#define pb push_back
//#define mp make_pair
//#define fr first
//#define sc second
//#define INF             INT64_MAX
//#define NINF            INT64_MIN

//typedef long long ll;
//typedef pair<int, int> ii;
//typedef pair<ll, ll> pll;
//typedef vector<ii> vii;
//typedef vector<int> vi;
//typedef vector<pll> vll;
//typedef vector<ll> vl;
string s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT"};
int main()
{
    string in;
    cin>>in;
    int i;
    for(i=0;i<7;i++)
    {
        if(s[i]==in)
            break;
    }
    cout<<7-i<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char str1[4],str2[4];
    cin>>str1>>str2;
    if(str1[0]==str2[2]&&str1[1]==str2[1]&&str1[2]==str2[0]) cout<<"YES";
    else cout<<"NO";
    return 0;
   
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i, k) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int N;
vector<int> A,B,C;
ll ans = 0;

vector<ll> BC;


int check(int bc, int a){
    
    int f = 0;
    int b = N-1;
    
    
    
    if(bc == 0){
        if(a <= B[f]) return 0;
        if(B[b] < a) return N;
        
        while (b - f > 1) {
            int mi = (f+b)/2;
            if(B[mi] >= a) b = mi;
            else if(B[mi] < a) f = mi;
        }
        if(B[b] < a) return b+1;
        else return f+1;
        
    }else{
        if(a <= A[f]) return 0;
        if(A[b] < a) return N;
               
        
        while (b - f > 1) {
            int mi = (f+b)/2;
            if(A[mi] >= a) b = mi;
            else if(A[mi] < a) f = mi;
        }
        if(A[b] < a) return b+1;
        else return f+1;
    }

}



int main()
{
    cin >> N;
    A.assign(N, 0);
    B.assign(N, 0);
    C.assign(N, 0);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    BC.assign(N, 0);
    
    sort(all(A));
    sort(all(B));
    sort(all(C));
    
       
    
    
    rep(i,N){
        int a = check(1, B[i]);
       // cout << a << " ";
        BC[i] = ll(a);
        if(i != 0) BC[i] += BC[i-1];
    }
    //cout << endl;
    
    rep(i,N){
        int b = check(0, C[i]);
        //cout << b << " ";
        if(b != 0) ans += BC[b-1];
    }
    //cout << endl;
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a;
    cin>>a;
    if(a=="SUN"){
        cout << '7';
    }
    if(a=="MON"){
        cout << '6';
    }
    if(a=="TUE"){
        cout << '5';
    }
    if(a=="WED"){
        cout << '4';
    }
    if(a=="THU"){
        cout << '3';
    }
    if(a=="FRI"){
        cout << '2';
    }
    if(a=="SAT"){
        cout << '1';
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
	string s,ss;
	int z=0;
	ss="keyence";
	cin>>s;
	string a,b;
	if(s==ss){
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=1;i<7;i++){
		a=s.substr(0,i);
		b=s.substr(s.size()-(7-i));
		if(a+b==ss)z++;
	}
	if(z)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
 
bool isdigit(char a) {
  if ('0' <= a && a <= '9') return true;
  return false;
}
 
int main(int argc, char** argv) {
  int a, b;
  std::string str;
  std::cin >> a >> b;
  
  std::cin >> str;
  
  const char* str_p = str.c_str();
  
  for (int i=0; i < a; i++) {
	if (isdigit(str_p[i]) == false) { std::cout << "No"; return 0;}
  }
  if (str_p[a] != '-') { std::cout << "No"; return 0;}
  for (int i=a+1; i < a+b+1; i++) {
	if (isdigit(str_p[i]) == false) { std::cout << "No"; return 0;}
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

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

int main()
{
  int N;scanf("%d",&N);
  vector<int> H(N);
  for(int i=0;i<N;i++)scanf("%d ",&H[i]);
  int ans=0,count=0;
  for(int i=1;i<N;i++)
  {
    if(H[i-1]>=H[i]){count++;ans=max(ans,count);}
    else count=0;
  }
  printf("%d\n",ans);
}

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

int main() {
    int h,w;
    cin >> h >> w;
    string a;
    vector<char> vec(w+2,'#');

    for(int i = 0;i < w+2;i ++){
        cout << vec.at(i);
    }
    cout << endl;
    for(int i = 0;i < h; i ++){
        cin >> a;
        cout << "#" << a << "#" << endl;
    }
    for(int i = 0;i < w+2;i ++){
        cout << vec.at(i);
    }
    cout << endl;


}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric
import Data.Char
import Data.List
import Data.Ord

main :: IO ()
main = do
  { cs <- getContents
  ; putStr $ unlines
           $ map showCharCount
           $ mergeCharCounts
           $ charCounts
           $ alphas cs
  }

alphas :: String -> String
alphas = map toLower . filter isAlpha

charCounts :: String -> [(Char, Int)]
charCounts = map count . group . sort

count :: String -> (Char, Int)
count s = (head s, length s)

initCharCounts :: [(Char, Int)]
initCharCounts = zip ['a' .. 'z'] (repeat 0)

mergeCharCounts :: [(Char, Int)] -> [(Char, Int)]
mergeCharCounts = merge  initCharCounts

merge :: [(Char , Int)] -> [(Char, Int)] -> [(Char, Int)]
merge [] [] = []
merge xs [] = xs
merge (x:xs) (y:ys) = case (comparing fst) x y of
  LT -> x : merge xs (y:ys)
  EQ -> y : merge xs ys
  _  -> error "Henn!"

showCharCount :: (Char, Int) -> String
showCharCount (c, n) = [c] ++ " : " ++ show n

--
getIntegers :: IO[Integer]
getIntegers = map read. words <$> getLine

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4268
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

    vector<string> a(H);
    for (int i = 0; i < H; i++) {
        cin >> a[i];
    }
    vector<int> route;
    for (int i = 0; i < H; i++) {
        int right = -1;
        int left = W;
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                if (j < left) left = j;
                right = j;
            }
        }
        if (i != 0 && left != route[i - 1]) {
            cout << "Impossible" << endl;
            return 0;
        }
        route.push_back(right);
    }
    cout << "Possible" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> alp(26);
    rep(i,n){
        char c = s.at(i);
        if (c == 'a') alp[0]++;
        else if (c == 'b') alp[1]++;
        else if (c == 'c') alp[2]++;
        else if (c == 'd') alp[3]++;
        else if (c == 'e') alp[4]++;
        else if (c == 'f') alp[5]++;
        else if (c == 'g') alp[6]++;
        else if (c == 'h') alp[7]++;
        else if (c == 'i') alp[8]++;
        else if (c == 'j') alp[9]++;
        else if (c == 'k') alp[10]++;
        else if (c == 'l') alp[11]++;
        else if (c == 'm') alp[12]++;
        else if (c == 'n') alp[13]++;
        else if (c == 'o') alp[14]++;
        else if (c == 'p') alp[15]++;
        else if (c == 'q') alp[16]++;
        else if (c == 'r') alp[17]++;
        else if (c == 's') alp[18]++;
        else if (c == 't') alp[19]++;
        else if (c == 'u') alp[20]++;
        else if (c == 'v') alp[21]++;
        else if (c == 'w') alp[22]++;
        else if (c == 'x') alp[23]++;
        else if (c == 'y') alp[24]++;
        else if (c == 'z') alp[25]++;
    }
    ll ans = 1;
    rep(i,26){
        ans *= (alp[i] + 1);
        ans %= MOD;
    }
    ans--;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 512
import sys
N = int(input())
H = list(map(int, input().split()))

cnt = 0
max_v = 0
for i in range(len(H)):
  #if max_v >= len(H)-i:
  #  print(max_v)
  #  sys.exit()
  if i == len(H)-1:
    cnt += 1
    print(max_v)
    sys.exit()
  if H[i] >= H[i+1]:
    cnt += 1
  elif H[i] < H[i+1]:
    cnt = 0
  if max_v < cnt:
    max_v = cnt

Measured memory_bytes: 14228
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	int n, i;
	cin >> n;
	vector<int> ing;
	for(i=0; i<n; i++){
		int x;
		cin >> x;
		ing.push_back(x);
	}
	sort(ing.begin(), ing.end());
	double res = ing[0];
	for(i=1; i<n; i++){
		res = (res+ing[i])/2.0;
		//cout << res << endl;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3804
#include<cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		rep(_,n){
			int a,b,c,d,e,f,g,h; scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
			printf("%d %d %d %d\n",a*e-b*f-c*g-d*h,a*f+b*e+c*h-d*g,a*g-b*h+c*e+d*f,a*h+b*g-c*f+d*e);
		}
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque

h, w = map(int, input().split())
s = [input() for i in range(h)]

d = [[h+w for j in range(w)] for i in range(h)]
que = deque()

#黒だったらスタートキューに入れる
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
        que.append((i, j))
        d[i][j] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


while que:
    p = que.popleft()
    # 黒にする4方向をループ
    for i in range(4):
        nx = p[1] + dx[i]
        ny = p[0] + dy[i]

        if (0<=nx<w) and (0<=ny<h) and (d[ny][nx]==h+w):
            que.append((ny, nx))
            d[ny][nx] = d[p[0]][p[1]] + 1

res = max(map(max, d))
print(res)


Measured memory_bytes: 88028
from math import sqrt
from itertools import accumulate


def common_divisors(x):
    ret = []
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)

    return ret


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

sm = sum(a)
cd = common_divisors(sm)

ans = 1
for ecd in cd:
    r = [e % ecd for e in a]
    r.sort()
    sub = [0] + list(accumulate(r))
    add = [0] + list(accumulate(ecd - e for e in r[::-1]))
    add = add[::-1]
    for sb, ad in zip(sub, add):
        if sb == ad and sb <= k:
            ans = max(ans, ecd)

print(ans)


Measured memory_bytes: 3188
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n, m = map(int, input().split())
arr = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    arr.append(tmp[1:])
prr = list(map(int, input().split()))

answer = 0
for switches in range(2 ** n):
    light_up = 0
    for light in range(m):
        on = 0
        for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

        if on % 2 == prr[light]:
            light_up += 1

    if light_up == m:
        answer += 1

print(answer)

Measured memory_bytes: 73824
#include<bits/stdc++.h>
using namespace std;
static vector< int > sum[5011];
int main(){
  for(int i = 0; i <= 5010 ; i++){
    sum[i].resize(i + 10, 0);
  }
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b, x;
    cin >> a >> b >> x;
    ++sum[a][b];
    --sum[a][b + 1];
    ++sum[a + x + 1][b + x + 2];
    --sum[a + x + 2][b + x + 2];
    ++sum[a + x + 2][b + 1];
    --sum[a + x + 1][b];
  }

  for(int i = 1; i <= N + 10; i++){
    for(int j = 1; j <= i + 5; j++){
      sum[i][j] += sum[i - 1][j - 1];
    }
  }
  for(int i = 1 ; i <= N + 10 ; i++){
    for(int j = 1 ; j <= i + 5; j++){
      sum[i][j] += sum[i][j - 1];
    }
  }
  for(int i = 1; i <= N + 10; i++){
    for(int j = 1; j <= i + 5; j++){
      sum[i][j] += sum[i - 1][j];
    }
  }

  int ret = 0, cnt = 0;
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= i; j++){
      if(sum[i][j] != 0) ret++;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 50608