akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int N, M;
int C[17], x[20001];
int dp[256][20001];

int rec(int now, int cnt) {
  if ( cnt == N ) return 0;
  if ( dp[now][cnt] != -1 ) return dp[now][cnt];

  int ret = 1e8;
  for ( int i = 0; i < M; i++ ) {
    int tmp = max(0, min(255, now + C[i]));
    ret = min(ret, rec(tmp, cnt + 1) + (x[cnt] - tmp) * (x[cnt] - tmp));
  }

  return dp[now][cnt] = ret;
}

int main()
{
  while ( cin >> N >> M, N | M ) {
    for ( int i = 0; i < M; i++ ) cin >> C[i];
    for ( int i = 0; i < N; i++ ) cin >> x[i];
    
    fill_n(*dp, 256 * 20001, -1);
    
    cout << rec(128, 0) << endl;
  }
}

Measured memory_bytes: 25040
#include <bits/stdc++.h>
using namespace std;
int k,n;
const int N=2e5+50;
int a[N];
int main(){
	scanf("%d%d",&k,&n);
	int mx=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i>0){
			mx=max(mx,a[i]-a[i-1]);
		}
	}
	mx=max(mx,a[0]+k-a[n-1]);
	printf("%d\n",k-mx);
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  set<int> c;
  REP(i, 3) {
    int tmp;
    cin >> tmp;
    c.insert(tmp);
  }
  cout << c.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int s[2*K] = {0};
  if(2*K >= B - A + 1){
    for(int i = 0; i < B - A + 1; i++){
      cout << A + i << endl;
    }
  }
  
  if(2*K < B - A + 1){
    for(int i = 0; i < K; i++){
      s[i] = A + i;
      s[2*K - i - 1] = B - i;
    }
    sort(s, s + 2*K);
    for(int i = 0; i < 2*K; i++){
      cout << s[i] << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(ll i=(k);i<(ll)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
 
using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  ll ans = 0;
  for(ll i=2;i*i<=n;++i) {
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    int add = 0;
    while (cnt - add - 1 >= 0) {
      ++add;
      cnt -= add;
    }
    ans += add;
  }
  if (n > 1) ++ans;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream> 
    #include <cstdlib>
using namespace std;
long long K;
const long long IINF=1e16+1000;
long long A[55];
int main()
{
	scanf("%lld",&K);
	for(long long n=2;n<=50;n++)
	{
		long long lvl=(n-1)+(K/n);
		long long lft=K%n;
		if(lvl>IINF)continue;
		lvl-=lft;
		//printf("%lld %lld\n",lvl,lft);
		//system("pause");
		for(int i=0;i<n;i++)
			A[i]=lvl;
		for(int i=0;i<lft;i++)
			A[i]+=n;
		printf("%lld\n",n);
		for(int i=0;i<n;i++)
			printf("%lld ",A[i]);
		printf("\n");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        int K = int.Parse(input[2]);
        var dr = new int[N];
        var u = new UnionFind(N);
        var bL = new List<int>[N];
        for (int i = 0; i < N; i++) bL[i] = new List<int>();
        for (int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(input[0]) - 1;
            var b = int.Parse(input[1]) - 1;
            u.Unite(a, b);
            dr[a]++;
            dr[b]++;
        }
        for (int i = 0; i < K; i++)
        {
            input = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(input[0]) - 1;
            var d = int.Parse(input[1]) - 1;
            bL[c].Add(d);
            bL[d].Add(c);
        }

        var ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            var w = u.getMem(i) - dr[i] - 1;
            foreach (var x in bL[i])
                if (u.Root(i) == u.Root(x)) w--;
            ans[i] = w;
        }
        Console.WriteLine(string.Join(" ", ans));
    }

    public class UnionFind
    {
        private int[] data;
        public UnionFind(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }
        public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
        public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
        public int getMem(int x) => -data[Root(x)];
    }
}

Measured memory_bytes: 30240
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
#define INF 10000000000000

using namespace std;

typedef long long ll;
ll dis[100010];
ll disSum[100010];
bool po = true,ne = true;
int main() {
  int N,K; cin >> N >> K;
  int x[100010];
  for ( int i = 0; i < N; i++ ) {
    cin >> x[i];
    if( x[i] < 0 ) po = false;
    if( x[i] > 0 ) ne = false;
  }
  ll tmp;
  ll minD = INF;
  ll zero;
  if(po) {
    cout <<  x[K-1] << endl;
    return 0;
  }else if ( ne ) {
    cout << abs(x[N-K]) << endl;
    return 0;
  } else {

  
  for ( int i = 0; i+K-1 < N; i++ ) {
    zero = 0;
    if(x[i] < 0 && x[i+K-1] > 0 ) {
      zero = min(abs(0-x[i]),abs(0-x[i+K-1]));
    }
    tmp = abs(x[i]-x[i+K-1])+zero;
    minD = min(tmp,minD);
    
  }

  cout << minD << endl;
  }
    return 0;
}


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

int main(void){
    int i, n, max, min;
    long int sum;
    max=-1000000;
    min=1000000;
    sum=0;
    cin >> n;
    if(n==0) cout << "0 0 0" << endl; 
    else {
        int a[n];
        for (i=0; i<n; i++){
            cin >> a[i];
            if (max < a[i]) max = a[i];
            if (min > a[i]) min = a[i];
            sum += a[i];
        }
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#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 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int a, b;
	cin>>a>>b;
	cout<<a/b<<" "<<a%b<<" ";
	cout<<fixed<<showpoint<<setprecision(114514)<<(double)a/(double)b<<endl;
}

Measured memory_bytes: 4020
#include <iostream>
#include<iomanip>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

long long A[100000];
long long B[100000];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }

    long long sum_A = 0;
    long long sum_B = 0;
    for(int i = 0; i < N; i++){
        sum_A += A[i];
        sum_B += B[i];
    }
    if(sum_A < sum_B){
        cout << -1 << endl;
    } else {
        vector <long long> preparedness;
        vector <long long> not_preparedness;
        for(int i = 0; i < N; i++){
            if(A[i] > B[i]){
                preparedness.push_back(A[i] - B[i]);
            }
            if(A[i] < B[i]){
                not_preparedness.push_back(A[i] - B[i]);
            }
        }
        if(not_preparedness.size() == 0){
            cout << 0 << endl;
            return 0;
        }
        int ans = not_preparedness.size();
        sort(preparedness.begin(), preparedness.end(), greater <long long>());
        sort(not_preparedness.begin(), not_preparedness.end());

        int not_preparedness_index = 0;
        //bool first_change = true;
        for(int i = 0; i < preparedness.size(); i++){
            ans ++;
            while(preparedness[i] > 0 && not_preparedness_index < not_preparedness.size()){
                if(preparedness[i] + not_preparedness[not_preparedness_index] >= 0){
                    preparedness[i] += not_preparedness[not_preparedness_index];
                    not_preparedness_index ++;
                } else {
                    not_preparedness[not_preparedness_index] += preparedness[i];
                    preparedness[i] = 0;
                }
            }
            
            if(not_preparedness_index >= not_preparedness.size()){
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2812
/*
 * ARC096_C.cpp
 *
 *  Created on: May 17, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if(A+B <= 2*C) {
		cout << A*X+B*Y << endl;
		return 0;
	}
	int sol = 0;
	int sm = min(X, Y);
	sol += sm*C*2;
	REP(i, X - sm) {
		sol += min(A, 2*C);
	}
	REP(i, Y-sm) {
		sol += min(B, 2*C);
	}
	cout << sol << endl;
}






Measured memory_bytes: 256
def main():
    S = input()
    w1 = 'dream'[::-1]
    w2 = 'dreamer'[::-1]
    w3 = 'erase'[::-1]
    w4 = 'eraser'[::-1]
    S = S[::-1]
    words = [w1, w2, w3, w4]

    flag = False
    i = 0
    while i != len(S):
        for w in words:
            if S[i:].startswith(w):
                i += len(w)
                flag = True
                break

        if not flag:
            print("NO")
            exit()
        flag = False

    print("YES")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s;
	cin >> s;
	int go = (int)s.size() - 7;
	if (go >= 0) {
		for (int i = 0; i <= 7; ++i)
			if (s.substr(0, i) + s.substr(s.size() - (7 - i)) == "keyence") {
				cout << "YES\n";
				return 0;
			}
	}
	cout << "NO\n";
	return 0;
}




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

int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;
	int count{};
	for (int i{}; i + 2 < N; i++)
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
			count++;
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

int fact(int c){
    
    if(c==0)return 1;

    return c*fact(c-1)%1000000007;
}

signed main(){
    
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<(fact(a)*fact(b)*2)%1000000007<<endl;
    }
    else{
        if(abs(a-b)>1)cout<<0<<endl;
        else cout<<(fact(a)*fact(b))%1000000007<<endl;
    }
    
}


Measured memory_bytes: 1792
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var X = one[0];
	var N = one[1];
	if(N == 0){
		myout(X);
		return;
	}
	var list = nextIntArray();
	list.sort(function(a,b){
		return a - b;
	});

	var min = 10007;
	var output;
	var check = [];
	
	for(var i = 0; i <= 107; i++){
		if(list.indexOf(i) == -1){
			check.push(i);
		}
	}
	for(var i = 0; i < check.length; i++){
		if(min > Math.abs(X - check[i])){
			min = Math.abs(X - check[i]);
			output = check[i];
		}
	}
	myout(output);
}

Measured memory_bytes: 30248
import java.util.Scanner;

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

		long a = 2;
		long b = 1;
		long c = 0;

		if (N == 0){
			System.out.println(2);
			return;
		}else if (N == 1){
			System.out.println(1);
			return;
		}

		for (int i=2; i<=N; i++){
			c = a + b;
			a = b;
			b = c;
		}
		System.out.println(c);
		return;
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(a) (a.begin(),a.end())
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  int n;
  cin >> n;
  map<ll,ll>cnt;
  ll sum = 0;
  rep(i,n){
    int tmp;
    cin >> tmp;
    cnt[tmp]++;
    sum += tmp;
  }
  
  int q;
  cin >> q;
  rep(i,q){
    ll a,b;
    cin >> a >> b;
    ll Abs = (cnt[a] * a) - cnt[a] * b;
    sum -= Abs;
    ll tmp = cnt[a];
    cnt[a] -= tmp;
    cnt[b] += tmp;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a,b,c;
  if(n%10==1){
    n+=8;
  }
  else{
    n-=8;
  }
  if(n%100==19||n%100==11){
    n+=80;
  }
  else{
    n-=80;
  }
  if(n==111||n==119||n==191||n==199){
    n+=800;
  }
  else{
    n-=800;
  }
  cout<<n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second

int main() {
	int d;
	cin >> d;
	string ans;
	switch (d) {
	case 22: ans = "Christmas Eve Eve Eve";	break;
	case 23: ans = "Christmas Eve Eve"; break;
	case 24: ans = "Christmas Eve"; break;
	case 25: ans = "Christmas"; break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    // for(int n = 1; n < 11; n++){
    //     printde(n);
    //     for(int m = 1; m <= n; m++){
    //         if(n / m == n % m){
    //             // if(n / m * (n / m) > n){
    //             //     printde(n, m);
    //             // }
    //             printde(n, m, n / m, n % m);
    //         }
    //     }
    // }
    ll ans = 0;
    for(ll i = 1; i * i <= n * 10; i++){
        ll nn = n - i;
        // printde(nn, i, nn % i, nn / i);
        if(nn / i == 0){ continue; }
        if(nn % i == 0 && n % (nn / i) == n / (nn / i)){
            ans += nn / i;
        }
        // if(nn % i == 0 && !(n % (nn / i) == n / (nn / i))){
        //     printde(nn, i, nn % i, nn / i, n % (nn / i), n / (nn / i));
        // }
        // if(nn % i == 0 && nn / i == i){
        //     ans += i;
        // }
    }
    cout << ans << '\n';
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m;
    cin >> n >> m;

    map<int, vector<int>> edge;
    for(int i=0; i<n+1; i++){
        edge[i] = {};
    }
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<int> prev(n+1, -1);
    prev[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i=0; i<edge[now].size(); i++){
            int next = edge[now][i];
            if(prev[next] == -1){
                prev[next] = now;
                q.push(next);
            }
        }
    }
    
    for(int i=1; i<=n; i++){
        if(prev[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2; i<=n; i++){
        cout << prev[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 18340
#include<stdio.h>
int main(){
    int c,t,x,y;
    scanf("%d%d",&x,&y);
    if((y-2*x)%2!=0||(4*x-y)%2!=0||y<2*x||4*x<y)
    printf("No");
    else
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

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

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>a>>b;
	cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdint>
#include<cassert>
using namespace std;

typedef int64_t i64;typedef int32_t i32;
typedef int16_t i16;typedef int8_t i8;
typedef uint64_t ui64;typedef uint32_t ui32;
typedef uint16_t ui16;typedef uint8_t ui8;

typedef i32 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define repeat_eq(i,j,k) for(int__ i=(j);i<=(k);i++)
#define all(v) begin(v),end(v)

const i32 INF=1<<30;//=10E10

string str;
int pos;

int rec(){
  vector<int> vote;

  if(str[pos]=='['){
    pos++;
    while(str[pos]!=']'){
      vote.push_back(rec());
    };
  }
  else if(isdigit(str[pos])==true){
    int pos_p=pos;
    while(isdigit(str[pos]))++pos;// ']'まで進める
    int vote_1=atoi(str.substr(pos_p,pos-pos_p).c_str());
    return vote_1/2+1;
  }

  int ans=0;
  sort(all(vote));

  rep(i, (int)vote.size()/2 + 1 ){
    ans+=vote[i];
  }
  pos++;
  return ans;
}

int main()
{
  int n;cin>>n;
  rep(i,n){
    cin>>str;
    pos=0;
    cout<<rec()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>
    int min(int a,int b){
      return a < b ? a : b;
    }
     
    int abs(int a){
      return a < 0 ? -1*a:a;
    }
     
    int main(){
      int n;
      scanf("%d",&n);
      int h[n];
      int i;
      for(i = 0;i < n;i++){
        scanf("%d",&h[i]);
      }
      int c[n];
      c[0] = 0;
      c[1] = abs(h[1]-h[0]);
      for(i = 2;i < n;i++){
        c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
      }
      printf("%d",c[n-1]);
    }

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\n'
// auto start = high_resolution_clock::now(); 
// auto stop = high_resolution_clock::now(); 
// auto duration = duration_cast<microseconds>(stop - start); 
 
// cout << duration.count() << endl; 


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
//      int t;
//      cin >> t; 
//      while(t--){
     	
// }

     int k;
     cin >> k;
     int res = 0;
     fo(i,1,k+1){
     	fo(j,1,k+1){
     		fo(z,1,k+1){
     			int x = __gcd(i,j);
     			res += __gcd(x,z);
     		}
     	}
     }

     cout << res << endl;
return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long int a[100001],i;
vector<long long int>v[100001];
long long int solve(long long int x)
{
    if(a[x]!=-1)
    {
        return a[x];
    }
    long long int y=0,p;
    for(p=0;p<v[x].size();p++)
    {
        y=max(y,solve(v[x][p])+1);
    }
   // a[x]=y;
    return a[x]=y;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    long long int n,m,x,y,ans=0,j;
    cin>>n>>m;
    for(i=0;i<=n;i++)
    {
       a[i]=-1;
    }
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(j=1;j<=n;j++)
    {
       // cout<<i<<endl;
        ans=max(ans,solve(j));
        //cout<<j<<" "<<ans<<endl;
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 8576
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors


n=int(input())
cnt=0
for i in range(1,n+1):
    if i%2==1 and len(make_divisors(i))==8:
        cnt +=1
print(cnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    vector<string> str;
    REP(i,n+1) {
        string tmp = s.substr(0,i);
        map<char,int> m;
        REP(j,i) ++ m[s[j]];
        for(char j = 'a'; j <= 'z'; ++ j) {
            if(m[j]==0) str.push_back(tmp+j);
        }
    }
    string ans = "";
    sort(ALL(str));
    REP(i,str.size()) {
        if(str[i]>s) {
            ans += str[i];
            break;
        }
    }
    cout << (ans=="" ? "-1" : ans) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val H = sc.nextInt()
    val A = Array.ofDim[Int](N)
    val B = Array.ofDim[Int](N)
    (0 until N) foreach { i =>
      A(i) = sc.nextInt()
      B(i) = sc.nextInt()
    }

    Sorting.quickSort(B)
    val Amax = A.max
    val ub = upperBound(B, Amax)
    val (dmg, killedAt) = (ub until N).foldRight((0, -1)) { case (i, (sum, j)) =>
      if (j == -1) {
        (sum + B(i), if (sum + B(i) >= H) i else -1)
      } else {
        (sum, j)
      }
    }

    val ans = if (killedAt != -1) {
      N - killedAt
    } else {
      val remainHealth = H - dmg
      N - ub + (remainHealth - 1) / Amax + 1
    }

    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  def upperBound(a: Array[Int], x: Int): Int = {
    def step(l: Int, h: Int): Int = {
      if (h - l == 1) h
      else {
        val mid = l + (h - l) / 2
        if (a(mid) > x) step(l, mid)
        else step(mid, h)
      }
    }
    step(-1, a.length)
  }
}


Measured memory_bytes: 47404
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n,m,y,count=0;
  cin>>n>>m>>y;
  int x[200];
  for(int i=0;i<m;i++){
    cin>>x[i];
    if(x[i]>y)
      count++;
  }
  cout<<min(count,m-count)<<endl;
}

Measured memory_bytes: 256
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.01 00:29:10
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll aaa = 1000000000000000000;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (aaa < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        aaa /= a[i];
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
/*author : Yashvardhan
Saturday, January 12, 2019
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int dp[3001][3001];
string s1,s2;
int n1,n2;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

 int solve(int i,int j){
	if(dp[i][j] != -1) return dp[i][j];
	if(i == 0 || j == 0) return dp[i][j] = 0;
	int x = 0;
	if(s1[i] == s2[j]) return dp[i][j] = solve(max(x,i-1),max(x,j-1)) + 1;
	return dp[i][j] = max(solve(i, max(x, j - 1)), solve(max(x, i - 1), j)); 
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	string s,t;
	s1 = "*";
	s2 = "*";
	cin>>s>>t;
	s1 += s;
	s2 += t;
	n1 = s1.size();
	n2 = s2.size();


	for(int i = 0; i < 3001 ; i++){
		for(int j = 0;j < 3001; j++){
			dp[i][j] = -1;
		}
	}

	int index = solve(n1-1, n2-1);
	int ans = index;
	string lcs[index+1];
	int i = n1-1;
	int j = n2-1;
	while(i>0 && j>0){
		if(s1[i] == s2[j]){
			lcs[index-1] = s1[i];
			index--; i--; j--; 
		}
		else if(dp[i-1][j] > dp[i][j-1]) i--;
		else j--;
	}
	for(int i = 0;i<ans;i++){
		cout<<lcs[i];
	}
	cout<<endl;
	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long int
void solve() {
    string s ;cin >> s;
    ll sum = 0;
    for(int i = 0; i < s.size(); i++){
        int digit = s[i] - '0';
        sum += digit;
    }
  
    if(sum % 9 == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    //Starts here , 
                
    // int T; cin >> T;
    // while(T--){
        solve();
    // }
    return 0;
            
}

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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  
  for (int i=1; i<=n; i+=2){
    int cnt = 0;
    for (int j=1; j<=i; j++){
      if (i%j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }
  
  cout << ans << endl; 
  return 0;
  
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int i = 2000;
  for (int j = 0; j < s.size() - t.size() + 1; j++) {
    int difcou = 0;
    for (int k = 0; k < t.size(); k++) {
      if (t.at(k) != s.at(j + k)) {
        difcou++;
      }
    }
    if (difcou < i) {
      i = difcou;
    }
  }
  cout << i << endl;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
bool heihou(int x){
  int y = 0;
  while(true){
    y++;
    if(y*y==x){
      return true;break;
    } else if(y*y > x){
      return false;break;
    }
  }
}
int main(){
  int n,d,i,j,k,ans = 0,c;cin >> n >> d;
  int x[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++) cin >> x[i][j];
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      c = 0;
      for(k=0;k<d;k++) c += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      ans += heihou(c);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   long long int n,a,b,w,s=0,i,j,k;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(i=1;i<=n;i++)
    {
       // if(i>=a&&i<10)
          //  s=s+i;
        // if(i>=10)
       // {
            j=i;
            w=0;
            while(j!=0)
            {
                k=j%10;
                j=j/10;
                w=w+k;
            }
            if(w>=a&&w<=b)
                s=s+i;
        }

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


Measured memory_bytes: 128
import copy
s = input()
original = copy.deepcopy(s)
s = list(s)
s.reverse()
s = "".join(s)
s = s.replace('b','x')
s = s.replace('d','b')
s = s.replace('x', 'd')
s = s.replace('q','x')
s = s.replace('p','q')
s = s.replace('x','p')
if s == original:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4468
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	ll n, k, r, s, p, ans = 0;
	scanf("%lld%lld%lld%lld%lld", &n, &k, &r, &s, &p);
	string t;
	scans(t);
	bool b = false;
	rep(i, n) {
		if (i - k >= 0) {
			if (t[i] == t[i - k]) {
				if (t[i] == 'r') {
					ans -= p;
				}
				else if (t[i] == 's') {
					ans -= r;
				}
				else if (t[i] == 'p') {
					ans -= s;
				}
				b = true;
			}
		}
		if (t[i] == 'r') {
			ans += p;
		}
		else if (t[i] == 's') {
			ans += r;
		}
		else if(t[i] == 'p'){
			ans += s;
		}
		if (b)t[i] = '!';
		b = false;
	}
	printf("%lld\n", ans);

	Please AC;
}


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


int main(){
	string s;
	cin >> s;
	int k, f;
	for(int i = 0; i<s.length(); i++){
		if(s[i] == 'A'){
			k = i;
			break;
		}
	}
	for(int i = 0; i<s.length(); i++){
		if(s[i] == 'Z'){
			f = i;
		}
	}
	cout << f- k+1;
	return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

#define min(a, b) (a < b ? a : b)

int main(void) {
	long sNum = 0, cNum = 0, scc = 0;
	scanf("%ld %ld", &sNum, &cNum);
	scc += (min(sNum, cNum / 2));
	sNum -= scc;
	cNum -= scc * 2;
	scc += cNum / 4;
	printf("%ld\n", scc);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
            int max = L[L.Length - 1];
            int sum = L.Sum() - max;
            if (max < sum) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }
    }
}

Measured memory_bytes: 11348
cinq = [i ** 5 for i in range(300)]
X = int(input())
for a in cinq:
  if a + X in cinq:
    print(cinq.index(a+X), cinq.index(a))
    break
  elif X-a in cinq:
    print(cinq.index(a), -cinq.index(X-a))
    break
          

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x, y; cin >> x >> y;
	if(x % y == 0) cout << -1 << endl;
	else cout << x << endl;
		
	return 0;                                              
}
	


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

using namespace std;

const int mod = 998244353;

class inverse {
    public:
    inverse(int n, int mod);
    ~inverse();
    long long get_inv(int x);
    long long get_fact(int x);
    long long get_invfact(int x);
    long long get_comb(int x, int y);
    
    private:
    int mod;
    long long* inv;
    long long* fact;
    long long* invfact;
};

inverse::inverse(int n, int mod) : mod(mod) {
    inv = (long long *)malloc(sizeof(long long) * (n + 1));
    fact = (long long *)malloc(sizeof(long long) * (n + 1));
    invfact = (long long *)malloc(sizeof(long long) * (n + 1));
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

inverse::~inverse() {
    free(inv);
    free(fact);
    free(invfact);
}

long long inverse::get_inv(int x) {
    return inv[x];
}

long long inverse::get_fact(int x) {
    return fact[x];
}

long long inverse::get_invfact(int x) {
    return invfact[x];
}

long long inverse::get_comb(int x, int y) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}

long long powmod(long long x, long long y) {
    long long ans = 1;
    
    while (y > 0) {
        if (y & 1) ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    
    return ans;
}

int main() {
    int n, i;
    long long ans;
    
    scanf("%d", &n);
    
    inverse inv(n, mod);
    
    ans = powmod(3, n);
    
    for (i = n; i > n / 2; i--) {
        long long x = inv.get_comb(n, i) * powmod(2, n - i) % mod;
        ans -= x * 2;
        while (ans < 0) ans += mod;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

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

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


int main(){
    long long A,B;
    cin >> A >> B;
    long long ans = lcm(A,B);
    cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    for(int  i = 1; i  <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if( i * j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define llong long long
int T;
int n;
llong a[220];
llong B[110];
int op[220];
void ins(llong x)
{
	for(int i=61;i>=0;--i)
		if((x>>i)&1)
		{
			if(!B[i])
			{
				B[i]=x;
				break;
			}
			x^=B[i];
		}
}
bool find(llong x)
{
	for(int i=61;i>=0;--i)
		if((x>>i)&1)x^=B[i];
	return x==0;
}
int main()
{
	scanf("%d",&T);
while(T--)
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)scanf("%1d",&op[i]);
	memset(B,0,sizeof(B));
	int ans=0;
	for(int i=n;i;--i)
		if(op[i]==0)ins(a[i]);
		else if(!find(a[i]))
		{
			ans=1;break;
		}
	printf("%d\n",ans);
}
	return 0;
}


Measured memory_bytes: 3720
#include <vector>
#include <unordered_set>
#include <cstdio>
using namespace std;

namespace std{
	template<typename I>
	class hash<pair<I,I>>{
		public:
		size_t operator()(pair<I,I> const &p) const {return hash<long long>() (((long long)(p.first))<<32|p.second);}
	};
}

int main(){
	long long H,W;
	int N;
	scanf("%lld%lld%d",&H,&W,&N);
	vector<long long>v(10);
	unordered_set<pair<int,int>>points;
	v[0]=(H-2)*(W-2);
	for(;N--;){
		int h,w;
		scanf("%d%d",&h,&w);h--,w--;
		points.emplace(h,w);
		for(int h0=-1;h0<2;h0++)for(int w0=-1;w0<2;w0++){
			if(1<=h+h0&&h+h0<H-1 && 1<=w+w0&&w+w0<W-1){
				int t=0;
				for(int h1=-1;h1<2;h1++)for(int w1=-1;w1<2;w1++){
					t+=points.find({h+h0+h1,w+w0+w1})!=points.end();
				}
				v[t-1]--;
				v[t]++;
			}
		}
	}
	for(auto &e:v)printf("%lld\n",e);
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  string s;
  cin >> N >> s;

  int rnum = 0;
  for (int i = 0; i < N; i++) if (s[i] == 'R') rnum++;

  int ans = 0;
  for (int i = 0; i < rnum; i++) if (s[i] == 'W') ans++;

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


Measured memory_bytes: 3736
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N>>H;
  cout<<H+max(10-N,0LL)*100<<endl;
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int N;
int A[111111];
int X[111111];
signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];

	int sumA=accumulate(A,A+N,0ll);
	int sumX=sumA/2;

	int tmp=0;
	for(int i=1;i<N;i+=2)tmp+=A[i];

	X[0]=sumX-tmp;
	for(int i=1;i<N;i++){
		X[i]=A[i-1]-X[i-1];
	}

	rep(i,N){
		if(i)cout<<" ";
		cout<<X[i]*2;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5180