akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

struct Saikoro{
    vector<int> v{6};
    void rotate(char c){
        if(c=='E'){
            vector<int> temp={v[3],v[1],v[0],v[5],v[4],v[2]};
            v=temp;
        }else if(c=='W'){
            vector<int> temp={v[2],v[1],v[5],v[0],v[4],v[3]};
            v=temp;
        }else if(c=='N'){
            vector<int> temp={v[1],v[5],v[2],v[3],v[0],v[4]};
            v=temp;
        }else if(c=='S'){
            vector<int> temp={v[4],v[0],v[2],v[3],v[5],v[1]};
            v=temp;
        }
    }

};

int main (){
    Saikoro dice;
    rep(i,0,6)cin>>dice.v[i];
    string s;
    cin>>s;
    for(auto gotutiyan:s){
        dice.rotate(gotutiyan);
    }
    cout<<dice.v[0]<<endl;
}



/*

*/


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

int seen[200001] = { false };
int a[200001] = { 0 };
int ans[200001] = { 0 };
void dfs(int v, int sum,whei(int)&G) {
	seen[v] = true;
	ans[v] = sum;
	for (auto x : G[v]) {
		if (seen[x])continue;
		dfs(x, sum + a[x], G);
	}
}

int main() {
	string s;
	cin >> s;
	bool ans = false;
	if (s.size() >= 4) {
		if ("YAKI" == s.substr(0, 4))ans = true;
	}
	Yes(ans)
	return 0;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;

    vector<int> a(N + 1), b(N + 1); // a->row,b->col
    for (int i = 1; i <= N; ++i) a[i] = b[i] = N;

    ll black = ll(N - 2) * (N - 2);

    int H = N, W = N;

    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < W) 
            {
                for (int i = x; i < W; ++i) 
                {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;

        } else 
        {
            if (x < H) 
            {
                for (int i = x; i < H; ++i) 
                {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;

    return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    string ans = "";

    int need_left = 0;
    int pointer = 0;

    rep(i,s.size()) {
        if (s[i] == '(') pointer++;
        else {
            if (pointer == 0) need_left++;
            else pointer--;
        }
    }

    int need_right = pointer;

    rep(i,need_left) ans += '(';
    ans += s;
    rep(i,need_right) ans += ')';
    cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int t = 0;
	string ss;
	rep(i, 2 * n) {
		if ((t + (s[i] == 'B' ? 1 : 0)) % 2 == 1) {
			ss.push_back('r'); t++;
		}
		else {
			ss.push_back('l'); t--;
		}
	}

	int r = 0;
	long long ans = 1;
	if (t != 0) ans = 0;
	rep(i, 2 * n) {
		
		if (ss[i] == 'l') {
			ans *= r--;
			ans %= MOD;
		}
		else r++;
	}
	for (int i = 1; i <= n; i++) { ans *= i; ans %= MOD; }

	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string a;
  cin >> a;
  if(a == "ABC")
    cout << "ARC\n";
  else
    cout << "ABC\n";
  return 0;
}

Measured memory_bytes: 3640
N = int(input())
a = list(map(int, input().split(" ")))


l = [[] for i in range(N)]
c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t > i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t < i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

l[0] = max(l[0])
for i in range(1,N):
	l[i].append(-1)
for i in range(1,N):
	
	if i!=N-1:
		l[i+1].append(-1)
		l[i] = max(l[i-1],max(l[i]),max(l[i+1]))
	else:
		l[i] = max(l[i-1],max(l[i]))


now = 0
res = 0

while now<N-1:
	now = l[now]	
	res+=1
if N==1:
	print(1)
	exit()
print(res)

Measured memory_bytes: 23444
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);reverse(a, a + 3);
	cout << a[0] * 10 + a[1] + a[2] << '\n';
	return 0;
}



Measured memory_bytes: 384
import java.util.*;

class Main {

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

        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        ArrayList<Integer> candidates = new ArrayList<>();
        boolean cand;
        int score;
        for (int i = 0; i < a.length - 1; i++) {
            score = Math.abs(a[i] - a[a.length - 1]);
            cand = true;
            for (int j = i + 1; j < a.length - 1; j++) {
                if (Math.abs(a[a.length - 1] - a[j]) < score) {
                    cand = false;
                    break;
                }
            }
            if (cand && candidates.size() > 0 && score > candidates.get(candidates.size() - 1)) candidates.add(score);
            else if (cand) candidates.add(score);
        }

        if (candidates.size() != 0) System.out.println(Math.max(candidates.get(candidates.size() - 1), Math.abs(w - a[a.length - 1])));
        else System.out.println(Math.abs(w - a[a.length - 1]));
    }
}


