akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class ARightTriangle {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c;
	    in >> a >> b >> c;
	    out << a*b/2 << endl;
	}
};


int main() {
	ARightTriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N = int ( input().strip() ) ;

L = [ 'AC', 'WA', 'TLE', 'RE' ] ;
dic = {} ; 
for x in L : 
	dic[x] = 0 ;

for x in range ( N ) :
	r =  input().strip() ;
	dic[r] += 1 ; 

for x in L :
	print ( "{0} x {1}".format( x  , dic[x] ) ) ;

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >


ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
	ll l, r, d, c = 0;
	cin>>l>>r>>d;
	for(ll i = l; i <= r; i++)
	{
	    if(i % d == 0)
	        c++;
	}
	cout<<c;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();		
	}
	return 0;
}

ll mulmod(ll a, ll b)
{
	ll res = 0; 
	a = a % MOD;
	while(b > 0)
	{
		if (b % 2 == 1)
			res = (res + a) % MOD;
 
		a = (a * 2) % MOD; 
		b /= 2;
	} 
	return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a = (a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2; i * i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
	ll res;
	res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
	return res;
}

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

int parent(int i){
    return i/2;
}   

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}    

int main(){
    int H;
    cin >> H;
    int A[H+1];
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1)  cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H)    cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H)    cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3084
n = int(input())
s = []
for i in range(n):
    j = input()
    s.append(j)
m = int(input())
t = []
for k in range(m):
    h = input()
    t.append(h)
couS=[]
for i in range(n):
    count=0
    count+=s.count(s[i])
    count-=t.count(s[i])
    couS.append(count)
    
if max(couS)<0:
    print(0)
else:
    print(max(couS))

Measured memory_bytes: 3064
N = gets.to_i
a = gets.chomp.split.map(&:to_i)

cnt = 0

a.each.with_index do |n, i|
  if n == i + 1
    a[i], a[i + 1] = a[i + 1], a[i]
    cnt += 1
  end
end

puts cnt

Measured memory_bytes: 8708
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second

using namespace std;

