akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, M;
  cin >> N >> M;

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

  vec x;
  int mx = -INF, mn = INF;
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    x.pb(tmp);
    chmax(mx, tmp);
    chmin(mn, tmp);
  }

  int sum = abs(mx - mn);

  sort(ALL(x));
  vec v;
  for (int i = 0; i + 1 < M; i++) {
    v.pb(x[i + 1] - x[i]);
  }
  sort(ALL(v), greater<int>());
  int sub = 0;
  for (int i = 0; i < N - 1; i++) {
    sub += v[i];
  }

  cout << sum - sub << endl;
  return 0;
}


Measured memory_bytes: 2548
/*ربى اصلح لى شأنى*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define el '\n';
long long  gcd(long long  a, long long  b) { return !b ? a : gcd(b, a % b); }
long long  lcm(long long a, long long  b) { return (a / gcd(a, b)) * b; }
long long  fact(long long  n) { return !n ? 1 : n * fact(n - 1); }
using namespace std;
const  double PI = acos(-1);
using lli = long long int;
/* smile ^_^ */
using namespace std;
void ezzo()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

}
lli mx(lli n, lli a[]){
	if (n == 0)return a[0];
	else return max(a[n - 1], mx(n - 1, a));
}
lli ar[2000];
int main()
{
	ezzo();
	lli a, b, x = 0; cin >> a >> b;
	x = abs(a - b);
	if (x & 1){
		cout << "IMPOSSIBLE" << el; return 0;
	}

	else{
		cout << (a + b) / 2 << el;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

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

  vector<ll> S(N);
  for (ll i = 0; i < Q; i++)
  {
    ll A;
    cin >> A;
    S.at(A - 1)++;
  }

  for (ll i = 0; i < N; i++)
  {
    cout << ((K - Q + S.at(i) > 0) ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
int n;
int d[51];
ll sum=0;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&d[i]);
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    {
    	sum+=((ll)d[i]*d[j]);
	}
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <queue>
typedef long long ll;
using namespace std;
int a[200005];
int maxs;
int main()
{
    int k,n;
    cin>>k>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        int q=a[i+1]-a[i];
        if(maxs<q)
        {
            maxs=q;
        }
    }
    int q=k-a[n-1]+a[0];
    if(maxs<q)
    {
        maxs=q;
    }
    cout<<k-maxs;
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A,A+N);
  cout << A[N-1]-A[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while (sc.hasNext()) {
      int a = sc.nextInt();
      int b = sc.nextInt();

      System.out.println(calcDigit(a, b));
    }
  }

  static int calcDigit(int a, int b) {
    return (int)Math.log10((double)(a + b)) + 1;
  }
}

Measured memory_bytes: 20412
a,b = map(int, input().split())
c = b*100
d = b*10000
e = b*1000000
f = b*100000000
g = b*10000000000
h = b*1000000000000
i = b*100000000000000
j = b*10000000000000000
k = b*1000000000000000000

while(a > abs(a-b)):
    if a > k:
        a = abs(a-k)
    elif a > j:
        a = abs(a-j)
    elif a > i:
        a = abs(a - i)
    elif a > h:
        a = abs(a - h)
    elif a > g:
        a = abs(a - g)
    elif a > f:
        a = abs(a - f)
    elif a > e:
        a = abs(a - e)
    elif a > d:
        a = abs(a - d)
    elif a > c:
        a = abs(a - c)
    else:
        a = abs(a-b)

print(a)

Measured memory_bytes: 3064
#include <stdio.h>
int main () {
  int n, i, x = 1;
  int a[100001];
  scanf ("%d", &n);
  for (i = 1; i < n+1; ++i) {
    scanf ("%d", &a[i]);
  }
  int counter = 0;
  while (x != 2 && counter <= n) {
    x = a[x];
    counter += 1;
  }
  if (counter > n) {
    printf ("-1\n");
  } else {
    printf ("%d\n", counter);
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    while(true){
        int n;
        double s[1000];
        cin >> n;
        if(n==0) break;
        
        double sum=0;
        for(int i=0;i<n;i++){
            cin >> s[i];
            sum+=s[i];
        }
        double average=sum/n;
        double v=0;
        for(int i=0;i<n;i++){
            v+=(s[i]-average)*(s[i]-average);
        }
        v/=n;

        printf("%.12lf\n",sqrt(v));
    }
    
    return 0;
}


Measured memory_bytes: 3212
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;

  vll xs(n), ys(n);
  rep(i, n) cin >> xs[i] >> ys[i];

  map<ll, ll> rmpx, rmpy;

  {  // cx
    map<ll, ll> mp;
    rep(i, n) mp[xs[i]] = 0;
    ll j = 1;
    for (auto& x : mp) x.second = j++;
    rep(i, n) {
      ll tx = mp[xs[i]];
      rmpx[tx] = xs[i];
      xs[i] = mp[xs[i]];
    }
  }
  {  // cy
    map<ll, ll> mp;
    rep(i, n) mp[ys[i]] = 0;
    ll j = 1;
    for (auto& x : mp) x.second = j++;
    rep(i, n) {
      ll ty = mp[ys[i]];
      rmpy[ty] = ys[i];
      ys[i] = mp[ys[i]];
    }
  }

  vvll csum(n + 1, vll(n + 1, 0));
  rep(i, n) csum[ys[i]][xs[i]]++;

  rep(i, n) rep(j, n) csum[i + 1][j + 1] +=
      csum[i][j + 1] + csum[i + 1][j] - csum[i][j];

  ll yaruo = LONG_LONG_MAX;
  repLRE(x1, 1, n - 1) repLRE(y1, 1, n - 1) repLRE(x2, x1 + 1, n)
      repLRE(y2, y1 + 1, n) {
    ll num = csum[y2][x2] - csum[y1 - 1][x2] - csum[y2][x1 - 1] +
             csum[y1 - 1][x1 - 1];
    if (num >= k) {
      ll tmp = (rmpx[x2] - rmpx[x1]) * (rmpy[y2] - rmpy[y1]);
      chmin(yaruo, tmp);
    }
  }

  cout << yaruo << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int p,q,r,a,b,c;
    scanf("%d %d %d",&p,&q,&r);
  a=p+q;
  b=p+r;
  c=q+r;

  if(a<=b && a<=c){
    printf("%d",a);
  }
  else if(b<a && b<c){
    printf("%d",b);
  }
  else
    printf("%d",c);

return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for (int i = 0; i < M; ++i)
    cin >> p[i] >> S[i];
  vector<int> WA(N + 1);
  vector<bool> problem(N + 1);
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < M; ++i) {
    if (!problem[p[i]] && S[i] == "WA")
      ++WA[p[i]];
    if (!problem[p[i]] && S[i] == "AC")
      problem[p[i]] = true, ++ans1, ans2 += WA[p[i]];
  }
  cout << ans1 << ' ' << ans2 << endl;
}