Measured memory_bytes: 26828
a,b = map(int,input().split())
S = input()
flag = 0
if S[a] != "-":
    flag += 1
for i in range(0,a):
    if S[i]== "-":
        flag += 1
for i in range(a+1,a+b+1):
    if S[i] == "-":
        flag += 1
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int d[110][110] = {};
int n, m, inf = 1e9 + 7, a[1010], b[1010], c[1010], ans;
bool used[1010];

void warshall_floyd(int n)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            d[i][j] = (i == j ? 0 : inf);
        }
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        a[i]--, b[i]--, d[a[i]][b[i]] = c[i], d[b[i]][a[i]] = c[i];
    }
    warshall_floyd(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            for (int k = 0; k < m; k++)
            {
                used[k] = used[k] || d[i][a[k]] + c[k] + d[b[k]][j] == d[i][j] || d[i][b[k]] + c[k] + d[a[k]][j] == d[i][j];
            }
        }
    }
    for (int i = 0; i < m; i++)
        ans += !used[i];
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[10010];
ll dd[10010];

int main(){
  clr(d,0);
  ll n;
  cin>>n;
  vector<vector<ll> > vv(n,vector<ll>());
  rep(i,0,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    vv[a].pb(b);
    vv[b].pb(a);
    d[a]++;
    d[b]++;
  }
  vector<ll> v;
  ll sum = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    sum+=a;
  }
  sort(all(v));
  ll ans = sum-v[v.sz-1];
  queue<ll> q;
  rep(i,0,n){
    if(d[i]==1){
      q.push(i);
    }
  }
  ll index = 0;
  while(!q.empty()){
    ll a = q.front();q.pop();
    dd[a] = v[index];
    index++;
    rep(i,0,vv[a].sz){
      d[vv[a][i]]--;
      if(d[vv[a][i]]==1)q.push(vv[a][i]);
    }
  }
  cout << ans << endl;
  rep(i,0,n){
    cout << dd[i];
    if(i!=n-1)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
int n,a[25],ans;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n-1;i++)
		if(a[i]>a[i-1]&&a[i]<a[i+1]||a[i]>a[i+1]&&a[i]<a[i-1])
		{
			ans++;
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll ans;
int main(){FAST;
cin>>n;
ans = n-1;
ll lim = sqrt(n);
for(int i=lim;i>=1;i--){
	if(n%i == 0){
		ll x = i;
		ll y = n/i;
		ans=min(ans,x-1+y-1);
	}
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using  namespace std;

int main()
{
	int N;
	cin >> N;
	double Ans = 1;
	
	for (int i = 1.0; i <= N; i++) {
		Ans *= i;
		if (Ans >= 1000000007.0)
			Ans = fmod(Ans,1000000007.0);
	}
	int ANS = Ans;
	cout << ANS << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    ll N, M;
    ll a,b;
    ll ans = 0;
    cin >> N >> M;
    vector<pair<ll, ll> > C;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        C.push_back(make_pair(a, b));
    }
    sort(C.begin(), C.end());
    for(int i = 0; i < N; i++){
        a = C[i].first;
        b = C[i].second;
        if(b >= M){
            ans += a * M;
            cout << ans << endl;
            return 0;
        }else{
            ans += a * b;
            M -= b;
        }   
    }
}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int i = 0;
		int a = s.nextInt();
		int max = a;
		int min = a;
		for (i = 0; i < n - 1; i++) {
			int b = s.nextInt();
			if (b > max) {
				max = b;
			}
			if (b < min) {
				min = b;
			}

		}
		int ans = max - min;
		System.out.println(ans);
	}

}

Measured memory_bytes: 20948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define ll long long 
using namespace std;
int n,m;
ll k;
int a[1000005],b[1000005];
struct node{
	int a,b;
	ll v;
}d[1000005];
bool check(ll now){
	ll s=0;
	for(int i=1;i<=n;i++)
		if(d[i].v>now){ 
		  s=s+(ll)d[i].a-now/d[i].b;
//		  else s=s+(ll) d[i].a-now/d[i].b;if(now%d[i].b==0) 
	    }
	if(s<=k) return true;
	return false;
}
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int j=1;j<=n;j++) scanf("%d",&b[j]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++) d[i].v=1ll*a[i]*b[n-i+1],d[i].a=a[i],d[i].b=b[n-i+1];
	ll l=0,r=1e18,ans=0;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10496
