akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int n,m;
int data[128];

int f(int mid){
	int cnt = 0;
	int sum = 0;
	rep(i,n){
		if( mid<data[i] ) return INT_MAX;
		sum += data[i];
		if( sum>mid ){
			cnt++;
			sum = data[i];
		}
	}
	return cnt+1;
}

int main(){
	while(scanf("%d%d",&m,&n),m|n){
		int sum = 0;
		rep(i,n){
			scanf("%d",data+i);
			sum += data[i];
		}
		int l = 0;
		int r = sum;
		while( l<r ){
			int mid = (l+r)/2;
			int k = f(mid);
#if DEB
			printf("mid:%d   k:%d\n",mid,k);
#endif			
			if( k<=m ){
				r = mid;
			}else{
				l = mid + 1;
			}
#if DEB
			printf("(l,r) = (%d,%d)\n",l,r);
#endif 			
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
fun main(arr: Array<String>) {
    println(solve(readLine()!!.toInt()))
}

fun solve(init:Int):Int {
    val dic = mutableMapOf(init to 1)
    var prev = init
    for(i in 2..Int.MAX_VALUE) {
        prev = if(prev % 2 == 0) prev /2 else (prev*3+1)
        dic[prev]?.let { return i }
        dic[prev] = i
    }
    return 0
}

Measured memory_bytes: 34912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0, cd[100];
    for (int i = 1; i <= 100; i++) {
        if (a%i == 0 && b%i == 0) cd[cnt++] = i;
    }
    cout << cd[cnt-k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
         
    	int price,hour,kotei;
     
     
        int main() {
          cin >> price >> hour >> kotei;
          
          if(price * hour <= kotei) {
            cout << price * hour << endl;
          }
          else {
            cout << kotei << endl;
          }  
        }

Measured memory_bytes: 256
H,W = map(int,input().split())
A = [list(map(int,input().split()))for _ in range(H)]
for i in range(H):
    b = list(map(int,input().split()))
    for j in range(W):
        A[i][j] = abs(A[i][j]-b[j])
NUM = 6400
DP = [[[0]*NUM for i in range(W)]for j in range(H)]
DP[0][0][A[0][0]] = 1
i = 0
for j in range(W-1):
    a = A[i][j+1]
    for k in range(NUM):
        if DP[i][j][k] == 1:
            if 0 <= a-k < NUM:
                DP[i][j+1][a-k] = 1
            if 0 <= k-a < NUM:
                DP[i][j+1][k-a] = 1
            if 0 <= k+a < NUM:
                DP[i][j+1][k+a] = 1
j = 0
for i in range(H-1):
    a = A[i+1][j]
    for k in range(NUM):
        if DP[i][j][k] == 1:
            if 0 <= a-k < NUM:
                DP[i+1][j][a-k] = 1
            if 0 <= k-a < NUM:
                DP[i+1][j][k-a] = 1
            if 0 <= k+a < NUM:
                DP[i+1][j][k+a] = 1
for i in range(H-1):
    for j in range(W-1):
        a = A[i+1][j+1]
        for k in range(NUM):
            if DP[i+1][j][k] == 1:
                if 0 <= a-k < NUM:
                    DP[i+1][j+1][a-k] = 1
                if 0 <= k-a < NUM:
                    DP[i+1][j+1][k-a] = 1
                if 0 <= k+a < NUM:
                    DP[i+1][j+1][k+a] = 1
            if DP[i][j+1][k] == 1:
                if 0 <= a-k < NUM:
                    DP[i+1][j+1][a-k] = 1
                if 0 <= k-a < NUM:
                    DP[i+1][j+1][k-a] = 1
                if 0 <= k+a < NUM:
                    DP[i+1][j+1][k+a] = 1

print(DP[-1][-1].index(1))

Measured memory_bytes: 360712
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
bool mark[maxn];
int a[maxn];
int main(){
	int n;
	int m;
	cin>>n>>m;
	mark[1]=true;
	for(int i=1;i<=n;i++){
		a[i]=1;
	}
	while(m>0){
		m--;
		int l;
		int r;
		cin>>l>>r;
		if(mark[l]==true){
			mark[r]=true;
		}
		a[r]++;
		a[l]--;
		if(a[l]==0){
			mark[l]=false;
		}
	}
	long long int res=0;
	for(int i=1;i<=n;i++){
		if(mark[i]==true){
			res++;
		}
	}
	cout<<res;
	return 0;
}

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

using namespace std;

int roundUp(int x) {
	if(x % 10 == 0) {
		return x;
	} else {
		return 10 * ((x / 10) + 1);
	}
}

int main(void) {
	vector<pair<int, int> > v;
	for(int i = 0; i < 5; ++i) {
		int t;
		cin >> t;
		v.push_back(make_pair((t % 10 == 0) ? 0 : 10 - (t % 10), t));
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < static_cast<int>(v.size()) - 1; ++i) {
		ans += roundUp(v[i].second);
	}
	ans += v.back().second;
	cout << ans << '\n';
	return 0;
}



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

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    bool flag = true;
    rep(i, n) {
        if (a[i] % 2 == 1) {}
        else {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) flag = false;
        }
    }

    if(flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

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

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
int main()
{
    int N, a = 111, ans;
    cin >> N;
    rep(i, 9)
    {
        if (N <= a)
        {
            ans = a;
            break;
        }
        else
        {
            a += 111;
        }
    }

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


Measured memory_bytes: 256
local function flag(x)return x>0 and 1 or x<0 and -1 or 0 end
X=io.read"*n"
K=io.read"*n"
D=io.read"*n"
 
K1=K-math.floor(math.abs(X)/D)
if(K1<0)then print(math.abs(X)-D*K)return end
X=X-flag(X)*D*(K-K1)
print(K1%2==0 and math.abs(X) or D-math.abs(X))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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;
}
template<class T>
void DEBUG_DP(T* viewdp, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen){
            if(viewdp[i][j] != -1)
                printf("[% 4d]", viewdp[i][j]);
            else
                printf("[    ]");
        }
        puts("");
    }
}

int h,w;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>h>>w;
    vector<vector<char>> m(h+2,vector<char>(w+2,'.'));
    ll dp[1005][1005] = {};
    REP(i,h) REP(j,w) cin>>m[i][j];
    dp[0][0]=1;
    REP(i,h) REP(j,w){
        if(m[i][j]=='.'){
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
            dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
        }
    }

    //DEBUG_DP(dp,21,21);

    cout << dp[h-1][w-1] << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<P> p(n);
  rep(i,n){
    int m;
    cin>>m;
    p[i]=make_pair(m,i);
  }
  sort(p.begin(),p.end());
  int ans=n;
  int tmp=1;
  rep(i,n-1){
    if(p[i].second<p[i+1].second){
      tmp++;
    }else{
      ans=min(ans,n-tmp);
      tmp=1;
    }
  }
  ans=min(ans,n-tmp);
  cout<<ans<<endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

//素数判定機
bool isprime(int x){
  if(x<2) return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

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

  cout << n <<':';
  
  while(1<n){
    if(n%2==0){
      cout<< ' ' << 2; n/=2; continue;
    }
    for(int i=3;i<=n;i+=2){
      if(n%i==0){
        if(isprime(i)){
          cout<< ' ' << i; n/=i; break;
        }
      }
      if(i*i>n){//クソでか素数対策。素数判定そのものの時と同じ理論で、その数自身の√まで、割れるかどうか試した後、無理だった場合その時点で素数なのでそのまま出力して終わり
        cout << ' ' << n << endl; return 0;
      }
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 3096
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
colors = []
for i in range(1, N + 1):
    colors += [i] * A[i - 1]
for i in range(H):
    if i % 2 == 0:
        print(*colors[i * W : (i + 1) * W])
    else:
        print(*colors[i * W : (i + 1) * W][::-1])


Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	set<string > s;
	for (LL n = 0; n < N; n++) {
		string S;
		cin >> S;
		s.insert(S);
	}
	cout << s.size() << "\n";
	return 0;
}

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

int stoi(string str) {
	int ret;
	ret = int(str[1])-48;
 	return ret;
}

int main() {
	int n, min, flg;
	string tmp;
	cin >> n;
	string *org = new string[n];
	string *a = new string[n];
	
	for (int i = 0; i < n; i++)
		cin >> org[i];
	for (int i = 0; i < n; i++)
		a[i] = org[i];
	for (int i = 0; i < n -1; i++)
		for(int j = n - 1; j > i; j--)
			if (stoi(a[j]) < stoi(a[j - 1])) {
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
	flg = 1;
	for (int i = 0; i < n - 1; i++) {
		if(flg == 0) break;
		for (int j = i + 1; j < n; j++) {
			if(flg == 0) break;
			for (int k = 0; k < n - 1; k++) {
				if(flg == 0) break;
				for (int l = k + 1; l < n; l++)
					if ((stoi(org[i]) == stoi(org[j])) && (org[i] == a[l]) && (org[j] == a[k])) {
						flg *= 0;
						break;
					}
			}
		}
	}
	for (int i = 0; i < n - 1; i++)
		cout << a[i] << ' ';
		cout << a[n - 1] << endl;
	if (flg)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	for (int i = 0; i < n; i++)
		a[i] = org[i];
	for (int i = 0; i < n -1; i++) {
		min = i;
		for (int j = i + 1; j < n ; j++) {
			if (stoi(a[j]) < stoi(a[min]))
				min = j;
		}
		if (min != i) {
			tmp = a[i];
			a[i] = a[min];
			a[min] = tmp;
		}
	}
	flg = 1;
	for (int i = 0; i < n - 1; i++) {
		if(flg == 0) break;
		for (int j = i + 1; j < n; j++) {
			if(flg == 0) break;
			for (int k = 0; k < n - 1; k++) {
				if(flg == 0) break;
				for (int l = k + 1; l < n; l++)
					if ((stoi(org[i]) == stoi(org[j])) && (org[i] == a[l]) && (org[j] == a[k])) {
						flg *= 0;
						break;
					}
			}
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << (a[i]) << ' ';
		cout << (a[n - 1]) << endl;
	if (flg)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = max({a * c, b * c, a * d, b * d});
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0)break;
        int a = 1,b = 1,sum = 1;
        while(1){
            if(sum < n){ b++; sum+=b;}
            else if(sum > n){ sum-=a;a++;}
            else break;
        }
        cout << a << " " << b-a+1 << endl;
    }
}


Measured memory_bytes: 3040
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int main(){
  int n,k; cin >> n >> k;
  int cnt=0;
  while(n!=0){
    n/=k;
    cnt++;
  }
  cout << cnt << endl;
}

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

long long n,dp[200005];
pair<int,int> x[200005];
deque<pair<long long,int> > v; 

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	
	for(int i=0;i<n;i++)cin>>x[i].first>>x[i].second;
	sort(x,x+n);
	
	v.push_back({1000000000000ll,n});
	dp[n]=1ll;

	for(int i=n-1;i>=0;i--){
		while(v.back().first<(x[i].first+x[i].second))v.pop_back();
		dp[i]=(dp[i+1]+dp[v.back().second])%MOD;
		v.push_back({x[i].first,i});
	}	
	
	cout<<dp[0]<<"\n";

return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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);
  rep(i,5) {
    int x; cin>>x;
    if(x==0) {
      cout<<i+1<<endl;
      return 0;
    }
  }
}

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

int main()
{
    string v;
    cin >> v;
    int no_a = 0;
    int no_b = 0;
    int no_c = 0;

    for (int i = 0; i < 3; i++) {
        if (v[i] == 'a') {
            no_a++;
        }
        else if (v[i] == 'b') {
            no_b++;
        }
        else if (v[i] == 'c') {
            no_c++;
        }
    }
    if ((no_a == 1) && (no_b == 1) && (no_c == 1)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, K;
    cin >> n >> K;
    int res = 0;
    for(int i = 1; i <= n; ++i) {
        if(i%K == 0) res++;
    }
    res = res*res*res;
    if(K%2 == 0) {
        K /= 2;
        int cnt = 0;
        for(int i = 1; i <= n; ++i) {
            if(i%K == 0 && i%(2*K) != 0) cnt++;
        }
        res += cnt*cnt*cnt;
    }
    cout << res << '\n';
    return 0;
}
















Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif





ll n;
vector<ll> v;
vector<ll> c;
vector<ll> c_prevpos;
vector<ll> pos_prevpos;


const ll MOD = 1e9+7;

int main(){
	cin >> n;
	
	v.resize(n);
	c.resize(n);
	c_prevpos.resize(200001,-1);
	pos_prevpos.resize(n,-1);
	
	rep(i,n){
		cin >> c[i];
		pos_prevpos[i] = c_prevpos[c[i]];
		c_prevpos[c[i]] = i;
	}
	
	v[0] = 1;
	for ( int i = 1; i < n; i++ ){
		// v[i] は c[0..i] の塗り方の数
		int p = pos_prevpos[i];
		if ( p != -1 && p != i-1 )
			v[i] = (v[i-1] + v[p])%MOD;
		else
			v[i] = v[i-1];
	}
	
	
	cout << v[n-1] << endl;
	
	return 0;
}




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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    int n;
    cin >> n;
    if(n == 0) break;

    REP(ii,n){
      int a[4], b[4];
      REP(i,4){
        cin >> a[i];
      }
      REP(i,4){
        cin >> b[i];
      }
      int ans[4] = {};

      REP(i,4){
        ans[i] += a[0] * b[i];
      }

      ans[1] += a[1] * b[0];
      ans[0] -= a[1] * b[1];
      ans[3] += a[1] * b[2];
      ans[2] -= a[1] * b[3];

      ans[2] += a[2] * b[0];
      ans[3] -= a[2] * b[1];
      ans[0] -= a[2] * b[2];
      ans[1] += a[2] * b[3];

      ans[3] += a[3] * b[0];
      ans[2] += a[3] * b[1];
      ans[1] -= a[3] * b[2];
      ans[0] -= a[3] * b[3];

      cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;

    }
  }
  return 0;
}




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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

constexpr ll INF = 1e18;

void amin(ll &x, ll y) {
  x = min(x, y);
}

template<class T>
struct matrix {
  int n;
  vector<T> dat;

  matrix(int n_) : n(n_), dat(n_ * n_) {}

  matrix(initializer_list<initializer_list<T>> a) {
    n = a.size();
    dat.reserve(n * n);
    for (initializer_list<T> x : a) {
      assert(x.size() == n);
      for (T y : x) {
        dat.push_back(y);
      }
    }
  }

  T &operator()(int i, int j) {
    assert(0 <= i && i < n && 0 <= j && j < n);
    return dat[i * n + j];
  }

  friend matrix<T> operator*(matrix<T> a, matrix<T> b) {
    assert(a.n == b.n);
    const int n = a.n;
    matrix<T> c(n);
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < n; k++) {
        for (int j = 0; j < n; j++) {
          c(i, j) = c(i, j) + a(i, k) * b(k, j);
        }
      }
    }
    return c;
  }

  friend vector<T> operator*(matrix<T> a, vector<T> b) {
    assert(a.n == b.size());
    const int n = b.size();
    vector<T> ans(n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ans[i] += a(i, j) * b[j];
      }
    }
    return ans;
  }

  friend matrix<T> &operator*=(matrix<T> &a, matrix<T> b) {
    return a = a * b;
  }

  friend matrix<T> pow(matrix<T> a, long long b) {
    matrix<T> res(a.n);
    for (int i = 0; i < a.n; i++) {
      res(i, i) = 1;
    }
    for (; b > 0; a *= a, b >>= 1) {
      if (b & 1) res *= a;
    }
    return res;
  }

  friend ostream &operator<<(ostream &o, matrix<T> a) {
    o << '[';
    for (int i = 0; i < a.n; i++) {
      if (i > 0) o << ' ';
      o << '[';
      for (int j = 0; j < a.n; j++) {
        if (j > 0) o << ' ';
        o << a(i, j);
      }
      o << ']';
    }
    o << ']';
    return o;
  }
};