Measured memory_bytes: 6528
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_Q 100000
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> A(N, 0);
  rep(i, Q) {
    int a;
    cin >> a;
    a--;
    A[a]++;
  }

  rep(i, N) {
    ll X = K - (Q - A[i]);
    if (X > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#define N 1000000007
long long a[1000000];
int main()
{
	int n;
	cin>>n;
	long long m[10000000];
	for(int i=1;i<=n;i++)
	{
		
		cin>>a[i];
		m[i]=(m[i-1]+a[i]);
	}
	long long sum=0;
	for(int i=3;i<=n;i++)
	{
		/*
		long long a=(m[i]-m[i-1])%N;
		long long b=(m[n-1]-m[i])%N;
//		cout<<i+1<<":   a-"<<a<<"  b-"<<b<<endl;
		long long q=(a*b)%N;
		sum+=q%N;
		sum=sum%N;
		*/
		sum+=(a[i]%N)*(m[i-1]%N)%N;
		sum%=N;
	}
	
	sum+=(a[1]%N)*(a[2]%N);
	sum%=N;
	cout<<sum;
}

Measured memory_bytes: 6728
fun main(args: Array<String>) {
    val l1 = readLine()!!.split(" ").map{ it.toInt() }
    val h = l1[0]
    val w = l1[1]
    var sarr = arrayOfNulls<List<String>>(h)
    for (i in 0 until h) {
        sarr[i] = readLine()!!.split("").subList(1, w+1)
    }
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (sarr[i]!![j] == "#") {
                print("#")
            } else {
                var cnt = 0
                if (i > 0 && j > 0) if (sarr[i-1]!![j-1] == "#") cnt++
                if (i > 0) if (sarr[i-1]!![j] == "#") cnt++
                if (i > 0 && j < w-1) if (sarr[i-1]!![j+1] == "#") cnt++
                if (j > 0) if (sarr[i]!![j-1] == "#") cnt++
                if (j < w-1) if (sarr[i]!![j+1] == "#") cnt++
                if (i < h-1 && j > 0) if (sarr[i+1]!![j-1] == "#") cnt++
                if (i < h-1) if (sarr[i+1]!![j] == "#") cnt++
                if (i < h-1 && j < w-1) if (sarr[i+1]!![j+1] == "#") cnt++
                print(cnt)
            }
            if (j == w-1) println()
        }
    }
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s;  cin >> s;
  vector<int> v(4);
  for(int i = 0 ; i < 4; i++)  v[i] = s[i] - '0';

  for(int bit = 0; bit < (1 << 3) ; bit++){
    int sum = v[0];
    for(int i = 0; i < 3 ; i++){
      if(bit & (1 << i))  sum += v[i + 1];
      else                sum -= v[i + 1];
    }

    if(sum == 7){
      cout << v[0];
      for(int i = 0; i < 3 ; i++){
        if(bit & (1 << i))  cout << '+' << v[i + 1];
        else                cout << '-' << v[i + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }

  return 0;
}


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

int N, S[15];
char cur, C[15];
vector<int> adj[15];
bool vis[15];
set<string> st;

void dfs(int n) {
	vis[n] = 1;
	assert(adj[n].size() <= 1);
	C[n] = cur + 'a';
	if (adj[n].size()) dfs(adj[n][0]);
}

void bf(int n, int s[]) {
	if (n == N) {
		memset(vis, 0, sizeof vis);
		for (int i = 1; i <= N; i++)
			adj[i].clear();
		for (int i = 1; i <= N; i++)
			if (s[i]) adj[s[i]].push_back(i);
		cur = 0;
		for (int i = 1; i <= N; i++)
			if (!vis[i]) dfs(i), cur++;
		string tmp = "";
		for (int i = 1; i <= N; i++) tmp.push_back(C[i]);
		st.insert(tmp);
		return;
	}
	for (int i = n + 1; i <= N; i++) {
		if (s[i]) continue;
		s[i] = n;
		bf(n + 1, s);
		s[i] = 0;
	}
	bf(n + 1, s);
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	bf(1, S);
	for (auto i : st) cout << i << '\n';
}


Measured memory_bytes: 14208
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll t;cin>>t;
  rep(i,t){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b > d){
      cout<<"No"<<endl;
      continue;
    }
    if(b > a){
      cout<<"No"<<endl;
      continue;
    }
    if(b <= c){
      cout<<"Yes"<<endl;
      continue;
    }

    ll rui = 1;
    while(a - c > b * rui){
      rui *= 2;
    }
    while(rui >= 1){
      if(a - b * rui > c){
        a -= b * rui;
      }
      rui /= 2;
    }
    ll gg = gcd(b,d);
    rui = 1;
    while(a - c > gg * rui){
      rui *= 2;
    }
    while(rui >= 1){
      if(a - gg * rui > c){
        a -= gg * rui;
      }
      rui /= 2;
    }

    if(a - b >= 0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
Var i,n,j,rem,fin:Longint;
    a:Array[1 .. 10000] of Longint;
Begin
    Readln(n);
    Fillchar(a,sizeof(a),0);
    fin:=1;
    For i:=1 to n do begin
        rem:=i;
        For j:=2 to rem do
            While rem mod j = 0 do begin
                Inc(a[j]);
                rem:=rem div j;
            End;
    End;
    For i:=1 to n do fin:=fin*(a[i]+1) mod 1000000007;
    Writeln(fin);
End.

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 2e5+10;
const int INF = 1e9;
vi S, T;
set<ll> pos[26];

bool check() {
    ll s = 0, t = 0;
    FORE (x, S) s |= (1<<x);
    FORE (x, T) t |= (1<<x);
    return (s | t) == s;
}

ll solve() {
    if (!check()) return -1;

    int M = S.size();
    REP (i, M) {
        pos[S[i]].insert(i);
    }

    ll ans = 0;
    FORE (t, T) {
        auto it = pos[t].lower_bound(ans%M);
        if (it == pos[t].end()) {
            ans = ((ans / M) + 1) * M + *pos[t].begin();
        } else {
            ans = ans / M * M + *it;
        }
        ans++;
    }
    return ans;
}

int main() {
    string s, t;
    cin >> s >> t;
    REP (i, s.size()) S.PB(s[i] - 'a');
    REP (i, t.size()) T.PB(t[i] - 'a');
    cout << solve() << endl;
}

Measured memory_bytes: 6648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[][] minD = new long[n][n];
    long[][] ansD = new long[n][n];
    long sum = 0;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        minD[i][j] = sc.nextLong();
        ansD[i][j] = minD[i][j];
      }
    }
    long ans = -1;
    boolean flg = true;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        for(int k = 0; k < n; k++) {
          if((i != j) && (i != k) && (j != k)) {
            if((minD[i][j] > (minD[i][k] + minD[k][j])) || (minD[i][k] > (minD[i][j] + minD[j][k])) || (minD[j][k] > (minD[j][i] + minD[i][k]))) flg = false;
          }
        }
      }
    }
    if(flg) {
      for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
          for(int k = 0; k < n; k++) {
            if((i != j) && (i != k) && (j != k)) {
              if(minD[i][j] == (minD[i][k] + minD[k][j])) ansD[i][j] = 0;
              if(minD[i][k] == (minD[i][j] + minD[j][k])) ansD[i][k] = 0;
              if(minD[j][k] == (minD[j][i] + minD[i][k])) ansD[j][k] = 0;
            }
          }
        }
      }
      for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
          sum += ansD[i][j];
        }
      }
      ans = sum;      
    }
    System.out.println(ans);
  }
}

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