const int N = 702;
int n, m, vis[N], cnt[N][3], cmpcnt, dp[N][N], mat[N][N], mn=1e6;
vector<int> g[N];
bool ret=true;
void dfs(int u, int col)
{
	//cout << u << " - " << col << endl;
	cnt[cmpcnt][col]++;
	vis[u]=col;
	for(auto v: g[u])
	{
		if(vis[v]==col)
		{
		//	cout << v << endl;
			ret=false;
		}
		else if(!vis[v]) dfs(v, 3-col);
	}
}
int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		mat[x][y]=mat[y][x]=1;
	}	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(!mat[i][j] && i!=j) g[i].pb(j);
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
		{	
			cmpcnt++;
			cnt[cmpcnt][1]=0;
			cnt[cmpcnt][2]=0;
			dfs(i, 1);
		}
	}
	if(!ret)
	{
		cout << -1;
		return 0;
	}
	dp[0][0]=1;
	for(int i = 1; i <= cmpcnt; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			dp[i][j]|=dp[i-1][j-cnt[i][1]];
			dp[i][j]|=dp[i-1][j-cnt[i][2]];
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(dp[cmpcnt][i])
		{
			int curr = (i*(i-1))/2 + ((n-i)*(n-i-1))/2;
			mn = min(mn, curr);
		}
	}	
	cout << mn;
}


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

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	ll ans = 1;
	int i = 0;
	const ll MOD = 1e9+7;
	if(s[0]==t[0])i=0,ans = 3;
	else i = 1,ans = 6; 
	for(;i<n-1;i++)
	{
		if(s[i]==t[i])
		{
			if(s[i+1]==t[i+1])
			{
				ans = ans * 2 %MOD;
			}
			else
			{
				ans = ans * 2 % MOD;
				i++;
			}
		}
		else
		{
			if(s[i+1]==t[i+1])
			{
			}
			else
			{
				ans = ans * 3 % MOD;
				i ++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> a(N);
  int cnt = 0;
  int n = 1;
  
  for(int i = 0; i < N; ++i){
    cin >> a.at(i);
    if(n == a.at(i)) n++;
    else cnt++;
  }
  
  if(n == 1) cout << -1 << endl;
  else cout << cnt << endl;
  
}

Measured memory_bytes: 1024
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAX   150002
#define X first
#define Y second
#define MOD 1000000007
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll t,n,i,j;
int main()
{
    fastio;
    ll a;
    string s;
    cin>>a>>s;
    if(a<3200)
        cout<<"red"<<endl;
    else
        cout<<s<<endl;
}


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

int main() {
  string S[100];
  int H, W;

  cin >> H >> W;
  for (int i = 0; i < H; i++) cin >> S[i];

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

  return 0;
}


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

int main(){
    int n;
    while(cin>>n && n!=0){
        vector<string> a(n);
        rep(i,n)cin >> a[i];
        vector<int> p(n);
        rep(i,n){
            int k = 0;
            for(int j=0;j<a[i].size();j++){
                if(a[i][j]=='.')k++;
            }
            p[i] = k;
        }
        for(int i=1;i<n;i++){
            int k = p[i];
            int nxt = -1;
            for(int x =i;x<n;x++){
                if(p[x]>k)continue;
                if(p[x]==k){
                    nxt = x;
                }
                if(p[x]<k)break;
            }
            a[i][k-1] = '+';
            if(nxt!=-1){
                
                for(int j=i+1;j<nxt;j++){
                    a[j][k-1] = '|';
                }
            }
        }
        rep(i,n){
            rep(j,a[i].size()){
                if(a[i][j]=='.')a[i][j] = ' ';
            }
        }
        rep(i,n){
            cout << a[i] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3804
s = input()
ans = [1] * len(s)
for i in range(len(s)-2):
    if s[i] == 'R' and s[i+1] == 'R':
        ans[i+2] += ans[i]
        ans[i] = 0
for i in range(len(s)-1, 1, -1):
    if s[i] == 'L' and s[i-1] == 'L':
        ans[i-2] += ans[i]
        ans[i] = 0
for i in ans:
    print(i ,end=" ")


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define maxn 205
#define inf 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
bool vis[10];
int d[maxn][maxn];
int r[10];
int n,m,k;
int res;
void dfs(int x,int last,int dis){
	if(x==k+1){
		res=min(res,dis);
		return;
	}
	for(int i=1;i<=k;i++){
		if(vis[i]) continue;
		vis[i]=true;
		if(last==-1) dfs(x+1,i,0);
		else dfs(x+1,i,dis+d[r[last]][r[i]]);
		vis[i]=false;
	}
}
int main(){
//	freopen("input.txt","r",stdin);
	scanf("%d%d%d",&n,&m,&k);
	mm(d,0),mm(vis,0);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i!=j) d[i][j]=inf;
		}
	}
	for(int i=1;i<=k;i++) scanf("%d",&r[i]);
	for(int i=1;i<=m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		if(w<d[u][v]) d[u][v]=d[v][u]=w;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
	res=inf;
	dfs(1,-1,0);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;
int answer=std::numeric_limits<int>::max();
int N, K;

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

    for(int i=0; i<=N-K; i++){
        int l2r = abs(X[i]) + abs(X[i]-X[i+K-1]);
        int r2l = abs(X[i+K-1]) + abs(X[i]-X[i+K-1]);
        answer = min(answer, min(l2r, r2l));
    }

    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    BigInteger[] irons = new BigInteger[len];
    BigInteger sum = new BigInteger("0");
    for (int i = 0; i < irons.length; i++) {
      irons[i] = new BigInteger(sc.next());
      sum = sum.add(irons[i]);
    }

    BigInteger half = sum.divide(new BigInteger("2"));
    BigInteger cur = new BigInteger("0");
    for (int i = 0; i < irons.length; i++) {
      if (cur.add(irons[i]).compareTo(half) != 1) cur = cur.add(irons[i]);
      else {
        BigInteger out1 = sum.subtract(cur.multiply(new BigInteger("2")));
        //System.out.println(cur);
        cur = sum.subtract(cur.add(irons[i]));
        //System.out.println(cur);
        BigInteger out2 = sum.subtract(cur.multiply(new BigInteger("2")));
        System.out.println(out1.min(out2));
        return;
      }
    }
  }
}


Measured memory_bytes: 75528
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n;
    long long ans=0;
    cin >> n;
    vector<int>profit(n,0);
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        profit[i]+=x;
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        profit[i]-=x;
    }
    for(auto now : profit){
        if(now > 0)ans+=now;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	ll a, b, c, d, e;
	while(true) {
		cin >> a >> b >> c >> d >> e;

		if(a == 0 && b == 0 && c == 0 && d == 0 && e == 0) break;

		ll na, nb, nc;
		cin >> na >> nb >> nc;

		vector<ll> v;
		rep(i, na) v.push_back(a);
		rep(i, nb) v.push_back(b);
		rep(i, nc) v.push_back(c);

		sort(v.begin(), v.end(), greater<ll>());

		ll sum = a * na + b * nb + c * nc;
		ll ans = sum, pre = 0;

		rep(i, v.size()) {
			pre += v[i];
			sum -= v[i];
			if(i >= d-1) {
				ans = min(ans, sum + min(pre, (i + 1) * e));
			} else {
				ans = min(ans, sum + min(pre, d * e));
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 8656
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int):
    ret = max(A + B, A - B, A * B)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int A,B,before,temp,after,ans=0;
    cin>>A>>B;

    for(int i=A;i<=B;i++){

        before = i;
        temp = before;
        after = 0;

        while(1){
            after*=10;
            int x =temp%10;
            after+=x;
            temp/=10;

            if(temp<1)break;
        }

        if(before==after)ans++;
    }

    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[2][n],i,j,s,m,x,temp,sum;
    for(i=0;i<2;i++)
    {
        for(j=0;j<n;j++)
            scanf("%d",&a[i][j]);
    }
    i=0;j=0;s=a[i][j];
    while(i<2&&j<n)
    {

        if(i==0)
        {
            if(j!=n-1)
            {
                if(a[i][j+1]>=a[i+1][j])
                    j++;
                else
                    i++;
            }
            else
                i++;
            if(i==1)
            {
                for(m=j+1,x=j,temp=0,sum=0;m<n&&x<n;m++,x++)
                {
                    temp=temp+a[0][m];
                    sum=sum+a[1][x];
                    if(temp>sum)
                    {
                        i--;
                        j++;
                        break;
                    }
                }

            }
        }
        else
            j++;
        if(i<2&&j<n)
            s=s+a[i][j];
    }
    printf("%d\n",s);
    return 0;
}


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

#define print(x) cout << x << '\n';
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;

ll k, n, w, x, y, z, a, b, c, l, m, d;
ll xx = 0, yy = 0, zz = 0, sum = 0, temp = 0;
string ss;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    cin >> ss;
    int nn = ss.size();

    fr(i, 0, ss.size()){
        if(ss[i] == '1') cout << '9';
        else cout << '1';
    }

    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 rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin >> s;

	if(s == "Sunny"){
		cout << "Cloudy" << endl;
	}else
	if(s == "Cloudy"){
		cout << "Rainy" << endl;
	}else
	if(s == "Rainy"){
		cout << "Sunny" << endl;
	}


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K,R,S,P;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  vector<bool>t(N,false);
  for(int i=0;i<K;i++){
  t[i]=true;
  }int sum=0;
  for(int i=0;i<K;i++)
    if(T[i]=='r')
      sum+=P;
  else if(T[i]=='s')
    sum+=R;
  else
    sum+=S;
  map<char,int>M; M['s']=R; M['p']=S; M['r']=P;
  for(int i=K;i<N;i++){
  if(T.at(i)==T.at(i-K)){
   if(!t[i-K]){sum+=M.at(T.at(i)); t[i]=true;}
  }else{
  sum+=M.at(T.at(i)); t[i]=true;
  
  }
    
  
  }cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int limit = s.length() - 1;
        long ans = 0;
        for (int bit = 0; bit < (1 << limit); bit++) {
            StringBuilder sb = new StringBuilder();
            long sum = 0;
            for (int i = 0; i < s.length(); i++) {
                sb.append(s.charAt(i));
                if ((bit & (1 << i)) != 0) {
                    sum += Long.parseLong(sb.toString());
                    sb.setLength(0);
                }
            }
            if (sb.length() != 0) {
                sum += Long.parseLong(sb.toString());
            }
            ans += sum;
        }
        System.out.println(ans);

    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 21716
#include<stdio.h>

int main(void)
{
  int a,b,seki;

  scanf("%d",&a);
  scanf("%d",&b);

  seki = a * b;

  if(seki % 2 == 0){
    printf("Even");
  }
  else{
    printf("Odd");
  }

  return 0;

}


Measured memory_bytes: 128
#include <stdio.h>

int H, W;
char C[128][128];

int main(void) {
	int i;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%127s", C[i]) != 1) return 1;
	}
	for (i = 0; i < H; i++) {
		puts(C[i]);
		puts(C[i]);
	}
	return 0;
}


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

int main() {
  string a, b;
  cin >> a >> b;
  string S = a + b;
  int x = 0;
  for (int i = 0; i < S.length(); i++) {
    x = 10 * x + (S[i] - '0');
  }
  for (int i = 0; i < 11111; i++) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
N = int(input())
S = input() + "_"
T = input() + "_"
D = []
i = 0
while i < N:
    if S[i] == S[i+1]:
        D.append(2)
        i += 1
    else:
        D.append(1)
    i += 1

if D[0] == 1:
    ans = 3
else:
    ans = 6
for k in range(1,len(D)):
    if D[k-1] == 1 and D[k] == 2:
        ans *= 2
    elif D[k-1] == 2 and D[k] == 1:
        ans *= 1
    elif D[k-1] == 1 and D[k] == 1:
        ans *= 2
    else:
        ans *= 3
    ans %= MOD
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int N, M;
	cin >> N >> M;

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

	//calculation
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	//output
	int temp = 4 * M * A[M - 1];
	if (temp < sum) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 

long table[2][1000000]={};
int main()
{
    long K;
    std::cin >> K;
    long count=0;
    long r=1;
    long element_num=9;
    long result=0;
    for(long i=0; i<9; i++){
        table[0][i]=i+1;
        count++;
        if(K==count){
            result=table[0][i];
            break;
        }
    }
    while(count<K){
        long element=0;
        long lsb;
        long keta_num=0;
        long s;
        if(r==1){
            s=0;
        }else{
            s=1;
        }
        for(long i=0; i<element_num; i++){
            lsb=table[s][i]%10;
            if(lsb!=0 && lsb!=9){
                table[r][keta_num]=table[s][i]*10+(lsb-1);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }

                table[r][keta_num]=table[s][i]*10+(lsb);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }

                table[r][keta_num]=table[s][i]*10+(lsb+1);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }

            }else if(lsb==0){
                table[r][keta_num]=table[s][i]*10+(lsb);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }
                table[r][keta_num]=table[s][i]*10+(lsb+1);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }
            }else{
                table[r][keta_num]=table[s][i]*10+(lsb-1);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }
                table[r][keta_num]=table[s][i]*10+(lsb);
                count++;
                keta_num++;
                if(K==count){
                    result=table[r][keta_num-1];
                    break;
                }
            }
        }
        element_num=keta_num;
        if(r==1){
            r=0;
        }else{
            r=1;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 2688
def count(n):
    c = 0
    while True:
        if n % 2 == 1:
            break
        n /= 2
        c += 1
    return c

s = 0
n = int(input())
l = list(map(int, input().split()))
for a in l:
    s += count(a)
print(s)

Measured memory_bytes: 4148
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#define int long long
using namespace std;

priority_queue<int, vector<int>, greater<int> > que;
priority_queue<int> que2;

int n;
int a[300000];
int mae[300000];
int usiro[300000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < 3 * n; i++) cin >> a[i];
	
	int ssum = 0;
	for (i = 0; i < 3 * n; i++) {
		que.push(a[i]);
		ssum += a[i];
		if (que.size() > n) {
			ssum -= que.top();
			que.pop();
		}
		mae[i] = ssum;
	}
	
	ssum = 0;
	for (i = 3 * n - 1; i >= 0; i--) {
		que2.push(a[i]);
		ssum += a[i];
		if (que2.size() > n) {
			ssum -= que2.top();
			que2.pop();
		}
		usiro[i] = ssum;
	}
	
	//デバッグ
	//for (i = 0; i < 3 * n; i++) cout << mae[i] << " " << usiro[i] << endl;
	
	//区切りを全探索 [0, i), [i, 3 * n)
	int ans = -1e+16;
	for (i = n; i <= 2 * n; i++) {
		ans = max(ans, mae[i-1] - usiro[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8948
n = int(input())
lst = list(map(int,input().split()))
ans = 0
for i in range(n - 1):
    if (lst[i] > lst[i + 1]):
        lst[i + 1] = lst[i + 1] + 1
    if (lst[i] > lst[i + 1]):
        ans = 1

if(ans == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20748
#include <cstdio>
#define MAX_N (10010)
#define MAX_Q (510)
int n;
int q;
int S[MAX_N+1];
int T[MAX_Q];

int linear_search(int d)
{
    int i = 0;
    while ( true ) {
	if (S[i] == d ) break;
	i++;
    }
    return i;
}

int main()
{
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    int ans = 0;
    for ( int i = 0; i < q; i++ ) {
	scanf("%d", &T[i]);
	S[n] = T[i];
	int index = linear_search(T[i]);
	if ( index < n ) ans++;
    }

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

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

using namespace std;


int main()
{
	int n, k; cin >> n >> k;
	int arr[n];
	for(int &x : arr) cin >> x;
	vector<int> dp(n);
	for(int i = 0; i < n; i++) dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i-j >= 0){
				dp[i] = min(dp[i], dp[i-j]+abs(arr[i]-arr[i-j]));
			}
		}
	}
	cout << dp[n-1];
}


Measured memory_bytes: 4044
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

bool isPrime[60000];
vector<int> primes;

void sieve() {
    isPrime[2] = true;
    primes.push_back(2);
    for (int i = 3; i <= 59999; ++i) {
        bool isP = true;
        for (int prime:primes) {
            if (i % prime == 0) {
                isP = false;
                break;
            }
        }
        if (isP) {
            isPrime[i] = true;
            primes.push_back(i);
        }
    }
}

signed main() {
    sieve();
    int N;
    cin >> N;
    int cnt = 0;
    int num = 11;
    while (cnt < N) {
        if (isPrime[num]) {
            cout << (cnt ? " " : "") << num;
            cnt++;
        }
        num += 10;
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
long long dp[101][2];

int main() {
	long long N, K;
	cin >> N >> K;
	vector<long long>A(N);
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
	}
	for (int n = 0; n < 101; ++n) {
		dp[n][0] = dp[n][1] = -1;
	}
	dp[0][0] = 0;
	for (int n = 0; n < 40; ++n) {
		long long mask = 1LL << (39 - n);
		long long count = 0;
		for (int i = 0; i < N; ++i) {
			if (A[i] & mask) {
				count++;
			}
		}
		if (dp[n][1] >= 0) {
			dp[n + 1][1] = max(dp[n + 1][1], dp[n][1] + mask * max(count, N - count));
		}
		if (dp[n][0] >= 0) {
			if (K&mask) {
				dp[n + 1][1] = max(dp[n + 1][1], dp[n][0] + mask * count);
				dp[n + 1][0] = max(dp[n + 1][0], dp[n][0] + mask * (N - count));
			}
			else {
				dp[n + 1][0] = max(dp[n + 1][0], dp[n][0] + mask * count);
			}
		}

	}
	cout << max(dp[40][0], dp[40][1]) << endl;
	return 0;
}


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

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

void trace(int a[], int n){
    REP(i, n) {
        if (i>0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void BubbleSort(int a[], int n) {
    int cnt = 0;
    REP(i, n) {
        RFOR(j, i+1, n) {
            if (a[j] < a[j-1]) {
                cnt++;
                swap(a[j], a[j-1]);
            }
        }
    }
    trace(a, n);
    cout << cnt << endl;
}

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

    int a[100];
    REP(i, n) {
        cin >> a[i];
    }

    BubbleSort(a, n);
    return 0;
}

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

using namespace std;
typedef long long ll;
int n;
int arr[200005];
int main()
{
    ios_base::sync_with_stdio(false);
   cin >> n;
    ll ret=0;
   for(int i=0;i<n;i++){
    cin>>arr[i];
    ret += arr[i];
   }
   int tmp=0;
cout<< ret-n<<endl;

    return 0;
}


Measured memory_bytes: 256
import copy
S = list(input())
s = copy.copy(S)

for i in range(9):
    s = copy.copy(S)
    for j in range(3):
        if (i >> j) & 1 :
            s.insert(3-j,"+")
        else:
            s.insert(3-j,"-")

        tmp = "".join(s)

    if eval(tmp) == 7 :
        for k in s:
            print(k,end="")
        else:
            print("=7")
            quit()


Measured memory_bytes: 3444
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        
        COMinit();
        
        // ans: f(x) = max(x) - min(x) の和
        long ans = 0;
        
        // 4 2
        // 1 1 3 4
        // min: a[0]*3c1 a[1]*2c1 a[2]*1c1
        // max: a[3]*3c1 a[2]*2c1 a[1]*1c1
        
        // 8 3
        // 1 1 2 3 4 5 6 6
        // min: a[0]*7c2 a[1]*6c2 ... a[5]*2c2
        // max: a[7]*7c2 a[6]*6c2 ... a[2]*2c2
        
        
        // max
        for (int i = n-1; i >= k-1; i--) {
            ans += array[i] * nCkMOD(i, k-1);
            ans %= MOD;
        }
        
        // min
        for (int i = 0; i <= n - k; i++) {
            ans -= array[i] * nCkMOD(n-1-i, k-1);
            ans %= MOD;
        }
        
        if (ans < 0) ans += MOD;
        System.out.println(ans);
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    // nCk = n! / (k! * (n-k)!)
    public static long nCkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    // 順列計算
    // nPk = n! / (n-k)!
    public static long nPkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return (fac[n] * finv[n - k]) % MOD;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}

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

Measured memory_bytes: 580
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

bool chsK(string s) {
	int n = s.length();
	if (n % 2 == 0) {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	else {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	return true;
}

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}




int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')a[i] = 1;
	}
	int t = 0;
	int count = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] == 1)count++;
		else count = 0;
		if (t < count)t = count;
	}
	cout << t << endl;
	return 0;
}

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

int main()
{
	int a,b,c,d,e,f,g,h,i,j,k;
	cin >> a; 
	cin >> b; 
	cin >> c; 
	cin >> d; 
	cin >> e; 
	cin >> f; 
	cin >> g; 
	cin >> h; 
	cin >> i; 
	cin >> j;
	k = a+b+c+d+e+f+g+h+i+j;
	cout << k << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int solve(int N, int M)
{
  vector<int> C(M), x(N);
  rep(i, M)
  {
    cin >> C[i];
  }
  rep(i, N)
  {
    cin >> x[i];
  }
  vector<vector<int>> dp(N + 1, vector<int>(256, INT32_MAX));
  dp[0][128] = 0;
  rep(i, N) rep(j, 256)
  {
    if(dp[i][j] != INT32_MAX)
    {
      rep(k, M)
      {
        int nj = j + C[k];

        if(nj < 0)
          nj = 0;          

        if(nj > 255)
          nj = 255;
        int dist = pow(nj - x[i], 2);
        dp[i + 1][nj] = min(dp[i + 1][nj], dist + dp[i][j]);
      }
    }
  }
  int dst = INT32_MAX;
  rep(i, 256)
  {
    dst = min(dst, dp[N][i]);
  }
  return dst;
}

int main()
{
  while(true)
  {
    int N, M;
    cin >> N >> M;
    if(N != 0 || M != 0)
      cout << solve(N, M) << endl;
    else
      break;
  }
  return 0;
}


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

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var B = new int[N];

			var count = MergeSort(A, B, 0, N);
			System.Console.WriteLine(count);
		}

		static long MergeSort(int[] array, int[] work, int left, int right)
		{
			var n = right - left;
			var mid = (left + right) / 2;
			if (n <= 1)
			{
				return 0;
			}
			var c = 0L;
			c += MergeSort(array, work, left, mid);
			c += MergeSort(array, work, mid, right);
			c += Merge(array, work, left, right);
			return c;
		}

		static long Merge(int[] array, int[] work, int left, int right)
		{
			var n = right - left;
			var mid = (left + right) / 2;
			var li = 0;
			var ri = 0;
			var c = 0L;
			for (int i = 0; i < n; i++)
			{
				var lv = left + li < mid ? array[left + li] : int.MaxValue;
				var rv = mid + ri < right ? array[mid + ri] : int.MaxValue;
				if (lv < rv)
				{
					work[left + i] = lv;
					li++;
				}
				else
				{
					work[left + i] = rv;
					ri++;
					c += n / 2 - li;
				}
			}

			for (int i = 0; i < n; i++)
			{
				array[left + i] = work[left + i];
			}

			return c;
		}
	}
}