N, M, C = map(int, input().split())
import numpy as np
B = np.array(list(map(int, input().split())))
ans = 0
for _ in range(N):
  M = list(map(int, input().split()))
  M = np.array(M)
  if np.sum(B * M) +C > 0:
    ans += 1
print(ans)

Measured memory_bytes: 12488
// Ryo Kamoi

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int INF = 1000000000;

int vnum_odd(int n) {
    return (n*(n-1)) / 2 - n/2;
}

int n;
int m;
int main(){
    cin >> n;

    if (n%2==1) {
        m = vnum_odd(n);
    } else {
        m = vnum_odd(n-1) + n-2;
    }
    cout << m << endl;

    int add = 0;
    if (n%2==0) {
        add = 1;
        REP(i, n-2) {
            cout << "1 " << (i+2) << endl;
        }
    }

    // for odd
    REP(i, n-add) {
        for(int j=i+2; j<=(n-add); j++) {
            if (j == (n-add)-(i+1)) continue;
            cout << (i+1+add) << " " << (j+add) << endl;
        }
    }
}


Measured memory_bytes: 256
function main()
    S = parse(Int, readline())
    T = parse.(Int, split(readline()))

    ret = 0
    #println(typeof(ret))
    ruiseki = 0
    for i in S:-1:2
        #println(i)
        ruiseki += T[i]
        ruiseki = ruiseki % (10 ^ 9 + 7)
        ret += (T[i - 1] * ruiseki) % (10 ^ 9 + 7)
        ret = ret % (10 ^ 9 + 7)
        #println(ret)
    end
    print(ret % (10 ^ 9 + 7))
end

main()

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

using namespace std;

