akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  if(s==t){
    cout<<"EQUAL";
  }else{
    if(s.size()<t.size()){
      cout<<"LESS";
    }else if(s.size()>t.size()){
      cout<<"GREATER";
    }else{
      for(int i=0;i<s.size();i++){
        if(s[i]<t[i]){
          cout<<"LESS";
          return 0;
        }else if(s[i]>t[i]){
          cout<<"GREATER";
          return 0;
        }
      }
    }
  }
}
        

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
TN = A // D 
Tmod = A % D
AN = C // B
Amod = C % B
if Tmod>0:
    TN+=1 # 青木くんに必要な攻撃回数
if Amod>0:
    AN+=1# 高橋くんに必要な攻撃回数
if AN<=TN:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#include <stdio.h>

int main(void){
	int ans=0;
	char s[4];
	scanf("%s",&s);
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
lint h,w;
lint ans = 100000000000;

int main(){
  cin >> h >> w;
  for(int i=0;i<=h;i++){
    lint a = i*w;
    lint b = (h-i)*((w)/2);
    lint c = (h-i)*((w+1)/2);
    lint k = max(abs(a-b),abs(b-c));
    k = max(k,abs(a-c));
    if(i==4700){
      //dump(h-i);
      //dump(((w)/2));
      //dump((h-i)*((w)/2));
      //dump(a);
      //dump(b);
      //dump(c);
    }
    if(k<ans){
      //dump(i);
      //dump(ans);
    }
    ans = min(k,ans);
  }
  //dump(ans);
  for(int i=0;i<=h;i++){
    lint a = i*w;
    lint b = (h-i+1)/2 * w;
    lint c = (h-i)/2 * w;
    lint k = max(abs(a-b),abs(b-c));
    k = max(k,abs(a-c));
    ans = min(k,ans);
  }

  lint now = h;
  h = w;
  w = now;
  for(int i=0;i<=h;i++){
    lint a = i*w;
    lint b = (h-i)*((w)/2);
    lint c = (h-i)*((w+1)/2);
    lint k = max(abs(a-b),abs(b-c));
    k = max(k,abs(a-c));
    ans = min(k,ans);
  }

  for(int i=0;i<=h;i++){
    lint a = i*w;
    lint b = (h-i+1)/2 * w;
    lint c = (h-i)/2 * w;
    lint k = max(abs(a-b),abs(b-c));
    k = max(k,abs(a-c));
    ans = min(k,ans);
  }

  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
#--import&define---------------------
import math
import sys
input = sys.stdin.readline
def yes():
    print("Yes")
def no():
    print("No")

#--以下解答---------------------------------
n = int(input())
H = list(map(int, input().split()))
ans = 1
flag = True

for i in range(1,n):
    flag = True
    for j in range(0,i):
        if H[i] < H[j]:
            flag = False
            break
    if flag == True:
        ans += 1
print(ans)

Measured memory_bytes: 3064
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nt = readn::<usize>(" ");
    let n = nt[0];
    let _t = nt[1];

    let a = readn::<usize>(" ");
    let mut ans = 1;
    let mut profit = 0;
    let mut mi = a[0];
    for i in 1..n {
        mi = std::cmp::min(mi, a[i]);
        if a[i] - mi == profit {
            ans += 1;
        } else if a[i] - mi > profit {
            ans = 1;
            profit = a[i] - mi;
        }
    }

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

Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
const int MAX = 500005;
int bit[MAX],arr[MAX];
struct Query
{
    int l, r, idx;
};
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}
void update(int idx,int val,int n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}
int query(int idx,int n)
{
    int sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int n, Query queries[], int q)
{
    fill(bit,bit+MAX,0);
    int last_visit[MAX];
    fill(last_visit,last_visit+MAX, -1);
    int ans[q];
    int query_counter = 0;
    for (int i=0; i<n; i++)
    {
        if (last_visit[arr[i]] !=-1)
            update (last_visit[arr[i]] + 1, -1, n);
        last_visit[arr[i]] = i;
        update(i + 1, 1, n);
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, n)-
                     query(queries[query_counter].l, n);
            query_counter++;
        }
    }
    for (int i=0; i<q; i++)
        cout << ans[i] << endl;
}
int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++) cin>>arr[i];
    Query queries[q];
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        queries[i].l=x;
        queries[i].r=y;
        queries[i].idx=i;
    }
    sort(queries, queries+q, cmp);
    answeringQueries(n, queries, q);
    return 0;
}


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