Measured memory_bytes: 36228
while True :
    try :
        a, b, c, d, e, f = [int(_) for _ in input().split()]
        y = (a * f - c * d) / (a * e - b * d)
        x = (c - b * y) / a
        print('{0:0.3f} {1:0.3f}'.format(x, y))
    except : break

Measured memory_bytes: 7500
import Control.Monad
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n, t] <- readInts
  cts <- replicateM n readInts
  putStrLn $ maybe "TLE" show $ solve t cts

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [[Int]] -> Maybe Int
solve t = listToMaybe . sort . map head . filter ((<= t) . last)

Measured memory_bytes: 1020
N, A, B, C = map(int, input().split())

LARGE = 10 ** 9 + 7


def p_inv(a):
    return pow(a, LARGE - 2, LARGE)


# not C 1 time
S = p_inv((1 - C * p_inv(100)) % LARGE)
#S = S * S % LARGE

# A / B
p = A * p_inv(A + B) % LARGE
q = B * p_inv(A + B) % LARGE

ncr_A_list = [0]*N
p0 = pow(p, N - 1, LARGE)
ncr_A_list[0] = p0
for i in range(1, N):
    p0 = (p0 * q * (N - 1 + i) * p_inv(i)) % LARGE
    ncr_A_list[i] = p0

