akhauriyash/Code-Regression huggingface dataset:
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> t, a;
  bool invalid = false;
  rep(i, n){
    ll x;
    cin >> x;
    t.pb(x);
    if(i > 0){
      if(t[i-1] > t[i])invalid = true;
    }
  }
  rep(i, n){
    ll x;
    cin >> x;
    a.pb(x);
    if(i > 0){
      if(a[i-1] < a[i])invalid = true;
    }
  }
  if(invalid || t[n-1] != a[0]){
    cout << 0 << endl;
    return 0;
  }
  ll res = 1;
  FOR(i, 1, n - 1){
    if(t[i-1] != t[i] || a[i+1] != a[i]){
      if(t[i-1] != t[i]){
        if(t[i] > a[i]){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(a[i] > t[i]){
          cout << 0 << endl;
          return 0;
        }
      }
    }else{
      res = res * min(t[i], a[i]) % mod;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int H[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		H[i] = rei();
	}
	int c = 0;
	int ans = 0;
	for(int i=N-2;i>=0;i--){
		if(H[i] >= H[i+1]){
			c++;
			ans = max(ans,c);
		}
		else{
			c = 0;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 640
#include <set>
#include <iostream>
#include <string>
using namespace std;
string cmd , word;
set<string> S;
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>cmd;
        if(cmd=="insert")
        {
            cin>>word;
            S.insert(word);
        }
        if(cmd=="find")
        {
            cin>>word;
            if(S.count(word)>0)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 32616
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <climits>
#include <cmath>
#define lli long long int
using namespace std ;

void eval(vector<int> &a, vector<int> &b, vector<int> &c, int ind, vector<vector<int> > &dp)
{
	if(ind == 0)
	{
		dp[0][0] = a[0] ;
		dp[0][1] = b[0] ;
		dp[0][2] = c[0] ;

		return ;
	} 

	eval(a,b,c,ind-1,dp) ;

	dp[ind][0] = a[ind] + max(dp[ind-1][1], dp[ind-1][2]) ;
	dp[ind][1] = b[ind] + max(dp[ind-1][0], dp[ind-1][2]) ;
	dp[ind][2] = c[ind] + max(dp[ind-1][0], dp[ind-1][1]) ;

	return ; 
}

int main(int argc, char const *argv[])
{
	int n ;
	cin>>n ;

	vector<int> a(n),b(n),c(n) ;
	for(int i = 0 ; i < n ; i++)
	{
		cin>>a[i]>>b[i]>>c[i] ;
	}

	vector<vector<int> > dp(n,vector<int> (3,-1)) ;
	eval(a,b,c,n-1,dp) ;
	int ans = max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])) ;
	cout<<ans<<endl ;
	return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>adj[100005];	//邻接表
bool vis[100005];
bool Hash[100005];
int n, m, a, b, ans = 0;
void dfs(int u)
{
	vis[u] = true;
	for (int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if (!vis[v]) dfs(v);
	}
}
int main()
{
	cin >> n >> m;
	while (m--)
	{
		scanf("%d %d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
		//Hash[a] = Hash[b] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i])
		{
			dfs(i);
			ans++;
		}
	}
	printf("%d", ans - 1);
	return 0;
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n), b(n), sum(2, 0);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) sum[0] += a[i], sum[1] += b[i];

    // 操作可能な回数
    // ；1回操作すると、sum[0]は2増え、sum[1]は1増えるため、差分が操作回数である。
    ll k = sum[1] - sum[0];

    // 操作が必要な回数
    ll cnt = 0;
    rep(i, n){
        if(a[i] < b[i]) cnt += ceil((b[i]-a[i])/2.0);
    }
    (k >= cnt) ? Yes() : No(); 
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 6005;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f3f3f3f;
#define ms(a,k)  memset(a,k,sizeof(a))
int main()
{
    int a,b;
    cin>>a>>b;
    if(b%a==0)printf("%d\n",a+b);
    else printf("%d\n",b-a);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    max_x = 100
    max_y = 100
    max_z = 100
    ans = [0] * N
    for x in range(1, max_x+1):
        for y in range(1, max_y+1):
            for z in range(1, max_z+1):
                a = (x+y+z)**2 - x*y - y*z - z*x
                if 1 <= a <= N:
                    ans[a-1] += 1
    for ni in ans:
        print(ni)
if __name__ == "__main__":
    main()

Measured memory_bytes: 68484
#include<bits/stdc++.h>
using namespace std;
long long n,x,tot,ans,a[100010];
int main()
{
    cin>>n;
    for(int i=1;i<=n+1;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(a[i]>=x)ans+=x;
        else 
        {
            x-=a[i];ans+=a[i];
            tot=min(x,a[i+1]);
            ans+=tot;a[i+1]-=tot;
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> w(n);
	int all = 0;
	for (size_t i = 0; i < n; i++) {
		std::cin >> w[i];
		all += w[i];
	}
	int s1 = 0;
	int ans = all;
	for (size_t i = 0; i < n; i++) {
		s1 += w[i];
		ans = min(ans, abs(all - 2 * s1));
	}

	std::cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
}


Measured memory_bytes: 3576
use proconio::input;
use std::ops::Range;
use either::Either;

fn main() {
    input! {
        H: usize,
        W: usize,
        grid: [[i128; W]; H]
    }
    let mut taken = None;
    let mut rev = false;
    let mut ops = vec![];
    for y in 0..H {
        for x
        in if rev {
            Either::Left((0..=(W - 1)).rev())
        } else {
            Either::Right(0..W)
        } {
            let num = grid[y][x] + if taken.is_some() { 1 } else { 0 };
            taken.iter().for_each(|&(from_x, from_y)| ops.push((from_x + 1, from_y + 1, x + 1, y + 1)));
            taken = if num % 2 == 0 {
                None
            } else {
                Some((x, y))
            }
        }
        rev =!rev
    }
    println!("{}", ops.len());
    for (x1, y1, x2, y2) in ops {
        println!("{} {} {} {}", y1, x1, y2, x2)
    }
}


Measured memory_bytes: 10764
#include <iostream>
//=  <   >
using namespace std;
typedef long long ll;
int main() 
{
  ll H, N_attacks, power = 0;
  cin >> H >> N_attacks;
  for ( int i = 0; i < N_attacks; ++i )
  {
    int p; cin >> p;
    power += p;
  }

  cout << ( ( H <= power ) ? "Yes" : "No" );
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
// }}} End

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

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

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

    int K, S; cin >> K >> S;

    intmax_t res = 0;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            int z = S - (x + y);
            if (0 <= z && z <= K) {
                res++;
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[100];
signed main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int ans = 1;
  rep(i,'z'-'a'+1){
    int tmp = -1;
    rep(j,n)if(s[j]-'a' == i){
      if(tmp == -1){
        tmp = t[j]-'a';
        continue;
      }
      if(t[j]-'a' != tmp)ans = 0;
    }
  }
  rep(i,'z'-'a'+1){
    int tmp = -1;
    rep(j,n)if(t[j]-'a' == i){
      if( tmp == -1){
        tmp = s[j]-'a';
        continue;
      }
      // if(t[j] == 'r')printf("%lld\n", tmp);
      if(s[j]-'a' != tmp)ans = 0;
    }
    // printf("%c ", i+'a');
  }
  printf("%s\n", ans ? "Yes" : "No");
	return 0;
}








Measured memory_bytes: 776
import heapq

N = int(input())
A = [int(s) for s in input().split()]

sum_a = sum(A[:N])
sum_b = sum(A[2*N:])

a_heap = A[:N]
b_heap = list(map(lambda x: x*-1, A[2*N:]))

heapq.heapify(a_heap)
heapq.heapify(b_heap)

SUM_A = [0] * (N + 1)
SUM_B = [0] * (N + 1)

SUM_A[0] = sum_a
SUM_B[0] = sum_b

# x = -1 * heapq.heappop(A) # 最大値の取り出し
# heapq.heappush(A, -1*x)  # 要素の挿入

for k in range(1, N + 1):
    heapq.heappush(a_heap, A[(N - 1) + k])
    heapq.heappush(b_heap, -A[(2 * N) - k])

    a1 = heapq.heappop(a_heap)
    b1 = -1 * heapq.heappop(b_heap)

    SUM_A[k] = SUM_A[k - 1] + A[(N - 1) + k] - a1
    SUM_B[k] = SUM_B[k - 1] + A[(2 * N) - k] - b1


print(max(map(lambda x: x[0]-x[1], zip(SUM_A, SUM_B[::-1]))))


Measured memory_bytes: 37212
import sys
X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
else:
  P=list(map(int,input().split()))
L=[]
A=[]
A_1=[]
for i in range(-100,200):
  L.append(i)
for i in P:
  L[i+100]=200
for i in L:
  A.append(abs(X-i))
A_1=sorted(A)
a=A_1[0]
for i in L:
  if i==X-a:
    print(i)
    sys.exit()
  elif i==X+a:
    print(X+a)
    break

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

int main() {
    int n; scanf("%d", &n);
    static int64_t a[100010], b[100010];
    for (int i = 0; i < n; i++) scanf("%lld%lld", &a[i], &b[i]);

    int64_t cnt = 0, acc = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[i] = (a[i] + acc % b[i]) % b[i];
        int x = (b[i] - a[i] % b[i]) % b[i];
        cnt += x; acc += x;
    }
    printf("%lld\n", cnt);
    return 0;
}

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

using namespace std;

int n, k;
vector<int> adj[200010];
int f[200010], fi[200010];
int ans = 1;
const int MOD = 1e9 + 7;

int mul(long long a, long long b){
	return (a * b) % MOD;
}

int fp(int a, int b){
	int ret = 1;

	while(b){
		if(b & 1) ret = mul(ret, a);

		a = mul(a, a), b >>= 1;
	}

	return ret;
}

void dfs(int u, int p){
	int av = k - 1;

	if(p != -1) av--;
	
	for(auto v : adj[u]){
		if(v == p) continue;

		if(av < 0) ans = 0;

		ans = mul(ans, av--);

		dfs(v, u);
	}
}

int main(){
	f[0] = fi[0] = 1;
	for(int i = 1; i <= 200000; i++){
		f[i] = mul(f[i - 1], i);
		fi[i] = fp(f[i], MOD - 2);
	}

	scanf("%d%d", &n, &k);

	assert(k != 0);

	for(int i = 1; i < n; i++){
		int u, v;
		scanf("%d%d", &u, &v);

		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}

	ans = k;
	dfs(1, -1);

	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int X[10][10];
int main() {
  int N,D;
  cin >> N >> D;
  for (int i=0;i<N;i++){
    for (int j=0;j<D;j++){
      cin >> X[i][j];
    }
  }
  int c = 0;
  for (int i=0;i<N-1;i++){
    for (int j=i+1;j<N;j++){
      
      int d_2 = 0;
      for (int k=0;k<D;k++) d_2 += pow(X[i][k]-X[j][k],2);
      int d_p =pow(d_2,0.5);
      if (pow(d_p,2)==d_2) c++;
    }
  }
  cout << c << "\n";
}

Measured memory_bytes: 256
#Ai/Aj not integer
#5
#24 11 8 3 16
#のときは、24は8,3があるからダメ　16も8があるからダメ
N=int(input())
A=[int(i) for i in input().split()]
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)


Measured memory_bytes: 39884
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
ans = ""
d = collections.deque()
for i in range(n):
    if i%2 == 1:
        d.append(a[i])
    else:
        d.appendleft(a[i])
ans = []
if n%2 == 1:
    for i in range(n):
        ans.append(d[i])
else:
    for i in range(n):
        ans.append(d[n-i-1])
print(*ans)


Measured memory_bytes: 25520
import sys
from collections import deque
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
d=deque(e.split()for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 v=int(v)
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t)


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

int main(void){
    int W,H,x,y,r;
    cin >>W>>H>>x>>y>>r;
    if(r+x<=W && x-r>=0){
        if(r+y<=H && y-r>=0){
            cout <<"Yes"<< endl;
            return 0;
        }
    }
    cout <<"No"<< endl;
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,p,mx=-1,s=0;
	int n;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>p;
		mx=max(p,mx);
		s+=p;
	}
	cout<<s-mx/2;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010],cnt[200010],L,R,l,r;
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)cnt[a[i]=read()]++;
	for(int i=1;i<=n;i++)cnt[b[n-i+1]=read()]++;
	for(int i=1;i<=n;i++)
	if(cnt[i]>n){cout<<"No";return 0;}
	cout<<"Yes\n";
	L=n;R=1;l=1;r=n;
	for(int i=1;i<=n;i++)
	if(a[i]==b[i]){
		L=min(L,i);
		R=max(R,i);
	}
	for(int i=L;i<=R;i++)
	if(b[i]!=a[l]&&b[i]!=b[l])swap(b[i],b[l++]);
	else swap(b[i],b[r--]);
	/*for(int i=L;i<=R;i++)
	if(l<L&&b[l]!=b[i])swap(b[i],b[l++]);
	else swap(b[i],b[r--]);*/
	for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
}

Measured memory_bytes: 6068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

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

int main()
{	
    ll n, k;
	cin >> n >> k;
    ll ans = 0;
    vector<ll> tmp(n, -1);

    REP(i, k){
        int d;
        cin >> d;
        vector<ll> v(d);  
        REP(j, d){
            cin >> v[j];
            tmp[v[j] - 1]++;
        }
    } 

    REP(i, n){
        if(tmp[i] == -1){
            ans++;
        }
    }
    //cout << endl;
    //REP(i, n) cout << tmp[i] << endl;
    //cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3624
<?php

  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $sum = array_sum($a);

  $x=0;
  for($i=0;$i<$n;$i++){
    if(1/(4*$m) <= $a[$i]/$sum){
       $x++;
    }
  }

  if($m <= $x){
    echo "Yes";
  }else{
    echo "No";
  }

Measured memory_bytes: 4604
/*
AtCoderBeginnerContest168
Problem A - ∴ (Therefore) / Therefore
Time Limit: 2 sec / Memory Limit: 1024 MB
Score:
100
points
*/

#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    N %= 10;

    if (N==3)
    {
        std::cout << "bon\n";
    }
    else if (N==0 || N==1 || N==6 || N==8)
    {
        std::cout << "pon\n";
    }
    else
    {
        std::cout << "hon\n";
    }
}


Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

struct Dest {
    int to;
    int cost;
};

struct Node {
    vector<Dest> dests;
    int distance;
    bool checked;
};

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int nodeNum, linkNum, startIndex;
    cin >> nodeNum >> linkNum >> startIndex;
    vector<Node> nodes;
    rep(i, nodeNum) {
        Node n;
        n.distance = -1;
        n.checked = false;
        nodes.push_back(n);
    }
    rep(i, linkNum) {
        int s, t, d;
        cin >> s >> t >> d;
        nodes[s].dests.push_back({.to = t, .cost = d});
        // nodes[t].dests.push_back({.to = s, .cost = d});
    }

    auto compare = [](Node x, Node y) {
        return x.distance > y.distance;
    };

    std::priority_queue<Node, vector<Node>, decltype(compare)> queue{compare};
    nodes[startIndex].distance = 0;
    queue.push(nodes[startIndex]);

    while (!queue.empty()) {
        Node n = queue.top();
        queue.pop();
        if (n.checked) continue;
        n.checked = true;
        for (auto& next : n.dests) {
            if (nodes[next.to].distance == -1 || nodes[next.to].distance > n.distance + next.cost) {
                nodes[next.to].distance = n.distance + next.cost;
                queue.push(nodes[next.to]);
            }
        }
    }
    for (auto &node : nodes) {
        if (node.distance == -1) {
            cout << "INF" << endl;
        } else {
            cout << node.distance << endl;
        }
        
    }
}


Measured memory_bytes: 19948
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//#define int long long
const int MAX_HW = 55;

int H, W, v[MAX_HW][MAX_HW];
int my[] = {0, 0, 1, -1, 1, 1, -1, -1};
int mx[] = {1, -1, 0, 0, 1, -1, 1, -1};

void dfs(int y, int x){
  REP(i, 8){
    int ny = y + my[i], nx = x + mx[i];
    if(ny < 0 || nx < 0 || ny >= H || nx >= W || v[ny][nx] == 0) continue;
    v[ny][nx] = 0;
    dfs(ny, nx);
  }
}

int main() {
  while(cin >>W >>H && W){
    int ans = 0;
    REP(i, H) REP(j, W) cin >>v[i][j];
    REP(i, H){
      REP(j, W){
        if(v[i][j] == 1){
          ++ans;
          v[i][j] = 0;
          dfs(i, j);
        }
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
def solve():
    a,b,c,x,y = map(int,input().split())
    ans = 10**12
    for i in range(max(x,y+1)):
        cost = c*2*i
        dx = max(0,x-i)
        dy = max(0,y-i)
        cost+=dx*a
        cost+=dy*b
        ans = min(ans,cost)
    print(ans)
if __name__ == "__main__":
    solve()

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

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	int c=0;
	int i=0,j=n-1;
	while(i<j)
	{
		while(i<n && s[i]!='W') i++;
		while(j>0 && s[j]!='R') j--;
		
		if(i<j)
		{
			c++;
			i++;
			j--;
		}
	}
	cout<<c<<endl;
}

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

Measured memory_bytes: 3784
#include <stdio.h>

int main(void) {

 char s1[10],s2[10],s3[10];
 scanf("%s%s%s", s1,s2,s3);
 printf("%c%c%c\n", s1[0]-32,s2[0]-32,s3[0]-32);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,i,j,k,l,m,M=1e9+7,d[110][4][4][4]={};
  scanf("%d",&n);
  for(j=0;j<4;j++){
    for(k=0;k<4;k++){
      for(l=0;l<4;l++){
	if(j==0&&k==2&&l==1)continue;
	if(j==0&&k==1&&l==2)continue;
	if(j==2&&k==0&&l==1)continue;
	d[3][j][k][l]=1;
      }
    }
  }
  for(i=3;i<n;i++){
    for(j=0;j<4;j++){     
      for(k=0;k<4;k++){
	for(l=0;l<4;l++){
	  for(m=0;m<4;m++){
	    // if(j==0&&k==2&&l==1)continue;
	    if(k==0&&l==2&&m==1)continue;

	    if(j==0&&l==2&&m==1)continue;
	    
	    // if(j==2&&k==0&&l==1)continue;
	    if(k==2&&l==0&&m==1)continue;
		    
	    if(j==0&&k==2&&m==1)continue;
	    
	    // if(j==0&&k==1&&l==2)continue;
	    if(k==0&&l==1&&m==2)continue;
	    d[i+1][k][l][m]=(d[i+1][k][l][m]+d[i][j][k][l])%M;
	  }
	}
      }
    }
  }
  for(j=m=0;j<4;j++){
    for(k=0;k<4;k++){
      for(l=0;l<4;l++)m=(m+d[n][j][k][l])%M;
    }
  }
  printf("%d\n",m);
}
			


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>

int const MAXN = 1e5;
int N, K, R, S, P;
std::string T, RSP = "rsp";
int iRSP[256];
int sRSP[3];
inline bool win(int c, int d) { return (c-d+3)%3 == 1; }

int dp[MAXN][3];
int calc(int n, int d) {
  if(dp[n][d] >= 0) return dp[n][d];
  int c = iRSP[T[n]];
  int res = win(c, d)? sRSP[d]: 0;
  if(n+K < N) res += std::max(calc(n+K, (d+1)%3), calc(n+K, (d+2)%3));
  return dp[n][d] = res;
}

int main() {
  std::cin >> N >> K >> R >> S >> P >> T;
  sRSP[0] = R; sRSP[1] = S; sRSP[2] = P;
  iRSP['r'] = 0; iRSP['s'] = 1; iRSP['p'] = 2;
  std::fill_n(dp[0], MAXN*3, -1);
  int ans = 0;
  for(int i = 0; i < K; ++i) {
    int m = std::max(calc(i, 0), calc(i, 1));
    ans += std::max(m, calc(i, 2));
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 9344
N = int(input())
L = input().split()
L = [int(x) for x in L]

count = 0
for i in range(1, N-1):
	if((L[i]<L[i-1] and L[i]>L[i+1]) or (L[i]>L[i-1] and L[i]<L[i+1])):
		count+=1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A1, A2, A3; cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    ll h;
    cin >> h;
    ll ans = 0;
    ll cnt = 1;
    while(h){
        ans += cnt;
        h >>= 1;
        cnt <<= 1;
    }
    cout << ans << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int n, k; cin >> n >> k;
	vector<bool> done(n);
	rep(i,k){
		int d; cin >> d;
		rep(i,d){
			int a; cin >> a;
			a--;
			done[a] = true;
		}
	}
	int ans = 0;
	rep(i,n){
		if(!done[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 //#define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


void solve()
{
  int n,x,t;
  cin >> n >> x >> t;

  int an = ceil((double)n/(double)x)*t ;
  cout<<an;  

}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n; cin >> n;
	vector<long double> a(n);
	//vector<long double> gyaku(n);
	long double total = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		total += 1.0 / a[i];
	}
	cout << (long double)1.0 / total;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cin >> m;
    vector<int> t(m);
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (t[cur] == d[i]) cur++;
        if (cur == m) break;
    }
    cout << (cur == m ? "YES" : "NO") << endl;
    return 0;
}

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


int main(){
    string s; cin >> s;
    int res = 0;
    int cnt=1;
    rep(i,s.size()-1){
        if(cnt==0) cnt++;
        if(s[i]=='R'){
            if(s[i+1]=='R'){
                cnt++;
            }
        }else cnt=0;
        res = max(res,cnt);
    }
    if(res==0&&s[2]=='R') res = 1;
    cout << res << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		double r[] = new double[40];
		double l[] = new double[40];
		int a[] = new int[2];
		int b[] = new int[2];
		int c[] = new int[2];
		int d[] = new int[2];
		
		int i = 0;
		while(scan.hasNext()){
			r[i] = scan.nextDouble();
			l[i] = scan.nextDouble();
			if(r[i] >= 1.1){
				++a[0];
			}else if(r[i] >= 0.6){
				++b[0];
			}else if(r[i] >= 0.2){
				++c[0];
			}else{
				++d[0];
			}
			if(l[i] >= 1.1){
				++a[1];
			}else if(l[i] >= 0.6){
				++b[1];
			}else if(l[i] >= 0.2){
				++c[1];
			}else{
				++d[1];
			}
			i++;
		}
		System.out.println(a[0] + " " + a[1]);
		System.out.println(b[0] + " " + b[1]);
		System.out.println(c[0] + " " + c[1]);
		System.out.println(d[0] + " " + d[1]);
	}
}

Measured memory_bytes: 28128
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, B, C, D, K = mi()

print(C*60+D-A*60-B-K)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;
string s;

vector<int> Z_algorithm(string x) {
    int xc = 0, xlen = x.length();
    vector<int> Z(xlen, 0);
    for(int i = 1; i < xlen; ++i) {
        int l = i-xc;
        if(i+Z[l] < xc+Z[xc]) Z[i] = Z[l];
        else {
            int j = max(0, xc+Z[xc]-i);
            while(i+j < n && x[j] == x[i+j]) ++j;
            Z[i] = j;
            xc = i;
        }
    }
    Z[0] = xlen;
    return Z;
}


int main() {
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        string ch = s.substr(i, n-i);
        vector<int> ansvec = Z_algorithm(ch);
        /*cout << "ansvec ";
        for(int j = 0; j < (int)ansvec.size(); ++j) {
            cout << ansvec.at(j) << " ";
        }
        cout << endl;*/
        for(int j = 1; j < (int)ansvec.size(); ++j) {
            chmax(ans, min(ansvec.at(j), j));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define X 0
#define Y 1
#define C 2
#define SIKI1 0
#define SIKI2 1
#define LEFT  0
#define RIGHT 1

int main(){
	double A[3][3][3];
	double n[6];

	while( scanf("%lf %lf %lf %lf %lf %lf",&n[0],&n[1],&n[2],&n[3],&n[4],&n[5]) != EOF){
		//ÏÌú»
		for(int i=0 ; i<=RIGHT ; i++){
			for(int j=0 ; j<=SIKI2 ; j++){
				for(int k=0 ; k<=C ; k++){
					A[i][j][k] = 0;
				}
			}
		}

		//lÌãü
		A[LEFT][SIKI1][X]  = n[0];
		A[LEFT][SIKI1][Y]  = n[1];
		A[RIGHT][SIKI1][C] = n[2];
		A[LEFT][SIKI2][X]  = n[3];
		A[LEFT][SIKI2][Y]  = n[4];
		A[RIGHT][SIKI2][C] = n[5];

		//®PÌXð¶Ó©çEÓÖÚ·é
		A[ RIGHT ][ SIKI1 ][ X ]  += (-1.0)*(A[ LEFT ][ SIKI1 ][ X ]);
		A[ LEFT  ][ SIKI1 ][ X ]  = 0;

		//®PÌ¼ÓðYÌWÅé		
		A[ RIGHT ][ SIKI1 ][ X ]  /= A[ LEFT ][ SIKI1 ][ Y ];
		A[ RIGHT ][ SIKI1 ][ C ]  /= A[ LEFT ][ SIKI1 ][ Y ];
		A[ LEFT  ][ SIKI1 ][ Y ]  = 1;

		//®QÌYÉãüµÄ®Qð(ax = b)Ì`É·é
		int a = A[ LEFT ][ SIKI2 ][ Y ];
		A[ LEFT  ][ SIKI2 ][ X ]  += a * A[ RIGHT ][ SIKI1 ][ X ];
		A[ LEFT  ][ SIKI2 ][ Y ]   = 0;
		A[ RIGHT ][ SIKI2 ][ C ]  += a * A[ RIGHT ][ SIKI1 ][ C ] * (-1.0);
		//XYÌðªÜé
		double answerX = A[ RIGHT ][ SIKI2 ][ C ] / A[ LEFT ][ SIKI2 ][ X ];
		double answerY = (n[2] + n[0]*answerX*(-1.0))/n[1];
		
		//¬æSÊðlÌÜü·é
		if( (((int)(answerX*10000))%10) >= 5){
			answerX += 0.001;
		}
		if( (((int)(answerY*10000))%10) >= 5){
			answerY += 0.001;
		}
		if(answerX==-0.0){
			answerX = 0;
		}
		
		//ðÌoÍ
		printf("%.3f %.3f\n", answerX , answerY);
	}

	return 0;
}

Measured memory_bytes: 0
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = sum(a[0:k])
    l = [s]
    for i in range(k,n):
        s = s + a[i] - a[i-k]
        l.append(s)
    print(max(l))


Measured memory_bytes: 11704
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL x, a;
int main() {
	cin >> x >> a;
	if (x < a) printf("0");
	else printf("10");
	return 0;
}

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

using namespace std;

void swapD(double *a,double *b){
	double tmp = *a;
	*a = *b;
	*b = tmp;
}

void swapString(string *a,string *b){
	string tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int n;
	string str[60];
	double data[60];
	for(int i=0;i<60;i++){
		data[i]=10000000;
	}

	while(cin>>n){
		if(n==0)break;

	for(int i=0;i<n;i++){
		data[i]=0;
		int p,a,b,c,d,e,f,s,m;

		cin>>str[i]>>p>>a>>b>>c>>d>>e>>f>>s>>m;

		int cnt=0;

		cnt = a+b+c+d+e;
		data[i]=s*f;
		m--;
		for(int j=0;j<m;j++){
			cnt+=(d+e);
			data[i]+=f*s;		}

		data[i]-=p;

		data[i]/=(double)cnt;
	}

	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(data[j]>=data[j-1] ){
				swapD(&data[j],&data[j-1]);
				swapString(&str[j],&str[j-1]);
			}
		}
	}

	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(data[j]>=data[j-1] && str[j]<=str[j-1]){
				swapD(&data[j],&data[j-1]);
				swapString(&str[j],&str[j-1]);
			}
		}
	}


	for(int i=0;i<n;i++){
		//cout<<str[i]<<" "<<data[i]<<endl;
		cout<<str[i]<<endl;
	}

	cout<<"#"<<endl;
	}


	return 0;
}

Measured memory_bytes: 1212
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=200000+1;
    bool ok=0;
    int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    for(int i=0;i<n;i++){
        if(s[i]=='#'){
            ok=1;
            cnt1++;
        }
        else cnt2++;
        if(ok&&s[i]=='.') cnt3++;
    }
    chmin(ans,cnt1);
    chmin(ans,cnt3);
    ok=0;
    int cnt=0;
    for(int i=0;i<=n;i++){
        if(s[i]=='#'){
            ok=1;
            chmin(ans,cnt3-cnt4+cnt);
            //chmin(ans,cnt3-cnt4+);
            cnt++;
        }else{
            if(ok) cnt4++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int x, n, t;
  int p[102] = {0};
  scanf("%d %d", &x, &n);
  rep(i, 0, n) {
    scanf("%d", &t);
    p[t] = 1;
  }

  int min = INF, ans = INF;
  rep(i, 0, 102) {
    if (p[i]) continue;
    if (abs(i - x) > min) continue;
    if (abs(i - x) < min) ans = i;
    else ans = min(i, ans);
    min = abs(i - x);
  }
  printf("%d\n", ans);
  return 0;
}


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

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

total = 0
p = -1

for i in a:
    total += b[i-1]
    
    if p + 1 == i:
        total += c[i-2]
        
    p = i
    
print(total)

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

int K;
string S;

int main() {
	cin>>S>>K;
	int n,len=0;
	for(int i=0; i<S.length(); i++) {
		if(S[i]!='1') {
			n=S[i]-'0';
			break;
		} else
			len++;
	}
	if(len>=K)
		cout<<'1'<<endl;
	else
		cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
int main(){
    string s;
    cin >> s;

    if(s == "AAA") cout << "No" << endl;
    else if(s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int n;
int pipes[65001];
int joints[65001];

int main() {
    while(std::cin >> n, n) {
        long long sum = 0, num = 1;

        for(int i = 0; i < n; ++i) {
            std::cin >> pipes[i];

            sum += pipes[i];
        }
        for(int i = 0; i < n - 1; ++i) {
            std::cin >> joints[i];

            sum += joints[i];
        }

        std::sort(joints, joints + n - 1);
        
        for(int i = 0; i < n - 1; ++i) {
            long long cp = sum - joints[i];
            
            if(cp * (num + 1) > sum * num) {
                sum = cp;
                ++num;
            }
        }

        std::cout << sum * num << std::endl;
    }
}

Measured memory_bytes: 1680
n=int(input())
A=list(map(int,input().split()))
ans4 = 0
ans2 = 0
for a in A:
  if a % 4 == 0:
    ans4 += 1
  elif a % 2 == 0:
    ans2 += 1
ans2 = ans2-(ans2%2)
if (n-ans2)//2 <= ans4:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 85008
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  int r;
  cin >> r;
  cout << r * r << "\n";
}

Measured memory_bytes: 256