vector<int> graph[200000];
long long cnt[200000];
long long ans[200000];

void dfs(int cur, int parent, long long tmp_cnt) {
  ans[cur] = tmp_cnt + cnt[cur];
  for (int to: graph[cur]) {
    if (to == parent) {
      continue;
    }
    dfs(to, cur, ans[cur]);
  }
}
int main() {
  int n, q;
  cin>>n>>q;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i=0; i<200000; i++) {
    cnt[i] = 0;
    ans[i] = 0;
  }
  for (int i=0; i<q; i++) {
    int p, x;
    cin>>p>>x;
    --p;
    cnt[p] += x;
  }
  dfs(0, -1, 0);
  cout<<ans[0];
  for (int i=1; i<n; i++) {
    cout<<" "<<ans[i];
  }
  cout<<endl;
}

Measured memory_bytes: 25856
/*
AizuOnline A0000
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
char roman[]="IVXLCDM";
int values[]={1,5,10,50,100,500,1000};
char s[101];

//
int romanc2num(char c)
{ return(values[strchr(roman,c)-roman]);
}

main()
{
  int i,prev,sum,v;

  while(EOF!=scanf("%s",s))
    {
      prev=10000;sum=0;
      for(i=0;s[i];i++)
	{
	  v=romanc2num(s[i]);
	  sum += v;
	  if(prev < v)
	    sum -= 2*prev;
	  prev=v;
	}

      printf("%d\n",sum);
    }

return(0);
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;
const int maxN = (1 << 15) + 13, N = 15 + 3;
int n, par[N], x[N], y[N], a[N];
long double dp[maxN], dis[N][N];
int get_par(int x) {
    if (x == par[x])
	return x;
    return par[x] = get_par(par[x]);
}

long double mst (int x) {
    long double ret = 0;
    vector<pair<long double, pair<int, int>>> d;
    vector<int> vec;
    vec.clear();
    d.clear();
    for (int i = 0; i < n; i++) {
	if ((1 << i) & x) {
	    vec.push_back(i);
	    par[i] = i;
	}
    }
    for (auto a : vec)
	for (auto b : vec) {
	    if (a != b) 
		d.push_back({dis[a][b], {a, b}});
	    
	}
    sort(d.begin(), d.end());
    for (auto a : d) {
	int u = a.S.F, v = a.S.S;
	long double w = a.F;
	int p1 = get_par(v), p2 = get_par(u);
	if (p1 != p2) {
	    par[p1] = p2;
	    ret += w;
	}
    }
    return ret;
}

int32_t main () {
    cin >> n;
    for (int i = 0; i < n; i++)
	cin >> x[i] >> y[i] >> a[i];
    for (int i = 0; i < n; i++)
	for (int j = 0; j < n; j++) {
	    dis[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
	}

    for (int i = 1; i < (1 << n); i++) {
	int cnt = __builtin_popcount(i), sum = 0;
	long double val = mst(i);
	for (int j = 0; j < n; j++)
	    if ((1 << j) & i) {
		sum += a[j];
	    }
	//cout << fixed << setprecision(10) << sum << " " << val << " " << cnt << endl;
	dp[i] = ((double)sum - val) / cnt;
	//cout << i << " " <<  dp[i] << endl;
    }

    for (int i = 1; i < (1 << n); i++) {
	for (int j = (i - 1) & i; j; j = (j - 1) & i)
	    dp[i] = max(dp[i], min(dp[j], dp[i ^ j]));
	//cout << i << " " << dp[i] << endl;
    }

    cout << fixed << setprecision(10) << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 768
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    println!(
        "{}",
        format!("{0}{1}{2}", s[0], s.len() - 2, s[s.len() - 1])
    );
}


Measured memory_bytes: 4352
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
make = {"r": "s", "s": "p", "p": "r"}
_t = input()
patterns = ["p" if x == "r" else "r" if x == "s" else "s" for x in _t]
scores = [p if x == "r" else r if x == "s" else s for x in _t]
for i in range(n):
    if i > k - 1:
        if patterns[i - k] == patterns[i]:
            if scores[i - k] == 0:
                patterns[i - k] = make[_t[i - k]]
            else:
                patterns[i] = _t[i]
                scores[i] = 0
print(sum(scores))


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

int main(void)
{
    int x, y;

    cin >> x >> y;

    int bb = y-2*x;
    int aa = 4*x-y;
    
    if(bb%2==0 && bb>=0 && aa%2==0 && aa>=0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;

const int N=1e5+5;
vll v[N];
ll vis[N];
ll noc=0;

void dfs(ll x)
{
    vis[x]=1;
    for(auto it:v[x])
    {
        if(!vis[it])
        {
            dfs(it);
        }
    }
}

void solve()
{
   ll n,m;
   cin>>n>>m;
   ll i;
   for(i=0;i<m;i++)
   {
       ll x,y;
       cin>>x>>y;
       x--,y--;
       v[x].pb(y);
       v[y].pb(x);
   }
   for(i=0;i<n;i++)
   {
       if(!vis[i])
       {
           noc++;
           dfs(i);
       }
   }
   cout<<(noc-1)<<"\n";
} 


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


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


return 0;
}

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

void solve() {
  int a, b = 0, c;
  cin >> a >> c;
  string ans = "No";
  while (a >= 0) {
    if (a * 2 + b * 4 == c) {
      ans = "Yes";
      break;
    }
    a--;
    b++;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3640
H,W=map(int,input().split())
L=[[0 for i in range(W)]for j in range(H)]
for i in range (H):
  L[i]=list(input())

for a in range(H):
    for b in range(W):
        if L[a][b]=='.':
             num=0
             for k in range(-1,2):
                 for l in range(-1,2):
                    if 0<=a+k<=H-1 and 0<=b+l<=W-1 and L[a+k][b+l]=='#':
                        num+=1
             L[a][b]=num
    print(*L[a],sep='')

Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 101

int pop(void);
int isFull(void);
int isEmpty(void);
void push(int);

int top=0;
int s[MAX]={};

int main(){
  int x,rslt;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop()+pop());
    } else if ( s[0] == '-' ){
      rslt = pop() - pop();
      push(rslt*(-1));
    } else if ( s[0] == '*' ){
      push(pop()*pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}


// initialize() to caii it initialize function for convenience sake

int isEmpty(){
return top == 0;
}

 int isFull(){
   return top >= MAX - 1;
	   }

void  push(int x){
  if (isFull()){
    printf("array is full\n");
    exit(1);
  }
  top++;
  s[top] = x;
}

int  pop(){
    if (isEmpty()){
      printf("array is empty\n");
    exit(2);
  }
   
  top--;
  return s[top+1];
  }



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int a[5],i;
    f(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;

}

Measured memory_bytes: 3556
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
		long X = Long.valueOf(x);
		double arg = 100;
		int ans = 0;

        while(arg < X) {
			arg = Math.floor(arg * 1.01);
			ans++;
        }

		System.out.println(ans);

        sc.close();
    }    
}


Measured memory_bytes: 26984
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
ll ok[1000001],ng[1000001],only0[1000001],only9[1000001];
const ll MOD=(ll)1e9+7;

int main(){
  ll n;
  cin>>n;
  ng[0]=1;
  for(int i=0;i<n;i++){
    ng[i+1]=8*ng[i]%MOD;
    only0[i+1]=(ng[i]%MOD)+(only0[i]*9%MOD);
    only9[i+1]=(ng[i]%MOD)+(only9[i]*9%MOD);
    ok[i+1]=(10*ok[i]%MOD)+(only0[i]%MOD)+(only9[i]%MOD);
  }
  cout<<ok[n]%MOD<<endl;
}


Measured memory_bytes: 34688
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var ans = (int)Pow(N, 3);
            WriteLine(ans);
        }

        public long C(long n, long r)
        {
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

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

int main()
{
   ll k;
   cin>>k;
   int current = 7%k;
   int ans{1};
   if(k%2 == 0 || k%5 ==0) 
   {
      cout<<-1<<endl;
      return 0;
   }
   else
   {
      while(current != 0)
      {
         current = current*10 + 7;
         current %= k;
         ans++;
      }
   }
   cout<<ans;
   return 0;
   
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

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

	vecll xd(n), yd(n);
	rep(i,n){
		xd[i] = x[i]-y[i];
		yd[i] = x[i]+y[i];
	}

	sortall(xd);
	sortall(yd);

	prt(max(xd[n-1]-xd[0], yd[n-1]-yd[0]));


}


Measured memory_bytes: 9588
from collections import defaultdict, deque
def inpl(): return list(map(int, input().split()))

N = int(input())
D = defaultdict(list)

for _ in range(N-1):
    u, v, w = inpl()
    D[u].append((v, w))
    D[v].append((u, w))

color = [-1]*(N+1)
Q = deque()
color[1] = 0
Q.append(1)

while Q:
    u = Q.pop()
    c = color[u]
    for v, w in D[u]:
        if color[v] == -1:
            if w % 2:
                color[v] = int(not c)
            else:
                color[v] = c
            Q.append(v)

print(*color[1:], sep="\n")

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

int main() {
    string ss, t;
    cin >> ss >> t;
    int replace_point = -1;
    string min_s = ""; 
    rep(i,ss.size()) min_s += 'z';
    rep(i,ss.size()) {
        int combo = 0;
        if (ss[i] == t[0] || ss[i] == '?') { 
            // start check !
            combo++;
            for (int j = 1; j < t.size() && i+j < ss.size(); j++) {
                if (ss[i+j] == t[j] || ss[i+j] == '?') {
                    combo++;
                }
                else {
                    combo = 0;
                    break;
                }
            }
        }
        if (combo == t.size()) replace_point = i;
        if (replace_point != -1) {
            string s = ss;
            s.replace(replace_point, t.size(), t);
            replace(s.begin(), s.end(), '?', 'a');
            min_s = min(s, min_s);
        }
    }
    if (replace_point == -1) min_s = "UNRESTORABLE";
    cout << min_s << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int cnt4 = 0, cnt2 = 0, odd = 0;
    V<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 4 == 0) cnt4++;
        else if (a[i] % 2 == 0) cnt2++;
        else odd++;
    }

    
    if (cnt2 == 0) {
        if (cnt4 >= odd - 1) cout << "Yes\n";
        else cout << "No\n"; 
    } else {
        if (cnt4 >= odd) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3724
import sys
input = sys.stdin.readline

def main():
    S = input().strip()
    ma = 0
    ACGT = ['A', 'C', 'G', 'T']
    count = 0
    for s in S:
        if s in ACGT:
            count += 1
        else:
            ma = max(ma, count)
            count = 0
    ma = max(ma, count)
    print(ma)


if __name__ == '__main__':
    main()




Measured memory_bytes: 3188
import math

N, M = map(int, input().split())
d_num = 10 ** 9 + 7
fact = math.factorial(N) * math.factorial(M)
diff = abs(N - M)
if diff > 1:
    print(0)
elif diff == 0:
    print(2 * fact % d_num)
else:
    print(fact % d_num)


Measured memory_bytes: 5184
#include <iostream>
#define int long long
using namespace std;
int E;
int solve(int e){
    int min = e;
    for(int z=0; z*z*z<=e; z++){
        for(int y=0; y*y<=e-z*z*z; y++){
            int x = e - z*z*z - y*y;
            min = (min < x+y+z)? min: x+y+z;
        }
    }
    return min;
}
signed main(){
    while(cin >> E && E > 0){
        cout << solve(E) << endl;
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define INF 100100100

int main(){

    int n, m; cin >> n >> m;
    int dp[55][10][55];
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n);

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= 8; j++){
            for(int k = 0; k <= m; k++){
                dp[i][j][k] = -INF;
            }
        }
    }

    dp[0][0][m] = 0;


    for(int i = 0; i < n; i++) cin >> A[i] >> B[i] >> C[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 8; j++){
            for(int k = 0; k <= m; k++){

                for(int a = 0; a <= 8; a++){
                    
                    //残ってない
                    if(k - a < 0) continue;
        
                    int value = -INF;
                    //振らない
                    value = max(value, C[i]);

                    if(a != 0) value = max(value, A[i] * a);

                    if(j != 0) value = max(value, B[i] * j);

                    if(a + j >= 9){
                        if(A[i] > B[i]){
                            value = max(value, A[i] * a + B[i] * (8 - a));
                        }else{
                            value = max(value, A[i] * (8 - j) + B[i] * j);
                        }
                    }else{
                        if(a + j != 0) value = max(value, A[i] * a + B[i] * j);
                    }

                    if(a >= 1) value = max(value, A[i]);

                    if(j >= 1) value = max(value, B[i]);

                    dp[i + 1][a][k - a] = max(dp[i + 1][a][k - a], dp[i][j][k] + value);

                }
            }
        }
    }

    /*for(int i = 0; i <= n; i++){
        cout << i << endl;
        for(int j = 0; j <= 8; j++){
            for(int k = 0; k <= m; k++){
                cout << dp[i][j][k] << " ";
            }
            cout << endl;
        }
    }*/

    int ans = -INF;
    for(int j = 0; j <= 8; j++){
        for(int k = 0; k <= m; k++){
            ans = max(ans, dp[n][j][k]);
        }
    }

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


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