ncr_B_list = [0]*N
q0 = pow(q, N - 1, LARGE)
ncr_B_list[0] = q0
for i in range(1, N):
    q0 = (q0 * p * (N - 1 + i) * p_inv(i)) % LARGE
    ncr_B_list[i] = q0

inv_C_list = [0]*N
r00 = ((A + B) * p_inv(100)) % LARGE
r0 = pow(r00, N, LARGE)
inv_C_list[0] = r0
for i in range(1, N):
    r0 = (r0 * r00) % LARGE
    inv_C_list[i] = r0

res = 0
#for i in range(N):
#    res += (((ncr_A_list[i] * p * inv_C_list[i]) % LARGE) * ((S * (N + i)) % LARGE)) % LARGE
#    res += (((ncr_B_list[i] * q * inv_C_list[i]) % LARGE) * ((S * (N + i)) % LARGE)) % LARGE
#    res = res % LARGE

for i in range(N):
    res += (((ncr_A_list[i] * p) % LARGE) * ((S * (N + i)) % LARGE)) % LARGE
    res += (((ncr_B_list[i] * q) % LARGE) * ((S * (N + i)) % LARGE)) % LARGE
    res = res % LARGE


print(res)


Measured memory_bytes: 61900
#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 Would
#define you
#define please


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

	
	int A, B, H;
	cin >> A >> B >> H;

	co((A + B) * H / 2);

	Would you please return 0;
}

