akhauriyash/Code-Regression huggingface dataset:
class Dice():

    def __init__(self, d):
        self.d = d
        self.north = [2, 6, 3, 4, 1, 5]
        self.south = [5, 1, 3, 4, 6, 2]
        self.east = [4, 2, 1, 6, 5, 3]
        self.west = [3, 2, 6, 1, 5, 4]
        self.label = [(self.d[0], self.d[1], self.d[2])]

    def roll(self, direction):
        if direction == 'S':
            self.d = [ self.d[self.south[i]-1] for i in range(6) ]
        elif direction == 'N':
            self.d = [ self.d[self.north[i]-1] for i in range(6) ]
        elif direction == 'E':
            self.d = [ self.d[self.east[i]-1] for i in range(6) ]
        elif direction == 'W':
            self.d = [ self.d[self.west[i]-1] for i in range(6) ]

    def rollAll(self):
        for i in range(4):
            for i in range(4):
                self.roll('E')
                self.label.append((self.d[0], self.d[1], self.d[2]))
            self.roll('S')
        self.roll('E')
        self.roll('S')
        for i in range(4):
            self.roll('E')
            self.label.append((self.d[0], self.d[1], self.d[2]))
        self.roll('S')
        self.roll('S')
        for i in range(4):
            self.roll('E')
            self.label.append((self.d[0], self.d[1], self.d[2]))

    def getLabel(self):
        return set(self.label)

    def getDice(self):
        return self.d

s1= [ int(s) for s in input().split() ]
s2= [ int(s) for s in input().split() ]
dice1 = Dice(s1)
dice2 = Dice(s2)
dice1.rollAll()
dice2.rollAll()

l = dice1.getLabel()
l2 = dice2.getLabel()
if l == l2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[200010][3],n,a[200005];
int maxi=1e17;
int dfs(int p,int f){
	if(p>n||(p==n&&f==2))RE 0;
	if(dp[p][f]!=-maxi)RE dp[p][f];
	int re=-maxi;
	FOR(i,2,2+f){
		gmax(re,dfs(p+i,f+2-i));
	}
	re=re+a[p];
	RE dp[p][f]=re;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n)cin>>a[i];
	int ans=-1e17;
	FOR(i,0,n+5)FOR(j,0,2)dp[i][j]=-maxi;
	if(n&1){
		FOR(i,0,2){
			gmax(ans,dfs(i+1,2-i));
		}
	}else{
		FOR(i,0,1){
			gmax(ans,dfs(i+1,1-i));
		}
	}
	cout<<ans<<'\n';
	RE 0;
}




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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	set<int>s ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		s.insert(x) ;
	}
	if(s.size() == n)
		return cout<<"YES\n" , 0 ;
	else
		return cout<<"NO\n" , 0 ;
}		

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

int main(){
    int N;
    cin >> N;
    double v[60];
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }
    sort(v, v+N);
    for(int i = 0; i < N - 1; i++){
        v[i+1] = (double)(v[i] + v[i+1])/2;
    }
    cout << v[N-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    string s;
    cin>>s;
    int i=1,c=0,ans=1,beg=0;
    if (s[0]=='0')
        c++;
    while (i<x){
        if (s[i]=='0'&&s[i-1]=='1'){
            c++;
            if (c>k){
                while (beg<i){
                    beg++;
                    if (s[beg]=='1'&&s[beg-1]=='0')
                        break;
                }
            }
        }
       ans=max(ans,i-beg+1);
       i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
const int oo = 1e6;
int n, k;
int arr[100007];

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; i++)
  cin >> arr[i];
  cout << ((n - 1) + (k - 2)) / (k - 1) << endl;
  return 0;



}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 1000000000000000000

							
									//nestedcode
									
ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % M;
        a = (a * a)% M;
        b >>= 1;
    }
    return res;
}




int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m,k,i,f,d,ans;
    cin>>n>>m>>k;
    ll a[n+5],b[m+5];
    vector<ll> dp(n),dpp(m);
    for(i=0;i<n;i++){
    	cin>>a[i];
    	if(i == 0){
    		dp[i] = a[i];
    		continue;
		}
    	dp[i] = dp[i-1]+a[i];
	}
	
	for(i=0;i<m;i++){
    	cin>>b[i];
    	if(i == 0){
    		dpp[i] = b[i];
    		continue;
		}
    	dpp[i] = dpp[i-1]+b[i];
	}
	
	ans = (upper_bound(dpp.begin(),dpp.end(),k) - dpp.begin());
	for(i=0;i<n;i++){
		if(k < dp[i])	continue;
		d = k-dp[i];
		f = upper_bound(dpp.begin(),dpp.end(),d) - dpp.begin();
		ans = max(ans,i+1+f);
		
	}
	cout<<ans;
    
    
}

