akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    string O,E; cin>>O>>E;
    REP(i,O.size()){
        cout<<O[i];
        if(i<E.size()) cout<<E[i];
    }
}



Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
a, b, k = map(int, input().split())
max_yakusuu = gcd(a, b)
yakusuu_array = []
for i in range(1,max_yakusuu):
  if max_yakusuu % i == 0:
    yakusuu_array.append(i)
if k!=1:
  print(yakusuu_array[len(yakusuu_array)-k+1])
else:
  print(max_yakusuu)

Measured memory_bytes: 3064
def main():
    n = int(input())
    a = []
    dp = [[0 for _ in range(3)] for _ in range(n)]
    for _ in range(n):
        a.append(list(map(int, input().split())))
    for i in range(3):
        dp[0][i] = a[0][i]
    for i in range(n-1):
        dp[i+1][0] = max(dp[i][1]+a[i+1][0], dp[i][2] + a[i+1][0])
        dp[i+1][1] = max(dp[i][0]+a[i+1][1], dp[i][2] + a[i+1][1])
        dp[i+1][2] = max(dp[i][0]+a[i+1][2], dp[i][1] + a[i+1][2])

    print(max(dp[-1]))

if __name__ == '__main__':
    main()



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

int keta(int n) {
  ll k = 1, i = 0;
  while (k <= n) {
    k = k * 10;
    ++i;
  }
  return i;
}

int main() {
  ll n, i, tmp = 1;
  cin >> n;
  for (i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      tmp = i;
    }
  }
  ll m = n / tmp;
  cout << keta(m) << "\n";
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var k = vals[1];
        var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var min = int.MaxValue;

        for (int i = 0; i <= n - k; i++)
        {
            var time1 = 0;
            if (x[i] < 0)
            {
                time1 = Math.Abs(x[i]);
            }
            var time2 = 0;
            if (x[i+k-1] > 0)
            {
                time2 = Math.Abs(x[i + k - 1]);
            }

            var time = time1 + time2 + Math.Min(time1, time2);
            min = Math.Min(time, min);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 23008
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	while(n--){
		ll y,m,d; cin >> y >> m >> d;
		ll ans = d;
		REP(i,1,y){
			if(i%3 == 0) ans += 200;
			else ans += 195;
		}
		REP(i,1,m){
			if(i%2==0 && y%3!=0){
				ans += 19;
			}else{
				ans += 20;
			}
		}
		cout << 196471 - ans << endl;
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
int n;
int ans[200005];
P a[200005];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i].F);
        a[i].S=i;
    }
    sort(a,a+n);
    int x=a[(n-1)/2].F,y=a[n/2].F;
    for(int i=0;i<=(n-1)/2;i++)ans[a[i].S]=y;
    for(int i=n/2;i<n;i++)ans[a[i].S]=x;
    for(int i=0;i<n;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

int main(){
    int n,k;
    long long ans=0;
    cin >> n >>k;
    vector<long> v(n);
    for(auto & e :v){
        cin >> e;
    }
    sort(v.begin(),v.end());
    if(k>n) k=n;
    for(int i=0; i<n-k;i++){
        ans+=v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def ascan; gets.split.map(&:to_i);end

n,k = (gets+gets).split.map(&:to_i)

best = 5e15
(0..1).to_a.repeated_permutation(n) do |arr|
    x = 1
    arr.each do |op|
        x*=2 if op == 0
        x+=k if op == 1
    end
    best = [x,best].min
end

p best

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

int main() {
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;
    cout << arr[K - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

void dfs(int curr, vector<int> adj[], vector<bool>& vis) {
	vis[curr] = true;
	for (int node : adj[curr]) {
		if (!vis[node])
			dfs(node, adj, vis);
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n, m, a, b;
	cin >> n >> m;
	vector<int> adj[n + 1];
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	vector<bool> vis(n + 1, false);
	int count = 0;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			count++;
			dfs(i, adj, vis);
		}
	}
	cout << count - 1 << endl;
	return 0;
}

Measured memory_bytes: 10684
N = int(input())
c = 0
ind = []
p = 0

for i,v in enumerate(input().split()):
    i = i+1
    if i == int(v):
        c += 1
        ind.append(i)

if len(ind) >= 3:
    i = 1
    while i <= len(ind) - 1:
        if ind[i-1]+1 == ind[i]:
            p+=1
            i += 2
        elif (i+1) <= (len(ind) - 1) and ind[i] + 1 == ind[i+1]:
            p += 1
            i += 3
        else:
            i += 1
elif len(ind) == 2 and ind[0] +1 == ind[1]:
    p += 1

if c == 0:
    print(0)
elif p == 0:
    print(c)
else:
    print(c-p)


Measured memory_bytes: 13956
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int H,W,K;
  cin>>H>>W>>K;
  vector<string>s(H);
  for(int i=0;i<H;i++){
    cin>>s[i];
  }
  vector<vector<int>>ans(H,vector<int>(W));
  int k=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#'){ans[i][j]=k;k++;}
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j>0&&ans[i][j]==0){ans[i][j]=ans[i][j-1];}
    }
  }
  for(int i=0;i<H;i++){
    for(int j=W-1;j>=0;j--){
      if(j<W-1&&ans[i][j]==0){ans[i][j]=ans[i][j+1];}
    }
  }
  for(int j=0;j<W;j++){
    for(int i=0;i<H;i++){
      if(i>0&&ans[i][j]==0){ans[i][j]=ans[i-1][j];}
    }
  }
  for(int j=0;j<W;j++){
    for(int i=H-1;i>=0;i--){
      if(i<H-1&&ans[i][j]==0){ans[i][j]=ans[i+1][j];}
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<ans[i][j];
      if(j<W-1){cout<<" ";}
    }
    cout<<endl;
  }
  return 0;  
}


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

