akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
#include <tuple>

#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (ll (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (ll (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (ll (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (ll (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = Max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

int main()
{
    int n;
    ll T;
    cin >> n >> T;
    vector<ll> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    v.pb(1e18);
    SORT(v);
    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += Min(v[i+1]-v[i], T);
    }
    cout << ans << newline;
    
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <utility>
#include <cassert>
#include <algorithm>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c - (max(a, max(b, c)))) << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin >> a >> b;
	
	ll n = __gcd(a,b);

	ll res = 1;
	for (ll p = 2; p*p <= n; p++) if (n%p == 0) {
		res++;
		while (n%p == 0) n /= p;
	}
	if (n > 1) res++;

	cout << res << endl;
}



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

int	main(void)
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans = min(a, k);
	if (a + b < k) ans -= k - (a + b);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3548
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  int INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;
 

  int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

void solve(){
  
int n;
cin>>n;
vector<int> have(1000000+10);
int g = 0;
for (int i = 0;i<n;i++){
  int x;
  cin>>x;
  have[x]++;
  if (i==0) 
    g = x;
  else
    g = gcd(g,x);
}
if (g!=1){
  cout<<"not coprime\n";
  return;
}
vector<bool> done(1000000+10);
bool da = true;
for (int mul = 2; mul<=1000000; mul++){
  int cnt = 0;
  int now = mul;

  if (done[now]) continue;
  while (now<=1000000){
    done[now] = true;
    cnt+= have[now];
    now+=mul;
  }
  if (cnt>1) da =false;
}
if (da)
cout<<"pairwise coprime\n";
else
cout<<"setwise coprime\n";

}

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    while(q--) solve();

}

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

