akhauriyash/Code-Regression huggingface dataset:
#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
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
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;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

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

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = calc(a, b/2, p);
        return (d * d) % p;
    } else {
        return (a * calc(a, b-1, p)) % p;
    }
}
     
int main()
{
    string s; cin >> s;
    rep(i,s.length()) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int r, n;
		cin>>r>>n;
		if(r == 0 && n == 0) break;
		vector<int> _h(40, 0);
		REP(i, n) {
			int xl, xr, h;
			cin>>xl>>xr>>h;
			FOR(j, xl, xr) {
				_h[j + 20] = max(h, _h[j + 20]);
			}
		}
		long double lb = 0, ub = 21;
		int cnt = 0;
		while(cnt < 100) {
			long double mid = (lb + ub) / 2;
			bool def = true;
			REP(i, r) {
				if(_h[19 - i] - ((mid - r) + sqrt(r * r - i * i)) < - EPS) def = false;
				if(_h[20 + i] - ((mid - r) + sqrt(r * r - i * i)) < - EPS) def = false;
			}
			if(def) lb = mid;
			else ub = mid;
			++cnt;
		}
		cout<<fixed<<showpoint<<setprecision(39)<<lb<<endl;
	}
}

Measured memory_bytes: 3228
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>

using namespace std ;

typedef long long LL ;

map<string,int> Mp ;
string str ;
int n ;

inline string Sort_str ( string s )
{
	int Len=s.length() , i , j ;
	for ( i=0 ; i<Len ; i++ )
		for ( j=i+1 ; j<Len ; j++ )
			if ( s[j]>s[i] ) swap(s[i],s[j]);
	return s ;
}