int main(){
	string s;
	cin >>s;
	
	for(int i =0; i< s.size()-1; i++) {
		if(s[i] == s[i+1])  {
			cout << i+1 << " " << i+2 << endl;
			return 0;
		} else if(i < s.size() -2  && s[i] == s[i+2] ){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long l = sc.nextLong();
        long r = sc.nextLong();

        long min = Long.MAX_VALUE;
        if (r - l > 2019) {
            min = 0;
        } else {
            flag:
            for (long i = l; i < r; i++) {
                for (long j = l + 1; j <= r; j++) {
                    min = Math.min(min, (i * j) % 2019);
                    if (min == 0) break flag;
                }
            }
        }


        System.out.println(min);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

char S[100];
int main()
{
  int cnt, len;
  int i;

  cnt = scanf("%s", S);
  len = (int)strlen(S);

  for (i=0; i<len; i++) {
    if (((i+1)&1) == 0) {
      if (S[i] == 'R') {
        printf("No");
        return 0;
      }
    } else {
      if (S[i] == 'L') {
        printf("No");
        return 0;
      }
    }
  }

  printf("Yes");
  return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> M(H, vector<int>(W));
    int sum = 0;
    rep(i,H){
        rep(j,W){
            char m; cin >> m;
            if(m == '.'){
                M[i][j] = 0;
            }else{
                M[i][j] = 1;
                sum++;
            }
        }
    }

    vector<int> Wnum(W, 0);
    vector<int> Hnum(H, 0);

    rep(j,W){
        rep(i,H){
            Wnum[j]++;
        }
    }
    rep(i,H){
        rep(j,W) Hnum[i]++;
    }
    int pattern = 0;
    // ビット演算で色を塗り替える行列を決定する
    for(int tmp1=0; tmp1<(1<<H); tmp1++){
        for(int tmp2=0; tmp2<(1<<W); tmp2++){
            bitset<6> hbit(tmp1);
            bitset<6> wbit(tmp2);
            vector<vector<int>> M2(H, vector<int>(W));
            M2 = M;
            rep(i,W){
                if(wbit.test(i)) rep(j,H) M2[j][i] = 2;
            }
            rep(i,H){
                if(hbit.test(i)) rep(j,W) M2[i][j] = 2;
            }
            int cnt = 0;
            rep(i,H){
                rep(j,W) if(M2[i][j] == 1) cnt++;
            }
            if(cnt == K) pattern++;
        }
    }
    cout << pattern << endl;
}

Measured memory_bytes: 3636
class Program
 {
        static void Main(string[] args)
        {
          string a = System.Console.ReadLine();
        string[] b = a.Split(' ');
        int x = int.Parse(b[0]);
        int y = int.Parse(b[1]);

if(x==y) System.Console.Write("Yes");
else System.Console.Write("No");
}
        }

Measured memory_bytes: 13140
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort()
ans = []
for i in A:
	x -= i
	#print(ans, x)
	if x >= 0:
		ans.append(i)
	else:
		break
	
if x > 0:
	print(len(ans)-1)
else:
	print(len(ans))

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  iota(v.begin(), v.end(), 0);
  int add = 0;
  double ret = 0.0;
  do {
    for (int j = 1; j < N; j++) {
      ret += hypot(X[v[j]] - X[v[j - 1]], Y[v[j]] - Y[v[j - 1]]);
    }
    ++add;
  } while (next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(12) << ret / add << endl;
}


Measured memory_bytes: 256
//In The Name of Beauty
//...So here I go is my shot
//Feet fail me not 'cause maybe the only opportunity that I got...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;

int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll ans = 0;
    ll temp = 0;
    for(ll i = 0;i < s.size();i++)
    {
        if(s[i] == '0')continue;
        ll x = temp;x += (s[i] - '0' - 1);x += (9 * (s.size() - i - 1));
        ans = max(ans,x);
        temp += (s[i] - '0');
    }
    ans = max(ans,temp);
    cout << ans;
    return 0;
}
//Written by M_H_H_7


Measured memory_bytes: 256
from collections import Counter

import numpy as np


def solve(n, pts):
    ans = [0] * n

    div = 200000
    a = np.linspace(0, 2 * np.pi, div, endpoint=False)
    b = np.array([np.cos(a), np.sin(a)], dtype=np.float32)
    for i, v in Counter(np.argmax(np.dot(pts, b), axis=0)).items():
        ans[i] = v / div
    return ans


n = int(input())
pts = np.array([list(map(int, input().split())) for _ in range(n)], dtype=np.float32)
print('\n'.join(map(str, solve(n, pts))))


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

using Int = unsigned long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int x;
	cin >> x;
	Int ans = 0;
	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int k, a, b, c, m;
    scanf("%d%d%d", &k, &a, &b);
    for(;;){
        c = a%k;
        if(c == 0)
            m += 1;
        
        if( a == b)
            break;
        a +=1;
    }
    if(m>=1)
        printf("OK");
    else
        printf("NG");

    return 0;
}

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

void solve() {
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	vector<int> v1, v2;
	int cnt = c;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'o' && cnt >= c) {
			v1.push_back(i + 1);
			cnt = 0;
		}
		else if(s[i] == 'x') cnt++;
		else if(s[i] == 'o' && cnt < c) cnt++;
		if(v1.size() == k) break;
	}
	cnt = c;
	for(int i = n - 1; i >= 0; i--) {
		if(s[i] == 'o' && cnt >= c) {
			v2.push_back(i + 1);
			cnt = 0;
		}
		else if(s[i] == 'x') cnt++;
		else if(s[i] == 'o' && cnt < c) cnt++;
		if(v2.size() == k) break;
	}
	sort(v2.begin(), v2.end());
	for(int i = 0; i < k; i++) {
		if(v1[i] == v2[i]) {
			printf("%d\n", v1[i]);
		}
	}
}