Measured memory_bytes: 256
fn a() {
    input! {
        l : u32,
        r : u32,
        d : u32
    }
    let mut c = 0;
    for i in l..=r {
        if i % d == 0 {
            c +=1;
        }
    }

    println!("{}", c);
}

use proconio::{input, marker::Chars};

fn main() {
    a();
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A, B, C, D;
  cin >> A >> B >> C >>D;

  if ( A + B > C + D){
  cout << "Left" << endl;
  }
  else if ( A + B < C + D){
  cout << "Right" << endl;
  }
  else if ( A + B == C + D){
  cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,y,t;
    while(1){
        cin>>x>>y;
        if(x==0&&y==0)break;
        if(x>y){
            t=x;x=y;y=t;
        }cout<<x<<" "<<y<<endl;
    }return 0;
}


Measured memory_bytes: 2992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vector<ll> sum[40 / 2 + 1];

int main()
{
    ll N = lin(), K = lin(), L = lin(), R = lin();

    vector<ll> A(N);

    rep(i, N) {
        A[i] = lin();
    }

    int sz1 = N / 2;
    rep(bit, 1 << sz1) {
        int cnt = 0;
        ll s = 0;

        rep(i, sz1) {
            if (bit >> i & 1) {
                cnt++;
                s += A[i];
            }
        }

        sum[cnt].PB(s);
    }

    rep(i, sz1 + 1) sort(all(sum[i]));

    ll ans = 0;

    int sz2 = N - N / 2;
    rep(bit, 1 << sz2) {
        int cnt = 0;
        ll s = 0;

        rep(i, sz2) {
            if (bit >> i & 1) {
                cnt++;
                s += A[i + sz1];
            }
        }

        if (K - cnt < 0 || K - cnt > sz1) continue;

        int pos1 = upper_bound(all(sum[K - cnt]), R - s) - begin(sum[K - cnt]) - 1;
        int pos2 = lower_bound(all(sum[K - cnt]), L - s) - begin(sum[K - cnt]);

        if (pos1 < pos2) continue;

        ans += max(pos1 - pos2 + 1, 0);
    }

    printf("%lld\n", ans);
}

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

int main(){
    string c1,c2;
    cin >> c1 >> c2;
    bool flag = false;
    if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]){
        flag = true;
    }
    cout << (flag ? "YES" : "NO") << endl;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<N/2; i++){
    if(S[i]!=S[N/2+i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tuple<ll, ll> P;
typedef tuple<ll, ll, ll> P3;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<P> VP;
typedef vector<string> VS;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n"

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"\
  <<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n"

#define YES(x) cout<<((x)?"YES":"NO")<<"\n"
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n"
#define yes(x) cout<<((x)?"yes":"no")<<"\n"

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(x,y) (0<=(x)&&(x)<w&&0<=(y)&&(y)<h)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;

bool isPrime(ll x) {
	if(x==1) return 0;
	for(ll i=2;i*i<=x;i++) {
		if(x%i==0) return 0;
	}
	return 1;
}

	ll x[100005]={};
int main() {
	//#####//
	for(ll i=1;i<=100002;i+=2) {
		if(isPrime(i)&&isPrime((i+1)/2)) x[i] = 1;
	}
	REP(i,100003) x[i+1] += x[i];
	int q=ini;
	REP(i ,q) {
		ll a=inl, b=inl;
		cout << x[b] - (a>0 ? x[a-1]: 0) << endl;
	}
}

//


Measured memory_bytes: 1408
#include <stdio.h>

typedef struct{
    int parent;
    int depth;
    int l,r;
}Node;

Node node[100001];
int rec(int,int);

int main(){
    int n,k;
    int id,c,l,r,a;
    int i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        node[i].parent = node[i].l = node[i].r = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&id,&k);
        for(j=0;j<k;j++){
            scanf("%d",&c);
            if(j==0) node[id].l=c;
            else node[l].r = c;
            l=c;
            node[c].parent = id;
        }
    }
    for(i=0;i<n;i++) if(node[i].parent == -1) r=i;
    rec(r,0);

    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,node[i].depth);
        if(node[i].parent==-1)printf("root, ");
        else if(node[i].l!=-1) printf("internal node, ");
        else printf("leaf, ");
        printf("[");
        if(node[i].l!=-1){
            printf("%d",node[i].l);
            a = node[i].l;
            while(1){
                if(node[a].r == -1) break;
                else printf(", %d",node[a].r);
                a = node[a].r;
            }
        }
        printf("]\n");
    }
    return 0;
}

