akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  if(abs(N-M) > 1){
    cout << 0 << endl;
    return 0;
  }
  long long int ans = 1, mod = 1000000007;
  for(int i = 1; i <= N; ++i){
    ans *= i;
    ans %= mod;
  }
  for(int i = 1; i <= M; ++i){
    ans *= i;
    ans %= mod;
  }
  if(N == M){
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>
#include <unordered_map>

using ll = long long;

using namespace std;

#define INF 200010

int dp[1 << 26];

int main() {
    string s;
    cin >> s;
    int len = s.size();
    vector<int> rui(1, 0);
    for (int i=0; i<len; i++) {
        rui.push_back(rui.back());
        rui.back() ^= (1 << (s[i] - 'a'));
    }
    fill(begin(dp), end(dp), INF);
    dp[0] = 0;
    for (int i=0; i<=len; i++) {
        for (int j=0; j<=26; j++) {
            int from = rui[i];
            if (j > 0) from ^= (1 << (j-1));
            dp[rui[i]] = min(dp[rui[i]], dp[from] + 1);
        }
    }
    cout << max(dp[rui[len]], 1) << '\n';
    return 0;
}


Measured memory_bytes: 263544
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int N;
            cin >> N;
        int c1 = 0;
        int c2 = 0;
            for(int i = 1; i <= N; i++){
                for(int k = 1; k <= i; k++){
                    if(i % k == 0){
                        c1 += 1;
                    }
                        //if(c1 == 8){
                        //    c2 += 1;
                        //}
                        //    c1 = 0;
                }
                        if(i % 2 != 0 && c1 == 8){
                            c2 += 1;
                        }
                            //c1 = 0;
                //cout << i << "約数個数" << c1 << " " << c2 << endl;
                            c1 = 0;
            }
                cout << c2;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int p,q,r; cin >> p >> q >> r;
    cout << p+q+r - max(max(p,q), r) << endl;
    return 0;
}


Measured memory_bytes: 3564
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    i = 2
    arr = [1, 1]
    seek = 0
    while seek < len(a) and a[seek]==1:
        arr[1] = 0
        seek+=1
    while i<=N:
        if seek < len(a) and i == a[seek]:
            arr[0], arr[1] = arr[1], 0
            seek+=1
        else:
            arr[0], arr[1] = arr[1], (arr[0]+arr[1])%MOD
        i+=1
    print(arr[1])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46428
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define inf 2147483647
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;