int main() {
    int N[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    
        cin>>k;
        
        cout<<N[k-1]<<endl;
    
	return 0;
}



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

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> h(N + K + 5), dp(N + K + 5, 1e10);
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    dp[1] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= K; j++) {
            dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j]);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int count=0;
    string s,t;

    cin>>s>>t;

    FOR(i,0,2){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int []arr=new int[2];
		int c=0;
		for(int i=0;i<2;i++) {
			arr[i]=sc.nextInt();
		}
		while (arr[0]>0) {
			arr[0]=arr[0]-arr[1];
			c++;
		}
		System.out.println(c);
	}
	
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ( (b-a) & 1 ) {
        //홀수
        cout << "Borys\n";
    } else {
        cout << "Alice\n";
    }
	return 0;
}



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


int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++) cin >> d[i];

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

    int res = d[(N/2)] - d[(N/2)-1];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm> 
using namespace std;
int c,ans;
int w[100001];
int ab(int k){
	if(k<0)k=-k;
	return k;
}
int main(){
	int i,j,k,l1,l2,m,n,p=-1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%lld",&w[i]);
	if(w[i]>c)c=w[i];
}
printf("%d ",c);
l1=(c+1)/2;
for(i=1;i<=n;i++){
if(w[i]!=c){
	l2=ab(l1-w[i]);
	if(l2>ab(c-l1-w[i]))l2=ab(c-l1-w[i]);
 if((p<0)||(l2<p)){
 p=l2;
 j=w[i]; 
} 
}
}
printf("%d",j);
	
	
		return 0;
	}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        char[] string = sc.next().toCharArray();
        int x = 0;
        int maxX = x;
        for (char c : string) {
            switch (c) {
            case 'I':
                x++;
                break;
            case 'D':
                x--;
                break;
            }

            maxX = Math.max(maxX, x);
        }

        System.out.println(maxX);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,C;cin >> N >> C;
    int D[C][C];REP(i,C) REP(j,C) cin >> D[i][j];
    int c[N][N];REP(i,N) REP(j,N) cin >> c[i][j];
    vector<int> V[3];
    REP(k,C){
        int X = 0,Y = 0,Z = 0;
        REP(i,N){
            REP(j,N){
                if((i+j)%3 == 0){
                    X += D[c[i][j]-1][k];
                }
                else if((i+j)%3 == 1){
                    Y += D[c[i][j]-1][k];
                }
                else if((i+j)%3 == 2){
                    Z += D[c[i][j]-1][k];
                }
            }
        }
        V[0].pb(X);V[1].pb(Y);V[2].pb(Z);
    }
    int ans = INF;
    REP(one,C){
        REP(two,C){
            if(one == two) continue;
            REP(three,C){
                if(one == three || two == three) continue;
                int cnt = V[0][one] + V[1][two] + V[2][three];
                ans = min(ans,cnt);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(2);
  
  using P = pair<int, double>;
  vector<P> g[4];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 8; j++) {
      int p;
      double t;
      cin >> p >> t;
      g[i].emplace_back(p, t);
    }
    sort(g[i].begin(), g[i].end(), [&](P a, P b) {
      return a.second < b.second;
    });
    for (int j = 2; j < 8; j++) {
      g[3].emplace_back(g[i][j]);
    }
  }
  sort(g[3].begin(), g[3].end(), [&](P a, P b) {
    return a.second < b.second;
  });
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 2; j++) {
      cout << g[i][j].first << " " << g[i][j].second << endl;
    }
  }

  return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;

  LL T = 0, px = 0, py = 0;
  REP(i,N){
	LL t, x, y;
	cin >> t >> x >> y;
	LL dt = t - T;
	LL dx = abs(px - x) + abs(py - y);
	if(dx > dt || (dt - dx)%2 == 1){
	  cout << "No" << endl;
	  return 0;
	}

	T = t;
	px = x;
	py = y;
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, W, H;
  while(cin >> N >> W >> H, W){
	vector<PII> q;
	q.PB(MP(W,H));
	REP(i,N){
	  int p, s; cin >> p >> s; --p;
	  PII pii = q[p]; q.erase(q.begin()+p);
	  PII n1, n2;
	  s %= (pii.first+pii.second);
	  if(s < pii.first){
		n1 = MP(min(s,pii.first-s), pii.second);
		n2 = MP(max(s,pii.first-s), pii.second);
	  }
	  else if(s < pii.first+pii.second){
		s -= pii.first;
		n1 = MP(pii.first, min(s,pii.second-s));
		n2 = MP(pii.first, max(s,pii.second-s));
	  }
	  else if(s < pii.first*2+pii.second){
		s -= pii.first + pii.second;
		n1 = MP(min(s,pii.first-s), pii.second);
		n2 = MP(max(s,pii.first-s), pii.second);
	  }
	  else{
		s -= pii.first*2 + pii.second;
		n1 = MP(pii.first, min(s,pii.second-s));
		n2 = MP(pii.first, max(s,pii.second-s));
	  }
	  q.PB(n1); q.PB(n2);
	}

	VI ans;
	REP(i,SZ(q))
	  ans.PB(q[i].first*q[i].second);
	SORT(ans);

	cout << ans[0];
	FOR(i, 1, SZ(ans))
	  cout << " " << ans[i];
	cout << endl;
  }
  
  
  return 0;
}

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

