akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <string>
#include <functional>

using namespace std;

typedef vector<bool> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;
typedef vector<string> vc2;
typedef vector<vc2> stage;
typedef pair<int,int> pii;
typedef pair<pii,pii> p2;

int solve();

bool isOut( int y, int x, int H, int W ) {
	return !( x >= 0 && y >= 0 && x < W && y < H );
}

int main(void) {
			
	while(solve()){}

	return 0;
}

int solve() {

	int W, H;
	cin >> W >> H;
	if(!(W|H)){ return 0; }

	v4 memo(H,v3(W,v2(H,v1(W,false))));

	stage stg( 2, vc2( H ) );

	//input
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < 2; j++ ) {
			cin >> stg[j][i];
		}
	}

	pii start[2];
	char ch[] = {'L','R'};
	for( int i = 0; i < 2; i++ ) {
		for( int j = 0; j < H; j++ ) {
			for( int k = 0; k < W; k++ ) {
				if( stg[i][j][k] == ch[i] ) {
					start[i].first = j;
					start[i].second = k;
				}
			}
		}
	}

	p2 st(start[0],start[1]);
	queue<p2> q;
	q.push(st);

	int d[4][2] = {{0,1},{1,0},{-1,0},{0,-1}};

	bool isClear = false;

	while( q.empty() == false && isClear == false){

		p2 p = q.front();
		q.pop();
		for( int i = 0; i < 4; i++ ) {

			p2 n = p;
			n.first.first += d[i][0];
			n.first.second += d[i][1];
			n.second.first += d[i][0];
			n.second.second -= d[i][1];
			
			if( isOut(n.first.first,n.first.second,H,W) == true ||
				stg[0][n.first.first][n.first.second] == '#' ) {
					n.first = p.first;
			}
			if( isOut(n.second.first,n.second.second,H,W) == true ||
				stg[1][n.second.first][n.second.second] == '#' ) {
					n.second = p.second;
			}
			if( ( stg[0][n.first.first][n.first.second] == '%' && stg[1][n.second.first][n.second.second] != '%' ) ||
				( stg[0][n.first.first][n.first.second] != '%' && stg[1][n.second.first][n.second.second] == '%' ) ) {
					continue;
			}

			if( memo[n.first.first][n.first.second][n.second.first][n.second.second] == false ) {
				memo[n.first.first][n.first.second][n.second.first][n.second.second] = true;
				if( stg[0][n.first.first][n.first.second] == '%' &&
					stg[1][n.second.first][n.second.second] == '%' ) {
					isClear = true;
				}
				q.push(n);
			}

		}


	}

	if( isClear ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 1;

}

Measured memory_bytes: 12248
#include<stdio.h>