int main() {
//	freopen("in.txt", "r", stdin);
	solve();
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> w;
    string c, ans = "Yes";
    for (int i = 0; i < n; i++) {
        string n;
        cin >> n;
        w[n]++;
        if (i != 0 && c.back() != n[0]) ans = "No";
        c = n;
    }

    for (auto e : w) if (e.second != 1) ans = "No";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n+1,0);
  rep1(i,n)cin>>a[i];
  vector<int> sum(n+1,0);
  rep1(i,n){
    sum[i]=sum[i-1]+a[i];
  }
  map<int,int> memo;
  if(k>n){
    rep(i,n+1){
    int buf=(sum[i]-i+n*k)%k;
    int hoge=memo[buf];
    memo[buf]+=1;
    }
    int res=0;
    auto it=memo.begin();
    while(it!=memo.end()){
    int buf=it->second;
    res+=buf*(buf-1)/2;
    //printf("%lld %lld\n",it->first,it->second);
    ++it;
    }
    cout<<res<<"\n";
  }
  else{
    rep(i,k){
    int buf=(sum[i]-i+n*k)%k;
    int hoge=memo[buf];
    memo[buf]+=1;
    }
    int res=0;
    auto it=memo.begin();
    while(it!=memo.end()){
    int buf=it->second;
    res+=buf*(buf-1)/2;
    //printf("%lld %lld\n",it->first,it->second);
    ++it;
    }
    for(int i=k;i<=n;i++){
      int buf=sum[i-k]-(i-k)+n*k;
      buf%=k;
      memo[buf]--;
      buf=sum[i]-i+k*n;
      buf%=k;
      res+=memo[buf];
      memo[buf]+=1;
    }
    cout<<res<<"\n";
  }
  return 0;
}


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