int main(){
    double n,k;
    cin >> n >> k;
    double sum=0.0;
    //iの目が出たときk以上に達する確率の和
    for(int i=1;i<=n;i++){
        double s=i;
        double p=1;
        while(s<k){
            s*=2.0;
            p/=2.0;
        }
        sum+=p;
        //cout << sum << endl;
    }
    //sumをnで割る
    sum/=n;
    cout << fixed << setprecision(12);
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

string s;
int q;
int cur = 0;
string f = "", b = "";

int32_t main()
{
	IOS;
	cin >> s >> q;
	while(q--)
	{
		int t;
		cin >> t;
		if(t == 1)
			cur ^= 1;
		else
		{
			int ff;
			char ch;
			cin >> ff >> ch;
			ff--;
			if(ff ^ cur)
				b += ch;
			else
				f += ch;
		}
	}	
	if(cur)
	{
		swap(f, b);
		reverse(s.begin(), s.end());
	}
	reverse(f.begin(), f.end());
	cout << f << s << b << endl;;
	return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 1000001


int32_t main()
{   
    io
    int n;
    cin>>n;

    int a[n+1], b[n+1], c[n];

    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<n;i++)
        cin>>c[i];

    int score = b[a[1]];

    for(int i=2;i<=n;i++)
    {
        score += b[a[i]];
        if(a[i]==a[i-1]+1)
            score += c[a[i-1]];
    }

    cout<<score;


       

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int sum=0;
    while(1){
        sum+=1000;
        if(sum>=n){
            break;
        }
    }
    cout<<sum-n<<"\n";
    return 0;
}

Measured memory_bytes: 3644
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(n: u32) -> u32 {
    let mut tmp = n;
    let mut cnt: u32 = 0;
    while tmp > 0 {
        cnt += 1;
        tmp = tmp / 10;
    }
    cnt
}

fn pow(a: u32, b: u32) -> u32 {
    let mut ans: u32 = 1;
    for _ in 0..b {
        ans *= a;
    }
    ans
}

fn main() {
    let n: usize = read();
    let h: Vec<u32> = read_vec();
    let mut can: bool = true;
    let mut out: bool = false;
    for i in 0..(n - 1) {
        if h[i] > h[i + 1] + 1 {
            out = true;
            break;
        } else if h[i] == h[i + 1] + 1 {
            if can {
                can = false;
            } else {
                out = true;
                break;
            }
        } else if h[i] < h[i + 1] {
            can = true;
        }
    }
    if out {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 8444
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n, k;
int r, s, p;
string t;
int tp[100000];
int point[3];
ll ans;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;
	point[0] = r;
	point[1] = s;
	point[2] = p;
	REP(i, n) {
		switch (t[i]) {
		case 'r':
			tp[i] = 0;
			break;
		case 's':
			tp[i] = 1;
			break;
		case 'p':
			tp[i] = 2;
			break;
		}
	}

	REP(i, k) {
		int now = i;
		do  {
			ans += point[(tp[now] + 2) % 3];
			now += k;
			if (now<n&&tp[now] == tp[now-k])now += k;
		} while (now < n);
	}
	cout << ans << endl;
}

Measured memory_bytes: 848
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Storable as V

main=do
    n<-readLn::IO Int
    xs<-unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    --
    let ys=V.fromList.sort $ xs
    let m1= ys V.! ((n `div` 2)-1)
    let m2= ys V.! (n `div` 2)
    --
    sequence_ $ map (print.(f m1 m2)) xs

f m1 m2 x = if x < m2 then m2 else m1

Measured memory_bytes: 50428
#include <stdio.h>
int H;
int A[251];
int main(){
  int i,j;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2 > 0)printf("parent key = %d, ",A[i/2]);
    if(i*2 <= H)printf("left key = %d, ",A[i*2]);
    if(i*2+1 <= H)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

typedef pair<ll, int> P;

struct e
{
    int from;
    int to;
    int cost;
};

vector<pair<int, int>> g[112345];

ll d[112345];

int n;

void dijkstra(int s)
{
    for (int i = 0; i <= n + 1; i++)
        d[i] = 1e18;

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

    q.push({0, s});

    while (q.size())
    {
        P p = q.top();
        q.pop();

        if (d[p.second] <= p.first)
            continue;

        d[p.second] = p.first;

        for (pair<int, int> i : g[p.second])
        {
            ll nex = d[p.second] + i.second;

            if (d[i.first] <= i.second)
                continue;

            q.push({nex, i.first});
        }
    }
}

int main()
{
    int m, l[112345], r[112345], c[112345];

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> l[i] >> r[i] >> c[i];
        g[l[i]].push_back({r[i], c[i]});
    }

    for (int i = 2; i <= n; i++)
    {
        g[i].push_back({i - 1, 0});
    }

    dijkstra(1);

    if (d[n] == 1e18)
        cout << -1 << endl;
    else
        cout << d[n] << endl;

    return 0;
}

Measured memory_bytes: 10356
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll gcd(ll a, ll b) {
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll n, x; cin >> n >> x;
	printf("%lld", 3LL * (n - gcd(n, x)));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int x;
    cin >> x;
    if(x>=1800)cout << 1 << endl;
    else if(x>=1600)cout << 2 << endl;
    else if(x>=1400)cout << 3 << endl;
    else if(x>=1200)cout << 4 << endl;
    else if(x>=1000)cout << 5 << endl;
    else if(x>=800)cout << 6 << endl;
    else if(x>=600)cout << 7 << endl;
    else if(x>=400)cout << 8 << endl;
}

Measured memory_bytes: 3632
import 'dart:io';
import "dart:math";

void main() {
  List abcd = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int xy=abcd[0]*abcd[2];
  int xySign=xy.sign;
  List xyxy=[];
  if((abcd[0].sign==-1 && abcd[1].sign==-1)&&(abcd[2].sign==-1 && abcd[3].sign==-1)){
    print(abcd[0]*abcd[2]); //1
  }else if((abcd[0].sign==1 && abcd[1].sign==1)&&(abcd[2].sign==1 && abcd[3].sign==1)){
    print(abcd[1]*abcd[3]);//2
  } else if((abcd[0].sign==-1 && abcd[1].sign==1)&&(abcd[2].sign==-1 && abcd[3].sign==-1)){
    print(abcd[0]*abcd[2]);//3
  } else if((abcd[0].sign==-1 && abcd[1].sign==-1)&&(abcd[2].sign==-1 && abcd[3].sign==1)){
    print(abcd[0]*abcd[2]);//4
  }else if((abcd[0].sign==1 && abcd[1].sign==1)&&(abcd[2].sign==-1 && abcd[3].sign==1)){
    print(abcd[1]*abcd[3]);//5
  }
  else if((abcd[0].sign==-1 && abcd[1].sign==1)&&(abcd[2].sign==1 && abcd[3].sign==1)){
    print(abcd[1]*abcd[3]);//6
  }else if((abcd[0].sign==-1 && abcd[1].sign==-1)&&(abcd[2].sign==1 && abcd[3].sign==1)){
    print(abcd[1]*abcd[2]);//7
  }else if((abcd[0].sign==1 && abcd[1].sign==1)&&(abcd[2].sign==-1 && abcd[3].sign==-1)){
    print(abcd[0]*abcd[3]);//8
  }else{
    xyxy=[abcd[0]*abcd[2],abcd[0]*abcd[3],abcd[1]*abcd[2],abcd[1]*abcd[3]];
    List sortXy=xyxy..sort((b, a) => a.compareTo(b));
    print(sortXy[0]);
  }
}

Measured memory_bytes: 13204
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  }
}