Measured memory_bytes: 9532
using System;
class Program
{
        static void Main(string[] args)
        {
            args = Console.ReadLine().Split(' ');
            int n = int.Parse(args[0]);
            int m = int.Parse(args[1]);
            char[,] x = new char[50, 50];
            char[,] y = new char[50, 50];
            for (int i = 0; i < n; i++)
            {
                args[0] = Console.ReadLine();
                for (int j = 0; j < n; j++)
                {
                    x[i, j] = args[0][j];
                }
            }
            for (int i = 0; i < m; i++)
            {
                args[0] = Console.ReadLine();
                for (int j = 0; j < m; j++)
                {
                    y[i, j] = args[0][j];
                }
            }
            bool r = false;
            for (int i = 0; i < n-m+1; i++)
            {
                for (int j = 0; j < n-m+1; j++)
                {
                    r = true;
                    for (int k = 0; k < m; k++)
                    {
                        for (int l = 0; l < m; l++)
                        {
                            if (x[i+k, j+l] != y[k, l])
                            {
                                r = false;
                                break;
                            }
                        }
                        if (!r)
                        {
                            break;
                        }
                    }
                    if (r)
                    {
                        break;
                    }
                }
                if (r)
                {
                    break;
                }
            }
            Console.WriteLine(r ? "Yes" : "No");
        }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define chk(a) rep(i, a.size()) cout << a[i] << " "
#define SORT(c) sort((c).begin(),(c).end())
#define ll long long
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)


using namespace std;
typedef pair<int, int> pii;
#define WARU 1000000007;