struct op {
  ll x;

  op(ll x_ = INF) : x(x_) {}

  friend op operator+(op a, op b) {
    return min(a.x, b.x);
  }

  friend op operator*(op a, op b) {
    return a.x + b.x;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s; cin >> s;
  const int n = s.size();
  int K; cin >> K;
  vector<vector<ll>> dp(27, vector<ll>(27, INF));
  rep(i, 27) dp[i][i] = 0;
  rep(i, n) {
    vector<vector<ll>> ep(27, vector<ll>(27, INF));
    rep(j, 27) rep(k, 27) rep(l, 26) {
      if (l != k) {
        amin(ep[j][l], dp[j][k] + (l != s[i] - 'a'));
      }
    }
    dp = ep;
  }
  matrix<op> mat(27);
  rep(i, 27) rep(j, 27) {
    mat(i, j) = dp[j][i];
  }
  mat = pow(mat, K);
  ll ans = INF;
  rep(i, 26) {
    amin(ans, mat(i, 26).x);
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
           {
              sum+=i;
           }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)

template<typename T>
void prinMatrix(string txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(string txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}


int main(){

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

	int n;
	cin >> n;
	int odds = 0, evens = 0;
	if (n == 1){
		cout << 1 << endl;
		return 0;
	}
	if (n % 2 == 0){
		cout << 0.5 << endl;
		return 0;
	}
	else{
		evens = n / 2;
		odds = evens + 1;

		cout << (double)odds / (double)(odds + evens) << endl;
	}

	return 0;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
d = dict()

ma = 0
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] > ma:
        ma = d[s]

res = []
for e in d:
    if d[e] == ma:
        res.append(e)

res.sort()
for e in res:
    print(e)

Measured memory_bytes: 92120
use proconio::marker::{Chars, Usize1};
use proconio::{fastout, input};
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! multi_vec {
    ( $elem:expr; $num:expr ) => (vec![$elem; $num]);
    ( $elem:expr; $num:expr, $($rest:expr),* ) => (vec![multi_vec![$elem; $($rest),*]; $num]);
}

const WALL: char = '#';
const ROAD: char = '.';
const INF: usize = std::usize::MAX >> 2;
#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        c: (Usize1, Usize1),
        d: (Usize1, Usize1),
        s: [Chars; h],
    }

    let mut solve = Solve { h, w, c, d, s };
    solve.solve();
}

struct Solve {
    h: usize,
    w: usize,
    c: (usize, usize),
    d: (usize, usize),
    s: Vec<Vec<char>>,
}

impl Solve {
    fn solve(&mut self) {
        let h = self.h;
        let w = self.w;
        let c = self.c;
        let (c1, c2) = self.c;

        let mut distances = multi_vec![-1i64; h, w];
        let mut q = VecDeque::new();
        distances[c1][c2] = 0;
        q.push_back(c);

        let dirs: Vec<(i64, i64)> = vec![(1, 0), (-1, 0), (0, 1), (0, -1)];
        let mut warp = vec![];
        for i in -2..=2 {
            for j in -2..=2 {
                if i == 0 && j == 0 {
                    continue;
                }
                if dirs.contains(&(i, j)) {
                    continue;
                }
                warp.push((i, j));
            }
        }
        let warp = warp;

        while let Some((p1, p2)) = q.pop_front() {
            for (d1, d2) in dirs.iter().copied() {
                let n1 = p1 as i64 + d1;
                let n2 = p2 as i64 + d2;
                if !(0 <= n1 && n1 < h as i64 && 0 <= n2 && n2 < w as i64) {
                    continue;
                }
                let n1 = n1 as usize;
                let n2 = n2 as usize;
                if self.s[n1][n2] == WALL {
                    continue;
                }
                if distances[n1][n2] != -1 && distances[n1][n2] <= distances[p1][p2] {
                    continue;
                }

                distances[n1][n2] = distances[p1][p2];
                q.push_front((n1, n2));
            }
            for (d1, d2) in warp.iter().copied() {
                let n1 = p1 as i64 + d1;
                let n2 = p2 as i64 + d2;
                if !(0 <= n1 && n1 < h as i64 && 0 <= n2 && n2 < w as i64) {
                    continue;
                }
                let n1 = n1 as usize;
                let n2 = n2 as usize;
                if self.s[n1][n2] == WALL {
                    continue;
                }
                if distances[n1][n2] != -1 && distances[n1][n2] <= distances[p1][p2] + 1 {
                    continue;
                }

                distances[n1][n2] = distances[p1][p2] + 1;
                q.push_back((n1, n2));
            }
        }

        let d = self.d;
        let ans = distances[d.0][d.1];
        println!("{}", ans);
    }
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    double theta;
    if(a*a*b < 2*x){
        theta = atan2(2*a*a*b-2*x, a*a*a) * 180.0 / M_PI;
    }
    else{
        theta = atan2(a*b*b, 2*x) * 180.0 / M_PI;
    }
    printf("%.12lf\n", theta);

