akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int H, W;
	while (cin >> H, cin >> W, !(H == 0 && W == 0)){
		struct Locate{
			int x;
			int y;
		};
		vector<vector<char>> map;
		vector<vector<bool>> loop_flag;
		Locate pos;
		pos.x = 0;
		pos.y = 0;
		map.resize(H);
		loop_flag.resize(H);
		for (int i = 0; i < H; i++){
			map[i].resize(W);
			loop_flag[i].resize(W);
			for (int j = 0; j < W; j++){
				cin >> map[i][j];
				loop_flag[i][j] = false;
			}
		}
		bool eflag = false;
		while (!eflag){
			if (loop_flag[pos.y][pos.x] == false){
				loop_flag[pos.y][pos.x] = true;
			}
			else{
				cout << "LOOP\n";
				eflag = true;
				continue;
			}
			if (map[pos.y][pos.x] == '>'){

				pos.x += 1;
			}
			else if (map[pos.y][pos.x] == 'v'){
				pos.y += 1;
			}
			else if (map[pos.y][pos.x] == '^'){
				pos.y -= 1;
			}
			else if (map[pos.y][pos.x] == '<'){
				pos.x -= 1;
			}
			else if (map[pos.y][pos.x] == '.'){
				eflag = true;
				cout << pos.x << " " << pos.y << "\n";
			}
		}
	}
}

Measured memory_bytes: 3012
#include <iostream>
using namespace std;
class restaulant {
    public:
        string city;
        int point;
        int id;
};
int main() {
    int n;
    cin >> n;
    restaulant r[n];
    for (int i=0; i<n; i++) {
        string s;
        int p;
        cin >> s >> p;
        r[i].city = s;
        r[i].point = p;
        r[i].id = i+1;
    }
    for (int i=1; i<n; i++) {
        restaulant tmpr =r[i];
        int j = i-1;
        while (j>=0 && (r[j].city>tmpr.city || ((r[j].city==tmpr.city) && (r[j].point<tmpr.point)))) {
            r[j+1] = r[j];
            j--;
        }
        r[j+1] = tmpr;
    }
    for (int i=0; i<n; i++) {
        cout << r[i].id << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int freq[1000005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int v[n];
    for(int i =0; i<n; i++)
        cin>>v[i], freq[v[i]]++;
    sort(v, v+n);
    int dp[v[n-1]+1] = {0};
    for(int i = 0; i<n; i++){
        if(!dp[v[i]]){
            int j = v[i]+v[i];
        while(j<=v[n-1]){
            dp[j] = 1;
            j+=v[i];
            }
        }
    }
    int cnt=0;
     for(int i = 0; i<n; i++)
         if(!dp[v[i]]&&freq[v[i]]<2) cnt++;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 12140
/*
  AtCoder Beginner Contest 089
  B - Hina Arare
*/

#include<iostream>
using namespace std;

int N;
char S;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%c ", &S);
    if (S == 'Y') {
      printf("Four\n");
      return 0;
    }
  }

  printf("Three\n");
  return 0;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3) << '\n';
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    for (int b = -118; b <= 119; b++) {
        for (int a = -118; a <= 119; a++) {
            int one = pow(abs(a), 5);
            int two = pow(abs(b), 5);

            if (a < 0)one *= -1;
            if (b < 0)two *= -1;

            int ans = one - two;
            if (ans == x) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  if(x <= a*a*b/2) {
    double aa = 2*x/(a*b);
    double l = sqrt(b*b + aa*aa);
    ans = asin(b/l) * 360 / (2*M_PI);
  }
  else {
    double bb = 2*(a*a*b-x) / (a*a);
    double l = sqrt(a*a+bb*bb);
    ans = acos(a/l) * 360 / (2*M_PI);
  }
  printf("%0.12f\n", ans);
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for (int i = 1; i<= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for (int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while (next_permutation(v.begin(), v.end()));

    int factorial = 1;
    for (int i = 2; i <=N; i++) factorial *= i;
    cout << fixed << setprecision(10) << sum / factorial << endl;
    return;
}

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

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
      int m = in.nextInt();
       int sum = 0;
      for(int i =0; i< m; i++)
         sum += in.nextInt();
      int re = n- sum;
      if(re<0){
        System.out.println(-1);
      }else {
       System.out.println(re);
      }
    }
}

Measured memory_bytes: 46180
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s;
    int a,b,x;
    cin>>x>>a>>b;
    x-=a;
    x-=(x/b)*b;
    cout<<x<<'\n';
    
    return(0);
}

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

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}

