akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,n,m,k,x,y=0,ans=1;
    string str,s="",t,u;


    for (int i = 0; i < 5; ++i) {
        cin>>a;
        if(a==0){
            cout<<i+1<<endl;
            return 0;
        }
    }





    cout<<endl;
    return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define ll              long long 
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)   
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}


template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
  }
};


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

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}
 
//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();
  
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  int i=0;
  while(a>0 && c>0)
  {
  	if(i%2==0)
  	c-=b;
  	else
  	a-=d;
  	
  	i++;
  }
  if(a>0 && c<=0)
  cout<<"Yes";
  else
  cout<<"No";
}

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

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

	vector<int>b(N);
	vector<int>ans;
	for (int i = N - 1; i >= 0; i--)
	{
		b[i] = a[i];

		if (b[i])
		{
			ans.push_back(i+1);

			int x = i+1;
			vector<int>prime;
			for (int j = 2; j * j <= x; j++)
			{
				while (x % j == 0)
				{
					prime.push_back(j);
					x/=j;
				}
			}
			if(x!=1)prime.push_back(x);

			vector<int>yaku;
			yaku.push_back(1);
			for (int j = 0; j < prime.size(); j++)
			{
				int p = prime[j];
				for (int k = yaku.size() - 1; k >= 0; k--)
				{
					yaku.push_back(yaku[k]*p);
				}
			}
			sort(yaku.begin(), yaku.end());
			yaku.erase(unique(yaku.begin(), yaku.end()), yaku.end());

			for (int k = 0; k < yaku.size(); k++)
			{
				a[yaku[k]-1]^=1;
			}
		}
	}

	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)
	{
		if(i)cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
  int a,b,n;
  int m[20][20]={};
int cnt;

void  dfs(int x,int y){
  if(x>a || y>b) return;
  if(m[y][x]==2) return ;
  if(x==a && y==b){cnt++;return ;}
  dfs(x+1,y);
  dfs(x,y+1);
}

int main(){
  while(1){
    cnt=0;
  cin>>a>>b;
  if(a+b==0)break;
  cin>>n;
  int x,y;
  for(int i=1;i<=b;i++)
    for(int j=1;j<=a;j++)m[i][j]=0;

  for(int i=0;i<n;i++){ cin>>x>>y; m[y][x]=2; }
  dfs(1,1);
  cout<<cnt<<endl;
  }
  return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e2 + 10;
const int mod = 1e9 + 7;


map<int, int> mp;

void fac(int n){
	while(n%2 == 0){
		n /= 2;
		mp[2]++;
	}
	int sq = sqrt(n);
	for(int i = 3 ; i <= sq ; i+=2){
		while(n%i == 0){
			n /= i;
			mp[i]++;
		}
	}

	if(n != 1){
		mp[n]++;
	}

}
int32_t main(){
	boost;

	int n;
	cin >> n;

	cout <<(( n < 1200) ? "ABC" : "ARC");
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(a;stdin.byLine().map!(to!real)())
    {
        auto t=a;
        foreach(i;2..11)
            a/=(i&1)?3:0.5,t+=a;
        writefln("%.7f",t);
    }
}

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

int main() {
  int N;
  cin >> N;
  int fN = 0;
  
  for (int i=0; i < 9; i++) {
    fN += N % (int)pow(10, i+1) / (int)pow(10, i);
  }
  
  if (N % fN == 0) {
    cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
}


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


Measured memory_bytes: 3644
n = int(input())
p = [int(i) for i in input().split()]

pos_list = [0] * n
for ind, i in enumerate(p):
	pos_list[i-1] = ind

left_nextInd = list(range(-1, n-1)) + [-1, -1]
right_nextInd = list(range(1, n+1)) + [n, n]

answer = 0
for i in range(1, n):
	ind = pos_list[i-1]
	l1 = left_nextInd[ind]
	l2 = left_nextInd[l1]
	r1 = right_nextInd[ind]
	r2 = right_nextInd[r1]

	answer += i * ((ind-l1) * (r2-r1) + (r1-ind) * (l1-l2))

	left_nextInd[r1] = l1
	right_nextInd[l1] = r1
print(answer)

Measured memory_bytes: 20152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <numeric>
#include <stdlib.h>

using namespace std;

typedef long long ll;

int main()
{
    int x, a, b; cin >> x >> a >> b;
    if (abs(x - a) <= abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

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

int main()
{
  int X, K;
  std::cin >> K >> X;
  int start = std::max(-1000000,X-K+1);
  int end = std::min(1000000,X+K-1);
  for(int i=start; i<=end; i++) { std::cout << i << " "; }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

void dfs(vector<ll>& ans, vector<vector<pair<ll,ll>>>& A, ll pos, ll distance)
{
    ans[pos] = distance % 2;
    for (auto b : A[pos]) {
        if (ans[b.first] == -1) {
            dfs(ans, A, b.first, distance + b.second);
        }
    }
}

ll solve()
{
    //ld ans = 0;
    ll N;
    cin >> N;
    vector<vector<pair<ll,ll>>> A(N);
    for1(i,N-1) {
        ll u,v,w;
        cin >> u >> v >> w;
        --u;
        --v;
        A[u].push_back(make_pair(v,w));
        A[v].push_back(make_pair(u,w));
    }
    vector<ll> ans(N,-1);
    dfs(ans, A, 0, 0);
    for1(i,N) {
        cout << ans[i] << endl;
    }

    return 0;
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  char a;
  scanf("%c",&a);

  if(a - 'Z' <= 0){
    printf("A");
  }else{
    printf("a");
  }

  return 0;
}


Measured memory_bytes: 1588
/*  Perseverance can make miracle happens  */
/* If u identify me then u r my frnd */

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

#define int long long int
#define vi vector<int>
#define pq priority_queue<int>
#define mpi map<int,int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define M 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

int mod(long long x) {
	return ((x % M + M) % M);
}
int add(int a, int b) {
	return mod(mod(a) + mod(b));
}
int diff(int a, int b) {
	return mod(mod(a) - mod(b));
}

int mul(int a, int b) {
	return mod(mod(a) * mod(b));
}

void solve() {

	int n; cin >> n;
	int a[n];
	int s = 0;
	forn(i, n) {
		cin >> a[i];
		s += a[i];
	}

	int ps[n];
	ps[0] = a[0];
	for (int i = 1; i < n; i++) {
		ps[i] = add(ps[i - 1] , a[i]);
	}


	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = add(mod(ans) , mul(a[i] , (s - ps[i])));
	}

	cout << ans << endl;


}


int32_t main() {

	fastio;

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

	// int t; cin >> t;
	int t = 1;

	while (t--) {
		solve();
	}

	return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
       int n; cin>>n;
       int arr[n];
       int m; cin>>m;
       memset(arr,-1,sizeof arr);
	   for (int i = 0; i < m; i++)
	   {
		   int a,b; cin>>a>>b;
		   a -= 1;
		   if(arr[a] != -1)
		   {
			   if(arr[a] != b) return cout<<-1,0;
		   }
		   else
		   {
			   arr[a] = b;
		   }
	   }
	   for (int i = 1; i < n; i++)
	   {
		   if(arr[i] == - 1) arr[i] = 0;
	   }
	   if(arr[0] == -1 and n != 1) arr[0] = 1;
	   if(arr[0] == -1 and n == 1) arr[0] = 0;
	   
	   if(arr[0] == 0 and n !=1) return cout<<-1,0;
	   
	   for(auto x : arr) cout<<x;
    }
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define N 200000
#define LL long long
using namespace std;

int n;
LL k,a[N+5],f[N+5],oo=1e12+0ll,l,r,mid,ans=1e12+0ll;

bool cmp1(LL a,LL b){
	return a<b;
}

bool cmp2(LL a,LL b){
	return a>b;
}

bool check(LL mid){
	LL num=0;
	for(int i=1;i<=n;i++)
	if(a[i]*f[i]>mid)
	num+=a[i]-mid/f[i]+0ll;
	if(num>k)return false;
	return true;
}

int main(void){
	scanf("%d %lld",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	scanf("%d",&f[i]); 
	sort(a+1,a+1+n,cmp1);
	sort(f+1,f+1+n,cmp2);
	l=0,r=oo;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid))ans=min(ans,mid),r=mid-1;
		else l=mid+1;
	}
	printf("%lld",ans);
}

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

int main(){
  stack<int> st;
  string s;
  while(cin >> s){
    if(isdigit(s[0])){
      st.push(atoi(s.c_str()));
    }
    else{
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();

      if(s == "+") st.push(b + a);
      if(s == "-") st.push(b - a);
      if(s == "*") st.push(b * a);
    }
  }
  cout << st.top() << endl;
}


Measured memory_bytes: 3180
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int n = Integer.parseInt(sn.next());
        int k = Integer.parseInt(sn.next());
        int cnt = 0;
        List<Integer> stateList = new ArrayList<Integer>();
        
        for ( int i = 0; i < n; i++){
            stateList.add(Integer.parseInt(sn.next()));
        }

        for ( int i2 = k-1; i2 < n-1; i2++){
            if (stateList.get(cnt) < stateList.get(i2+1)){
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
            cnt = cnt+1;
        }
    }
}


Measured memory_bytes: 65388
/*
  Lower bound: first element that is greater-or-equal.
  int i=lower_bound(a,a+n,x)-a;
  Upper bound: first element that is strictly greater.
  #include<boost/multiprecision/cpp_int.hpp>
  namespace mp=boost::multiprecision;
  mp::cpp_int u=1; for(unsigned i=1;i<=n;i++) u*=i;
*/
#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
const int mod=(int)1e9+7;
const long long INF = 1000000000000000000LL;
const int WASTE=(int)2e5;
int power(int a,int b,int m=mod){
	if(b == 0) return 1;
	if(b == 1) return a;
	int x = power(a,b/2,m)%m;
	x = (x*x)%m;
	if(b%2) return (x*a)%m;
	return x;
}
//#define int long long
const int N=1e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int c[n+1],s[n+1],f[n+1];
    for(int x=1;x<n;x++){
    	cin>>c[x]>>s[x]>>f[x];
    }
    int ans[n+1];
    ans[n]=0;
    for(int x=1;x<n;x++){
    	int st=s[x];
    	for(int y=x+1;y<=n;y++){
    		st+=c[y-1];
    		if(y==n)
    			break;
    		if(st<s[y])
    			st=s[y];
    		while(st%f[y])
    			st++;
    	}
    	ans[x]=st;
    }
    for(int x=1;x<=n;x++)
    	cout<<ans[x]<<endl;
    return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    int bt=1;
    int ans=0;
    rep(i,n){
        int lbt=v[bt-1];
        if(bt==2){
            cout<<ans<<endl;return 0;
        }else{
            ans++;
        }
        bt=v[bt-1];
    }
    cout<<-1<<endl;
    
    
    
    
return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int n, a, b, c, d, i;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  char u;
  for(i = 0; i < n; i++){
    scanf(" %c", &u);
  }
  if(n%3&&(n%3!=1||(b%3+c%3)%2)){printf("No\n");}
  else{printf("Yes\n");}
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

/*================================================
	GCD function
================================================*/
ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	ll A, B;

	cin >> A >> B;

	cout << A * B / gcd(A, B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = a[0];
  for (int i = 1; i < n; i++)
    ans = __gcd(ans, a[i]);
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 3964
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

i64 mod = 1e9+7;

int main(){
    string l;
    cin >> l;
    i64 n = l.length();
    vector<i64> dp0(n, 0), dp1(n, 0);
    dp0[0] = 1;
    dp1[0] = 2;
    for(int i = 1; i < n; ++i){
        if(l[i] == '0'){
            dp0[i] = dp0[i - 1] * 3 % mod;
            dp1[i] = dp1[i - 1];
        }else{
            dp0[i] = (dp0[i - 1] * 3 % mod + dp1[i - 1]) % mod;
            dp1[i] = dp1[i - 1] * 2 % mod;
        }
    }
    cout << (dp0[n - 1] + dp1[n - 1]) % mod << endl;
}

Measured memory_bytes: 2048
/*
   first we need to sort the all edges then updates them one after another .
   we update them according to the adjacent edges then maximize the answer of edge
*/
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
int n,m,l,r,a[100010];
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
input;

cin>>n>>m;

forr(i,1,m)
{
    cin>>l>>r;
    a[l]++;
    a[r+1]--;
}
int ans=0;
forr(i,1,n)
{
a[i]+=a[i-1];
if(a[i]==m)ans++;
}

cout<<ans;
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  string s;
  cin >> s;
  bool ok = true;
  if(s[0] != s[2]) ok = false;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n, m;
    cin >> n >> m;
    int wa_sum = 0;
    map<int, bool> ac;
    map<int, int> wa;
    int ac_count = 0;
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA" && !ac[p]) {
            wa[p]++;
        } else if (s == "AC" && !ac[p]) {
            ac[p] = true;
            ac_count++;
        }
    }
    for(auto itr : wa){
        int p = itr.first;
        if(ac[p]) wa_sum += wa[p];
    }
    cout << ac_count << " " << wa_sum << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << (a <= c and c <= b ? "Yes\n" : "No\n");
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
  std::vector<std::string>  str;
  int N, L;
  scanf("%d %d", &N, &L);

  str.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> str[i];
  }

  std::sort(str.begin(), str.end());
  
  std::cout << std::accumulate(str.begin(), str.end(), std::string("")) << std::endl;
  return 0;
}




Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = as.nextInt();
		int c = as.nextInt();
		int k = as.nextInt();
		int[] a;
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(as.next());
		}
		Arrays.sort(a); 
		int l = 0;
		long q = 0;
		int e = 0;
		boolean w = true;
		for(int i=0;i<n;i++){
			if(w){
				l++;
				e++;
				q = a[i];
				w = false;
			}else{
				if(e<c&&q+k>=a[i]){
					e++;
				}else{
					i--;
					e = 0;
					w = true;
				}
			}
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 48192
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=1,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T,U;
  cin>>N;
  N%digitsum(N)==0?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll A, B;
    cin >> A >> B;
    ll C   = __gcd(A, B);
    ll ans = 1;
    for (ll i = 2; i * i <= C; i++) {
        if (C % i == 0) {
            ans++;
            while (C % i == 0) {
                C /= i;
            }
        }
    }
    if (C != 1) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(  (a%3==0) || (b%3==0) || ((a+b)%3==0)  )
		cout<<"Possible";
	else
		cout<<"Impossible";	 
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{

	public static void main(String args[]){
		int i,j,n;;
		Scanner sc=new Scanner(System.in);
		n=Integer.parseInt(sc.next());
		int s[]=new int[n+1];
		for(i=0;i<n;i++){
			s[i]=Integer.parseInt(sc.next());
			
		}
		
		
		int q=Integer.parseInt(sc.next());
		int t[]=new int[q+1];
		for(i=0;i<q;i++){
			t[i]=Integer.parseInt(sc.next());
		}
		
		int count=0;
		for(i=0;i<q;i++){
			if(s[n/2]<t[i]){
				for(j=(n/2)+1;j<n;j++){
					
					if(s[j]==t[i]){
						count++;
						break;
					}
				}
			}
			else{
				for(j=0;j<(n/2)+1;j++){
					
					if(s[j]==t[i]){
						count++;
						break;
					}
				}
			}
		}
		
		System.out.println(count);
		
		
		
		
		
		
	}
}

Measured memory_bytes: 68640
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    a = S()
    if a<'a':
        print('A')
    else:
        print('a')
    print
    return

if __name__=='__main__':
    Main()

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

bool ok[1001];

int main(){

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

    int n;
    cin >> n;

    for(int i = 1; i <= 9; ++i)
        for(int j = 1; j <= 9; ++j)
            ok[i * j] = 1;
    cout << (ok[n] ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  set<int>S;
  for(int i=0;i<K;i++){
  int d;
    cin>>d;
    for(int j=0;j<d;j++){
    int a;
      cin>>a;
      S.insert(a);
    }
  
  }int b=S.size();
  cout<<N-b<<endl;
   return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

int dp[200010]={};
VV<int> ne;

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  string s;cin>>s;  
  int n=siz(s); 

  ne=VV<int> (n+2,V<int>(26,n));

  repr(i,0,n){
    rep(j,0,26){
      ne[i][j]=ne[i+1][j];
    }
    ne[i][s[i]-'a']=i;
  }


  dp[n]=1;
  rep(i,0,n)dp[i]=INF;

  repr(i,0,n){
    rep(j,0,26){
      if(ne[i][j]==n){//
        dp[i]=1;
      }else{//作れない文字列の先頭の文字
        chmin(dp[i],dp[ne[i][j]+1]+1);//
      }
    }
  }


  string ans="";
  int ind=0;
  dp[n]=0;
  while(ind<n){
    rep(i,0,26){
      int nind=ne[ind][i]+1;
      if(dp[ind]-1==dp[nind]){
        ans+='a'+i;
        ind=min(n,nind);
        break;
      }
      assert(i<25);
    }

  }
  cout<<ans<<endl;
}

//dp[i] := i文字目以降で作れない文字列の長さの最小
//ne[i][j] := i文字目以降にある文字jで最も左のindex
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 27796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] str=new String[3];
		int a,b,c;
		int divisor=0;

		try{
			str=br.readLine().split(" ");
			a=Integer.parseInt(str[0]);
			b=Integer.parseInt(str[1]);
			c=Integer.parseInt(str[2]);

			for(int i=a;i<=b;i++){
				if(c%i==0)divisor++;
			}
		}catch(IOException e){
			e.printStackTrace();
		}

		System.out.println(divisor);
	}
}

