akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

pair<string, int> Q[100005], x;
int n, head = 0, tail = 0, timen= 0;

void enqueue(pair<string, int> x){
    Q[tail] = x;
    tail++;
    tail %= n + 1;
}

pair<string, int> dequeue(){
    pair<string, int> res = Q[head];
    head++;
    head %= n + 1;
    return res;
}

int main(){
    int q, t, p = 0;
    string name;
    cin >> n >> q;
    for(int i = 0; i < n; i++){
        cin >> name >> t;
        enqueue(make_pair(name, t));
    }
    while(head != tail){
        x = dequeue();
        if(x.second - q <= 0){
            timen += x.second - q < 0 ? x.second : q;
            cout << x.first << " " << timen << endl;
        }
        else{
            timen += q;
            x.second -= q;
            enqueue(x);
        }
    }
    return 0;
}


Measured memory_bytes: 7064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10)
        cout<<a*b<<'\n';
    else
        cout<<-1<<'\n';


}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){

  int a=1;
  int b=1;

  for(a=1;a<10;a++){
  
    for(b=1;b<10;b++){

      cout << a <<"x"<<b<<"="<<a*b << endl;
    }
  }
  
  return 0;
}

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

int main() {
    string s; cin >> s;
    string t;
    for (int i = 0; i < s.size(); i++)
    {
        if(t.size()>0 && t[t.size()-1] != s[i]){
            t.erase(t.end()-1);
        } else {
            t += s[i];
        }
    }
    cout << s.size() - t.size() << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    if(a%2 == b%2)
        cout << (a+b)/2 << endl;
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  string t; for (char c : s) if (c != 'x') t += c;
  int n = s.size(), tn = t.size();
  for (int i = 0; i < tn; i++) if (t[i] != t[tn - 1 - i]) return cout << -1 << '\n', 0;
  int l = 0, r = n - 1, p = 0, res = 0;
  while (l < r and p < tn) {
    int dl = l;
    while (s[l] != t[p]) l++;
    dl = l - dl;
    int dr = r;
    while (s[r] != t[p]) r--;
    dr = dr - r;
    l++, r--, p++;
    res += abs(dl - dr);
  }
  cout << res << '\n';
}

Measured memory_bytes: 592
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 185+5;
int n, m, s[N][N], f[2][N][N][N]; char a[N][N];
bool chk(int a, int b, int c, int d) 
{
    int x = (c-a+1)*(d-b+1), y = s[c][d]+s[a-1][b-1]-s[a-1][d]-s[c][b-1];
    return x == y||!y;
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) scanf("%s", a[i]+1);
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) s[i][j] = s[i][j-1]+s[i-1][j]-s[i-1][j-1]+(a[i][j] == '#');
    for(int x = 0; x < 2; ++x) for(int i = 1; i <= n+1; ++i) for(int k = 1; k <= m; ++k) f[x][i][i-1][k] = m;
    for(int i = 1; i <= n; ++i) for(int j = i; j <= n; ++j) for(int k = m; k; --k)
    {
        f[0][i][j][k] = k == m?m:f[0][i][j][k+1];
        while(!chk(i, k, j, f[0][i][j][k])) --f[0][i][j][k];
    }
    for(int y = 1; ; ++y)
    {
        int x = y&1; if(f[!x][1][n][1] == m) return printf("%d\n", y-1), 0;
        for(int i = 1; i <= n; ++i) for(int j = i; j <= n; ++j) for(int k = 1; k <= m; ++k)
            f[x][i][j][k] = f[!x][i][j][f[!x][i][j][k]+1];
        for(int i = 1; i <= n; ++i) for(int k = 1; k <= m; ++k) for(int p = i, j = i; j <= n; ++j)
        {
            while(p < j&&min(f[!x][i][p][k], f[!x][p+1][j][k]) <= min(f[!x][i][p+1][k], f[!x][p+2][j][k])) ++p;
            f[x][i][j][k] = max(f[x][i][j][k], min(f[!x][i][p][k], f[!x][p+1][j][k]));
        }
    }
    return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