int main ()
{
	int i ;
	LL res=0 ;
	cin >> n ;
	for ( i=1 ; i<=n ; i++ )
	{
		cin >> str ;
		str=Sort_str(str);
		res+=(LL)(Mp[str]),Mp[str]++;
	}
	printf("%lld\n",res);
	return 0 ;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxk = 2e5+5;
int fac[maxk], inv[maxk];

int pow(const int a, const int p)
{
    int ans = 1, x = a;
    FOR(i,0,31) {
        if (p & (1<<i)) 
            ans = 1LL * ans * x % mod;
        x  = 1LL * x * x % mod;
    }
    return ans;
}

int cnk(const int n, const int k)
{
    int ans = 1;
    FOR(i,0,k)
        ans = 1LL * ans * (n-i) % mod;
    ans = 1LL * ans * inv[k] % mod;
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    fac[0] = inv[0] = 1;
    FOR(i,1,maxk) {
        fac[i] = 1LL * i * fac[i-1] % mod;
        inv[i] = pow(fac[i], mod-2);
    }
    int n,a,b;
    while (cin >> n >> a >> b) {
        int ans = pow(2,n)-1;
        ans -= cnk(n,a);
        ans %= mod;
        ans -= cnk(n,b);
        ans %= mod;
        ans += mod;
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 1000008
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;


void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll check(ll n,ll b){
  ll ans=0;
  while (n>0){
    ans+=n%b;
    n/=b;
  }
  return ans;
}
int main() {
 ll n,s;
 cin>>n>>s;
 if(n<s){out(-1);return 0;}

  if (s==n) {
  out(n+1);
    return 0;
  }
  ll x=sqrt(n);
   for (ll i=2; i<=x; i++){
    if (check(n,i)==s){
      out(i);
      return 0;
    }
  }
   for (ll i=x; i>=1; --i){
    ll ch=((n-s)/i)+1;
    if (ch==1)continue;
    if (check(n,ch)==s){
      out(ch);
      return 0;
    }
  }
  out(-1);


 }





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

int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int a;
	scanf("%d",&a);
	if (400 <= a&&a < 600)
		printf("8");
	else if (600 <= a&&a < 800)
		printf("7");
	else if (800 <= a&&a < 1000)
		printf("6");
	else if (1000 <= a&&a < 1200)
		printf("5");
	else if (1200 <= a&&a < 1400)
		printf("4");
	else if (1400 <= a&&a < 1600)
		printf("3");
	else if (1600 <= a&&a < 1800)
		printf("2");
	else if (1800 <= a&&a < 2000)
		printf("1");

	return 0;
}//pd pdp

Measured memory_bytes: 1648
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Touitsu
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;
const int M = 3;

/* typedef */

/* global variables */

char ss[M][MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < M; i++) scanf("%s", ss[i]);

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int d = 0;
    for (int j = 0; j < M; j++)
      if (ss[j][i] == ss[(j + 1) % M][i]) d++;
    if (d == 0) cnt += 2;
    else if (d == 1) cnt++;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		char[][] c = new char[h][w];
		for (int i = 0; i < h; i++) {
			c[i] = sc.next().toCharArray();
		}
		sc.close();

		int h2 = 1 << h;
		int w2 = 1 << w;
		int ans = 0;
		for (int x = 0; x < h2; x++) {
			for (int y = 0; y < w2; y++) {
				int cnt = 0;
				for (int i = 0; i < h; i++) {
					if ((x >> i & 1) == 1) {
						continue;
					}
					for (int j = 0; j < w; j++) {
						if ((y >> j & 1) == 1) {
							continue;
						}
						if (c[i][j] == '#') {
							cnt++;
						}
					}
				}
				if (cnt == k) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 36236
import math

N,H = list(map(int,input().split()))

A=[]
B=[]
for n in range(N):
    a,b = list(map(int,input().split()))
    A.append(a)
    B.append(b)
    
A.sort(reverse=True)
B.sort(reverse=True)
A,B

a_max=A[0]

B_=[]
for b in B:
    if b < a_max:
        break
    B_.append(b)
B=B_

B_sum = [0]
for b in B:
    B_sum.append(B_sum[-1]+b)

ans = 0
for b_sum_idx,b_sum in enumerate(B_sum):
    if b_sum >= H:
        ans = b_sum_idx
        break
        
    ans = b_sum_idx
H = max(0,H - b_sum)

ans += math.ceil(H/a_max)

print(ans)

Measured memory_bytes: 98880
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

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

using namespace std;
typedef long long ll;

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int MAX = 210000;
ll 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;
    }
}

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

ll modpow(ll a, ll n, ll MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, m, k; cin >> n >> m >> k;
    COMinit();

    // ((x_dist * n * n + y_dist * m * m) / 2) * com(n*m-2, k-2)
    ll x_dist = 0;
    rep(i, m) {
        if (i > 0) {
            x_dist += ll(1 + i) * ll(i) % MOD * inv[2];
            x_dist %= MOD;
        }
        if (i < m-1) {
            x_dist += ll(1 + m-i-1) * ll(m-i-1) % MOD * inv[2];
            x_dist %= MOD;
        }
    }
    ll y_dist = 0;
    rep(i, n) {
        if (i > 0) {
            y_dist += ll(1 + i) * ll(i) % MOD * inv[2];
            y_dist %= MOD;
        }
        if (i < n-1) {
            y_dist += ll(1 + n-i-1) * ll(n-i-1) % MOD * inv[2];
            y_dist %= MOD;
        }
    }
    
    x_dist *= n;
    x_dist %= MOD;
    x_dist *= n;
    x_dist %= MOD;

    y_dist *= m;
    y_dist %= MOD;
    y_dist *= m;
    y_dist %= MOD;

    ll ans = ((x_dist + y_dist) % MOD * inv[2] % MOD) * COM(n*m-2, k-2) % MOD;

    cout << ans << endl;


    return 0;
}


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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
#define MOD               998244353

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N, S;
	cin >> N >> S;
	VL A(N);
	REP(i, N) cin >> A[i];
	
	VVL dp(N + 1, VL(S + 3005, 0));
	dp[0][0] = 1;
	REP(i, N) {
		REP(j, S + 1) {
			if (dp[i][j]) {
				dp[i + 1][j] += dp[i][j] * 2;
				dp[i + 1][j + A[i]] += dp[i][j];
				dp[i + 1][j] %= MOD;
				dp[i + 1][j + A[i]] %= MOD;
			}
		}
	}

	cout << dp[N][S] << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 144168
N = int(input())
p_ls = [int(i) for i in input().split()]
gold_p_ls = sorted(p_ls)
_start = None
_end = None
for i, p in enumerate(p_ls):
    if i + 1 != p:
        _start = i
        break

for j, p in enumerate(p_ls[::-1]):
    if N - j != p:
        _end = N - 1 - j
        break

if _start is None:
    print("YES")
else:
    tmp = p_ls[_start]
    p_ls[_start] = p_ls[_end]
    p_ls[_end] = tmp
    if p_ls == gold_p_ls:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n;
ll a[100100], b[100100];

int main(){
	ll ans = 0, buf = 0;
	cin >> n;
	REP(i, n){
		cin >> a[i] >> b[i];
	}
	for (ll i = n - 1; i >= 0; i--){
		if (b[i] == 1)continue;
		if ((a[i] + buf) % b[i] == 0)continue;
		ans += ((a[i] + buf) / b[i] + 1)*b[i] - (a[i] + buf);
		buf = ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n = gets.to_i
a = n.times.map { gets.to_i }
sum = 0
maxa = 0
n.times do |i|
  if i.zero?
    sum = a[0].pred
    a[0] = 1
  else
    if a[i] <= maxa.succ
    else
      t = a[i] / maxa.succ
      f = a[i] % maxa.succ
      if f.zero?
        a[i] = 1
        sum += t.pred
      else
        a[i] = f
        sum += t
      end
    end
  end
  maxa = [a[i], maxa].max
end

p sum



Measured memory_bytes: 3124
S = input()
k = 1
pre = S[0]
n = len(S)
check = False
for i in range(1, n):
    if check:
        check = False
        continue
    k += 1
    if S[i] == pre:
        if i == n-1:
            k -= 1
            break
        pre = S[i] + S[i+1]
        check = True
    else:
        pre = S[i]

print(k)


Measured memory_bytes: 3500
import collections
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を文字列として読み込み
    # s = list(input().rstrip())
    
    # 位置文字ずつ標準入力を数値配列として読み込み
    # X = [int(_) for _ in input().split()]
    X = [int(_) for _ in input().split()]
    if X[0] == X[1] and X[0] == X[2] and X[1] == X[2]:
        ans = 1
    elif X[0] == X[1] or X[0] == X[2] or X[1] == X[2]:
        ans = 2
    else:
        ans = 3
    print(ans)


    # c = collections.Counter(X)
    # print(c.most_common()[0][1])
        
   
if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long

void solve() {
    int a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

using namespace std;

const int N = 55;

char s[N];

int main() {
  int a, b, v, w;
  scanf("%d %d", &a, &v);
  scanf("%d %d", &b, &w);
  int t;
  scanf("%d", &t);
  int d = abs(a - b);
  if (v <= w) {
    puts("NO");
    return 0;
  }
  int dv = v - w;
  puts(((long long)dv * t >= d) ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> b(N - 1);
    for (auto &&i : b) {
        cin >> i;
    }

    ll ans = 0;
    vector<int> a(N);
    a[0]     = b[0];
    a[N - 1] = b[N - 2];
    FOR(i, 1, N - 1) { a[i] = min(b[i], b[i - 1]); }
    for (auto &&i : a) {
        ans += i;
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int  main()
{


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double a, b, x, y;
	cin >> a >> b >> x >> y;
	if ((x + x ) == a && (y + y) == b)
		printf("%0.12f 1", a * b / 2.0);
	else
		printf("%0.12f 0", a * b / 2.0);

}

Measured memory_bytes: 256
fun main(args: Array<String>) {


    val (a, p) = readLine()!!.split(' ').map(String::toLong)
    val max = ((a * 3) + p) / 2
    println(max)

}

fun readList() = readLine()!!.split(' ')
fun readLongList() = readList().map(String::toLong)

fun readLong() = readLine()!!.toLong()
fun readString() = readLine()!!

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

Measured memory_bytes: 38300
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define T pair<int, int>
#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n;
    cin >> n;
    while(n > 0){
        int x = n%10;
        if(x == 7){
            puts("Yes");
            return 0;
        }
        n /= 10;
    }
    puts("No");
}

Measured memory_bytes: 3608
s = input()
flag = False
for i in range(len(s)):
    if s[i] == "C":
        flag = True
        break


if flag:
    flag = False
    for j in range(len(s)-1, -1, -1):
        if s[j] == "F":
            flag = True
            break

print("Yes" if (flag and i < j) else "No")


Measured memory_bytes: 2940
#include <iostream>
//#include <random>
//#include <fstream> //iostreamのファイル入出力をサポート
#include <vector>
#include <algorithm>
//#include <string>
//#include <math.h> 
//#include <time.h>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define vs vector<string>
#define VI vector<int>
#define vi vector<int>
using namespace std;

int main(){
	int N,i,b;
	cin>>N;

	vi a;
	rep(i,N){
		cin>>b;
		a.pb(b);
	}
	sort(all(a));
	b=a[N-1]-a[0];
	cout<<b<<endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		//System.out.println(Arrays.toString(a));
		
		// 計算
		int result = 0;
		if(n == 1 && a[0] == 1){
		    System.out.println(1);
		    return;
		}
		if(n > 1 && a[0] == 1 && a[1] == 1){
		    System.out.println(0);
		    return;
		}
		
		if(n > 1 && a[0] == 1 && a[1] != 1){
		    System.out.println(1);
		    return;
		}
		
		int[] seive = new int[1000001];
		Arrays.fill(seive, -1);
		int[] check = new int[1000001];
		for(int i = 0; i < n; i++){
		    int p = a[i];
		    if(check[p] == 1){
		        result--;
		        check[p]++;
		        continue;
		    }
			if(seive[p] != -1) continue;
			seive[p] = p;
			result++;
			check[p]++;
			for(long j = p; j <= 1000000; j += p){
				if(seive[(int)j] == -1) seive[(int)j] = p; 
			}
		}

		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 49472
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  vector<int> A(5);
  rep(i,5) cin>>A[i];

  rep(i,5){
    if(A[i]==0){
      cout<<i+1<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int *hanahuda, n, r, p, c;

void initHanahuda(){
	int i;
	hanahuda = (int *)malloc(sizeof(int) * n+1);
	for(i = 1; i <= n; i++){
		hanahuda[i] = n-i+1;
	}
}

void shuffle(int p, int c){
	int i;
	int *tmparray = (int *)malloc(sizeof(int) * c+1);
	//取り出した札をtmparrayに保管
	for(i = 1; i <= c; i++){
		tmparray[i] = hanahuda[p+i-1];
	}
	//取った札を下に下ろす
	for(i = 1; i <= p-1; i++){
		hanahuda[p-i+c] = hanahuda[p-i];
	}
	//一時的に保管した札を上に載せる
	for(i = 1; i <= c; i++){
		hanahuda[i] = tmparray[i];
	}
}

int main(void){
	while(1){
		scanf("%d%d", &n, &r);
		if(n==0 && r==0)	break;
		initHanahuda();
		int i;
		for(i = 0; i < r; i++){
			scanf("%d%d", &p, &c);
			shuffle(p, c);
		}
		printf("%d\n", hanahuda[1]);
		free(hanahuda);
	}

	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)
#define be begin()
#define en end()
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;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  cout<<(c-a)*60+(d-b)-e<<endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#define MOD (1000000007)

static inline long mdadd(long a,long b){
    return (a+b) % MOD;
}

static inline long mdml(long a,long b){
    long long res  = (long long)a * b;
    return res % MOD;
}

static inline long mdpow(long num,long ind){
    unsigned long c = (unsigned long)ind;
    long res = 1l;
    while(c){
        if(c & 1u)res = mdml(res,num);
        num = mdml(num,num);
        c >>= 1;
    }
    return res;
}

static inline long mdnck(long n,long k){
    long tmp = 1;
    register long i;
    for(i = 1;i <= k;i++)tmp = mdml(tmp,i);
    for(i = 1;i <= (n-k);i++)tmp = mdml(tmp,i);
    tmp = mdpow(tmp,MOD - 2);
    long tmp2 = 1;
    for(i = 1;i <= n;i++)tmp2 = mdml(tmp2,i);
    return mdml(tmp,tmp2);
}

int main(void){
    long x,y;
    scanf("%ld %ld",&x,&y);
    if((x+y)%3){
        puts("0");
        return 0;
    }
    long n,k;
    n = (2 * y - x) / 3;
    k = (2 * x - y) / 3;
    if(n < 0 || k < 0){
        puts("0");
        return 0;
    }
    printf("%ld",mdnck(n+k,k));
    return 0;
}

Measured memory_bytes: 128
S = input ()
S = S.replace('A', 'a')
S = S.replace('T', 'a')
S = S.replace('C', 'a')
S = S.replace('G', 'a')
ans = 0
x = 0
for i in range (len(S)):
  if S[i] == 'a':
    x += 1
  else:
    if ans < x:
      ans = x
    x = 0
if ans < x:
  ans = x
print (ans)

Measured memory_bytes: 8944
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,head,tail,prev,next,tmp;
	vector<int> A;
	unsigned long long t_ans=0;

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> tmp;
		A.push_back(tmp);
	}

	for(int i=0;i<N;i++){
		if(i==0) t_ans += abs(A[i]);
		else t_ans += abs(A[i] - A[i-1]);
	}
	t_ans += abs(A[N-1]);


	for(int i=0;i<N;i++){
		unsigned long long ans = t_ans;
		if(i == 0){
			ans -= abs(A[0]);
			ans -= abs(A[1] - A[0]);
			ans += abs(A[1]);
		}else if(i == N-1){
			ans -= abs(A[N-1] - A[N-2]);
			ans -= abs(A[N-1]);
			ans += abs(A[N-2]);
		}else{
			ans -= abs(A[i+1] - A[i]);
			ans -= abs(A[i] - A[i-1]);
			ans += abs(A[i+1] - A[i-1]);
		}
		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int n;
    int v[51],c[51];
    int sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
        if(v[i]-c[i]>0)
            sum+=v[i]-c[i];
    }
    cout<<sum<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long	ll;
 
typedef pair< ll, ll >	pll;
map< pll, ll > cnt;
 
const int N = int(2e5) + 100;
ll a[N], b[N];
const ll mod = ll(1e9) + 7LL;
 
ll fast_pow(ll x, ll e){
	ll b = x;
	ll r = 1LL;
 
	while(e){
		if(e & 1LL){
			r = (r * b) % mod;
		}
 
		e >>= 1LL;
		b = (b * b) % mod;
	}
 
	return r;
}
 
int main(){
	int n;
 
	scanf("%d", &n);

	ll joker = 0LL;
 
	for(int i = 0 ; i < n ; i++){
		scanf("%lld %lld", &a[i], &b[i]);
 
		if(a[i] == 0 && b[i] == 0){
			joker++;
			continue;
		}
		
		ll g = __gcd(a[i], b[i]);	
		a[i] /= g;
		b[i] /= g;
 
		if(a[i] < 0){
			a[i] *= -1LL;
			b[i] *= -1LL;
		}
 
		cnt[{a[i], b[i]}]++;
	}
 
	ll tot = 1LL;
	ll qtdg = 0;
	ll add = joker;
 
	for(auto u: cnt){
		if(u.first.second < 0){
			continue;
		}
 
		auto v = u.first;
		swap(v.first, v.second);
 
		v.second *= -1;
 
		// cout << u.first.first << " " << u.first.second << " | " << v.first << " " << v.second << endl;
 
		if(cnt.count(v) == 0){
			qtdg++;
		}else{
			add += cnt[u.first] + cnt[v];
 
			// cout << cnt[u.first] << " " << cnt[v] << " " << v.first << " " << v.second << endl;
 
			tot = (tot * ((fast_pow(2LL, cnt[u.first]) + fast_pow(2LL, cnt[v]) - 1LL) % mod) % mod) % mod;
		}
	}
 	
	tot = (tot * fast_pow(2LL, ll(n) - add)) % mod;
	tot = ((tot - 1LL) % mod + mod) % mod;
	tot += joker;

	if(tot >= mod) tot -= mod;

	printf("%lld\n", tot);
 
	return 0;
}

Measured memory_bytes: 19384
#include<bits/stdc++.h>
 
#define hell2                         1000000007
#define hell                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=300005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

ll fact[MAX];
void f() {
	fact[0]=fact[1]=1;
	rep(i,2,MAX) {
		fact[i]=(fact[i-1]*i)%hell;
	}
}

ll expo(ll a, ll b, ll p) {
	ll res=1;
	a%=p;
	while(b>0) {
		if(b&1) {
			res=(res*a)%p;
		}
		a=(a*a)%p;
		b>>=1;
	}
	return res;
}

ll inv(ll a, ll p) {
	return expo(a, p-2, p);
}

ll C(ll x, ll y) {
	if(y==0) return 1;
	if(x<y) return 0; 
	return ((fact[x]*inv(fact[x-y], hell))%hell)*(inv(fact[y], hell))%hell;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    f();
    ll n,m,k;
    cin >> n >> m >> k;

    ll ans=0;
    rep(i,0,k+1) {
    	//i same;
    	ll same=C(n-1,i);
    	ll cost=m;
    	ll rem=n-i-1;
		cost=(cost*expo(m-1,rem,hell))%hell;
		cost=(cost*same)%hell;
    	ans=(ans+cost)%hell;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6000
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

d = Counter(readInts())

d = [i for i in sorted(d.items(), reverse=True) if i[1]>=2]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		pass
	else:
		print(0)
		exit()
if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))


Measured memory_bytes: 25680
#include <iostream>
#define NIL -1
using namespace std;

typedef struct
{
    int parent, left, right;
} Node;

Node T[25];

void GetParent(int n)
{
    for (int i = 0; i < n; i++)
    {
        if (T[i].right != NIL)
        {
            T[T[i].right].parent = i;
        }
        if (T[i].left != NIL)
        {
            T[T[i].left].parent = i;
        }
    }
}

void Preorder(int u)
{
    if (u == NIL)
    {
        return;
    }
    cout << ' ' << u;
    Preorder(T[u].left);
    Preorder(T[u].right);
}

void Inorder(int u)
{
    if (u == NIL)
    {
        return;
    }
    Inorder(T[u].left);
    cout << ' ' << u;
    Inorder(T[u].right);
}

void Postorder(int u)
{
    if (u == NIL)
    {
        return;
    }
    Postorder(T[u].left);
    Postorder(T[u].right);
    cout << ' ' << u;
}

int main()
{
    int num;
    int id;
    int root;

    cin >> num;
    for (int i = 0; i < num; i++)
    {
        cin >> id;
        cin >> T[id].left >> T[id].right;
        T[id].parent = NIL;
    }

    GetParent(num);

    for (int i = 0; i < num; i++)
    {
        if (T[i].parent == NIL)
        {
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    Preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    Inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    Postorder(root);
    cout << endl;

    return 0;
}



Measured memory_bytes: 3108
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    #A, B, C = map(int, input().split())
    N = int(input())

    num = 0
    for i in [1, 3, 5]:
        base = 10 ** i
        if N >= base:
            num += 9 * 10 ** (i - 1)

        if N >= 10 ** (i - 1)\
            and N < 10 ** i:
            remain = N - 10 ** (i - 1) + 1
            num += remain

    print(num)

if __name__ == '__main__':
    main()


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

int main(){
    int a,b,ans;
    cin >> a >> b;
    if(a>=13){
        ans = b;
    }else if(a<=5){
        ans = 0;
    }else{
        ans = b/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var HW = ReadLine().Split().Select(int.Parse).ToArray();
        int H = HW[0];
        int W = HW[1];
        int N = int.Parse(ReadLine());
        var a = ReadLine().Split().Select(int.Parse).ToArray();

        var c = new int[H, W];
        bool f = true;
        int index = 0;
        for (int i = 0; i < H; i++)
        {
            if (f)
            {
                for (int j = 0; j < W; j++)
                {
                    if (a[index] == 0)
                    {
                        index++;
                        j--;
                        continue;
                    }
                    else
                    {
                        c[i, j] = index + 1;
                        a[index]--;
                    }
                }
            }
            else
            {
                for (int j = W - 1; j >= 0; j--)
                {
                    if (a[index] == 0)
                    {
                        index++;
                        j++;
                        continue;
                    }
                    else
                    {
                        c[i, j] = index + 1;
                        a[index]--;
                    }
                }
            }
            f = !f;
        }

        for (int i = 0; i < H; i++)
        {
            string line = "";
            for (int j = 0; j < W; j++)
            {
                line += c[i, j] + " ";
            }
            WriteLine(line.Substring(0,line.Length-1));
        }
    }
}


Measured memory_bytes: 34172
//Created by Aminul on 3/28/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(solve(in.next().toCharArray()));
        pw.close();
    }

    static String solve(char s[]) {
        return s[2] == s[3] && s[4] == s[5] ? "Yes" : "No";
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 21588
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		List<String> a = new ArrayList<>();
		for(int i = 0; i < h; i++) {
			String x = sc.next();
			boolean f = false;
			for(int j = 0; j < w; j++) {
				if(x.charAt(j) == '#') f = true;
			}
			if(f) {
				a.add(x);
			}
		}
		List<Integer> b = new ArrayList<>();
		for(int i = 0; i < w; i++) {
			boolean f = false;
			for(int j = 0; j < a.size(); j++) {
				if(a.get(j).charAt(i) == '#') f = true;
			}
			if(!f) {
				b.add(i);
			}
		}
		if(a.size() == 0) return;
		for(int i = 0; i < a.size(); i++) {
			for(int j = 0; j < a.get(0).length(); j++) {
				boolean f = false;
				for(int k = 0; k < b.size(); k++) {
					if(j == b.get(k)) f = true;
				}
				if(!f) System.out.print(a.get(i).charAt(j));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24916
import java.util.*;

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

        if (input.equals("")) {
            System.out.println("No");
            return;
        }

        input = input.replace("hi", "");

        if (input.length() == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972
import fractions as fr
import itertools as it
import collections as col
import heapq as hq
import sys
sys.setrecursionlimit(10**9)

"""
N=int(input())
W=list(map(int, input().split()))
ans=10**100
for T in range(1,N):
        S1=sum(W[:T])
        S2=sum(W[T:])
        ans = min(ans, abs(S1-S2))
print(ans)
"""
"""
P,Q,R=map(int, input().split())
print(min([P+Q, P+R, Q+R]))
"""
MOD=1000000007
N,M=map(int, input().split())
A=set()
for i in range(M):
        A.add(int(input()))

dp=dict()
dp[0]=1
dp[1]=0 if 1 in A else 1
for i in range(2, N+1):
        if i in A: dp[i] = 0
        else:
                m1=0 if (i-1) in A else dp[i-1]
                m2=0 if (i-2) in A else dp[i-2]
                dp[i]=(m1+m2) % MOD
print(dp[N])
"""

        print(i)
        if i in A: return 0
        if i in dp: return dp[i]
        m1=0 if (i-1) in A else f(i-1)
        m2=0 if (i-2) in A else f(i-2)
        dp[i]=(m1+m2) % MOD
        return dp[i]

print(f(N))
"""

Measured memory_bytes: 27348
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 998244353

ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        if(n%2==0)
        {
            ll res=fast(n/2,a);
            return (((res%M)*(res%M))%M);
        }
        else
        {
            ll res=fast(n/2,a);
            return (((((res%M)*a)%M)*res)%M);
        }
    }

}
const int N=1e6+5;
int d[N]={0};
void calc()
{
    int i,j;
    for(i=1;i<N;i++)
    {
        for(j=i;j<N;j+=i)
        {
            d[j]++;
        }
    }
}
int main()
{
   int n,i;
   cin>>n;
   int A[n],B[n];
   for(i=0;i<n;i++)
    cin>>A[i]>>B[i];

   int ans=0;
   for(i=0;i<n-2;i++)
   {
       if(A[i]==B[i]&&A[i+1]==B[i+1]&&A[i+2]==B[i+2])
       {
           ans=1;
           break;
       }
   }
   if(ans==1)
    cout<<"Yes";
   else
    cout<<"No";


}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0;
    vector<int> v(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> S;

    for(int i=0; i<4; i++){
	ans += (S[i]=='+') ? 1 : -1;
    }
    

    cout << ans << endl;
    // ans = a<=b ? a:a-1;

    
    // ans = min(A, B) + min(C, D);
    // cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(abs(a-b) <=d && (b-c) <=d ||abs(c-a)<=d)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string S[3];

void solve(){
	int c[3] = {};
	int n = 0;
	while(1){
		if(c[n] == S[n].size()){
			cout << char('A' + n) << endl;
			break;
		}
		c[n]++;
		n = S[n][c[n] - 1] - 'a';
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i, 3){
		cin >> S[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int F(ll a, ll b) {
  int x = max(a, b);
  for(int i = 1; true; i++) {
    x /= 10;
    if(x == 0) return i;
  }
}

int main() {
  ll N; int t = 11; cin >> N;
  for(ll i = 1; i <= 100000; i++) if(N % i == 0) t = min(t, F(i, N / i));
  cout << t << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            if(n == Math.pow(2,i)){
                System.out.println((int)Math.pow(2,i));
                break;
            }else if(n < Math.pow(2,i)){
                System.out.println((int)Math.pow(2,i-1));
                break;
            }
        }
    }
}


Measured memory_bytes: 21716
fun main(args: Array<String>) {
    val (x, y,z) = readLine()!!.split(" ").map{ it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    val l2 = readLine()!!.split(" ").map { it.toInt() }
    var a = l.min()!! + l2.min()!!
    for (i in 0 until z){
        val (alpha, bravo, charlie ) = readLine()!!.split(" ").map{ it.toInt() }
        val ticketUse =  l[alpha - 1] + l2[bravo - 1] - charlie
        if(a > ticketUse){
            a = ticketUse
        }
    }
    println(a)
}


Measured memory_bytes: 71872
A, B, C = map(int, input().split())

N = max(A, B, C) - min(A, B, C)

if A == B == C:
    if A % 2 == 0:
        print(-1)
        exit()
    else:
        print(0)
        exit()

for i in range(N):
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print(i)
        exit()
    a, b, c = (B + C) // 2, (C + A) // 2, (A + B) // 2
    A, B, C = a, b, c



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for (ll i=0;i<N;i++)
#define REP(i,N) for (ll i=1;i<=N;i++)
#define PI 3.14159265358979
ll N,M,A,B,C,ANS;
string S,T,U;
double n,m,a,b,c,ans;
 
int main() {
	cin>>a;
  cout<<2*a*PI;
	return 0;
}

Measured memory_bytes: 3788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(min(b,d) - max(a,c), 0) << endl;
}

Measured memory_bytes: 256
from sys import stdin
from math import sqrt
input = stdin.readline

N = int(input())

if N == 2:
    print(1)
    exit()

s = set([N - 1, N])


for i in range(2, int(sqrt(N)) + 1):
    tmp = N
    if (tmp - 1) % i == 0:
        s.add(i)
        s.add((tmp - 1) // i)
    elif tmp % i == 0:
        while tmp % i == 0:
            tmp //= i

        if tmp % i == 1:
            s.add(i)

        tmp = N
        while tmp % (N // i) == 0:
            tmp //= (N // i)

        if tmp % (N // i) == 1:
            s.add(N // i)

# print(s)
print(len(s))


Measured memory_bytes: 3064