    return 0;
}

/*



*/

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

int main(){
	int n, r, t;
	cin >> n >> r >> t;

	int now[110];
	int p[110];

	int need = n;

	t--;

	int drink[1010] = {};
	for(int i = 0;i < n;i++){
		cin >> p[i];
		now[i] = p[i];
	}

	for(int i = 0;i < t;i++){
		for(int j = 0;j < n;j++){
			now[j] += p[j];
			now[j] %= r;
			if(drink[now[j]] == 0){
				need++;
			}else{
				drink[now[j]]--;
			}
		}
		
		for(int j = 0;j < n;j++) drink[now[j]]++;
	}
	
	cout << need << endl;

	return 0;
}



Measured memory_bytes: 3112
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#ifndef ONLINE_JUDGE
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

vector<int> res[450];

int main() {
    int n = gi();

    int k = 1;
    for (; k < 450; k++)
        if (k*(k-1)/2 == n)
            break;

    if (k == 450) {
        printf("No\n");
        return 0;
    }

    int c = 0;
    for (int i = 0; i < k; i++)
        for (int j = i+1; j < k; j++) {
            c++;
            res[i].push_back(c);
            res[j].push_back(c);
        }

    printf("Yes\n%d", k);
    for (int i = 0; i < k; i++) {
        printf("\n%d", k-1);
        for (int j = 0; j < k-1; j++)
            printf(" %d", res[i][j]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <map>

using namespace std;

int main()	{
  	int a;
  	map<int, int> freq;
  	for (int i = 0; i < 3; i++)	{
    	cin >> a;
      	freq[a]++;
    }
  	if (freq[5] != 2 || freq[7] != 1)	{
    	cout << "NO" << endl;
    }
  	else	{
    	cout << "YES" << endl;
    }
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, ll> pa;

struct edge {
    int to;
    ll coin;
};

int n;
ll p;
vector<vector<edge>> graph;
vector<vector<int>> b_graph;
vector<bool> reachable;
bool is_inf;

void backdfs(int now) {
    reachable[now] = true;
    for (auto to:b_graph[now]) {
        if (reachable[to])continue;

        backdfs(to);
    }
}

ll bfs() {
    queue<pa> vertex;
    vertex.push(pa(0, 0));
    vertex.push(pa(-1, 0));
    int depth = 0;
    vector<ll> maxpoint(n, -3643641919810114514);

    while (true) {
        pa now_edge = vertex.front();
        int nowv = now_edge.first;
        vertex.pop();
        if (nowv == -1) {
            if (vertex.empty()) break;
            depth++;
            vertex.push(pa(-1, -1));
        } else {
            if (maxpoint[nowv] <= now_edge.second) {
                maxpoint[nowv] = now_edge.second;
                if (nowv == n - 1 && depth > 10000) {
                    is_inf = true;
                    cout << -1 << endl;
                    return -1;
                }
                for (auto next:graph[nowv]) {
                    ll point = now_edge.second + next.coin - p;
                    if (point > maxpoint[next.to] && reachable[next.to]) {
                        maxpoint[next.to] = point;
                        vertex.push(pa(next.to, point));
                    }
                }
            }
        }
    }

    return max(0LL, maxpoint[n - 1]);
}

int main() {
    int m;
    cin >> n >> m >> p;
    graph = vector<vector<edge>>(n);
    b_graph = vector<vector<int>>(n);

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back(edge{b, c});
        b_graph[b].push_back(a);
    }

    reachable = vector<bool>(n);
    backdfs(n - 1);

    ll ret = bfs();
    if (!is_inf)cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int N,M,i,ans;
	ans=0;
	scanf("%d %d",&N,&M);
	for(i=1;i<N;i++){
		ans+=i;
	}
	for(i=1;i<M;i++){
		ans+=i;
	}
	printf("%d\n",ans);
	return 0;
}

		

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

const int MAX_N = 1E5 + 10;

int n, q, ans[MAX_N];
string s;

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

    cin >> n >> q >> s;

    for (int i = 1; i < s.length(); i++)
        ans[i] = ans[i - 1] + (s[i] == 'C' && s[i - 1] == 'A');

    for (int i = 0; i < q; i++)
    {
        int l, r;

        cin >> l >> r;

        cout << ans[r - 1] - ans[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1488
package main

import "fmt"

func main() {
	// Code for B - Shiritori
	var N int
	fmt.Scanf("%d", &N)

	var W, WBefore string
	var rule int = 0
	flag := make(map[string]int, N)

	fmt.Scanf("%s", &W)
	WBefore = W
	flag[W]++
	for i := 1; i < N; i++ {
		fmt.Scanf("%s", &W)
		flag[W]++

		if flag[W] == 2 || WBefore[len(WBefore)-1] != W[0] {
			rule = 1
			break
		}
		WBefore = W
	}

	if rule == 1 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

int main()
{
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx - sx;
	int y = ty - sy;

	for(int i  =0;i<y;i++)
	{
		cout<<'U';
	}
	for(int i = 0;i<x+1;i++)
	{
		cout<<'R';
	}
	for(int i = 0;i<y+1;i++)
	{
		cout<<'D';
	}
	for(int i = 0;i<x+1;i++)
	{
		cout<<'L';
	}
	cout<<'U';
	for(int i =0;i< x;i++)cout<<'R';
	for(int i = 0;i<y+1;i++)cout<<'U';
	for(int i =0;i<x+1;i++)cout<<'L';
	for(int i =0 ;i<y+1;i++)cout<<'D';
	cout<<'R'<<endl;;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		ArrayList<String>array = new ArrayList<String>();
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String[] str = n.split("[,\\s.]");
		for(int i = 0; i < str.length; i++){
			if(2 < str[i].length() && str[i].length() < 7){
				array.add(str[i]);
			}
		}
		for(int i = 0;i < array.size()-1;i++){
			System.out.print(array.get(i)+" ");
		}
		System.out.println(array.get(array.size()-1));
	}
		 
}

Measured memory_bytes: 26260
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,5,63]
elif 4 <= N <= 15000:
    for i in range(1,n):
        ans.append(2*i)
        x = 30000 - 2*i
        ans.append(x)
    if N % 2 == 1:
        ans.append(30000)
    ans.append(3)
    ans.append(9)
else:
    for i in range(1,15000):
        ans.append(2*i)
    x = N - 14999
    for j in range(x-1):
        y = 6*j + 3
        ans.append(y)
    if x % 2 == 1:
        ans.append(30000)
    else:
        ans.append(6*x - 3)
print(*ans)
    


Measured memory_bytes: 4576
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	K, _ := io.nextInt()
	Q, _ := io.nextInt()

	A := make([]int, N)

	for i := 0; i < Q; i++ {
		n, _ := io.nextInt()
		A[n-1]++
	}

	for _, val := range A {
		if (Q - val) < K {
			io.PutString("Yes")
		} else {
			io.PutString("No")
		}
	}
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 3968
# https://atcoder.jp/contests/abc148/tasks/abc148_d


def main():
    num = int(input())
    origin = [int(i) for i in input().split(" ")]
    break_count = 0
    want = 1
    satisfy = False
    for b in origin:
        if b == want:
            want += 1
            satisfy = True
            continue
        else:
            break_count += 1
    print("-1" if not satisfy else break_count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26268
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	ll N;
	cin >> N;

	ll dp[61][2][2] = {};
	dp[60][0][0] = 1;
	const ll mod = 1e9 + 7;

	for (int i = 59; i >= 0; i--) {
		if (N >> i & 1) {
			dp[i][0][0] += dp[i + 1][0][0];
			dp[i][0][1] += dp[i + 1][0][0];
			dp[i][1][0] += dp[i + 1][0][0];

			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][1][1] += dp[i + 1][1][0];

			dp[i][0][1] += dp[i + 1][0][1];
			dp[i][1][1] += dp[i + 1][0][1];
			dp[i][1][0] += dp[i + 1][0][1];

			dp[i][1][0] += dp[i + 1][1][1];
			dp[i][1][1] += dp[i + 1][1][1];
			dp[i][1][1] += dp[i + 1][1][1];
		}
		else {
			dp[i][0][0] += dp[i + 1][0][0];

			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][1][0] += dp[i + 1][1][0];
			dp[i][1][1] += dp[i + 1][1][0];

			dp[i][0][1] += dp[i + 1][0][1];
			dp[i][0][0] += dp[i + 1][0][1];

			dp[i][1][0] += dp[i + 1][1][1];
			dp[i][1][1] += dp[i + 1][1][1];
			dp[i][1][1] += dp[i + 1][1][1];
		}
		dp[i][0][0] %= mod;
		dp[i][0][1] %= mod;
		dp[i][1][0] %= mod;
		dp[i][1][1] %= mod;
	}

	co((dp[0][0][0] + dp[0][1][0]) % mod);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL_INF 0x7ffffffffffffffe
using namespace std;
typedef long long ll;

int main(void) {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll x[4];
	x[0] = a * c;
	x[1] = a * d;
	x[2] = b * c;
	x[3] = b * d;
	ll maxi = -LL_INF;
	for(int i=0;i<4;i++) {
		if(x[i] > maxi) {
			maxi = x[i];
		}
	}
	cout << maxi << endl;
	return 0;
}



Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

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



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

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

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

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
const int N = 100005;

ll dp[N][2];
int a[N];

int main () {
    int n;
    read(n);
    for (int i = 1; i <= n; ++i) {
        read(a[i]);
    }
    dp[1][0] = a[1];
    dp[1][1] = -iinf;
    for (int i = 2; i <= n; ++i) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
        dp[i][1] = max(dp[i - 1][0] - 2 * a[i - 1] - a[i], dp[i - 1][1] + 2 * a[i - 1] - a[i]);
    }
    write(max(dp[n][0], dp[n][1])), EL;
    return 0;
}

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


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>

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

    std::vector<int> x(n);
    for(int i = 0; i < n; ++i){
        std::cin >> x.at(i);
    }

    std::vector<int> y(x);
    std::sort(y.begin(), y.end());
    for(int i = 0; i < n; ++i){
        if(x.at(i) <= y.at(n / 2 - 1)){
            std::cout << y.at(n / 2) << std::endl;
        }else{
            std::cout << y.at(n / 2 - 1) << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		char[] s_chars = s.toCharArray();
        Arrays.sort(s_chars);
        String s_asc = new String(s_chars);
		
		String t = in.next();
		char[] t_chars = t.toCharArray();
		Arrays.sort(t_chars);
		String t_asc = new String(t_chars);
		String t_desc = new StringBuilder(t_asc).reverse().toString();
		
		if (s_asc.compareTo(t_desc) < 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;
    vector<pll> a(n);
    for(int i = 0; i < n; i++) {
        ll h;
        cin >> h;
        a[i] = mp(h,i);
    }
    sort(all(a));
    reverse(all(a));

    vector<vll> dp(n + 1, vll(n + 1, -(1LL << 50)));
    dp[0][0] = 0;

    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j < n; j++) {
            if(dp[i][j] == -(1LL << 50)) continue;
            int right = i - j + 1;
            // lets go left
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i].first*abs(a[i].second - j));
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i].first*abs(n - right - a[i].second));
        }
    }
    ll ans = -1;
    for(int i = 0; i < n + 1; i++) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
	int n,m;
	cin >> n >> m;
	UnionFind tree(n);
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	rep(i,m){
		int x,y;
		cin >> x >> y;
		//0~n-1を入れるので、
		//かならずデクリメントする！！
		x--;y--;
		tree.unite(x,y);
	}
	int cnt=0;
	rep(i,n){
		if(tree.same(i,p[i]-1)) 
			cnt++;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N,ma=-INF,x=0,mi=INF,y=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
    if(A.at(i)>ma){
      ma=max(ma,A.at(i));
      x=i;
    }
    if(mi>A.at(i)){
      mi=min(mi,A.at(i));
      y=i;
    }
  }
  cout << 2*N-1 << endl;
  if(abs(ma)<abs(mi)){
    rep(i,N){
      cout << y+1 << " " << i+1 << endl;;
    }
    rep(i,N-1){
      cout << N-i << " " << N-1-i << endl;
    }
  }else{
    rep(i,N){
      cout << x+1 << " " << i+1 << endl;;
    }
    rep(i,N-1){
      cout << i+1 << " " << i+2 << endl;
    }
  }
}

Measured memory_bytes: 3632
import itertools
import math
# import decimal import *

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

#idList = [i for i in range(1, n + 1)]
idList = [i for i in range(n)]

com = list(itertools.combinations(idList, 2))
# print(com)

ans = 0

for i, j in com:
    tar1 = data[i]
    tar2 = data[j]

    add = (tar1[0] - tar2[0]) ** 2 + (tar1[1] - tar2[1]) ** 2
    ans += math.sqrt(add)

ans = ans * 2 / float(n)
#ans = decimal(ans / float(n))

print(ans)


Measured memory_bytes: 3064