int main(void){
	int i ,j ,n ,suji;
	char cards[4][14] ,mark;
	char suke[4] = {'S','H','C','D'};
	
	for(i = 0;i<4;++i){
		for(j=1;j<=13;++j)cards[i][j]=0;
	}
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf(" %c",&mark);
		scanf("%d",&suji);
		if(mark=='S')cards[0][suji]=1;
		if(mark=='H')cards[1][suji]=1;
		if(mark=='C')cards[2][suji]=1;
		if(mark=='D')cards[3][suji]=1;
		}
	for(i=0;i<4;++i){
		for(j=1;j<=13;++j){
			if(cards[i][j]==0){
				printf("%c %d\n",suke[i],j);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
import sys

n = input()
v = map(int, raw_input().split(' '))
startHere = [0 for i in range(n)]

if sum(v) % ((n * (n + 1)) / 2) != 0:
	print "NO"
	sys.exit()

operations = sum(v) / ((n * (n + 1)) / 2)

for i in range(n):
	diff = v[(i + 1) % n] - v[i]

	startHere[i] = (operations - diff) / n

contribution = 0
gathered = 0

for i in range(n):
	v[i] -= contribution
	gathered += startHere[i % n]
	contribution += gathered

for i in range(n):
	v[i] -= contribution
	gathered -= startHere[i % n]
	contribution -= startHere[i % n] * n
	contribution += gathered

if min(startHere) >= 0 and sum(startHere) == operations and min(v) == 0 and max(v) == 0:
	print "YES"
else:
	print "NO"


Measured memory_bytes: 11348
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

// O(√n) 
bool primeNumber(int n){  
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true; 
  VL c(9),a(3),b(3);
  rep(i,9){
    cin >> c[i];
  }
  a[0] = 0;
  rep(i,3){
    b[i] = c[i] - a[0];
  }
  for(int i=1;i<3;i++){
    a[i] = c[i*3] - b[0];
  }
  k=0;
  rep(i,3){
    rep(j,3){
      if(c[k]!=a[i]+b[j]){
        pri("No");
        return 0;
      }
      k++;
    }
  }
  pri("Yes");
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
//0 通らない部分
//1 偶数部分
//2 奇数部分
//3 偶数部分
//4 通らない部分
//先の数字へはいくらでもskip可能
long long INF=700000000000009;
long long dp[200010][5]={};
long long A,tmp;
int N;
cin>>N;
for(int i=1;i<=N;i++){
  cin>>A;
  for(int j=0;j<=4;j++){
    //dp[i][j]を初期化
    dp[i][j]=INF;
    if(j==0 || j==4){
      tmp=A;
    }
    else if(j==1 || j==3){
      if(A==0){tmp=2;}
      else{tmp=A%2;}
    }
    else{
      if(A==0){tmp=1;}
      else{tmp=(A+1)%2;}
    }
    //前のやつより小さくはならない
    for(int k=0;k<=j;k++){
      dp[i][j]=min(dp[i][j],dp[i-1][k]+tmp);
    }
  }
}
long long ans=INF;
for(int i=0;i<=4;i++){
  ans=min(dp[N][i],ans);
}
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

char a[21][21];

int n , m;

int get(int x, int y){
	int dis[21][21];
	memset(dis,0,sizeof(dis));
	int vis[21][21];
	memset(vis,0,sizeof(vis));
	vis[x][y] = 1;
	queue<pair<int,int>>q;
	q.push({x,y});
	int ret = 1;
	while(!q.empty()){
		pair<int,int> p = q.front();
		q.pop();
		for(int i = 0; i < 4; i++){
			int xx = p.first + dx[i];
			int yy = p.second + dy[i];
			if(xx >= 0  and xx <n and yy >= 0 and yy < m and !vis[xx][yy] and a[xx][yy]!='#'){
				dis[xx][yy] = dis[p.first][p.second] + 1;
				q.push({xx,yy});
				vis[xx][yy] = 1;
				ret = max(ret,dis[xx][yy]);
			}
 		}
	}
	return ret;
}

int32_t main(){
	fastio();
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m;j++){
			cin >> a[i][j];
		}
	}

	int ans = 0;
	for(int i = 0; i <n;i++){
		for(int j = 0; j < m; j++){
			if(a[i][j]=='.'){
				ans = max(ans,get(i,j));
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  ll n;
  cin >> n;
  vector<int>X(n);
  vector<int>A(n);
  for(int i=0;i<n;i++){
    cin >> A[i];
    X[i] = A[i] - (i+1);
  }
  sort(All(X));
  ll median = X[n/2];
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += abs(A[i]-(median+(i+1)));
  }

  cout<< ans <<endl;
}


Measured memory_bytes: 1792
h, w = map(int, input().split())
g = []
for _ in range(h):
    r = input()
    if r != "."*w:
        g.append(r)

gg = ["" for _ in range(len(g))]

for i in range(w):
    if "".join([g[j][i] for j in range(len(g))]) != "." * len(g):
        for j in range(len(g)):
            gg[j] += g[j][i]
print(*gg, sep="\n")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    int x = (m / 2) * 2 + 1;
    REP(i, m / 2) cout << i + 1 << " " << x - i << endl;
    x++;
    int y = x + ((m + 1) / 2) * 2 - 1;
    REP(i, (m + 1) / 2) cout << x + i << " " << y - i << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define fin(ans) cout << ans << endl
using namespace std;

long int GCM(long int num1, long int num2) {
  long int les = num1 % num2;
  if (les == 0)
    return num2;
  GCM(num2, les);
}

int main(void) {
  long int a, b;
  cin >> a >> b;
  long int d = GCM(a, b);
  fin(a * b / d);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

///======================  TEMPLATE ENDS HERE  =====================/// 

 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
    
    int n,x,sum = 0;

    cin >> n;

    rep(i,n) {
        cin >> x; sum ^= x;
    }

    string s = (!sum) ? "Yes" : "No";

    cout << s << endl;
	
 
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,c[11][11],a[210][210],ans=0;
    cin>>h>>w;
    rep(i,10)rep(j,10) cin>>c[i][j];
    rep(i,h)rep(j,w) cin>>a[i][j];
    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    rep(i,h)rep(j,w){
        if(a[i][j]>=0) ans+= c[a[i][j]][1]; 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#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 main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  vector<int> time={a,b,c,d,e};
  vector<int> index={0,1,2,3,4};
  int Besttime=(int) 1e+9;
  do{
    int nowtime=0;
    rep(i,5){
      while(nowtime%10!=0) nowtime++;
      nowtime+=time[index[i]];
    }
    Besttime=min(nowtime,Besttime);
  }while(next_permutation(all(index)));
  cout<<Besttime<<endl;
}

Measured memory_bytes: 3580
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int dp[N];

signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, m;  cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int p;  cin >> p;
        dp[p] = -1;
    }   
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        if(dp[i] == -1) continue;
        if(i >= 1 && dp[i-1] != -1)
            dp[i] += dp[i-1];
        if(i >= 2 && dp[i-2] != -1)
            dp[i] += dp[i-2];
        dp[i] %= mod;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#A
N = int(input())
S = list(map(int,input().split()))

R = []
now = 1
for i in range(N-1):
    if S[i] != S[i+1]:
        now+=1
    else:
        R.append(now)
        now = 1
        
R.append(now)
#print(R)
RL = len(R)
ans = 0
for i in range(RL):
    if i == 0:
        if RL == 1:
            ans = R[0]
        else:
            ans = R[i]+R[i+1]
    elif i == RL-1:
        ans = max(ans,R[i]+R[i-1])
    else:
        ans = max(ans,R[i-1]+R[i]+R[i+1])
        
print(ans)



Measured memory_bytes: 7180
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, k;
int a[224514];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	for (int i = k; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        ReaderB.init(System.in);
        Set<Character> arare = new HashSet<>();
        int n = ReaderB.nextInt();
        for (int i = 0; i < n; i++) {
            arare.add(ReaderB.next().charAt(0));
        }
        System.out.println(arare.size() == 4 ? "Four" : "Three");
    }
}

/**
 * Reader class based on the article at "https://www.cpe.ku.ac.th/~jim/java-io.html"
 */
class ReaderB {
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    //    Get a whole line.
    static String line() throws IOException {
        return reader.readLine();
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}



Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	int Q;
	cin >> Q;
	int ans = 0;
	while(Q--){
		int t;
		cin >> t;
		auto itr = lower_bound(ALL(a),t);
		if(itr == a.end())continue;
		if(*itr == t)++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3488
double P[51][4901],t;main(X,Y,Z){for(;scanf("%d%d%d",&X,&Y,&Z)*X;printf("%d\n",X=t)){int V[4],E[60]={0},A[51],M[51]={0},i,p,m,q,n,e;for(i=X;i--;)scanf("%d",V+i);for(**P=1;Z--;E[n]=e,A[n]=m)scanf("%d%d%d",&n,&e,&m);for(p=0;p<Y;p++)for(m=0;m<=M[p];m++)if(P[p][m])for(t=P[p][m]/X,P[p][m]=0,i=X;i--;P[q][n]+=t)q=p+V[i],n=m,(e=E[q])?e<2?q+=A[q]:e-2?n-=A[q],n<0?n=0:0:(n+=A[q]):0,q>Y?q=Y:0,n>M[q]?M[q]=n:0;for(t=m=0;m<=M[Y];m++)t+=P[Y][m]*m,P[Y][m]=0;}}

Measured memory_bytes: 0
sx,sy,tx,ty=map(int,input().split())
r=tx-sx
u=ty-sy
ans=[]
for i in range(r):
  ans.append("R")
for i in range(u):
  ans.append("U")
for i in range(r):
  ans.append("L")
for i in range(u):
  ans.append("D")
ans.append("D")
for i in range(r+1):
  ans.append("R")
for i in range(u+1):
  ans.append("U")
ans.append("L")
ans.append("U")
for i in range(r+1):
  ans.append("L")
for i in range(u+1):
  ans.append("D")
ans.append("R")
print(*ans,sep="")

Measured memory_bytes: 4852
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,P;cin>>A>>P;
  cout<<(3*A+P)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
//#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)

struct cmp
{
    bool operator()(pair<int, int> a, pair<int, int> b)
    {
        if (a.first != b.first)
        {
            if (a.second == b.second)
            {
                return a.first < b.first;
            }
            else
            {
                return a.second < b.second;
            }
        }
        else
        {
            return a.second < b.second;
        }
    }
};

int edgeTo[100000 + 5];
int distTo[100000 + 5];
set<pair<int, int>, cmp> pq;
void relax(int from, int to, int weight)
{
    if (distTo[to] > distTo[from] + weight)
    {
        pair<int, int> backup = {to, distTo[to]};
        distTo[to] = distTo[from] + weight;
        edgeTo[to] = from;
        if (pq.find(backup) != pq.end())
        {
            pq.erase(backup);
            pq.insert({to, distTo[to]});
        }
        else
        {
            pq.insert({to, distTo[to]});
        }
    }
}

void dijsktra(vector<vector<pair<int, int>>> g, int s)
{
    int n = g.size();
    for (int i = 0; i < n + 1; i++)
    {
        distTo[i] = 2147483647;
    }

    distTo[s] = 0;
    pq.insert({s, 0});
    while (!pq.empty())
    {
        auto it = pq.begin();
        pair<int, int> top = *it;
        pq.erase(*it);
        for (pair<int, int> e : g[top.first])
        {
            relax(top.first, e.first, e.second);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> graph(n + 1);
    rep(i, 1, m + 1)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back({b, 1});
        graph[b].push_back({a, 1});
    }
    dijsktra(graph, 1);

    cout << "Yes" << endl;
    rep(i, 2, n + 1)
    {
        cout << edgeTo[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 22592
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

vector<int> v;
int n, k;

int main() {
#ifdef HOME
	freopen("agc018a.in", "r", stdin);
	freopen("agc018a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int g;

	cin >> n >> k;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	g = v[0];
	for (auto i: v)
		g = gcd(g, i);

	for (auto i: v)
		if (i >= k && (i - k) % g == 0) {
			cout << "POSSIBLE\n";
			return 0; }

	cout << "IMPOSSIBLE\n";

	return 0; }


Measured memory_bytes: 640
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(auto& c:v)
        cin>>c;

    int have=1000;
    int prv=0;
    for(int i=1;i<n;++i)
    {
        if(v[i-1]>v[i])
        {
            int cnt=have/v[prv];
            have%=v[prv];
            have+=v[i-1]*cnt;

            prv=i;
        }

//        show(i,prv,have);
    }

    int cnt=have/v[prv];
    have%=v[prv];
    have+=v[n-1]*cnt;

    cout<<have;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (sum <= a[i] * 4 * m) cnt++;
	}
	cout << (cnt >= m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int LOC[128];
int value[4][14],mult[9];

int getNUM(char ch){

	if(ch >= '2' && ch <= '9')return ch - '0';

	switch(ch){
	case 'A':return 1;
	case 'T':return 10;
	case 'J':return 11;
	case 'Q':return 12;
	case 'K':return 13;
	}
	return -1; //must not reach here
}

bool is_straight(int array[5]){

	if(array[4]-array[0] == 4)return true;

	if(array[0] == 1 && array[1] == 10)return true;

	return false;
}


int main(){

	LOC['S'] = 0;
	LOC['C'] = 1;
	LOC['H'] = 2;
	LOC['D'] = 3;

	int N,num_2,num_3,num_4,num_suit,point;
	bool isFirst = true;
	char buf[3];
	int num_table[14],suit_table[4],tmp_num,tmp_suit,array[5],index;

	while(scanf("%d",&N) != EOF){

		if(isFirst){
			isFirst = false;
		}else{
			printf("\n");
		}

		for(int i = 0; i < 4; i++){
			for(int k = 1; k <= 13; k++)scanf("%d",&value[i][k]);
		}

		for(int i = 0; i < 9; i++)scanf("%d",&mult[i]);

		for(int loop = 0; loop < N; loop++){
			for(int i = 1; i <= 13; i++)num_table[i] = 0;
			for(int i = 0; i < 4; i++)suit_table[i] = 0;

			num_2 = num_3 = num_4 = num_suit = point = 0;

			for(int k = 0; k < 5; k++){
				scanf("%s",buf);

				tmp_suit = LOC[buf[1]];
				tmp_num = getNUM(buf[0]);

				point += value[tmp_suit][tmp_num];
				num_table[tmp_num]++;
				suit_table[tmp_suit]++;
			}

			for(int k = 0; k < 4; k++){
				if(suit_table[k] > 0)num_suit++;
			}

			for(int k = 1; k <= 13; k++){
				if(num_table[k] == 0)continue;

				switch(num_table[k]){
				case 2:
					num_2++;
					break;
				case 3:
					num_3++;
					break;
				case 4:
					num_4++;
					break;
				}
			}

			if(num_2 == 1){
				if(num_3 != 1){
					printf("%d\n",point*mult[0]);
					continue;
				}else{
					printf("%d\n",point*mult[5]);
					continue;
				}
			}

			if(num_2 == 2){
				printf("%d\n",point*mult[1]);
				continue;
			}
			if(num_3 == 1){
				printf("%d\n",point*mult[2]);
				continue;
			}

			if(num_4 == 1){
				printf("%d\n",point*mult[6]);
				continue;
			}

			index = 0;
			for(int k = 1; k <= 13; k++){
				if(num_table[k] == 0)continue;
				array[index++] = k;
			}

			if(num_suit >= 2){

				if(is_straight(array)){
					printf("%d\n",point*mult[3]);
				}else{
					printf("0\n");
				}

			}else{

				if(is_straight(array)){
					if(array[0] == 1 && array[4] == 13){
						printf("%d\n",point*mult[8]);
					}else{
						printf("%d\n",point*mult[7]);
					}
				}else{
					printf("%d\n",point*mult[4]);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3196
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = [0]*n
place = 0
for i in range(n):
    ans[i] = abs(t - (h[i] * 0.006) - a)

for i in range(n):
    if ans[i] == min(ans):
        place = i
        break

print(place + 1)

Measured memory_bytes: 3064
export class Main {
  static main(input): string {
    const [a, b, c]: number[] = input.split("\n")[0].split(" ").map(Number);
    return `${a == b && b == c ? "Yes" : "No"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;

  int SugarWater=0,Sugar=0;
  double x=0;
  for(int a=0;a*100*A<=F;a++){
    for(int b=0;b*100*B+a*100*A<=F;b++){
      for(int c=0;c*C+b*100*B+a*100*A<=F;c++){
        for(int d=0;d*D+c*C+b*100*B+a*100*A<=F;d++){
          if(d*D+c*C+b*100*B+a*100*A<=0)  continue;
          if(100*(d*D+c*C)*(100+E)>100*E*(d*D+c*C+b*100*B+a*100*A)) continue;
          double y=(double)100*(d*D+c*C)/(d*D+c*C+b*100*B+a*100*A);
          if(x<=y){
            x=y;
            SugarWater=d*D+c*C+b*100*B+a*100*A;
            Sugar=d*D+c*C;
          }
        }
      }
    }
  }
  cout << SugarWater << " " << Sugar << endl;

  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_2_A
def bubble_sort(ary, n):
    count = 0
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in reversed(range(i+1, n)):
            if ary[j] < ary[j-1]:
                ary[j], ary[j-1] = ary[j-1], ary[j]
                count += 1
                flag = 1
        i += 1

    print(' '.join(map(str, ary)))
    print(count)

n = int(input())
numbers = list(map(int, input().split()))
bubble_sort(numbers, n)

Measured memory_bytes: 7784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

int main()
{
    long long x, y;
    std::cin >> x >> y;
    long long ans = 0;
    while(x <= y) {
        x *= 2;
        ans++;
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 3684
//chokudaiさんの書いたプログラムをC++にした。
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
using namespace std;

int main() {
	long long N; cin >> N;
	vector<long long> A(N + 1), B(N);
	for (int i = 0; i <= N; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> B.at(i);
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		long long left = min(A.at(i), B.at(i));
		ans += left;
		A.at(i) -= left;
		B.at(i) -= left;

		long long right = min(A.at(i + 1), B.at(i));
		ans += right;
		A.at(i + 1) -= right;
		B.at(i) -= right;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
from scipy.sparse.csgraph import shortest_path
import numpy as np
import itertools

n,m,r=map(int,input().split())
r=list(map(int,input().split()))

edge=np.zeros((n+1,n+1))
for i in range(m):
    a,b,c=map(int,input().split())
    edge[a,b]=c

dist=shortest_path(edge,directed=False).astype(int)

ans=10**18
for v in itertools.permutations(r):
    ans2=0
    p=v[0]
    for x in v[1:]:
        if p!=None:
            ans2+=dist[p,x]
        p=x
    ans=min(ans,ans2)

print(ans)


Measured memory_bytes: 18188
a,b,c,x,y = map(int,input().split())

if (a + b) <= 2 * c:
  print(a * x + b * y)
else:
  max_c = max(x,y)
  min_c = min(x,y)
  AB = 2 * c * max_c
  if x > y:
    SP = ((x - min_c) * a) + (2 * c * min_c)
  else:
    SP = ((y - min_c) * b) + (2 * c * min_c)
  print(min(AB,SP))


Measured memory_bytes: 9040
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int i;
    int h[10];

    for(i=0; i<10; i++){
        cin >> h[i];
    }

    sort(h, h+10, greater<int>());

    for(i=0; i<3; i++){
        cout << h[i] << std::endl;
    }

}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;

int main() {

    ll n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a+n);

    rep(i, n - 1) {
        ans += a[ n - 1 - (i+1) / 2];
    }

    AA(ans);
}

Measured memory_bytes: 5184
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double a=Double.parseDouble(sc.next());
		double b=Double.parseDouble(sc.next());
		double rc=Double.parseDouble(sc.next());
		double S=(a*b*Math.sin(Math.toRadians(rc))/2);
		double L=a+b+(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(rc))));
		double h=S*2/a;
		String strAns=String.valueOf(S);
		BigDecimal bd=new BigDecimal(strAns);
		BigDecimal A=bd.setScale(8, BigDecimal.ROUND_HALF_UP);
		strAns=String.valueOf(L);
		bd=new BigDecimal(strAns);
		BigDecimal B=bd.setScale(8, BigDecimal.ROUND_HALF_UP);
		strAns=String.valueOf(h);
		bd=new BigDecimal(strAns);
		BigDecimal C=bd.setScale(8, BigDecimal.ROUND_HALF_UP);
		System.out.println(A+" "+B+" "+C);
	}

}



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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; }
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int H = -1, tmpH;
            int maxH = INT_MAX;
            bool ok = true;
            for (int i = 0; i < n; i++) {
                if (h[i] != 0) {
                    tmpH = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                    if (tmpH == 0 || maxH < tmpH) {
                        ok = false;
                        break;
                    }
                    if (H != -1 && H != tmpH) {
                        ok = false;
                        break;
                    } else
                        H = tmpH;
                } else {
                    if (H != -1 && H > abs(x[i] - cx) + abs(y[i] - cy)) {
                        ok = false;
                        break;
                    }
                    if (H == -1) {
                        maxH = min(maxH, abs(x[i] - cx) + abs(y[i] - cy));
                    }
                }
            }
            if (ok) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int a,b;
string s,t,u;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s>>t>>a>>b>>u;
	if(u==s)a--;
	else b--;
	cout<<a<<" "<<b<<endl;
	return 0;
}


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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	int ans = 0;
	f(i,0,n)
	{
		int x;
		cin >> x;
		ans += (x >= k);
	}
	cout << ans;
}







Measured memory_bytes: 256
n = int(input())
S = list(map(int,input().split())) + [0]
q = int(input())
T = map(int,input().split())
ret = 0
for t in T:
  i = 0
  S[n] = t
  while t != S[i]:
    i += 1
  if i != n:
    ret += 1
print(ret)


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

 // source by drken
  
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
  
  // テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int X,Y;
  cin >> X >> Y;
  if ((X + Y)%3 != 0 || 2*Y-X < 0 || 2*X-Y < 0) {
    cout << 0 << endl;
    return 0;
  }
  int A,B;
  A = (2*Y-X)/3; B = (2*X-Y)/3;
  
  // 前処理
  COMinit();
  
  // 計算例
    cout << COM(A+B, A) << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	int n,k,i,j,p,c=0;
	scanf("%d%d",&n,&k);
	map<int,int>mp;
	for(i=1;i<=k;i++)
	{
		int d;
		scanf("%d",&d);
		for(j=1;j<=d;j++)
		{
			scanf("%d",&p);
			mp[p]++;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(mp.count(i)==0)
		{
			c++;
		}
	}
	printf("%d\n",c);
    return 0;
}


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

using namespace std;

int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  char S[100000], T[100000];
  scanf("%s%s", S, T);
  
  // 最大公約数を計算
  int g = __gcd(N, M);
  int stepS = N / g;
  int stepT = M / g;
  for (int i = 0; i < g; ++i) {
    if (S[stepS * i] != T[stepT * i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%lld", 1ll * stepS * M);
  return 0;
}

Measured memory_bytes: 384
NM_list = input().split(" ")
N = int(NM_list[0])
M = int(NM_list[1])
num = []
for i in range(N):
    num.append(-1)
for i in range(M):
    sc_list = input().split(" ")
    s = int(sc_list[0])-1
    c = int(sc_list[1])
    if num[s] ==-1 or num[s] == c:
        num[s] = c
    else:
        print(-1)
        exit()
if N != 1 and num[0] == 0:
    print(-1)
    exit()
if N != 1 and num[0] == -1:
    num[0] = 1
for i in range(1,N):
    if num[i] == -1:
        num[i] = 0
if N == 1 and num[0] == -1:
    print(0)
else:
    sum = 0
    for i in range(N):
        sum += num[i]*10**(N-i-1)
    print(sum)


Measured memory_bytes: 3064
N = int(input())
list = list(map(int,input().split()))
cnt=0
for i in range(1,N-1):
	sub = [list[i-1],list[i],list[i+1]]
	match = list[i]
	sub.sort()
	if(sub[1] == match):
		cnt+=1
print(cnt)

Measured memory_bytes: 3064
N,K=map(int,input().split())
A=list(map(int,input().split()))

count=0
while True and K>count:
    nx=[0]*N
    for i in range(N):
        posl=max(0,i-A[i])
        posr=min(N-1,i+A[i])
        if N-1>posr:
            nx[posl]+=1
            nx[posr+1]-=1
        else:
            nx[posl]+=1
    for i in range(1,N):
        nx[i]+=nx[i-1]
    A=nx
    count+=1
    if min(A)==N:
        break

print(*A)


Measured memory_bytes: 156556
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=3300;
typedef long long ll;

bool nprime[N+10];
int c[N+10];
ll a[100010],b[100010];

int main()
{
	#ifdef waltz
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	memset(nprime,0,sizeof(nprime));
	int cnt=0;
	for (int i=2;i<=N;i++)
	{
		if (!nprime[i]) c[++cnt]=i;
		for (int j=1;j<=cnt;j++)
		{
			if (i*c[j]>N) break;
			nprime[i*c[j]]=1;
			if (i%c[j]==0) break;
		}
	}
	for (int i=1;i<=n;i++)
	{
		ll t=a[i];b[i]=1;
		for (int j=1;t>1&&j<=cnt;j++)
		{
			int s=0;
			while (t%c[j]==0) {t/=c[j];s++;}
			for (int k=0;k<s%3;k++) b[i]*=c[j];
		}
		b[i]*=t;
	}
	sort(b+1,b+n+1);
	int l=1,ans=0;
	for (int i=2;i<=n+1;i++)
		if (i==n+1||b[i]!=b[i-1])
		{
			if (b[l]==1) {ans++;l=i;continue;}
			ll t1=b[l],t2=1;
			for (int j=1;t1>1&&j<=cnt;j++)
				if (t1%c[j]==0)
				{
					int s=0;
					while (t1%c[j]==0) {t1/=c[j];s++;}
					for (int k=0;k<3-s;k++) t2*=c[j];
				}
			if (t1>1)
			{
				ll t3=ll(sqrt(t1+0.5));
				if (t3*t3==t1)
					t2*=t3;
				else
				{
					t2*=t1;
					if (t1>100000) t2=1000000000000ll; else t2*=t1;
				}
			}
			int w=upper_bound(b+1,b+n+1,t2)-lower_bound(b+1,b+n+1,t2);
			if (i-l>w||(i-l==w&&b[l]>t2)) ans+=i-l;
			l=i;
		}
	printf("%d\n",ans);
	return 0;
}
				

Measured memory_bytes: 1792