Measured memory_bytes: 25848
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

typedef double Real;

const Real EPS = 1e-8;

int sign(Real d){
	return d > EPS ? 1 : d < -EPS ? -1 : 0;
}

struct Point{
	Real x,y;
	
	Point(Real x_ = 0,Real y_ = 0):x(x_),y(y_){}

	Point operator+(const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator-(const Point &p) const {return Point(x-p.x,y-p.y);}
	Point operator*(Real s) const {return Point(x*s,y*s);}
	Point operator/(Real s) const {return Point(x/s,y/s);}
	bool operator<(const Point &p) const{return sign(x-p.x) == -1 || (sign(x-p.x) == 0 && sign(y-p.y) == -1);}
	bool operator==(const Point &p) const{return sign(x-p.x) == 0 && sign(y-p.y) == 0;}

};

istream &operator>>(istream &is,Point &p){return is >> p.x >> p.y;}//??\???????°???????
ostream &operator<<(ostream &os ,const Point &p){return os << '(' << p.x << ", " << p.y << ')';}//??????????°???????

struct Segment : public array<Point,2>{
	Segment(const Point &a,const Point &b){	at(0) = a; at(1) = b;}
};

struct Line : public array<Point,2>{
	Line(const Point &a,const Point &b){at(0) = a; at(1) = b;}
};

struct Circle{
	Point c;
	Real r;