int n;
int a[4];

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s[0]=='A') a[0]++;
		if(s[0]=='W') a[1]++;
		if(s[0]=='T') a[2]++;
		if(s[0]=='R') a[3]++;
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3604
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: i64,
        y: i64,
        z: i64,
    }
    println!("{}", (x-z) / (y+z));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p = 1e9 + 7;
int qpow(int a, int n) {
  int res = 1;
  for (; n; n >>= 1, a = (ll)a * a % p) {
    if (n & 1) {
      res = (ll)res * a % p;
    }
  }
  return res;
}
struct dsu_t {
  vector<int> fa;
  dsu_t(int n) {
    fa.resize(n);
    for (int i = 0; i < n; i++) {
      fa[i] = i;
    }
  }
  int get_fa(int u) {
    if (u != fa[u]) {
      fa[u] = get_fa(fa[u]);
    }
    return fa[u];
  }
  void merge(int u, int v) {
    fa[get_fa(u)] = get_fa(v);
  }
  bool same(int u, int v) {
    return get_fa(u) == get_fa(v);
  }
};
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, m;
  cin >> n >> m;
  vector<int> eu(m), ev(m);
  for (int i = 0; i < m; i++) {
    cin >> eu[i] >> ev[i];
    eu[i]--;
    ev[i]--;
  }
  int tree = n - 1;
  vector<int> edge(1 << tree);
  for (int mask = 0; mask < (1 << tree); mask++) {
    dsu_t dsu(n);
    for (int i = 0; i < tree; i++) {
      if (mask & (1 << i)) {
        dsu.merge(eu[i], ev[i]);
      }
    }
    for (int i = tree; i < m; i++) {
      if (dsu.same(eu[i], ev[i])) {
        edge[mask]++;
      }
    }
  }
  vector<int> fact(m + 1);
  fact[0] = 1;
  for (int i = 1; i <= m; i++) {
    fact[i] = (ll)fact[i - 1] * i % p;
  }
  vector<int> ifac(m + 1);
  ifac[m] = qpow(fact[m], p - 2);
  for (int i = m; i > 0; i--) {
    ifac[i - 1] = (ll)ifac[i] * i % p;
  }
  vector<int> ways(1 << tree), sum(1 << tree), count(1 << tree);
  ways[0] = 1;
  for (int mask = 0; mask < (1 << tree); mask++) {
    for (int i = 0; i < tree; i++) {
      if (!(mask & (1 << i))) {
        int next = mask | (1 << i);
        int white = edge[((1 << tree) - 1) ^ mask] - edge[((1 << tree) - 1) ^ next];
        count[next] = count[mask] + white + 1;
        ways[next] = (ways[next] + (ll)ways[mask] * fact[count[next] - 1] % p * ifac[count[mask]]) % p;
        sum[next] = (sum[next] + (ll)ways[mask] * fact[count[next] - 1] % p * ifac[count[mask]] % p * __builtin_popcount(next) + (ll)sum[mask] * fact[count[next]] % p * ifac[count[mask] + 1]) % p;
      }
    }
  }
  cout << sum[(1 << tree) - 1] << endl;
  return 0;
}


Measured memory_bytes: 8576
n = int(input())
a = list(map(int,input().split(' ')))
ans = 0
for i in range(n):
    if i ==0 and a[0]==1:
        a[0],a[1] = a[1],a[0]
        ans += 1
        continue
    if i<n-1 and i+1 == a[i] and i+2 ==a[i+1]:
        a[i],a[i+1]  = a[i+1],a[i]
        ans += 1
    if i+1 ==a[i] and i+1 != a[i-1]:
        a[i-1],a[i] = a[i],a[i-1]
        ans += 1
print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

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