using namespace std;

namespace {
    int N;
    vector<string> T, A, D;
    int Q;

    const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int days_leap[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    bool is_leap(int y) {
        if (y % 400 == 0) return true;
        if (y % 100 == 0) return false;
        if (y % 4 == 0) return true;
        return false;
    }

    int date(const string& s) {
        int y, m, d;
        sscanf(s.c_str(), "%d/%d/%d", &y, &m, &d);
        int ret = 365 * y;
        ret += (y / 400) * 97;
        for (int i = 0; i < y % 400; i++) {
            if (is_leap(i)) ret++;
        }
        bool l = is_leap(y);
        for (int i = 1; i < m; i++) ret += (l ? days_leap : days)[i];
        ret += d;
        return ret;
    }

    bool check(const string& s, const string& key) {
        if (key == "*") return true;
        return s.find(key) != string::npos;
    }

    void query(const string& t, const string& a, const string& froms, const string& tos) {
        int from, to;
        if (froms == "*") from = 0;
        else from = date(froms);
        if (tos == "*") to = date("2040/01/01");
        else to = date(tos);

        for (int i = 0; i < N; i++) {
            if (!check(T[i], t)) continue;
            if (!check(A[i], a)) continue;
            int d = date(D[i]);
            if (!(from <= d && d <= to)) continue;
            cout << T[i] << endl;
        }
    }

    void solve() {
        cin >> N;
        T.resize(N); A.resize(N); D.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> T[i] >> A[i] >> D[i];
        }
        cin >> Q;
        for (int i = 0; i < Q; i++) {
            string t, a, from, to;
            cin >> t >> a >> from >> to;
            if (i != 0) cout << endl;
            query(t, a, from, to);
        }
    }
}

int main() {
    solve();
    return 0;
}

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

int main() {
  int N; cin >> N;
  bool isPossible = true;
  
  vector<vector<int>> routes(N + 1, vector<int>(3));
  routes[0] = {0, 0, 0};
  
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> routes[i][j];
    }
  }
  
  for (int i = 0; i < N; i++) {
    int time = routes[i + 1][0] - routes[i][0];
    int dist = abs(routes[i + 1][1] - routes[i][1]) + 
               abs(routes[i + 1][2] - routes[i][2]);
    if (dist > time || dist % 2 != time % 2) {
      isPossible = false;
      break;
    }
  }
  
  if (isPossible) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int M=1e6+7;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