int rec(int r,int p){
    node[r].depth = p;
    if(node[r].r!=-1) rec(node[r].r,p);
    if(node[r].l!=-1) rec(node[r].l,p+1);
}




Measured memory_bytes: 6396
#include<stdio.h>
#include<limits.h>
#define WHITE 0
#define BLACK 2
#define GRAY 1

int pa[101];
int A[101][101];
int Cost[101];
int CL[101];
int NT[101];
int cnt;
int sum;
int n;
void MST(int);
int main(){
int i,j,x;    
 scanf("%d",&n);
 for(i=0;i<n;i++){
     for(j=0;j<n;j++){
         scanf("%d",&x);
         if(x==-1)
         A[i][j]=INT_MAX;
         else
         A[i][j]=x;
     }
 }
MST(0);
for(i=0;i<n;i++)
sum+=Cost[i];
printf("%d\n",sum);
return 0;

}
void MST(int x){
int i,mincost,u,j;
for(i=0;i<n;i++){
Cost[i]=INT_MAX;
pa[i]=-1;
CL[i]=WHITE;
}
cnt=0;
NT[cnt++]=x;
CL[x]=WHITE;
    Cost[x]=0;

  
   while(1){
       mincost=INT_MAX;
       for(i=0;i<n;i++){
           
           if(Cost[i]<mincost&&CL[i]!=BLACK){
               mincost=Cost[i];
               u=i;
           
           
           }
       }
       if(mincost==INT_MAX)
       break;
       CL[u]=BLACK;
 
           for(j=0;j<n;j++){
           if(CL[j]!=BLACK&&A[u][j]<Cost[j]){
               Cost[j]=A[u][j];
               pa[j]=u;
           }
           
       }
	   //for(i=0;i<n;i++)
	   //printf("%d %d\n",Cost[i],CL[i]);
   }
}



Measured memory_bytes: 2052