int main() {
    string S; cin >> S;
    map<string, string> mp;
    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";

    cout << mp[S] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N){
    cin >> P[i];
    if(P[i]<0){
      num++;
      P[i]*=-1;
    }
    sum+=P[i];
  }
  Sort(P);
  if(num&1)Out(sum-2*P[0]);
  else Out(sum);
}

Measured memory_bytes: 1024
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int n, a=0, mi=0;
    string s;
    cin>>n>>s;
    for(char c:s) { 
        if     (c=='(') {
            a++;
        }
        else if(c==')') {
            a--;
            mi=min(a,mi);
        }
    }//cout<<a<<" "<<mi<<endl;
    if(mi>=0) {
        rep(i,-a) cout<<"(";
        cout<<s;
        rep(i,a) cout<<")";
    }
    else {
        rep(i,-mi) cout<<"(";
        cout<<s;
        rep(i,-mi+a) cout<<")";
    }
    cout<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

    int ans = 0;

    FOR(i,1,n-2)
    {
        int maxitm = max({p[i-1],p[i],p[i+1]});
        int minitm = min({p[i-1],p[i],p[i+1]});
        if (p[i] != maxitm && p[i] != minitm)
        {
            ans++;        
        }
    }
    cout << ans << endl;
    return 0;   
}