char s[M];
int n,f,l,r;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int x=1;x<=26;x++){
		int mn=0,sum=0; l=0;
		for(int i=1;i<=n;i++){
			sum--;
			if(s[i]=='a'+x-1) sum+=2;
			if(sum-mn>0&&i-l!=1){f=1; l++; r=i; break;}
			if(sum<mn) mn=sum,l=i;//printf("%d %d\n",x,i);
		}
		if(f) break;
	}
	if(!f) puts("-1 -1");
	else printf("%d %d\n",l,r);
	return 0;
}

Measured memory_bytes: 384
from bisect import bisect_left
N = int(input())
A = [int(input()) for _ in range(N)]


INF = 10 ** 10
dp = [INF] * N
res = 0
for i in range(N):
    idx = bisect_left(dp,A[i])
    dp[idx] = A[i]
print(bisect_left(dp, INF))



Measured memory_bytes: 10472
#include <bits/stdc++.h>
#define rep(I,N) for(int I=0;I<N;I++)
using ll=long long int;
using namespace std;

int main(){
	int n,d;
	int ans=0;
	cin>>n>>d;
	double x[n],y[n],dis[n];
	rep(i,n){
		cin>>x[i]>>y[i];
		dis[i]=sqrt(x[i]*x[i]+y[i]*y[i]);
		if(dis[i]<=d)ans++;

	}
	cout<<ans;	

}


Measured memory_bytes: 8492
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int l = s.length();
    int cs = 0;
    int ct = 0;
    int c = 0;
    for (int i = 0; i < l; i++)
    {
        if(s[i] == 'S')
        {
            cs++;
        }
        else
        {
            if(cs >= 1)
            {
                c++;
            }
            cs = max(0, cs - 1);
        }
    }

    cout << l - c * 2 << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll a,b,c;cin>>a>>b>>c;
  if(a+b>=c)cout<<b+c<<endl;
  else cout<<a+b+b+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=1e5+1;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define sclli(x) scanf("%lld",&x);
#define pii pair<int,int>
#define plli pair<long long int ,lont long int>
#define foit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr);
#define sz(x) x.size()
ll int dp[mex][100];
int main()
{
    
    fast
  ll int n,w;
   cin>>n>>w;
   ll int arr[2][n];
   fo(i,0,n)
   cin>>arr[0][i]>>arr[1][i];
   dp[arr[0][0]][0]=arr[1][0];
   fo(j,1,n)
   fo(i,0,w+1)
   {
        dp[i][j]=max(dp[i][j],dp[i][j-1]);
       if((i-arr[0][j])>=0&&dp[i-arr[0][j]][j-1])
       dp[i][j]=max(dp[i-arr[0][j]][j-1]+arr[1][j],dp[i][j]);
       
       dp[arr[0][j]][j]=max(dp[arr[0][j]][j],arr[1][j]);
      
   }
   
    ll int ans=0;
   fo(i,0,w+1) ans=max(ans,dp[i][n-1]);
   cout<<ans;
}

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

int c[10][10];

// 深さ優先探索
// i -> 1 に必要な最小のMP
int minMP( int i, vector<bool> isVisited )
{
    if( i == 1 ) return 0;
    
    isVisited[i] = true;
    int minimum = INT_MAX;
    for( int j = 0; j < 10; ++j ){
        if( !isVisited[j] ){
            minimum = min( minimum, minMP(j, isVisited) + c[i][j] );
        }
    }
    return minimum;
}

