akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct SkewHeap{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  SkewHeap *l,*r;
  T val;
  F &f;
  G &g;
  E add,e;
  
  SkewHeap(T val,F &f,G &g,E e):val(val),f(f),g(g),add(e),e(e){l=r=NULL;}
  
  void eval(){
    if(add==e) return;
    if(l) l->add=g(l->add,add);
    if(r) r->add=g(r->add,add);
    val=f(val,add);
    add=e;
  }
  
  T top(){
    return f(val,add);
  }
  
};

template<typename T, typename E>
SkewHeap<T, E>* meld(SkewHeap<T, E> *a,SkewHeap<T, E> *b){
  if(!a) return b;
  if(!b) return a;
  if(a->top() > b->top())  swap(a,b);
  a->eval();
  a->r=meld(a->r,b);
  swap(a->l,a->r);
  return a;
}

template<typename T, typename E>
SkewHeap<T, E>* pop(SkewHeap<T, E>* a){
  a->eval();
  auto res=meld(a->l,a->r);
  free(a);
  return res;
};
//END CUT HERE

signed main(){
  using Heap = SkewHeap<int, int>;
  Heap::F f=[](int a,int b){return a+b;};
  Heap::G g=[](int a,int b){return a+b;};
  Heap* base = new Heap(0,f,g,0);
  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      base=meld(base, new Heap(-x,f,g,0));
    }
    if(s=="extract"){
      x=base->top();
      base=pop(base);
      cout<<-x<<endl;
    }
  }
  return 0;
}
/*
  verified on 2018/01/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C&lang=jp
*/



Measured memory_bytes: 65712
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);} 


int32_t main()
{
	int n,l;
	cin >> n >> l;
	int s = 0;
	for(int i = 1;i<= n;i++)
	{
		s += i+ l - 1;
	}
	int minabs = 100000;
	int rem;
	for(int i= 1;i<= n;i++)
	{
		if(minabs > abs(i+l-1))
		{
			rem = i;
			minabs = abs(i+l-1);
		}
	}
	cout << s - (l + rem - 1) << endl;
}

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

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