Measured memory_bytes: 256
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize, M: usize, K: usize,
        A: [usize; N],
        B: [usize; M],
    }
    let mut ans = 0;
    let mut a_i = 0;
    let mut b_i = 0;
    let mut count = 0;
    while a_i < N && count + A[a_i] <= K {
        count += A[a_i];
        a_i += 1;
    }
    while b_i < M && count + B[b_i] <= K {
        count += B[b_i];
        b_i += 1;
    }
    if ans < a_i + b_i {
        ans = a_i + b_i;
    }
    while a_i != 0 {
        a_i -= 1;
        count -= A[a_i];
        while b_i < M && count + B[b_i] <= K {
            count += B[b_i];
            b_i += 1;
        }
        if ans < a_i + b_i {
            ans = a_i + b_i;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 9336
#include"bits/stdc++.h"

using namespace std;

int main() {
	int n;
	cin >> n;
	for (long long int i = 1; i <= 3500; i++) {
		for (long long int j = 1; j <= 3500; j++) {
			pair<long long int, long long int> p = make_pair(i + j, i*j);
			long long int b = n*i*j;
			long long int u = i*j * 4LL - (i + j)*n;
			if (u < 0)continue;
			if (u == 0) {
				continue;
			}
			if (b%u == 0) {
				printf("%lld %lld %lld\n", i, j, b / u);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int maxv = -2000000000;
    int minv;
    cin >> minv;
    for(int i = 1; i < n; i++) {
        int x;
        cin >> x;
        if(maxv < x - minv) maxv = x - minv;
        if(x < minv) minv = x;
    }
    cout << maxv << endl;
    return 0;
}


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


int main(){
	int n,k;
	cin>>n>>k;
	int x[n];
	for (int i = 0; i < n; ++i){
		cin>>x[i];
	}

	long long ans=1e+18;
	for (int i = 0; i < n-k+1; ++i){
		long long mm=min(abs(x[i])+abs(x[i+k-1]-x[i]),abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
		ans = min(ans,mm);
	}

	cout<<ans<<endl;

}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 100002

int main(){
	Fio;
	ll n,k;
	cin>>n>>k;
	vl A(n);
	f(i,n)cin>>A[i];
	sort(A.begin(),A.end());
	ll dp[k+1] = {0};
	fo(i,0,k){
		fo(j,0,n-1){
			if(i<A[j])break;
			if(dp[i-A[j]]==0){
				dp[i] = 1;
				break;
			}
		}
	}
	if(dp[k]==1)cout<<"First";
	else cout<<"Second";
	return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;
ll n, h, a[1 << 17], b[1 << 17];
int main() {
	cin >> n >> h;
	for (int i = 0;i < n;i++)cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	ll cnt = 0;
	for (int i = n - 1;i >= 0;i--) {
		if (b[i] < a[n - 1])break;
		cnt++;
		h -= b[i];//a[n-1]より大きいものを先に使う
		if (h <= 0)break;
	}
	cout << (cnt + (h > 0 ? (h + a[n - 1] - 1) / a[n - 1] : 0)) << endl;//真のときは足りてないとき
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,m;
	char a[55][55],b[55][55];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[j][i];
		}
	}
	
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			cin>>b[j][i];
		}
	}

	int check=0;

	for(int i=0;i<n-m+1;i++){
		for(int j=0;j<n-m+1;j++){
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(b[l][k]==a[j+l][i+k]){
						check++;
					}
					else{
						check=0;
						break;
					}
				}
				if(check==0) break;
				if(k==m-1){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner input  = new Scanner(System.in);
		int n = input.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = input.nextInt();
		}
		System.out.println(func(n,arr));
	}
	static int func(int n,int arr[]) {
		int dp[] = new int[n];
		dp[0] = 0;
		for(int i=1;i<n;i++) {
			int ans = 0;
			if(i-1>=0) {
				ans = Math.abs(arr[i]-arr[i-1])+dp[i-1];
			}
			if(i-2>=0) {
				ans = Math.min(ans, Math.abs(arr[i]-arr[i-2])+dp[i-2]);
			}
			dp[i] = ans;
		}
		return dp[n-1];
	}

}


Measured memory_bytes: 51228
#include <stdio.h>

int main(void) {

  double xa,ya,xb,yb,xc,yc,xd,yd;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF) {
  
    if(xb-xa==0.0) {
      if(yd-yc==0.0 && xd-xc!=0.0) printf("YES\n");
      else printf("NO\n");
    }
    else if(xd-xc==0.0) {
      if(yb-ya==0.0 && xb-xa!=0.0) printf("YES\n");
      else printf("NO\n");
    }

    else if((yb-ya)*(yd-yc)/((xb-xa)*(xd-xc))==-1.0) printf("YES\n");

    else printf("NO\n");
  }

  return 0;

}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i,3) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    ll res=0;
    rep3(i,1,n+1){
        ll x;
        cin>>x;
        if(i%2==1&&x%2==1){
            res++;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;
  string s;

  cin >> N;

  int tmp = N/1.08;
  tmp -= 10;
  
  // cout << "tmp start = " << tmp << endl;

  int cnt = 0;
  int calc = 0;
  while(cnt < 20){
    calc = tmp*1.08;
    if(calc == N){
      cout << tmp << endl;
      ans++;
      break;
    }

    tmp++;
    cnt++;
  }

  if(ans == 0){
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

typedef struct{
	vector<int> leafs;
	int add;
	int sum;
	bool visited;
}Node;

vector<Node> nodes;

int dfs(int id, int base){
	nodes[id].visited = true;
	nodes[id].sum = base+nodes[id].add;
	int sz = nodes[id].leafs.size();
	REP(i,sz){
		if(!nodes[nodes[id].leafs[i]].visited){
			dfs(nodes[id].leafs[i],nodes[id].sum);
		}
	}

	return 0;
}

int main(void){
	int n,q ;
	cin >> n >> q;
	REP(i,n){
		Node nd;
		nd.add= nd.sum = 0;
		nd.visited = false;
		nodes.push_back(nd);
	}
	REP(i,n-1){
		int a,b;
		cin >> a >> b;
		nodes[a-1].leafs.push_back(b-1);
		nodes[b-1].leafs.push_back(a-1);
	}
	REP(i,q){
		int p,x;
		cin >> p >> x;
		nodes[p-1].add += x;
	}
	dfs(0,0);
	REP(i,n){
		printf("%d ",nodes[i].sum);
	}
}


Measured memory_bytes: 24296
import math
A, B, H, M = map(int, input().split())
Mkaku = 6 * M
Hkaku = (H * 60 + M) / 2
r1 = Hkaku * math.pi / 180
r2 = Mkaku * math.pi / 180
v1x = A * math.cos(r1)
v1y = A * math.sin(r1)
v2x = B * math.cos(r2)
v2y = B * math.sin(r2)
ans = ((v1x - v2x) ** 2 + (v1y - v2y) ** 2) ** (1 / 2)
print(ans)

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

int main(){
  string s;
  cin >> s;
  int ans = 700;
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] == 'o'){
      ans += 100;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


A, B, K = LI()

player = 0
for i in range(K):
    if player == 0:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2
    player ^= 1

print(A, B)


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

typedef long long ll;

const int MAXN = 1e5 + 5;

int N, M, V, P;
int a[MAXN];

void load() {
	scanf("%d%d%d%d", &N, &M, &V, &P);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
}

bool check(int x) {
	vector <int> small;
	for (int i = 0; i < N && small.size() < N - P; i++)
		if (i != x)
			small.push_back(a[i]);
	
	ll mx = 0, sum = 0;
	for (int i = N - P - 1; i >= 0; i--) {
		sum += small[i];
		mx = max(mx, (sum + (ll)M * max(V - P - i, 0) - 1) / (N - P - i) + 1);
	}
	
	return mx <= a[x] + M;
}

int solve() {
	sort(a, a + N);
	
	int lo = 0, hi = N;
	while (lo < hi) {
		int mid = (lo + hi) / 2;
		if (check(mid))
			hi = mid;
		else
			lo = mid + 1;
	}
	
	return N - lo;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 1588
#include <cstdio>
#include <algorithm>
#define maxn 100010
using namespace std;
char in[3];
int n,v[3],p[maxn],q[maxn],ans[maxn];
int main()
{
    int i;
    scanf("%d",&n);
    //ABC
    for(i=0; i<3; i++)
        scanf("%d",&v[i]);
    for(i=1; i<=n; i++)
    {
        scanf("%s",in);
        p[i]=in[0]-'A';
        q[i]=in[1]-'A';
    }
    for(i=1; i<=n; i++)
    {
        if(v[p[i]]>v[q[i]])//小的在前，大的在后
            swap(p[i],q[i]);
        else if(v[p[i]]==v[q[i]])
        {
            if(i+1<=n&&(p[i+1]==q[i]||q[i+1]==q[i]))
                swap(p[i],q[i]);
        }
        if(!v[q[i]])//大的-1都不行了
        {
            return 0*printf("No\n");
        }
        v[p[i]]++;
        v[q[i]]--;
        ans[i]=p[i];//输出加1的那一个字符
    }
    printf("Yes\n");
    for(i=1; i<=n; i++)
    {
        printf("%c\n",ans[i]+'A');
    }
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}
int main()
{
   
  IOS
  ll n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  for(ll i=0,j=0,k=0;i<n;i++)
  {
    cout<<a[i]<<b[i];
  }
  


  

}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int n,p[200000],m[200000],ans=1;
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i],m[i]=p[i];
  for(int i=1;i<n;i++)m[i]=min(m[i-1],m[i]),ans+=(p[i]<=m[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		//System.out.println(M);
		
		int A[] = new int [N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		double sum = 0.0;
		for(int j=0;j<N;j++) {
			sum += A[j];
		}
		//System.out.println(sum);
		boolean ok[] = new boolean[N];
		Arrays.fill(ok, true);
		double hantei = sum/(4*M);
		for(int k=0;k<N;k++) {
			if(A[k]<hantei) {
				ok[k] = false;
			}
		}
		int count = 0;
		for(int l=0;l<N;l++) {
			if(ok[l]) {
				count ++;
			}
		}
		//System.out.println(count);
		if(count>=M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a.at(i);
    }

    int Al =0;
    int Bo = 0;

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    for(int i=0; i<N; i++){
        if(i==0 || i%2==0){
            Al += a.at(i);
        }
        else{
            Bo += a.at(i);
        }
    }

    cout << Al - Bo << endl;
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll MAX = N*(N-1)/2;
    sort(all(A));
    vector<ll> B,C;
    rep(i,N) {
        if (A[i] < 0) B.emplace_back(A[i]);
        else if (A[i] > 0) C.emplace_back(A[i]);
    }
    ll M = B.size();
    ll L = C.size();
    ll S = N-M-L;
    ll cntmi = M*L;
    ll cnt0 = S*(M+L) + S*(S-1)/2;
    ll cntpr = M*(M-1)/2 + L*(L-1)/2;
    if (K > cntmi && K <= cntmi+cnt0) {
        cout << 0 << ln;
        return 0;
    }
    if (K <= cntmi) {
        ll left = 0;
        ll right = 1e18;
        while (right - left > 1) {
            ll mid = (left+right)/2;
            ll cnt = 0;
            for (auto i : B) {
                ll p = mid/abs(i);
                cnt += C.end() - upper_bound(all(C),p); 
            }
            if (cnt < K) right = mid;
            else left = mid;
        }
        cout << -right << ln;
    } else {
        K -= cntmi + cnt0;
        rep(i,B.size()) B[i] = -B[i];
        reverse(all(B));
        ll left = 0;
        ll right = 1e18;
        while (right - left > 1) {
            ll mid = (left+right)/2;
            ll cnt = 0;
            rep(i,B.size()) {
                ll p = mid/B[i];
                ll k = upper_bound(all(B),p) - B.begin();
                if(k > i) cnt += k-1-i;
            }
            rep(i,C.size()) {
                ll p = mid/C[i];
                ll k = upper_bound(all(C),p) - C.begin();
                if(k > i) cnt += k-1-i;
            }
            if (cnt >= K) right = mid;
            else left = mid;
        } 
        cout << right << ln;
    }

}

Measured memory_bytes: 4084
#168 - F
import sys
import numpy as np
#from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    #X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    #Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    X = np.unique(np.concatenate([D, [-INF, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


#@njit
def cal_area(A, B, C, D, E, F, X, Y):
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1

    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    A = A.tolist()
    B = B.tolist()
    C = C.tolist()
    D = D.tolist()
    E = E.tolist()
    F = F.tolist()
    X = X.tolist()
    Y = Y.tolist()
    DX = DX.tolist()
    DY = DY.tolist()

    LenX = len(X)
    LenY = len(Y)

    visit = [[False] * LenY for _ in range(LenX)]
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    #for x1, x2, y in zip(A, B, C):
    #    for x in range(x1, x2):
    #        LineY[x][y] = True
    for i in range(len(A)):
        y = C[i]
        for x in range(A[i], B[i]):
            LineY[x][y] = True

    #for x, y1, y2 in zip(D, E, F):
    #    for y in range(y1, y2):
    #        LineX[x][y] = True
    for i in range(len(D)):
        x = D[i]
        for y in range(E[i], F[i]):
            LineX[x][y] = True

    LenX -= 1
    LenY -= 1
    
    while queue:
        x, y = queue.pop()
        
        if x == 0 or x == LenX or y == 0 or y == LenY:
            area = 0
            break
        
        area += DX[x] * DY[y]
        
        x1 = x - 1
        if not LineX[x][y] and not visit[x1][y]:
            visit[x1][y] = True
            queue.append((x1, y))
        y1 = y - 1
        if not LineY[x][y] and not visit[x][y1]:
            visit[x][y1] = True
            queue.append((x, y1))
        x1 = x + 1
        if not LineX[x1][y] and not visit[x1][y]:
            visit[x1][y] = True
            queue.append((x1, y))
        y1 = y + 1
        if not LineY[x][y1] and not visit[x][y1]:
            visit[x][y1] = True
            queue.append((x, y1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


Measured memory_bytes: 66116
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 200000;
int P[MAXN + 5];
int st[20][MAXN + 5], lg[MAXN + 5];
int le[MAXN + 5], ri[MAXN + 5];
int lf[MAXN + 5], rf[MAXN + 5];
int rmq(int type, int l, int r) {
	if( l < 1 ) l = 1;
	if( l > r ) return 0;
	int q = lg[r-l+1], p = (1<<q);
	if( type == 0 )
		return min(st[q][l], st[q][r-p+1]);
	else
		return max(st[q][l], st[q][r-p+1]);
}
void init() {
	for(int i=2;i<=MAXN;i++) lg[i] = lg[i>>1] + 1;
}
int main() {
	init(); int N, K;
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++)
		scanf("%d", &P[i]);
	P[0] = N, P[N + 1] = 0;
	for(int i=1;i<=N;i++)
		le[i] = (P[i-1] < P[i]) ? le[i-1] : i;
	for(int i=N;i>=1;i--)
		ri[i] = (P[i] < P[i+1]) ? ri[i+1] : i;
	for(int i=1;i<=N;i++) st[0][i] = P[i];
	for(int j=1;j<20;j++) {
		int t = (1<<(j-1));
		for(int i=1;i+t<=N;i++)
			st[j][i] = min(st[j-1][i], st[j-1][i+t]);
	}
	for(int i=1;i+K-1<=N;i++) {
		if( ri[i] >= i+K-1 )
			rf[i] = N;
		else {
			int l = i - 1, r = ri[i], mn = rmq(0, ri[i] + 1, i + K - 1);
			while( l < r ) {
				int mid = (l + r + 1) >> 1;
				if( P[mid] < mn ) l = mid;
				else r = mid - 1;
			}
			rf[i] = l + 1;
		}
	}
	for(int i=1;i<=N;i++) st[0][i] = P[i];
	for(int j=1;j<20;j++) {
		int t = (1<<(j-1));
		for(int i=1;i+t<=N;i++)
			st[j][i] = max(st[j-1][i], st[j-1][i+t]);
	}
	for(int i=N;i-K+1>=1;i--) {
		if( le[i] <= i-K+1 )
			lf[i] = K;
		else {
			int l = le[i], r = i + 1, mx = rmq(1, i - K + 1, le[i] - 1);
			while( l < r ) {
				int mid = (l + r) >> 1;
				if( mx < P[mid] ) r = mid;
				else l = mid + 1;
			}
			lf[i] = r - 1;
		}
	}
	for(int i=1;i<=N;i++) st[0][i] = rf[i];
	for(int j=1;j<20;j++) {
		int t = (1<<(j-1));
		for(int i=1;i+t<=N;i++)
			st[j][i] = max(st[j-1][i], st[j-1][i+t]);
	}
	int ans = 0;
	for(int i=1;i+K-1<=N;i++) {
		int p = lf[i + K - 1];
		if( rmq(1, p - K + 1, i - 1) < i )
			ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 19328
#include<algorithm>
#include<cstdio>
bool cmp(int x,int y)
{
    return x>y;
}
int num[105],n,ans,ans2,i=1;
int main()
{
    scanf("%d",&n);
    for(;i<=n;i++) scanf("%d",&num[i]);
    std::sort(num+1,num+n+1,cmp);
    for(i=1;i<=n;i++)
	{
        if(i%2)
        {
			ans+=num[i];
		}
        if(!(i%2))
        {
			ans-=num[i];
		}
    }
	printf("%d",ans);
}

Measured memory_bytes: 128
k, n = map(int, input().split())
A = list(map(int, input().split()))


start_diff = A[0] + k - A[-1]
diff = [start_diff]
answer = 0
start = A[0]

for i in range(1, n):
    diff.append(A[i] - start)
    start = A[i]

# print(diff)
# print(start_diff)

answer = sum(diff) - max(diff)
print(answer)


Measured memory_bytes: 25840
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N, A, B;

    cin >> N >> A >> B;

    if ((B - A - 1) % 2 != 0)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Borys" << endl;
    }
}


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

int main() {
        int arr[5];
        int ans = -1;
        for(int i = 0 ; i<5 ; i++) {
                cin >> arr[i];
                if(arr[i] == 0)
                        ans = i+1;
        }
        cout << ans << "\n";
        return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll x;
  cin>>x;
  ll n=100,ans=0;
  while(n<x){
    n+=n/100;
    ans++;
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

int main()
{
  int n;
  int64_t ans = 0, tmp1, tmp2, l_max, r_max;
  cin >> n;
  vector<int64_t> A(n), tmp(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  tmp = A;
  sort(tmp.begin(), tmp.end(), greater<int64_t>());
  
  for (int i = 0; i < n; i++){
    if (A[i] != tmp[0]) cout << tmp[0] << endl;
    else cout << tmp[1] << endl;
  }
}


Measured memory_bytes: 4736