	Circle(const Point &c_, Real r_):c(c_),r(r_){}
};

typedef vector<Point> Polygon;



Point rotate90(const Point &p){
	return Point(-p.y,p.x);
}

Point rotate(const Point &p,Real theta){
	const Real s = sin(theta),c = cos(theta);
	return Point(c*p.x-s*p.y,s*p.x+c*p.y);
}

Real angle(const Point &p){
	return atan2(p.y,p.x);
}

Real dot(const Point &a,const Point &b){ //??????????????????
	return a.x*b.x+a.y*b.y;
}

Real cross(const Point &a,const Point &b){ //??????????????????
	return a.x*b.y-a.y*b.x;
}


Real norm(const Point &p){
	return p.x*p.x+p.y*p.y;
}

Real abs(const Point &p){
	return sqrt(norm(p));
}


Point project(const Line &l,const Point &p){
	Real t = dot(p-l[0], l[1]-l[0]) / norm(l[0] - l[1]);
	return l[0] + (l[1] - l[0]) * t;
}

bool intersect(const Line &a,const Line &b){ //????????????
	return sign(cross(a[1]-a[0],b[1]-b[0])) != 0
		||	sign(cross(a[1]-a[0],b[1]-a[0]) == 0);
}
int main(){


	cout.setf(ios::fixed);
	cout.precision(10);

	Point p0,p1,p2;
	cin >> p0 >> p1;
	int q;
	cin >> q;

	rep(i,q){
		cin >> p2;
		Point tmp = project(Line(p1,p0),p2);
		Point ans = p2+((tmp-p2)*2.0);
		cout << ans.x << " " << ans.y << endl;
	}

	return 0;
}

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

typedef long long ll;

int main() {
    ll N, A;
    cin >> N;
    vector<pair<ll, int>> Ai(N), Bi(N);
    rep(i, N) {
        cin >> A;
        Ai[i] = make_pair(A, i);
    }
    sort(Ai.begin(), Ai.end());
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    rep(i, N) {
        rep(j, i + 1) {
            A = Ai[N - 1 - i].first;
            int k = Ai[N - 1 - i].second;
            //cout << "i=" << i << " A=" << A << " k=" << k << "\n";
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A * abs(N - 1 - (i - j) - k));
            //cout << "dp[" << i + 1 << "][" << j << "]=" << dp[i + 1][j] << "\n";
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + A * abs(j - k));
            //cout << "dp[" << i + 1 << "][" << j + 1 << "]=" << dp[i + 1][j + 1] << "\n";
        }
    }
    ll ans = 0;
    rep(i, N + 1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << "\n";
    /*
    rep(i, N + 1) {
        rep(j, N + 1) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}


Measured memory_bytes: 34656
"""
今回の移動方法は、全て右に進んだ場合{1, 2, 3, 4, 5, 6, …., t}となる。これは等差数列であり、
この数列の項の総和は等差数列の和の公式によってO(1)で求めることができる。
(t >= X)となる最小のｔが答えとなる。
"""

X = int(input())

t = 1
while (t*(t+1)//2) < X:
  t += 1
print(t)  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();

        int a = n * (n - 1) / 2 +  n * l;
        int d = 1000000;
        int index = 0;
        for (int i = 0 ; i < n ; i++ ) {
            int b = a - (l + i);
            if (Math.abs(b - a) < d) {
                d = Math.abs(b - a);
                index = i;
            }

        }
        System.out.println(a - (l + index));
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> cnt(n);
  REP(i, n) {
    ll a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  sort(ALL(cnt));
  ll ans = 0;
  REP(i, n - k) { ans += cnt[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m;
    cin >> n >> m;
    ll h[n+1],i,a,b,cc[n+1]={0};
    for(i=1;i<=n;i++)
        cin >> h[i];
    ll cnt=0;
    while(m--)
    {
        cin >> a >> b;
        if(h[a]>=h[b])
            cc[b]=1;
        if(h[a]<=h[b])
            cc[a]=1;
    }
    for(ll i=1;i<=n;i++)
        if(cc[i]==0)
        cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 5220
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		int n,a,b,c;
		cin>>n>>a>>b>>c;
		if(n>=c) cout<<c<<endl;
		else if(n+a>=c){
			cout<<n<<endl;
		}
		else {
			c=c-n;
			c=c-a;
			cout<<n-c<<endl;
		}
		return 0;
	}


Measured memory_bytes: 3652
//ABC150

#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <random>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <string>

using namespace std;

int main(){
    char str;
    cin >> str;
    if(str >= 'a' && str <= 'z'){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
    int i, j;
    for(i = 1; i < 10; ++i)
    {
        for(j = 1; j < 10; ++j)
        {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }

    return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 100
#define ull unsigned long long
#define F(a,b,c,d) ((a>b||c>d)?ans:f[num[a][b]][num2[c][d]])
#define N 65535
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
char st[MN+5][MN+5];
int f[5505][5505],num[MN+5][MN+5],num2[MN+5][MN+5],n,m,ans,cnt[1<<16],s[MN+5][MN+5];
inline void R(int&x,int y){y>x?x=y:0;}
struct Bitset
{
    ull a,b;
    Bitset(){a=b=0;}
    Bitset(ull c,ull d):a(c),b(d){}
    void Mod(int y){y>=64?(b|=1ULL<<y-64):(a|=1ULL<<y);}
    Bitset operator & (const Bitset&c){return Bitset(a&c.a,b&c.b);}
    int Count(){return cnt[a&N]+cnt[a>>16&N]+cnt[a>>32&N]+cnt[a>>48&N]
        +cnt[b&N]+cnt[b>>16&N]+cnt[b>>32&N]+cnt[b>>48&N];}
    Bitset operator << (int y){return !y?*this:(y>=64?Bitset(0,a<<y-64):Bitset(a<<y,b<<y|(a>>64-y)));}
}lru[MN+5][MN+5],lrd[MN+5][MN+5],udl[MN+5][MN+5],udr[MN+5][MN+5],a[MN+5],b[MN+5];
inline int C(int u,int l,int d,int r){return s[d][r]-s[u-1][r]-s[d][l-1]+s[u-1][l-1];}
int main()
{
    for(int i=1;i<=N;++i) cnt[i]=cnt[i>>1]+(i&1);
    n=read();m=read();
    for(int i=1,k=0;i<=n;++i)for(int j=i;j<=n;++j)num[i][j]=++k;
    for(int i=1,k=0;i<=m;++i)for(int j=i;j<=m;++j)num2[i][j]=++k;
    for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)
    {
        if(st[i][j]=='o') a[i].Mod(j),b[j].Mod(i);
        s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(st[i][j]=='E');
    }
    for(int i=1;i<=m;++i) for(int j=1;j<=n;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(1,k,n-j+1,m-(i-k))) lru[i][j].Mod(k);
            if(C(j,k,n,m-(i-k)))     lrd[i][j].Mod(k);
        }
    for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(k,1,n-(i-k),m-j+1)) udl[i][j].Mod(k);
            if(C(k,j,n-(i-k),m))     udr[i][j].Mod(k);
        }
    for(int i=1;i<=n;++i) for(int j=n;j>=i;--j)
        for(int k=1;k<=m;++k) for(int l=m;l>=k;--l)
        {
            int v=F(i,j,k,l);
            R(F(i+1,j,k,l),v+(a[i]&(lru[l-k+1][j-i+1]<<k-1)).Count());
            R(F(i,j-1,k,l),v+(a[j]&(lrd[l-k+1][j-i+1]<<k-1)).Count());
            R(F(i,j,k+1,l),v+(b[k]&(udl[j-i+1][l-k+1]<<i-1)).Count());
            R(F(i,j,k,l-1),v+(b[l]&(udr[j-i+1][l-k+1]<<i-1)).Count());
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 110848
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int ans = 0;
		int Rc = 0;
		for(int i = 0; i < N; i++)
			if(S.charAt(i) == 'R')
				Rc++;
		for(int i = 0; i < Rc; i++)
			if(S.charAt(i) == 'W')
				ans++;
		System.out.println(ans);
	}

}

Measured memory_bytes: 40340
fn solve() {
    let stdin = std::io::stdin();
    let mut scn = Scanner {
        stdin: stdin.lock(),
    };
    let mut abc: Vec<i32> = scn.vec(3);
    abc.sort();
    println!("{}", abc[0] + abc[1]);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define F first
#define S second
using namespace std;

vector<pair<char, int> > vs;
int ans = 0;
string s;

signed main()
{
	cin >> s;
	vs.PB(MP('0', 1));
	for(int i = 0; i < (int)s.size(); i++){
		if(vs.back().F == s[i]){
			vs.back().S++;
		}
		else{
			vs.PB(MP(s[i], 1));
		}
	}
	vs.PB(MP('0', 1));
	
	for(int i = 1; i < (int)vs.size() - 1; i++){
		if(vs[i - 1].F == 'J' && vs[i].F == 'O' && vs[i + 1].F == 'I' && vs[i - 1].S >= vs[i].S && vs[i].S <= vs[i + 1].S){
			ans = max(ans, vs[i].S);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20692
#include<stdio.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int a[m], sum=0;
    for(int i=0; i<m; i++)
    {
        scanf("%d", &a[i]);
        sum=sum+a[i];
    }
    if(sum>n)
        printf("-1\n");
    else if(sum==n)
        printf("0\n");
    else
        printf("%d\n", n-sum);
    return 0;
}


Measured memory_bytes: 1680
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n,a,b;
    cin>>a>>b;
    n=__gcd(a,b);
    cout<<(a*b)/n;
}

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

min_cost = 10000000000
for i in range(max(x, y) + 1):
    cost = 2 * c * i + max(0, a * (x - i)) + max(0, b * (y - i))

    if min_cost > cost:
        min_cost = cost
print(min_cost)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;
#define int long long

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
inline void chmin(int &x, int v) { if (x>v)x=v;}

int N;
int A[200000];
long long dp[200001][5];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N+1) rep(j,5)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i, N+1) {
    rep(j, 4) chmin(dp[i][j+1], dp[i][j]);
    if (i == N) break;
    rep(j, 5) {
      if (j==0||j==4) chmin(dp[i+1][j], dp[i][j]+A[i]);
      if (j==1||j==3) chmin(dp[i+1][j], dp[i][j]+(A[i]==0?2:(A[i]%2)));
      if (j==2) chmin(dp[i+1][j], dp[i][j]+((A[i]%2)^1));
    }
  }
  cout << dp[N][4] << "\n";
  return 0;
}


Measured memory_bytes: 9728
#include <iostream>
using namespace std;
int main(void){
    int n, x[105], y[105], h[105];
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> h[i];
    
    int H;
    
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            bool cond = true;
            
            for (int i = 1; i <= n; i++) {
                if (h[i] != 0) {H = h[i] + abs(x[i] - cx) + abs(y[i] - cy); break;}
            }
            
            for (int i = 1; i <= n; i++) {
                if (h[i] != 0) {
                    if (h[i] + abs(x[i] - cx) + abs(y[i] - cy) != H) {
                        cond = false;
                    }
                }
                else {
                    if (abs(x[i] - cx) + abs(y[i] - cy) < H) cond = false;
                }
            }
            
            if (cond) {
                cout << cx << " " << cy << " " << H;
                return 0;
            }
            
        }
    }
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	int N;
	cin >> N;
	string s;
	cin >> s;
	if (N%2==0) {
		int sum=0;
		for (int i=0, j=N/2; j<N; i++, j++) {
			if (s[i]==s[j]) {
				sum++;
			}
		}
		if (sum==N/2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3612
// AtCoder Regular Contest 065
// C - 白昼夢 / Daydream

#include <cstdio>
#include <cstring>
#include <string>
#define MAX_S 100000
using namespace std;
typedef long long int ll;


char S[MAX_S + 2];
int len;
string strs[4] = { "dream", "dreamer", "erase", "eraser" };

bool dfs(int idx) {
  bool ret = false;
  bool matched = true;
  if (idx >= len) {
    return true;
  }
  for (int j = 0; j < 4; j++) {
    matched = true;
    for (int i = 0; i < (int)strs[j].size(); i++) {
      if ((idx + i >= len) || (S[idx + i] != strs[j][i])) {
        matched = false;
        break;
      }
    }
    ret = (matched && dfs(idx + strs[j].size())) || ret;
  }
  return ret;
}

int main() {

  scanf("%s", S);
  len = strlen(S);

  printf("%s\n", dfs(0) ? "YES" : "NO");

  return 0;

}




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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N;
	// 出入力
	cin >> N;
	vector<int> P(N);
    vector<int> Q(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        cin>>Q[i];
    }

    vector<int> k(9);
    k[0]=1;
    for(int i=1;i<=8;i++){
        k[i] = k[i-1]*i;
    }
    int a,b;
    a=0;b=0;;
    for(int i=0;i<N;i++){
        int n = P[i]-1;
        for(int j=0;j<i;j++){
            if(P[j]<P[i]){
                --n;
            }
        }
        a+=k[N-1-i]*n;
    }
    for(int i=0;i<N;i++){
        
        int n = Q[i]-1;
        for(int j=0;j<i;j++){
            if(Q[j]<Q[i]){
                --n;
            }
        }
        b+=k[N-1-i]*n;
    }

    // for(int i=0;i<9;i++){
    //     cout<<k[i]<<"\n";
    // }
    // cout<<a<<b<<"\n";
    int ans =0;
    ans = abs(a-b);
    cout<<ans<<"\n";
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s, t;
    cin >> s >> t;
    s += s;

    if (s.find(t) != -1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>

int main(void){
    char a;
    int n;
    long long ans = 0;
    while(1){
        scanf("%c", &a);
        if(a == '\n') break;
        n = a - '0';
        ans += n;
    }

    if(ans%9 == 0) printf("Yes\n");
    else printf("No\n");

    return 0;
}


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

typedef long long ll;
typedef double db;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int mod   = 1e9 + 7;
const int maxn  = 3e5;
const int inf   = 2e9;

int make[maxn*10];

int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    fill(make,make+maxn*10,-1);
    int n;
    cin>>n;
    int len=(1+n)*2;
    int k;
    cin>>k;
    make[len]=k;
    for(int i=2;i<=n;i++)
    {
        cin>>k;
        if(i%2==0)
            make[len-i/2]=k;
        else 
            make[len+i/2]=k;
    }
    int pos=0;
    if(n%2==0)
    {
    while(make[pos]==-1)
        pos++;
    for(int i=pos;make[i]!=-1;i++)
        cout<<make[i]<<" ";
    cout<<endl;
    }
    else 
    {
        pos=maxn*10-1;
        while(make[pos]==-1)
            pos--;
        for(int i=pos;make[i]!=-1;i--)
            cout<<make[i]<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 13952
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: u64,
        ab_a: [[u64; 2]; n],
    }

    let mut ab_a = ab_a;

    ab_a.sort_by_key(|ab| ab[0]);

    let mut count = k;
    for ab in &ab_a {
        let a = ab[0];
        let b = ab[1];

        if b >= count {
            println!("{}", a);
            return;
        } else {
            count -= b;
        }
    }
}


Measured memory_bytes: 10492
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




// https://atcoder.jp/contests/agc034/tasks/agc034_a
int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		ll a,b,d;
		cin>>n>>a>>b>>c>>d>>s;
		// n=s.length();
		// ll a[n];
		a--;
		b--;c--;d--;
		repe(i,a+1,c-1)
		{
			if(i<n-1 && s[i+1]==s[i] && s[i]=='#')
			{
				cout<<"No";
				return 0;
			}
		}
		repe(i,b+1,d-1)
		{
			if(i<n-1 && s[i+1]==s[i] && s[i]=='#')
			{
				cout<<"No";
				return 0;
			}
		}
		if(c<d || (c>d && s[d+1]!='#' && s[d-1]!='#' ))
		{
			cout<<"Yes";
			return 0;
		}
		repe(i,b,d+1)
		{
			// debug3(s[i-1],i,s[i+1]);
			if(i<n-1 && s[i-1]=='.' && s[i+1]=='.' && s[i]=='.')
			{
				cout<<"Yes";
				return 0;
			}
		}
		cout<<"No";
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
using namespace std;
int main(){
	long long int y=100;
	long long  int x;
	int i=0;
	cin>>x;
	while(1)
	{
		y=y*1.01;
		i++;
		if(y>=x)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(b<a) a--;
	cout<<a<<endl;
	return 0;
}

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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 5e5;
const int maxM = 3e5 + 10;
const int oo = 2e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    vector <int> A;
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n; ) {
        int j = i;
        while (j < n && s[i] == s[j]) j++;
        A.push_back(j - i);
        i = j;
    }
    int S = 0;
    for (int x : A) S += x - 1;
    cout << min(n - 1, S + 2 * k);
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 972
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	string s;
	cin >>s;
	int sum = 0;
	for(auto c : s){
		int d = c - '0';
		sum += d;
	}
	if(sum % 9 == 0)
		cout <<"Yes\n";
	else 
		cout <<"No\n";
	return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

string mej(string v){
	return v.substr(v.size()-1) + v.substr(0,v.size()-1);
}
string mec(string v){
	return v.substr(1) + v.substr(0,1);
}
string mee(string v){
	for(int i=0;i<v.size()/2;i++){
		swap(v[i], v[i + (v.size()+1)/2]);
	}
	return v;
}
string mea(string v){
	for(int i=0;i<v.size()/2;i++){
		swap(v[i], v[v.size()-1-i]);
	}
	return v;
}
string mep(string v){
	for(int i=0;i<v.size();i++){
		if(v[i] >= '1' && v[i] <= '9') v[i] -= 1;
		else if(v[i] == '0') v[i] = '9';
	}
	return v;
}
string mem(string v){
	for(int i=0;i<v.size();i++){
		if(v[i] >= '0' && v[i] <= '8') v[i] += 1;
		else if(v[i] == '9') v[i] = '0';
	}
	return v;
}

int main(){
	int i, j, n;
	string s, o;
	
	cin >> n;
	for(i=0;i<n;i++){
		cin >> o >> s;
		for(j=o.size()-1;j>=0;j--){
			if(o[j] == 'J') s = mej(s);
			if(o[j] == 'C') s = mec(s);
			if(o[j] == 'E') s = mee(s);
			if(o[j] == 'A') s = mea(s);
			if(o[j] == 'P') s = mep(s);
			if(o[j] == 'M') s = mem(s);
		}
		cout << s << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))
#define MOD 1000000007

typedef long long int ll;

using namespace std;

long long int dp[201][201];

int main(){

    long long int ans = 0;
    char s[201];
    int n;
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    cin >> n;
    for(int i=0;i<n;i++){
	cin >> s[i];
    }

    for(int i=0;i<n;i++){
	if(s[i] == '-'){
	    for(int j=0;j<=i;j++) dp[i+1][j] = dp[i][j];
	}else if(s[i] == 'D'){
	    for(int j=1;j<=i+1;j++){
		dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j] * j * j )% MOD;
		dp[i+1][j] = (dp[i+1][j] + dp[i][j] * j) % MOD;
	    }
	}else if(s[i] == 'U'){
	    for(int j=0;j<=i;j++){
		dp[i+1][j] = (dp[i+1][j] + dp[i][j] * j )% MOD;
		dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD;
	    }
	}
    }
    cout << dp[n][0] << endl;;
    return 0;
}

Measured memory_bytes: 1484
X = int(input())
ls = [2, 2, 2, 3, 3, 5]
a = []
for l in ls:
  if X % l == 0:
    a.append(l)
    X /= l
num = 1
if len(a) != 0:
  for b in a:
    num *= b
print(int(360 / num))

Measured memory_bytes: 9168
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  x.sort();h=[]
  for k,l,r in x:
   s+=r
   if k:s+=l-r;heappush(h,l-r)
   if len(h)>k:s-=heappop(h)
 print(s)

Measured memory_bytes: 50744
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
		}else {
			int A = sc.nextInt(),B = sc.nextInt();
			System.out.println(A+B);
		}
	}
}

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

UL N,K;
UL W[100000];

bool Proc(UL P){
 UL ans=0;
 UL crr=0;
 rep(i,N){
  crr+=W[i];
  if(W[i]>P) return false;
  if(crr>P){crr=W[i]; ans++;}
 }
 return ans+1<=K;
}

int main() {
 scanf("%u%u",&N,&K);
 rep(i,N) scanf("%u",&W[i]);
 UL l=0, r=1100000000;
 while(l+1<r){ UL m=(l+r)>>1;
  if(Proc(m)) r=m;
  else l=m;
 }
 printf("%u\n",r);
 return 0;
}



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

using ll = long long;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int size(int x) {
    return siz[find(x)];
}

int main() {
    int N, M, x, y, ans = 0;
    cin >> N >> M;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    init(N);
    rep(i, M) {
        cin >> x >> y;
        unite(x - 1, y - 1);
    }
    rep(i, N) {
        if (same(i, p[i] - 1)) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

/*
10^n - 8^n
*/

ll powe(ll x, ll y){
    //xのy乗をMODで割った余り
    ll tmp=1;
    rep(i,y){
        tmp = (tmp * x)%MOD;
    }
    return tmp;
}

void solve(){

    ll n;
    cin >> n;
    ll t1,t2,t3;
    t1 = powe(10,n);
    t2 = powe(8,n);
    t3 = powe(9,n);
    ll ans = (((t1 + MOD*MOD - 2*t3)%MOD + t2)%MOD);
    cout << ans << endl;
    
    //cout << t1 << endl;
    //cout << t2 << endl;
    //cout << t3 << endl;

}

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


Measured memory_bytes: 3616