int main() 
{
    int N;
    cin >> N;
    
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            for (int k = 1; k <= N; k++) {
                ans += gcd2(i, gcd2(j, k));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <stdio.h>
 
int main(void)
{
	int a,b;
 
	scanf("%d%d",&a,&b);
 
	if(a<b)
		printf("a < b\n");
	
	else if(a>b)
		printf("a > b\n");
		
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
while True:
    line = input().split()
    a = int(line[0])
    op = str(line[1])
    b = int(line[2])
    if op == '?':
        break
    if op == '+':
        ans = a + b
    if op == '-':
        ans = a - b
    if op == '*':
        ans = a * b
    if op == '/':
        ans = int(a / b)
    print(ans)


Measured memory_bytes: 5596
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
string str;
int s[26];

int main()
{
  cin>>str;
  for(int i=0;i<str.size();i++)
  s[str[i]-'a']++;
  for(int i=0;i<26;i++)
  {
  	if(s[i]&1==1)
  	{
  		puts("No");
  		return 0;
	  }
  }
  puts("Yes");
  
}

Measured memory_bytes: 256
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    //test {

        ll n, W;
        cin >> n >> W;
        ll w[n], v[n];
        sidha (i, 0, n) cin >> w[i] >> v[i];

        ll dp[n+1][W+1];
        memset(dp, -1, sizeof(dp));
        dp[0][W] = 0;

        sidha (i, 0, n) {
            sidha (j, 1, W+1) {
                //cout<<i<<'*'<<j<<'-'<<dp[i][j]<<' ';
                if (~dp[i][j]) {//cout<<i<<' '<<j<<'\n';
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
                    if (w[i] <= j) {
                        dp[i+1][j-w[i]] = max(dp[i+1][j-w[i]], dp[i][j]+v[i]);
                    }
                }
            }
        } 

        ll ans = 0;
        sidha (i, 0, W+1)
            ans = max(ans, dp[n][i]);

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


Measured memory_bytes: 79232
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <math.h>
#include <stdio.h>
#define ll long long
#define anf 0x3f3f3f3f
using namespace std;
int main()
{
    int a,b,c;

    while(cin>>a>>b>>c)
    {
        if(a<b)
        swap(a,b);
        if(a<c)
        swap(a,c);
        if(b<c)
        swap(b,c);

        int ans=0;
        ans=ans+a-b;
        c=c+ans;
        if((a-c)%2==1)
            ans+=(a-c+1)/2+1;
        else
            ans+=(a-c)/2;
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W;
    int N;
    cin >> H >> W >> N;

    map<p, int> m;

    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                int y = a - j;
                int x = b - k;
                if(x < 0 || y < 0 || W - 3 < x || H - 3 < y) continue;
                m[make_pair(y, x)]++;
            }
        }
    }

    vector<ll> ans(10);
    
    for(auto i = begin(m); i != m.end(); i++) {
        ans[i -> second]++;
    }

    ans[0] = (H - 2LL) * (W - 2LL);

    for(int i = 1; i < 10; i++) ans[0] -= ans[i];

    for(int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 56576
N,X,M=map(int,input().split())

ans = 0
A = [X]
tmp = X

first=0
firstCnt=0
loop=0
loopLen=0
loopCnt=0
remain=0
remainCnt=0

induces=[ -1 for _ in range(M+1)]

for n in range(1,M+1):
	cur = ( tmp ** 2 ) % M
	if induces[ cur ] != -1:
		index = induces[ cur ]
		first = sum(A[:index])
		firstCnt = len(A[:index])
		loop = sum(A[index:])
		loopLen = len(A[index:])
		loopCnt = (N-firstCnt)//loopLen
		remainCnt = (N-firstCnt)%loopLen
		remain = sum(A[index:index+remainCnt])

		# print(first,firstCnt,loop,loopLen,loopCnt,remainCnt,remain)
		# print(cur, induces[ cur ], A[:induces[ cur ]], A[induces[ cur ]:])
		break
	induces[ cur ] = n
	A.append( cur )
	tmp = cur

ans = first + loop * loopCnt + remain
print( ans )


Measured memory_bytes: 76996
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <map>
#include <stack>
#include <cstdio>
using namespace std;

struct Node {
  bool re;
  bool onetwo;
  int prev;
};

const int MAXN = 10002;
int N;
Node ns[MAXN];
bool vis[MAXN];

string toS(int x) {
  char buff[100];
  sprintf(buff, "%d", x);
  return string(buff);
}

bool canRead(int pos) {
  return !ns[pos].re && !ns[pos].onetwo;
}

void read(int pos) {
  vis[pos] = true;
  cout << pos+1 << endl;
  if(pos && !vis[pos-1] && ns[pos-1].re) {
    read(pos-1);
  }
  if(ns[pos].prev != -1 && !vis[ns[pos].prev]) {
    read(ns[pos].prev);
  }
}

int main() {
  while(cin >> N && N) {
    map<string, stack<int> > onetwo;
    for(int i = 0; i < N; ++i) {
      string s;
      cin >> s;
      Node &n = ns[i];
      if(s == "v") {
	n.re = true;
	n.onetwo = false;
	n.prev = -1;
      } else if(s == "-") {
	n.re = false;
	n.onetwo = false;
	n.prev = -1;
      } else {
	if(*s.rbegin() == 'v') {
	  n.re = true;
	  s.erase(s.end()-1);
	} else {
	  n.re = false;
	}
	int k = (int)s.size()-1;
	while(isdigit(s[k])) --k;
	++k;
	string t = s.substr(0, k);
	int num = atoi(s.substr(k).c_str());
	string p = t + toS(num+1);
	if(onetwo[p].size()) {
	  n.prev = onetwo[p].top();
	  onetwo[p].pop();
	} else {
	  n.prev = -1;
	}
	if(num != 1) {
	  n.onetwo = true;
	  onetwo[s].push(i);
	} else {
	  n.onetwo = false;
	}
      }
    }
    fill(vis, vis+MAXN, false);
    for(int i = 0; i < N; ++i) {
      if(!vis[i] && canRead(i)) {
	read(i);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 9716
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    string S,T;
    cin >> S >> T;

    int s_Table[26],t_Table[26];
    for(int i=0;i<26;i++){
        s_Table[i] = -1;
        t_Table[i] = -1;
    }

    for(int i=0;i < S.size();i++){
        if(s_Table[S[i] - 'a'] != -1){
            if(s_Table[S[i] - 'a'] != T[i] - 'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(t_Table[T[i] - 'a'] != -1){
            if(s_Table[S[i] - 'a'] != T[i] - 'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(s_Table[S[i] - 'a'] < 0){s_Table[S[i] - 'a'] = T[i] - 'a';}
        if(t_Table[T[i] - 'a'] < 0){t_Table[T[i] - 'a'] = S[i] - 'a';}        
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <cstdio>
#include <cctype>
using namespace std;

int main(){
	char A;
	int C[26]={0},i;
	while( scanf("%c", &A)!= EOF){
		
		if(isalpha(A)){
			A=tolower(A);
		    int i=A-'a';
		    C[i]++;
		}
	}
	
	for(int i=0; i<26; i++){
		printf("%c : %d\n",i+'a',C[i]);
	}

	return 0;
}

Measured memory_bytes: 2760
n=int(input())
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for kk in range(n):
	b,f,r,v=map(int,input().split())
	count[b-1][f-1][r-1]+=v
for cc in range(4):
	for aa in range(3):
		for bb in range(10):
				print(' '+str(count[cc][aa][bb]),end='')
		print()
	if cc!=3:
		print('#'*20)


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

int main() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];

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


    ll ans = 0;
    // Iter through all pairs
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ll ub = lower_bound(arr.begin(), arr.end(), arr[j] + arr[i]) - arr.begin();
//            cout << "pos for pair " << arr[i] << ", " << arr[j] << \
//            " = " << ub << endl;
            ans = ans + (ll) ub - j - 1;
        }
    }

    cout << ans << endl;
}

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

int a, b, c;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	for(int i=1; i<=4000; ++i){
		if(i % 60 == c && i % (a+b) <= a){
			cout << i << "\n";
			return 0;
		}
	}
	cout << "-1\n";
}


Measured memory_bytes: 3116
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a[] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    if(a[x-1] == a[y-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100010,p=1e9+7;
int add(int x,int y){return(x+y)%p;}
int mul(int x,int y){return 1ll*x*y%p;}
int mpow(int a,int n){
    int ret=1;
    while(n){
        if(n&1)ret=mul(ret,a);
        a=mul(a,a);
        n/=2;
	}
	return ret;
}
int fac[N],inv[N];
int C(int n,int m){
	if(m>n)return 0;
    return mul(fac[n],mul(inv[m],inv[n-m]));
}
int n,k;
int tot,bian[N<<1],nxt[N<<1],head[N];
void add_edge(int x,int y){
    ++tot,bian[tot]=y,nxt[tot]=head[x],head[x]=tot;
}
int rd[N],fa[N];
int ans=1;
void dfs(int x,int f,int col){
	fa[x]=f;
	if(f)col+=rd[f]-1;
	if(fa[f])col++;
    for(int i=head[x];i;i=nxt[i]){
        int y=bian[i];
        if(y==f)continue;
        rd[x]++;
	}
	if(!rd[x])return;
	ans=mul(ans,C(col-1,rd[x]));
	ans=mul(ans,fac[rd[x]]);
	for(int i=head[x];i;i=nxt[i]){
	    int y=bian[i];
	    if(y==f)continue;
	    dfs(y,x,col-rd[x]);
	}
}
int main(){
//	freopen("1.in","r",stdin);
	fac[0]=1;
	for(int i=1;i<N;++i)fac[i]=mul(fac[i-1],i);
	inv[N-1]=mpow(fac[N-1],p-2);
	for(int i=N-2;~i;--i)inv[i]=mul(inv[i+1],i+1);
    cin>>n>>k;
    for(int i=1;i<n;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        add_edge(x,y);
        add_edge(y,x);
	}
	ans=k;
	dfs(1,0,k);
	cout<<ans<<endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    
    int total = 0;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        total += min(x, abs(x - K)) * 2;
    }

    cout << total << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i

b = []
c = []
q.times do
  b_i, c_i = gets.chomp.split.map(&:to_i)
  b << b_i
  c << c_i
end

hash = Hash.new(0)
s = a.sum
a.each do |a_i|
  hash[a_i] += 1
end

q.times do |i|
  b_i = b[i]
  c_i = c[i]

  s -= hash[b_i] * b_i
  s += hash[b_i] * c_i
  hash[c_i] += hash[b_i]
  hash[b_i] = 0

  puts s
end


Measured memory_bytes: 29992
// spnauT
//
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int _b=(b),i=(a);i<_b;++i)
#define ROF(i,b,a) for(int _a=(a),i=(b);i>_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(),(x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define nl '\n'
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long LL;typedef pair<int,int> PII;
typedef vector<int>VI;typedef vector<LL>VL;typedef vector<PII>VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

int main()
{
	IO();
	cint2(A,B);
	if(A <= 0 && B >= 0) cout << "Zero" << nl;
	else if(A > 0) cout << "Positive" << nl;
	else
	{
		if(B >= 0) B = -1;
		if((B-A) & 1) cout << "Positive" << nl;
		else cout << "Negative" << nl;
	}

	return 0;
}

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

using namespace std;

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

  if (k * 500 >= x)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline

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

    for i in range(N):
        A[i] -= i+1
    A.sort()
    b = A[N//2]
    print(sum([abs(a - b) for a in A]))


if __name__ == '__main__':
    main()


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

int main() {
  int n, k;
  cin >> n >> k;
  int h, cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h >= k) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	int n;
	scanf("%d",&n);
	printf("%d\n",n*(n+1)/2);


	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int a,b;
int main()
{
cin>>a;
cin>>b;
if (a<=8&&b<=8) printf("Yay!\n"); else printf(":(\n");
    return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		StringBuilder sb = new StringBuilder(str);

		String string = sc.nextLine();
		int q = Integer.parseInt(string);



		for (int i = 0; i < q; i++) {
			String line = sc.nextLine();
			String[] order = line.split(" ");
			int a = Integer.parseInt(order[1]);
			int b = Integer.parseInt(order[2])+1;

			if (order[0].equals("print")) {
				System.out.println(sb.substring(a, b));
			} else if (order[0].equals("reverse")) {
				StringBuilder SB = new StringBuilder(sb.substring(a, b));
				sb.replace(a, b, SB.reverse().toString());
			} else if (order[0].equals("replace")) {
				sb.replace(a, b, order[3]);
			}
		}

	}

}

Measured memory_bytes: 28440
def main():
    _ = input()
    A = list(map(int, input().split()))
    A_list = []
    count = 0
    for a in A:
        if a < 0:
            count += 1
            A_list.append(a * -1)
        else:
            A_list.append(a)
    if count % 2 == 0:
        print(sum(A_list))
    else:
        print(sum(A_list)-min(A_list) * 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14284
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	string s;
	int am, pm;
	while(cin >> s) {
		cin >> am >> pm;
		cout << s << " " << am + pm << " " << am * 200 + pm * 300 << endl;
	}
    return 0;
}

Measured memory_bytes: 1200
/*
  AOJ #1378
 */
#include <stdio.h>

long long memo[100][100];

long long combi(int n, int r)
{
  long long ret;
  
  if(ret=memo[n][r])
    return(ret);

  if(r>n)
    ret=0;
  else if (r == 0 || r == n)
    ret=1;
  else if (r == 1)
    ret=n;
  else
    ret= (combi(n - 1, r - 1) + combi(n - 1, r));

  memo[n][r]=ret;
  return(ret);
}

long long solve(int l,int k)
{
  long long ret,c;
  int i,j;

  ret=0;
  for(i=(l+1)/2;i>=1;i--)
    for(j=0;(2*i-1)+j*(k-1)<=l;j++)
      {
	 // printf("ij=%d,%d combi=%lld\n",i,j,c=combi(i,j));
	 // ret += c;
	 ret += combi(i,j);
      }
  return(ret);
}


int main()
{
  long long ret;
  int l,k;
  
  scanf("%d %d",&l,&k);
  
  ret=solve(l,k);
  printf("%lld\n",ret);


}



Measured memory_bytes: 2104
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
long long int heap[250];
int size;
scanf("%d",&size);
for(int i=1;i<=size;i++) cin>>heap[i];
for(int i=1;i<=size;i++){
printf("node %d: key = %d, ",i,heap[i]);
if(i/2>0)printf("parent key = %d, ",heap[i/2]);
if(i*2<=size) printf("left key = %d, ",heap[i*2]);
if(i*2+1<=size)printf("right key = %d, ",heap[i*2+1]);
printf("\n");
}

return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const double pi = 3.14159265359;
  
  int a, b, x;
  cin>>a>>b>>x;
  double y;
  double mv = a*a*b;
  if(mv/2>x){
    y = atan((double)(a*b*b)/x/2);
  }
  else{
    y = atan((mv-x)*2/a/a/a);
  }
  cout<<fixed<<setprecision(7);
  cout<<y/pi*180<<endl;
}

Measured memory_bytes: 4048
#include <cstdio>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
    int x, l, t[10], mi, ma;
    bool f;
    map<int, int> a;

    while (cin >> x >> l && x || l) {
        a.clear();
        f = true;
        for (int n = 1; f; n++) {
            a[x] = n;
            for (int i = 0; i<l; i++) {
                t[i] = x % 10; x /= 10;
            }

            sort(t, t + l);
            mi = ma = 0;
            for (int i = 0; i<l; i++) {
                mi *= 10; mi += t[i];
                ma *= 10; ma += t[l - 1 - i];
            }

            x = ma - mi;
            if (a[x]) {
                printf("%d %d %d\n", a[x] - 1, x, n - a[x] + 1);
                f = false;
            }
        }
    }
}

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

int a[15];

int main()
{
	int i,n,ans,pro=1;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[n];
		if(a[n]%2 == 0){
			pro = pro*2;
		}
	}
	ans=pow(3,n)-pro;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
function main(input) {
    const args = input.split(' ');
    var A = parseInt(args[0], 10);
    var B = parseInt(args[1], 10);
    var C = parseInt(args[2], 10);

    if(A * C <= B) {
        console.log(C)
    } else {
        console.log(Math.floor(B / A));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	UL gcd(UL a, UL b) { return b ? gcd(b, a % b) : a; }
	static ULL powm(ULL a, ULL i, ULL m) {
		if (i == 0) return 1;
		ULL tmp = powm(a, i >> 1, m);
		tmp = tmp * tmp % m;
		if (i & 1) tmp = tmp * a % m;
		return tmp;
	}

	void Solve() {

		UL K, N; cin >> N >> K;
		static const ULL M = 1000000007;
		vector<ULL> J(K);
		rep(i, K) {
			J[i] = K / (i + 1);
			J[i] = powm(J[i], N, M);
		}
		for (UL i = K - 1; i != -1; i--) {
			UL x = i + 1;
			for (UL m = x * 2; m <= K; m += x) {
				J[i] = J[i] + M - J[m - 1];
			}
			J[i] %= M;
		}
		ULL ans = 0;
		rep(i, K) {
			J[i] %= M;
			J[i] = J[i] * (i + 1) % M;
			ans += J[i];
		}
		ans %= M;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

#include <map>
template<typename T> struct Compress1D {
    map<T, int> zip; vector<T> unzip; int sz;
    Compress1D(vector<T> a) {
        sort(begin(a), end(a)); a.erase(unique(begin(a), end(a)), end(a));
        sz = a.size(); unzip.resize(sz);
        for (int i = 0; i < sz; i++) zip[a[i]] = i, unzip[i] = a[i];
    }
    int operator[](T x) { return zip[x]; }
    T inv(int idx) { return unzip[idx]; }
    int size() { return sz; }
};

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> l(n), b(n), r(n), t(n);
        for (int i = 0; i < n; i++) cin >> l[i] >> t[i] >> r[i] >> b[i];
        vector<int> xx, yy;
        xx.insert(xx.end(), l.begin(), l.end());
        yy.insert(yy.end(), t.begin(), t.end());
        xx.insert(xx.end(), r.begin(), r.end());
        yy.insert(yy.end(), b.begin(), b.end());
        xx.emplace_back(-1); xx.emplace_back(1e9);
        yy.emplace_back(-1); yy.emplace_back(1e9);
        Compress1D<int> compX(xx), compY(yy);
        int sx = compX.size(), sy = compY.size();
        using ll = long long;
        vector<vector<ll>> xy(sx, vector<ll>(sy));
        for (int i = 0; i < n; i++) {
            l[i] = compX[l[i]], r[i] = compX[r[i]];
            b[i] = compY[b[i]], t[i] = compY[t[i]];
            for (int x = l[i]; x < r[i]; x++) {
                for (int y = b[i]; y < t[i]; y++) {
                    xy[x][y] |= 1LL << i;
                }
            }
        }
        int dxy[] = {0, 1, 0, -1, 0};
        auto dfs = [&](auto dfs, int x, int y, ll cur) -> void {
            xy[x][y] = -1;
            for (int k = 0; k < 4; k++) {
                int nx = x + dxy[k], ny = y + dxy[k + 1];
                if (nx < 0 || nx >= sx || ny < 0 || ny >= sy) continue;
                if (xy[nx][ny] == cur) dfs(dfs, nx, ny, cur);
            }
        };
        int cnt = 0;
        for (int x = 0; x < sx; x++) for (int y = 0; y < sy; y++) {
            if (~xy[x][y]) dfs(dfs, x, y, xy[x][y]), cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3864
N, A, B = map(int, input().split())
S = input()

f_rank = 0
d_pass, f_pass = 0, 0
for s in S:
    if s == "b":
        f_rank += 1

    if s == "a" and d_pass + f_pass < A + B:
        print("Yes")
        d_pass += 1
    elif s == "b" and d_pass + f_pass < A + B and f_rank <= B:
        print("Yes")
        f_pass += 1
    else:
        print("No")


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
int a[100005];
int n,ant;
void ss()
{
    int mn;
    for(int i=0;i<n-1;i++)
    {
        mn=i;
        for(int j=i;j<n;j++)
        {
            if(a[j]<a[mn])
                mn=j;
        }
        swap(a[i],a[mn]);
        if(i!=mn)
            ant++;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    ss();
    for(int i=0;i<n;i++)
    {
        if(i)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
    printf("%d\n",ant);
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

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

int main() {

	vector<int> a(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}

	int k;
	cin >> k;

	for (int i = 0; i < 4; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (abs(a[j] - a[i] > k))
			{
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;




	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


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


def main():
    str = "abcdefghijklmnopqrstuvwxyz"
    c = input()
    for i in range(len(str)):
        if str[i] == c:
            ret = str[i + 1]
    return ret


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 23332
def actual(X, N, P):
    # 解の候補: [0, 101] かつ Pに含まれていない
    nums = set(range(0, 101 + 1)) - set(P)

    # [min — Python 3.8.3(https://docs.python.org/ja/3/library/functions.html#min)
    return min(nums, key=lambda n: abs(n - X))

X, N = map(int, input().split())
P = list(map(int, input().split()))

print(actual(X, N, P))

Measured memory_bytes: 9184
package main

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

type Node struct {
	id       int
	parent   int
	sibling  int
	children []int // index of node or -1
	depth    int
	height   int
	typ      string
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	nodes, err := nextNodes(n, sc)
	if err != nil {
		panic(err)
	}

	for _, node := range nodes {
		for _, childId := range node.children {
			childIndex := findById(childId, nodes)
			nodes[childIndex].parent = node.id
		}
	}

	_, rootInd := findRoot(nodes)

	visit(rootInd, 0, nodes)

	sort.Slice(nodes, func(i, j int) bool {
		return nodes[i].id < nodes[j].id
	})

	for _, node := range nodes {
		fmt.Printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", node.id, node.parent, node.sibling, len(node.children), node.depth, node.height, node.typ)
	}
}

func findById(id int, nodes []Node) int {
	for i, v := range nodes {
		if v.id == id {
			return i
		}
	}
	return -1
}

func findRoot(nodes []Node) (*Node, int) {
	for i, v := range nodes {
		if v.parent == -1 {
			return &v, i
		}
	}
	return nil, -1
}

func visit(rootInd int, depth int, nodes []Node) int {
	root := &nodes[rootInd]
	// typ
	if root.parent == -1 {
		root.typ = "root"
	} else if len(root.children) == 0 {
		root.typ = "leaf"
	} else {
		root.typ = "internal node"
	}
	// sibling
	if len(root.children) == 2 {
		leftInd := findById(root.children[0], nodes)
		rightInd := findById(root.children[1], nodes)
		nodes[leftInd].sibling = root.children[1]
		nodes[rightInd].sibling = root.children[0]
	}
	// depth
	root.depth = depth
	// height
	maxH := 0
	for _, v := range root.children {
		childInd := findById(v, nodes)
		// child := nodes[childInd]
		h := visit(childInd, depth+1, nodes) + 1
		if h > maxH {
			maxH = h
		}
	}
	root.height = maxH
	return root.height
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	rs := make([]int, n)
	for i, _ := range rs {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		rs[i] = x
	}
	return rs, nil
}

func nextNodes(n int, sc *bufio.Scanner) ([]Node, error) {
	rs := make([]Node, n)
	for i, _ := range rs {
		id, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		left, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		right, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		children := []int{}
		if left != -1 {
			children = append(children, left)
		}
		if right != -1 {
			children = append(children, right)
		}
		rs[i] = Node{id, -1, -1, children, 0, 0, "internal node"}
	}
	return rs, nil
}



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

#define int long long

auto main() -> signed {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0; i<h; ++i) {
        cin >> v[i];
    }
    for(int i=0; i<w+2; ++i) cout << "#";
    cout << endl;
    for(int i=0; i<h; ++i) {
        cout << "#" << v[i] << "#" << endl;
    }
    for(int i=0; i<w+2; ++i) cout << "#";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
void share(int x,int y)
{
	printf(((!(x%3))||(!(y%3))||(!((x+y)%3)))?("Possible"):("Impossible"));
	return;
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	share(a,b);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
    ll N,Y;
    cin >> N >> Y;
    ll z=0;
    for(int i=0;i<(Y/10000)+1;i++){
        for(int j=0;j<(Y/5000)+1;j++){
            z=Y-10000*i-5000*j;
            if((z/1000)+i+j==N&&z>=0){
                cout << i << " " << j << " " << z/1000 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)




int main(){
    string s;
    int Q;
    int len_s;
    int list_f[200001];
    char list_c[200001];
    int list_t[200001];
    list<char> lst;
    cin >>s>>Q;
    len_s=s.length();
    rep(i,len_s){
        lst.push_back(s[i]);
    }
    
    bool muki=true;
    for(int i=1;i<=Q;i++){
        cin>>list_t[i];
        if(list_t[i]==2)cin>>list_f[i]>>list_c[i];
    }
    for(int i=1;i<=Q;i++){
        if(list_t[i]==1){
            muki= !muki;
        }
        else if(list_t[i]==2){
            if(list_f[i]==1){
                if(muki)lst.push_front(list_c[i]);
                else{
                    lst.push_back(list_c[i]);
                }
            }
            else{
                if(muki)lst.push_back(list_c[i]);
                else{
                    lst.push_front(list_c[i]);
                }
            }
        }    
    }

    if(muki){
        for(auto itr = lst.begin(); itr != lst.end(); ++itr) {
        cout << *itr;
        }cout<<endl;
    }
    else{
       for(auto itr = lst.rbegin(); itr != lst.rend(); ++itr) {
        cout << *itr;
        }cout<<endl;
    } 
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, std::vector<std::string> S) {
    map<string, ll> m;
    rep(i, N) { m[S[i]]++; }
    ll res = 0;
    for (auto x : m) {
        res++;
    }
    cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 25104
n = gets.chars.map(&:to_i).reverse+[0]
s = n.size

ans = 0
s.times do |i|
    
    if n[i]<5 or (n[i]==5 and n[i+1]<5)
        ans += n[i]
    else
        ans += 10 - n[i]
        n[i+1] += 1
    end
end

puts ans

Measured memory_bytes: 78084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

int main() {
    ll N,M,R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    for(int i=0;i<R;i++){
        ll a;
        cin >> a;
        --a;
        r[i] = a;
    }

    ll d[N][N];
    for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        if(i==j){
            d[i][j] = 0;
        }else{
            d[i][j] = INF;
        }
    }
    for(int i=0;i<M;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        --a;--b;
        d[a][b] = c;
        d[b][a] = c;
    }

    //ワーシャルフロイド法
    for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
    }

    sort(r.begin(),r.end());
    ll ans= INF;
    do{
        ll temp = 0;
        for(int i=1;i<r.size();i++){
            temp += d[r[i-1]][r[i]];
        }
        ans = min(ans,temp);
    }while(next_permutation(r.begin(),r.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int A, B;

	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int main()
{
    fastio();
    string s; cin>>s;
    int maxi=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G' )
        {
            int j=i;
            while(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){++i;}
            maxi=max(maxi,i-j);
        }
    }
    cout<<maxi;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;

int n, m, ansl, ansr, mid;
char s[MAXN];
struct node {
	char c, d;
} q[MAXN];

bool check(int pos)
{
	int x = mid;
	for (int i = 1; i <= m; i++) {
		if (s[x] == q[i].c) {
			q[i].d == 'L' ? --x : ++x;
			if (x < 1 || x > n)return x == pos;
		}
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie();
	cin >> n >> m >> s + 1;
	for (int i = 1; i <= m; i++)cin >> q[i].c >> q[i].d;
	int l = 1, r = n, ansl = 0;
	while (l <= r) {
		mid = (l + r) >> 1;
		check(0) ? (ansl = mid, l = mid + 1) : r = mid - 1;
	}
	l = 1, r = n, ansr = n + 1;
	while (l <= r) {
		mid = (l + r) >> 1;
		check(n + 1) ? (ansr = mid, r = mid - 1) : l = mid + 1;
	}
	cout << ansr - ansl - 1;
	return 0;
}

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

using namespace std;

typedef long long ll;

ll memo[100001];

ll fract(ll num) {
  if (num == 1 || num == 0) return 1;
  if (memo[num] == -1) memo[num] = (num * fract(num - 1)) % 1000000007 ;
  return memo[num];
}

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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> as;
  for (int i = 0; i < 100001; i++) {
    memo[i] = -1;
  }

  //cout << "koko" << endl;

  for (int i = 0; i < m; i++)
  {
    int t; cin >> t; as.push_back(t);
  }

  for (int i = 1; i < m; i++)
  {
    if (as[i] - 1 == as[i - 1]) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  //cout << "koko0" << endl;

  int start = 0;
  ll ccnt = 1;
  for (int i = 0; i < m + 1; i++)
  {
    int sub;
    if (m != 0) {
       sub = i < m ? as[i] - start -1 : n - start;
      start = as[i] + 1;
    }
    else
       sub = n;
    //cout << "sub:" << sub << endl;
    ll sum = 1;
    if (sub % 2 == 0) {
      //sum += 1;
      for (int j = 1; j <= sub / 2; j++) {
        sum += fract(sub - j) * modinv(fract(j) * fract(sub - j * 2), 1000000007);
        sum %= 1000000007;
      }
      //cout << "koko1:" << sum << endl;
    }
    else {
      //sum += 1;
      for (int j = 1; j <= (sub - 1) / 2; j++) {
        sum += fract(sub - j) * modinv(fract(j) * fract(sub - j * 2), 1000000007);
        sum %= 1000000007;
      }
      //cout << "koko2:" << sum << endl;
    }
    //cout << sum << endl;
    ccnt = (ccnt * sum) % 1000000007;
  }
     
  cout << ccnt << endl;

  return 0;
}

Measured memory_bytes: 2560
N = int(input())
#A,B,K= map(int,input().split())
#v =list(map(int,input().split()))
L = [list(map(str,input().split())) for i in range(N)]
Last = input()
flag = 0
answer  =0
for j in L:
    if flag == 1:
        answer += int(j[1])
    if j[0] == Last:
        flag = 1
print(answer)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    string ans = "";
    int n = s.size();
    rep(i, n) {
        if (s[i] == 'B') {
            if (ans.size()) ans.pop_back();
        } else {
            ans.push_back(s[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void){
    long L, R;
    long x = 2019;
    long y = 0;
    long diff = 0;
    
    cin >> L >> R;
    diff = R-L;
    
    if (diff==1) {
        cout << (L*R)%2019;
        return 0;
    } else if (diff>=2019) {
        cout << 0;
        return 0;
    } else {
        for (long i = L; i < R; i++) {
            for (long j = i+1; j < R + 1; j++) {
                y = (i*j)%2019;
                if (x >= y) {
                    x = y;
                }
            }
        }
        cout << x;
    }
    return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace Linear_Search
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            var a = new HashSet<string>(Console.ReadLine().Split());
            Console.ReadLine();
            var b = Console.ReadLine().Split();
            Console.WriteLine("{0}", a.Intersect(b).Count());
        }
    }
}

Measured memory_bytes: 24636
n, m = map(int, input().split())
a = list(map(int, input().split()))
sort = sorted(a, reverse=True)
sum = sum(sort)
count = 0
for i in range(m):
    if sort[i] < float(sum / (4 * m)):
        count += 1
    else:
        continue
if count == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38392
using System;
using System.Linq;

namespace abc176.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = getIntParam();
            long[] paramArray = getLongParams();

            long adjust = 0;
            long level = paramArray[0];

            for (int c = 1; c < num; c++)
            {
                if (paramArray[c] < level)
                {
                    adjust += (level - paramArray[c]);
                }
                else if (paramArray[c] > level)
                {
                    level = paramArray[c];
                }
            }
            Console.WriteLine(adjust);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 47488
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
ll A, B;
const int maxN = 1e5 + 10;
ll S[maxN];
const int mod = (int)1e9 + 7;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
ll c[maxN];
int pref[maxN];
int dp[maxN];
int solve(int l, int r) {
    int n = r - l + 1;
    for (int i = 1; i <= n; i++) {
        c[i] = S[i + l - 1];
    }
    if (n == 1) return 2;
    for (int i = 1; i + 2 <= n; i++) {
        if (c[i + 2] - c[i] < B) return 0;
    }
    for (int i = 0; i <= n; i++) {
        pref[i] = 0;
        dp[i] = 0;
    }
    dp[0] = 1;
    pref[0] = 1;
    int last_can = 0;
    int last_ok = 0;
    for (int i = 1; i <= n; i++) {
        while (last_can + 1 <= i && c[i] - c[last_can + 1] >= A) last_can++;
        //place A
        if (last_ok <= last_can) {
            dp[i] = pref[last_can];
            if (last_ok > 0) dp[i] = sub(dp[i], pref[last_ok - 1]);
        }
        //place B
        if (i > 1 && c[i] - c[i - 1] < B) {
            last_ok = i - 1;
        }
        pref[i] = sum(pref[i - 1], dp[i]);
    }
    int c = pref[n];
    if (last_ok > 0) c = sub(c, pref[last_ok - 1]);
    return c;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> A >> B;
    for (int i = 1; i <= n; i++) {
        cin >> S[i];
    }
    if (A < B) swap(A, B);
    int lst = 1;
    int ans = 1;
    for (int i = 1; i + 1 <= n; i++) {
        if (S[i + 1] - S[i] >= A) {
            ans = mult(ans, solve(lst, i));
            lst = i + 1;
        }
    }
    ans = mult(ans, solve(lst, n));
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
int main() {
  ll N=0;cin>>N;
  ll VAL=0;cin>>VAL;
  vector<ll> dp(VAL+1);
  ll tmpWeight=0,tmpVal=0;cin>>tmpWeight;cin>>tmpVal;
  for(ll j=0;j<=VAL;j++) {
	if(tmpWeight>j)dp[j]=0;
    else dp[j]=tmpVal;
  }
  for(ll i=1;i<N;i++) {
    ll tmpWeight=0,tmpVal=0;cin>>tmpWeight;cin>>tmpVal;
    vector<ll> cmp;
  	for(ll j=0;j<=VAL;j++) {
      if(j-tmpWeight>=0) {
        cmp.push_back(max(dp[j-tmpWeight]+tmpVal,dp[j]));
      } else {
      	cmp.push_back(dp[j]);
      }
    }
    dp=cmp;
  }
  //for(ll i=0;i<N;i++){for(ll j=0;j<=VAL;j++)cout<<dp[i][j]<<" ";cout<<endl;}
  cout<<dp[VAL]<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  vector<int> b(n);
  for(int i=0;i<n;i++){
    bool flg=true;
  	for(int j=0;j<n;j++){
    	if(a[i]==b[j]){flg=false;}
    }
    if(flg){b[i]=a[i];}
  }
  int count=0;
  for(int i=0;i<n;i++){
  	if(b[i]!=0){count++;}
  }
  cout << count << endl;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    long long x = 0;
    for(int i = n-1; i >= 0; i--){
        if((a[i] + x) % b[i] != 0){
            x += b[i] - (a[i] + x) % b[i];
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4420