int main() {
    string s;
    string t;
    cin>>s>>t;
    int m = s.length();
    int n = t.length();

    int L[m+1][n+1];
    string res = "";
    for (int i=0; i<=m; i++) {
        for (int j=0; j<=n; j++) {
            if (i==0 || j==0)
                L[i][j] = 0;
            else if (s[i-1] == t[j-1]) {
                L[i][j] = L[i-1][j-1] + 1;
            } else 
                L[i][j] = max(L[i-1][j], L[i][j-1]);
        }
    }

    int i = m, j = n;
    while(i>0 && j>0) {
        if (s[i-1] == t[j-1]) {
            res = s[i-1] + res;
            i--;
            j--;
        } else if (L[i-1][j] > L[i][j-1])
            i--;
        else
            j--;
        
    }

    cout<<res<<endl;

    
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {

    lli a,b,c,k,ans=0,mid;
    cin>>a>>b>>c>>k;
    mid=k;
    ans+=a;
    k-=a;
    if(k==0) {
        printf("%lld\n",ans);
    }

    else if(k<0) {
        printf("%lld\n",min(mid,a));
    }

    else if(k>0) {
        k-=b;
        if(k<=0) {
            printf("%lld\n",ans);
        }
        if(k>0) {
            if(k>=c) {
                ans-=c;
                printf("%lld\n",ans);
            } else {
                ans-=k;
                printf("%lld\n",ans);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3764
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 2019;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N,cnt=0;
    cin >> N;
    for (int i=1; i<=N; i++) {
        string str = to_string(i);
        size_t size = str.length();
        if (size % 2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int H,W,ans=0; cin >> H >> W;
  vv<char> field(H,v<char>(W));
  rep(i,H)rep(j,W) cin >> field[i][j];
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  for(int sx=0;sx<H;sx++){
    for(int sy=0;sy<W;sy++){
      if(field[sx][sy]=='#') continue;
      vector<vector<int>> dist(H,vector<int>(W,-1));
      queue<pair<int,int>> que;
      dist[sx][sy]=0;
      que.push(make_pair(sx,sy));
      while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        rep(i,4){
          int x=p.first+dx[i];
          int y=p.second+dy[i];
          //cout << x << y << endl;
          if(0<=x && x<=H-1 && 0<=y && y<=W-1 && field[x][y]!='#' && dist[x][y]==-1){
            dist[x][y]=dist[p.first][p.second]+1;
            chmax(ans,dist[x][y]);
            que.push(make_pair(x,y));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
	int a, b, flag = 0;
	string s;
	cin >> a >> b; cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i == a) {
			if (s[i] != '-') flag = 1;
		}
		else {
			if (s[i] == '-') flag = 1;
		}
	}
	cout << (flag == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
# 8% -> [a,a+1)
# 10% -> [b,b+1)
# max(a*100/8, b*10) <= 元の価格 < min((a+1)*100/8, (b+1)*10)
min8 = a*(100/8)
max8 = (a+1)*(100/8)
min10 = b*10
max10 = (b+1)*10
mi = int(max(min8, min10) - 0.001) + 1
ma = int(min(max8, max10) - 0.001)
if mi > ma:
    ans = -1
else:
    ans = mi
print(ans)

Measured memory_bytes: 61832
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 mp make_pair
#define fi first
#define sc second
int n,m;
int a[10000],b[10000];
vector<int> G[100];
bool used[100];

void dfs(int i ) {
	used[i] = true;

	REP(j,G[i].size()) {
		if(!used[G[i][j]]) {
			dfs(G[i][j]);
		}
	}
}

bool check(int aaa) {
	REP(i,n) {
		G[i].clear();
	}
	REP(i,m) {
		if(i != aaa) {
			G[a[i]].pb(b[i]);
			G[b[i]].pb(a[i]);
		}
	}

	REP(i,n) {
		used[i] = false;
	}

	int c = 0;

	REP(i,n) {
		if(!used[i]) {
			c++;
			dfs(i);
		}
	}

	return c > 1;
}

int main(){
	cin >> n >> m;
	REP(i,m) {
		cin >> a[i] >> b[i];
		a[i]--;b[i]--;
	}

	int ans = 0;
	REP(i,m) {
		ans += check(i);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, C = map(int, input().split())
X, V = [], []
for i in range(N):
    xi, vi = map(int, input().split())
    X.append(xi)
    V.append(vi)

r_cal = [0]
l_cal = [0]
for i in range(N):
    r_cal.append(r_cal[-1] + V[i])
    l_cal.append(l_cal[-1] + V[N-i-1])

# 折り返さないパターン and 折り返してどこまでいくのか
r_straight = r_cal.copy()
l_straight = l_cal.copy()

for i in range(1, N+1):
    r_straight[i] -= X[i-1]
    l_straight[i] -= (C - X[N-i])

# 折り返すパターン
for i in range(1, N+1):
    r_cal[i] -= 2*X[i-1]
    l_cal[i] -= 2*(C - X[N-i])

# 折り返した後どこまで行くのが最適か
r_max = [0]
l_max = [0]
for i in range(1, N+1):
    r_max.append(max(r_max[-1], r_straight[i]))
    l_max.append(max(l_max[-1], l_straight[i]))

ans = max(r_max[-1], l_max[-1])
for i in range(N):
    ans = max(ans, r_cal[i] + l_max[N-i])
    ans = max(ans, l_cal[N-i] + r_max[i])
    
print(ans)

Measured memory_bytes: 30116
from functools import lru_cache
import sys

mod=1000000007

n,k=[int(i) for i in input().split(" ")]



facts=[1 for i in range(n+k+1)]

for i in range(1,n+k+1):
    facts[i]=i*facts[i-1]

if n<k:
    print(0)
    sys.exit()

tables=[[-1 for i in range(k+1)] for j in range(n+1)]

def f(n,k):
    if k==1:
        return 1

    elif n==k:
        return facts[n]

    elif tables[n][k]!=-1:
            return tables[n][k]

    else:
        retval=(k*f(n-1,k)+k*f(n-1,k-1))
        tables[n][k]=retval
        return retval

print((f(n,k)//facts[k])%mod)



Measured memory_bytes: 115712
N, K = map(int, input().split())
H = [None] * N

for i in range(N):
    H[i] = int(input())

H = sorted(H)
ans = 10e9

for i in range(N-K+1):
    tmp = H[i+K-1] - H[i]
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 8240
#include<bits/stdc++.h>
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;
}
int main()
{
	int x,y,z;
	x=read();
	y=read();
	z=read();
	x-=z;
	cout<<x/(y+z)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(ll mode){
    switch(mode){
    case 0:
        cout << "Alice" << endl;
        exit(0);
    case 1:
        cout << "Borys" << endl;
        exit(0);
    case 2:
        cout << "Draw" << endl;
        exit(0);
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, a, b;
    cin >> n >> a >> b;
    pr((b-a)%2);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<long long,long long> pii;
const long long NR=210000;
long long n,d,a,A[NR];
pii p[NR];
int main()
{
	scanf("%lld%lld%lld",&n,&d,&a);
	for(long long i=1;i<=n;i++)
	{
		long long x,h;
		scanf("%lld%lld",&x,&h);
		p[i]=make_pair(x,h);
	}
	sort(p+1,p+n+1);
	long long ans=0,tmp=0;
	for(long long i=1;i<=n;i++)
	{
		p[i].second-=tmp;
		if(p[i].second>0)
		{
			long long l=i,r=n,c=p[i].first+2ll*d,need=(p[i].second+a-1)/a;
			tmp+=need*a;
			ans+=need;
			while(l<=r)
			{
				long long mid=l+r>>1;
				if(p[mid].first>c)
				{
					r=mid-1;
				}
				else
				{
					l=mid+1;
				}
			}
			A[r]+=need*a;
		}
		tmp-=A[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <stack>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ", "
#define de(x) cout << #x << "=" << x << endl
#define ds() puts("---stop here---")
#define mset(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int INF = 0x3f3f3f3f;
const int maxn = 101010;
const int MOD = 1e9 + 7;

int arr[55];
int main()
{
    vector<pii> vec;
    int n , minn = INF , maxx = -INF , maxid , minid;
    scanf("%d",&n);
    rep(i,1,n+1) scanf("%d",&arr[i]);
    rep(i,1,n+1){
        if(arr[i]>maxx){
            maxx = arr[i];
            maxid = i;
        }
        if(arr[i]<minn){
            minn = arr[i];
            minid = i;
        }
    }

    bool ok = true;
    rep(i,1,n) if(arr[i]>arr[i+1]) ok = false;
    if(ok){
        puts("0");
        return 0;
    }

    if(minn >= 0){
        rep(i,1,n) vec.pb(mp(i,i+1));
        printf("%d\n",sz(vec));
        rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
        return 0;
    }
    if(maxx <=0){
        rrep(i,n,2) vec.pb(mp(i,i-1));
        printf("%d\n",sz(vec));
        rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
        return 0;
    }
    if(abs(maxx)>abs(minn)){
        rep(i,1,n+1) vec.pb(mp(maxid,i));
        rep(i,1,n) vec.pb(mp(i,i+1));
        printf("%d\n",sz(vec));
        rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
        return 0;
    }
    else{
        rep(i,1,n+1) vec.pb(mp(minid , i));
        rrep(i,n,2) vec.pb(mp(i,i-1));
        printf("%d\n",sz(vec));
        rep(i,0,sz(vec)) printf("%d %d\n",vec[i].fi , vec[i].se);
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    lint L, R;
    cin>>L>>R;
    if(L/2019<R/2019) {cout<<0<<endl; return 0;}
    lint ans = 2020;
    for(lint i=L;i<=R;i++){
        for(lint j=i+1;j<=R;j++){
            ans = min(ans, i*j%2019);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,s,i;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	s=a[n-1]-a[0];
	cout<<s;
}

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



int main(){


    cout<<fixed<<setprecision(10);


    int n,x; cin>>n>>x;
    
    while( n!=0 || x!=0){
        int ans = 0;
        for(int a=1; a<=n; ++a){
            for(int b=a+1; b<=n; ++b){
                int c = x - a - b;
                if( c <= n && c > b){
                  ans++;
                }
            }
        }
        cout<<ans<<endl;
        cin>>n>>x;
    }
    
    // cout<<ans<<endl;
    

    return 0;
}








Measured memory_bytes: 3056
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	_ = getNextInt(scanner)

	a := getNextInt(scanner)
	min := a
	minc := 1

	dmax := 0
	ans := 0
	for i := 0; i < n-1; i++ {
		a = getNextInt(scanner)
		d := a - min
		if dmax <= d {
			if dmax == d {
				ans++
			} else {
				ans = 1
			}
			dmax = d

			if minc == 0 {
				continue
			}
			minc--
		}
		if min >= a {
			min = a
			if min == a {
				minc++
				continue
			}
			minc = 1
		}

	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

int main(){
  int n, k;
  int sum = 0;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i = 0; i < k; i++) {
    sum += vec.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    vector<pair<ll,ll>> red(N);vector<pair<ll,ll>> blue(N);
    rep(i,N){
        red[i].FI=a[i];
        red[i].SE=b[i];
        blue[i].FI=c[i];
        blue[i].SE=d[i];
    }
    sort(all(red));
    sort(all(blue));
    ll ans=0;
    rep(i, N) {
        ll tmp=-1;
        rep(j, N) {
            if(blue[i].FI>red[j].FI&&blue[i].SE>red[j].SE){
                if(tmp==-1||red[j].SE>red[tmp].SE){
                    tmp=j;
                }
            }
        }
        if(tmp!=-1){
            red[tmp].FI=201;
            red[tmp].SE=201;
            ans++;
        }
    }
    op(ans)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> c(N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 1e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

int main() {
//    IO();
    ll ans;
    for(ll i = 1; i <= 5; ++i) {
        ll x = read();
        if(x == 0) ans = i;
    }
    print(ans);
    return 0;
}



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

// 0 未到達 1 到達 2 障害物あり
vector<vector<int>> field(200, vector<int>(200, 0));
int ans;

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

int dfs(int x, int y, int limit) {
    field[y][x] = limit;
    if (limit == 0) return 0;
    for (int i = 0; i < 6; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (field[ny][nx] < limit - 1) {
            dfs(nx, ny, limit - 1);
        }
    }
    return 0;
}

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

    while (1) {
        int INF = 1000000000;
        for (int i = 0; i < 200; i++) {
            for (int j = 0; j < 200; j++) {
                field[i][j] = -1;
            }
        }
        int t, n;
        cin >> t >> n;
        if (!t & !n) break;
        int x, y;
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            field[y + 100][x + 100] = INF;
        }
        cin >> x;
        cin >> y;
        ans = 0;

        dfs(x + 100, y + 100, t);
        for (int i = 0; i < 200; i++) {
            for (int j = 0; j < 200; j++) {
                if (0 <= field[i][j] && field[i][j] != INF) ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3368
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main() {
	double r, a, b;
	cin >> r;
	a = r * r * M_PI;
	b = 2 * r * M_PI;
	cout << fixed << setprecision(5) << a << " " << fixed << setprecision(5) << b << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

bool Solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> ba(n);
    for (int i = 0; i < n; ++i)
        cin >> ba[i].second >> ba[i].first;

    sort(ba.begin(), ba.end());

    ll t = 0;
    for (int i = 0; i < n; ++i) {
        t += ba[i].second;
        if (ba[i].first < t) return false;
    }
    return true;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    if (Solve()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 1792
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3580
import math
import itertools
n, d = map(int, input().split())
ary = []
for i in range(n):
	x = list(map(int, input().split()))
	ary.append(x)
c = 0
for j,k in itertools.combinations(ary,2):
	s = 0
	for l in range(d):
		s += (j[l]-k[l])**2
	ss = math.sqrt(s)
	if ss.is_integer():
		c += 1
print (c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int x, n, p;
bool out[105];
int main(){
	scanf("%d%d", &x, &n);
	rep(i,n){
		scanf("%d", &p);
		out[p] = 1;
	}
	for(int t=0; 1; t++){
		if(!out[x-t]) return printf("%d\n", x-t) * 0;
		if(!out[x+t]) return printf("%d\n", x+t) * 0;
	}
}

Measured memory_bytes: 3828
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] p = new int[n];
		
		for(int i = 0; i < n; i++) {
			p[i] = stdIn.nextInt();
		}
		
		int cnt = 0;
		for(int i = 1; i < n-1; i++) {
			if(p[i-1]<p[i] && p[i]<p[i+1] || p[i-1]>p[i] && p[i]>p[i+1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 21844
n = int(input())
S = []
ans = float('inf')
flag = False
for i in range(2,1000001):
  if n%i == 0:
    S.append([i,n//i])
    flag = True
if flag:
  for i in range(len(S)):
    if S[i][0]+S[i][1]-2 < ans:
      ans = S[i][0]+S[i][1]-2
else:
  ans = n-1
print(ans)

Measured memory_bytes: 3560