Measured memory_bytes: 24404
N = int(input())

cnt = [[0]*10 for i in range(10)]
# 先頭がi, 末尾がjであるような数の個数を計算
for n in range(1, N+1):
    n = str(n)
    i = int(n[0])
    j = int(n[-1])
    cnt[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j]*cnt[j][i]

print(ans)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
int maxd = 20005;
int dp[20005]={0};

int main(){
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  REP(i, N){
    cin >> A[i] >> B[i];
  }
  REP(i, maxd){
    dp[i] = INF;
  }
  dp[0] = 0;
  REP(i, H){
    if(dp[i] == -1) continue;
    REP(j, N){
      dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j]);
    }
  }
  int ans = INF;
  FOR(i, H, maxd-1){
    ans = min(ans, dp[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(int n,int w,int h){
    vector<pair<int,int>> v;
    v.emplace_back(h,w);
    rep(i,n){
        int k,x;
        cin>>k>>x;
        --k;
        auto p=v[k];
        vector<pair<int,int>> nv;
        rep(j,v.size())if(j!=k)nv.push_back(v[j]);
        h=p.first;w=p.second;
        x%=(h+w);
        if(x<w){
            nv.emplace_back(h,min(x,w-x));
            nv.emplace_back(h,max(x,w-x));
        }
        else {
            nv.emplace_back(min(h+w-x,x-w),w);
            nv.emplace_back(max(h+w-x,x-w),w);
        }
        v.swap(nv);
    }
    sort(v.begin(),v.end(),[](pair<int,int> x,pair<int,int> y){
        return x.first*x.second<y.first*y.second;
    });
    rep(i,v.size()){
        auto p=v[i];
        cout<<p.first*p.second;
        if(i!=n)cout<<" ";
    }
    cout<<endl;
}
int main(){
    int n,w,h;
    while(cin>>n>>w>>h,w!=0)solve(n,w,h);
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000005
constexpr int inf = 100000000;

int n,k;
int w[MAX];

bool check(ll mid){
    int j=0;
    for(int i=0;i<k;i++){
         ll s=0;
        while(s+w[j]<=mid){
            s+=w[j];
            j++;
            if(j==n){
                return true;
            }
        }
    }
    return false;
}

int bs(int ok,int ng){
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(check(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    return ok;
}

int main() {
	cin>>n>>k;
    rep(i,n)cin>>w[i];
    int ng=0,ok=INT_MAX;
    ll ans=bs(ok,ng);
    cout<<ans<<endl;
	return 0;
}












Measured memory_bytes: 3476
n= int(input())
*a,=map(int, input().split( ))
*b,=map(int, input().split( ))
ab = [a[i]-b[i] for i in range(n)]
if sum(ab)<0:
    print(-1)
    exit()

ab.sort()
import bisect
j = bisect.bisect_left(ab,0)
minus = sum(ab[:j])

ans = 0
while minus<0:
    abi = ab.pop()
    minus += abi
    ans += 1
print(ans+j)

Measured memory_bytes: 88880
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	boolean[] p = new boolean[100000];
	setP(p);
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    solve(p, n);
	}
    }

    static void solve(boolean[] p, int n){
	int cnt=0, i;
	for(i=1; i<=n; i++){
	    if(p[i] && p[n-i+1]) cnt++;
	}
	System.out.println(cnt);
    }

    static void setP(boolean[] p){
	Arrays.fill(p, true);
	p[0] = false; p[1] = false;
	for(int i=2; i<p.length; i++){
	    for(int j=i+i; j<p.length; j+=i){
		if(p[i]) p[j] = false;
	    }
	}
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void normal(string s,ll req,ll temp)
{
    if(req==0)
    {
        cout<<s<<endl;
        return;
    }
    for(ll i=0;i<=temp;i++)
    {
        char ch='a'+(int)i;
        string s1=s;
        s+=ch;
        ll maxi='a';
        for(ll i=0;i<s.length();i++)
        {
            if(s[i]>maxi)
                maxi=s[i];
        }
        normal(s,req-1,maxi-'a'+1);
        s=s1;
    }
}
int main() 
{
    ll n;
    cin>>n;
    string s="a";
    normal(s,n-1,1);
}

Measured memory_bytes: 1536
givenSeq = input()
list1=list(givenSeq)

index=0
while index < len(list1):
    if list1[index] == "B":
        if index!=0:
            del list1[index]
            del list1[index-1]
        else:
            del list1[index]
        index-=1
    else:
        index+=1
print("".join(list1))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args) throws IOException {
		StringBuilder sb = new StringBuilder();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		DecimalFormat df = new DecimalFormat("0.000");
		String line;
		while ((line = br.readLine()) != null) {
			String[] tmp = line.split(" ");
			double[] values = toDoubleArray(tmp);
			double x = (values[2] * values[4] - values[1] * values[5]) / (values[0] * values[4] - values[1] * values[3]);
			double y = (values[2] * values[3] - values[0] * values[5]) / (values[1] * values[3] - values[0] * values[4]);

			x = new BigDecimal(x).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
			y = new BigDecimal(y).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
			sb.append(df.format(x)).append(" ").append(df.format(y)).append("\n");
		}

		System.out.print(sb.toString());
	}

	public static double[] toDoubleArray(String[] lines) {
		double[] doubles = new double[lines.length];
		for (int i = 0; i < lines.length; i++) {
			doubles[i] = Double.parseDouble(lines[i]);
		}
		return doubles;
	}
}

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

using namespace std;

int main()
{
  int x, y; cin >> x >> y;
  for(int i = 0; i <= 50; i++)
  {
    int n = y - i*2;
    if(n%4 == 0 and n/4+i == x)
      return !(cout << "Yes" << endl);
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main() {
  int i, k, n, m, cnt, data[100], data2[100][100], data3[100] = {0};
  scanf("%d %d", &n, &m);
  for(i = 0; i < m; i++) {
    scanf("%d", &data[i]);
  }
  for(i = 0; i < m; i++) {
    for(k = 0; k < n; k ++) {
      scanf("%d", &data2[i][k]);
    }
  }
  for(i = 0; i < m; i++) {
    cnt = 0;
    for(k = 0; k < n; k++) {
      if(data[i] == data2[i][k]) {
        data3[k]++;
        if(k == 1) {
        }
      }else{
        data3[data[i] - 1]++;
      }
    }
  }
  for(i = 0; i < n ; i++) {
    printf("%d\n",data3[i]);
  }
  return 0;
}
  

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int N;
    cin >> N;
    char table[5] = {'M','A','R','C','H'};
    unsigned long long charcount[5] = {0,0,0,0,0};
    string s;

    //頭文字
    for(int i=0;i<N;i++){
        cin >> s;
        for(int j=0;j<5;j++){
            if(s[0] == table[j])
                charcount[j]++;
        }
    }

    unsigned long long answer = 0;   
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                answer += charcount[i]*charcount[j]*charcount[k];
            }
        }
        
    }
    cout << answer << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n,k;cin >> n >> k;
	int arr[n];
	int dp[n];
	for(int i = 0;i<n;i++)cin >> arr[i];
	
	dp[0] = 0;
	
	for(int i = 1;i<n;i++){
		int ans = INT_MAX;
		for(int j = i-1;j >= max(0,i-k);j--){
			ans = min(ans,dp[j]+abs(arr[i]-arr[j]));
		}
		dp[i] = ans;
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

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

	int arr[3];
	for(int i=0;i<3;i++)
		cin>>arr[i];
		
	sort(arr,arr+3);
	if(arr[0]+arr[1] == arr[2]){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

//define counter class
class Counter{
    int cnt;
public:
    Counter():cnt(0){}
    int show(){return cnt;}
    void up(){cnt++;}
    void down(){cnt--;}
};
long long cnt;
vector<int> G;

//define insertion sort
void insertsort(int* A, int n, int g){
    for(int i=g;i<n;++i){
        int v=A[i];
        int j=i-g;
        while(j>=0 && A[j]>v){
            A[j+g]=A[j];
            j-=g;
            ++cnt;
        }
        A[j+g]=v;
    }
}

void shellsort(int* A,int n){
    for(int h=1;;){
        if(h>n) break;
        G.push_back(h);
        h=3*h+1;
    }
    for(int i=G.size()-1;i>=0;--i){
        insertsort(A,n,G[i]);
    }
    cout<<G.size()<<"\n";
    for(int i=G.size()-1;i>=0;--i){
        cout<<G[i];
        if(i) cout<<" ";
    }
    cout<<"\n";
    cout<<cnt<<"\n";
    for(int i=0;i<n;++i){
        cout<<A[i]<<"\n";
    }
}

int main(){
    int n;
    cin>>n;
    int* array=new int[n];
    for(int i=0;i<n;++i){cin>>array[i];}
    cnt=0;
    shellsort(array,n);
    delete[] array;
}

Measured memory_bytes: 6656
#入力
lst = input().split()

A = int(lst[0])
B = int(lst[1])

#判定
if A == 1 or B == 1:
   if A == B == 1:
      result = 'Draw'
   elif A == 1:
      result = 'Alice'
   elif B == 1:
      result = 'Bob'
else:
   if A == B:
      result = 'Draw'
   elif A < B:
      result = 'Bob'
   elif A > B:
      result = 'Alice'

#出力
print(result)

Measured memory_bytes: 9088
n, m = map(int, input().split())
list_a = []
for i in range(n):
  list_a.append(input())
list_b = []
for i in range(m):
  list_b.append(input())

for i in range(n - m + 1):
  for j in range(n - m + 1):
    temp = 0
    for k, one_b in enumerate(list_b):
      if one_b == list_a[j+k][i:(i+m)]:
        temp += 1
      else:
        break
    if temp == m:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
char a[10010];//字符数组 
bool c, f;//标志变量 
int main() {
    scanf("%s", a);//读入字符串 
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;//找到C后标记 
        if(a[i]=='F'&&c==true) f=true;//在找到C后再找到F时标记 
    }
    if(f==true) printf("Yes\n");//如果找到C和F输出Yes 
    else printf("No\n");//否则输出No 
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> hen;
    map<ll, ll> mp;

    for(auto v : a) {
        mp[v]++;
        if(mp[v] == 2) {
            hen.push_back(v);
            mp[v] = 0;
        }
    }
    sort(hen.rbegin(), hen.rend());
    cout << (hen.size() < 2 ? 0 : hen[0] * hen[1]) << endl;
    return 0;
}


Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main(){
  int a,b,i;string s;
  cin>>a>>b>>s;
  for(i=0; i<a; i++){
    if(s[i]<'0' || '9'<s[i]){
      cout<<"No"; return 0;
    }
  }
  if(s[i++]!='-'){ cout<<"No"; return 0; }
  for(; i<=a+b; i++){
    if(s[i]<'0' || '9'<s[i]){
      cout<<"No"; return 0;
    }
  }
  cout<<"Yes"; return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
L = [1] * n
P_num = [1] * n

for i in range(n-1):
  L[i + 1] = L[i] * 2 + 3
  P_num[i + 1] = P_num[i] * 2 + 1

def pati_num(n, x):
  if n == 0:
    if x >= 1:
      return 1
    else:
      return 0
  elif x <= 1 + L[n-1]:
    return pati_num(n-1, x-1)
  else:
    return P_num[n-1] + 1 + pati_num(n-1, x-2-L[n-1])
print(pati_num(n, x))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define long long long
using namespace std;
long n,m;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n>>m;

  if(n==1&&m==1)
  {
    cout<<1<<endl;
    return 0;
  }
  if(n==2||m==2)
  {
    cout<<0<<endl;
    return 0;
  }
  if(n==1||m==1)
  {
    cout<<max(n,m)-2<<endl;
    return 0;
  }
  cout<<(n-2)*(m-2)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
class UnionFindTree
{
private:
   int N;
   int *rootnum;
   int *rank;
   int *unionnum;

public:
   UnionFindTree(int n)
   {
      /*0からn-1までの要素をunionとしてもつ*/
      N = n;
      rootnum = new int[N];
      rank = new int[N];
      unionnum = new int[N];
      for (int i = 0; i < N; i++)
      {
         rootnum[i] = i;
         rank[i] = 0;
         unionnum[i] = 1;
      }
   }

   int Find(int j)
   {
      if (rootnum[j] == j)
      {
         return j;
      }
      else
      {
         return rootnum[j] = Find(rootnum[j]);
      }
   }

   void Union(int i, int j)
   {
      int x = Find(i);
      int y = Find(j);
      if (x == y)
         return;
      N--;
      if (rank[x] < rank[y])
      {
         rootnum[y] = x;
         unionnum[x] += unionnum[y];
      }
      else
      {
         rootnum[x] = y;
         unionnum[y] += unionnum[x];
         if (rank[x] == rank[y])
            rank[x]++;
      }
   }

   int Num(int j)
   {
      /*与えられた要素の入っている集合の要素数を答える*/
      int x = Find(j);
      return unionnum[x];
   }

   int UnionNum()
   {
      /*集合の数を答える*/
      return N;
   }

   ~UnionFindTree()
   {
      delete rootnum;
      delete rank;
      delete unionnum;
   }
};

int main()
{
   int N, M;
   cin >> N >> M;
   UnionFindTree uft(N);
   for (int i = 0; i < M; i++)
   {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      uft.Union(a, b);
   }
   int ans = 0;
   for (int i = 0; i < N; i++)
   {
      ans = max(ans, uft.Num(i));
   }
   cout << ans << endl;
   return 0;
}


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

int main() {
    int N;
    int A[110];

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

    sort(A, A + N);

    int ans = (A[N-1] - A[0]);

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

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

ll calc(char c, string s) {
  ll cnt = 0, amari = 0;
  while (1) {
    bool flag = 0;
    REP(i, (signed)s.size())
    s[i] == c &&i != 0 && s[i - 1] != c && (s[i - 1] = c) && (flag = 1);
    if (!flag)
      break;
    cnt++;
  }
  for (auto &a : s)
    a != c &&amari++;
  return max(cnt, amari);
}

int main() {
  string s;
  cin >> s;
  ll mini = 1LL << 30;
  for (char i = 'a'; i <= 'z'; i++)
    mini = min(mini, calc(i, s));
  printf("%lld\n", mini);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    
    int N;
    cin >> N;
    set<pair<int, int>> AB;
    for (int i = 0; i < N; i++) {
        pair<int, int>p;
        cin >> p.first >> p.second;
        AB.insert(p);
    }
    
    set<pair<int, int>> CD;
    for (int i = 0; i < N; i++) {
        pair<int, int>p;
        cin >> p.first >> p.second;
        CD.insert(p);
    }

    int ans = 0;
    for (auto i : CD) {
        int sum1 = -1;
        int sum2 = -1;
        for (auto j : AB) {
            if (i.second > j.second && i.first > j.first) {
                if (sum2 < j.second) {
                    sum1 = j.first;
                    sum2 = j.second;
                }
            }
        }
        if (sum1 != -1 && sum2 != -1) {
            AB.erase(pair<int, int>(sum1, sum2));
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256