int main()
{
    int H, W;
    int A[201][201];

    cin >> H >> W;
    for( int i = 0; i < 10; ++i ){
        for( int j = 0; j < 10; ++j ) cin >> c[i][j];
    }
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ) cin >> A[i][j];
    }


    vector<int> cost(10);  // 0~9 -> 1 と書き換えるために必要な最小のMP
    for( int i = 0; i < 10; ++i ){
        vector<bool> isVisited(10, false);
        cost[i] = minMP( i, isVisited );
    }
    
    int ans = 0;
    for( int i = 0; i < H; i++ ){
        for( int j = 0; j < W; j++ ){
            if( A[i][j] != -1 ) ans += cost[A[i][j]];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val k, x = sc.nextInt
//  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(n)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)

  val min = Math.max(-1000000, x - (k - 1))
  val max = Math.min(1000000, x + (k - 1))

  println((min to max).mkString(" "))

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 167344
n=int(input())
s=input()
t=input()
p=0
i=0
ans=1
while i<n:
	if s[i]==t[i]:
		if p==0:
			ans*=3
		elif p=="x":
			ans*=2
		p="x"
		ans%=(10**9+7)
		i+=1
	else:
		if p==0:
			ans*=6
		elif p=="x":
			ans*=2
		else:
			ans*=3
		p="y"
		ans%=(10**9+7)
		i+=2
print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

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

    if (s.length() == 2) {
        cout << s << endl;
    } else {
        cout << s[2] << s[1] << s[0] << endl;
    }

    return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL a[mx5], mod = 1e9 + 7;

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

    LL n;
    cin >> n;

    for(LL i = 0; i < n; i++){
        LL x;
        cin >> x;

        a[x]++;
    }

    LL N = n + 1;

    if(N % 2 == 0 && a[0] != 1)
        return cout << 0 << '\n', 0;

    for(LL i = N % 2; i < n; i += 2){
        if(i && a[i] != 2)
            return cout << 0 << '\n', 0;
    }

    n /= 2;
    LL ans = 1;

    while(n)
        ans = (ans << 1) % mod, n--;

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 1024
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
    
    
n,m = map(int,input().split())
uf = WeightedUnionFind(n)
ans = True
for i in range(m):
    l,r,d = map(int,input().split())
    if uf.same(l,r)==False:
        uf.union(l,r,d)
    else:
        if abs(uf.diff(l,r))!=d:
            ans = False
            break
print("Yes" if ans else "No")

Measured memory_bytes: 102816
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

K, S = nl()

count = 0
for k1 in range(K+1):
    for k2 in range(K+1):
        k3 = S - (k1 + k2)
        if k3 >= 0 and k3 <= K:
            count += 1

print(count)


Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int mini = M;
    for(int i = -100; i <= 100; i++){
        int cand = 0;
        if(a < i){ cand += (i - a + 1) / 2 + (abs(a - i) & 1); }else if(a > i){ cand += a - i; }
        if(b < i){ cand += (i - b + 1) / 2 + (abs(b - i) & 1); }else if(b > i){ cand += b - i; }
        if(c < i){ cand += (i - c + 1) / 2 + (abs(c - i) & 1); }else if(c > i){ cand += c - i; }
        if(cand < mini){
            // prints(i, mini, cand);
            mini = cand;
        }
    }
    cout << mini << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)
static const int dx[] = {1,-1,0,0} , dy[]={0,0,-1,1};
char data[30][30];
struct P{
	int x,y;
	P(int a,int b){x=a,y=b;}
	bool operator ==(const P& a){ return x == a.x && y == a.y; }
};

int bfs(P s,P g){
	// mèm[hú» , ¢KâÈçÎ-1A»¤ÅÈ¯êÎs©çÌÅZ£
	int done[30][30];
	rep(i,30)rep(j,30)done[i][j] = -1;
	
	queue<P>Q;
	Q.push(s);
	done[s.y][s.x] = 0;
	
	while(Q.size()){
		P q = Q.front(); Q.pop();
		
		if(q == g) return done[g.y][g.x];
		
		rep(i,4){
			P t = P(q.x+dx[i],q.y+dy[i]);
			if(data[t.y][t.x] == 'x' || ~done[t.y][t.x]){
				continue;
			}else{
				done[t.y][t.x] = done[q.y][q.x]+1;
				Q.push(t);
			}
		}
	}
	return INF;
}
int main(){
	int W,H;
	while(cin >> W >> H , W){
		// }bvú»
		rep(i,30)rep(j,30)data[i][j] = 'x';
		
		//@üÍ
		rep(i,H)rep(j,W)
			cin >> data[i+1][j+1];
		
		// {bgEê^CÌÊuEÂæ¾
		P s(0,0);
		vector<P> pos;
		rep(i,30)rep(j,30)
			if(data[i][j] == '*') pos.push_back(P(j,i));
			else if(data[i][j] == 'o')s = P(j,i);
		int n = pos.size();

		// eê^C¯mÌÅZoHðvZµÄ¨­B
		int dist[10][10] = {0};
		rep(i,n)rep(j,n)dist[i][j] = bfs(pos[i],pos[j]);

		// ñZ[X}ú»
		int dp[1<<10][10];
		rep(i,1<<10)rep(j,10)dp[i][j] = INF;
		
		// ñZ[X}
		rep(i,n) dp[1<<i][i] = bfs(s,pos[i]);
		rep(i,1<<n)rep(j,n)rep(k,n)
			dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+dist[j][k]);
		
		// oÍ
		int ans = INF;
		rep(i,n)ans = min(ans,dp[(1<<n)-1][i]);
		cout << (ans<INF?ans:-1) << endl;
	}
}