long long T;
int x = 0;
string a = "3";
string b = "5";
string c = "7";

void upnumber(long long n)
{
	if (n <= T)
	{
		string N = to_string(n);
		if (N.find(a) != string::npos && N.find(b) != string::npos && N.find(c) != string::npos)
		{
			x++;
		}
		upnumber(n * 10 + 3);
		upnumber(n * 10 + 5);
		upnumber(n * 10 + 7);
	}
}

int main()
{
	cin >> T;
	upnumber(0);
	cout << x;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main () {

    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;

    ll ans=0;

    if (a+b>=2*c) {
        ans+=c*2*min(x,y);
    }
    else {
        ans+=(a+b)*min(x,y);
    }

    if (a*(x-min(x,y))+b*(y-min(x,y))>=2*c*(x+y-2*min(x,y))) {
        ans+=2*c*(x+y-2*min(x,y));
    }
    else {
        ans+=a*(x-min(x,y))+b*(y-min(x,y));
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int t;
	for (int i = 0; i < 5; i++) {
		cin >> t;
		if (t == 0) {
			printf("%d", i + 1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3696
x1, y1, x2, y2 = map(int, input().split())
x3, y3 = x2 - (y2 - y1), y2 + (x2 - x1)
x4, y4 = x1 - (y2 - y1), y1 + (x2 - x1)
print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 2940
#include<cstring>
#include<cstdio>
int a[107],sum=0,ssum=0;
int main ()
{
    int n,mmin=1e9;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=1;i<=n;i++)
    {
        int k;
        ssum+=a[i];
        k=sum-2*ssum;
        if(k<0) k*=-1;
        if(k<mmin)
            mmin=k;
    }
    printf("%d\n",mmin);
    return 0;
}


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

public class Test
{
	public static void Main()
	{
		int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Array.Sort(a);
		if(a[0] == a[1] && a[1] == a[2] && a[2] == a[3] && a[4] == a[5] && a[5] == a[6] && a[6] == a[7] && a[8] == a[9] && a[9] == a[10] && a[10] == a[11]) Console.WriteLine("yes");
		else Console.WriteLine("no");
	}
}

Measured memory_bytes: 9472
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
ll b[60];
ll p[60];
ll sum[60];
ll f(ll n,ll x){
  if(n==0)return x>0;
  if(x==1)return 0;
  if(x>1&&x<=sum[n-1]+1)return f(n-1,x-1);
  if(x==sum[n-1]+2)return p[n-1]+1;
  if(x>sum[n-1]+2&&x<=sum[n-1]*2+2)return p[n-1]+1+f(n-1,x-2-sum[n-1]);
  if(x>=sum[n])return p[n];
  
}

int main(){
  ll n,x;
  cin>>n>>x;
  b[0]=0;
  p[0]=1;
  sum[0]=1;
  rep1(i,n){
    b[i]=b[i-1]*2+2;
    p[i]=p[i-1]*2+1;
    sum[i]=sum[i-1]*2+3;
  }
  ll ans=0;
  ans=f(n,x);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define N 1000010
using namespace std;
ll m,n,jie[N],nj[N],dp[N][2],a[22],su[N],ans,co[N];
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll C(ll x,ll y){if(x<y)return 0;return (jie[x]*nj[x-y]%mo)*nj[y]%mo;}
int main(){
	cin>>n>>m;
	jie[0]=1;for (int i=1;i<=(1<<n);i++)jie[i]=jie[i-1]*i%mo;
	nj[(1<<n)]=po(jie[(1<<n)],mo-2);for (int i=(1<<n)-1;i>=0;i--)nj[i]=nj[i+1]*(i+1)%mo;
	for (int i=0;i<(1<<n);i++)su[i]=su[i/2]*2+(i&1),co[i]=co[i/2]+(i&1);
	for (int i=m;i>=1;i--)cin>>a[i];
	dp[0][0]=1;
	for (int j=1;j<=m;j++){
		for (int i=0;i<(1<<n);i++){
			for (int k=0;k<n;k++){
				if ((i&(1<<k))==0){
					dp[i+(1<<k)][1]=(dp[i+(1<<k)][1]+(dp[i][0]*C((1<<n)-a[j]-su[i],(1<<k)-1)%mo)*jie[(1<<k)])%mo;
				}
			}
		}
		for (int i=0;i<(1<<n);i++){dp[i][0]=(dp[i][0]+dp[i][1])%mo;dp[i][1]=0;}
	}
	for (int i=0;i<(1<<n);i++){
		if (co[i]%2==1)ans=(ans+(mo-jie[(1<<n)-1-su[i]])*dp[i][0])%mo;
		else ans=(ans+jie[(1<<n)-1-su[i]]*dp[i][0])%mo;
	}
	cout<<ans*(1<<n)%mo<<endl;
	return 0;
}

Measured memory_bytes: 13056
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

ll H, W;
string s[410];
ll x = 0, y = 0;//xが黒yが白
bool visited[410][410];
void dfs(ll Y, ll X) {
	if (visited[Y][X] == true)return;
	visited[Y][X] = true;
	for (int k = 0; k < 4; ++k) {
		ll ny = Y + dy[k];
		ll nx = X + dx[k];
		if (ny >= H || ny < 0 || nx >= W || nx < 0 || visited[ny][nx] || s[ny][nx] == s[Y][X])continue;
		dfs(ny, nx);
	}
	if (s[Y][X] == '.') {
		x++;
	}
	else {
		y++;
	}
	return;
}
signed main() {
	cin >> H >> W;
	REP(i, H)cin >> s[i];
	ll ans = 0;
	for (ll i = 0; i < H; ++i) {
		for (ll j = 0; j < W; ++j) {
			dfs(i, j);
			ans += x * y;
			x = 0;
			y = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15616
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    while(1){
        int yoko,tate;
        cin>>yoko>>tate;
        if(yoko==0&&tate==0)break;
        int x=1,y=1,muki=1;//１上、２右、３下、４左
        while(1){
            string in;
            cin>>in;
            if(in=="STOP"){
                cout<<x<<" "<<y<<endl;
                break;
            }
            if(in=="FORWARD"){
                int susumu;
                cin>>susumu;
                switch (muki) {
                    case 1:
                        y+=susumu;
                        break;
                    case 2:
                        x+=susumu;
                        break;
                    case 3:
                        y-=susumu;
                        break;
                    case 4:
                        x-=susumu;
                        break;
                }
            }
            if(in=="BACKWARD"){
                int susumu;
                cin>>susumu;
                switch (muki) {
                    case 1:
                        y-=susumu;
                        break;
                    case 2:
                        x-=susumu;
                        break;
                    case 3:
                        y+=susumu;
                        break;
                    case 4:
                        x+=susumu;
                        break;
                }
            }
            if(x>yoko){
                x=yoko;
            }else if(x<1){
                x=1;
            }else if(y>tate){
                y=tate;
            }else if(y<1){
                y=1;
            }
            if(in=="RIGHT"){
                switch(muki){
                    case 1:
                        muki=2;
                        break;
                    case 2:
                        muki=3;
                        break;
                    case 3:
                        muki=4;
                        break;
                    case 4:
                        muki=1;
                        break;
                }
            }
            if(in=="LEFT"){
                switch(muki){
                    case 1:
                        muki=4;
                        break;
                    case 2:
                        muki=1;
                        break;
                    case 3:
                        muki=2;
                        break;
                    case 4:
                        muki=3;
                        break;
                }
            }
        } 
    }
    
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
    ll n,d;
    cin >> n >> d;
    ll count = 0;
    while(n--)
    {
        ll a,b;
        cin >>a >>b;
        ll dist = d*d;
        if(a*a + b*b <= dist){
                count++;

        }


    }
    cout << count;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
signed main()
{   
	IOS
  /*  #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
int n,k;
cin>>n;
cin>>k;
int h[n+1];
for(int i=1;i<=n;i++)
{
	cin>>h[i];
}
int dp[n+1]={0};
dp[1]=dp[0]=0;
dp[2]= abs(h[2]-h[1]);
if(k==1)
{
for(int i =3;i<=n;i++)
{
	dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
}	
cout<<dp[n]<<endl;

	return 0;
}

for(int i =3;i<=n;i++)
{
	int c = min(i-1,k);
	int ans = INT_MAX;
	for(int j = 1;j<=c;j++)
	{
		ans = min(ans,abs(h[i]-h[i-j])+dp[i-j]);
	}
    dp[i]=ans;

}


/*int a = dp[i-2]+abs(h[i]-h[i-2]);
int b = dp[i-1]+abs(h[i]-h[i-1]);	
dp[i]=min(a,b);*/



cout<<dp[n]<<endl;

}






Measured memory_bytes: 1792
#include <iostream>
#include <array>

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

    long long int n;

    std::array<int, 150> age2generation;

    for (int i = 0; i < 70; ++i) {
        age2generation[i] = i / 10;
    }
    for (int i = 70; i < 150; ++i) {
        age2generation[i] = 6;
    }

    while (std::cin >> n, n) {
        
        std::array<long long int, 7> arr{{}};
        int age;

        for (; n--;) {
            std::cin >> age;
            ++arr[age2generation[age]];
        }
        
        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1200