int main () {
    int a, b, c;
    read(a), read(b), read(c);
    write(std::min(b / a, c)), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	
	int N,M;
	cin>>N>>M;
	
	int S = 0;
	for(int i=0;i<M;i++){
		int A;
		cin>>A;
		S+=A;
	}
	
	N -= S;
	if(N<0)cout<<-1<<endl;
	else cout<<N<<endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 123;
#define int long long 
int n, m;
pair <int, int> a[maxn];
string s, t;
main () { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;   
    multiset <int> q;
    for(int i = 1; i <= n; i++) {
    	int x;
    	cin >>x;
    	q.insert(x);
    }

    for(int i = 1; i <= m; i++) {
    	cin >> a[i].second >> a[i].first;
    }

    sort(a + 1, a + m + 1);
    reverse(a + 1, a + m + 1);

    for(int i = 1; i <= m; i++) {
    	while(*q.begin() < a[i].first && a[i].second){
    		int x = *q.begin();
    		q.erase(q.find(x));
    		q.insert(a[i].first);
    		a[i].second--;
    	}
    }
    int ans = 0;
    while(q.size()) {
    	int x = *q.begin();
    	ans += x;
    	q.erase(q.find(x));
    }
    cout <<ans;
}




Measured memory_bytes: 9920
S = input()

Flag = True
# Lは奇数
N = len(S)

for i in range(N//2):
    if S[i] != S[-(i+1)]:
        Flag = False

for j in range( (N-1)//2 ):
    if S[j] != S[(N-1)//2 - 1 - j]:
        Flag = False

for k in range( (N+3)//2 -1 , N ):
    if S[k] != S[-(k+1)]:
        Flag = False

if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using D=long double;
using P=pair<ll,ll>;
vector<string> v;
int n;
void dfs(int i,int m,string s){
	if(i==n){
		v.eb(s);
	}
	int c[10]={};
	for(auto &e:s){
		c[(int)(e-'a')]++;
	}
	int cnt=0;
	for(int j=0;j<m;j++){
		if(c[j]==0){
			cnt++;
		}
	}
	if(cnt>n-i)return;
	for(int j=0;j<m;j++){
		string t=s+(char)('a'+j);
		dfs(i+1,m,t);
		if(c[j]==0)break;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		dfs(0,i,"");
	}
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	for(int i=0;i<v.size();i++){
		cout<<v[i]<<'\n';
	}
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);

	ll ans = 1, mod = 1e9+7;
	vector<int> mp(n);
	for (auto &i : a)
	{
		cin >> i;
		if (i > 0) ans = ans * (mp[i-1] - mp[i]) % mod;
		++mp[i];
	}

	if (mp[0] > 3) { cout << "0\n"; return 0; }
	ll f = 6;
	for (int i = 1; i <= 3-mp[0]; ++i) f /= i;
	ans *= f;
	ans %= mod;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e7+5;
void solve(){
    int a,b; 
    cin>>a>>b; 
    cout<<max(0,a-2*b)<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3592
n = input()
l = len(n)
t = 0
for i in range(2**(l-1)):
	chk = [False] * (l)
	for j in range(l-1):
		if (i >> j) & 1:
			chk[j] = True
	v = ""
	for j in range(l):
		v += n[j]
		if chk[j]:
			v += ","
	u = v.split(",")
	for i in u:
		t += int(i)
print (t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    k = min(n,k);
    vector<ll> h(n);
    REP(i,n) cin >> h[i];
    sort(ALL(h));
    REP(i,k) h.pop_back();
    ll ans = 0;
    ans = accumulate(ALL(h),0LL);

    cout << ans << '\n';

    return 0;
}

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

int
main (void)
{
  int n = 0;
  int problems[4] = {0, 0, 0, 0};
  string result;

  cin >> n;

  for (int i = 0; i < n; i++)
    {
      cin >> result;

      if (result == "AC")
        problems[0]++;
      else if (result == "WA")
        problems[1]++;
      else if (result == "TLE")
        problems[2]++;
      else if (result == "RE")
        problems[3]++;
    }

  cout << "AC x " << problems[0] << "\n";
  cout << "WA x " << problems[1] << "\n";
  cout << "TLE x " << problems[2] << "\n";
  cout << "RE x " << problems[3] << "\n";

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	#ifdef PIYUSH_HOME
		I_O;
	#else
	#define print(...) 0
	#endif
	int n, m;
	cin >> n >> m;
	std::vector<std::pair<int, int> > p1(m);
	set<pair<int, int> > s;
	for (int i = 0; i < m; ++i)
	{
		int x, y;
		cin >> x >> y;
		p1[i] = {x, y};
		s.insert({y, x});
	}
	int tot = 0;
	int ex = 0;
	int x, y;
	sort(p1.begin(), p1.end());
	while(!s.empty()) {
		auto o = *(s.begin());
		tot++;
		while(p1[ex].first < o.first) {
			tie(x, y) = p1[ex++];
			s.erase({y, x});
		}
	}
	cout << tot;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
struct code{
	int num;
	int pos;
	int dis;
}a[105];
int b[105];
int c[105];
int main(){
	int x;
	cin>>x;
	for(int i=1;i<=x;i++){
		cin>>a[i].num;
		a[i].pos=i;
		a[i].dis=0;
	}//输入完毕
	int n=0,flag;
	for(int i=0;i<x;i++){
		flag=0;
		for(int j=x;j>0;j--){
			if(a[j].num==a[j].pos-a[j].dis&&c[j]==0){
				b[n++]=a[j].num;
				c[j]=1;
				flag=1;
				for(int k=j+1;k<=x;k++){
					a[k].dis++;
				}
				break;
			}
		}
		if(flag==0){
			break;
		}
	}
	if(flag==0){
		cout<<"-1"<<endl;
	} else{
		for(int i=x-1;i>=0;i--){
			cout<<b[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;
int *a = nullptr;

int main()
{
	//ios::sync_with_stdio(false);
	ll n = 0, mid = 0, res1 = 0, res2 = 0;
	cin >> n;
	a = new int[n+5]{0};
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		mid += a[i];
	}
	mid /= n;
	for(int i = 0; i < n; ++i)
		res1 += p(a[i] - mid);
	mid += 1;
	for(int i = 0; i < n; ++i)
		res2 += p(a[i] - mid);
	//cout << res1 << " " << res2 << endl;
	cout << min(res1, res2) << endl;
	delete[] a;
	a = nullptr;
    return 0;
}













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

int getSumOfDigits(int n){
	int sum = 0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int total = 0;
	for(int i=1;i<=n;i++){
		int sum = getSumOfDigits(i);
		if(sum >= a && sum <=b){
			total += i;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair

int main()
{
  ll a;
  long double b;
  cin>>a>>b;
  long double ans=(long double)a*b*1.0;
  //cout<<ans<<endl;
  cout<<(ll)ans<<endl;
}


Measured memory_bytes: 3732
s = input()
K =int(input())

ll = []

for i in [1,2,3,4,5]:
    for j in range(len(s)-i+1):
        ll.append(s[j:j+i])
ll.sort()

now = ll[0]
K -= 1
counter = 1
while K!= 0:
    if ll[counter] != now:
        K-=1
        now = ll[counter]
        counter += 1
    else:
        counter += 1
print(now)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector < vector<char> > arr(h, vector<char>(w));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> arr[i][j];
		}
	}

	for(int i = 0; i < h + 2; i++) {
		for(int j = 0; j < w + 2; j++) {
			if(j == w + 1) {
				cout << "#" << endl;;
			} else if((j == 0)||(i == 0)||(i == h + 1)) {
				cout << "#";
			} else {
				cout << arr[i - 1][j - 1];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A+B;
  R = C+D;
  if (L == R) {
    cout << "Balanced" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
  else if (L > R) {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int W,H,N;
int X1[1000],X2[1000],Y1[1000],Y2[1000];
int f[3030][3030];
int compress(int *x1,int *x2,int w){
  vector<int>xs;
  for(int i=0;i<N;i++){
    if(1<=x1[i]&&x1[i]<w)xs.PB(x1[i]);
    if(1<=x2[i]&&x2[i]<w)xs.PB(x2[i]);
  }
  xs.PB(0);xs.PB(w);
  sort(ALL(xs));
  xs.erase(unique(ALL(xs)),xs.end());
  REP(i,N){
    x1[i]=find(ALL(xs),x1[i])-xs.begin();
    x2[i]=find(ALL(xs),x2[i])-xs.begin();
  }
  return xs.size()-1;
}
int main(){
  while(1){
    memset(f,0,sizeof(f));
    cin>>W>>H>>N;
    if(W==0&&H==0)break;
    REP(i,N){
      cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
    }
    W=compress(X1,X2,W);
    H=compress(Y1,Y2,H);
    for(int i=0;i<N;i++){
            f[Y1[i]][X1[i]]++;
            f[Y2[i]][X2[i]]++;
            f[Y1[i]][X2[i]]--;
            f[Y2[i]][X1[i]]--;
    }
    REP(i,H)REP(j,W){
      if(i!=0)f[i][j]+=f[i-1][j];
      if(j!=0)f[i][j]+=f[i][j-1];
      if(i!=0&&j!=0)f[i][j]-=f[i-1][j-1];
    }
    int ans=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(f[i][j])continue;
        ans++;
        queue<P>q;
        q.push(MP(j,i));
        while(!q.empty()){
          int tx=q.front().first,ty=q.front().second;
          q.pop();
          for(int k=0;k<4;k++){
            int nx=tx+dx[k],ny=ty+dy[k];
            if(nx<0||nx>W||ny<0||ny>H||f[ny][nx]>0)continue;
            q.push(MP(nx,ny));
            f[ny][nx]=1;
          }
        }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 37108
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

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

  vi a(M), b(M);
  vvi c(M);

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    for (ll j = 0; j < b[i]; j++) {
      ll k; cin >> k;
      c[i].push_back(k);
    }
  }
  vector<ll> d(1 << N, INF);
  d[0] = 0;
  
  for (ll i = 0; i <= N; i++) {
    for (ll j = 0; j < (1 << N); j++) {
      ll cnt = 0;
      for (ll k = 0; k < N; k++) {
        if ((j >> k) % 2) cnt += 1;
      }
      if (cnt != i) continue;

      for (ll k = 0; k < M; k++) {
        ll mask = 0;
        for (ll l = 0; l < c[k].size(); l++) {
          mask |= (1 << (c[k][l] - 1));
        }
        d[j | mask] = min(d[j | mask], d[j] + a[k]);
      }
    }
  }

  if (d[(1 << N) - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << d[(1 << N) - 1] << endl;
  }
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    for(int ki = K+1 ; ki<=N ; ki++){
        if(A[ki-1] > A[ki-1-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 4044
#line 1 "main.cpp"
#include <stdio.h>
#line 1 "/home/ecasdqina/cpcpp/libs/library_cpp/data_structure/segment_tree.hpp"



#include <cstdint>
#include <vector>
#include <functional>

template<class Monoid>
class segment_tree {
public:
	using T = typename Monoid::value_type;
	using size_type = std::uint_fast32_t;

	using updator = std::function<T(T)>;
	using checker = std::function<bool(T)>;
	
private:
	const size_type size_;
	size_type height_;

public:
	std::vector<T> data;
	
private:
	const size_type get_height(size_type size) const {
		size_type height = 1;
		while(1 << height <= size) height++;
		return height;
	}
	const size_type base_size() const { return 1 << height_; }

	void meld(size_type index) {
		data[index] = Monoid::operation(data[index << 1 ^ 0], data[index << 1 ^ 1]);
	}

public:
	segment_tree() = default;
	segment_tree(segment_tree&&) = default;
	segment_tree(const segment_tree&) = default;
	
	segment_tree(size_type size)
		: size_(size) {
		height_ = get_height(size);
		data.assign(base_size() << 1, T{});
	}
	T fold(size_type left, size_type right) {
		T l_value = T{};
		T r_value = T{};

		for(left += base_size(), right += base_size();
			left < right;
			left >>= 1, right >>= 1) {
			if(left & 1)  l_value = Monoid::operation(l_value, data[left++]);
			if(right & 1) r_value = Monoid::operation(data[--right], r_value); 
		}
		return Monoid::operation(std::move(l_value), std::move(r_value));
	}

	void update(size_type index, const updator& update) {
		index += base_size();
		data[index] = update(data[index]);

		while(index >>= 1) meld(index);
	}
	void update(size_type index, const T& value) { update(index, [&value](const T& x) { return Monoid::operation(x, value); }); }
	void change(size_type index, const T& value) { update(index, [&value](const T& x) { return value; }); }
	
	const size_type search(size_type left, const checker& check) {
		T val = T{};
		size_type k = left + base_size();
		while(true) {
			if(check(Monoid::operation(val, data[k]))) {
				val = Monoid::operation(val, data[k]);
				if(k & 1) {
					if((k + 1) & k) k = (k + 1) >> 1;
					else return size();
				} else {
					k = k + 1;
				}
			} else {
				if(k < base_size()) {
					k = k << 1 ^ 0;
				} else {
					return k - base_size();
				}
			}
		}
	}
	
	const T operator[](size_type index) const { return data[index + base_size()]; }
	const size_type size() const { return size_; }
	const bool empty() const { return data.empty(); }
};

template<class T>
struct monoid {
	using value_type = T;

	static value_type operation(const value_type& a, const value_type& b) { return a + b; };
};

// @docs docs/segment_tree.md


#line 3 "main.cpp"

int main() {
	int n; scanf("%d", &n);

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


Measured memory_bytes: 1720
#include <cstdio>
#include <algorithm>
using namespace std;

struct Node
{
    int par,left,right;
};

Node G[26];

void dfs(int n, int i)
{
    if(i == 0)printf(" %d", n);
    if(G[n].left != -1){
        dfs(G[n].left, i);    
    }
    if(i == 1)printf(" %d", n);
    if(G[n].right != -1){
        dfs(G[n].right, i);
    }
    if(i == 2)printf(" %d", n);
}

int main()
{
    int n,id,left,right;
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
        G[i].par = -1;
    }
    
    for(int i = 0; i < n; ++i){
        scanf("%d%d%d", &id, &left, &right);
        G[id].left = left;
        G[id].right = right;
        if(left != -1)G[left].par = id;
        if(right != -1)G[right].par = id;
    }
    
    int root;
    for(int i = 0; i < n; ++i){
        if(G[i].par == -1){
            root = i;
            break;
        }
    }
    puts("Preorder");
    dfs(root, 0);
    puts("");
    
    puts("Inorder");
    dfs(root, 1);
    puts("");
    
    puts("Postorder");
    dfs(root, 2);
    puts("");
}

Measured memory_bytes: 1040
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int MAXT=1000003;
const int MAXN=1000010;
int n;
string s;
int head[1000003],nex[MAXN],to[MAXN],top,top1,ans[MAXN];
void input()
{
	cin>>n;
	memset(head,-1,sizeof(head));
	memset(nex,-1,sizeof(nex));
}

int jisuan(char c)
{
	if(c=='A') return 1;
	if(c=='C') return 2;
	if(c=='G') return 3;
	if(c=='T') return 4;
}

void insert(int k)
{
	nex[top]=head[k%MAXT];
	head[k%MAXT]=top;
	to[top++]=k;
}

int k(string ss)
{
	int s(1);
	int sum(0);
	for(int i=0;i<ss.size();i++)
	{
		sum+=s*jisuan(ss[i]);
		s*=5;
	}
	return sum;
}

bool ff(int k)
{
	int u=head[k%MAXT];
	while(u!=-1)
	{
		if(to[u]==k) return true;
		u=nex[u];
	}
	return false;
}

void xxj()
{
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="insert"){
			cin>>s;
			int tmp=k(s);
			insert(tmp);
		}
		else{
			cin>>s;
			int tmp=k(s);
			ans[top1++]=ff(tmp);
		}
	}
}

void output()
{
	for(int i=0;i<top1;i++)
	    if(ans[i]) cout<<"yes"<<'\n';
	    else cout<<"no"<<'\n';
}

int main()
{
	input();
	xxj();
	output();
	return 0;
}

Measured memory_bytes: 14848
#include <stdio.h>

int main (void)
{
  int lake;
  int home;
  int i;
  int distance=0;
  
  scanf("%d", &lake);
  scanf("%d", &home);
  
  int house[home];
  int walk[home];
  int max_walk=0, max;
  
  for (i=0; i<home; i++)
    scanf("%d", &house[i]);
  
  for (i=0; i<home - 1; i++) {
    walk[i] = house[i+1] - house[i];
    
    if (walk[i] > max_walk) {
      max_walk = walk[i];
      max = i;
    }
  }
  
  walk[home - 1] = house[0] + (lake - house[home - 1]);
  if (walk[home - 1] > max_walk) {
    max_walk = walk[home-1];
    max = home-1;
  }
  
  for (i=0; i<max; i++)
    distance += walk[i];
  
  for (i=max+1; i<home; i++)
    distance += walk[i];
  
  printf("%d\n",distance);
  
  return 0;
}

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

int main(){
    
    int n;
    string s;
    cin >> n >> s;
    string ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i = 0; i < s.size(); ++i)
        s[i] = ans[((s[i] - 'A') + n) % 26];
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

int main(){
    int N;
    cin>>N;
    ll ans=0;
    vector<ll> B;
    B.push_back(BIG);
    for(int i=0;i<N-1;i++){
        ll x;
        cin>>x;
        B.push_back(x);
    }
    B.push_back(BIG);
    for(int i=0;i<N;i++){
        ans+=min(B.at(i),B.at(i+1));
    }
    cout<<ans<<endl;

}



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

int main() {
  int N,A;
  cin >> N;
  A = N;
  int fx = 0;
  int i = 10;
  for(; i < N;){
    fx += (A % i) / (i/10);
    A -= A % i;
    i *= 10;
  }
  fx += A / (i/10);
  if(N % fx == 0){
    cout << "Yes" << endl;
  }else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#define mst(X,Y) memset(X,Y,sizeof X)
#define mp(X,Y) make_pair(X,Y)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<long double,ll> pdl;
typedef pair<pll,pii> ppp;
typedef pair<ll,pii> plp;
int c,a,b;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",min(c,b/a));
	return 0;
} 

Measured memory_bytes: 256
using System;

class B{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int N = Ar[0],M = Ar[1],C = Ar[2], ans = 0, soy = 0;
    int[] B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int[] temp = new int[M];
    for (int i = 0; i < N; i++){
      soy = 0;
      temp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
      for (int j = 0; j < M; j++){
        soy += temp[j] * B[j];
      }
      if (soy + C > 0) ans++;
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 27476
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

ll md = 0;

set<ll>lun;

void dfs(ll d,ll now,ll nd){
    if(d==md){
        if(now!=0)lun.insert(now);
        return;
    }
    ll tmp = (ll)pow(10,d);
    if(nd==0){
        dfs(d+1,now,0);
        dfs(d+1,now+tmp,1);
    }
    else{
        if(nd==9){
            dfs(d+1,now+tmp*9,9);
            dfs(d+1,now+tmp*8,8);
        }
        else{
            dfs(d+1,now+tmp*(nd-1),nd-1);
            dfs(d+1,now+tmp*(nd),nd);
            dfs(d+1,now+tmp*(nd+1),nd+1);
        }
    }
}

int main(void){
    ll k;
    cin>>k;
    for(ll i=0;i<10;i++){
        md = i+1;
        for(ll j=0;j<=9;j++){
            dfs(0,0,j);
        }
    }
    for(auto itr = lun.begin();itr!=lun.end();++itr){
        k--;
        if(k==0){
            cout<<(*itr)<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 9856
use std::collections::HashSet;
use std::io::*;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let n: i32 = buf.trim_right().parse().unwrap();

    let mut mochimochi: Vec<i32> = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        let num: i32 = buf.trim_right().parse().unwrap();
        mochimochi.push(num);
    }

    let uniq: HashSet<i32> = mochimochi.into_iter().collect();
    
    let out = stdout();
    let mut out = out.lock();
    writeln!(out, "{}\n", uniq.len()).unwrap();

}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << max({ a + b,a - b,a * b }) << "\n";
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		PriorityQueue<Integer>pq=new PriorityQueue<>(Comparator.reverseOrder());
		int n=s.nextInt(),m=s.nextInt();
		for(int i=0;i<n;++i)
			pq.add(s.nextInt());
		for(int i=0;i<m;++i)
			pq.add(pq.poll()/2);
		System.out.println(pq.stream().mapToLong(i->i).sum());
	}
}


Measured memory_bytes: 59296
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	int ans = 0;
	int R, G, B, N;
	int a, b, c;
	vector<int> vec(3);

	for (int i = 0; i < 3; i++) {
		cin >> vec.at(i);
	}
	cin >> N;

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

	a= N/vec.at(2);

	for (int i = 0; i <= a; i++) {
		if (i * vec.at(2)==N) {
			ans++;
			continue;
		}
		b = (N - i * vec.at(2))/vec.at(1);
		for (int j = 0; j <= b; j++) {
			if (j * vec.at(1)==N- i * vec.at(2)) {
				ans++;
				continue;
			}
			if ((N - (i * vec.at(2) + j * vec.at(1))) % vec.at(0) == 0) {
				ans++;
 		    }
		}
	}



	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int n,a[110];
bool done[100100],memo[100100];

bool solve(int x){
	int i;
	if(done[x]){
		return memo[x];
	}
	done[x] = true;
	for(i=0; i<n; ++i){
		if(x<a[i]){
			break;
		}
		if(!solve(x-a[i])){
			return memo[x] = true;
		}
	}
	return memo[x];
}

int main(void){
	int k,i;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	cout << ((solve(k))?"First":"Second") << endl;
	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S[0]=='0'&&S[1]!='0'){
        if(S[2]=='0'&&S[3]=='0')
            cout<<"MMYY";
        else if(S[2]=='1'&&S[3]!='0'&&S[3]!='1'&&S[3]!='2')
            cout<<"MMYY";
        else if(S[2]!='0'&&S[2]!='1')
            cout<<"MMYY";
        else
            cout<<"AMBIGUOUS";
    }
    else if(S[0]=='1'&&S[1]=='0'||S[1]=='1'||S[1]=='2'){
        if(S[2]=='0'&&S[3]=='0')
            cout<<"MMYY";
        else if(S[2]=='1'&&S[3]!='0'&&S[3]!='1'&&S[3]!='2')
            cout<<"MMYY";
        else if(S[2]!='0'&&S[2]!='1')
            cout<<"MMYY";
        else
            cout<<"AMBIGUOUS";
    }
    else if(S[2]=='0'&&S[3]!='0'){
        if(S[0]=='0'&&S[1]=='0')
            cout<<"YYMM";
        else if(S[0]=='1'&&S[1]!='0'&&S[1]!='1'&&S[1]!='2')
            cout<<"YYMM";
        else if(S[0]!='0'&&S[1]!='1')
            cout<<"YYMM";
        else
            cout<<"AMBIGUOUS";
    }
    else if(S[2]=='1'&&S[3]=='0'||S[3]=='1'||S[3]=='2'){
        if(S[0]=='0'&&S[1]=='0')
            cout<<"YYMM";
        else if(S[0]=='1'&&S[1]!='0'&&S[1]!='1'&&S[1]!='2')
            cout<<"YYMM";
        else if(S[0]!='0'&&S[1]!='1')
            cout<<"YYMM";
        else
            cout<<"AMBIGUOUS";
    }
    else
        cout<<"NA";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main() {
	int i, j, k, t, N, M;
	char A[51][51], B[51][51];

	cin >> N >> M;

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

	for (i = 0; i < M; i++) {
		for (j = 0; j < M; j++) {
			cin >> B[i][j];
		}
	}

	int flag;
	//cout << endl;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			//cout<< A[i][j];
			flag = 0;
			for (k = 0; k < M; k++) {
				if (k > 49) {
					flag = 1;
					break;
				}
				for (t = 0; t < M; t++) {
					//cout << B[k][t];
					if (t > 49) {
						flag = 1;
						break;
					}
					if (B[k][t] != A[i+k][j+t]) {
						flag = 1;
						break;
					}
				}
				if (flag == 1) break;
				//cout << endl;
			}
			if (flag == 0) {
				cout << "Yes" << endl;
				
				return 0;
			}
		}
		//cout << endl;
	}

	cout << "No" << endl;


	/*
	for (i = 0; i < M; i++) {
		for (j = 0; j < M; j++) {
			cout<< B[i][j];
		}
		cout << endl;
	}
	*/








	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

using namespace std;

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

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

  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
// Running Offline
// g++ tester.cpp
// ./a.out
//#include "/Users/manasgupta/Desktop/stdc++.h"

 #include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pi pair<int,int>
#define pb push_back
#define fi first
#define se second
// #define mp make_pair
#define inf 1e9
#define EPS 1e-6
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FILEIO(name1, name2) \
    freopen(name1".txt","r",stdin); \
    freopen(name2".txt","w",stdout);

const int N=105;
const int mod = 119 << 23 | 1;

int power(int a, int b, int c)
{
	int res=1;
	while (b)
	{
		if (b&1) res=(res*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return res;
}

int n,w;
int wt[N], v[N];
int dp[N][100005];

signed main()
{
	IOS;
	cin>>n>>w;
	for (int i=1; i<=n; i++)
	{
		cin>>wt[i]>>v[i];
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=0; j<=w; j++)
		{
			if (wt[i] > j)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j] = max(dp[i-1][j-wt[i]]+v[i], dp[i-1][j]);
			}
		}
	}
	cout<<dp[n][w]<<endl;
    return 0;
}





Measured memory_bytes: 79360
import numpy as np

a, b, h, m = map(int, input().split())
theta_h = 2 * np.pi * (h * 60 + m) / 720
theta_m = 2 * np.pi * m / 60
dx = a * np.cos(theta_h) - b * np.cos(theta_m)
dy = a * np.sin(theta_h) - b * np.sin(theta_m)
d = np.sqrt(dx ** 2 + dy ** 2)
print(d)


Measured memory_bytes: 27156
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M;
int A[100];
double sum=0;

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }

    int c=0;
    rep(i,N){
        if(A[i]>=sum/(4.0*M)) c++;
    }

    if(c>=M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

int main() {
  int n; cin>>n;
  if(n%2==0) cout<<n<<endl;
  else cout<<2*n<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	int cost;
	int next;

	Edge(int n,int c)
	{
		next=n;
		cost=c;
	}
};

vector<Edge> g[2500];
int d[2500];
bool used[2500];
char c[51][51];

int main()
{
	int h,w;
	int white=0;
	int ans=0;
	cin>>h>>w;
	fill(d,d+2500,100000);
	fill(used,used+2500,false);
	for(int i=0;i<h;i++)
	{
		cin>>c[i];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(c[i][j]=='.')
			{
				white++;
			}
			if(c[i][j]=='#')
			{
				continue;
			}
			if(i>0&&c[i-1][j]=='.')
			{
				g[50*i+j].push_back(Edge(50*(i-1)+j,1));
			}
			if(j>0&&c[i][j-1]=='.')
			{
				g[50*i+j].push_back(Edge(50*i+j-1,1));
			}
			if(i<h-1&&c[i+1][j]=='.')
			{
				g[50*i+j].push_back(Edge(50*(i+1)+j,1));
			}
			if(j<w-1&&c[i][j+1]=='.')
			{
				g[50*i+j].push_back(Edge(50*i+j+1,1));
			}
		}
	}
	/*
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cerr<<g[50*i+j].size()<<endl;
		}
	}*/

	//ダイクストラ
	d[0]=0;
	while(true)
	{
		int v=-1;
		for(int u=0;u<2500;u++)
		{
			if(!used[u] && (v==-1 || d[u]<d[v]))
				v=u;
		}
		if(v == -1)
		{
			break;
		}
		
		used[v]=true;
		for(int u=0;u<g[v].size();u++)
		{
			Edge n = g[v][u];
			if(d[n.next]>d[v]+n.cost)
				d[n.next]=d[v]+n.cost;
		}
	}
	/*
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cerr<<d[50*i+j]<<endl;
		}
	}*/

	//塗りつぶす場所
	ans = white-d[50*(h-1)+w-1]-1;
	if(d[50*(h-1)+w-1]==100000)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------
const int V = 100005;
//隣接リストを２部グラフで
//２部グラフは一列のVIの配列で記述（行固定列可変）
VI to[V*2];
bool visited[V*2];
VI cnt;

//def function, class
//------------------------------------------
void dfs(int v){
  if(visited[v]) return;
  visited[v] = true;
  cnt[v/V]++;//cnt[0]はx，cnt[1]はyのノードの数
  for(int u : to[v]) dfs(u);
}
//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;
  REP(i, N){
    int x, y;
    cin >> x >> y;
    y += V;
    to[x].pb(y);
    to[y].pb(x);
  }
  int ans=0;
  //連結しているノードの数を数える
  REP(i, V*2){
    if(visited[i]) continue;
    cnt = VI(2);
    dfs(i);
    ans += cnt[0]*cnt[1];
  }

  ans -= N;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);re(i, n) scanf("%lld", &a[i]);
  vll b(n, 0);
  for(int i=1;i<n;i++) b[i] = a[i] - a[i-1];

  vll p(n);
  for(int i=0;i<n;i++) p[i] = i;

  vvl nxt = VV(64, n, 0, ll);
  ll m, k;std::cin >> m >> k;
  vll ans(n);
  ans[0] = a[0];
  for(int i=0;i<m;i++){
    ll x;scanf("%lld", &x);x--;
    swap(p[x], p[x+1]);
  }
  nxt[0] = p;
  for(int i=0;i<63;i++){
    for(int j=0;j<n;j++){
      nxt[i+1][j] = nxt[i][nxt[i][j]];
    }
  }
  for(int i=0;i<n;i++) p[i] = i;
  for(int i=0;i<64;i++){
    if(((k>>i)&1)==0) continue;
    for(int j=0;j<n;j++) p[j] = nxt[i][p[j]];
  }

  for(int i=1;i<n;i++) ans[i] = ans[i-1] + b[p[i]];
  for(int i=0;i<n;i++) std::cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 56168
#include <iostream>
#include <sstream>
#include <float.h>
using namespace std;

#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>


const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> ii;


// Custom comparator
struct cmp {
    bool operator()(int a, int b) {
        return b < a;
    }
};


// Solution class
//class Solution {
//public:
//    char sol(char c) {
//        return c >= 'a' && c <= 'z' ? 'a' : 'A';
//    }
//};



// Run code
int main(int argc, char const *argv[])
{

    int N;
    scanf("%d", &N);

    unordered_map<string, int> cnt;
    for (int i = 0; i < N; i++) {
        string s;
        cin>>s;
        cnt[s]++;
    }

    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    while(true){
    string s;
    cin >> s;
    reverse(all(s));
    if (s=="0") break;
    vector<vector<int>> f(11,vector<int>(11,0));
    int ans=0;
    rep(i,s.size()){
        int u=s[i]-'0';
        vector<vector<int>> ff=f;
        rep(j,11){
            rep(k,11){
                f[(j+(u*k*10))%11][(k*10)%11]=ff[j][k];
            }
        }
        f[u][1]++;
        if (u!=0) {rep(i,11) ans+=f[0][i];}
    }
    cout << ans << endl;
}}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int v[n], c[n];
	REP(i, n) cin >> v[i];
	REP(i, n) cin >> c[i];

	ll ans = 0;
	REP(i, n){
		if (v[i] - c[i] > 0) ans += v[i] - c[i];
	}

	cout << ans << endl;


}


Measured memory_bytes: 256
import numpy as np

N,M,C=list(map(int,input().split()))
B=np.array(list(map(int,input().split())))
A=np.zeros((N,M))
for i in range(N):
    A[i]=list(map(int,input().split()))
    
def calc(a):
    ret=0
    for i in range(M):
        ret+=a[i]*B[i]
    ret+=C
    if ret>0:
        return 1
    return 0

ans=0
for i in range(N):
    ans+=calc(A[i])
print(ans)

Measured memory_bytes: 12508
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(abs(a-b)<abs(a-c))cout<<"A"<<endl;
	else cout<<"B"<<endl;
}








Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int K=scan.nextInt();
        int[] x=new int[N];
        int i;
        int distance=0;
        for(i=0;i<N;i++){
            x[i]=scan.nextInt();
            if(K/2<x[i]){
                distance+=2*Math.abs(K-x[i]);
            }
            else{
                distance+=2*x[i];
            }
        }
        System.out.println(distance);

    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
const int MAX = 1777771;
const int LEN = 14;
int D[MAX];
int getChar(char ch)
{
	if (ch == 'A')
		return 1;
	else if (ch == 'G')
		return 2;
	else if (ch == 'C')
		return 3;
	else if (ch == 'T')
		return 4;
	else
		return 0;
}
long long hash(char s[])
{
	long long key=0;
	for (int i = 0; i < strlen(s); i++)
		key = key * 4 + getChar(s[i]);
	return key;
}
int main()
{
	int n;
	scanf("%d", &n);
	char com[9],s[LEN];
	for (int i = 0; i < n; i++)
	{
		scanf("%s %s", com, s);
		int key = hash(s);
		if (com[0] == 'i')
			D[key%MAX] = 1;
		else
		{
			if (D[key%MAX])
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 8024
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

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

int main() {
  int N; std::cin >> N;
  std::vector<int> A(N+2);
  A[0] = 0; A[N+1] = 0;
  for (int i = 1; i <= N; ++i) std::cin >> A[i];

  std::vector<int> L(N+2), R(N+2);
  L[0] = 0; R[N+1] = 0;
  for (int i = 0; i <= N; ++i) L[i+1] = gcd(L[i], A[i]);
  for (int i = N; i >= 0; --i) {
    R[i] = gcd(R[i+1], A[i]);
  }

  int max_gcd = 0;
  for (int i = 1; i <= N; ++i) {
    int v = gcd(L[i], R[i+1]);
    max_gcd = std::max(max_gcd, v);
  }
  std::cout << max_gcd << std::endl;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static int toori = 0;

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int m = sc.nextInt();

        boolean[] broken = new boolean[n + 1];

        for (int i = 0; i < m; i++) {
            broken[sc.nextInt()] = true;
        }

        long[] dp = new long[n + 2];
        dp[n + 1] = 0;
        dp[n] = 1;

        for (int i = n - 1; i >= 0; i--) {
            if (broken[i]) {
                continue;
            }
            dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
        }

        out.println(dp[0]);

        out.flush();

    }

    static class Toi {
        public int x;
        public int y;

        public Toi(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }

            if (this == obj) {
                return true;
            }

            if (this.getClass() != obj.getClass()) {
                return false;
            }

            Toi toi = (Toi) obj;
            return x == toi.x && y == toi.y;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int T(int i, int j, vector<vector<int>> a)
{
  int t = a.at(i).at(j);
  int up = 0;
  int left = 0;
  if(i==1 && j==1) return a.at(i).at(j);
  if(i!=1)
  {
    up += T(i-1,j,a);
  }
  if(j!=1)
  {
    left += T(i,j-1,a);
  }
  
  t += max(up,left);
  
  return t;
}


int main()
{
  int N;
  cin >> N;
  vector<vector<int>> a(3, vector<int>(101));
  
   for(int i=1; i<=N; i++)
  {
    cin >> a.at(1).at(i);
  }
  for(int i=1; i<=N ; i++)
  {
    cin >> a.at(2).at(i);
  }
  
  int t = T(2,N,a);
  
  cout << t << endl;
}
  
  

Measured memory_bytes: 3744