int main()
{
    FAST
    int n;
    cin>>n;
    char arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    ll ans=0;
    vector<ll> v[4];
    for(int i=0; i<n; i++)
    {
        if(arr[i]=='B')
            v[0].push_back(i);
        if(arr[i]=='R')
            v[1].push_back(i);
        if(arr[i]=='G')
            v[2].push_back(i);
    }
    ans=(ll)((ll)v[0].size()*(ll)v[1].size()*(ll)v[2].size());
    if(!ans)
        return cout<<0,0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            if(arr[i]==arr[j])
                continue;
            int seq[26]= {0};
            seq[arr[i]-'A']=1;
            seq[arr[j]-'A']=1;
            int temp=0;
            if(!seq[1])
                temp=0;
            else if(!seq['R'-'A'])
                temp=1;
            else
                temp=2;
            ll dif=j-i;
            vector<ll>::iterator it=lower_bound(v[temp].begin(),v[temp].end(),j+dif);
            if(*it==j+dif)
                ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3672
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));

        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        solve(1, in, out);

//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for (int qq = 0; qq < q; qq++) {
            int N = in.nextInt(), K = in.nextInt();
            int[] a = new int[N];
            for(int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            boolean[] dp = new boolean[K + 1];  //dp[i]: the current player in turn can win with i stones left;
            dp[0] = false;

            for(int stones = 1; stones <= K; stones++) {
                for(int i = 0; i < N && a[i] <= stones; i++) {
                    dp[stones] |= !dp[stones - a[i]];
                }
            }
            out.println(dp[K] ? "First" : "Second");
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




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

int main() {
  long long a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;
  
cin >> n >> d;
vector<long long> x(n,0);
vector<long long> y(n,0);
 
for(int i=0;i<n;i++)
{
cin >> x.at(i) >> y.at(i);
if(x.at(i)*x.at(i)+y.at(i)*y.at(i)<=d*d)
{
b++;
}

}
	  
cout << b;  
}


Measured memory_bytes: 6424
s = input()
if s[0] != "A":
  print("WA")
  exit()
if  s.find("C") < 2 or s.find("C") == len(s)-1:
  print("WA")
  exit()
if s.count("C") != 1:
  print("WA")
  exit()
s = s.replace("A","",1)
s = s.replace("C","")
if s != s.lower():
  print("WA")
  exit()
print("AC")

Measured memory_bytes: 3064
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,h;
  cin >> a >> b >> h;
  cout << ((a+b)*h)/(2.0) << "\n";
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, K;
  cin >> N >> K;
  int ans = K;
  for(int i = 1; i < N; i++) {
    ans *= (K - 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

int main() 
{
    FAST;
    ll x;
    cin>>x;
    ll y=x/500;
    x=x%500;
    ll ans=1000*y;
    y=x/5;
    ans+=5*y;
    cout<<ans;
    subt;   
    return 0;
}

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

const int maxn=110;

int v[maxn],n;

int main(){
	scanf("%d",&n);	
	int sum1=0,sum2=0;
	for(int i=0;i<n;i++){
		scanf("%d",&v[i]);
		sum2+=v[i];
	}
	int ans=1e9;
	for(int i=0;i<n;i++){
		sum1+=v[i];
		sum2-=v[i];
		ans=min(ans,abs(sum2-sum1));
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
  long a, b, c, x, y;
  scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
  printf("%lld\n", std::min(x, y) * std::min(a + b, 2 * c) + (x > y ? (x - std::min(x, y)) * std::min(a, 2 * c) : (y - std::min(x, y)) * std::min(b, 2 * c)));
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,t[100001],x,ans;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&x);
		if(x>n) ans++;
		else t[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!t[i]) continue;
		if(t[i]<i) ans+=t[i];
		if(t[i]>i) ans+=t[i]-i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	string s;
	cin >> s;
	int a, z;
	for (int i = 0; ; i++)
		if (s[i] == 'A') {
			a = i;
			break;
		}
	for (int i = s.size(); ; i--)
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)

int main(void){
    ll n;
    cin>>n;
    vector<ll>C((ll)1e6);
    rep(0,i,(ll)1e6)C[i]=0;
    ll s=0;
    rep(0,i,n){
        ll a;
        cin>>a;
        ++C[a];
        s+=a;
    }
    ll q;
    cin>>q;
    rep(0,i,q){
        ll b,c;
        cin>>b>>c;
        s+=(c-b)*C[b];
        C[c]+=C[b];
        C[b]=0;
        cout<<s<<endl;
    }
}

Measured memory_bytes: 11140
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    string s;cin>> s;
    int ss=s.size();
    while(true){
        s.erase(ss-1,1);
        ss=s.size();
        if(ss%2==1)continue;
        string sss = s.substr(ss/2,ss/2);
        if(sss==s.substr(0,ss/2)){cout << ss << endl;return 0;}
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 100
 
vector<int> p, q, r, b;

bool dfs(int v, int val)
{
    int l = p[v] + q[v];
    if (val % l != 0) {
        return 0;
    }
    bool can = 1;
    if (r[v] >= 0) {
        can &= dfs(r[v], val/l*q[v]); 
    } 
        
    if (b[v] >= 0) {
        can &= dfs(b[v], val/l*p[v]); 
    }       
    return can;
}
 
void init(int N)
{
    p.resize(N); q.resize(N);
    r.resize(N); b.resize(N);
}

int main()
{
    int N;
    while (cin >> N, N) {
        init(N);
        int mx = 0;
        bool used[MAX_N] = {};
        for (int i = 0; i < N; i++) {
            cin >> p[i] >> q[i] >> r[i] >> b[i];
            r[i]--; b[i]--;
            if (r[i] >= 0) used[r[i]] = 1;
            if (b[i] >= 0) used[b[i]] = 1;
            int gcd = __gcd(p[i], q[i]);
            p[i] /= gcd; q[i] /= gcd;
            mx = max(mx, p[i] + q[i]);
        }
        int par = -1;
        for (int i = 0; i < N; i++) {
            if (!used[i]) {
                par = i;
                break;
            }
        }
        for (int i = mx; ; i += mx) {
            if (dfs(par, i)) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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


int main(){
  int n,i;
  cin >> n;
  vector<int> x(n);
  for(i=0;i<n;++i){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  int mid=n/2;
  int ans=0;
  for(i=0;i<n;++i){
    ans+=(x[i]-x[mid])*(x[i]-x[mid]);
  }
  int cal1=0;
  int cal2=0;
  int mid2=x[mid]+1;
  for(i=0;i<n;++i){
    cal1+=(x[i]-mid2)*(x[i]-mid2);
  }
  mid=x[mid]-1;
  for(i=0;i<n;++i){
    cal2+=(x[i]-mid)*(x[i]-mid);
  }
  mid2++;
  if(ans>cal1){
    while(ans>cal1){
      ans=cal1;
      cal1=0;
      for(i=0;i<n;++i){
        cal1+=(x[i]-mid2)*(x[i]-mid2);
      }
      mid2++;
    }
  }
  if(ans>cal2){
    mid--;
    while(ans>cal2){
      ans=cal2;
      cal2=0;
      for(i=0;i<n;++i){
        cal2+=(x[i]-mid)*(x[i]-mid);
      }
      mid--;
    }
  }


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


Measured memory_bytes: 256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int t[503][503];
int sum[503][503];

signed main() {
	int n;
	int m;
	int q;

	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		t[a][b]++;
	}
	for (int i = 0; i < 503; i++) {
		int s = 0;
		for (int j = i; j < 503; j++) {
			s += t[i][j];
			sum[i][j] = s;
		}
	}

	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		int ans = 0;
		for (int j = a; j <= b; j++) {
			ans += sum[j][b];
		}
		cout << ans NL;
	}


	return 0;
}



Measured memory_bytes: 2944
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N;i++)	cin>>d[i];
  map<int,int> mp;
  for(int i=0;i<N;i++){
    mp[d[i]]++;
  }
  int res=0;
  for(auto itr=mp.begin();itr!=mp.end();++itr){
    res++;
  }
  cout<<res<<endl;
}
  
  
  

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

int main(void) {
    int h,w;
    string s;
    int c[26];
    string alp = "abcdefghijklmnopqrstuvwxyz";
    cin >> h >> w;
    for (int i=0; i<26; i++){
        c[i] = 0;
    }
    for (int i=0; i<h; i++){
        cin >> s;
        for (int j=0; j<w; j++){
            c[alp.find(s[j])]++;
        }
    }
    int t = 0;
    int u = 0;
    int v = 0;
    int x = 0;
    if (h%2+w%2==0) {
        for (int i=0; i<26; i++){
            t += c[i]%4;
        }
        if (t > 0) {
            cout << "No";
        } else {
            cout << "Yes";
        }
    } else if (h%2==0 && w%2==1) {
        for (int i=0; i<26; i++){
            if (c[i]%4 != 0){
                t++;
                if (c[i]%2 == 0){
                    u++;
                } else {
                    v++;
                }
            }
        }
        if (t==0) {
            cout << "Yes";
        } else {
            if (u<=(h/2) && v==0){
                cout << "Yes";
            } else {
                cout << "No";
            }
        }
    } else if (h%2==1 && w%2==0) {
        for (int i=0; i<26; i++){
            if (c[i]%4 != 0){
                t++;
                if (c[i]%2 == 0){
                    u++;
                } else {
                    v++;
                }
            }
        }
        if (t==0) {
            cout << "Yes";
        } else {
            if (u<=(w/2) && v==0){
                cout << "Yes";
            } else {
                cout << "No";
            }
        }
    } else if (h%2+w%2==2) {
        for (int i=0; i<26; i++){
            if (c[i]%4 == 0){
                t++;
            } else if (c[i]%4 == 1){
                u++;
            } else if (c[i]%4 == 2){
                v++;
            } else if (c[i]%4 == 3){
                x++;
            }
        }
        if ((u+v+x)==0) {
            cout << "Yes";
        } else {
            if ((u+x)==1) {
                if (u==1) {
                    if (v<=(h-1)/2+(w-1)/2){
                        cout << "Yes";
                    } else {
                        cout << "No";
                    }
                } else {
                    if (v<=(h-1)/2+(w-1)/2-1){
                        cout << "Yes";
                    } else {
                        cout << "No";
                    }
                }
            } else {
                cout << "No";
            }
        }
    }
    cout << endl;
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<vector<char>> cell(H, vector<char>(W));
    Vi hs, ws;
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) {
            cell[i][j] = S[j];
            if (S[j] == '#') {
                hs.emplace_back(i);
                ws.emplace_back(j);
            }
        }
    }

    sort(hs.begin(), hs.end());
    sort(ws.begin(), ws.end());

    hs.erase(unique(hs.begin(), hs.end()), hs.end());
    ws.erase(unique(ws.begin(), ws.end()), ws.end());

    for (const auto& h : hs) {
        for (const auto& w : ws) {
            cout << cell[h][w];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif

template<typename T>
T& ckmin(T& a, T b){ return a = a > b ? b : a; }

template<typename T>
T& ckmax(T& a, T b){ return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
	
	ll n;
	cin >> n;
	int a = 0;
	for(ll i = 2; i * i <= n; i++){
		debug(i, n);
		int c = 0;
		for(; n % i == 0; n /= i) c++;
		for(int j = 1; c >= j; j++, a++) c -= j;
	}
		
	a += n != 1;

	cout << a << '\n';

    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a,b[2],c[2],d[2];
    string bb,cc,dd,s[2];
    s[0]="+";
    s[1]="-";
    cin>>a;
    b[0]=(a/100)%10;
    b[1]=(-1)*b[0];
    c[0]=(a/10)%10;
    c[1]=(-1)*c[0];
    d[0]=a%10;
    d[1]=(-1)*d[0];
    a/=1000;
    f(i,0,2){
        f(j,0,2){
            f(k,0,2){
                if(a+b[i]+c[j]+d[k]==7){
                    bb=s[i];
                    cc=s[j];
                    dd=s[k];
                    break;
                }
            }
        }
    }
    cout<<a<<bb<<b[0]<<cc<<c[0]<<dd<<d[0]<<"="<<7<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<numeric>
using i64=long long;
const int N=300007;
int a[N],b[N],f[N],g[N],fa[N],s[N],t[N],vis[N];
int read(){int x;scanf("%d",&x);return x;}
int find(int x){return x==fa[x]? x:fa[x]=find(fa[x]);}
void merge(int x,int y){fa[find(x)]=find(y);}
int main()
{
    int n=read(),m=read();i64 ans=0;std::iota(fa+1,fa+n*3+1,1);
    for(int i=1;i<=m;++i) ++f[a[i]=read()],++g[b[i]=read()],merge(a[i],b[i]+n),merge(a[i]+n,b[i]+n+n),merge(a[i]+n+n,b[i]);
    for(int i=1;i<=n;++i) if(++s[find(i)],++t[find(i+n)],f[i]&&g[i]) vis[find(i)]=vis[find(i+n)]=vis[find(i+n+n)]=1;
    for(int i=1;i<=n*3;++i) if(find(i)==i&&vis[i]) ans+=1ll*s[i]*t[i];
    for(int i=1;i<=m;++i) ans+=!vis[find(a[i])];
    printf("%lld\n",ans);
}

Measured memory_bytes: 8704
#include<iostream>
using namespace std;
int main() {
    int a, b;
    cin>>a>>b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6 && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int N,T,A;
	int num = 0;
	int H[1100] = {};
	double min = 1000000;
	scanf("%d",&N);
	scanf("%d",&T);
	scanf("%d",&A);
	for (int i = 1; i <= N; ++i){
		scanf("%d",&H[i]);
		double temp = T - H[i] * 0.006;
		//printf("%lf\n",temp);
		double diff = fabs(A - temp);
		//printf("%lf\n",diff);
		if (min > diff){
		    min = diff;
			num = i;
		}
	}
	printf("%d\n",num);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int n,k;
vector<int> G[N];
int lvl[N];
vector<int> par;
int s=0;
int dfs(int v,int l){
  int pv=-1;
  if(l>k) pv=l-k+1;
  REP(i,G[v].size()){
    int to=G[v][i];
    int k=dfs(to,l+1);
    if(k!=-1) {
      pv=max(pv,k);
    }
  }
  //printf("%d %d\n",v+1,pv);
  if(pv==l){
    s++; pv=-1;
    //printf("%d\n",v+1);
  }
  return pv;
}
int main(){
  scanf("%d%d",&n,&k);
  
  REP(i,n){
    int x; scanf("%d",&x);
    x--;
    if(i==0) s+=(x!=0);
    else G[x].pb(i);
  }
  dfs(0,0);
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 33024
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<stack>
#include<vector>
//#include<conio.h>
#include<string>
#include<map>
#include<cstdlib>
#include<queue>
#include<math.h>
#include<time.h>
#include<set>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
using namespace std;
inline int read(){
	int ans=0,flag=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
	if(ch=='-') flag=-1,ch=getchar();
	while(ch>='0'&&ch<='9'){
		ans=(ans<<1)+(ans<<3)+(ch^'0');
		ch=getchar();
	}
	return ans*flag;
}
int n,p[3][101],f[3][101];
int main(){
	n=read();
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++) p[i][j]=read();
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++) f[i][j]=max(f[i-1][j],f[i][j-1])+p[i][j];
	printf("%d\n",f[2][n]);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
import bisect
for i in range(N-2):
    
    for j in range(i,N-1):
        if i==j:
            continue
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L,a+b)
        l = bisect.bisect_left(L,b-a)
        ans += k-max(j+1,l)
print(ans)


Measured memory_bytes: 47028
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d,e;
int main() {
	cin>>n;
	e=n%10;
	d=e;
	n=n/10;
	e=0;
	e=n%10;
	c=e;
	n=n/10;
	e=0;
	e=n%10;
	b=e;
	n=n/10;
	e=0;
	e=n%10;
	a=e;
	if(a==b&&b==c){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(b==c&&c==d){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s;
	cin >> s;

	bool OK = true;
	for (int ii = 0; ii < s.size(); ++ii){
		if (ii % 2 == 1){
			if ( (s[ii]!='L') && (s[ii]!='U') && (s[ii]!='D')){
				OK = false;
				break;
			}
		} else{
			if ( (s[ii]!='R') && (s[ii]!='U') && (s[ii]!='D')){
				OK = false;
				break;
			}

		}
	}

	if (OK){
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";		
	}


	return 0;
}


Measured memory_bytes: 256
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    k = max(get_int(), get_int())
    n = get_int()
    print((n+k-1)//k)


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
#print(*out, sep='\n')


Measured memory_bytes: 3436
N,K=map(int,input().split())

# まずKこちょうどを選ぶとして，Kこの選び方はN_C_K通り，これについて実際の和を計算して同じものを省いていくととてつもなくめんどくさい
count=0
for i in range(K,N+1+1):
    count+=1
    yoyu=N-i
    count += (N+1-i)*i % (10**9+7)
    count %= (10**9+7)
print(count)


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <functional>
#include <cmath>
#include <map>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int a[50][50];
int main() {
	int h, w; cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j];
	ll Min = 1LL << 60;
	rep(i, h)rep(j, w) {
		ll sum = 0;
		rep(k, h)rep(t, w) {
			sum += min(abs(k - i), abs(j - t))*a[k][t];
		}
		Min = min(Min, sum);
	}
	cout << Min << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Bingo | diff Bingo.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Bingo.cpp && ./a.out

/*
 
 3/1/2020
 
 8:31-
 
 */

const int MAX_N=100+1;
int A[3][3],B[MAX_N];
int N;

void yes() { cout<<"Yes"<<endl; exit(0); }
void solve() {
  auto ok=[&](int i, int j) -> bool {
    return A[i][j]==-1;
  };
  REP(i,N) REP(j,3)REP(k,3) if(A[j][k]==B[i]) A[j][k]=-1;
  REP(i,3) {
    if(ok(i,0)&&ok(i,1)&&ok(i,2)) yes();
    if(ok(0,i)&&ok(1,i)&&ok(2,i)) yes();
  }
  if(ok(0,0)&&ok(1,1)&&ok(2,2)) yes();
  if(ok(0,2)&&ok(1,1)&&ok(2,0)) yes();
  cout<<"No"<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  REP(i,3) REP(j,3)cin>>A[i][j];
  cin>>N;
  REP(i,N) cin>>B[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    if(A>=K) {
        cout << K;
    } else {
        K -= A;
        if(B>=K) {
            cout << A;
        } else {
            K -= B;
            cout << A-K;
        }
    }

    return 0;
    
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<utility>//swapでaとbの値を入れ替える
using namespace std;
#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 reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;


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




Measured memory_bytes: 1024
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = sorted(x)
keep = []
ans = 0
for i in range(m - 1):
    keep.append(y[i + 1] - y[i])
keep = sorted(keep)
for i in range(max(0, m - n)):
    ans += keep[i]
print(ans)


Measured memory_bytes: 13968
import java.util.*;

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

        int N = s.nextInt();
        String answer = "No";

        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (j * i == N) {
                    answer = "Yes";
                    break;
                }
            }
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

int N; cin >> N;
VI A(N); invec(A);
VI cnt(3, 0); // 012 = RBG
i64 ans = 1;
rep(i, 0, N){
    int m = count(ALL(cnt), A[i]);
    (ans *= m) %= MOD;
    rep(j, 0, 3) if (cnt[j] == A[i]){
        ++cnt[j];
        break;
    }
}
cout << ans << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1024
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

int d[127];
int main() {
    int N;
    string S1,S2;
    ll ans=3LL;
    cin >> N >>S1 >> S2;
    Fill(d,INFint);

    int s_cur=0;
    int d_base=0;
    while(s_cur != N){
        if(S1[s_cur]!=S2[s_cur]){
            d[d_base]=2;
            s_cur+=2;
            d_base++;
        }else{
            d[d_base]=1;
            s_cur+=1;
            d_base++;
        }
    }

    if(d[0]==2){
        ans=6;
    }else{
        ans=3;
    }

    for(int i=1; i<d_base; i++){
        if(d[i-1]==1 && d[i]==1){
            ans*=2;
            ans%=MOD;
        }else if(d[i-1]==1 && d[i]==2){
            ans*=2;
            ans%=MOD;
        }else if(d[i-1]==2 && d[i]==1){
            ;
        }else if(d[i-1]==2 && d[i]==2){
            ans*=3;
            ans%=MOD;
        }
    }

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


Measured memory_bytes: 256
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N,M;cin>>N>>M;vector<int>df(N+1);for(int i=0;i<M;i++){int L,R;cin>>L>>R;df[L-1]++;df[R]--;}vector<int>cnt(N+1);partial_sum(df.begin(),df.end(),cnt.begin());assert(cnt[N]==0);int res=0;for(int i=0;i<N;i++){if(cnt[i]==M)res++;}cout<<res<<endl;}


Measured memory_bytes: 1024
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    ilist = []

    t = n
    while t > 0:
        ilist.append(t)
        t -= 2
    if t == -1:
        t = 2
    else:
        t = 1
    while t < n:
        ilist.append(t)
        t += 2
    
    print(" ".join(str(a[i - 1]) for i in ilist))


main()

Measured memory_bytes: 36164
#include <bits/stdc++.h>
using namespace std;
const int N=3e3+10;

int dp[N][N];
 
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=1+dp[i][j];
            }else{
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
            
        }
    }
    string ans="";
    int i=n;
    int j=m;
    while(i>0 and j>0){
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--,j--;
        }else if(dp[i-1][j]==dp[i][j]){
            i--;
        }else{
            j--;
        }
   
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<'\n';
}

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

bamboos = []
for _ in range(N):
    l = int(input())
    bamboos.append(l)
    
import copy

def dfs(i, bs):
    if i == len(bamboos):
        #print(bs)
        if not bs['A'] or not bs['B'] or not bs['C']:
            return []
        return [bs]
    ret = []
    tmp = copy.deepcopy(bs)
    tmp['A'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['B'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['C'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    tmp = copy.deepcopy(bs)
    tmp['D'].append(bamboos[i])
    ret.extend(dfs(i+1, tmp))
    
    return ret

ABC = {'A': A, 'B': B, 'C': C}
bs_comb = dfs(0, {'A':[],'B':[],'C':[],'D':[]})

import sys
ans = sys.maxsize
for bs in bs_comb:
    cost = 0
    for abc in ['A', 'B', 'C']:
        cost += (len(bs[abc]) - 1) * 10
        cost += abs(sum(bs[abc]) - ABC[abc])
    ans = min(ans, cost)
print(ans)



Measured memory_bytes: 38592
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
string addDigit(string s){
    while(s.size() < 6){
        s = "0"+s;
    }
    return s;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> inp;
    map<int,vector<int>> mp;
    for(int i = 0; i < m; ++i){
        int p,y;
        cin >> p >> y;
        inp.push_back(make_pair(p,y));
        mp[p].push_back(y);
    }
    map<pair<int,int>, string> mp2;
    for(auto it = mp.begin(); it != mp.end(); ++it){
        vector<int> vec = it->second;
        sort(vec.begin(),vec.end());
        string s = addDigit(to_string(it->first));
        for(int i = 0; i < vec.size(); ++i){
            string t = addDigit(to_string(i+1));
            mp2[make_pair(it->first,vec[i])] = s+t;
        }
    }
    for(pair<int,int> p:inp){
        cout << mp2[p] << endl;
    }
    return 0;
}

Measured memory_bytes: 22628
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

//最大公約数
ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}

int main(int argc, char const *argv[]) {
  ll n,X,x[100010];
  std::cin >> n >> X;
  for(int i=0; i<n; i++){
    ll p; std::cin >> p;
    x[i]=abs(X-p);
  }

  ll ans=gcd(x[0],x[1]);

  for(int i=2; i<n; i++){
    ans=gcd(ans,x[i]);
  }

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 1024
<?php
list($a, $b, $c, $x, $y) = explode(" ", trim(fgets(STDIN)));

$case1 = $a * $x + $b * $y;

if ($x <= $y) {
    $case2 = $b * ($y - $x) + $c * 2 * $x;
} else {
    $case2 = $a * ($x - $y) + $c * 2 * $y;
}

if ($x <= $y) {
    $case3 = $c * 2 * $y;
} else {
    $case3 = $c * 2 * $x;
}

echo min($case1, $case2, $case3);

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define fios ios_base::sync_with_stdio(false); cin.tie(0);
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define ll long long
#define nl "\n"
using namespace std;


int main()
{
    int n,br=0,x=1;
    cin>>n;

    int a[n],i;

    for(i=0; i<n; i++)
    {
        cin>>a[i];

        if(a[i]!=x)
            br++;
        else
            x++;
    }
    if(x==1)
        cout<<-1<<nl;
    else
        cout<<br<<nl;

    return 0;
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 0;
  if(A == B) ans = C;
  else if(B == C) ans = A;
  else if(C == A) ans = B;

  cout << ans; 
  return 0;
}



Measured memory_bytes: 256
<?php

	fscanf(STDIN, "%d %d %d", $N, $K, $Q);
	
	$score_array = array();
	for ($i = 0; $i < $N; $i++) {
      $score_array[] = 0;
    }

	for ($i = 0; $i < $Q; $i++) {
      fscanf(STDIN, "%d", $A);
      $score_array[$A-1]++;
    }

	for ($i = 0; $i < $N; $i++) {
      if (($K - $Q + $score_array[$i]) > 0) {
        echo ('Yes'."\n");
      } else {
        echo ('No'."\n");
      }
    }
?>

Measured memory_bytes: 18420
let rec p x y=function|[]->true|z::_ when x>z&&y>z->false|z::r when x<z&&y>z->p z y r|z::r when x>z&&y<z->p x z r|z::r when x<z&&y<z->p x z r||p z y r|_->false;;for i=1to read_int()do print_endline(if p 0 0(List.map int_of_string(Str.split(Str.regexp" ")(read_line())))then"YES"else"NO")done

Measured memory_bytes: 2028
def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n % b

n = int(input())
s = int(input())
if n == s:
    print(n + 1)
    exit()
    
for i in range(2, int(n**0.5) + 3):
    if f(i, n) == s:
        print(i)
        exit()

ans = 10**13
for k in range(1, int(n**0.5) + 3):
    if (n-s) % k != 0 or n-s < 0:
        continue
    b = (n-s)//k + 1
    if b == 1:
        continue
    if f(b, n) == s:
        ans = min(b, ans)

if ans != 10**13:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 41456
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	char a; scanf("%c", &a);
	
	if(a == 'a' or a == 'e' or a == 'i' or a == 'u' or a == 'o') printf("vowel\n");
	else printf("consonant\n");
	return 0;
}


Measured memory_bytes: 256