using namespace std;

int main(void) {
    long n;
    cin >> n;

    auto q = [&](long i) {
        cout << i << endl;
        cout << flush;
        string s;
        cin >> s;
        if(s == "Vacant") {
            exit(0);
        }
        if(s == "Male")   return 0;
        if(s == "Female") return 1;
        assert(false);
    };

    long lb = 0, ub = n;
    long sl = q(lb);
    while(1) {
        long m = (lb+ub)/2;

        long sm = q(m);
        if(((m-lb)&1) ^ (sl == sm))
            lb = m, sl = sm;
        else
            ub = m;
    }
}


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

void solve() {
    double r;
    cin >> r;
    cout << r * 2 * 3.1415 << endl;
}


Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, s, a, ans, M=998244353, d[3005]={1};
int main() {
	cin >> n >> s;
	while(n--) {
		scanf("%lld", &a);
		if(s >= a) (ans += d[s-a] * (n+1)) %= M;
		for(ll i=s-a-1; i>=0; i--) (d[i+a] += d[i]) %= M;
		d[0]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll N, R;
  cin >> N >> R;

  if (N >= 10) drop(R);

  rep1(in, 1e5) {
    if (in - 100 * (10 - N) == R) {
      drop(in);
    }
  }

  return 0;
}


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

const int N = 200005, M = 4005, mod = 1000000007;
typedef long long LL;
int n, a[N], b[N], ans;

int dp[M][M], factor[M << 1], ifactor[M << 1];
int& t(int x, int y) { return dp[x + 2000][y + 2000]; }
void reduce(int &x) { x += x >> 31 & mod; }
void add(int &x, int y) { x += y - mod, x += x >> 31 & mod; }

int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}
void init(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i) factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[n] = pow(factor[n], mod - 2);
	for (int i = n; i; --i) ifactor[i - 1] = (LL) ifactor[i] * i % mod;
}
int C(int x, int y) { return (LL) factor[x] * ifactor[y] % mod * ifactor[x - y] % mod; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, ans = 0, init(8000);
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i] >> b[i], ++t(-a[i], -b[i]);
	for (int i = -2000; i <= 2000; ++i)
		for (int j = -2000; j <= 2000; ++j)
			add(t(i + 1, j), t(i, j)), add(t(i, j + 1), t(i, j));
	for (int i = 1; i <= n; ++i) add(ans, t(a[i], b[i]));
	for (int i = 1; i <= n; ++i)
		reduce(ans -= C(a[i] + b[i] << 1, a[i] << 1));
	std::cout << (LL) ans * (mod + 1 >> 1) % mod << '\n';
	return 0;
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  int ans = 0;
  while (n) {
    ++ans;
    n /= k;
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#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 H;
  cin >> H;
  
  ll ans = 0;
  
  rep(i,100){
    if ( H == 1 ) {
      ans =1;
      break;
    }
    if ( pow(2,i)<= H && pow(2,i+1) > H ){
      ans = pow(2,i+1)-1;
      break;
    }
  }
  
  cout << ans << endl;
    
}
  


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