int main(void) {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) {
		cin >> v[i];
	}
	int count = 0;
	rep(i, n) {
		if (i + 1 == v[v[i] - 1]) {
			count++;
		}

	}
	cout << count / 2 << endl;

	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main()
{
    int i,j,k,l,m,n,o,a,b,sum;
    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);
    sum=0;
    for(o=0;o<=9;o++)
    {
        for(i=0;i<=9;i++)
        {
            for(j=0;j<=9;j++)
            {
                for(k=0;k<=9;k++)
                {
                    for(l=0;l<=9;l++)
                    {
                        for(m=a;m<=b&&10000*o+1000*i+100*j+10*k+l<=n;m++)
                        {
                            if(m==o+i+j+k+l)
                            {
                                sum=sum+10000*o+1000*i+100*j+10*k+l;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
def han(l):
    for i in range((len(l) // 2)):
        if l[i] != l[-i - 1]:
            return 0
    return 1

S = input()

f1 = han(S)
S2 = S[0:(len(S) // 2)]
S3 = S[len(S)//2 + 1 : len(S)]
f2 = han(S2)
f3 = han(S3)

if f1 * f2 * f3:
    print('Yes')
else:
    print('No')



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

using namespace std;

#define int long long
#define rep(i,a,n) for(int i = a; i<n; i++)
#define per(i,a,n) for(int i = n-1; i>=a; i--)

int max(int a,int b){return a>b ? a:b;}
int min(int a,int b){return a<b ? a:b;}


const int INF = 1e9+7;

int n,m,d;

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

  cin>>n>>m>>d;
  int ctr = 0;
  rep(i,n,m+1){
    if(i%d == 0)ctr++;
  }
  cout<<ctr<<"\n";
}


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

using namespace std;

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

    int ans[26];
    fill(ans, ans + 26, 100);

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        
        map<char, int> mp;
        for (int j = 0; j < s.size(); j++)
            mp[s[j]]++;
        
        for (int j = 0; j < 26; j++)
            ans[j] = min(ans[j], mp[(char)('a' + j)]);
    }

    for (int i = 0; i < 26; i++)
        for (int j = 0; j < ans[i]; j++)
            printf("%c", 'a' + i);
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
if len(a) > len(b):
  print("GREATER")
elif len(b) > len(a):
  print("LESS")
else: #桁数が同じ
  if a == b:
    print("EQUAL")
  else:
    for i, j in zip(a, b):
      if i > j:
        print("GREATER")
        break
      elif j > i:
        print("LESS")
        break
  
  



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;
ll dp[805][805];

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

	
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
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;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 k;
  cin >> k;

  vi a(k);
  rep(i,k) cin >> a[i];

  vi dpmax(k+1,2);
  vi dpmin(k+1,2);

  rep(i,k){
    i64 g = a[k-1-i];
    dpmin[i+1] = ((dpmin[i]+g-1)/g) * g;
    dpmax[i+1] = (dpmax[i]/g) * g + g - 1;
    if(dpmin[i+1]>dpmax[i+1]){
      cout << -1 << endl;
      return;
    }
  }

  cout << dpmin[k] << " " << dpmax[k] << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 2560
import Queue
def main():
    H,W=map(int,raw_input().split())
    s=[raw_input() for i in range(H)]
    q=Queue.Queue()
    visited=[[False]*W for _ in range(H)]
    dist=[[1145141919810]*W for _ in range(H)]
    visited[0][0]=True
    dist[0][0]=0
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    q.put((0,0))

    while not q.empty():
        x,y=q.get()
        for i in range(4):  
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue
            if s[xx][yy] == "#" :continue
            if visited[xx][yy]:continue
            visited[xx][yy]=True
            dist[xx][yy]=dist[x][y]+1
            q.put((xx,yy))
    if not visited[H-1][W-1]:
        print(-1)
        return
    use=[[False]*W for _ in range(H)]
    use[H-1][W-1]=True
    use[0][0]=True
    (x,y)=(H-1, W-1)
    while (x,y) != (0,0):
        use[x][y]=True
        mpos=(-1,-1)
        mval=1145141919
        for i in range(4):
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue     
            if dist[xx][yy] < mval:
                mpos=(xx,yy)
                mval=dist[xx][yy]
        x,y=mpos
    cnt=0
    for x in range(H):
        for y in range(W):
            if s[x][y] == "." and not use[x][y]: cnt+=1
    print(cnt)
main()    

Measured memory_bytes: 3052
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];
bool used[100100];

int main(void){
	ll t,s=0ll,ans=0ll,n=0ll,m,i,p=0ll;
	std::cin >> t >> a[0] >> m;
	while(true){
		used[a[n]] = true;
		a[n+1] = (a[n]*a[n])%m;
		++n;
		if(used[a[n]]){
			break;
		}
	}
	while(a[p]!=a[n]){
		ans += a[p];
		--t; ++p;
	}
	for(i=p; i<n; ++i){
		s += a[i];
	}
	ans += s*(t/(n-p));
	t %= (n-p);
	for(i=0; i<t; ++i){
		ans += a[p+i];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4116
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

signed main()
{
    int x, n;
    set<int> v;

    cin >> x >> n;

    for (int i = 0; i < n; ++i)
    {
        int in;
        cin >> in;
        v.insert(in);
    }

    int diff = 0;

    for (;;)
    {
        int ans;

        ans = x - diff;

        if (v.count(ans) == 0)
        {
            cout << ans << endl;
            return 0;
        }

        ans = x + diff;

        if (v.count(ans) == 0)
        {
            cout << ans << endl;
            return 0;
        }

        diff++;
    }
}


Measured memory_bytes: 3636
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int mod = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n;
string s;
// 繰り返し二乗法
ll pow_mod(ll x, ll n)
{
    if (n == 0)
        return 1;
    ll ret = pow_mod((x * x) % mod, n / 2);
    if (n & 1)
        ret = (ret * x) % mod;
    return ret;
}
ll inv_mod(ll n)
{
    // フェルマーの小定理
    return pow_mod(n, mod - 2);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    map<char,ll> m;
    //map<char, ll> mans;
    ll ans=0;
    ll kumi=1;
    for (int i = 0; i < n; i++)
    {
        m[s[i]]++;
        if (m[s[i]] == 1)
        {
            ans += kumi;
            kumi*=2;
        }
        else{
            kumi*=inv_mod(m[s[i]]);
            kumi%=mod;
            ans+=kumi;
            kumi*=m[s[i]]+1;
        }
        kumi%=mod;
        ans%=mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

/* vector<ll> solve(ll n, ll k) {
	vector<ll> res;
	while (n >= k) {
		res.pb(n);
		if (n % k == 0) {
			n /= k;
		}
		else {
			n -= k;
		}
	}
	res.pb(n);
	return res;
}*/

int main(void) {
	ll n;
	scanf("%lld", &n);
	/*for (ll k = 2; k <= n; k++) {
		vector<ll> res = solve(n, k);
		if (res.back() == 1) {
			printf("%lld:", k);
			REP(i, sz(res)) {
				printf(" %lld", res[i]);
			}
			printf("\n");
		}
	}*/

	ll ans = 0;
	set<ll> s;
	for (ll k = 2; k * k <= n; k++) {
		if (n % k == 0) {
			ll n1 = n;
			ll n2 = 1;
			while (n1 % k == 0) {
				n1 /= k;
				n2 *= k;
			}

			if (n1 % k == 1) {
				s.insert(k);
			}

			if (n2 % n1 == 1) {
				s.insert(n1);
			}
		}
	}

	s.insert(n);
	n--;
	if (n >= 2) {
		s.insert(n);
		for (ll k = 2; k * k <= n; k++) {
			if (n % k == 0) {
				s.insert(k);
				s.insert(n / k);
			}
		}
	}
	printf("%d\n", sz(s));
	scanf("%lld", &n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;
 
string s, t;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s >> t;
	vector<string> v;
	FOR(i, s.size()-t.size()+1) {
		if (s[i]==t[0] || s[i]=='?') {
			bool ok = true;
			FOR(j, t.size()) {
				if (s[i+j]!='?' && s[i+j]!=t[j]) ok = false;
			}
			if (ok) {
				string _s = s;
				FOR(j, t.size()) _s[i+j] = t[j];
				FOR(j, _s.size()) if (_s[j]=='?') _s[j] = 'a';
				v.push_back(_s);
			}
		}
	}
	if (v.empty()) cout << "UNRESTORABLE" << endl;
	else {
		sort(ALL(v));
		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


// 3 1 2 2 1
// 1 1 2 2 3
// (1 1) 2 2 3 need = nsm - sm






int main(){
	llint n, m;
	cin>>n>>m;
	cout<<(n*(n-1))/2 + (m*(m-1)/2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){

    int N, M;
    ll K;
    cin >> N >> M >> K;

    vector<ll> A(N);
    vector<ll> B(M);

    for(int i=0; i<N; i++) cin >> A.at(i);
    for(int i=0; i<M; i++) cin >> B.at(i);

    ll ans = 0, a_sum = 0, b_sum = 0, cnt = 0, B_best = 0;

    for(int i=0; i<M; i++) b_sum += B.at(i);
//    cout << b_sum << endl;
//    if(b_sum<=K) ans = M;

    for(int i=-1; i<N; i++){
        if(i>=0) a_sum += A.at(i);
//        cnt = 0;
        while(a_sum+b_sum>K){
            if(cnt >= M) break;
//            cout << a_sum+b_sum << endl;
            b_sum -= B.at(M-1-cnt);
            cnt++;
        }
//        cout << cnt << " " << b_sum << " " << endl;
        ll temp = (i+1)+(M-cnt);
        if(a_sum+b_sum<=K) ans = max(ans, temp);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int a=0;
  string s[8];
  rep(i,8) {
    string t;
    cin >> t;
    s[i]=t;
  }
  rep(k,3) {
    a+=90;
    pr(a);
    string s2[8]=s;
    rep(i,8) {
      rep(j,8) {
	s2[i][j]=s[7-j][i];
      }
      pr(s2[i]);
    }
    rep(i,8) s[i]=s2[i];
  }
  return 0;
}


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

const int MAXN = 2e5 + 5;

int N, M;
char s[MAXN];
vector <int> adj[2 * MAXN];
int bio[2 * MAXN];

void add(int u, int v) {
	adj[u].push_back(v);
}

void load() {
	scanf("%d%d%s", &N, &M, s + 1);
	while (M--) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (s[a] == s[b]) {
			add(2 * a - 1, 2 * b);
			add(2 * b - 1, 2 * a);
		}
		else {
			add(2 * a, 2 * b - 1);
			add(2 * b, 2 * a - 1);
		}
	}
}

bool dfs(int x) {
	if (bio[x])
		return 2 - bio[x];
	bio[x] = 1;
	for (auto it : adj[x])
		if (dfs(it))
			return true;
	bio[x] = 2;
	return false;
}

bool solve() {
	for (int i = 1; i <= 2 * N; i++)
		if (dfs(i))
			return true;
	return false;
}

int main() {
	load();
	puts(solve() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 24832
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    ans = [0 for _ in range(n)]
    for i in range(k):
        d = ri()
        la = rli()
        for a in la:
            ans[a-1] += 1
    print(sum(1 for a in ans if a == 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main()
{
    string s;
    unordered_map <string, int> mp; 
    long long ans=0;
    int n, i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s;
        sort(s.begin(), s.end());
        ans=ans+mp[s];
        mp[s]++;
    }

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

Measured memory_bytes: 10660
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
// SZ = 1e6 だと10ms
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;
    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            // 素数の倍数に対して2つ以上存在するなら gcd == i になる
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime\n";
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1) {
            cout << "setwise coprime\n";
        } else {
            cout << "not coprime\n";
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 18984
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string s;
char s_[111111];
int k;

struct SA {
  string s;
  vector<int> sa, pos;
  int gap;
  
  void build(const string& s_) {
    s = s_;
    sa.resize(s.size());
    pos.resize(s.size());
    auto comp = [&](int a, int b) {
      if (pos[a] != pos[b]) return pos[a] < pos[b];
      a += gap;
      b += gap;
      return (a < int(s.size()) &&
              b < int(s.size())) ? pos[a] < pos[b] : a > b;
    };
    for (size_t i = 0; i < s.size(); i++) {
      sa[i] = i;
      pos[i] = s[i];
    }
    vector<int> t(s.size());
    for (gap = 1;; gap *= 2) {
      sort(sa.begin(), sa.end(), comp);
      for (size_t i = 0; i+1 < s.size(); i++) {
        t[i+1] = t[i] + (comp(sa[i], sa[i+1]) ? 1 : 0);
      }
      for (size_t i = 0; i < s.size(); i++) {
        pos[sa[i]] = t[i];
      }
      if (t.back() == int(s.size())-1) break;
    }
  }
};

SA sa;
vector<int> vs;
int l;

bool test(int j) {
  int c = 0;
  string buf = "";
  string t = s.substr(j, l);
  // printf("%s\n", t.c_str());
  for (size_t i = 0; i < s.size(); i++) {
    // printf("%zd: %d %d\n", i, x, c);
    // printf("%zd: %s %d\n", i, buf.c_str(), c);
    if (l == 1) {
      if (s[i] > t[0]) return false;
    }
    if (((buf+s[i] > t && buf.size()+1 == t.size()) || buf.size()+1 > t.size())) {
      buf = s[i];
      ++c;
    } else {
      buf += s[i];
    }
  }
  return c <= k;
}

int main(void) {
  scanf("%d%s", &k, s_); s = s_;
  sa.build(s);
  l = (s.size()+k)/(k+1);
  for (int i = 0; i < int(sa.sa.size()); i++) {
    if (sa.sa[i]+l <= int(s.size())) {
      vs.push_back(sa.sa[i]);
    }
  }

  int lb = -1;
  int rb = vs.size()-1;
  while (rb-lb > 1) {
    int mb = (lb+rb)/2;
    if (test(vs[mb])) {
      rb = mb;
    } else {
      lb = mb;
    }
  }
  printf("%s\n", s.substr(vs[rb], l).c_str());
  return 0;
}


Measured memory_bytes: 2168
n=int(input())
a=list(map(int,input().split()))
a.append(a[0])
x=[0]*n
for i in range(n):
  x[0]+=a[i]*(-1)**i
for i in range(1,n):
  x[i]=2*a[i-1]-x[i-1]
for i in range(n):
  print(x[i],end=' ')

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

int main() {
  int N, B,sum,c1,c2,c3,c4,c5,LA;
  string A;
  cin >>A;
  sum =1;
  N = A.size();
 
  	if(A=="a"||A=="e"||A=="i"||A=="o"||A=="u"){
    cout<<"vowel"<<endl;
    }
    else{
    cout<<"consonant"<<endl;
    }
 


}

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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
int a[100010];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    rep(i,0,n)cin>>a[i];
    
    int ans=0,anscnt=INF;
    rep(i,-100,101){
        int cnt=0;
        rep(j,0,n){
            cnt+=abs(a[j]-i)*abs(a[j]-i);
        }
        if(anscnt>cnt){
            anscnt=cnt;
            ans=i;
        }
    }
    cout<<anscnt<<endl;
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 100000 + 5;

int n;
int dp[maxn][3];
int a[maxn],b[maxn],c[maxn];

inline void Solve (){
	for(int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i - 1][1] + a[i],dp[i - 1][2] + a[i]);
		dp[i][1] = max(dp[i - 1][0] + b[i],dp[i - 1][2] + b[i]);
		dp[i][2] = max(dp[i - 1][0] + c[i],dp[i - 1][1] + c[i]);
	}
	int ans = 0;
	for(int i = 0; i <= 2; i++){
		Chkmax(ans,dp[n][i]);
	}
	printf("%d\n",ans);
}

inline void Input (){
	n = read<int>();
	for(int i = 1; i <= n; i++){
		a[i] = read<int>();
		b[i] = read<int>();
		c[i] = read<int>();
	}
}

int main(){
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"YES"<<endl; else cout<<"NO"<<endl;
using namespace std;
int aaa(int a, int b) {
	for (int i = 1;; i++) {
		if (i * a > b)return i - 1;
	}
}
int b(int n,vector<ll> a) {
	ll ans = 0;
	rep(i, 0, n - 1) {
		rep(j, i + 1, n) {
			if (a[i] == a[j])return 1;
		}
	}
	return 0;
}

int main() {
	int n;
	int ans=0;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a);
	rep(i, 0, n - 1) {
		if (a[i] == a[i + 1]) {
			ans = 1;
			break;
		}
	}
	Yes(ans == 0);
	return 0;
}

Measured memory_bytes: 1792
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;


bool dp[80][80][6400];
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H), B(H);
    int x;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> x;
            A[i].push_back(x);
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> x;
            B[i].push_back(x);
        }
    }

    memset(dp, 0, sizeof dp);
    //for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) for (int k = 0; k < 6400; k++) dp[i][j][k] = false;

    dp[0][0][abs(A[0][0] - B[0][0])] = true;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i == 0 && j == 0)
                continue;
            int d = abs(A[i][j] - B[i][j]);
            if (i-1 >= 0) {
                for (int k = 0; k < 6400; k++) {
                    if (dp[i-1][j][k]) {
                        int k1 = abs(k+d);
                        int k2 = abs(k-d);
                        if (k1 < 6400)
                            dp[i][j][k1] = true;
                        if (k2 < 6400)
                            dp[i][j][k2] = true;
                    }
                }
            }
            if (j-1 >= 0) {
                for (int k = 0; k < 6400; k++) {
                    if (dp[i][j-1][k]) {
                        int k1 = abs(k+d);
                        int k2 = abs(k-d);
                        if (k1 < 6400)
                            dp[i][j][k1] = true;
                        if (k2 < 6400)
                            dp[i][j][k2] = true;
                    }
                }
            }
        }
    }

    for (int k = 0; k < 6400; k++) {
        if (dp[H-1][W-1][k] == true) {
            cout << k << endl;
            return 0;
        }
    }
    return 0;
}



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

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

  int H; cin >> H;
  vector<ll> v(H+1);
  for(int i = 0; i < H; i++){
    cin >> v[i+1];
  }
  for(int i = 1; i <= H; i++){
    cout << "node " << i << ": key = " << v[i] << ", ";
    if(i/2 > 0){
      cout << "parent key = " << v[i/2] << ", ";
    }
    if(2 * i < v.size()){
      cout << "left key = " << v[i*2] << ", ";
    }
    if(2*i+1 < v.size()){
      cout << "right key = " << v[i*2+1] << ", ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = 0
t = 0
for i in range(n):
	k = b[i] - a[i]
	if k < 0:
		s += -k
	elif k > 0:
		t += k//2
if s <= t:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 4596
N, X, Y = map(int, input().split())
dists = [0] * N
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(j - i, abs(X - i) + abs(Y - j) + 1)
        dists[d] += 1

for k in range(1, N):
    print(dists[k])

Measured memory_bytes: 46780
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    char str[6]={0};
    scanf("%s", str);
    int i;
    for(i=0; i<5; i++) {
        if(str[i]=='A' && str[i+1]=='C') {
            printf("Yes\n"); return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n, t, l, b;
	while (cin >> n >> t >> l >> b, n) {
		int marked[101] = {};
		int x=0;
		rep(i, l) {
			cin >> x; marked[x] = 1;
		}
		rep(i, b) {
			cin >> x; marked[x] = -1;
		}
		double p[101] = {};
		p[0] = 1;
		double q[101] = {};
		double u[101] = {};
		double sum = 0;
		rep(i, t) {
			rep(j, n + 1) {
				rep1(k, 6) {
					int r = j + k;
					if (r > n) {
						r = 2 * n - r;
					}
					if (marked[r] == -1) {
						q[0] += p[j] / (double)6;
					}
					else if (marked[r] == 1) {
						u[r] += p[j] / (double)6;
					}
					else {
						q[r] += p[j] / (double)6;
					}
				}
			}
			rep(j, n + 1) {
				p[j] = q[j];
			}
			rep(j, n + 1) {
				q[j] = u[j];
			}
			rep(j, n + 1) {
				u[j] = (double)0;
			}
			sum += p[n];
			p[n] = (double)0;
		}
		cout << fixed << setprecision(6) << sum << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
  vector<vector<int>> f(6);

  for (int i = 1; i <= 30000; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      f[i % 6].push_back(i);
    }
  }

  int n;
  cin >> n;

  if (n == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }

  cout << f[2].back() << endl;
  f[2].pop_back();
  cout << f[3].back() << endl;
  f[3].pop_back();
  cout << f[3].back() << endl;
  f[3].pop_back();
  cout << f[4].back() << endl;
  f[4].pop_back();
  n -= 4;

  while (n >= 2 && f[2].size() > 0 && f[4].size() > 0) {
    cout << f[2].back() << endl;
    f[2].pop_back();
    cout << f[4].back() << endl;
    f[4].pop_back();
    n -= 2;
  }
  while (n >= 2 && f[3].size() >= 2) {
    cout << f[3].back() << endl;
    f[3].pop_back();
    cout << f[3].back() << endl;
    f[3].pop_back();
    n -= 2;
  }
  while (n > 0 && f[0].size() > 0) {
    cout << f[0].back() << endl;
    f[0].pop_back();
    n--; 
  }
}

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

int main()
{
    int n;
    cin >> n;
    int cnt[10][10] = {0};
    for(int i = 1; i <= n; i++)
    {
        string s = ::to_string(i);
        cnt[(int)(s.front() - '0')][(int)(s.back() - '0')]++;
    }
    int sum = 0;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            sum += cnt[i][j] * cnt[j][i];
        }
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 100000
int dp[101][101][2];
int main(){
	int w,h;
	int i,j;
	while(1){
	scanf("%d %d",&w,&h);
	if(w==0)return 0;
	for(i=0;i<=h;i++){
		for(j=0;j<=w;j++){
			dp[i][j][0]=0;
			dp[i][j][1]=0;
			if(i==1||j==1){
				dp[i][j][0]=1;
				dp[i][j][1]=1;
			}
		}
	}
	for(i=2;i<=h;i++){
		for(j=2;j<=w;j++){
			dp[i][j][0]=(dp[i-2][j][1]+dp[i][j-2][0]+dp[i-2][j-1][1])%M;
			dp[i][j][1]=(dp[i-2][j][1]+dp[i][j-2][0]+dp[i-1][j-2][0])%M;
		}
	}
	printf("%d\n",(dp[h-1][w][1]+dp[h][w-1][0])%M);
	}
}

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

int main(){
    int A,B;
    cin >> A >> B;
    //you subtract a outlet everytime you plug a new one in, 
   int answer;
   int outlet = 1;
   while(outlet < B){
       --outlet;
       outlet += A;
       ++answer;
   }
cout << answer;

  
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <queue>
#include <map>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
#define MOD int(1e9+7)
#define REP(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second

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

	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];

	ll ans = 1, hiku=1;
	for (int i = 0; i < N; i++) {
		if (A[i] % 2)hiku *= 1;
		else hiku *= 2;

		ans *= 3;
	}

	cout << ans - hiku << endl;

    return 0;
}



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

int main(){
    string s;cin>>s;
    int res=0;
    stack<char> st;
    for(int i=0;i<s.size();i++){
        if(st.empty() || st.top()==s[i])st.push(s[i]);
        else{
            res+=2;
            st.pop();
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

intmax_t euler_phi(intmax_t n) {
    intmax_t ret = n;
    for (intmax_t i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            ret -= ret / i;
            while (n % i == 0) {
                n /= i;
            }
        }
    }
    if (n > 1) {
        ret -= ret / n;
    }
    return ret;
}

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

    intmax_t N; cin >> N;
    cout << euler_phi(N) << "\n";

    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))

const ll mod = 1e9 + 7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll a , ll b){ a = a%mod; if(b == 0) return 1LL;if(b&1)  return (a*1LL*expo(a , b - 1))%mod;ll t = expo(a , b/2);return (t*1LL*t)%mod;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

const int M = 2e5 + 5;

ll C[M] , F[M] , S[M];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    int n;
    si(n);


    for(int i = 1 ; i < n ; i++){
        sll(C[i]);  sll(S[i]);  sll(F[i]);
    }

    for(int i = 1 ; i < n ; i++){
        ll time_here = S[i];
        for(int j = i + 1 ; j <= n ; j++){
            time_here += C[j - 1];
            if(j == n) break;
            if(S[j] >= time_here){
                time_here = S[j];
            }
            else{
                ll lef = time_here - S[j];
                lef = lef/F[j] + (lef%F[j] != 0);
                time_here = S[j] + lef*F[j];
            }
        }
        printf("%lld\n" , time_here);
    }
    cout<<"0";

















}














Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int DX4[4]= {-1,0,0,1};
const int DY4[4]= {0,-1,1,0};
 
int main(){
	int n,k;
	int i,j;
	int ans=1;
	char temp;
 
	SCAN(&n);SCAN(&k);

	REP(i,n){
		if(ans<k){ans*=2;}else{ans+=k;}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  ll h,w;
  cin >> h >> w;
  ll a, b, c, ans;
  a = w * (h/2);
  b = ((w +1)/2);
  c =(h%2);
  ans = a + b * c;
  if ( h == 1 || w == 1) ans = 1;
  cout << ans;
}



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

class Graph{
    int N;
    vector<vector<int>> adjList;
    vector<int> colors;
    public:
        Graph(int N){
            this->N = N;
            this->colors.resize(N,0);
            this->adjList.resize(N);
        }
        int howManyVertex(){
            return this->N;
        }
        bool dfs(int u){
            this->colors[u] = 1; // this vertex is being processed
            for(int adjVertex : this->adjList[u]){
                if(this->colors[adjVertex] == 1){
                    return true;
                }
                if(this->colors[adjVertex] == 0 && this->dfs(adjVertex)){
                    return true;
                }
            }
            this->colors[u] = 2;
            return false;
        }
        bool hasCycle(){
            for(int i = 0 ; i < this->N ; i++){
                if(this->colors[i] == 0){
                    if(this->dfs(i)){
                        return true;
                    }
                }
            }
            return false;
        }
        void addVertex(int a, int b){
            this->adjList[a].push_back(b);
        }
};

int main(){
    int n,e;
    cin >> n >> e;
    Graph G(n);
    for(int i = 0 ; i < e ; i++){
        int a,b;
        cin >> a >> b;
        G.addVertex(a,b);
    }
    cout << G.hasCycle() << endl;

    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int ans;
    ans=0;
    for(int i=a;i<=b;i++){
        int s,t;
        int u,v;
        s = i%10;
        t = i/10000%10;
        u = i/10%10;
        v = i/1000%10;
        if(s==t&&u==v) ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

void Input_elements_column(int& n, int& m, int& l);
std::vector<std::vector<int>> Input_matrix(int n, int m);
void output(std::vector<std::vector<long long>> matrix);

int main()
{
	int n, m, l;
	Input_elements_column(n, m, l);
	std::vector<std::vector<int>> matrix_a = Input_matrix(n, m);
	std::vector<std::vector<int>> matrix_b = Input_matrix(m, l);

	std::vector<std::vector<long long>> matrix_C(n, std::vector<long long>(l));

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			for (int k = 0; k < l; ++k)
			{
				matrix_C[i][k] += static_cast<long long> (matrix_a[i][j]) * matrix_b[j][k];
			}
		}
	}

	output(matrix_C);

	return 0;
}

void Input_elements_column(int& n, int&m, int&l)
{
	std::cin >> n >> m >> l;
}

std::vector<std::vector<int>> Input_matrix(int n, int m)
{
	std::vector<std::vector<int>> matrix_a(n, std::vector<int>(m));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			std::cin >> matrix_a[i][j];
		}
	}
	return matrix_a;
}

void output(std::vector<std::vector<long long>> matrix)
{
	for (auto row : matrix)
	{
		int roop = 0;
		for (auto element : row)
		{
			if (roop!=0)
			{
				std::cout << " ";
			}
			std::cout << element;
			roop++;
		}
		std::cout << std::endl;
	}
}




Measured memory_bytes: 3176