Measured memory_bytes: 952
#include <bits/stdc++.h>
using namespace std;
int main()
{   int n, b[101], ans=0, a[101];
    cin>>n;
    for (int i=1;i<n;i++)
	{ 	cin>>b[i]; a[i]=b[i];
	}
    b[0]=a[0]=b[1];
    for (int i=n-1;i>1;i--)
    {   if(b[i]<b[i-1])
        {a[i-1]=b[i];
		}
    }
    for (int i=0;i<n;i++)
    {   ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s = "?" + s;
    for(int i = a; i < c; i++) {
        if(s[i] == s[i+1] && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = b; i < d; i++) {
        if(s[i] == s[i+1] && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if(d > c) {
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = b; i <= d; i++) {
        if(s[i] == s[i-1] && s[i] == s[i+1] && s[i] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 720
from math import ceil
N, H = [int(i) for i in input().split()]
A = []
B = []
maxa = -1
for i in range(N):
    a, b = [int(i) for i in input().split()]
    maxa = max(maxa, a)
    A.append(a)
    B.append(b)

sb = []
for b in B:
    if b >= maxa:
        sb.append(b)

sb.sort(reverse=True)

c = 0
for i in sb:
    H -= i
    c += 1
    if H <= 0:
        print(c)
        quit()

print(c+ceil(H/maxa))

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

int main()
{
  char b;
  cin >> b;
  if (b == 'A')
  {
    cout << "T" << endl;
  }
  if (b == 'C')
  {
    cout << "G" << endl;
  }
  if (b == 'T')
  {
    cout << "A" << endl;
  }
  if (b == 'G')
  {
    cout << "C" << endl;
  }
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    string s;
    cin >> s;
    string rest = "";
    for (auto c : s) if (c != 'A') rest += c;
    if (rest == "KIHBR" && s.find("AA") == string::npos && s.find("KIH") != string::npos) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math

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

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

int main(void) {
  int ans, a, b, c;

  cin >> a >> b >> c;
  ans = a+b+c;

  if(ans>=22) cout << "bust" << endl;
  if(ans<=21) cout << "win" << endl;

  return (0);
}


Measured memory_bytes: 256
public class Hello{
    public static void Main(){

        string[] num = System.Console.ReadLine().Split(' ');

        int X = int.Parse(num[0]);
        int A = int.Parse(num[1]);
        int B = int.Parse(num[2]);
        
        if( 0 - A + B <= 0){
            System.Console.WriteLine("delicious");
        }else if(0 - A + B <= X){
            System.Console.WriteLine("safe");
        }else{
            System.Console.WriteLine("dangerous");
        }
    }
}


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

using namespace std;

int n, a[4], t[259];

string c[100005], s;

int main()
{
	ios::sync_with_stdio(false);
	t['A'] = 1, t['B'] = 2, t['C'] = 3;
	cin >> n >> a[1] >> a[2] >> a[3];
	for(int i = 1; i <= n; i++) cin >> c[i];
	if(a[1] + a[2] + a[3] == 0)
	{
		if(n == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if(a[1] + a[2] + a[3] == 1)
	{
		int pre;
		if(a[1]) pre = 1; if(a[2]) pre = 2; if(a[3]) pre = 3;
		bool flag = 0;
		for(int i = 1; i <= n; i++)
		{
			s = c[i];
			int x, y;
			x = t[s[0]], y = t[s[1]];
			if(x != pre && y != pre)
			{
				flag = 1;
			}
			pre = ((x == pre) ? y : x);
		}
		if(flag) cout << "No" << endl;
		else 
		{
			cout << "Yes" << endl;
			if(a[1]) pre = 1; if(a[2]) pre = 2; if(a[3]) pre = 3;
			for(int i = 1; i <= n; i++) 
			{
				s = c[i];
				int x, y;
				x = t[s[0]], y = t[s[1]];
				pre = ((x == pre) ? y : x);
				cout << char('A' + pre - 1) << endl;
			}
		}
	}
	else
	{
		s = c[1];
		int x = t[s[0]], y = t[s[1]];
		if(a[x] == 0 && a[y] == 0) 
		{
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		for(int i = 1; i <= n; i++)
		{
			s = c[i];
			int x = t[s[0]], y = t[s[1]], ans = 0;
			if(a[x] == 0) a[x]++, a[y]--, ans = x;
			else if(a[y] == 0) a[x]--, a[y]++, ans = y;
			else
			{
				if(a[1] + a[2] + a[3] - a[x] - a[y] == 0 && a[x] && a[y] && i != n)
				{
					string nxt = c[i + 1];
					int nx = t[nxt[0]], ny = t[nxt[1]];
					int z = 6 - x - y, nz = 6 - nx - ny;
					if(z != nz)
					{
						if(x == nx || x == ny) a[x]++, a[y]--, ans = x;
						else a[x]--, a[y]++, ans = y;
					}
					else a[x]++, a[y]--, ans = x;
				}
				else a[x]++, a[y]--, ans = x;
			}
			cout << (char)('A' + ans - 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6764
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll ans;
ll N,K;




int main(){
    cin >> N >> K;
    for (ll i = K;i<=N+1;i++){
        ans = (i*(2*N-i+1)/2 -i*(i-1)/2 +1+ ans)%1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    char a;
    char b;

    std::cin >> b;

if(b == 'A'){
    std::cout << "T" << std::endl;
}

if(b == 'C'){
 std::cout << "G" << std::endl;
}

if(b == 'G'){
 std::cout << "C" << std::endl;
}

if(b == 'T'){
 std::cout << "A" << std::endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  while(cin>>n>>m, n|m){
    vector<int> par(n,-1);
    vector<int> sz(n,1);
    vector<long> weight(n,0); // weight[i] : par[i]?????????i??????????????????????

    // <parent-id, weight>
    function<pair<int,long>(int)> find = [&](int i){
      if(par[i]<0) return mp(i, 0L);
      else {
        auto p = find(par[i]);
        weight[i] += p.se;
        par[i] = p.fi;
        return mp(p.fi, weight[i]);
      }
    };

    // j is heavier than i by w.
    auto unite = [&](int i, int j, long w){
      auto pi = find(i), pj = find(j);
      int x = pi.fi, y = pj.fi;
      if(x == y) return;
      if(sz[x] >= sz[y]) {
        par[y] = x;
        weight[y] = pi.se + w - pj.se;
        sz[x] += sz[y];
      }
      else {
        par[x] = y;
        weight[x] = pj.se - w - pi.se;
        sz[y] += sz[x];
      }
    };

    rep(i,m){
      char s[5];
      int a,b;
      cin>>s>>a>>b;
      a--;b--;
      if(s[0]=='?'){
        auto pa = find(a), pb = find(b);
        if(pa.fi == pb.fi) cout << pb.se - pa.se << endl;
        else cout << "UNKNOWN" << endl;
      } else {
        long c;
        cin>>c;
        unite(a,b,c);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 4328
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
using namespace std;


int main() {

	int n;
	double a,b = 0;
	cin >> n;
	//int* a = new int[n];
	for (int i = 0; i < n; i++) {

		cin >> a;
		b += 1 / a;
	}
	cout << 1.0 / b << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b > c * 2)  {
        if (x > y)  {
            x -= y;
            if (a > 2 * c)  cout << 2 * c * y + x * 2 * c;
            else    cout <<  2 * c * y + x * a;
        }   else {
            y -= x;
            if (b > 2 * c)  cout << 2 * c * x + y * 2 * c;
            else    cout << 2 * c * x + y * b;
        }
    }   else    cout << a * x + b * y;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  if(n==1){
    cout<<"Yes"<<endl;
    cout<<2<<endl;
    cout<<"1 1"<<endl;
    cout<<"1 1"<<endl;
    return 0;
  }
  // int x = -1;
  // rep(i,n){
  //   if((i+1)*(i+2) == n*2) x = i+1;  
  // }
  // if(x<0){
  //   cout<<"No"<<endl;
  //   return 0;
  // }
  vector<queue<int>> V(3);
  rep(i,3){
   V[i].push(i+1);
   V[i].push((i+2>3)?(i+2)%3:(i+2)); 
  }
  int k = 3;
  while(k<n){
    int m = sz(V);
    rep(i,m)V[i].push(k+i+1);
    queue<int> q;
    rep(i,m)q.push(k+i+1);
    V.push_back(q);
    k+=m;
  }
  if(k!=n){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  cout<<sz(V)<<endl;
  rep(i,sz(V)){
    cout<<sz(V[i])<<" ";
    while(!V[i].empty()){
      cout<<V[i].front()<<" ";
      V[i].pop();
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector<int> a(n),b(n),c(n-1);
for(int i=0;i<n;i++){
    cin >> a.at(i);
} 
long long ans =0;
for(int i=0;i<n;i++){
    cin >>b.at(i);
    ans+=b.at(i);
}

for(int i=0;i<n-1;i++){
    cin >>c.at(i);
}
int z =0;
 for(int i=1;i<n;i++){     
     if(a.at(i-1)+1==a.at(i)){
         ans+=c.at(a.at(i-1)-1);
         z++;     }
 }
 cout << ans << endl;
}


Measured memory_bytes: 256
//ABC108B.cpp
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int x1,y1,x2,y2,x3,y3,x4,y4,temp1,temp2,temp3,temp4;
	cin>>x1>>y1>>x2>>y2;
/*	if(x2-x1==0){
		if(y2>y1){
			y3=y2;
			y4=y1;
			len=y2-y1;
			x3=x2-len;
			x4=x3;
		}else{
			y3=y2;
			y4=y1;
			len=y1-y2;
			x3=x2+len;
			x4=x3;
		}
	}else{
		if(y2-y1==0){
			if(x1<x2){
				x3=x2;
				x4=x1;
				len=x2-x1;
				y3=y2+len;
				y4=y3;
			}else{
				x3=x2;
				x4=x1;
				len=x1-x2;
				y3=y2-len;
				y4=y3;
			}
		}else{*/
			temp1=x2-x1;
			temp2=y2-y1;
			temp3=-1*temp2;
			temp4=temp1;
			x3=x2+temp3;
			y3=y2+temp4;
			x4=x1+temp3;
			y4=y1+temp4;
/*		}
	}*/
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FORE(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORIT(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define X first
#define Y second
#define ll long long
#define mp make_pair
#define pb push_back
#define all(a) a.begin(),a.end()
#define sqr(x) (x)*(x)
#define endl '\n'

template <typename G> inline void read(G &x)
{
    x = 0; char c;
    while(!isdigit(c = getchar()));
    do{x = x*10 + c - '0';} while(isdigit(c = getchar()));
}

template <typename G> inline void write(G x)
{
    if (x > 9) write(x/10);
    putchar(x%10 + '0');
}

template <class T> inline T min(T a,T b,T c){ return min(a,min(b,c)); }
template <class T> inline T min(T a,T b,T c,T d) { return min(a,min(b,c,d)); }
template <class T> inline T max(T a,T b,T c){ return max(a,max(b,c)); }
template <class T> inline T max(T a,T b,T c,T d) { return max(a,max(b,c,d)); }



const int MAXN = 1e5 * 5;
const int base = 1e9 + 7;
const int N = 5000;


int n;
int cnt;
int a[MAXN],id[MAXN];
ll s[MAXN];

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

    cin>>n;
    FORE(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    s[1] = a[1];
    id[n] = 1;
    FORE(i,2,n)
    {
        if (2*s[i-1] >= a[i]) id[i-1] = 1;
        else id[i-1] = 0;
        //if (i == 3)
            //cout<< s[i-1] <<' '<< a[i] <<endl;
        s[i] = s[i-1] + a[i];
    }
    FORD(i,n,1)
    if (id[i]) ++cnt;
    else break;
    cout<< cnt <<endl;
    return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int[] yOrM = new int[2];
    String[] yymm = {"", ""};
    String ans = "";

    yOrM[0] = S / 100;
    yOrM[1] = S % 100;

    for(int i = 0; i < 2; i++) {
    	if(yOrM[i] <= 12 && yOrM[i] >= 1) {
        	yymm[i] = "MM";
        }
        else if(yOrM[i] > 12 || yOrM[i] == 0) {
        	yymm[i] = "YY";
        } else {
        	yymm[i] = "NA";
        }
    }

    ans = yymm[0] + yymm[1];

    if(ans.equals("MMMM")) {
    	ans = "AMBIGUOUS";
    }
    else if(ans.indexOf("NA") != -1 || ans.equals("YYYY")) {
    	ans = "NA";
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int cnt=0;
	rep(i,n){
		int a;cin >> a;
		if(a%2==0) cnt++;
	}
	if(cnt==n) cout << "second" << endl;
	else cout << "first" << endl;
}

Measured memory_bytes: 256
function f(P,K,D)
	Q=Pair{Int,Int}[]
	while !isempty(P)
		(u,d)=pop!(P)
		if D[(u+1)%K+1]>d+1
			D[(u+1)%K+1]=d+1
			push!(Q,(u+1)%K=>d+1)
		end
		if D[u*10%K+1]>d
			D[u*10%K+1]=d
			push!(P,u*10%K=>d)
		end
	end
	Q
end
function main()
	K=parse(Int,readline())
	P=Pair{Int,Int}[1=>1]
	D=Int[1145141919 for _=0:K]
	D[2]=1
	while !isempty(P)
		(u,d)=shift!(P)
		if D[(u+1)%K+1]>d+1
			D[(u+1)%K+1]=d+1
			push!(P,(u+1)%K=>d+1)
		end
		if D[u*10%K+1]>d
			D[u*10%K+1]=d
			unshift!(P,u*10%K=>d)
		end
	end
	println(D[1])
end
main()

Measured memory_bytes: 113008
s = input()

if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()


if len(s)!=26:
    for i in range(26):
        if chr(97+i) not in s:
            print(s+chr(97+i))
            exit()
else:
    for i in range(25):
        if s[24-i]<s[25-i]:
            m = s[25-i]
            for x in s[25-i:]:
                if x > s[24-i]:
                    m = min(m, x)
            print(s[:24-i]+m)
            exit()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,flag=0;
    cin>>n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
    cin>>arr[i];
    for(i=0;i<n;i++){
        if(arr[i]%2==0){
            if(!(arr[i]%3==0 || arr[i]%5==0))
            {flag++;
            break;
            }
        }
    }
    if(flag==1)
    cout<<"DENIED"<<endl;
    else
    {
        cout<<"APPROVED"<<endl;
    }
    
}

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

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;}

template<class T>
    bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
}
template<class T> 
    bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
}


int main() {
    
    int l = 3005;
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> dp(l, vector<ll>(l, 0));

    //solve LCS
    //dp[i+1][j+1]:s[i]とt[j]までのLCA
    int num = 0;
    rep(i,s.size())rep(j,t.size()){
        if(s[i]==t[j]){
            chmax(dp[i+1][j+1], dp[i][j]+1);
        }
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
        // cout << "i : " << i << " j : " << j << endl;
    }

    string ans = "";
    ll i = s.size(), j = t.size(); 
    while(i > 0 && j > 0){
        if(dp[i][j]==dp[i-1][j]){
            i --;
        }else if(dp[i][j]==dp[i][j-1]){
            j --;
        }else{
            ans = s[i-1] + ans;
            i--; j--;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 70912
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int odddp[2030]={},evendp[2030]={},res=0;
long long int N,M,A,B,C,X,Y,t[10];


int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    for(long long int i = M; i <= N+1; i++){
        res+=i*N-i*(i-1)+1;
    }
    cout<<res%mod<<endl;
}    


Measured memory_bytes: 3628
from collections import Counter as C
N = int(input())
A = [int(a) for a in input().split()]
B = C(A)

if A[0] != 0 or A.count(0) != 1:
    print(0)
else:
    ans = 1
    for i in range(1, max(A) + 1):
        ans = ans * pow(B[i-1], B[i], 998244353) % 998244353
    print(ans)

Measured memory_bytes: 63412
#include <iostream>

int main()
{
    int A, B;
    std::cin >> A >> B;

    int ans = 0;

    if (A < B)
    {
        ans += B--;
    }
    else
    {
        ans += A--;
    }

    if (A < B)
    {
        ans += B--;
    }
    else
    {
        ans += A--;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256