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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;

    int ans = n * (n-1) /2 + m * (m-1)/2;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
BA = []
for _ in range(M):
    a, b = map(int, input().split())
    BA.append((b, a))

BA.sort()

cnt = 0
end = 0
for ba in BA:
    b, a = ba
    if a > end:
        cnt += 1
        end = b - 1

print(cnt)


Measured memory_bytes: 17008
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    llong X; cin >> X;
    for (llong A = -200; A <= 200; A++) {
        for (llong B = 0; B >= -200; B--) {
            llong lhs = A * A * A * A * A;
            llong rhs = B * B * B * B * B + X;
            if (lhs == rhs ) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}



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

int main(){
    string s;
    cin >> s;
    if(count(s.begin(),s.end(),'a') == 1&&count(s.begin(),s.end(),'b') == 1&&count(s.begin(),s.end(),'c') == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

bool isEven(string s){
	if (s.size() & 1) return false;
	string firstHalf = "";
	string latterHalf = "";
	rep(i, s.size() / 2){
		firstHalf += s[i];
		latterHalf += s[i + s.size() / 2];
	}if (firstHalf == latterHalf) return true;
	return false;
}

int main(){

	string s; cin >> s;
	s.erase(s.begin()+s.size()-1);
	ll n = s.size();
	rep(i, n){
		if (isEven(s)){
			cout << s.size() << endl;
			return 0;
		}s.erase(s.begin()+s.size() - 1);
	}
	return 0;
}

Measured memory_bytes: 256
#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];
  }

  sort(a,a+N,greater<int>());

  int A,B;
  A=0;
  B=0;
  for(int i=0; i<N; i++){
    (i%2==0)? A+=a[i] : B+=a[i];
  }

  cout << A-B << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 110;
char str[maxn];
int q, num, ans;
int main()
{
    while(~scanf("%d",&q))
    {
        memset(str,0,sizeof(str));
        ans = 0; num = 0;
        for(int i = 0; i < q; i++)
        {
            scanf(" %c",&str[i]);
            if(str[i] == 'I')
            {
                num++;
                ans = max(ans,num);
            }
            if(str[i] == 'D')
            {
                num--;
                ans = max(ans,num);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner s = new Scanner(System.in);
    String S = s.next();
    if(S.equals("SUN")){
      System.out.println(7);
    }else if(S.equals("MON")){
      System.out.println(6);
    }else if(S.equals("TUE")){
      System.out.println(5);
    }else if(S.equals("WED")){
      System.out.println(4);
    }else if(S.equals("THU")){
      System.out.println(3);
    }else if(S.equals("FRI")){
      System.out.println(2);
    }else if(S.equals("SAT")){
      System.out.println(1);
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N, M, K;
  cin >> N >> M >> K;
  vector<i64> A(N + 1);
  vector<i64> B(M + 1);
  rep(i,0,N) {
    i64 a = 0;
    cin >> a;
    A[i + 1] = A[i] + a;
  }
  rep(i,0,M) {
    i64 b = 0;
    cin >> b;
    B[i + 1] = B[i] + b;
  }
  i64 ans =0 ;
  rep(i,0,N + 1) {
    i64 k = K - A[i];
    if(k < 0) continue;
    i64 bi = upper_bound(all(B), k) - begin(B);
    ans = std::max(ans, bi + i - 1);
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  if(n <= 111) n = 111;
  else if(n <= 222) n = 222;
  else if(n <= 333) n = 333;
  else if(n <= 444) n = 444;
  else if(n <= 555) n = 555;
  else if(n <= 666) n = 666;
  else if(n <= 777) n = 777;
  else if(n <= 888) n = 888;
  else if(n <= 999) n = 999;
  cout << n << 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 all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string s;
  cin >> s;
  int ans = MOD;
  rep(i,s.size()-2){
    int buf = 0;
    buf += 100 * (s[i] - '0');
    buf += 10 * (s[i+1] - '0');
    buf += 1 * (s[i+2] - '0');
    ans = min(ans,abs(753-buf));
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

int main(){
	int n,q;
	cin>>n>>q;
	vi vec(n);
	rep(i,n)scanf("%d",&vec[i]);
	sort(all(vec));
	int vec_MAX = vec[vec.size()-1];
	
	rep(i,q){
		int query;
		scanf("%d",&query);
		
		int ans = 0;
		int c=1;
		while((c-1)*query<=vec_MAX){
			int pos = lower_bound(all(vec),c*query)-vec.begin();
			c++;
			if(pos==0)continue;
			ans = max(ans,vec[pos-1]%query);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
tuple<int,int,int> tab[MAXN];

ll solve(int ind,int n){
	int c,s,f;
	ll res=0;
	while(ind!=n-1){
		tie(c,s,f)=tab[ind];
		if(res<s) res=s+c,ind++;
		else res=s+((res-s+f-1)/f)*1LL*f+c,ind++;
	}
	return res;
}

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n,c,s,f;
    cin >> n;
    for(int i=0;i<n-1;i++){
		cin >> c >> s >> f;
		tab[i]=make_tuple(c,s,f);
	}
	for(int i=0;i<n;i++){
		cout << solve(i,n) << '\n';
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const int M=3010;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		ks=ks*2%d;
	}
	printf("! %lld\n",ret);
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
//#define MyDebug

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)

#ifdef MyDebug
	#define debug(x) cout << #x << " : " << x << endl
	#define debugP(x) cout << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

list<ll> data;
list<ll> copyed;
ll a, b, m;
bool isKill(ll n) {
	copyed = data;
	ll c = a - b;
	ll ret = 0;
	for (auto&& d : copyed) {
		d -= b * n;
		if (n == 2) debug(d);
	}
	for (auto&& d : copyed) {
		if (d > 0) {
			ret += (d + c - 1)/ c;
			if (ret > n) {
				debug(ret);
				return false;
			}
		}
	}
	debug(ret);
	return true;
}

void solve() {
	cin >> m >> a >> b;
	rep (i, 0, m) {
		ll v;
		cin >> v;
		data.push_back(v);
	}
	ll left = 0, right = (ll)1e9;
	ll middle;
	while (left != right) {
		middle = (left + right) / 2;
		debug(middle);
		if (isKill(middle)) right = middle;
		else left = middle + 1;
	}
	cout << left << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N = 2e5 + 5;
int main()
{
	int n;
	long long int d;
	cin >> n >> d;
	int sum = 0;
	while(n--){
		long long int x,y;
		cin >> x >> y;
		long long int ans = x*x+y*y;
//		cout << ans << endl;
		if(ans <= (d*d))
			sum++;
	}
	cout << sum << endl;	
		
	return 0;	
} 

Measured memory_bytes: 3632
#!/usr/bin/env python

import sys

n= int(sys.stdin.readline())
h= [ int(x) for x in sys.stdin.readline().split() ]

flag= True
ans= "Yes"
for i in range(n-1):
    #
    dh= h[i+1]-h[i]
    if dh<=-2:
        ans="No"
        break
    if dh==-1 and flag:
        flag= False
    elif dh==0:
        pass
    elif dh>=1:
        flag= True
    else:
        ans="No"
        break
#
print( ans )


Measured memory_bytes: 14188
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  if(N%K==0)cout<<0<<endl;
  else cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

int main(){
	int n,m;
	//vi x(n);
	cin >> n >> m;
	int res[114514]={0};
	int cnt[114514]={0};
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		int r=x%m;
		res[r]++;
		cnt[x]++;
	}
	int ans=0;
	if(m%2==0){
		ans=ans+res[m/2]/2;
		res[m/2]=0;
	}
	ans+=res[0]/2;
	res[0]=0;
	for(int i=1;i<=(m-1)/2;i++){
		int xx=min(res[i],res[m-i]);
		res[i]-=xx;
		res[m-i]-=xx;
		ans+=xx;
	}
	for(int i=0;i<100005;i++){
		int ii=i%m;
		int y=min(cnt[i],res[ii]);
		y=y/2;
		ans+=y;
		res[ii]=res[ii]-y*2;
	}	
	cout<<ans<<endl;
}


Measured memory_bytes: 1152
import java.util.*;
import java.io.*;
import java.util.function.*;

public class Main {
	public final int MOD = (int)1e9 + 7;
	
	public void solve(BufferedReader br) throws IOException {
		int[] nw = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int n = nw[0];
		int W = nw[1];
		long[] dp = new long[W + 1];
		// dp[i] - Contains the maximum knapsack value containing exactly weight i
		for (int i = 0; i < n; i++) {
			int[] wv = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
 			int w = wv[0];
			long v = wv[1];
			for (int j = W; j >= w; j--) {
				dp[j] = Math.max(dp[j], v + dp[j - w]);
			}
		}	
		System.out.println(dp[W]);
	}
	
	public long mathPow(long base, long exp, long mod) {
		long res = 1;
		base = base % mod;
		while (exp > 0) {
			if ((exp & 1) == 1) res = (res * base ) % mod;
			exp = exp >> 1;
			base = (base * base) % mod;
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
	}
}



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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,m,n) for(int i = m; i < n; i++)
#define rep2(i,n) for(int i = 0; i <= n; i++)
#define rep3(i,m,n) for(int i = 0; m <= n; i++)


int main(void) {
  int n;
  double k,h;
  cin >> n;
  if(n % 2 == 0) {
    h = n / 2;
    k = h / n;
    cout << k << endl;
  } else {
    h = n / 2 + 1;
    k = h / n;
    cout << k << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{     
	int i,n,b,f,r,v;     
	int house[4][3][10] = {0};           
	scanf("%d",&n);     
	for (i=0; i<n; i++) 
	{         
		scanf("%d %d %d %d",&b,&f,&r,&v);         
		house[b-1][f-1][r-1] += v;     
	}     
	for (b=0; b<4; b++) 
	{         
		for (f=0; f<3; f++) 
		{             
			for (r=0; r<10; r++) 
			{                 
				printf(" %d",house[b][f][r]);             
			}         
			printf("\n");         
		}        
		if(b != 3) 
			printf("####################\n");     
	}     
	return 0; 
} 

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

int a[20];
int x[20][20];
int y[20][20];

int main(){
  int n;
  cin >> n;
  rep(i,n){
   cin >> a[i];
    rep(j,a[i]){
    	cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;

  for(int bit = 0; bit < (1 << n); ++bit){
  	bitset<15> s(bit); 
  	bool can = true;
  	int cont = 0;

  	rep(i,n){
  		if(bit & (1 << i)){
  			++cont;
  			rep(j,a[i]){
  				if(((bit >> (x[i][j]-1)) & 1) ^ y[i][j]) can = false;
  				
  			}
  		}else continue;
  	}
  	if(can) ans = max(ans, cont);
  }
  cout << ans << endl;
  return 0;
}



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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int x[5];
	for (int i = 0; i < 5; ++i) {
		cin >> x[i];
		if (x[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
a.sort()
rui = [a[0]]
for i in range(1, n):
    rui.append(rui[i-1] + a[i])
col = [1 for i in range(n)]
for i in range(n-1):
    if 2*rui[i] < a[i+1]:
        col[i] = 0
ans = 0
for i in range(n-1, -1, -1):
    if col[i] == 1:
        ans += 1
    else:
        break
print(ans)

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

int main(void){
    char t[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ans[6]="snuke";
    int h,w;
    scanf("%d%d",&h,&w);
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            char s[6];
            scanf("%s",s);
            if (strcmp(s,ans)==0){
                printf("%c%d\n",t[j],i+1);
                exit (0);
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 128
from collections import deque

poe=deque([])
S=input()
for i in range(len(S)):
    poe.append(S[i])
Q=int(input())
P=[]
cnt=0
for i in range(Q):
    a=list(input().split())
    P.append(a)

for i in range(Q):
    if len(P[i])==1:
        cnt+=1
    else:
        P[i][1]=int(P[i][1])+cnt
        if P[i][1]%2==1:
            poe.appendleft(P[i][2])
        else:
            poe.append(P[i][2])

poe=list(poe)
if cnt%2==1:
    poe=poe[::-1]
print(''.join(poe))

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

using namespace std;

bool arr[55556];

void Eratosthenes(){
  for(int i = 0; i <= 55555; i++){ arr[i] = true;}
  arr[0] = false; arr[1] = false;
  for(int i = 0; i <= 55555; i++){
    if( arr[i]){
      for(int j = 2; i*j <= 55555; j++){
        arr[i*j] = false;} 
    }}
}

int main(){
  int N; cin >> N;
  vector<int> vec; int itr = 1;
  
  Eratosthenes();
  while( N > 0){
    if( !arr[itr] ){ itr++; continue;}
    else{
      if( itr % 5 != 1){ itr++; continue;}
      else{ vec.push_back(itr); N--; itr++;}
    }
  }
  
  for(int i = 0; i < (int) vec.size(); i++){
    cout << vec[i] << " ";}
  cout << endl;
  
  return 0;}

Measured memory_bytes: 256
#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>;

int main() {
  int a,b;
  cin >> a >> b;
  int cnt = 1;
  int A = a;
  if (b == 1) cout << 0;
  else if(a == b) cout << 1;
  else if(1) {
    while(b > a) {
      a += A -1;
    cnt++;
  }
  cout << cnt << endl;  
  }
}
 

Measured memory_bytes: 3588
n = int(input())
a = list(map(int, input().split()))

l = [0]*n
r = [0]*n

l = [i+a[i] for i in range(n)]
r = [i-a[i] for i in range(n)]
ld = {}
rd = {}

c = 0

for i in range(n):
	if l[i] in ld:
		ld[l[i]] += 1
	else:
		ld[l[i]] = 1
	if r[i] in rd:
		rd[r[i]] += 1
	else:
		rd[r[i]] = 1

for i in ld.keys():
	if i in rd:
		c += ld[i]*rd[i]	
	
print(c)

Measured memory_bytes: 62204
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v% MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};

constexpr int MOD = 1000000007;

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

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

  // 0 ~ N, N+1ko

  int N;
  int K;
  cin >> N >> K;

  // 全部使う際
  Fp<MOD> a = ((u64)(N + 1)) * (N) / 2;

  Fp<MOD> result = 0;

  FOR(i, K, N + 2) {
      // i個足す際の最小
      Fp<MOD> b = ((u64)(i)) * (i - 1) / 2;
      //cout << i << "++ min:" << b << '\n';

      // N-i個 最小
      Fp<MOD> c = ((u64)(N + 1 - i)) * (N - i) / 2;
      //cout << (N - i) << "++ min:" << c << '\n';

      // i個最大
      Fp<MOD> d = a - c;
      //cout << "i++ max : " << d << '\n';

      Fp<MOD> e = d - b + 1;
      //cout << e << "\n";

      result += e;
  }

  cout << result;
}


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

setA=set(list(range(int(A//0.08+1),int((A+1)//0.08+1))))
setB=set(list(range(int(B//0.1+1),int((B+1)//0.1+1))))
ans=setA & setB

if len(ans)==0:
    print(-1)
    exit()

print(min(ans))

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define rep(i,n) for(int i=0;i<(n);i++)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define nl cout<<endl;
#define pu push
#define pb push_back
//str.substr(pos,number)
//str.insert(str.begin()+5,'3')
//set<int> myset
//myset.insert(num)
//myset.count(i)!=0
const int maxn = 2e5 + 5;
int main(){
    fio();
	int num;
	bool ans=false;
	cin>>num;
	for(int i=0;i<3;i++){
		if(num%10 == 7){
			ans = true;
			break;
		}
		num /=10;
	}
	if(ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}














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

int main()
{
  int h, w;
  cin >> h >> w;
  string s;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> s;
      if (s == "snuke")
      {
        char c = 'A' + j;
        cout << c << i + 1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;

ll test[1234][1234];
signed main() {
	vector<vector<ll>> abc(27, vector<ll>(2));
	ll D, c, s; cin >> D;
	for (int h = 1; h <= 26; h++) {
		cin >> abc[h][0]; abc[h][1] = h;
	}
	sort(abc.begin() + 1, abc.end());
	for (int i = 0; i < D; i++) {
		for (int h = 0; h < 26; h++) {
			cin >> test[i][h];
		}
	}
	for (int h = 0; h < 13; h++) {
		vector<vector<ll>> v(676, vector<ll>(3)); ll uio = 0;
		for (int i = 0; i < 26; i++) {//26*h+i
			for (int j = 0; j < 26; j++) {
				v[uio][0] = test[26 * h + i][j];
				v[uio][1] = i; v[uio][2] = j; uio++;
			}
		}
		sort(v.begin(), v.end()); reverse(v.begin(), v.end());
		vector<ll> ok1(26), ok2(26), ans(26); ll jkl = 0;
		for (int h = 0; h < 676; h++) {
			if (ok1[v[h][1]] == 0 && ok2[v[h][2]] == 0) {
				ok1[v[h][1]]++; ok2[v[h][2]]++;
				ans[v[h][1]] = v[h][2]; jkl++;
			}
		}
		for (int h = 0; h < 26; h++) {
			cout << ans[h] + 1 << endl;
		}
	}
	cout << abc[26][1] << endl;
	for (int h = 14; h <= 26; h++) { cout << abc[h][1] << endl; }
	for (int h = 14; h <= 26; h++) { cout << abc[h][1] << endl; }
	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    ll K, A, B; cin >> K >> A >> B;
    if(B<=A+1){
        cout << K+1 << endl;
        return 0;
    }
    
    ll ret = 0;
    ll C = (K-A+1);
    if(C%2) ret++;
    C/=2;
    ret += C*B - (C-1)*A;
    cout << ret << endl;
    return 0;
}


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

#define MAX_N 10001

vector<pii> G[MAX_N];

int prim(int n){        //n : ノード数
    bool used[MAX_N];
    int mincost[MAX_N];
    
    rep(i,n){
        mincost[i]=INF;
        used[i]=false;
    }
    mincost[0]=0;
    int res=0;
    
    while(1){
        int v=-1;
        rep(u,n){
            if(used[u]==false && ( v==-1 || mincost[u]<mincost[v] ))
                v=u;
        }
        if(v==-1)break;
        used[v]=true;
        res+=mincost[v];
        
        rep(i,G[v].size()){
            int u = G[v][i].first;
            mincost[u] = min( mincost[u] , G[v][i].second);
        }
    }
    return res;
}

int main(){
    int v,e;
    while(cin>>v&&v){
        cin>>e;
        cin.ignore();
        rep(i,MAX_N)G[i].clear();
        rep(i,e){
            int u,v,d;
            scanf("%d,%d,%d",&u,&v,&d);
            G[u].pb(pii(v,d/100-1));
            G[v].pb(pii(u,d/100-1));
        }
        
        cout<<prim(v)<<endl;
    }
}



Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }
 
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };
 
    for (string t: blue) {
        ans = max(ans, calc(t));
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        FastReader in  = new FastReader(); 
        Solver s = new Solver();
        int t = 1;
        while(t-- > 0) s.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(FastReader in, PrintWriter out) throws IOException {
            // solve
            int n=in.nextInt();
            int W=in.nextInt();
            int[] w=new int[n];
            int[] v=new int[n];
            long dp[][]=new long[n+1][W+1];
            for(int i=0;i<n;i++) {
                w[i]=in.nextInt();
                v[i]=in.nextInt();
            }
            for(int i=1;i<dp.length;i++){
                for(int j=1;j<dp[0].length;j++){
                    if(w[i-1]<= j) 
                        dp[i][j]=Math.max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
                    else dp[i][j]=dp[i-1][j];
                }
            }
            out.println(dp[n][W]);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        public char nextChar() {
            return next().charAt(0);
        }

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

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

int main(){ 
  int N, W;
  vector<int> v(110, 0), w(110, 0);

  cin >> N >> W;
  for(int i=1; i<=N; i++) cin >> v[i] >> w[i];

  //dp[i][j]: i番目の品物まで，重さj以内での最大価値
  vector<vector<int>> dp(110, vector<int>(100010, 0));

  for(int i=0; i<N; i++){
    for(int j=0; j<=W; j++){
      if(j-w[i+1] >= 0){
        dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i+1]]+v[i+1]);
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> l;
    rep(i,n){
        int t;cin>>t;
        l.push_back(t);
    }
    sort(l.rbegin(), l.rend());
    int sum=0;
    for(int i=1;i<n;i++){
        sum+=l[i];
    }
    if(sum>l[0]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int n,i,a[100001],top,p;
int main()
{
   	getline(cin,s);
   	n=s.length();
   	while(i<n&&p==0)
   	{
   		if(s[i]=='C')
   		{
   		a[++top]=s[i];	
   		i++;
		}
   		if(s[i]=='F')
   		if(a[top]=='C')
   		{
   			cout<<"Yes"<<endl;
   			p=1;
   			return 0;
		}
		i++;
	}
	if(p==0)
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());
    vector<int> bit(data.at(N - 1), 0);
    for (int i = 0; i < N; i++) {
        if (1 < bit.at(data.at(i) - 1)) {
            continue;
        }
        if (bit.at(data.at(i) - 1)) {
            bit.at(data.at(i) - 1)++;
            continue;
        }
        for (int j = data.at(i); j <= data.at(N - 1); j += data.at(i)) {
            bit.at(j - 1)++;
        }
    }
    int ans = 0;
    for (int x : data) {
        if (bit.at(x - 1) == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7956
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

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

int main()
{   
	string s;
	cin >> s;
	int total=0;
	for (char c: s) total+=c-'0';
	if (total%9==0) cout << "Yes";
	else cout << "No";
	return 0;
}

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

int main() {
  int N,K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  int min_iterator = 0;
  for (int i = 0; i < N; i++ ) {
    std::cin >> A[i];
    if (A[i] == 1) {
      min_iterator = i + 1;
    }
  }  

  // min_iteratorの左右をみる.
  int answer = -1;
  for (int i = 0; i <= (K - 2); i++) {
    int right = N - min_iterator - i;
    int left = min_iterator - 1 + i;
    left = (left % (K - 1) == 0) ? left/(K - 1) : (left/(K - 1) + 1);
    right = (right % (K - 1) == 0) ? right/(K - 1) : (right/(K - 1) + 1);
    if ((left + right) < answer || answer < 0 ) {
      answer = left + right ;
    }
  }
  
  std::cout << answer << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    string p;
    cin >> p;

    bool min_length, has_number = false, has_upper = false, has_lower = false;

    min_length = 6U <= p.size();

    for (int i=0; i<(int)p.size(); ++i) {
        if (isdigit(p[i])) has_number = true;
        if (isupper(p[i])) has_upper = true;
        if (islower(p[i])) has_lower = true;
    }

    if (min_length && has_number && has_upper && has_lower) {
        cout << "VALID" << endl;
    } else {
        cout << "INVALID" << endl;
    }

    return 0;
}

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

string calc(string s1,string s2){
  int num1=s1.size()-1,num2=s2.size()-1;
  int tmp=0;
  string s;
  while(!(num1==-1&&num2==-1&&tmp==0)){
    if(num1!=-1&&num2!=-1){
      tmp+=int(s1[num1]-'0')+int(s2[num2]-'0');
      num1--;num2--;
    }else if(num1!=-1&&num2==-1){
      tmp+=int(s1[num1]-'0');
      num1--;
    }else if(num1==-1&&num2!=-1){
      tmp+=int(s2[num2]-'0');
      num2--;
    }
    s=to_string(tmp%10)+s;
    tmp/=10;
  }
  if(s.size()>80)s="overflow";
  return s;
}

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  int n;
  string s1,s2;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<calc(s1,s2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
int f[N],a[N],g[N],n,h[N];
int w[N*2],ne[N*2],la[N],t,cnt;
void link(int x,int y){
	w[++t]=y;
	ne[t]=la[x];
	la[x]=t;
}
void dp(int x,int fa,int dep){
	int sum=0,mx=0;
	g[x]=a[x];
	cnt+=a[x]*dep;
	h[x]=0;
	for (int y=la[x];y;y=ne[y]){
		int z=w[y];
		if (z==fa)continue;
		dp(z,x,dep+1);
		mx=max(mx,f[z]+g[z]);
		g[x]+=g[z];
		h[x]+=h[z]+g[z];
	}
	for (int y=la[x];y;y=ne[y]){
		int z=w[y];
		if (z==fa)continue;
		int q=min(h[z]+g[z],mx);
		if ((q^(h[z]+g[z]))&1)q--;
		sum+=q;
	}
	f[x]=max(sum&1,2*mx-sum);
}
int main(){
	cin>>n;
	scanf("\n");
	for (int i=1;i<=n;i++)a[i]=getchar()=='1';
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y);
		link(y,x);
	}
	int ans=1e9;
	for (int i=1;i<=n;i++){
		cnt=0;
		dp(i,0,0);
		if (!f[i])
			ans=min(ans,cnt>>1);
	}
	if (ans>5e8)ans=-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    char[][] MAP;
    MAP.length = H;
    foreach (ref line; MAP) {
        line = readln.chomp.to!(char[]);
    }

    int[][] HMAP, WMAP;
    HMAP.length = H;
    WMAP.length = H;
    foreach (i; 0..H) {
        HMAP[i].length = W;
        WMAP[i].length = W;
    }

    foreach (i; 0..H) {
        int x;
        foreach (j; 0..W) {
            if (MAP[i][j] == '#') {
                x = 0;
            } else {
                WMAP[i][j] = ++x;
            }
        }
        x = 0;
        foreach_reverse (j; 0..W) {
            if (MAP[i][j] == '#') {
                x = 0;
                continue;
            }
            if (WMAP[i][j] > x) {
                x = WMAP[i][j];
            } else {
                WMAP[i][j] = x;
            }
        }
    }

    foreach (j; 0..W) {
        int x;
        foreach (i; 0..H) {
            if (MAP[i][j] == '#') {
                x = 0;
            } else {
                HMAP[i][j] = ++x;
            }
        }
        x = 0;
        foreach_reverse (i; 0..H) {
            if (MAP[i][j] == '#') {
                x = 0;
                continue;
            }
            if (HMAP[i][j] > x) {
                x = HMAP[i][j];
            } else {
                HMAP[i][j] = x;
            }
        }
    }

    int r;
    foreach (i; 0..H) {
        foreach (j; 0..W) {
            r = max(r, HMAP[i][j] + WMAP[i][j] - 1);
        }
    }
    writeln(r);
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int i = 0, m = 0;
	for (auto c : s)
		switch (c) {
		default:
			i = 0;
			break;
		case 'A':
		case 'T':
		case 'G':
		case 'C':
			i++;
			m = max(m, i);
		}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long mod = (long) 1e9 + 7;
		
		int L = 63;
		int[] B0 = new int[L];
		for(int i=0;i<L;i++){
			B0[i] = (int)((N >> i) & 1);
		}
		
		long ans = 0;
		
		// sum < N;
		for(int i=0;i<L;i++){
			var B = (int[]) B0.Clone();
			if(B0[i] == 0) continue;
			
			B[i] = 0;
			long[] dp = new long[2];
			dp[0] = 1;
			for(int j=0;j<i;j++){
				var nxt = new long[2];
				nxt[0] += dp[0]; //(0, 0)
				nxt[0] += dp[0]; //(1, 0)
				nxt[1] += dp[0]; //(1, 1);
				nxt[0] += dp[1]; //(0, 0)
				nxt[1] += dp[1]; //(1, 0)
				nxt[1] += dp[1]; //(1, 1);
				
				nxt[0] %= mod;
				nxt[1] %= mod;
				dp = nxt;
				
			}
			for(int j=i;j<L;j++){
				var nxt = new long[2];
				if(B[j] == 0){
					nxt[0] += dp[0]; // (0, 0);
					nxt[1] += dp[0]; // (1, 1);
					nxt[1] += dp[1]; // (1, 0);
				} else {
					nxt[0] += dp[0]; // (1, 0);
					nxt[1] += dp[1]; // (1, 1);
					nxt[0] += dp[1]; // (0, 0);
				}
				
				nxt[0] %= mod;
				nxt[1] %= mod;
				dp = nxt;
				
			}
			ans += dp[0];
			ans %= mod;
		}
		
		// sum == N;
		for(int i=0;i<1;i++){
			var B = (int[]) B0.Clone();
			long[] dp = new long[2];
			dp[0] = 1;
			for(int j=0;j<i;j++){
				var nxt = new long[2];
				nxt[0] += dp[0]; //(0, 0)
				nxt[0] += dp[0]; //(1, 0)
				nxt[1] += dp[0]; //(1, 1);
				nxt[0] += dp[1]; //(0, 0)
				nxt[1] += dp[1]; //(1, 0)
				nxt[1] += dp[1]; //(1, 1);
				
				nxt[0] %= mod;
				nxt[1] %= mod;
				dp = nxt;
				
			}
//Console.WriteLine(String.Join(" ", dp));
			for(int j=i;j<L;j++){
				var nxt = new long[2];
				if(B[j] == 0){
					nxt[0] += dp[0]; // (0, 0);
					nxt[1] += dp[0]; // (1, 1);
					nxt[1] += dp[1]; // (1, 0);
				} else {
					nxt[0] += dp[0]; // (1, 0);
					nxt[1] += dp[1]; // (1, 1);
					nxt[0] += dp[1]; // (0, 0);
				}
				
				nxt[0] %= mod;
				nxt[1] %= mod;
				dp = nxt;
//Console.WriteLine(String.Join(" ", dp));
				
			}
			ans += dp[0];
			ans %= mod;
		}
		
		Console.WriteLine(ans);
		
	}
	long N;
	public Sol(){
		N = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

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

string sa[100];
int t[100];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sb;
	cin>>n;

	for(i=0;i<n;i++){
		cin>>sa[i];
		cin>>t[i];
	}
	cin>>sb;
	for(i=0;i<n;i++){
		if(sa[i]==sb)break;
	}
	a=0;
	for(i++;i<n;i++){
		a+=t[i];
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int num,tmp=0;
    cin >> num;
    int array[num];
    for(int i=0;i<num;i++)cin >> array[i];
    for(int i=num-1;i>=0;i--){
        cout << array[i];
        if(i!=0)cout <<  " ";
    }cout << endl;
	return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int fail[1000005],a[1000005],mia[1000005],b[1000005],mib[1000005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		a[n+i]=a[i];
	}
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	if(n==1){
		cout<<0<<" "<<(a[0]^b[0]);
		return 0;
	}
	for(int i=0;i<2*n-2;i++) mia[i]=a[i]^a[i+1];
	for(int i=0;i<n-1;i++) mib[i]=b[i]^b[i+1]; 
	mib[n-1]=-1;
	int pos=-1;
	fail[0]=-1;
	fail[n-1]=-1;
	for(int i=1;i<n-1;i++){
		while(pos!=-1&&mib[pos+1]!=mib[i]) pos=fail[pos];
		if(mib[pos+1]==mib[i]) fail[i]=++pos; else fail[i]=pos=-1;
	}
	pos=-1;
	for(int i=0;i<2*n-2;i++){
		while(pos!=-1&&mib[pos+1]!=mia[i]) pos=fail[pos];
		if(mib[pos+1]==mia[i]) pos++;
		if(pos==n-2&&i-pos<n){
			printf("%d %d\n",(i-pos),(b[0]^a[i-pos]));
		}
	}
}

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

int main(){
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0) break;
        
        vector<int> a(n);
        int minv = 1001;
        int maxv = -1;
        int sum = 0;
        rep(i,n){
            cin >> a[i];
            minv = min(minv,a[i]);
            maxv = max(maxv,a[i]);
            sum += a[i];
        }
        sum = sum - minv - maxv;
        sum /= (n-2);
        
        cout << sum << endl;
    }
}





Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var deg = ToInt32(input[0]);
        var goal = ToInt32(input[1]);
        var pro = new int[deg];
        var bo = new int[deg];
        for(var i = 0; i < deg; i++)
        {
            var inp = ReadLine().Split(' ');
            pro[i] = ToInt32(inp[0]);
            bo[i] = ToInt32(inp[1]);
        }

        var result = int.MaxValue;
        for (var i = 0; i < Pow(2, deg); i++)
        {
            var res = 0;
            var count = 0;
            var set = new HashSet<int>();
            for (var j = 0; j < deg; j++) set.Add(j);
            for (var j = 0; j < deg; j++)
            {
                if ((1 & i >> j) == 1)
                {
                    res += pro[j] * 100 * (j+1) + bo[j];
                    count += pro[j];
                    set.Remove(j);
                }
            }
            if (res < goal)
            {
                var ma = set.Max();
                var a = (int)Ceiling((double)(goal - res) / ((ma+1)*100));
                if (a >= pro[ma]) continue;
                else count += a;
            }
            if (result > count) result = count;
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	V a(5);
	rep(i, 5) {
		cin >> a[i];
	}
	rep(i, 5) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	long long a[N];
	long long b[N];
	for(int i=0; i<N; i++){
		cin >> a[i];
		b[i]=a[i];		//bはaのコピー
	}
	
	int ctrl[2*N]={0};
	int kaisu=0;
	
	
	sort(b, b+N);
	int max_a;
	int min_a;
	for(int i=0; i<N; i++){
	if(a[i]==b[N-1]){max_a=i+1;}
	if(a[i]==b[0]){min_a=i+1;}
	}
	

	if(b[0]<0 && b[N-1]>0){
		if(b[0]+b[N-1]>=0){
		for(int i=0; i<N; i++){
			if(a[i]<0){
				ctrl[2*kaisu]=max_a;
				ctrl[2*kaisu+1]=i+1;
				kaisu++;
				a[i]+=a[max_a-1];
			}
		}
		}
		
		if(b[0]+b[N-1]<0){
		for(int i=0; i<N; i++){
			if(a[i]>0){
				ctrl[2*kaisu]=min_a;
				ctrl[2*kaisu+1]=i+1;
				kaisu++;
				a[i]+=a[min_a-1];
			}
		}
		}
	}
	
	if(b[0]+b[N-1]>=0){
	ctrl[2*kaisu]=max_a;
	ctrl[2*kaisu+1]=1;
	kaisu++;
	for(int i=1; i<N; i++){
		ctrl[2*kaisu]=i;
		ctrl[2*kaisu+1]=i+1;
		kaisu++;
	}
	}
	else if(b[0]+b[N-1]<0){
	ctrl[2*kaisu]=min_a;
	ctrl[2*kaisu+1]=N;
	kaisu++;
	for(int i=N; i>1; i--){
		ctrl[2*kaisu]=i;
		ctrl[2*kaisu+1]=i-1;
		kaisu++;
	}
	}
	
	
	
	
	cout << kaisu <<endl;
	for(int i=0; i<kaisu; i++){
		cout << ctrl[2*i] << " " << ctrl[2*i+1]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
           count++;
    }
    int ans=0;
    for(int i=0;i<count;i++)
    {
        if(s[i]=='W')
           ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3684