const int MAX_N = 100000;
std::vector<int> list;

bool IsPrime(int n){ 
   for(int i=0; i<list.size(); ++i){
      if(n%list[i]==0) return false;
   }   
   list.push_back(n);
   return true;
}

bool IsPrime2(int n){ 
   for(int i=0; i<list.size(); ++i){
      if(n==list[i]) return true;
   }   
   return false;
}

int main(){
   int Q;
   std::cin >> Q;
   int l[Q], r[Q];
   for(int i=0; i<Q; ++i)
      std::cin >> l[i] >> r[i];

   int x[MAX_N+1];
   x[0] = 0;
   x[1] = 0;
   for(int i=2; i<=MAX_N; ++i){
      if(IsPrime(i) && IsPrime2((i+1)/2)){
         x[i] = x[i-1] + 1;
      }else{
         x[i] = x[i-1];
      }
   }

   for(int i=0; i<Q; ++i){
      std::cout << x[r[i]]-x[l[i]-1] << std::endl;
   }
   return 0;
}

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

int main(){
	int N;
	cin >> N;
	for(int X=1;X<=50000;X++){
		if(N*100<=X*108 && X*108<(N+1)*100){
			cout << X << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if S == 'ABC':
    print('ARC')
elif S == 'ARC':
    print('ABC')


Measured memory_bytes: 10564
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s1,s2;
    cin >> s1 >> s2;

    if(s1.at(0) == s2.at(2) && s1.at(1) == s2.at(1) && s1.at(2) == s2.at(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long 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;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	int ans = 0;
	int ansnumber = 1;
	for (int i = 1; i <= n; i++) {
		int a = i;
		int sum = 0;
		while (a % 2 == 0) {
			sum++;
			a = a / 2 + a % 2;
		}
		if (sum > ans) {
			ansnumber = i;
			ans = sum;
		}
	}
	cout << ansnumber;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  //AとBが直接会話できるか
  if(abs(a-b) <= d){
    //BとCが直接会話できるか
    if(abs(b-c) <= d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  //AとCが直接会話できるか
  else if(abs(a-c) <= d)
    cout << "Yes" << endl;
  //AとCは直接でも間接でも会話できない
  else
    cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """
    if n<r:
        return 0
    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

S=list(input())

if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21644
def end():
    print(0)
    exit()

mod = 10**9+7
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
t1 = [0]*n
a1 = [0]*n
t1[0] = a1[-1] = 1

for i in range(1, n):
    if t[i-1] != t[i]:
        t1[i] = 1
    if a[n-1-i] != a[n-i]:
        a1[n-1-i] = 1

ans = 1
for i in range(n):
    if t1[i] and a1[i]:
        if t[i] != a[i]:
            end()
    elif t1[i]:
        if t[i] > a[i]:
            end()
    elif a1[i]:
        if t[i] < a[i]:
            end()
    else:
        ans *= min(t[i], a[i])
        ans %= mod
print(ans)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

inline vector<int> digit(unsigned long long n) {
  vector<int> ret;
  do { ret.push_back(n % 10); n /= 10; } while (n > 0);
  return ret;
}

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

  int n;
  cin >> n;

  int minv = INF;
  for (int a = 1; a <= n-1; ++a) {
    int b = n - a;
    int a_sum = 0, b_sum = 0;

    for (auto e : digit(a)) a_sum += e;
    for (auto e : digit(b)) b_sum += e;

    chmin(minv, a_sum + b_sum);
  }

  cout << minv << "\n";

  return 0;
}

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

int main() {
  double n;
  cin >> n;
  cout << 2 * n * M_PI << endl;
}

Measured memory_bytes: 3760
a =int(input())
b =int(input())
c =int(input())
x =int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500 + j*100 + k*50 == x:
        ans+=1
print(ans)

Measured memory_bytes: 3060
n = int(input())
edge = []
for _ in range(n-1):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,c])
q, k = map(int,input().split())
querry = []
for _ in range(q):
    x,y = map(int,input().split())
    querry.append([x-1,y-1])
    

class Graph():
    def __init__(self,n,edge):
        self.n = n
        self.edge = edge
        self.ed_list = [[] for _ in range(n)]
        for a,b,c in edge:
            self.ed_list[a].append([b,c])
            self.ed_list[b].append([a,c])
    
    def dijkstra(self,start):
        INF = float('inf')
        cost = [INF]*self.n
        cost[start] = 0
        from heapq import heappop,heappush
        stack = [[0, start]]
        while stack:
            c, x = heappop(stack)
            for to,j in self.ed_list[x]:
                if cost[to] > j + c:
                    cost[to] = j + c
                    heappush(stack,[j + c, to])
        return cost

gp = Graph(n,edge)
cost = gp.dijkstra(k-1)
for i,j in querry:
    print(cost[i] + cost[j])



Measured memory_bytes: 85248
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=[]
q=[0 for i in range(n)]
for i in range(n):   
 p.append(i1())
 q[p[-1]-1]=i
k=1
s=0
for i in range(n-1):
  if q[i+1]-q[i]>0:
     k+=1
  else:
     s=max(s,k)
     k=1
s=max(s,k)
print(n-s)

Measured memory_bytes: 59596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=4010,P=998244353;
int n,k,a[maxn],fac[maxn],ifac[maxn],inv[maxn],ans;
inline int C(int a,int b){return 1ll*fac[a]*ifac[b]%P*ifac[a-b]%P;}
inline int calc(int n,int s){
        int k2=min(k-s/2,(s-1)/2),k1=k-k2*2-!(s&1),ans=0;
        rep(i,0,k2)
            if(i&1) ans=(ans-1ll*a[k2-i]*C(k2,i)%P*C(n+k1+k2-i-1,k1+k2-i-1)%P+P)%P;
            else ans=(ans+1ll*a[k2-i]*C(k2,i)%P*C(n+k1+k2-i-1,k1+k2-i-1)%P)%P;
        return ans;
    }
int main(){
    scanf("%d%d",&k,&n);
    a[0]=inv[1]=fac[0]=ifac[0]=1;
    rep(i,2,2*max(n,k)) inv[i]=1ll*(P-P/i)*inv[P%i]%P;
    rep(i,1,2*max(n,k)) a[i]=1ll*a[i-1]*2%P,fac[i]=1ll*fac[i-1]*i%P,ifac[i]=1ll*ifac[i-1]*inv[i]%P;
    rep(i,2,2*k){
        ans=calc(n,i);
        if(i%2==0) ans=(ans+calc(n-1,i))%P;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 384