akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  int cnt=0;
  cin>>s;
  rep(i,s.size()-1){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout<<cnt<<endl;
}
///////////////////////////

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<limits.h>
using namespace std;

int main(){
  string ss;
  int i,k=0,u=0,p=0,c=0,xmax=INT_MAX;
  cin >> ss;
  i=0;
  while(1){
    if(ss[i] == '\0')break;
    if(ss[i] == 'K')k++;
    else if(ss[i] == 'U')u++;
    else if(ss[i] == 'P')p++;
    else if(ss[i] == 'C')c++;
    i++;
  }


  xmax=min(xmax,min(k,min(u,min(p,c))));
  cout  << xmax << endl;



}

Measured memory_bytes: 0
#include<bits/stdc++.h>
        #define REP(i,n) for(int i=0;i<n;i++)
        #define LOOP(i,x,n) for(int i=x;i<n;i++)
        #define ALL(v) (v).begin(),(v).end()
        #define PB push_back
        #define MP make_pair
        #define FIR first
        #define UB upper_bound
        #define LB lower_bound
        #define int long long
        using namespace std;
        const int MOD=1000000007;
        const int INF=1000000009;
         
        signed main(){
          int n,k;
          cin>>n>>k;
          vector<int> a(n+1),b(n+1);
         
          int tmp=1;
          REP(i,n){
            int a=tmp*2;
            int b=tmp+k;
            tmp=min(a,b);
          }
          cout<<tmp<<endl;
          return 0;
        }

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int n,ans;double d;
int main(){
    scanf("%d%lf",&n,&d);
    for(int i=1;i<=n;i++){
        double x,y;scanf("%lf%lf",&x,&y);
        if(sqrt(pow(x,2)+pow(y,2))<=d) ++ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2184
#include <iostream>
#include <string>

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a[3];
	int str1;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	str1 = a[0];
	for (int i = 0; i < 3; i++) {
		for (int j = i+1; j < 3; j++) {
			if (a[i] > a[j]) {
				swap(a[i], a[j]);
			}
		}
	}
	cout << a[0] + a[1] << '\n';
	
	

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	S := nextBytes()

	for i := 0; i < len(S); i++ {
		if i%2 == 0 && S[i] == 'L' {
			fmt.Println("No")
			return
		}
		if i%2 == 1 && S[i] == 'R' {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, a, b;
    cin>>n>>a>>b;

    int s=0;
    for (int i=1;i<=n;i++)
    {
        int c=0;
        int m=i;
        while (m)
        {
            c+=m%10;
            m/=10;
            if (c>b)
            {
                break;
            }
        }
        if (c>=a&&c<=b)
        {
            s+=i;
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3652
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
#include <queue>

using namespace std;
using namespace std::chrono;

#define int long long

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	vector<int> gg;
	for (int i = 0; i < n; i += 2)
	{
		gg.push_back(a[i] ^ a[i + 1]);
	}
	int all = 0;
	for (int i : gg)
	{
		all ^= i;
	}
	for (int i : a)
	{
		cout << (i ^ all) << ' ';
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();
	
	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 5880
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#define ll long long
using namespace std;

struct moneypack{
    int value;
    string unit;
};
int main ()
{
    int n;
    cin >> n;
    double sum = 0;
    moneypack m;
    for (int i = 0; i < n; ++i){
        double tmp;
        scanf("%lf",&tmp);
        string s;
        cin >> s;
        if (s=="BTC") tmp*=380000.0;
        sum+=tmp;
    }
    cout << sum;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

S = i_s()

cnt = 0
ans = 0
for s in S:
    if s in ['A', 'T', 'C', 'G']:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int a, b; cin >> a >> b;
    int ans = max(a+b,a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
}

Measured memory_bytes: 256
g = set()
al  = set()
e = set()
lists = list(map(int, input().split()))
h = list(map(int, input().split()))
for j in range(lists[0]):
  e.add(j+1)
for i in range(lists[1]):
    a,b= map(int, input().split())
    al.add(a)
    al.add(b)
    if h[a-1] > h[b-1]:
        g.add(b)

       
    elif h[a-1] < h[b-1]:
        g.add(a)


    else:

      
        g.add(a)
        g.add(b)
        

    
denai = e - al 
s1 = e - g
ans =  s1 | denai

print(len(ans))


Measured memory_bytes: 109380
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] *= -1;
	}
	sort(a, a + n);
	long long ans = 0;
	for (int i = k; i < n; i++)
		ans -= a[i];
	cout << ans << "\n";
}



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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 1005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
ll solve(ll a, ll k,int n)
{
	if ( n == 0)
		return a;
	return min( solve(a*2,k,n-1), solve(a+k,k,n-1));
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll n, k;
	cin >> n >> k ;
	ll ans = solve(1,k,n);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

calc :: [Char] -> Int -> Int -> Int
calc op a b = case op of
  "+" -> a + b
  "-" -> a - b
  "*" -> a * b
  "/" -> a `div` b

main = do
  [a, op, b] <- words <$> getLine
  when (op /= "?") $ print (calc op (read a :: Int) (read b :: Int)) >> main

Measured memory_bytes: 4024
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<numeric>

using namespace std;
using ll = long long;

ll solve(int n, int r, int k, vector<ll>a, ll acc, ll now, int used){
  if(n == r){
    // cout << used << ' ' << k << ' ' << acc << endl;
    if(used < k) return 1e11+7;
    return acc;
  }
  ll ret = 1e11+7;
  if(now+1 > a[r]){
    ret = solve(n, r+1, k, a, acc, now, used);
  }
  acc += max(ll(0), now+1 - a[r]);
  now = max(now+1, a[r]);
  return min(ret, solve(n, r+1, k, a, acc, now, used+1));
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int k, n;
  cin >> n >> k;
  vector<ll> a(n);
  for(auto &i : a) cin >> i;

  cout << solve(n, 0, k, a, 0, 0, 0) << endl;

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = (ll)1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int a[200000], b[200000];

int main(){
  int n, m;
  vector<pair<int, int>> v;
  cin >> n >> m;
  rep(i, m){
    int x, y;
    cin >> x >> y;
    v.emplace_back(x, y);
  }
  sort(all(v));
  rep(i, n) a[i] = b[i] = i;
  each(p, v){
    b[p.second - 1] = b[p.second];
    a[p.second] = a[p.second - 1];
  }
  rep(i, n) cout << b[i] - a[i] + 1 << "\n "[i + 1 < n];
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    ll a, b;
    while(cin >> a >> b){
        cout << __gcd(a, b) << " " << a/__gcd(a, b)*b << endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll n,x;
  cin>>n>>x;
  
  vector<ll> A(n);
  ll y;
  rep(i,n){
    cin>>y;
    A[i]=abs(y-x);
  }
  
  ll ans=A[0];
  for(int i=1;i<n;i++){
    ans=gcd(ans,A[i]);
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  vector<int> x(5);
  vector<int> y(5);
  x={A,B,C,D,E};
  for(int i=0;i<5;i++){
    if(x.at(i)%10!=0)
      y.at(i)=10-x.at(i)%10;
    else
      y.at(i)=0;
  }
  sort(y.begin(),y.end());
  int sum=0;
  for(int i=0;i<4;i++)
    sum+=x.at(i)+y.at(i);
  cout<<sum+x.at(4);
}

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

using namespace std;

const int MOD = 1000000007;

int f(int t){
    if(t < 10) return 1;
    if(t < 100) return 2;
    if(t < 1000) return 3;
    if(t < 10000) return 4;
    if(t < 100000) return 5;
    if(t < 1000000) return 6;
    if(t < 10000000) return 7;
    if(t < 100000000) return 8;
    return 9;
}

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

int solve(int S){
    int high = 1;
    int sum = 0;
    int res = 0;
    for(int i=1;i<10000000;i++){
        while(sum < S){
            sum += f(high);
            ++high;
        }
        if(sum == S) ++res;
        sum -= f(i);
    }
    for(int d=1;;d++){
        int m = S/d;
        if(m < 8) break;
        if(S%d == 0){
            long long add = (9 * modPow(10, m-1) % MOD + MOD - d + 1) % MOD;
            res = (res + add) % MOD;
        } else {
            ++res;
        }
    }
    return res%MOD;
}

int main(){
    int S; cin >> S;
    cout << solve(S) << endl;
}

Measured memory_bytes: 3628
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	K := Int(s)
	negaNums, posiNums := scanNums(s, N)
	negaMap := map[int]int{}
	posiMap := map[int]int{}
	negaMap[0] = 0
	posiMap[0] = 0
	cnt := 0
	for i := len(negaNums) - 1; i >= 0; i-- {
		cnt++
		if _, ok := negaMap[cnt-1]; ok {
			negaMap[cnt] = abs(negaNums[i])
		} else {
			negaMap[cnt] = abs(negaNums[i])
		}
	}
	cnt = 0
	for i := 0; i < len(posiNums); i++ {
		cnt++
		if _, ok := posiMap[cnt-1]; ok {
			posiMap[cnt] = abs(posiNums[i])
		} else {
			posiMap[cnt] = abs(posiNums[i])
		}
	}

	minCost := 1000000000
	it := min(len(negaMap)-1, K)
	for i := 0; i <= it; i++ {
		if K-i > len(posiMap)-1 {
			continue
		}

		cost := negaMap[i]*2 + posiMap[K-i]
		if cost < minCost {
			minCost = cost
		}
	}

	it = min(len(posiMap)-1, K)
	for i := 0; i <= it; i++ {
		if K-i > len(negaMap)-1 {
			continue
		}

		cost := posiMap[i]*2 + negaMap[K-i]

		if cost < minCost {
			minCost = cost
		}
	}

	fmt.Println(minCost)
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(nums ...int) int {
	res := nums[0]
	for _, num := range nums {
		if res > num {
			res = num
		}
	}
	return res
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (negaNums []int, posiNums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		if num < 0 {
			negaNums = append(negaNums, num)
		} else {
			posiNums = append(posiNums, num)
		}
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = N * (N-1) / 2;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)
vector< pair<int, int> > G[100000];
bool visited[100000];
int x[100000];

bool setx(int src)
{
	bool ret = true;
	queue<int> Q;

	Q.push(src);
	x[src] = 0;
	visited[src] = true;

	while (!Q.empty()) {
		int current = Q.front(); Q.pop();
		int size = G[current].size();

		rep(i, size) {
			pair<int, int> next_item = G[current][i];
			int next = next_item.first;
			int cost = next_item.second;

			if (!visited[next]) {
				Q.push(next);
				x[next] = x[current] + cost;
				visited[next] = true;
			}
			else if (x[next] != x[current] + cost) {
				ret = false;
			}
		}
	}

	return ret;
}

int main()
{
	int N, M, L, R, D;
	bool ans = true;

	cin >> N >> M;

	rep(i, M) {
		cin >> L >> R >> D;
		G[L - 1].push_back(p(R - 1, D));
		G[R - 1].push_back(p(L - 1, -D));
	}

	rep(i, N) {
		if (!visited[i]) {
			if (!setx(i)) ans = false;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 9472
a, b, k = gets.strip.split.map(&:to_i)
c = k - a
if a == 0 && b == 0
  puts "#{a} #{b}"
else
  if c > 0
    d = b - c
    if d > 0
      puts "0 #{d}"
    else
      puts "0 0"
    end
  else
    puts "#{a - k} #{b}"
  end
end


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>

namespace PermutationSpace{
	const int PermutationLen=100000;
	struct Permutation{
		int P[PermutationLen+1];
		Permutation(){for (int i=0;i<=PermutationLen;i++) P[i]=i;}
		inline int & operator [] (const int &index){return P[index];}
	};
	Permutation operator * (Permutation A,Permutation B){
		Permutation C;
		for (int i=1;i<=PermutationLen;i++) C[i]=A[B[i]];
		return C;
	}

	Permutation Inv(Permutation C){
		Permutation D;
		for (int i=1;i<=PermutationLen;i++) D[C[i]]=i;
		return D;
	}
	Permutation Pow(Permutation D,int p){
		bool vis[PermutationLen+1];
		int stk[PermutationLen],top;
		Permutation E;
		memset(vis,0,sizeof(vis));
		for (int i=1;i<=PermutationLen;i++){
			if (vis[i]) continue;
			top=0;
			for (int now=i;!vis[now];now=D[now])
				stk[top++]=now,vis[now]=true;
			for (int j=0;j<top;j++) E[stk[j]]=stk[(j+p)%top];
		}
		return E;
	}
}

using namespace PermutationSpace;

Permutation A[6],G;

int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&A[1][i]);
	for (int j=1;j<=n;j++) scanf("%d",&A[2][j]);
	A[0]=Inv(A[2])*A[1];
	A[3]=A[2]*Inv(A[1]);
	A[4]=A[3]*Inv(A[2]);
	A[5]=A[4]*Inv(A[3]);
	G=A[2]*Inv(A[1])*Inv(A[2])*A[1];
	G=Pow(G,m/6)*A[m%6]*Pow(Inv(G),m/6);
	for (int i=1;i<=n;i++) printf("%d ",G[i]);
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
# define mod 1000000007;
 
int main() {
    int n,k;
    cin>>n>>k;
    vector <int> vec (n,0);
    vector <int> sum(k+1,0);
    vector <int> dp(k+1,0);
    long long sm=0;
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    for(int i=0;i<=k;i++){
    if(i<=vec[0])sum[i]++;
    if(i>0)sum[i]=(sum[i]+sum[i-1])%mod;}
                  // cout<<sum[i]<<" ";       }
    //cout<<endl;
    for(int i=1;i<n;i++){
     for(int j=0;j<=k;j++){
         int sub=((j-vec[i]-1)<0)?0:sum[j-vec[i]-1];
         dp[j]=(sum[j]-sub)%mod;
         if(j>0)dp[j]=(dp[j]+dp[j-1])%mod;
         //cout<<dp[j]<<" ";
     }
        //cout<<endl;
        sum=dp;
    }
    int ans=sum[k]-sum[k-1];
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
X,Y=map(int,input().split())
if 2*Y<X or 2*X<Y:
  print(0)
  exit()
if not((X%3==0 and Y%3==0) or (X%3==1 and Y%3==2) or (X%3==2 and Y%3==1)):
  print(0)
  exit()
P=10**9+7
A=(2*Y-X)//3
B=(2*X-Y)//3
num = 1
for i in range(A+1, A+B+1):
  num=num*i%P
den = 1
for j in range(1, B+1):
  den = den*j%P
den = pow(den,P-2,P)
print((num*den)%P)

Measured memory_bytes: 9068
/*
	0257:Railway Ticket
*/
#include	<iostream>

using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	if( (a == 1 && b == 1) || c == 1 ) {
		cout << "Open" << endl;
	} else {
		cout << "Close" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;
int main() {
  string S;
  int N, K;
  char r;
  cin >> N >> S >> K;
  r = S[K - 1];
  for(int i = 0; i < N; ++i) 
    if(i == K - 1) continue;
    else if(S[i] != r) S[i] = '*';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=51;
const int MAX_M=21;
int N,M; ll ans=0;
map<Pii,int> m;
vector<int> u(MAX_M),v(MAX_M),par(MAX_N);
vector<ll> po(MAX_N,1);
vector<vector<int>> G(MAX_N);

void dfs(int v,int p){
    for(int u:G[v]){
        if (u==p) continue;
        par[u]=v; dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        m[{a,b}]=m[{b,a}]=i;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    cin >> M;
    rep(i,M) cin >> u[i] >> v[i],--u[i],--v[i];
    vector<bitset<MAX_N>> list(M);
    rep(i,M){
        fill(all(par),-1);
        dfs(u[i],-1);
        int t=v[i];
        while(t!=u[i]){
            list[i].set(m[{t,par[t]}]);
            t=par[t];
        }
    }
    rep(i,N-1) po[i+1]=po[i]*2;
    rep(bit,1<<M){
        bitset<MAX_N> cnt(0);
        int flag=0;
        rep(i,M) if (bit&1<<i) ++flag,cnt|=list[i];
        int c=0;
        rep(i,N-1) if (!cnt.test(i)) ++c;
        ans+=(flag%2?-po[c]:po[c]);
    }
    cout << ans << endl;
}


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

x=[0 for i in range(-1,10**5+10)]

for i in a:
        x[i-1]+=1
        x[i]+=1
        x[i+1]+=1

x=sorted(x)

for i in reversed(x):
        if(not i<0):
                print(i)
                exit()



Measured memory_bytes: 14008
def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

def nasu(a, b):
  g = gcd(a, b)
  if g < 0:
    g *= -1
  if b < 0:
    a *= -1
    b *= -1
  return [a // g, b // g]

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

MOD = 10 ** 9 + 7
R = {}

ze = 0
na = 0
su = 0
for a, b in AB:
  if a == 0 and b == 0: 
    ze += 1
    continue
  if b == 0:
    na += 1
  elif a == 0:
    su += 1
  else:
    a, b = nasu(a, b)
    if a in R:
      if b in R[a]:
        R[a][b] += 1
      else:
        R[a][b] = 1
    else:
      R[a] = {}
      R[a][b] = 1

L = []
for i in R.keys():
  for j in R[i].keys():
    a, b = i, j
    x, y = -j, i
    if x < 0 and y < 0:
      x *= -1
      y *= -1
    t = R[i][j]
    if x not in R:
      L.append(pow(2, t, MOD))
      continue
    if y not in R[x]:
      L.append(pow(2, t, MOD))
      continue
    k = R[x][y]
    L.append((pow(2, t) + pow(2, k) - 1) % MOD)
    R[a][b] = 0
    R[x][y] = 0

L.append((pow(2, na) + pow(2, su) - 1) % MOD)

ans = 1
for i in L:
  ans = ans * i % MOD

ans = (ans + ze) % MOD

ans -= 1
if ans < 0:
  ans += MOD
print(ans)




Measured memory_bytes: 117392
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    string s;
    cin >> s;
    int sz = s.size();
    if (s[sz-1] == 's') {
        s.push_back('e');
    } 
    s.push_back('s');
    cout << s << endl;
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3632
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	int res = n;
	vector<int> a(n);
	for (int i = 0; i < 26; ++i)
	{
		for (int j = 0; j < n; ++j)
			a[j] = (s[j] - 'a' == i) ? 0 : 1;
		int t = n, k = 0;
		while (true)
		{
			bool flag = true;
			for (int j = 0; j < t; ++j)
				if (a[j] == 1)
				{
					flag = false; break;
				}
			if (flag)
			{
				res = min(res, k); break;
			}
			for (int j = 0; j + 1 < t; ++j)
				a[j] = min(a[j], a[j + 1]);
			--t;
			++k;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3644
A, B, C, X, Y = map(int, input().split())

if (A+B) <= 2*C:
  print(A*X + B*Y)
else:
  Z = 2 * min(X, Y)
  X_rem = X - Z // 2
  Y_rem = Y - Z // 2
  
  if (X_rem != 0) and (A > 2*C):
    print(C*(2*X))
  elif (Y_rem != 0) and (B > 2*C):
    print(C*(2*Y))
  else:
    print(A*X_rem + B*Y_rem + C*Z)


Measured memory_bytes: 3060
mod = 10**9 + 7
n, a, b = map(int, input().split())
res = pow(2, n, mod)-1

c1 = 1
for i in range(n-a+1, n+1):
    c1 *= i
    c1 %= mod

for i in range(1, a+1):
    c1 *= pow(i, mod-2, mod)
    c1 %= mod
    
c2 = 1
for i in range(n-b+1, n+1):
    c2 *= i
    c2 %= mod

for i in range(1, b+1):
    c2 *= pow(i, mod-2, mod)
    c2 %= mod
    
res -= (c1+c2)
res %= mod
print(res)

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

int pop(void);
void push(int);
int stack[100];
int i=0;

int main(){
  int x;
  char s[100]; 
  int a=0,b=0;
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    } else { 
      x = atoi(s);
      push(x); 
    }
  }
  printf("%d\n",stack[i]);
  return 0;
}

void push(int x){
  i++;
  stack[i]=x;
}

int pop(){
  i--;
  return stack[i+1];
}

Measured memory_bytes: 548
#include<stdio.h>
#include<math.h>

int main(void)
{
	int i,n;
	double sum,a,m,A,B;
	double s[1000];

	while(scanf("%d",&n)){
		if(n == 0)break;
		sum = 0;
		for(i = 0;i < n;i++){
			scanf("%lf",&s[i]);
			sum += s[i];
		}
		m = 0;
		m = sum / n;
		B = 0;
		for(i = 0;i < n;i++){
			B += pow((s[i] - m),2);
		}
		A = 0;
		A = B / n;
		a = 0;
		a = sqrt(A);
		printf("%f\n",a);
	}
	return 0;
}	

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

int main(){
  int x,i,b,p,ans=1,cur;
  cin >> x;
  if(x==1){
    cout << 1; return 0;
  }else{
    for(b=2; b*b<=x; b++){
      cur=b;
      while(cur<=x){
        cur*=b;
      }
      ans=max(ans, cur/b);
    }
  }
  cout << ans;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k, a[100001], b[100001];
int main() {
  cin >> n >> k;
  for (lli i=0; i<n; ++i) cin >> a[i] >> b[i];
  
  lli ans = 0;

  for (lli bit = 1; (k == 0 && bit == 1) || bit <= k; bit <<= 1) {
    lli x;
    if (bit == 1) x = k;
    else if (bit & k) {
      x = (k & (~bit)) | (bit-1);
    } else {
      continue;
    }
    // cerr << bitset<31>(x) << '\n';
    lli scr = 0;
    for (lli i=0; i<n; ++i) {
      if ((a[i] | x) == x) scr += b[i];
    }
    ans = max(ans, scr);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(),v.end())
#define pb push_back
int main()
{
ll a,b,c,d,e,f=0,i,j;
cin>>a;
    vector<ll>v;
c=1e10;
for(ll i=1;i<=a;i++)
{
cin>>b;
v.pb(b);
}
    sort(v);
  c=a-1;
 f=v[a-1];
 c--;v.pop_back();
 if(c%2==0)
  {
 c=c/2;
 for(j=c,i=v.size()-1;j>=1;i--,j--)
 {
            f+=v[i]*2;
 }
 
  }
 else
 {
c=c/2;c++;
 for(j=c,i=v.size()-1;j>=1;i--,j--)
 {
            if(j!=1)
            f+=v[i]*2;
           else f+=v[i];
 }
 }
  cout<<f;
 }

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout << fixed << i << endl
using namespace std;
using ll = long long;

//解説放送見て解答
//かなり苦手だった

int main() {
    ll c[3][3];
    rep(y, 3) rep(x, 3) cin >> c[x][y];

    ll a1, a2, a3, b1, b2, b3;

    for (long long i = 0; i <= c[0][0]; i++) {
        a1 = i;
        b1 = c[0][0] - i;
        a2 = c[0][1] - b1;
        a3 = c[0][2] - b1;
        b2 = c[1][0] - a1;
        b3 = c[2][0] - a1;
        if (a1 + b1 == c[0][0] and a1 + b2 == c[1][0] and a1 + b3 == c[2][0] and
            a2 + b1 == c[0][1] and a2 + b2 == c[1][1] and a2 + b3 == c[2][1] and
            a3 + b1 == c[0][2] and a3 + b2 == c[1][2] and a3 + b3 == c[2][2]) {
            put("Yes");
            return 0;
        }

    }
    put("No");
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint cnt = 0;
	rep(i, N) {
		if (A[i] < 0) {
			cnt++;
		}
	}
	lint sum = 0;
		rep(i, N) {
			sum += abs(A[i]);
		}
		lint a = INT_MAX;
		rep(i, N) {
			a = min(a, abs(A[i]));
		}
		if (cnt % 2!=0) {
			sum -= a*2;
		}
		cout << sum << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector < ll > A(N);
    REP(i,N) cin >> A[i];

    vector < ll > X(N, 0);
    REP(i,N) {
        if (i % 2 == 0) {
            X[0] += A[i];
        } else {
            X[0] -= A[i];
        }
    }

    for (int i = 1; i < N; i++) {
        X[i] = 2 * A[i - 1] - X[i - 1];
    }

    for (auto x : X) cout << x << endl;

    return 0;
}


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

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

	int now=1,i=0;
	while(1){
		if(now==2){
			cout<<i<<endl;
			break;
		}else if(i>=n){
			cout<<"-1"<<endl;
			break;
		}

		i++;
		

		now=a[now];
	}

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e7;

int main() {
    int d, g; cin >> d >> g;
    g /= 100;
    vector<P> a(d);
    rep(i,d) {
        int p, c; cin >> p >> c;
        c /= 100;
        a[i] = P(p,c);
    }
    int ans = inf;
    for (int i = 0; i < 1<<d; i++) {
        int sum = 0;
        int ct = 0;
        rep(j,d) {
            if (i >> j & 1) {
                sum += a[j].first*(j+1) + a[j].second;
                ct += a[j].first;
            }
        }
        if (sum >= g) {ans = min(ans,ct); continue;}
        for (int j = d-1; j >= 0; j--) {
            if (!(i >> j & 1)) {
                int x = (g-sum+j)/(j+1);
                if (x <= a[j].first-1) {
                    ct += x; 
                    ans = min(ans,ct);
                    break;
                }
                else {
                    ct += a[j].first-1;
                    sum += (a[j].first-1) * (j+1);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
sum={}
while a=gets
x=a.downcase
x.length.times{|i|sum[x[i]]!=nil ? sum[x[i]]+=1 : sum[x[i]]=1}
end
[*'a'..'z'].each{|i|puts i+" : "+sum[i].to_s if sum[i] != nil
puts i+" : 0" if sum[i] == nil}

Measured memory_bytes: 8668
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, h; cin >> n >> h;
	vector<int> a(n), b(n);
	rep(i, 0, n - 1)
	{
		cin >> a[i] >> b[i];
	}
	sort(all(a), greater<int>());
	sort(all(b), greater<int>());
	int aa = a[0];
	int ans = 0;
	int i = 0;
	int cnt = 0;
	while (0 < h&&i < n&&aa < b[i])
	{
		h -= b[i];
		++cnt;
		++i;
	}
	if (h <= 0)cout << cnt << endl;
	else
	{
		ans = cnt + (h + aa - 1) / aa;
		cout << ans << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

ll gcd(ll a, ll b)
{
	if(a < b) swap(a, b);

	while(b)
	{
		ll r = a%b;
		a = b;
		b = r;	
	}

	return a;
}

int main()
{
	////////////input//////////////
	ll n;
	ll A[100009];

	cin >> n;
	rep(i, n) cin >> A[i];

	////////////compute////////////

	std::vector<ll> Right(100009);
	std::vector<ll> Left(100009);

	rep(i,  n)  Left[i + 1] = gcd(Left[i]     , A[i]);
	rrep(i, n)  Right[i]    = gcd(Right[i + 1], A[i]);

	std::vector<ll> ans(100009);

	rep(i, n) ans[i] = gcd(Left[i], Right[i + 1]);

	sort(ans.begin(), ans.end(), greater<ll>());

	cout << ans[0] << endl;


}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    int H, N;
    cin >> H >> N;

    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A.at(i);

    int sum = accumulate(A.begin(), A.end(), 0);

    if(H > sum) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,M,R;
    cin>>N>>M>>R;
    vector<int> r(R);
    cin>>r;
    vector<vector<int>> dist(N,vector<int>(N,INF));
    REP(i,N) dist[i][i]=0;
    REP(i,M) {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        dist[a][b]=dist[b][a]=c;
    }

    REP(i,N) REP(j,N) REP(k,N) chmin(dist[j][k],dist[j][i]+dist[i][k]);

    sort(ALL(r));
    int ans=INF;
    do {
        int tmp=0;
        REP(i,R-1) {
            tmp+=dist[r[i]-1][r[i+1]-1];
        }
        chmin(ans,tmp);
    } while(next_permutation(ALL(r)));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import collections

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

d = dict(collections.Counter([i + A[i] for i in range(N)]))
ans = sum([d.get(j - A[j], 0) for j in range(N)]) # .get()の第２引数は、第１引数がなかった場合に返す値

print(ans)

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

typedef long long               ll;
typedef unsigned long long      ull;

const int N = 2 * 100 * 1000 + 20;

vector <ll> adj[N];
ll sum[N];
bool vis[N];

void dfs(ll v, ll par, ll val) {
    vis[v] = true;
    sum[v] += val;
    for (auto u: adj[v])
        if (u != par)
            dfs(u, v, sum[v]);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    ll n, q;
    cin >> n >> q;
    for (int i = 0, u, v; i < n - 1; i++) {
        cin >> v >> u;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ll x, y;
    while (q--) {
        cin >> x >> y;
        sum[x] += y;
    }
    dfs(1, 0, 0);
    for (int i = 1; i <= n; i++)
        cout << sum[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 24448
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        string X,Y;
        cin >> X >> Y;
        int L[X.length()+10][Y.length()+10];
        for(int j = 0;j < X.length()+5;j++){
            for(int k = 0;k < Y.length()+5;k++){
                L[j][k] = 0;
            }
        }
        for(int j = 1;j<=X.length();j++){
            for(int k = 1;k<=Y.length();k++){
                if(Y[k-1] == X[j-1]){
                    L[j][k] = 1+L[j-1][k-1];
                }
                else{
                    L[j][k] = max(L[j-1][k],L[j][k-1]);
                }
            }
        }
        cout << L[X.length()][Y.length()] << endl;
    }
    return 0;
}

Measured memory_bytes: 6976
import math
import sys
from collections import deque
a=input()
ans=0
for i in range(2**(len(a)-1)):
  s=0
  c=int(a[0])
  for j in range(len(a)-1):
    if (i>>j) &1:
      s+=c
      c=int(a[j+1])
    else:
      c=10*c+int(a[j+1])
  ans+=s+c
print(ans)
 
      

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string A,B;
    cin >> A >> B;
    if(A.size() > B.size()){
        cout << "GREATER" << endl;
    }else if(B.size() > A.size()){
        cout << "LESS" << endl;
    }else{
        for (int i = 0; i < A.size(); ++i) {
            if(A[i] > B[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(A[i] < B[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,M;
char s[55][55];
int dfs(int x,int y){
    int r=1;
    s[x][y]=0;
    if(s[x+1][y]=='#')
        r+=dfs(x+1,y);
    if(s[x][y+1]=='#')
        r+=dfs(x,y+1);
    if(s[x-1][y]=='#')
        r+=dfs(x-1,y);
    if(s[x][y-1]=='#')
        r+=dfs(x,y-1);
    return r;
}
int main(){
    scanf("%d%d",&N,&M);
    for(int i=0;i<N;i++){
        scanf("%s",s[i+1]+1);
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            if(s[i][j]=='#'){
                if(dfs(i,j)<2){
                    cout<<"No\n";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define mmod 1000000007
int f[100010];
int main()
{

    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<=n;i++) f[i]=1;
    for (int i=0;i<m;i++)
    {
        int tt;scanf("%d",&tt);
        f[tt]=-1;
    }

    for (int i=2;i<=n;i++)
    {
        if (f[i]==-1) continue;
        f[i]=0;
        if (f[i-1]!=-1) f[i]+=f[i-1],f[i]%=mmod;
        if (f[i-2]!=-1) f[i]+=f[i-2],f[i]%=mmod;
    }
    printf("%d\n",f[n]);

}


Measured memory_bytes: 512